Blame SOURCES/0001-disable-generation-of-ole-previews-in-ODF-format-unt.patch

f325b2
From da6682c1cf339cb711a6ba2d28673978d42e446a Mon Sep 17 00:00:00 2001
f325b2
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
f325b2
Date: Tue, 13 Sep 2016 12:32:04 +0100
f325b2
Subject: [PATCH] disable generation of ole previews in ODF format until after
f325b2
 load
f325b2
MIME-Version: 1.0
f325b2
Content-Type: text/plain; charset=UTF-8
f325b2
Content-Transfer-Encoding: 8bit
f325b2
f325b2
so the user update links dialog can control their generation
f325b2
f325b2
SdrEmbedObjectLink becomes exposed to calc so it can
f325b2
detect if the link dialog needs to be used to update
f325b2
ole links.
f325b2
f325b2
Reviewed-on: https://gerrit.libreoffice.org/28879
f325b2
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
f325b2
Tested-by: Caolán McNamara <caolanm@redhat.com>
f325b2
(cherry picked from commit 74844277cc2194c9e43f5bd7a6f78a9603da32f3)
f325b2
f325b2
detangle gadzillion checks into something readable
f325b2
f325b2
no logic change intended
f325b2
f325b2
(cherry picked from commit fad9786b06d188ba6e354620f57176f3d94a6637)
f325b2
f325b2
+ partial merge of
f325b2
f325b2
commit c09b3e32372537be739182b02ae83a96386d1e1c
f325b2
Author: Noel Grandin <noel@peralex.com>
f325b2
Date:   Tue Mar 8 13:13:59 2016 +0200
f325b2
f325b2
    loplugin:constantparam in sw
f325b2
f325b2
for bool bUI is always true in UpdateLinks
f325b2
f325b2
Unmodified default SdrOle2Obj size is 101x101
f325b2
f325b2
svx/source/unodraw/unoshape.cxx
f325b2
f325b2
sets a css::awt::Size maSize to 100, 100
f325b2
f325b2
svx/source/unodraw/unopage.cxx
f325b2
f325b2
increases that by 1, 1
f325b2
f325b2
awt::Size aSize = xShape->getSize();
f325b2
aSize.Width += 1;
f325b2
aSize.Height += 1;
f325b2
f325b2
to call SdrObjFactory::MakeNewObject with 101, 101
f325b2
so default size is 101x101 (getWidth() vs GetWidth() confusion ?)
f325b2
f325b2
Reviewed-on: https://gerrit.libreoffice.org/28895
f325b2
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
f325b2
Tested-by: Caolán McNamara <caolanm@redhat.com>
f325b2
(cherry picked from commit 7f0a219c9ad38ae33b51ff69d545f69659691c1e)
f325b2
f325b2
b6af93afc1f80b7fc36239c96d5e0a71fcbcb789
f325b2
4d4375dff64d7b8e236d1a24322e749e04ee530f
f325b2
Reviewed-on: https://gerrit.libreoffice.org/28930
f325b2
Tested-by: Jenkins <ci@libreoffice.org>
f325b2
Reviewed-by: Michael Stahl <mstahl@redhat.com>
f325b2
Reviewed-by: Eike Rathke <erack@redhat.com>
f325b2
Tested-by: Eike Rathke <erack@redhat.com>
f325b2
f325b2
(cherry picked from commit 2ff4c68b63c4842ec85a21287317096b6ca8e66e)
f325b2
f325b2
Change-Id: Id1dd7ea17342140eab9307d546528747e3a98090
f325b2
---
f325b2
 embeddedobj/source/commonembedding/visobj.cxx      |  6 +-
f325b2
 include/svx/svdoole2.hxx                           | 16 ++++
f325b2
 sc/inc/documentlinkmgr.hxx                         |  5 +-
f325b2
 sc/source/ui/docshell/docsh.cxx                    |  7 +-
f325b2
 sc/source/ui/docshell/docsh4.cxx                   | 12 ++-
f325b2
 sc/source/ui/docshell/documentlinkmgr.cxx          | 26 ++++++-
f325b2
 sc/source/ui/view/tabvwsh4.cxx                     |  2 +-
