dbaccess/source/core/dataaccess/ModelImpl.cxx |    3 +-
 include/sfx2/docmacromode.hxx                 |    5 ++-
 include/sfx2/objsh.hxx                        |    6 ++++
 include/sfx2/sfx.hrc                          |    1 
 sc/source/core/data/global.cxx                |    8 ++++-
 sfx2/source/appl/app.src                      |    5 +++
 sfx2/source/doc/docmacromode.cxx              |    8 ++++-
 sfx2/source/doc/objmisc.cxx                   |   35 +++++++++++++++++++++++
 sfx2/source/doc/objxtor.cxx                   |    1 
 sfx2/source/inc/objshimp.hxx                  |    3 +-
 sw/source/uibase/wrtsh/wrtsh2.cxx             |   38 ++++++++++++++++----------
 11 files changed, 92 insertions(+), 21 deletions(-)

New commits:
commit af4985b11d421acb1d7620353714364304fa9f5f
Author:     Caolán McNamara <[email protected]>
AuthorDate: Wed Nov 15 11:39:24 2023 +0000
Commit:     Stephan Bergmann <[email protected]>
CommitDate: Wed Feb 14 14:06:01 2024 +0100

    reuse AllowedLinkProtocolFromDocument in writer
    
    reorg calc hyperlink check to reuse elsewhere
    
    Change-Id: I20ae3c5df15502c3a0a366fb4a2924c06ffac3d0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159487
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>
    (cherry picked from commit e6a7537762e19fde446441edd10d301f9b37ce75)
    
    reuse AllowedLinkProtocolFromDocument in writer
    
    Change-Id: Iacf5e313fc6ca5f7d69ca6986a036f0e1ab1f2a0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159488
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>
    (cherry picked from commit 32535dfa82200b54296838b52285c054fbe5e51d)
    
    combine these hyperlink dispatchers into one call
    
    Change-Id: Icb7822e811013de648ccf2fbb23a5f0be9e29bb0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159489
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>
    (cherry picked from commit 0df175ccc6ea542bc5801f631ff72bed187042eb)
    
    we can have just one LoadURL for writer
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159557
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>
    (cherry picked from commit 521ca9cf6acbae96cf95d9740859c9682212013d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159858
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit e32b8601dbd63cf01497889601d6c9c1241106d6)
    (cherry picked from commit 7bd23139442dcd3a9c4aaa4bcfd295c45f49579a)
    Conflicts:
            include/sfx2/objsh.hxx
            sc/source/core/data/global.cxx
            sfx2/source/doc/objmisc.cxx
            sw/source/uibase/shells/drwtxtex.cxx
            sw/source/uibase/wrtsh/wrtsh2.cxx
    
    Change-Id: Ia0162ee1c275292fcf200bad4662e4c2c6b7b972
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163368
    Tested-by: Stephan Bergmann <[email protected]>
    Reviewed-by: Stephan Bergmann <[email protected]>

diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index 9f96bd6f647d..dc1e0ee5b7f3 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -222,6 +222,9 @@ private:
 
     SAL_DLLPRIVATE bool SaveTo_Impl(SfxMedium &rMedium, const SfxItemSet* pSet 
);
 
+    // true if the document had macros (or similar) on load to trigger warning 
user
+    SAL_DLLPRIVATE bool  GetHadCheckedMacrosOnLoad() const;
+
 protected:
                                 SfxObjectShell(SfxObjectCreateMode);
                                 SfxObjectShell(SfxModelFlags);    // see 
sfxmodelfactory.hxx
@@ -428,8 +431,8 @@ public:
     void                        SetMacroCallsSeenWhileLoading();
     bool                        GetMacroCallsSeenWhileLoading() const;
 
-    // true if the document had macros (or similar) on load to trigger warning 
user
-    bool                        GetHadCheckedMacrosOnLoad() const;
+    // true if this type of link, from a document, is allowed by the user to 
be passed to uno:OpenDoc
+    static bool                 AllowedLinkProtocolFromDocument(const 
OUString& rUrl, SfxObjectShell* pObjShell, vcl::Window* pDialogParent);
 
     const css::uno::Sequence< css::beans::PropertyValue >& 
