desktop/source/app/cmdlineargs.cxx | 10 +++++++++- sfx2/source/appl/macroloader.cxx | 9 +++++++-- sfx2/source/doc/iframe.cxx | 20 +++++++++++++++----- sfx2/source/inc/macroloader.hxx | 2 ++ sw/source/filter/html/htmlplug.cxx | 7 ++++++- sw/source/filter/xml/xmltexti.cxx | 9 +++++++-- wizards/source/access2base/DoCmd.xba | 2 +- 7 files changed, 47 insertions(+), 12 deletions(-)
New commits: commit 153218d19db4eaf4bb356ca1e476dcab79ff509a Author: Stephan Bergmann <[email protected]> AuthorDate: Thu Sep 1 17:33:51 2022 +0200 Commit: Thorsten Behrens <[email protected]> CommitDate: Fri Sep 2 00:03:26 2022 +0200 Filter out unwanted command URIs Change-Id: I0b7e5329af8cc053d14d5c60ec14fe7f364ef993 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139225 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <[email protected]> Conflicts: desktop/source/app/cmdlineargs.cxx diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx index 8fe83f523c48..97bb8bc50bbb 100644 --- a/desktop/source/app/cmdlineargs.cxx +++ b/desktop/source/app/cmdlineargs.cxx @@ -29,6 +29,7 @@ #include <tools/stream.hxx> #include <vcl/svapp.hxx> #include <rtl/uri.hxx> +#include <tools/urlobj.hxx> #include <rtl/ustring.hxx> #include <rtl/process.h> #include <comphelper/lok.hxx> @@ -167,7 +168,14 @@ CommandLineEvent CheckOfficeURI(/* in,out */ OUString& arg, CommandLineEvent cur } if (nURIlen < 0) nURIlen = rest2.getLength(); - arg = rest2.copy(0, nURIlen); + auto const uri = rest2.subView(0, nURIlen); + if (INetURLObject(uri).GetProtocol() == INetProtocol::Macro) { + // Let the "Open" machinery process the full command URI (leading to failure, by intention, + // as the "Open" machinery does not know about those command URI schemes): + curEvt = CommandLineEvent::Open; + } else { + arg = uri; + } return curEvt; } commit 996172c18b4cc8c2829d6e24cbe3928a87531332 Author: Caolán McNamara <[email protected]> AuthorDate: Tue Aug 30 17:01:08 2022 +0100 Commit: Thorsten Behrens <[email protected]> CommitDate: Fri Sep 2 00:01:51 2022 +0200 check IFrame "FrameURL" target similiar to commit b3edf85e0fe6ca03dc26e1bf531be82193bc9627 Date: Wed Aug 7 17:37:11 2019 +0100 warn on load when a document binds an event to a macro Change-Id: Iea888b1c083d2dc69ec322309ac9ae8c5e5eb315 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139059 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <[email protected]> Conflicts: sfx2/source/doc/iframe.cxx sw/source/filter/html/htmlplug.cxx sw/source/filter/xml/xmltexti.cxx diff --git a/sfx2/source/appl/macroloader.cxx b/sfx2/source/appl/macroloader.cxx index a910138908fd..113a85241115 100644 --- a/sfx2/source/appl/macroloader.cxx +++ b/sfx2/source/appl/macroloader.cxx @@ -73,10 +73,10 @@ css::uno::Sequence<OUString> SAL_CALL SfxMacroLoader::getSupportedServiceNames() return aSeq; } -SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl() +SfxObjectShell* SfxMacroLoader::GetObjectShell(const Reference <XFrame>& xFrame) { SfxObjectShell* pDocShell = nullptr; - Reference < XFrame > xFrame( m_xFrame.get(), UNO_QUERY ); + if ( xFrame.is() ) { SfxFrame* pFrame=nullptr; @@ -93,6 +93,11 @@ SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl() return pDocShell; } +SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl() +{ + Reference < XFrame > xFrame( m_xFrame.get(), UNO_QUERY ); + return SfxMacroLoader::GetObjectShell(xFrame); +} uno::Reference<frame::XDispatch> SAL_CALL SfxMacroLoader::queryDispatch( const util::URL& aURL , diff --git a/sfx2/source/doc/iframe.cxx b/sfx2/source/doc/iframe.cxx index 7d7fdb02ad98..f1e03e7898a2 100644 --- a/sfx2/source/doc/iframe.cxx +++ b/sfx2/source/doc/iframe.cxx @@ -39,10 +39,12 @@ #include <svl/ownlist.hxx> #include <svl/itemprop.hxx> #include <sfx2/frmdescr.hxx> +#include <sfx2/objsh.hxx> #include <sfx2/sfxdlg.hxx> #include <sfx2/sfxsids.hrc> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/window.hxx> +#include <macroloader.hxx> using namespace ::com::sun::star; @@ -158,6 +160,19 @@ sal_Bool SAL_CALL IFrameObject::load( { if ( SvtMiscOptions().IsPluginsEnabled() ) { + util::URL aTargetURL; + aTargetURL.Complete = maFrmDescr.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ); + uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( mxContext ) ); + xTrans->parseStrict( aTargetURL ); + + if (INetURLObject(aTargetURL.Complete).GetProtocol() == INetProtocol::Macro) + { + uno::Reference<frame::XFramesSupplier> xParentFrame = xFrame->getCreator(); + SfxObjectShell* pDoc = SfxMacroLoader::GetObjectShell(xParentFrame); + if (pDoc && !pDoc->AdjustMacroMode()) + return false; + } + DBG_ASSERT( !mxFrame.is(), "Frame already existing!" ); VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); VclPtr<IFrameWindow_Impl> pWin = VclPtr<IFrameWindow_Impl>::Create( pParent, maFrmDescr.IsFrameBorderOn() ); @@ -180,11 +195,6 @@ sal_Bool SAL_CALL IFrameObject::load( if ( xFramesSupplier.is() ) mxFrame->setCreator( xFramesSupplier ); - util::URL aTargetURL; - aTargetURL.Complete = maFrmDescr.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ); - uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( mxContext ) ); - xTrans->parseStrict( aTargetURL ); - uno::Sequence < beans::PropertyValue > aProps(2); aProps[0].Name = "PluginMode"; aProps[0].Value <<= sal_Int16(2); diff --git a/sfx2/source/inc/macroloader.hxx b/sfx2/source/inc/macroloader.hxx index 94fa5165fdd9..e2d5f8fd76c4 100644 --- a/sfx2/source/inc/macroloader.hxx +++ b/sfx2/source/inc/macroloader.hxx @@ -81,6 +81,8 @@ public: virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) override; virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) override; + + static SfxObjectShell* GetObjectShell(const css::uno::Reference<css::frame::XFrame>& xFrame); }; #endif diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx index 19ef7252094a..955eeab36ee9 100644 --- a/sw/source/filter/html/htmlplug.cxx +++ b/sw/source/filter/html/htmlplug.cxx @@ -1006,7 +1006,12 @@ void SwHTMLParser::InsertFloatingFrame() bool bHasBorder = aFrameDesc.HasFrameBorder(); Size aMargin = aFrameDesc.GetMargin(); - xSet->setPropertyValue("FrameURL", uno::makeAny( aFrameDesc.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ) ) ); + OUString sHRef = aFrameDesc.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ); + + if (INetURLObject(sHRef).GetProtocol() == INetProtocol::Macro) + NotifyMacroEventRead(); + + xSet->setPropertyValue("FrameURL", uno::makeAny( sHRef ) ); xSet->setPropertyValue("FrameName", uno::makeAny( aName ) ); if ( eScroll == ScrollingMode::Auto ) diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx index 0cbf9fd85677..8366f0ae3804 100644 --- a/sw/source/filter/xml/xmltexti.cxx +++ b/sw/source/filter/xml/xmltexti.cxx @@ -854,9 +854,14 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertFloatingFra uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY ); if ( xSet.is() ) { + OUString sHRef = URIHelper::SmartRel2Abs( + INetURLObject( GetXMLImport().GetBaseURL() ), rHRef ); + + if (INetURLObject(sHRef).GetProtocol() == INetProtocol::Macro) + GetXMLImport().NotifyMacroEventRead(); + xSet->setPropertyValue("FrameURL", - makeAny( URIHelper::SmartRel2Abs( - INetURLObject( GetXMLImport().GetBaseURL() ), rHRef ) ) ); + makeAny( sHRef ) ); xSet->setPropertyValue("FrameName", makeAny( rName ) ); commit 317fc74baff26e9075240e14a2c03e1c88efd7c3 Author: Stephan Bergmann <[email protected]> AuthorDate: Tue Aug 30 14:04:52 2022 +0200 Commit: Thorsten Behrens <[email protected]> CommitDate: Thu Sep 1 23:52:36 2022 +0200 These commands are always URLs already Change-Id: I5083765c879689d7f933bbe00ad70bb68e635a21 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139042 Tested-by: Jean-Pierre Ledure <[email protected]> Tested-by: Jenkins Reviewed-by: Stephan Bergmann <[email protected]> Conflicts: wizards/source/scriptforge/SF_Session.xba diff --git a/wizards/source/access2base/DoCmd.xba b/wizards/source/access2base/DoCmd.xba index c640af7c5478..79b109ddf47f 100644 --- a/wizards/source/access2base/DoCmd.xba +++ b/wizards/source/access2base/DoCmd.xba @@ -2649,7 +2649,7 @@ Private Sub _ShellExecute(sCommand As String) Dim oShell As Object Set oShell = createUnoService("com.sun.star.system.SystemShellExecute") - oShell.execute(sCommand, "" , com.sun.star.system.SystemShellExecuteFlags.DEFAULTS) + oShell.execute(sCommand, "" , com.sun.star.system.SystemShellExecuteFlags.URIS_ONLY) End Sub ' _ShellExecute V0.8.5
