sfx2/source/appl/linkmgr2.cxx |   25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

New commits:
commit e4e7616ab4c4fe23c9ec25c93a8006cef230b330
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Jan 16 13:21:46 2025 +0500
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Jan 17 09:46:00 2025 +0100

    LOK: Do not try to show an "update links" dialog
    
    In commit f8528cdda9292c7ae6c9d49b80c1a3a3b4a67094 (LOK: don't crash
    when trying to show a dialog during file load, 2024-12-26), all not
    yet async / not properly set up dialogs made to fail gracefully. In
    the follow-up https://gerrit.libreoffice.org/c/core/+/180334, an
    assert is added to still fail in debug builds.
    
    The specific "update links" dialog case, that triggered the original
    change in the first place, does not need to appear at all in the LOK
    case, because there is no external documents available for updating.
    This change avoids the dialog in that case.
    
    Change-Id: I7c6bc755d87656f002829460f4768fed34dc2f17
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180354
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx
index 3412d727c656..22bccfe904e2 100644
--- a/sfx2/source/appl/linkmgr2.cxx
+++ b/sfx2/source/appl/linkmgr2.cxx
@@ -17,6 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <comphelper/lok.hxx>
 #include <comphelper/string.hxx>
 #include <sfx2/linkmgr.hxx>
 #include <sfx2/sfxsids.hrc>
@@ -277,6 +280,12 @@ bool LinkManager::GetDisplayNames( const SvBaseLink * 
pLink,
     return bRet;
 }
 
+static void disallowAllLinksUpdate(SvBaseLink* pShellProvider)
+{
+    if (SfxObjectShell* pShell = 
pShellProvider->GetLinkManager()->GetPersist())
+        pShell->getEmbeddedObjectContainer().setUserAllowsLinkUpdate(false);
+}
+
 void LinkManager::UpdateAllLinks(
     bool bAskUpdate,
     bool bUpdateGrfLinks,
@@ -322,6 +331,13 @@ void LinkManager::UpdateAllLinks(
 
         if( bAskUpdate )
         {
+            if (comphelper::LibreOfficeKit::isActive())
+            {
+                // only one document in jail, no update possible
+                disallowAllLinksUpdate(pLink);
+                return;
+            }
+
             OUString aMsg = SfxResId(STR_QUERY_UPDATE_LINKS);
             INetURLObject aURL(pPersist->getDocumentBaseURL());
             aMsg = aMsg.replaceFirst("%{filename}", aURL.GetLastName());
@@ -333,14 +349,7 @@ void LinkManager::UpdateAllLinks(
             int nRet = xQueryBox->run();
             if( RET_YES != nRet )
             {
-                SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist();
-
-                if(pShell)
-                {
-                    comphelper::EmbeddedObjectContainer& 
rEmbeddedObjectContainer = pShell->getEmbeddedObjectContainer();
-                    rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
-                }
-
+                disallowAllLinksUpdate(pLink);
                 return ;        // nothing should be updated
             }
             bAskUpdate = false;  // once is enough

Reply via email to