f325b2
 sd/source/core/drawdoc.cxx                         |  6 ++
f325b2
 sd/source/ui/docshell/docshel4.cxx                 |  5 +-
f325b2
 svx/source/svdraw/svdoole2.cxx                     | 20 -----
f325b2
 svx/source/unodraw/unoshap4.cxx                    |  4 +-
f325b2
 sw/inc/IDocumentLinksAdministration.hxx            |  2 +-
f325b2
 .../doc/DocumentLinksAdministrationManager.cxx     | 85 ++++++++++++----------
f325b2
 .../inc/DocumentLinksAdministrationManager.hxx     |  2 +-
f325b2
 sw/source/filter/basflt/shellio.cxx                |  2 +-
f325b2
 sw/source/uibase/app/docsh.cxx                     |  2 +-
f325b2
 sw/source/uibase/app/docshini.cxx                  |  3 +
f325b2
 17 files changed, 131 insertions(+), 74 deletions(-)
f325b2
f325b2
diff --git a/embeddedobj/source/commonembedding/visobj.cxx b/embeddedobj/source/commonembedding/visobj.cxx
f325b2
index fea7c3a2cf0a..3ee85851af9f 100644
f325b2
--- a/embeddedobj/source/commonembedding/visobj.cxx
f325b2
+++ b/embeddedobj/source/commonembedding/visobj.cxx
f325b2
@@ -174,7 +174,11 @@ embed::VisualRepresentation SAL_CALL OCommonEmbeddedObject::getPreferredVisualRe
f325b2
     bool bBackToLoaded = false;
f325b2
     if ( m_nObjectState == embed::EmbedStates::LOADED )
f325b2
     {
f325b2
-        changeState( embed::EmbedStates::RUNNING );
f325b2
+        awt::Size aOrigSize = getVisualAreaSize(nAspect);
f325b2
+        changeState(embed::EmbedStates::RUNNING);
f325b2
+        awt::Size aNewSize = getVisualAreaSize(nAspect);
f325b2
+        if (aOrigSize.Width != aNewSize.Width || aOrigSize.Height != aNewSize.Height)
f325b2
+            setVisualAreaSize(nAspect, aOrigSize);
f325b2
 
f325b2
         // the links should be switched back to loaded state for now to avoid locking problems
f325b2
         bBackToLoaded = m_bIsLink;
f325b2
diff --git a/include/svx/svdoole2.hxx b/include/svx/svdoole2.hxx
f325b2
index f14646b20428..7f47ebff607b 100644
f325b2
--- a/include/svx/svdoole2.hxx
f325b2
+++ b/include/svx/svdoole2.hxx
f325b2
@@ -22,6 +22,7 @@
f325b2
 
f325b2
 #include <svx/svdorect.hxx>
f325b2
 #include <svx/svxdllapi.h>
f325b2
+#include <sfx2/linkmgr.hxx>
f325b2
 
f325b2
 #include <com/sun/star/uno/Reference.h>
f325b2
 
f325b2
@@ -179,6 +180,21 @@ public:
f325b2
     virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const SAL_OVERRIDE;
f325b2
 };
f325b2
 
f325b2
+class SVX_DLLPUBLIC SdrEmbedObjectLink : public sfx2::SvBaseLink
f325b2
+{
f325b2
+    SdrOle2Obj*         pObj;
f325b2
+
f325b2
+public:
f325b2
+    explicit            SdrEmbedObjectLink(SdrOle2Obj* pObj);
f325b2
+    virtual             ~SdrEmbedObjectLink();
f325b2
+
f325b2
+    virtual void        Closed() override;
f325b2
+    virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
f325b2
+        const OUString& rMimeType, const css::uno::Any & rValue ) override;
f325b2
+
f325b2
+    bool                Connect() { return GetRealObject() != nullptr; }
f325b2
+};
f325b2
+
f325b2
 #endif // INCLUDED_SVX_SVDOOLE2_HXX
f325b2
 
f325b2
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
f325b2
diff --git a/sc/inc/documentlinkmgr.hxx b/sc/inc/documentlinkmgr.hxx
f325b2
index 0af5cf896c63..cc42410ca3dc 100644
f325b2
--- a/sc/inc/documentlinkmgr.hxx
f325b2
+++ b/sc/inc/documentlinkmgr.hxx
f325b2
@@ -53,14 +53,17 @@ public:
f325b2
     bool idleCheckLinks();
