These commands are always URLs already
authorStephan Bergmann <sbergman@redhat.com>
Tue, 30 Aug 2022 12:04:52 +0000 (14:04 +0200)
committerRene Engelhard <rene@debian.org>
Sat, 25 Mar 2023 13:04:55 +0000 (13:04 +0000)
Conflicts:
wizards/source/scriptforge/SF_Session.xba

Change-Id: I5083765c879689d7f933bbe00ad70bb68e635a21
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139042
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Gbp-Pq: Name ZDI-CAN-17859.diff

desktop/source/app/cmdlineargs.cxx
sfx2/source/appl/macroloader.cxx
sfx2/source/doc/iframe.cxx
sfx2/source/inc/macroloader.hxx
sw/source/filter/html/htmlplug.cxx
sw/source/filter/xml/xmltexti.cxx
wizards/source/access2base/DoCmd.xba
xmloff/source/draw/ximpshap.cxx

index e58ee2f6e2e4a1968e84fa2cb2b3bcdf8ecaaf95..54cc7f868d3245d56bafeac0ad177431aa9eccb6 100644 (file)
@@ -28,6 +28,7 @@
 #include "cmdlineargs.hxx"
 #include <osl/thread.hxx>
 #include <tools/stream.hxx>
+#include <tools/urlobj.hxx>
 #include <rtl/ustring.hxx>
 #include <rtl/process.h>
 #include <comphelper/lok.hxx>
@@ -166,7 +167,14 @@ CommandLineEvent CheckOfficeURI(/* in,out */ OUString& arg, CommandLineEvent cur
     }
     if (nURIlen < 0)
         nURIlen = rest2.getLength();
-    arg = rest2.copy(0, nURIlen);
+    auto const uri = rest2.copy(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;
 }
 
index 46090f7126656cbd77bdac97527a5ada5d38e9f1..ad70ef5fa0f68df24855e9a554c0e4b9fea2d47a 100644 (file)
@@ -68,10 +68,10 @@ css::uno::Sequence<OUString> SAL_CALL SfxMacroLoader::getSupportedServiceNames()
     return { "com.sun.star.frame.ProtocolHandler" };
 }
 
-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;
@@ -88,6 +88,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            ,
index d722ac987b336c0d21a0b556a2b95c387f6afc93..22b18c6e382b00d041ac483164d25034be4b1d99 100644 (file)
 #include <svtools/miscopt.hxx>
 #include <svl/itemprop.hxx>
 #include <sfx2/frmdescr.hxx>
+#include <sfx2/objsh.hxx>
 #include <sfx2/sfxdlg.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 #include <vcl/window.hxx>
 #include <tools/debug.hxx>
+#include <macroloader.hxx>
 
 using namespace ::com::sun::star;
 
@@ -157,6 +159,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() );
@@ -179,11 +194,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);
index 051486c09adfee9d5df6f9464b716e90b0dae9b8..62a6555ff8775cd9e319607ada7ad7e48d33fffa 100644 (file)
@@ -79,6 +79,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
index 525b3b0ea17555f7a0d9d3354469e5ae5a342c57..733be35312d7dd07abce23d3a243b3ce9b028d4c 100644 (file)
@@ -1090,7 +1090,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 )
index 9f9995868809bea82a72690f15fed5870c64773b..07f935f1695e836a34c6a68d02977f6d0fb7a926 100644 (file)
@@ -856,9 +856,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 ) );
index 27b0d74be34f95273f1e8f096d8f5c0c6dfffa11..26755a8d901d275fd6450d9aeef1d1e4a6ee2dc4 100644 (file)
@@ -2655,7 +2655,7 @@ Private Sub _ShellExecute(sCommand As String)
 
 Dim oShell As Object
        Set oShell = createUnoService(&quot;com.sun.star.system.SystemShellExecute&quot;)
-       oShell.execute(sCommand, &quot;&quot; , com.sun.star.system.SystemShellExecuteFlags.DEFAULTS)
+       oShell.execute(sCommand, &quot;&quot; , com.sun.star.system.SystemShellExecuteFlags.URIS_ONLY)
 
 End Sub                                &apos;  _ShellExecute                   V0.8.5
 
index fdfbbc2562a8af13a10efdc1661ab89e627d2944..71a2ee7d637b9754f4ed6a5197ab4b46f082a628 100644 (file)
@@ -87,6 +87,7 @@
 #include <basegfx/polygon/b2dpolypolygon.hxx>
 #include <basegfx/polygon/b2dpolypolygontools.hxx>
 #include <basegfx/vector/b2dvector.hxx>
+#include <tools/urlobj.hxx>
 #include <o3tl/any.hxx>
 #include <o3tl/safeint.hxx>
 
@@ -3265,6 +3266,9 @@ void SdXMLFloatingFrameShapeContext::StartElement( const css::uno::Reference< cs
 
             if( !maHref.isEmpty() )
             {
+                if (INetURLObject(maHref).GetProtocol() == INetProtocol::Macro)
+                    GetImport().NotifyMacroEventRead();
+
                 xProps->setPropertyValue("FrameURL", Any(maHref) );
             }
         }