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

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