include/vcl/graphicfilter.hxx | 4 ++-- vcl/source/filter/graphicfilter.cxx | 11 ++++++----- vcl/source/graphic/UnoGraphicProvider.cxx | 21 ++++----------------- 3 files changed, 12 insertions(+), 24 deletions(-)
New commits: commit c72b5dd520f2e54c00cdbdaec09cd40f52a9866b Author: Mike Kaganski <[email protected]> AuthorDate: Sat Oct 4 12:26:24 2025 +0200 Commit: Mike Kaganski <[email protected]> CommitDate: Sat Oct 4 13:42:10 2025 +0200 Use Graphic::GetXGraphic instead of explicit use of unographic::Graphic Change-Id: Iba98a11cc7e50b23307beff2e7f9835c2d3a8de1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191855 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/vcl/source/graphic/UnoGraphicProvider.cxx b/vcl/source/graphic/UnoGraphicProvider.cxx index f5efba26320f..0892bd55316f 100644 --- a/vcl/source/graphic/UnoGraphicProvider.cxx +++ b/vcl/source/graphic/UnoGraphicProvider.cxx @@ -187,10 +187,7 @@ uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadMemory( std::u16s if( nGraphicAddress == 0 ) return nullptr; - rtl::Reference<::unographic::Graphic> pUnoGraphic = new ::unographic::Graphic; - - pUnoGraphic->init( *reinterpret_cast< ::Graphic* >( nGraphicAddress ) ); - return pUnoGraphic; + return reinterpret_cast<::Graphic*>(nGraphicAddress)->GetXGraphic(); } uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadRepositoryImage( std::u16string_view rResourceURL ) @@ -408,10 +405,7 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co if (!aPath.isEmpty() && bLoadAsLink) aVCLGraphic.setOriginURL(aPath); - rtl::Reference<::unographic::Graphic> pUnoGraphic = new ::unographic::Graphic; - - pUnoGraphic->init( aVCLGraphic ); - xRet = pUnoGraphic; + xRet = aVCLGraphic.GetXGraphic(); } else{ SAL_WARN("svtools", "Could not create graphic for:" << aPath << " error: " << error); @@ -450,14 +444,8 @@ uno::Sequence< uno::Reference<graphic::XGraphic> > SAL_CALL GraphicProvider::que std::vector< uno::Reference<graphic::XGraphic> > aRet; for (const auto& pGraphic : aGraphics) { - uno::Reference<graphic::XGraphic> xGraphic; - assert(pGraphic); - rtl::Reference<unographic::Graphic> pUnoGraphic = new unographic::Graphic(); - pUnoGraphic->init(*pGraphic); - xGraphic = pUnoGraphic; - - aRet.push_back(xGraphic); + aRet.push_back(pGraphic->GetXGraphic()); } return comphelper::containerToSequence(aRet); commit db0e0f963b92d2e8577374340e1f39f236d601ac Author: Mike Kaganski <[email protected]> AuthorDate: Thu Oct 2 12:34:25 2025 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Sat Oct 4 13:42:01 2025 +0200 Let ImportGraphics return the vector, instead of using out argument Change-Id: I6c362cb8e6f77963df47b1327f1f479b9ff90d93 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191847 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx index d3c77ca25e8e..12f5d3bfc967 100644 --- a/include/vcl/graphicfilter.hxx +++ b/include/vcl/graphicfilter.hxx @@ -282,8 +282,8 @@ public: /// Imports multiple graphics. /// - /// The resulting graphic is added to rGraphics on success, empty graphic is added on failure. - SAL_DLLPRIVATE void ImportGraphics(std::vector< std::shared_ptr<Graphic> >& rGraphics, std::vector< std::unique_ptr<SvStream> > vStreams); + /// The resulting graphic is added to result on success, empty graphic is added on failure. + SAL_DLLPRIVATE std::vector<std::shared_ptr<Graphic>> ImportGraphics(std::vector< std::unique_ptr<SvStream> > vStreams); /** Tries to ensure all Graphic objects are available (Graphic::isAvailable()). Only an optimization, may diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index e2985ba4336f..4dcb30256b40 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -534,7 +534,7 @@ void GraphicImportTask::doImport(GraphicImportContext& rContext) } } -void GraphicFilter::ImportGraphics(std::vector< std::shared_ptr<Graphic> >& rGraphics, std::vector< std::unique_ptr<SvStream> > vStreams) +std::vector<std::shared_ptr<Graphic>> GraphicFilter::ImportGraphics(std::vector< std::unique_ptr<SvStream> > vStreams) { static bool bThreads = !getenv("VCL_NO_THREAD_IMPORT"); std::vector<GraphicImportContext> aContexts; @@ -608,7 +608,8 @@ void GraphicFilter::ImportGraphics(std::vector< std::shared_ptr<Graphic> >& rGra rSharedPool.waitUntilDone(pTag); // Process data after import. - rGraphics.reserve(aContexts.size()); + std::vector<std::shared_ptr<Graphic>> aGraphics; + aGraphics.reserve(aContexts.size()); for (auto& rContext : aContexts) { rContext.m_pAccess.reset(); @@ -644,8 +645,9 @@ void GraphicFilter::ImportGraphics(std::vector< std::shared_ptr<Graphic> >& rGra pGraphic->SetGfxLink(std::make_shared<GfxLink>(aGraphicContent, rContext.m_eLinkType)); } - rGraphics.push_back(std::move(pGraphic)); + aGraphics.push_back(std::move(pGraphic)); } + return aGraphics; } void GraphicFilter::MakeGraphicsAvailableThreaded(std::vector<Graphic*>& graphics) @@ -676,8 +678,7 @@ void GraphicFilter::MakeGraphicsAvailableThreaded(std::vector<Graphic*>& graphic { streams.push_back(graphic->GetSharedGfxLink()->getDataContainer().getAsStream()); } - std::vector< std::shared_ptr<Graphic>> loadedGraphics; - ImportGraphics(loadedGraphics, std::move(streams)); + std::vector<std::shared_ptr<Graphic>> loadedGraphics = ImportGraphics(std::move(streams)); assert(loadedGraphics.size() == toLoad.size()); for( size_t i = 0; i < toLoad.size(); ++i ) { diff --git a/vcl/source/graphic/UnoGraphicProvider.cxx b/vcl/source/graphic/UnoGraphicProvider.cxx index 7d0ffbfbea78..f5efba26320f 100644 --- a/vcl/source/graphic/UnoGraphicProvider.cxx +++ b/vcl/source/graphic/UnoGraphicProvider.cxx @@ -443,9 +443,8 @@ uno::Sequence< uno::Reference<graphic::XGraphic> > SAL_CALL GraphicProvider::que } // Import: streams to graphics. - std::vector< std::shared_ptr<Graphic> > aGraphics; GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); - rFilter.ImportGraphics(aGraphics, std::move(aStreams)); + std::vector<std::shared_ptr<Graphic>> aGraphics = rFilter.ImportGraphics(std::move(aStreams)); // Returning: graphics to UNO objects. std::vector< uno::Reference<graphic::XGraphic> > aRet;