GetModifyPasswordInfo() const;
     bool                        SetModifyPasswordInfo( const 
css::uno::Sequence< css::beans::PropertyValue >& aInfo );
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 2bc1817607f0..2f618b6ecdaa 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -28,8 +28,6 @@
 #include <sfx2/docfile.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/objsh.hxx>
-#include <sfx2/sfxresid.hxx>
-#include <sfx2/sfx.hrc>
 #include <sfx2/viewfrm.hxx>
 #include <sfx2/viewsh.hxx>
 #include <svl/stritem.hxx>
@@ -890,34 +888,8 @@ void ScGlobal::OpenURL(const OUString& rURL, const 
OUString& rTarget)
             aReferName = pMed->GetName();
     }
 
-    if (INetURLObject(rURL).IsExoticProtocol())
-    {
-        // Default to ignoring exotic protocols
-        bool bAllow = false;
-        if (pObjShell)
-        {
-            // If the document had macros when loaded then follow the allowed 
macro-mode
-            if (pObjShell->GetHadCheckedMacrosOnLoad())
-                bAllow = pObjShell->AdjustMacroMode();
-            else // otherwise ask the user, defaulting to cancel
-            {
-                assert(pFrame && "if we have pObjShell we have pFrame");
-                //Reuse URITools::onOpenURI warning string
-                ScopedVclPtrInstance<MessageDialog> 
xQueryBox(&pFrame->GetWindow(),
-                                                               
SfxResId(STR_DANGEROUS_TO_OPEN),
-                                                               
VclMessageType::Warning, VclButtonsType::YesNo);
-                
xQueryBox->set_primary_text(xQueryBox->get_primary_text().replaceFirst("$(ARG1)",
-                    INetURLObject::decode(rURL, 
INetURLObject::DecodeMechanism::Unambiguous)));
-                //TODO: xQueryBox->set_default_response(RET_NO);
-                bAllow = xQueryBox->Execute() == RET_YES;
-            }
-        }
-        if (!bAllow)
-        {
-            SAL_WARN("sc", "ScGlobal::OpenURL ignoring: " << rURL);
-            return;
-        }
-    }
+    if (!SfxObjectShell::AllowedLinkProtocolFromDocument(rURL, pObjShell, 
pFrame ? &pFrame->GetWindow() : nullptr))
+        return;
 
     SfxFrameItem aFrm( SID_DOCFRAME, pFrame );
     SfxStringItem aReferer( SID_REFERER, aReferName );
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 02be193c75c1..b25bd3070444 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -959,6 +959,33 @@ bool SfxObjectShell::GetHadCheckedMacrosOnLoad() const
     return pImpl->m_bHadCheckedMacrosOnLoad;
 }
 
+bool SfxObjectShell::AllowedLinkProtocolFromDocument(const OUString& rUrl, 
SfxObjectShell* pObjShell, vcl::Window* pDialogParent)
+{
+    if (!INetURLObject(rUrl).IsExoticProtocol())
+        return true;
+    // Default to ignoring exotic protocols
+    bool bAllow = false;
+    if (pObjShell)
+    {
+        // If the document had macros when loaded then follow the allowed 
macro-mode
+        if (pObjShell->GetHadCheckedMacrosOnLoad())
+            bAllow = pObjShell->AdjustMacroMode();
+        else // otherwise ask the user, defaulting to cancel
+        {
+            //Reuse URITools::onOpenURI warning string
+            ScopedVclPtrInstance<MessageDialog> xQueryBox(pDialogParent,
+                                                           
SfxResId(STR_DANGEROUS_TO_OPEN),
+                                                           
VclMessageType::Warning, VclButtonsType::YesNo);
+            
xQueryBox->set_primary_text(xQueryBox->get_primary_text().replaceFirst("$(ARG1)",
+                INetURLObject::decode(rUrl, 
INetURLObject::DecodeMechanism::Unambiguous)));
+            //TODO: xQueryBox->set_default_response(RET_NO);
+            bAllow = xQueryBox->Execute() == RET_YES;
+        }
+    }
+    SAL_WARN_IF(!bAllow, "sfx.appl", 
"SfxObjectShell::AllowedLinkProtocolFromDocument ignoring: " << rUrl);
+    return bAllow;
+}
+
 void SfxObjectShell::CheckEncryption_Impl( const uno::Reference< 
task::XInteractionHandler >& xHandler )
 {
     OUString aVersion;
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx 
b/sw/source/uibase/wrtsh/wrtsh2.cxx
index 1ff5866f5dd2..8978bb7434c2 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -459,29 +459,23 @@ bool SwWrtShell::ClickToINetGrf( const Point& rDocPt, 
LoadUrlFlags nFilter )
     return bRet;
 }
 
