embeddedobj/source/commonembedding/visobj.cxx             |    5 
 include/svx/svdoole2.hxx                                  |   16 ++
 sc/inc/documentlinkmgr.hxx                                |    5 
 sc/source/ui/docshell/docsh.cxx                           |    7 -
 sc/source/ui/docshell/docsh4.cxx                          |   12 +-
 sc/source/ui/docshell/documentlinkmgr.cxx                 |   26 +++-
 sc/source/ui/view/tabvwsh4.cxx                            |    2 
 sd/source/core/drawdoc.cxx                                |    6 +
 sd/source/ui/docshell/docshel4.cxx                        |    4 
 svx/source/svdraw/svdoole2.cxx                            |   18 ---
 svx/source/unodraw/unoshap4.cxx                           |    4 
 sw/source/core/doc/DocumentLinksAdministrationManager.cxx |   83 +++++++-------
 sw/source/uibase/app/docshini.cxx                         |    3 
 13 files changed, 124 insertions(+), 67 deletions(-)

New commits:
commit 8c20df32c8278bc4a076cef285db7788627f4c07
Author: Caolán McNamara <caol...@redhat.com>
Date:   Tue Sep 13 12:32:04 2016 +0100

    disable generation of ole previews in ODF format until after load
    
    so the user update links dialog can control their generation
    
    SdrEmbedObjectLink becomes exposed to calc so it can
    detect if the link dialog needs to be used to update
    ole links.
    
    Reviewed-on: https://gerrit.libreoffice.org/28879
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>
    (cherry picked from commit 74844277cc2194c9e43f5bd7a6f78a9603da32f3)
    
    Change-Id: Id1dd7ea17342140eab9307d546528747e3a98090
    
    detangle gadzillion checks into something readable
    
    no logic change intended
    
    Change-Id: Ib6af93afc1f80b7fc36239c96d5e0a71fcbcb789
    (cherry picked from commit fad9786b06d188ba6e354620f57176f3d94a6637)
    
    Unmodified default SdrOle2Obj size is 101x101
    
    svx/source/unodraw/unoshape.cxx
    
    sets a css::awt::Size maSize to 100, 100
    
    svx/source/unodraw/unopage.cxx
    
    increases that by 1, 1
    
    awt::Size aSize = xShape->getSize();
    aSize.Width += 1;
    aSize.Height += 1;
    
    to call SdrObjFactory::MakeNewObject with 101, 101
    so default size is 101x101 (getWidth() vs GetWidth() confusion ?)
    
    Change-Id: I4d4375dff64d7b8e236d1a24322e749e04ee530f
    Reviewed-on: https://gerrit.libreoffice.org/28895
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>
    (cherry picked from commit 7f0a219c9ad38ae33b51ff69d545f69659691c1e)
    Reviewed-on: https://gerrit.libreoffice.org/28926
    Reviewed-by: Michael Stahl <mst...@redhat.com>
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Eike Rathke <er...@redhat.com>

diff --git a/embeddedobj/source/commonembedding/visobj.cxx 
b/embeddedobj/source/commonembedding/visobj.cxx
index fea7c3a..6bf9c49 100644
--- a/embeddedobj/source/commonembedding/visobj.cxx
+++ b/embeddedobj/source/commonembedding/visobj.cxx
@@ -174,7 +174,10 @@ embed::VisualRepresentation SAL_CALL 
OCommonEmbeddedObject::getPreferredVisualRe
     bool bBackToLoaded = false;
     if ( m_nObjectState == embed::EmbedStates::LOADED )
     {
-        changeState( embed::EmbedStates::RUNNING );
+        awt::Size aOrigSize = getVisualAreaSize(nAspect);
+        changeState(embed::EmbedStates::RUNNING);
+        if (aOrigSize != getVisualAreaSize(nAspect))
+            setVisualAreaSize(nAspect, aOrigSize);
 
         // the links should be switched back to loaded state for now to avoid 
locking problems
         bBackToLoaded = m_bIsLink;
diff --git a/include/svx/svdoole2.hxx b/include/svx/svdoole2.hxx
index cd21df9..3629ce7 100644
--- a/include/svx/svdoole2.hxx
+++ b/include/svx/svdoole2.hxx
@@ -22,6 +22,7 @@
 
 #include <svx/svdorect.hxx>
 #include <svx/svxdllapi.h>
+#include <sfx2/linkmgr.hxx>
 
 #include <com/sun/star/uno/Reference.h>
 
@@ -175,6 +176,21 @@ public:
     virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const 
override;
 };
 
