include/vcl/graphicfilter.hxx | 28 +++++++++++++++++----------- sfx2/source/dialog/filedlghelper.cxx | 13 ++++++++----- sfx2/source/dialog/filedlgimpl.hxx | 4 ++-- vcl/source/filter/graphicfilter.cxx | 27 ++++++++++++++++----------- 4 files changed, 43 insertions(+), 29 deletions(-)
New commits: commit 4d653db5c6b3fe32e3f3b527a7e2acf866cae69c Author: Dr. David Alan Gilbert <[email protected]> AuthorDate: Fri May 16 02:20:48 2025 +0100 Commit: David Gilbert <[email protected]> CommitDate: Fri Jun 13 22:03:15 2025 +0200 tdf#162826: sfx2: Get InteractionHandler Get an InteractionHandler in 'getGraphic' that will be passed down for getting a password later. Change-Id: Ibb0d2f28b5efff8b28b1f0d28d2f386c3bab8bbe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185468 Reviewed-by: David Gilbert <[email protected]> Tested-by: Jenkins diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 677cea0e370f..9050192f0bb2 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -781,7 +781,7 @@ IMPL_LINK_NOARG(FileDialogHelper_Impl, TimeOutHdl_Impl, Timer *, void) } ErrCode FileDialogHelper_Impl::getGraphic( const OUString& rURL, - Graphic& rGraphic ) const + Graphic& rGraphic ) { if ( utl::UCBContentHelper::IsFolder( rURL ) ) return ERRCODE_IO_NOTAFILE; @@ -804,6 +804,9 @@ ErrCode FileDialogHelper_Impl::getGraphic( const OUString& rURL, aURLObj.SetSmartURL( rURL ); } + uno::Reference<task::XInteractionHandler2> xInteractionHandler = + task::InteractionHandler::createWithParent(::comphelper::getProcessComponentContext(), GetFrameInterface()); + ErrCode nRet = ERRCODE_NONE; GraphicFilterImportFlags nFilterImportFlags = GraphicFilterImportFlags::SetLogsizeForJpeg; @@ -813,19 +816,19 @@ ErrCode FileDialogHelper_Impl::getGraphic( const OUString& rURL, std::unique_ptr<SvStream> pStream = ::utl::UcbStreamHelper::CreateStream( rURL, StreamMode::READ ); if( pStream ) - nRet = mpGraphicFilter->ImportGraphic( rGraphic, rURL, *pStream, nFilter, nullptr, nFilterImportFlags ); + nRet = mpGraphicFilter->ImportGraphic(rGraphic, rURL, *pStream, nFilter, nullptr, nFilterImportFlags, -1, xInteractionHandler); else - nRet = mpGraphicFilter->ImportGraphic( rGraphic, aURLObj, nFilter, nullptr, nFilterImportFlags ); + nRet = mpGraphicFilter->ImportGraphic(rGraphic, aURLObj, nFilter, nullptr, nFilterImportFlags, xInteractionHandler); } else { - nRet = mpGraphicFilter->ImportGraphic( rGraphic, aURLObj, nFilter, nullptr, nFilterImportFlags ); + nRet = mpGraphicFilter->ImportGraphic(rGraphic, aURLObj, nFilter, nullptr, nFilterImportFlags, xInteractionHandler); } return nRet; } -ErrCode FileDialogHelper_Impl::getGraphic( Graphic& rGraphic ) const +ErrCode FileDialogHelper_Impl::getGraphic( Graphic& rGraphic ) { ErrCode nRet = ERRCODE_NONE; diff --git a/sfx2/source/dialog/filedlgimpl.hxx b/sfx2/source/dialog/filedlgimpl.hxx index 66c1aa37f53c..2fee6c08c7d6 100644 --- a/sfx2/source/dialog/filedlgimpl.hxx +++ b/sfx2/source/dialog/filedlgimpl.hxx @@ -116,7 +116,7 @@ namespace sfx2 std::shared_ptr<const SfxFilter> getCurrentSfxFilter(); bool updateExtendedControl( sal_Int16 _nExtendedControlId, bool _bEnable ); - ErrCode getGraphic( const OUString& rURL, Graphic& rGraphic ) const; + ErrCode getGraphic( const OUString& rURL, Graphic& rGraphic ); void setDefaultValues(); void preExecute(); @@ -193,7 +193,7 @@ namespace sfx2 OUString getFilter() const; void getRealFilter( OUString& _rFilter ) const; - ErrCode getGraphic( Graphic& rGraphic ) const; + ErrCode getGraphic( Graphic& rGraphic ); void createMatcher( const OUString& rFactory ); bool isShowFilterExtensionEnabled() const; commit c1cdf4cd9cb2dbebe53fd7100ccc8f5ee46fbbb7 Author: Dr. David Alan Gilbert <[email protected]> AuthorDate: Fri May 16 18:56:43 2025 +0100 Commit: David Gilbert <[email protected]> CommitDate: Fri Jun 13 22:03:00 2025 +0200 tdf#162826: vcl: Plumb InteractionHandler down Plumb an InteractionHandler parameter down through GraphicFilter::ImportGraphic and into GraphicFilter::readPDF. Change-Id: Id949080d3b176f9512407ea9a0f416253a74ca7d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185467 Tested-by: Jenkins Reviewed-by: David Gilbert <[email protected]> diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx index fca48e341fa5..a37328d6380f 100644 --- a/include/vcl/graphicfilter.hxx +++ b/include/vcl/graphicfilter.hxx @@ -23,6 +23,7 @@ #include <tools/gen.hxx> #include <vcl/dllapi.h> #include <vcl/graph.hxx> +#include <com/sun/star/task/InteractionHandler.hpp> #include <comphelper/errcode.hxx> #include <o3tl/typed_flags_set.hxx> #include <vcl/BinaryDataContainer.hxx> @@ -262,19 +263,22 @@ public: sal_uInt16 nFormat, sal_uInt16 * pDeterminedFormat); - ErrCode ImportGraphic( Graphic& rGraphic, const INetURLObject& rPath, - sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW, - sal_uInt16 * pDeterminedFormat = nullptr, GraphicFilterImportFlags nImportFlags = GraphicFilterImportFlags::NONE ); + ErrCode ImportGraphic( + Graphic& rGraphic, const INetURLObject& rPath, + sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW, sal_uInt16 * pDeterminedFormat = nullptr, + GraphicFilterImportFlags nImportFlags = GraphicFilterImportFlags::NONE, + const css::uno::Reference<css::task::XInteractionHandler>& xInteractionHandler = nullptr); ErrCode CanImportGraphic( std::u16string_view rPath, SvStream& rStream, sal_uInt16 nFormat, sal_uInt16 * pDeterminedFormat); - ErrCode ImportGraphic(Graphic& rGraphic, std::u16string_view rPath, SvStream& rStream, - sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW, - sal_uInt16* pDeterminedFormat = nullptr, - GraphicFilterImportFlags nImportFlags = GraphicFilterImportFlags::NONE, - sal_Int32 nPageNum = -1); + ErrCode ImportGraphic( + Graphic& rGraphic, std::u16string_view rPath, SvStream& rStream, + sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW, sal_uInt16* pDeterminedFormat = nullptr, + GraphicFilterImportFlags nImportFlags = GraphicFilterImportFlags::NONE, + sal_Int32 nPageNum = -1, + const css::uno::Reference<css::task::XInteractionHandler>& xInteractionHandler = nullptr); /// Imports multiple graphics. /// @@ -296,10 +300,11 @@ public: Link<ConvertData&,bool> GetFilterCallback() const; static GraphicFilter& GetGraphicFilter(); - static ErrCode LoadGraphic( const OUString& rPath, const OUString& rFilter, + static ErrCode LoadGraphic(const OUString& rPath, const OUString& rFilter, Graphic& rGraphic, GraphicFilter* pFilter = nullptr, - sal_uInt16* pDeterminedFormat = nullptr ); + sal_uInt16* pDeterminedFormat = nullptr, + const css::uno::Reference<css::task::XInteractionHandler>& xInteractionHandler = nullptr); ErrCode compressAsPNG(const Graphic& rGraphic, SvStream& rOutputStream); @@ -318,7 +323,8 @@ public: SAL_DLLPRIVATE static ErrCode readEMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType); SAL_DLLPRIVATE static ErrCode readPDF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType, - sal_Int32 nPageIndex = -1); + sal_Int32 nPageIndex = -1, + const css::uno::Reference<css::task::XInteractionHandler>& xInteractionHandler = nullptr); SAL_DLLPRIVATE static ErrCode readTIFF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType); SAL_DLLPRIVATE static ErrCode readWithTypeSerializer(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType, std::u16string_view aFilterName); SAL_DLLPRIVATE static ErrCode readBMP(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType); diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 3e512777198c..383d3696ed8f 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -443,8 +443,10 @@ ErrCode GraphicFilter::CanImportGraphic( std::u16string_view rMainUrl, SvStream& } //SJ: TODO, we need to create a GraphicImporter component -ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const INetURLObject& rPath, - sal_uInt16 nFormat, sal_uInt16 * pDeterminedFormat, GraphicFilterImportFlags nImportFlags ) +ErrCode GraphicFilter::ImportGraphic( + Graphic& rGraphic, const INetURLObject& rPath, sal_uInt16 nFormat, + sal_uInt16 * pDeterminedFormat, GraphicFilterImportFlags nImportFlags, + const css::uno::Reference<css::task::XInteractionHandler>& xInteractionHandler) { SAL_WARN_IF( rPath.GetProtocol() == INetProtocol::NotValid, "vcl.filter", "GraphicFilter::ImportGraphic() : ProtType == INetProtocol::NotValid" ); @@ -459,7 +461,7 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const INetURLObject& rP std::unique_ptr<SvStream> xStream(::utl::UcbStreamHelper::CreateStream( aMainUrl, StreamMode::READ | StreamMode::SHARE_DENYNONE )); if (xStream) { - nRetValue = ImportGraphic( rGraphic, aMainUrl, *xStream, nFormat, pDeterminedFormat, nImportFlags ); + nRetValue = ImportGraphic(rGraphic, aMainUrl, *xStream, nFormat, pDeterminedFormat, nImportFlags, -1, xInteractionHandler); } return nRetValue; } @@ -1133,8 +1135,9 @@ ErrCode GraphicFilter::readEMF(SvStream & rStream, Graphic & rGraphic, GfxLinkTy return readWMF_EMF(rStream, rGraphic, rLinkType, VectorGraphicDataType::Emf); } -ErrCode GraphicFilter::readPDF(SvStream& rStream, Graphic& rGraphic, GfxLinkType& rLinkType, - sal_Int32 nPageIndex) +ErrCode GraphicFilter::readPDF( + SvStream& rStream, Graphic& rGraphic, GfxLinkType& rLinkType, sal_Int32 nPageIndex, + const css::uno::Reference<css::task::XInteractionHandler>& /*xInteractionHandler*/) { if (vcl::ImportPDF(rStream, rGraphic, nPageIndex)) { @@ -1317,7 +1320,8 @@ ErrCode GraphicFilter::readWEBP(SvStream & rStream, Graphic & rGraphic, GfxLinkT ErrCode GraphicFilter::ImportGraphic(Graphic& rGraphic, std::u16string_view rPath, SvStream& rIStream, sal_uInt16 nFormat, sal_uInt16* pDeterminedFormat, - GraphicFilterImportFlags nImportFlags, sal_Int32 nPageIndex) + GraphicFilterImportFlags nImportFlags, sal_Int32 nPageIndex, + const css::uno::Reference<css::task::XInteractionHandler>& xInteractionHandler) { OUString aFilterName; sal_uInt64 nStreamBegin; @@ -1408,7 +1412,7 @@ ErrCode GraphicFilter::ImportGraphic(Graphic& rGraphic, std::u16string_view rPat } else if (aFilterName.equalsIgnoreAsciiCase(IMP_PDF)) { - nStatus = readPDF(rIStream, rGraphic, eLinkType, nPageIndex); + nStatus = readPDF(rIStream, rGraphic, eLinkType, nPageIndex, xInteractionHandler); } else if (aFilterName.equalsIgnoreAsciiCase(IMP_TIFF) ) { @@ -1938,9 +1942,10 @@ GraphicFilter& GraphicFilter::GetGraphicFilter() return gStandardFilter.m_aFilter; } -ErrCode GraphicFilter::LoadGraphic( const OUString &rPath, const OUString &rFilterName, +ErrCode GraphicFilter::LoadGraphic(const OUString &rPath, const OUString &rFilterName, Graphic& rGraphic, GraphicFilter* pFilter, - sal_uInt16* pDeterminedFormat ) + sal_uInt16* pDeterminedFormat, + const css::uno::Reference<css::task::XInteractionHandler>& xInteractionHandler) { if ( !pFilter ) pFilter = &GetGraphicFilter(); @@ -1962,9 +1967,9 @@ ErrCode GraphicFilter::LoadGraphic( const OUString &rPath, const OUString &rFilt ErrCode nRes = ERRCODE_NONE; if ( !pStream ) - nRes = pFilter->ImportGraphic( rGraphic, aURL, nFilter, pDeterminedFormat ); + nRes = pFilter->ImportGraphic(rGraphic, aURL, nFilter, pDeterminedFormat, GraphicFilterImportFlags::NONE, xInteractionHandler); else - nRes = pFilter->ImportGraphic( rGraphic, rPath, *pStream, nFilter, pDeterminedFormat ); + nRes = pFilter->ImportGraphic(rGraphic, rPath, *pStream, nFilter, pDeterminedFormat, GraphicFilterImportFlags::NONE, -1, xInteractionHandler); #ifdef DBG_UTIL OUString aReturnString;