-void LoadURL( SwViewShell& rVSh, const OUString& rURL, LoadUrlFlags nFilter,
-              const OUString& rTargetFrameName )
+static void LoadURL(SwView& rView, const OUString& rURL, LoadUrlFlags nFilter,
+                    const OUString& rTargetFrameName)
 {
-    OSL_ENSURE( !rURL.isEmpty(), "what should be loaded here?" );
-    if( rURL.isEmpty() )
-        return ;
+    SwDocShell* pDShell = rView.GetDocShell();
+    OSL_ENSURE( pDShell, "No DocShell?!");
+    SfxViewFrame* pViewFrame = rView.GetViewFrame();
 
-    // The shell could be 0 also!!!!!
-    if ( dynamic_cast<const SwCursorShell*>( &rVSh) ==  nullptr )
+    if (!SfxObjectShell::AllowedLinkProtocolFromDocument(rURL, pDShell, 
&pViewFrame->GetWindow()))
         return;
 
     // We are doing tiledRendering, let the client handles the URL loading.
     if (comphelper::LibreOfficeKit::isActive())
     {
-        
rVSh.GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_HYPERLINK_CLICKED,
 rURL.toUtf8().getStr());
+        rView.libreOfficeKitViewCallback(LOK_CALLBACK_HYPERLINK_CLICKED, 
rURL.toUtf8().getStr());
         return;
     }
 