f325b2
 
f325b2
     bool hasDdeLinks() const;
f325b2
+    bool hasDdeOrOleLinks() const;
f325b2
 
f325b2
-    bool updateDdeLinks( vcl::Window* pWin );
f325b2
+    bool updateDdeOrOleLinks(vcl::Window* pWin);
f325b2
 
f325b2
     bool updateDdeLink( const OUString& rAppl, const OUString& rTopic, const OUString& rItem );
f325b2
 
f325b2
     size_t getDdeLinkCount() const;
f325b2
 
f325b2
     void disconnectDdeLinks();
f325b2
+private:
f325b2
+    bool hasDdeOrOleLinks(bool bDde, bool bOle) const;
f325b2
 };
f325b2
 
f325b2
 }
f325b2
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
f325b2
index d0c083625465..25dab86e5ca0 100644
f325b2
--- a/sc/source/ui/docshell/docsh.cxx
f325b2
+++ b/sc/source/ui/docshell/docsh.cxx
f325b2
@@ -561,9 +561,12 @@ bool ScDocShell::Load( SfxMedium& rMedium )
f325b2
 
f325b2
     GetUndoManager()->Clear();
f325b2
 
f325b2
-    bool bRet = SfxObjectShell::Load( rMedium );
f325b2
-    if( bRet )
f325b2
+    bool bRet = SfxObjectShell::Load(rMedium);
f325b2
+    if (bRet)
f325b2
     {
f325b2
+        comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = getEmbeddedObjectContainer();
f325b2
+        rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
f325b2
+
f325b2
         if (GetMedium())
f325b2
         {
f325b2
             SFX_ITEMSET_ARG( rMedium.GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, false);
f325b2
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
f325b2
index 969c678e4ce1..9fcf549c8920 100644
f325b2
--- a/sc/source/ui/docshell/docsh4.cxx
f325b2
+++ b/sc/source/ui/docshell/docsh4.cxx
f325b2
@@ -29,6 +29,7 @@ using namespace ::com::sun::star;
f325b2
 
f325b2
 #include "scitems.hxx"
f325b2
 #include <sfx2/fcontnr.hxx>
f325b2
+#include <sfx2/linkmgr.hxx>
f325b2
 #include <sfx2/objface.hxx>
f325b2
 #include <sfx2/docfile.hxx>
f325b2
 #include <svtools/ehdl.hxx>
f325b2
@@ -42,6 +43,7 @@ using namespace ::com::sun::star;
f325b2
 #include <svx/drawitem.hxx>
f325b2
 #include <svx/fmshell.hxx>
f325b2
 #include <svtools/xwindowitem.hxx>
f325b2
+#include <svx/svdoole2.hxx>
f325b2
 #include <sfx2/passwd.hxx>
f325b2
 #include <sfx2/filedlghelper.hxx>
f325b2
 #include <sfx2/dispatch.hxx>
f325b2
@@ -407,6 +409,9 @@ void ScDocShell::Execute( SfxRequest& rReq )
f325b2
             break;
f325b2
         case SID_UPDATETABLINKS:
f325b2
             {
f325b2
+                comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = getEmbeddedObjectContainer();
f325b2
+                rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true);
f325b2
+
f325b2
                 ScDocument& rDoc = GetDocument();
f325b2
 
f325b2
                 ScLkUpdMode nSet = rDoc.GetLinkMode();
f325b2
@@ -450,9 +455,9 @@ void ScDocShell::Execute( SfxRequest& rReq )
f325b2
                     ReloadTabLinks();
f325b2
                     aDocument.UpdateExternalRefLinks(GetActiveDialogParent());
f325b2
 
f325b2
-                    bool bAny = aDocument.GetDocLinkManager().updateDdeLinks(GetActiveDialogParent());
f325b2
+                    bool bAnyDde = aDocument.GetDocLinkManager().updateDdeOrOleLinks(GetActiveDialogParent());
f325b2
 
f325b2
-                    if (bAny)
f325b2
+                    if (bAnyDde)
f325b2
                     {
f325b2
                         //  Formeln berechnen und painten wie im TrackTimeHdl
f325b2
                         aDocument.TrackFormulas();
f325b2
@@ -468,7 +473,10 @@ void ScDocShell::Execute( SfxRequest& rReq )
f325b2
                     rReq.Done();
f325b2
                 }
f325b2
                 else
f325b2
+                {
f325b2
+                    rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
f325b2
                     rReq.Ignore();
f325b2
+                }
f325b2
             }
f325b2
             break;
f325b2
 
f325b2
diff --git a/sc/source/ui/docshell/documentlinkmgr.cxx b/sc/source/ui/docshell/documentlinkmgr.cxx
f325b2
index 42745eb3f344..8e5a5c3a02bb 100644
f325b2
--- a/sc/source/ui/docshell/documentlinkmgr.cxx
f325b2
+++ b/sc/source/ui/docshell/documentlinkmgr.cxx
f325b2
@@ -23,7 +23,7 @@
f325b2
 #include <sc.hrc>
f325b2
 #include <scresid.hxx>
f325b2
 
f325b2
-#include <sfx2/linkmgr.hxx>
f325b2
+#include <svx/svdoole2.hxx>
f325b2
 #include <vcl/layout.hxx>
f325b2
 
f325b2
 #include <boost/noncopyable.hpp>
f325b2
@@ -115,6 +115,16 @@ bool DocumentLinkManager::idleCheckLinks()
f325b2
 
f325b2
 bool DocumentLinkManager::hasDdeLinks() const
f325b2
 {
f325b2
+    return hasDdeOrOleLinks(true, false);
f325b2
+}
f325b2
+
f325b2
+bool DocumentLinkManager::hasDdeOrOleLinks() const
f325b2
+{
f325b2
+    return hasDdeOrOleLinks(true, true);
f325b2
+}
f325b2
+
f325b2
+bool DocumentLinkManager::hasDdeOrOleLinks(bool bDde, bool bOle) const
f325b2
+{
f325b2
     if (!mpImpl->mpLinkManager)
f325b2
         return false;
f325b2
 
f325b2
@@ -122,14 +132,16 @@ bool DocumentLinkManager::hasDdeLinks() const
f325b2
     for (size_t i = 0, n = rLinks.size(); i < n; ++i)
f325b2
     {
f325b2
         sfx2::SvBaseLink* pBase = *rLinks[i];
f325b2
-        if (dynamic_cast<ScDdeLink*>(pBase))
f325b2
+        if (bDde && dynamic_cast<ScDdeLink*>(pBase))
f325b2
+            return true;
f325b2
+        if (bOle && dynamic_cast<SdrEmbedObjectLink*>(pBase))
f325b2
             return true;
f325b2
     }
f325b2
 
f325b2
     return false;
f325b2
 }
f325b2
 
f325b2
-bool DocumentLinkManager::updateDdeLinks( vcl::Window* pWin )
f325b2
+bool DocumentLinkManager::updateDdeOrOleLinks( vcl::Window* pWin )
f325b2
 {
f325b2
     if (!mpImpl->mpLinkManager)
f325b2
         return false;
f325b2
@@ -143,6 +155,14 @@ bool DocumentLinkManager::updateDdeLinks( vcl::Window* pWin )
f325b2
     for (size_t i = 0, n = rLinks.size(); i < n; ++i)
f325b2
     {
f325b2
         sfx2::SvBaseLink* pBase = *rLinks[i];
f325b2
+
f325b2
+        SdrEmbedObjectLink* pOleLink = dynamic_cast<SdrEmbedObjectLink*>(pBase);
f325b2
+        if (pOleLink)
f325b2
+        {
f325b2
+            pOleLink->Update();
f325b2
+            continue;
f325b2
+        }
f325b2
+
f325b2
         ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>(pBase);
f325b2
         if (!pDdeLink)
f325b2
             continue;
f325b2
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
f325b2
index 64a6e9f0f063..ff3a5a1d94f1 100644
f325b2
--- a/sc/source/ui/view/tabvwsh4.cxx
f325b2
+++ b/sc/source/ui/view/tabvwsh4.cxx
f325b2
@@ -1584,7 +1584,7 @@ void ScTabViewShell::Construct( TriState nForceDesignMode )
f325b2
             if (!bLink)
f325b2
             {
f325b2
                 const sc::DocumentLinkManager& rMgr = rDoc.GetDocLinkManager();
f325b2
-                if (rMgr.hasDdeLinks() || rDoc.HasAreaLinks())
f325b2
+                if (rMgr.hasDdeOrOleLinks() || rDoc.HasAreaLinks())
f325b2
                     bLink = true;
f325b2
             }
f325b2
             if (bLink)
f325b2
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
f325b2
index f820fabaab81..6b5673f66592 100644
f325b2
--- a/sd/source/core/drawdoc.cxx
f325b2
+++ b/sd/source/core/drawdoc.cxx
f325b2
@@ -694,6 +694,12 @@ void SdDrawDocument::UpdateAllLinks()
f325b2
     {
f325b2
         pDocLockedInsertingLinks = this; // lock inserting links. only links in this document should by resolved
f325b2
 
f325b2
+        if (mpDocSh)
f325b2
+        {
f325b2
+            comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = mpDocSh->getEmbeddedObjectContainer();
f325b2
+            rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true);
f325b2
+        }
f325b2
+
f325b2
         pLinkManager->UpdateAllLinks();  // query box: update all links?
f325b2
 
f325b2
         if( pDocLockedInsertingLinks == this )
f325b2
diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx
f325b2
index bed2fd7b4e97..b56f46e717f9 100644
f325b2
--- a/sd/source/ui/docshell/docshel4.cxx
f325b2
+++ b/sd/source/ui/docshell/docshel4.cxx
f325b2
@@ -285,8 +285,11 @@ bool DrawDocShell::Load( SfxMedium& rMedium )
f325b2
     }
f325b2
 
f325b2
     bRet = SfxObjectShell::Load( rMedium );
f325b2
-    if( bRet )
f325b2
+    if (bRet)
f325b2
     {
f325b2
+        comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = getEmbeddedObjectContainer();
f325b2
+        rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
f325b2
+
f325b2
         bRet = SdXMLFilter( rMedium, *this, true, SDXMLMODE_Normal, SotStorage::GetVersion( rMedium.GetStorage() ) ).Import( nError );
f325b2
     }
f325b2
 
f325b2
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
f325b2
index 403646b6f10e..8985a3bb8a60 100644
f325b2
--- a/svx/source/svdraw/svdoole2.cxx
f325b2
+++ b/svx/source/svdraw/svdoole2.cxx
f325b2
@@ -58,7 +58,6 @@
f325b2
 #include <comphelper/classids.hxx>
f325b2
 
f325b2
 #include <sot/formats.hxx>
f325b2
-#include <sfx2/linkmgr.hxx>
f325b2
 #include <svtools/transfer.hxx>
f325b2
 #include <cppuhelper/implbase5.hxx>
f325b2
 
f325b2
@@ -588,25 +587,6 @@ void SdrLightEmbeddedClient_Impl::setWindow(const uno::Reference< awt::XWindow >
f325b2
     m_xWindow = _xWindow;
f325b2
 }
f325b2
 
f325b2
-
f325b2
-
f325b2
-class SdrEmbedObjectLink : public sfx2::SvBaseLink
f325b2
-{
f325b2
-    SdrOle2Obj*         pObj;
f325b2
-
f325b2
-public:
f325b2
-                        SdrEmbedObjectLink(SdrOle2Obj* pObj);
f325b2
-    virtual             ~SdrEmbedObjectLink();
f325b2
-
f325b2
-    virtual void        Closed() SAL_OVERRIDE;
f325b2
-    virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
f325b2
-        const OUString& rMimeType, const ::com::sun::star::uno::Any & rValue ) SAL_OVERRIDE;
f325b2
-
f325b2
-    bool                Connect() { return GetRealObject() != NULL; }
f325b2
-};
f325b2
-
f325b2
-
f325b2
-
f325b2
 SdrEmbedObjectLink::SdrEmbedObjectLink(SdrOle2Obj* pObject):
f325b2
     ::sfx2::SvBaseLink( ::SfxLinkUpdateMode::ONCALL, SotClipboardFormatId::SVXB ),
f325b2
     pObj(pObject)
f325b2
diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx
f325b2
index 9b9d7500b162..002f69e35dec 100644
f325b2
--- a/svx/source/unodraw/unoshap4.cxx
f325b2
+++ b/svx/source/unodraw/unoshap4.cxx
f325b2
@@ -416,7 +416,7 @@ bool SvxOle2Shape::createObject( const SvGlobalName &aClassName )
f325b2
     if( xObj.is() )
f325b2
     {
f325b2
         Rectangle aRect = pOle2Obj->GetLogicRect();
f325b2
-        if ( aRect.GetWidth() == 100 && aRect.GetHeight() == 100 )
f325b2
+        if ( aRect.GetWidth() == 101 && aRect.GetHeight() == 101 )
f325b2
         {
f325b2
             // TODO/LATER: is it possible that this method is used to create an iconified object?
f325b2
             // default size
f325b2
@@ -484,7 +484,7 @@ bool SvxOle2Shape::createLink( const OUString& aLinkURL )
f325b2
     if( xObj.is() )
f325b2
     {
f325b2
         Rectangle aRect = pOle2Obj->GetLogicRect();
f325b2
-        if ( aRect.GetWidth() == 100 && aRect.GetHeight() == 100 )
f325b2
+        if ( aRect.GetWidth() == 101 && aRect.GetHeight() == 101 )
f325b2
         {
f325b2
             // default size
f325b2
             try
f325b2
diff --git a/sw/inc/IDocumentLinksAdministration.hxx b/sw/inc/IDocumentLinksAdministration.hxx
f325b2
index 8d4f4c74d47f..e618b111e427 100644
f325b2
--- a/sw/inc/IDocumentLinksAdministration.hxx
f325b2
+++ b/sw/inc/IDocumentLinksAdministration.hxx
f325b2
@@ -46,7 +46,7 @@ using rtl::OUString;
f325b2
     /** #i42634# Moved common code of SwReader::Read() and
f325b2
         SwDocShell::UpdateLinks() to new SwDoc::UpdateLinks():
f325b2
     */
f325b2
-    virtual void UpdateLinks(bool bUI) = 0;
f325b2
+    virtual void UpdateLinks() = 0;
f325b2
 
f325b2
     /** SS fuers Linken von Dokumentteilen  / ?? for linking of parts of documents.
f325b2
     */
f325b2
diff --git a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
f325b2
index 989a85240f58..882050b52f45 100644
f325b2
--- a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
f325b2
+++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
f325b2
@@ -199,47 +199,58 @@ const sfx2::LinkManager& DocumentLinksAdministrationManager::GetLinkManager() co
f325b2
 
f325b2
 // #i42634# Moved common code of SwReader::Read() and SwDocShell::UpdateLinks()
f325b2
 // to new SwDoc::UpdateLinks():
f325b2
-void DocumentLinksAdministrationManager::UpdateLinks( bool bUI )
f325b2
+void DocumentLinksAdministrationManager::UpdateLinks()
f325b2
 {
f325b2
-    SfxObjectCreateMode eMode;
f325b2
-    sal_uInt16 nLinkMode = m_rDoc.GetDocumentSettingManager().getLinkUpdateMode( true );
f325b2
-    if ( m_rDoc.GetDocShell()) {
f325b2
-        sal_uInt16 nUpdateDocMode = m_rDoc.GetDocShell()->GetUpdateDocMode();
f325b2
-        if( (nLinkMode != NEVER ||  document::UpdateDocMode::FULL_UPDATE == nUpdateDocMode) &&
f325b2
-            !GetLinkManager().GetLinks().empty() &&
f325b2
-            SfxObjectCreateMode::INTERNAL !=
f325b2
-                        ( eMode = m_rDoc.GetDocShell()->GetCreateMode()) &&
f325b2
-            SfxObjectCreateMode::ORGANIZER != eMode &&
f325b2
-            SfxObjectCreateMode::PREVIEW != eMode &&
f325b2
-            !m_rDoc.GetDocShell()->IsPreview() )
f325b2
+    if (!m_rDoc.GetDocShell())
f325b2
+        return;
f325b2
+    SfxObjectCreateMode eMode = m_rDoc.GetDocShell()->GetCreateMode();
f325b2
+    if (eMode == SfxObjectCreateMode::INTERNAL)
f325b2
+        return;
f325b2
+    if (eMode == SfxObjectCreateMode::ORGANIZER)
f325b2
+        return;
f325b2
+    if (eMode == SfxObjectCreateMode::PREVIEW)
f325b2
+        return;
f325b2
+    if (m_rDoc.GetDocShell()->IsPreview())
f325b2
+        return;
f325b2
+    if (GetLinkManager().GetLinks().empty())
f325b2
+        return;
f325b2
+    sal_uInt16 nLinkMode = m_rDoc.GetDocumentSettingManager().getLinkUpdateMode(true);
f325b2
+    sal_uInt16 nUpdateDocMode = m_rDoc.GetDocShell()->GetUpdateDocMode();
f325b2
+    if (nLinkMode == NEVER && nUpdateDocMode != document::UpdateDocMode::FULL_UPDATE)
f325b2
+        return;
f325b2
+
f325b2
+    bool bAskUpdate = nLinkMode == MANUAL;
f325b2
+    bool bUpdate = true;
f325b2
+    switch(nUpdateDocMode)
f325b2
+    {
f325b2
+        case document::UpdateDocMode::NO_UPDATE:   bUpdate = false;break;
f325b2
+        case document::UpdateDocMode::QUIET_UPDATE:bAskUpdate = false; break;
f325b2
+        case document::UpdateDocMode::FULL_UPDATE: bAskUpdate = true; break;
f325b2
+    }
f325b2
+    if (nLinkMode == AUTOMATIC && !bAskUpdate)
f325b2
+    {
f325b2
+        SfxMedium * medium = m_rDoc.GetDocShell()->GetMedium();
f325b2
+        if (!SvtSecurityOptions().isTrustedLocationUriForUpdatingLinks(
f325b2
+                medium == nullptr ? OUString() : medium->GetName()))
f325b2
         {
f325b2
-            bool bAskUpdate = nLinkMode == MANUAL;
f325b2
-            bool bUpdate = true;
f325b2
-            switch(nUpdateDocMode)
f325b2
-            {
f325b2
-                case document::UpdateDocMode::NO_UPDATE:   bUpdate = false;break;
f325b2
-                case document::UpdateDocMode::QUIET_UPDATE:bAskUpdate = false; break;
f325b2
-                case document::UpdateDocMode::FULL_UPDATE: bAskUpdate = true; break;
f325b2
-            }
f325b2
-            if (nLinkMode == AUTOMATIC && !bAskUpdate)
f325b2
-            {
f325b2
-                SfxMedium * medium = m_rDoc.GetDocShell()->GetMedium();
f325b2
-                if (!SvtSecurityOptions().isTrustedLocationUriForUpdatingLinks(
f325b2
-                        medium == nullptr ? OUString() : medium->GetName()))
f325b2
-                {
f325b2
-                    bAskUpdate = true;
f325b2
-                }
f325b2
-            }
f325b2
-            if( bUpdate && (bUI || !bAskUpdate) )
f325b2
-            {
f325b2
-                SfxMedium* pMedium = m_rDoc.GetDocShell()->GetMedium();
f325b2
-                SfxFrame* pFrm = pMedium ? pMedium->GetLoadTargetFrame() : 0;
f325b2
-                vcl::Window* pDlgParent = pFrm ? &pFrm->GetWindow() : 0;
f325b2
-
f325b2
-                GetLinkManager().UpdateAllLinks( bAskUpdate, true, false, pDlgParent );
f325b2
-            }
f325b2
+            bAskUpdate = true;
f325b2
         }
f325b2
     }
f325b2
+    comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = m_rDoc.GetDocShell()->getEmbeddedObjectContainer();
f325b2
+    if (bUpdate)
f325b2
+    {
f325b2
+        rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true);
f325b2
+
f325b2
+        SfxMedium* pMedium = m_rDoc.GetDocShell()->GetMedium();
f325b2
+        SfxFrame* pFrame = pMedium ? pMedium->GetLoadTargetFrame() : nullptr;
f325b2
+        vcl::Window* pDlgParent = pFrame ? &pFrame->GetWindow() : nullptr;
f325b2
+
f325b2
+        GetLinkManager().UpdateAllLinks( bAskUpdate, true, false, pDlgParent );
f325b2
+    }
f325b2
+    else
f325b2
+    {
f325b2
+        rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
f325b2
+    }
f325b2
 }
f325b2
 
f325b2
 bool DocumentLinksAdministrationManager::GetData( const OUString& rItem, const OUString& rMimeType,
f325b2
diff --git a/sw/source/core/inc/DocumentLinksAdministrationManager.hxx b/sw/source/core/inc/DocumentLinksAdministrationManager.hxx
f325b2
index 79eb9adf3b96..712cb7942b74 100644
f325b2
--- a/sw/source/core/inc/DocumentLinksAdministrationManager.hxx
f325b2
+++ b/sw/source/core/inc/DocumentLinksAdministrationManager.hxx
f325b2
@@ -47,7 +47,7 @@ public:
f325b2
 
f325b2
     const sfx2::LinkManager& GetLinkManager() const SAL_OVERRIDE;
f325b2
 
f325b2
-    void UpdateLinks(bool bUI) SAL_OVERRIDE;
f325b2
+    void UpdateLinks() override;
f325b2
 
f325b2
     bool GetData(const OUString& rItem, const OUString& rMimeType, ::com::sun::star::uno::Any& rValue) const SAL_OVERRIDE;
f325b2
 
f325b2
diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx
f325b2
index d42b0642a52c..b111e80d73cc 100644
f325b2
--- a/sw/source/filter/basflt/shellio.cxx
f325b2
+++ b/sw/source/filter/basflt/shellio.cxx
f325b2
@@ -364,7 +364,7 @@ sal_uLong SwReader::Read( const Reader& rOptions )
f325b2
         // #i42634# Moved common code of SwReader::Read() and
f325b2
         // SwDocShell::UpdateLinks() to new SwDoc::UpdateLinks():
f325b2
     // ATM still with Update
f325b2
-        pDoc->getIDocumentLinksAdministration().UpdateLinks( true );
f325b2
+        pDoc->getIDocumentLinksAdministration().UpdateLinks();
f325b2
 
f325b2
         // not insert: set the redline mode read from settings.xml
f325b2
         eOld = static_cast<RedlineMode_t>(
f325b2
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
f325b2
index 6655f045539e..dd307248832e 100644
f325b2
--- a/sw/source/uibase/app/docsh.cxx
f325b2
+++ b/sw/source/uibase/app/docsh.cxx
f325b2
@@ -1179,7 +1179,7 @@ void SwDocShell::CalcLayoutForOLEObjects()
f325b2
 // read by the binary filter:
f325b2
 void SwDocShell::UpdateLinks()
f325b2
 {
f325b2
-    GetDoc()->getIDocumentLinksAdministration().UpdateLinks(true);
f325b2
+    GetDoc()->getIDocumentLinksAdministration().UpdateLinks();
f325b2
     // #i50703# Update footnote numbers
f325b2
     SwTextFootnote::SetUniqueSeqRefNo( *GetDoc() );
f325b2
     SwNodeIndex aTmp( GetDoc()->GetNodes() );
f325b2
diff --git a/sw/source/uibase/app/docshini.cxx b/sw/source/uibase/app/docshini.cxx
f325b2
index fca4e2e44657..faefa968d26c 100644
f325b2
--- a/sw/source/uibase/app/docshini.cxx
f325b2
+++ b/sw/source/uibase/app/docshini.cxx
f325b2
@@ -486,6 +486,9 @@ bool  SwDocShell::Load( SfxMedium& rMedium )
f325b2
     bool bRet = false;
f325b2
     if( SfxObjectShell::Load( rMedium ))
f325b2
     {
f325b2
+        comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = getEmbeddedObjectContainer();
f325b2
+        rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
f325b2
+
f325b2
         SAL_INFO( "sw.ui", "after SfxInPlaceObject::Load" );
f325b2
         if (m_pDoc)              // for last version!!
f325b2
             RemoveLink();       // release the existing
f325b2
-- 
f325b2
2.12.0
f325b2