+class SVX_DLLPUBLIC SdrEmbedObjectLink : public sfx2::SvBaseLink
+{
+    SdrOle2Obj*         pObj;
+
+public:
+    explicit            SdrEmbedObjectLink(SdrOle2Obj* pObj);
+    virtual             ~SdrEmbedObjectLink();
+
+    virtual void        Closed() override;
+    virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
+        const OUString& rMimeType, const css::uno::Any & rValue ) override;
+
+    bool                Connect() { return GetRealObject() != nullptr; }
+};
+
 #endif // INCLUDED_SVX_SVDOOLE2_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/documentlinkmgr.hxx b/sc/inc/documentlinkmgr.hxx
index 4553470..d5d801a 100644
--- a/sc/inc/documentlinkmgr.hxx
+++ b/sc/inc/documentlinkmgr.hxx
@@ -55,14 +55,17 @@ public:
     bool idleCheckLinks();
 
     bool hasDdeLinks() const;
+    bool hasDdeOrOleLinks() const;
 
-    bool updateDdeLinks( vcl::Window* pWin );
+    bool updateDdeOrOleLinks(vcl::Window* pWin);
 
     void updateDdeLink( const OUString& rAppl, const OUString& rTopic, const 
OUString& rItem );
 
     size_t getDdeLinkCount() const;
 
     void disconnectDdeLinks();
+private:
+    bool hasDdeOrOleLinks(bool bDde, bool bOle) const;
 };
 
 }
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 163024e..dcb7722 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -559,9 +559,12 @@ bool ScDocShell::Load( SfxMedium& rMedium )
 
     GetUndoManager()->Clear();
 