-    //A CursorShell is always a WrtShell
-    SwWrtShell &rSh = static_cast<SwWrtShell&>(rVSh);
-
-    SwDocShell* pDShell = rSh.GetView().GetDocShell();
-    OSL_ENSURE( pDShell, "No DocShell?!");
     OUString sTargetFrame(rTargetFrameName);
     if (sTargetFrame.isEmpty() && pDShell)
     {
@@ -496,7 +490,6 @@ void LoadURL( SwViewShell& rVSh, const OUString& rURL, 
LoadUrlFlags nFilter,
     OUString sReferer;
     if( pDShell && pDShell->GetMedium() )
         sReferer = pDShell->GetMedium()->GetName();
-    SfxViewFrame* pViewFrame = rSh.GetView().GetViewFrame();
     SfxFrameItem aView( SID_DOCFRAME, pViewFrame );
     SfxStringItem aName( SID_FILE_NAME, rURL );
     SfxStringItem aTargetFrameName( SID_TARGETNAME, sTargetFrame );
@@ -522,6 +515,23 @@ void LoadURL( SwViewShell& rVSh, const OUString& rURL, 
LoadUrlFlags nFilter,
             SfxCallMode::ASYNCHRON|SfxCallMode::RECORD );
 }
 
+void LoadURL( SwViewShell& rVSh, const OUString& rURL, LoadUrlFlags nFilter,
+              const OUString& rTargetFrameName )
+{
+    OSL_ENSURE( !rURL.isEmpty(), "what should be loaded here?" );
+    if( rURL.isEmpty() )
+        return ;
+
+    // The shell could be 0 also!!!!!
+    if ( dynamic_cast<const SwCursorShell*>( &rVSh) ==  nullptr )
+        return;
+
+    //A CursorShell is always a WrtShell
+    SwWrtShell &rSh = static_cast<SwWrtShell&>(rVSh);
+
+    ::LoadURL(rSh.GetView(), rURL, nFilter, rTargetFrameName);
+}
+
 void SwWrtShell::NavigatorPaste( const NaviContentBookmark& rBkmk,
                                     const sal_uInt16 nAction )
 {
commit 6c03d6bf106322e8495b0b32a26c084e3c0950ff
Author:     Caolán McNamara <[email protected]>
AuthorDate: Fri Nov 3 17:26:25 2023 +0000
Commit:     Stephan Bergmann <[email protected]>
CommitDate: Wed Feb 14 14:05:53 2024 +0100

    default to ignoring libreoffice special-purpose protocols in calc hyperlink
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158911
    Tested-by: Jenkins
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>
    (cherry picked from commit b6062623b4d69c79e90e9365ac7c5e7f11986793)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159045
    Reviewed-by: Eike Rathke <[email protected]>
    (cherry picked from commit 672716d09c54cb6fdd59baa7da4b8393cf104cd2)
    (cherry picked from commit 09833101c989ead8dc751a611a27489ed2f1bcf1)
    Conflicts:
            dbaccess/source/core/dataaccess/ModelImpl.cxx
            include/sfx2/docmacromode.hxx
            include/sfx2/sfx.hrc
            include/sfx2/strings.hrc
            sc/source/core/data/global.cxx
            sfx2/source/appl/app.src
            sfx2/source/doc/docmacromode.cxx
            sfx2/source/doc/objmisc.cxx
    
    Change-Id: Ib9f62be3acc05f24ca234dec0fec21e24579e9de
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163314
    Tested-by: Stephan Bergmann <[email protected]>
    Reviewed-by: Stephan Bergmann <[email protected]>

diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx 
b/dbaccess/source/core/dataaccess/ModelImpl.cxx
index 2a27e8ddec8a..b08591ea71f9 100644
--- a/dbaccess/source/core/dataaccess/ModelImpl.cxx
+++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx
@@ -1099,7 +1099,8 @@ bool ODatabaseModelImpl::checkMacrosOnLoading()
 {
     Reference< XInteractionHandler > xInteraction;
     xInteraction = m_aMediaDescriptor.getOrDefault( "InteractionHandler", 
xInteraction );
-    return m_aMacroMode.checkMacrosOnLoading( xInteraction );
+    const bool bHasMacros = m_aMacroMode.hasMacros();
+    return m_aMacroMode.checkMacrosOnLoading(xInteraction, bHasMacros);
 }
 
 void ODatabaseModelImpl::resetMacroExecutionMode()
diff --git a/include/sfx2/docmacromode.hxx b/include/sfx2/docmacromode.hxx
index c396de555d49..c91e120ceaf2 100644
--- a/include/sfx2/docmacromode.hxx
+++ b/include/sfx2/docmacromode.hxx
@@ -258,6 +258,8 @@ namespace sfx2
         */
         static bool storageHasMacros( const css::uno::Reference< 
css::embed::XStorage >& _rxStorage );
 
+        bool hasMacros() const;
+
         static bool containerHasBasicMacros( const css::uno::Reference< 
css::script::XLibraryContainer >& xContainter );
         /** checks the macro execution mode while loading the document.
 
@@ -284,7 +286,8 @@ namespace sfx2
         */
         bool
                 checkMacrosOnLoading(
-                    const css::uno::Reference< css::task::XInteractionHandler 
>& _rxInteraction
+                    const css::uno::Reference< css::task::XInteractionHandler 
>& _rxInteraction,
+                    bool bHasMacros
                 );
 
     private:
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index 26be5293cdc9..9f96bd6f647d 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -428,6 +428,9 @@ public:
     void                        SetMacroCallsSeenWhileLoading();
     bool                        GetMacroCallsSeenWhileLoading() const;
 
+    // true if the document had macros (or similar) on load to trigger warning 
user
+    bool                        GetHadCheckedMacrosOnLoad() const;
+
     const css::uno::Sequence< css::beans::PropertyValue >& 
GetModifyPasswordInfo() const;
     bool                        SetModifyPasswordInfo( const 
css::uno::Sequence< css::beans::PropertyValue >& aInfo );
 
diff --git a/include/sfx2/sfx.hrc b/include/sfx2/sfx.hrc
index a72a57dfe180..9cf262cd017a 100644
--- a/include/sfx2/sfx.hrc
+++ b/include/sfx2/sfx.hrc
@@ -124,6 +124,7 @@
 #define STR_SIGNATURE_OK                    (RID_SFX_START+144)
 #define STR_REFRESH_MASTER_PASSWORD         (RID_SFX_START+145)
 #define STR_REFRESH_PASSWORD                (RID_SFX_START+146)
+#define STR_DANGEROUS_TO_OPEN               (RID_SFX_START+147)
 
 // group ids
 
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index c8821157da4e..2bc1817607f0 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -28,6 +28,8 @@
 #include <sfx2/docfile.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/objsh.hxx>
+#include <sfx2/sfxresid.hxx>
+#include <sfx2/sfx.hrc>
 #include <sfx2/viewfrm.hxx>
 #include <sfx2/viewsh.hxx>
 #include <svl/stritem.hxx>
@@ -36,6 +38,7 @@
 #include <vcl/image.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/settings.hxx>
+#include <vcl/window.hxx>
 #include <sal/macros.h>
 #include <tools/rcid.h>
 #include <unotools/charclass.hxx>
@@ -876,15 +879,46 @@ void ScGlobal::OpenURL(const OUString& rURL, const 
OUString& rTarget)
     if ( nScClickMouseModifier & KEY_SHIFT )     // control-click -> into new 
window
         aTarget.SetValue("_blank");
     SfxViewFrame* pFrame = nullptr;
+    SfxObjectShell* pObjShell = nullptr;
     OUString aReferName;
     if ( pScActiveViewShell )
     {
         pFrame = pScActiveViewShell->GetViewFrame();
-        SfxMedium* pMed = pFrame->GetObjectShell()->GetMedium();
+        pObjShell = pFrame->GetObjectShell();
+        SfxMedium* pMed = pObjShell->GetMedium();
         if (pMed)
             aReferName = pMed->GetName();
     }
 
+    if (INetURLObject(rURL).IsExoticProtocol())
+    {
+        // Default to ignoring exotic protocols
+        bool bAllow = false;
+        if (pObjShell)
+        {
+            // If the document had macros when loaded then follow the allowed 
macro-mode
+            if (pObjShell->GetHadCheckedMacrosOnLoad())
+                bAllow = pObjShell->AdjustMacroMode();
+            else // otherwise ask the user, defaulting to cancel
+            {
+                assert(pFrame && "if we have pObjShell we have pFrame");
+                //Reuse URITools::onOpenURI warning string
+                ScopedVclPtrInstance<MessageDialog> 
xQueryBox(&pFrame->GetWindow(),
+                                                               
SfxResId(STR_DANGEROUS_TO_OPEN),
+                                                               
VclMessageType::Warning, VclButtonsType::YesNo);
+                
xQueryBox->set_primary_text(xQueryBox->get_primary_text().replaceFirst("$(ARG1)",
+                    INetURLObject::decode(rURL, 
INetURLObject::DecodeMechanism::Unambiguous)));
+                //TODO: xQueryBox->set_default_response(RET_NO);
+                bAllow = xQueryBox->Execute() == RET_YES;
+            }
+        }
+        if (!bAllow)
+        {
+            SAL_WARN("sc", "ScGlobal::OpenURL ignoring: " << rURL);
+            return;
+        }
+    }
+
     SfxFrameItem aFrm( SID_DOCFRAME, pFrame );
     SfxStringItem aReferer( SID_REFERER, aReferName );
 
diff --git a/sfx2/source/appl/app.src b/sfx2/source/appl/app.src
index 6c3bb53d2330..7f2b2b6ceb5b 100644
--- a/sfx2/source/appl/app.src
+++ b/sfx2/source/appl/app.src
@@ -60,6 +60,11 @@ String STR_NO_ABS_URI_REF
     Text [ en-US ] = "\"$(ARG1)\" is not an absolute URL that can be passed to 
an external application to open it." ;
 };
 
+String STR_DANGEROUS_TO_OPEN
+{
+    Text [ en-US ] = "It might be dangerous to open \"$(ARG1)\".
Do you really want to open it?" ;
+};
+
 String GID_INTERN
 {
     Text [ en-US ] = "Internal" ;
diff --git a/sfx2/source/doc/docmacromode.cxx b/sfx2/source/doc/docmacromode.cxx
index 4d2d566f3c02..3453e0facaf0 100644
--- a/sfx2/source/doc/docmacromode.cxx
+++ b/sfx2/source/doc/docmacromode.cxx
@@ -386,8 +386,12 @@ namespace sfx2
         return bHasMacros;
     }
 
+    bool DocumentMacroMode::hasMacros() const
+    {
+        return m_xData->m_rDocumentAccess.documentStorageHasMacros() || 
hasMacroLibrary() || m_xData->m_rDocumentAccess.macroCallsSeenWhileLoading();
+    }
 
-    bool DocumentMacroMode::checkMacrosOnLoading( const Reference< 
XInteractionHandler >& rxInteraction )
+    bool DocumentMacroMode::checkMacrosOnLoading( const Reference< 
XInteractionHandler >& rxInteraction, bool bHasMacros )
     {
         bool bAllow = false;
         if ( SvtSecurityOptions().IsMacroDisabled() )
@@ -397,7 +401,7 @@ namespace sfx2
         }
         else
         {
-            if (m_xData->m_rDocumentAccess.documentStorageHasMacros() || 
hasMacroLibrary() || m_xData->m_rDocumentAccess.macroCallsSeenWhileLoading())
+            if (bHasMacros)
             {
                 bAllow = adjustMacroMode( rxInteraction );
             }
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 26efe689106e..02be193c75c1 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -949,9 +949,15 @@ void SfxObjectShell::CheckSecurityOnLoading_Impl()
     CheckEncryption_Impl( xInteraction );
 
     // check macro security
-    pImpl->aMacroMode.checkMacrosOnLoading( xInteraction );
+    const bool bHasMacros = pImpl->aMacroMode.hasMacros();
+    pImpl->aMacroMode.checkMacrosOnLoading( xInteraction, bHasMacros );
+    pImpl->m_bHadCheckedMacrosOnLoad = bHasMacros;
 }
 
+bool SfxObjectShell::GetHadCheckedMacrosOnLoad() const
+{
+    return pImpl->m_bHadCheckedMacrosOnLoad;
+}
 
 void SfxObjectShell::CheckEncryption_Impl( const uno::Reference< 
task::XInteractionHandler >& xHandler )
 {
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index b033b666c843..e1c138c477bd 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -238,6 +238,7 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& 
_rDocShell )
     ,m_bAllowShareControlFileClean( true )
     ,m_bConfigOptionsChecked( false )
     ,m_bMacroCallsSeenWhileLoading( false )
+    ,m_bHadCheckedMacrosOnLoad( false )
     ,lErr(ERRCODE_NONE)
     ,nEventId ( SfxEventHintId::NONE )
     ,pReloadTimer ( nullptr)
diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx
index 913516aa0edf..18b5dc9ce27a 100644
--- a/sfx2/source/inc/objshimp.hxx
+++ b/sfx2/source/inc/objshimp.hxx
@@ -95,7 +95,8 @@ struct SfxObjectShell_Impl : public 
::sfx2::IMacroDocumentAccess
                         m_bSharedXMLFlag:1, // whether the document should be 
edited in shared mode
                         m_bAllowShareControlFileClean:1, // whether the flag 
should be stored in xml file
                         m_bConfigOptionsChecked:1, // whether or not the user 
options are checked after the Options dialog is closed.
-                        m_bMacroCallsSeenWhileLoading:1; // whether or not the 
user options are checked after the Options dialog is closed.
+                        m_bMacroCallsSeenWhileLoading:1, // whether or not 
macro calls were seen when loading document.
+                        m_bHadCheckedMacrosOnLoad:1; // if document contained 
macros (or calls) when loaded
 
     IndexBitSet         aBitSet;
     sal_uInt32          lErr;

Reply via email to