-    bool bRet = SfxObjectShell::Load( rMedium );
-    if( bRet )
+    bool bRet = SfxObjectShell::Load(rMedium);
+    if (bRet)
     {
+        comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = 
getEmbeddedObjectContainer();
+        rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
+
         if (GetMedium())
         {
             const SfxUInt16Item* pUpdateDocItem = 
SfxItemSet::GetItem<SfxUInt16Item>(rMedium.GetItemSet(), SID_UPDATEDOCMODE, 
false);
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index bdf1c52..853692c 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -30,6 +30,7 @@ using namespace ::com::sun::star;
 #include "scitems.hxx"
 #include <editeng/flstitem.hxx>
 #include <sfx2/fcontnr.hxx>
+#include <sfx2/linkmgr.hxx>
 #include <sfx2/objface.hxx>
 #include <sfx2/docfile.hxx>
 #include <svtools/ehdl.hxx>
@@ -43,6 +44,7 @@ using namespace ::com::sun::star;
 #include <svx/drawitem.hxx>
 #include <svx/fmshell.hxx>
 #include <svtools/xwindowitem.hxx>
+#include <svx/svdoole2.hxx>
 #include <sfx2/passwd.hxx>
 #include <sfx2/filedlghelper.hxx>
 #include <sfx2/dispatch.hxx>
@@ -400,6 +402,9 @@ void ScDocShell::Execute( SfxRequest& rReq )
             break;
         case SID_UPDATETABLINKS:
             {
+                comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer 
= getEmbeddedObjectContainer();
+                rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true);
+
                 ScDocument& rDoc = GetDocument();
 
                 ScLkUpdMode nSet = rDoc.GetLinkMode();
@@ -443,9 +448,9 @@ void ScDocShell::Execute( SfxRequest& rReq )
                     ReloadTabLinks();
                     aDocument.UpdateExternalRefLinks(GetActiveDialogParent());
 
-                    bool bAny = 
aDocument.GetDocLinkManager().updateDdeLinks(GetActiveDialogParent());
+                    bool bAnyDde = 
aDocument.GetDocLinkManager().updateDdeOrOleLinks(GetActiveDialogParent());
 
-                    if (bAny)
+                    if (bAnyDde)
                     {
                         //  Formeln berechnen und painten wie im TrackTimeHdl
                         aDocument.TrackFormulas();
@@ -461,7 +466,10 @@ void ScDocShell::Execute( SfxRequest& rReq )
                     rReq.Done();
                 }
                 else
+                {
+                    rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
                     rReq.Ignore();
+                }
             }
             break;
 
diff --git a/sc/source/ui/docshell/documentlinkmgr.cxx 
b/sc/source/ui/docshell/documentlinkmgr.cxx
index 02f00e9..520b854 100644
--- a/sc/source/ui/docshell/documentlinkmgr.cxx
+++ b/sc/source/ui/docshell/documentlinkmgr.cxx
@@ -23,7 +23,7 @@
 #include <sc.hrc>
 #include <scresid.hxx>
 
-#include <sfx2/linkmgr.hxx>
+#include <svx/svdoole2.hxx>
 #include <vcl/layout.hxx>
 
 #include <memory>
@@ -115,6 +115,16 @@ bool DocumentLinkManager::idleCheckLinks()
 
 bool DocumentLinkManager::hasDdeLinks() const
 {
+    return hasDdeOrOleLinks(true, false);
+}
+
+bool DocumentLinkManager::hasDdeOrOleLinks() const
+{
+    return hasDdeOrOleLinks(true, true);
+}
+
+bool DocumentLinkManager::hasDdeOrOleLinks(bool bDde, bool bOle) const
+{
     if (!mpImpl->mpLinkManager)
         return false;
 
@@ -122,14 +132,16 @@ bool DocumentLinkManager::hasDdeLinks() const
     for (const auto & rLink : rLinks)
     {
         sfx2::SvBaseLink* pBase = rLink.get();
-        if (dynamic_cast<ScDdeLink*>(pBase))
+        if (bDde && dynamic_cast<ScDdeLink*>(pBase))
+            return true;
+        if (bOle && dynamic_cast<SdrEmbedObjectLink*>(pBase))
             return true;
     }
 
     return false;
 }
 
-bool DocumentLinkManager::updateDdeLinks( vcl::Window* pWin )
+bool DocumentLinkManager::updateDdeOrOleLinks( vcl::Window* pWin )
 {
     if (!mpImpl->mpLinkManager)
         return false;
@@ -143,6 +155,14 @@ bool DocumentLinkManager::updateDdeLinks( vcl::Window* 
pWin )
     for (const auto & rLink : rLinks)
     {
         sfx2::SvBaseLink* pBase = rLink.get();
+
+        SdrEmbedObjectLink* pOleLink = 
dynamic_cast<SdrEmbedObjectLink*>(pBase);
+        if (pOleLink)
+        {
+            pOleLink->Update();
+            continue;
+        }
+
         ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>(pBase);
         if (!pDdeLink)
             continue;
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 2d8825b..a8f3197 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -1564,7 +1564,7 @@ void ScTabViewShell::Construct( TriState nForceDesignMode 
)
             if (!bLink)
             {
                 const sc::DocumentLinkManager& rMgr = rDoc.GetDocLinkManager();
-                if (rMgr.hasDdeLinks() || rDoc.HasAreaLinks())
+                if (rMgr.hasDdeOrOleLinks() || rDoc.HasAreaLinks())
                     bLink = true;
             }
             if (bLink)
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index 2bf77d9..80dc851 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -726,6 +726,12 @@ void SdDrawDocument::UpdateAllLinks()
     {
         s_pDocLockedInsertingLinks = this; // lock inserting links. only links 
in this document should by resolved
 
+        if (mpDocSh)
+        {
+            comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = 
mpDocSh->getEmbeddedObjectContainer();
+            rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true);
+        }
+
         pLinkManager->UpdateAllLinks();  // query box: update all links?
 
         if (s_pDocLockedInsertingLinks == this)
diff --git a/sd/source/ui/docshell/docshel4.cxx 
b/sd/source/ui/docshell/docshel4.cxx
index f2d43e9..277db86 100644
--- a/sd/source/ui/docshell/docshel4.cxx
+++ b/sd/source/ui/docshell/docshel4.cxx
@@ -287,8 +287,10 @@ bool DrawDocShell::Load( SfxMedium& rMedium )
     }
 
     bRet = SfxObjectShell::Load( rMedium );
-    if( bRet )
+    if (bRet)
     {
+        comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = 
getEmbeddedObjectContainer();
+        rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
         bRet = SdXMLFilter( rMedium, *this, SDXMLMODE_Normal, 
SotStorage::GetVersion( rMedium.GetStorage() ) ).Import( nError );
     }
 
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index 0b8116e..e06391d 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -58,7 +58,6 @@
 #include <comphelper/classids.hxx>
 
 #include <sot/formats.hxx>
-#include <sfx2/linkmgr.hxx>
 #include <svtools/transfer.hxx>
 #include <cppuhelper/implbase.hxx>
 
@@ -588,23 +587,6 @@ void SdrLightEmbeddedClient_Impl::setWindow(const 
uno::Reference< awt::XWindow >
     m_xWindow = _xWindow;
 }
 
-
-class SdrEmbedObjectLink : public sfx2::SvBaseLink
-{
-    SdrOle2Obj*         pObj;
-
-public:
-    explicit            SdrEmbedObjectLink(SdrOle2Obj* pObj);
-    virtual             ~SdrEmbedObjectLink();
-
-    virtual void        Closed() override;
-    virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
-        const OUString& rMimeType, const css::uno::Any & rValue ) override;
-
-    bool                Connect() { return GetRealObject() != nullptr; }
-};
-
-
 SdrEmbedObjectLink::SdrEmbedObjectLink(SdrOle2Obj* pObject):
     ::sfx2::SvBaseLink( ::SfxLinkUpdateMode::ONCALL, 
SotClipboardFormatId::SVXB ),
     pObj(pObject)
diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx
index 093d72f..4fc1f5a 100644
--- a/svx/source/unodraw/unoshap4.cxx
+++ b/svx/source/unodraw/unoshap4.cxx
@@ -416,7 +416,7 @@ bool SvxOle2Shape::createObject( const SvGlobalName 
&aClassName )
     if( xObj.is() )
     {
         Rectangle aRect = pOle2Obj->GetLogicRect();
-        if ( aRect.GetWidth() == 100 && aRect.GetHeight() == 100 )
+        if ( aRect.GetWidth() == 101 && aRect.GetHeight() == 101 )
         {
             // TODO/LATER: is it possible that this method is used to create 
an iconified object?
             // default size
@@ -484,7 +484,7 @@ void SvxOle2Shape::createLink( const OUString& aLinkURL )
     if( xObj.is() )
     {
         Rectangle aRect = pOle2Obj->GetLogicRect();
-        if ( aRect.GetWidth() == 100 && aRect.GetHeight() == 100 )
+        if ( aRect.GetWidth() == 101 && aRect.GetHeight() == 101 )
         {
             // default size
             try
diff --git a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx 
b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
index 39a8032..0949aa7 100644
--- a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
+++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
@@ -199,45 +199,56 @@ const sfx2::LinkManager& 
DocumentLinksAdministrationManager::GetLinkManager() co
 // to new SwDoc::UpdateLinks():
 void DocumentLinksAdministrationManager::UpdateLinks()
 {
-    SfxObjectCreateMode eMode;
-    sal_uInt16 nLinkMode = 
m_rDoc.GetDocumentSettingManager().getLinkUpdateMode( true );
-    if ( m_rDoc.GetDocShell()) {
-        sal_uInt16 nUpdateDocMode = m_rDoc.GetDocShell()->GetUpdateDocMode();
-        if( (nLinkMode != NEVER ||  document::UpdateDocMode::FULL_UPDATE == 
nUpdateDocMode) &&
-            !GetLinkManager().GetLinks().empty() &&
-            SfxObjectCreateMode::INTERNAL !=
-                        ( eMode = m_rDoc.GetDocShell()->GetCreateMode()) &&
-            SfxObjectCreateMode::ORGANIZER != eMode &&
-            SfxObjectCreateMode::PREVIEW != eMode &&
-            !m_rDoc.GetDocShell()->IsPreview() )
+    if (!m_rDoc.GetDocShell())
+        return;
+    SfxObjectCreateMode eMode = m_rDoc.GetDocShell()->GetCreateMode();
+    if (eMode == SfxObjectCreateMode::INTERNAL)
+        return;
+    if (eMode == SfxObjectCreateMode::ORGANIZER)
+        return;
+    if (eMode == SfxObjectCreateMode::PREVIEW)
+        return;
+    if (m_rDoc.GetDocShell()->IsPreview())
+        return;
+    if (GetLinkManager().GetLinks().empty())
+        return;
+    sal_uInt16 nLinkMode = 
m_rDoc.GetDocumentSettingManager().getLinkUpdateMode(true);
+    sal_uInt16 nUpdateDocMode = m_rDoc.GetDocShell()->GetUpdateDocMode();
+    if (nLinkMode == NEVER && nUpdateDocMode != 
document::UpdateDocMode::FULL_UPDATE)
+        return;
+
+    bool bAskUpdate = nLinkMode == MANUAL;
+    bool bUpdate = true;
+    switch(nUpdateDocMode)
+    {
+        case document::UpdateDocMode::NO_UPDATE:   bUpdate = false;break;
+        case document::UpdateDocMode::QUIET_UPDATE:bAskUpdate = false; break;
+        case document::UpdateDocMode::FULL_UPDATE: bAskUpdate = true; break;
+    }
+    if (nLinkMode == AUTOMATIC && !bAskUpdate)
+    {
+        SfxMedium * medium = m_rDoc.GetDocShell()->GetMedium();
+        if (!SvtSecurityOptions().isTrustedLocationUriForUpdatingLinks(
+                medium == nullptr ? OUString() : medium->GetName()))
         {
-            bool bAskUpdate = nLinkMode == MANUAL;
-            bool bUpdate = true;
-            switch(nUpdateDocMode)
-            {
-                case document::UpdateDocMode::NO_UPDATE:   bUpdate = 
false;break;
-                case document::UpdateDocMode::QUIET_UPDATE:bAskUpdate = false; 
break;
-                case document::UpdateDocMode::FULL_UPDATE: bAskUpdate = true; 
break;
-            }
-            if (nLinkMode == AUTOMATIC && !bAskUpdate)
-            {
-                SfxMedium * medium = m_rDoc.GetDocShell()->GetMedium();
-                if (!SvtSecurityOptions().isTrustedLocationUriForUpdatingLinks(
-                        medium == nullptr ? OUString() : medium->GetName()))
-                {
-                    bAskUpdate = true;
-                }
-            }
-            if( bUpdate )
-            {
-                SfxMedium* pMedium = m_rDoc.GetDocShell()->GetMedium();
-                SfxFrame* pFrame = pMedium ? pMedium->GetLoadTargetFrame() : 
nullptr;
-                vcl::Window* pDlgParent = pFrame ? &pFrame->GetWindow() : 
nullptr;
-
-                GetLinkManager().UpdateAllLinks( bAskUpdate, true, false, 
pDlgParent );
-            }
+            bAskUpdate = true;
         }
     }
+    comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = 
m_rDoc.GetDocShell()->getEmbeddedObjectContainer();
+    if (bUpdate)
+    {
+        rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true);
+
+        SfxMedium* pMedium = m_rDoc.GetDocShell()->GetMedium();
+        SfxFrame* pFrame = pMedium ? pMedium->GetLoadTargetFrame() : nullptr;
+        vcl::Window* pDlgParent = pFrame ? &pFrame->GetWindow() : nullptr;
+
+        GetLinkManager().UpdateAllLinks( bAskUpdate, true, false, pDlgParent );
+    }
+    else
+    {
+        rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
+    }
 }
 
 bool DocumentLinksAdministrationManager::GetData( const OUString& rItem, const 
OUString& rMimeType,
diff --git a/sw/source/uibase/app/docshini.cxx 
b/sw/source/uibase/app/docshini.cxx
index 92b2394..5be4089 100644
--- a/sw/source/uibase/app/docshini.cxx
+++ b/sw/source/uibase/app/docshini.cxx
@@ -492,6 +492,9 @@ bool  SwDocShell::Load( SfxMedium& rMedium )
     bool bRet = false;
     if( SfxObjectShell::Load( rMedium ))
     {
+        comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = 
getEmbeddedObjectContainer();
+        rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
+
         SAL_INFO( "sw.ui", "after SfxInPlaceObject::Load" );
         if (m_pDoc)              // for last version!!
             RemoveLink();       // release the existing
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to