[libreoffice] 04/07: ubuntu13: arbitrary file read via link update
Rene Engelhard
rene at moszumanska.debian.org
Thu Jul 27 19:17:16 UTC 2017
This is an automated email from the git hooks/post-receive script.
rene pushed a commit to tag libreoffice_3.5.7_0ubuntu13
in repository libreoffice.
commit 01dea7f7f3615f47fd580b7af9b0cba3c57820e6
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Tue Feb 21 13:32:58 2017 +0100
ubuntu13: arbitrary file read via link update
---
changelog | 12 +-
control | 2 +-
patches/olefix.diff | 788 ++++++++++++++++++++++++++++++++++++++++++++++++++++
patches/series | 1 +
4 files changed, 800 insertions(+), 3 deletions(-)
diff --git a/changelog b/changelog
index c7afe36..69f7b7c 100644
--- a/changelog
+++ b/changelog
@@ -1,6 +1,14 @@
-libreoffice (1:3.5.7-0ubuntu12~precise1) precise; urgency=medium
+libreoffice (1:3.5.7-0ubuntu13) precise; urgency=low
- * SECURITY UPDATE: possible arbritrary code execution via out-of-bounds
+ * SECURITY UPDATE: arbitrary file read via link update
+ - debian/patches/olefix.diff
+ - CVE-2017-3157
+
+ -- Bjoern Michaelsen <bjoern.michaelsen at canonical.com> Mon, 20 Feb 2017 19:52:34 +0100
+
+libreoffice (1:3.5.7-0ubuntu12) precise-security; urgency=medium
+
+ * SECURITY UPDATE: possible arbitrary code execution via out-of-bounds
polygon array
- debian/patches/poly-bounds.diff: check polygon array bounds
- CVE-2016-1513
diff --git a/control b/control
index 1f4b3ea..5da6b04 100644
--- a/control
+++ b/control
@@ -4,7 +4,7 @@ Priority: optional
Maintainer: Ubuntu Developers <ubuntu-devel-discuss at lists.ubuntu.com>
XSBC-Original-Maintainer: Debian LibreOffice Maintainers <debian-openoffice at lists.debian.org>
Uploaders: Rene Engelhard <rene at debian.org>
-Build-Depends: dpkg-dev (>= 1.16.1), lsb-release, bzip2, bison, flex | flex-old, libxaw7-dev, unzip, zip, autoconf, automake, sharutils, pkg-config, libfontconfig1-dev, libc0.1 (>= 2.10.2-7) [kfreebsd-i386 kfreebsd-amd64], zlib1g-dev, libfreetype6-dev, libx11-dev, libsm-dev, libxt-dev, libxext-dev, libxtst-dev, libice-dev, libcups2-dev, libarchive-zip-perl, fastjar, xsltproc, libxkbfile-dev, libxinerama-dev, x11proto-render-dev, libxml-parser-perl, gperf, po-debconf, bc, wget | curl, gcc [...]
+Build-Depends: dpkg-dev (>= 1.16.1), lsb-release, bzip2, bison, flex | flex-old, libxaw7-dev, unzip, zip, autoconf, automake, sharutils, pkg-config, libfontconfig1-dev, libc0.1 (>= 2.10.2-7) [kfreebsd-i386 kfreebsd-amd64], zlib1g-dev, libfreetype6-dev, libx11-dev, libsm-dev, libxt-dev, libxext-dev, libxtst-dev, libice-dev, libcups2-dev, libarchive-zip-perl, fastjar, xsltproc, libxkbfile-dev, libxinerama-dev, x11proto-render-dev, libxml-parser-perl, gperf, po-debconf, bc, wget | curl, lib [...]
Build-Depends-Indep: fdupes, xml-core, imagemagick, fontforge
Build-Conflicts: libcairo2 (= 1.4.8-1), libxul-dev (= 1.8.0.13~pre070720-0etch1), gjdoc (= 0.7.8-2), libc6-dev (= 2.6.1-3) [i386 amd64], libc6-dev (= 2.6.1-4) [i386 amd64], libc0.1-dev (= 2.13-26) [kfreebsd-i386 kfreebsd-amd64], nvidia-glx-dev, nvidia-glx-legacy-dev, gcj-4.2 (= 4.2.2-6), flex (= 2.5.34-1) [amd64], libboost1.39-dev (<< 1.39.0-2), graphicsmagick-imagemagick-compat (<< 1.3.9~), qt3-dev-tools, ant (= 1.8.0-1) [hppa kfreebsd-i386 kfreebsd-amd64], ant (= 1.8.0-2) [hppa kfreebs [...]
Standards-Version: 3.9.1
diff --git a/patches/olefix.diff b/patches/olefix.diff
new file mode 100644
index 0000000..75d026a
--- /dev/null
+++ b/patches/olefix.diff
@@ -0,0 +1,788 @@
+diff --git a/embeddedobj/source/commonembedding/visobj.cxx b/embeddedobj/source/commonembedding/visobj.cxx
+index 4c8d353..302a98f 100644
+--- a/embeddedobj/source/commonembedding/visobj.cxx
++++ b/embeddedobj/source/commonembedding/visobj.cxx
+@@ -191,7 +191,11 @@ embed::VisualRepresentation SAL_CALL OCommonEmbeddedObject::getPreferredVisualRe
+ sal_Bool bBackToLoaded = sal_False;
+ if ( m_nObjectState == embed::EmbedStates::LOADED )
+ {
+- changeState( embed::EmbedStates::RUNNING );
++ awt::Size aOrigSize = getVisualAreaSize(nAspect);
++ changeState(embed::EmbedStates::RUNNING);
++ awt::Size aNewSize = getVisualAreaSize(nAspect);
++ if (aOrigSize.Width != aNewSize.Width || aOrigSize.Height != aNewSize.Height)
++ setVisualAreaSize(nAspect, aOrigSize);
+
+ // the links should be switched back to loaded state for now to avoid locking problems
+ bBackToLoaded = m_bIsLink;
+diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
+index 93c3c66..92da63e 100644
+--- a/sc/Library_sc.mk
++++ b/sc/Library_sc.mk
+@@ -550,6 +550,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
+ sc/source/ui/view/viewfunc \
+ sc/source/ui/view/viewutil \
+ sc/source/ui/view/waitoff \
++ sc/source/ui/docshell/documentlinkmgr \
+ ))
+
+ $(eval $(call gb_SdiTarget_SdiTarget,sc/sdi/scslots,sc/sdi/scalc))
+diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
+index 50bcd27..8e641a6 100644
+--- a/sc/inc/document.hxx
++++ b/sc/inc/document.hxx
+@@ -51,6 +51,7 @@
+ #include <list>
+ #include <vector>
+ #include <boost/ptr_container/ptr_vector.hpp>
++#include <documentlinkmgr.hxx>
+
+ namespace editeng { class SvxBorderLine; }
+
+@@ -225,6 +226,7 @@ friend class ScDocRowHeightUpdater;
+
+ typedef ::std::vector<ScTable*> TableContainer;
+ private:
++ mutable boost::scoped_ptr<sc::DocumentLinkManager> mpDocLinkMgr;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager;
+
+ rtl::Reference<ScPoolHelper> xPoolHelper;
+@@ -442,6 +444,9 @@ public:
+ rtl::Reference<XColorList> GetColorList();
+
+ SC_DLLPUBLIC sfx2::LinkManager* GetLinkManager() const;
++ sc::DocumentLinkManager& GetDocLinkManager();
++ const sc::DocumentLinkManager& GetDocLinkManager() const;
++
+
+ SC_DLLPUBLIC const ScDocOptions& GetDocOptions() const;
+ SC_DLLPUBLIC void SetDocOptions( const ScDocOptions& rOpt );
+diff --git a/sc/inc/documentlinkmgr.hxx b/sc/inc/documentlinkmgr.hxx
+new file mode 100644
+index 0000000..fee53fc
+--- /dev/null
++++ b/sc/inc/documentlinkmgr.hxx
+@@ -0,0 +1,59 @@
++/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
++/*
++ * This file is part of the LibreOffice project.
++ *
++ * This Source Code Form is subject to the terms of the Mozilla Public
++ * License, v. 2.0. If a copy of the MPL was not distributed with this
++ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
++ */
++
++#ifndef SC_DOCUMENTLINKMGR_HXX
++#define SC_DOCUMENTLINKMGR_HXX
++
++#include <boost/noncopyable.hpp>
++#include <sfx2/linkmgr.hxx>
++
++namespace sc {
++
++class DataStream;
++struct DocumentLinkManagerImpl;
++
++class DocumentLinkManager : boost::noncopyable
++{
++ DocumentLinkManagerImpl* mpImpl;
++
++public:
++ DocumentLinkManager();
++ ~DocumentLinkManager();
++
++ /**
++ * @param bCreate if true, create a new link manager instance in case one
++ * does not exist.
++ *
++ * @return link manager instance.
++ */
++ sfx2::LinkManager* getLinkManager( bool bCreate = true );
++
++ const sfx2::LinkManager* getExistingLinkManager() const;
++
++ bool idleCheckLinks();
++
++ bool hasDdeLinks() const;
++ bool hasDdeOrOleLinks() const;
++
++ bool updateDdeOrOleLinks(Window* pWin);
++
++ bool updateDdeLink( const rtl::OUString& rAppl, const rtl::OUString& rTopic, const rtl::OUString& rItem );
++
++ size_t getDdeLinkCount() const;
++
++ void disconnectDdeLinks();
++private:
++ bool hasDdeOrOleLinks(bool bDde, bool bOle) const;
++};
++
++}
++
++#endif
++
++/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
+index cf3e81c..4d94fcf 100644
+--- a/sc/source/core/data/documen2.cxx
++++ b/sc/source/core/data/documen2.cxx
+@@ -267,6 +267,19 @@ sfx2::LinkManager* ScDocument::GetLinkManager() const
+ return pLinkManager;
+ }
+
++sc::DocumentLinkManager& ScDocument::GetDocLinkManager()
++{
++ if (!mpDocLinkMgr)
++ mpDocLinkMgr.reset(new sc::DocumentLinkManager);
++ return *mpDocLinkMgr;
++}
++
++const sc::DocumentLinkManager& ScDocument::GetDocLinkManager() const
++{
++ if (!mpDocLinkMgr)
++ mpDocLinkMgr.reset(new sc::DocumentLinkManager);
++ return *mpDocLinkMgr;
++}
+
+ void ScDocument::SetStorageGrammar( formula::FormulaGrammar::Grammar eGram )
+ {
+diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
+index 8f4f3fc..532190b 100644
+--- a/sc/source/ui/docshell/docsh.cxx
++++ b/sc/source/ui/docshell/docsh.cxx
+@@ -489,9 +489,12 @@ sal_Bool ScDocShell::Load( SfxMedium& rMedium )
+
+ GetUndoManager()->Clear();
+
+- sal_Bool bRet = SfxObjectShell::Load( rMedium );
+- if( bRet )
+- {
++ bool bRet = SfxObjectShell::Load(rMedium);
++ if (bRet)
++ {
++ comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = getEmbeddedObjectContainer();
++ rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
++
+ if (GetMedium())
+ {
+ SFX_ITEMSET_ARG( rMedium.GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, false);
+diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
+index 7332ed2..1f5b6fd 100644
+--- a/sc/source/ui/docshell/docsh4.cxx
++++ b/sc/source/ui/docshell/docsh4.cxx
+@@ -39,6 +39,7 @@ using namespace ::com::sun::star;
+
+ #include "scitems.hxx"
+ #include <sfx2/fcontnr.hxx>
++#include <sfx2/linkmgr.hxx>
+ #include <editeng/eeitem.hxx>
+ #include <sfx2/objface.hxx>
+ #include <sfx2/app.hxx>
+@@ -64,6 +65,7 @@ using namespace ::com::sun::star;
+ #include <svx/svdpage.hxx>
+ #include <svx/fmshell.hxx>
+ #include <svtools/xwindowitem.hxx>
++#include <svx/svdoole2.hxx>
+ #include <sfx2/passwd.hxx>
+ #include <sfx2/filedlghelper.hxx>
+ #include <sfx2/docinsert.hxx>
+@@ -119,6 +121,7 @@ using namespace ::com::sun::star;
+ #include "conditio.hxx"
+ #include "sheetevents.hxx"
+ #include "unotools/securityoptions.hxx"
++#include <documentlinkmgr.hxx>
+
+ //------------------------------------------------------------------
+
+@@ -436,6 +439,8 @@ void ScDocShell::Execute( SfxRequest& rReq )
+ case SID_UPDATETABLINKS:
+ {
+ ScDocument* pDoc = GetDocument();
++ comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = getEmbeddedObjectContainer();
++ rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true);
+
+ ScLkUpdMode nSet=pDoc->GetLinkMode();
+
+@@ -476,14 +481,29 @@ void ScDocShell::Execute( SfxRequest& rReq )
+ {
+ ReloadTabLinks();
+ aDocument.UpdateExternalRefLinks(GetActiveDialogParent());
+- aDocument.UpdateDdeLinks(GetActiveDialogParent());
++
++ bool bAnyDde = aDocument.GetDocLinkManager().updateDdeOrOleLinks(GetActiveDialogParent());
++
++ if (bAnyDde)
++ {
++ // Formeln berechnen und painten wie im TrackTimeHdl
++ aDocument.TrackFormulas();
++ Broadcast(SfxSimpleHint(FID_DATACHANGED));
++
++ // wenn FID_DATACHANGED irgendwann mal asynchron werden sollte
++ // (z.B. mit Invalidate am Window), muss hier ein Update erzwungen werden.
++ }
++
+ aDocument.UpdateAreaLinks();
+
+ //! Test, ob Fehler
+ 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
+new file mode 100644
+index 0000000..722aec8
+--- /dev/null
++++ b/sc/source/ui/docshell/documentlinkmgr.cxx
+@@ -0,0 +1,221 @@
++/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
++/*
++ * This file is part of the LibreOffice project.
++ *
++ * This Source Code Form is subject to the terms of the Mozilla Public
++ * License, v. 2.0. If a copy of the MPL was not distributed with this
++ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
++ */
++
++#include <documentlinkmgr.hxx>
++#include <ddelink.hxx>
++#include <sc.hrc>
++#include <scresid.hxx>
++
++#include <svx/svdoole2.hxx>
++
++#include <boost/noncopyable.hpp>
++#include <boost/scoped_ptr.hpp>
++#include <vcl/msgbox.hxx>
++
++using namespace rtl;
++
++namespace sc {
++
++struct DocumentLinkManagerImpl : boost::noncopyable
++{
++ SfxObjectShell* mpShell;
++ std::unique_ptr<sfx2::LinkManager> mpLinkManager;
++
++ DocumentLinkManagerImpl() {}
++};
++
++DocumentLinkManager::DocumentLinkManager() : mpImpl(new DocumentLinkManagerImpl) {}
++
++DocumentLinkManager::~DocumentLinkManager()
++{
++ delete mpImpl;
++}
++
++sfx2::LinkManager* DocumentLinkManager::getLinkManager( bool bCreate )
++{
++ if (!mpImpl->mpLinkManager && bCreate && mpImpl->mpShell)
++ mpImpl->mpLinkManager.reset(new sfx2::LinkManager(mpImpl->mpShell));
++ return mpImpl->mpLinkManager.get();
++}
++
++const sfx2::LinkManager* DocumentLinkManager::getExistingLinkManager() const
++{
++ return mpImpl->mpLinkManager.get();
++}
++
++bool DocumentLinkManager::idleCheckLinks()
++{
++ if (!mpImpl->mpLinkManager)
++ return false;
++
++ bool bAnyLeft = false;
++ const sfx2::SvBaseLinks& rLinks = mpImpl->mpLinkManager->GetLinks();
++ for (size_t i = 0, n = rLinks.Count(); i < n; ++i)
++ {
++ sfx2::SvBaseLink* pBase = *rLinks[i];
++ ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>(pBase);
++ if (!pDdeLink || !pDdeLink->NeedsUpdate())
++ continue;
++
++ pDdeLink->TryUpdate();
++ if (pDdeLink->NeedsUpdate()) // Was not successful?
++ bAnyLeft = true;
++ }
++
++ return bAnyLeft;
++}
++
++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;
++
++ const sfx2::SvBaseLinks& rLinks = mpImpl->mpLinkManager->GetLinks();
++ for (size_t i = 0, n = rLinks.Count(); i < n; ++i)
++ {
++ sfx2::SvBaseLink* pBase = *rLinks[i];
++ if (bDde && dynamic_cast<ScDdeLink*>(pBase))
++ return true;
++ if (bOle && dynamic_cast<SdrEmbedObjectLink*>(pBase))
++ return true;
++ }
++
++ return false;
++}
++
++bool DocumentLinkManager::updateDdeOrOleLinks( Window* pWin )
++{
++ if (!mpImpl->mpLinkManager)
++ return false;
++
++ sfx2::LinkManager* pMgr = mpImpl->mpLinkManager.get();
++ const sfx2::SvBaseLinks& rLinks = pMgr->GetLinks();
++
++ // If the update takes longer, reset all values so that nothing
++ // old (wrong) is left behind
++ bool bAny = false;
++ for (size_t i = 0, n = rLinks.Count(); i < n; ++i)
++ {
++ sfx2::SvBaseLink* pBase = *rLinks[i];
++
++ SdrEmbedObjectLink* pOleLink = dynamic_cast<SdrEmbedObjectLink*>(pBase);
++ if (pOleLink)
++ {
++ pOleLink->Update();
++ continue;
++ }
++
++ ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>(pBase);
++ if (!pDdeLink)
++ continue;
++
++ if (pDdeLink->Update())
++ bAny = true;
++ else
++ {
++ // Update failed. Notify the user.
++ OUString aFile = pDdeLink->GetTopic();
++ OUString aElem = pDdeLink->GetItem();
++ OUString aType = pDdeLink->GetAppl();
++
++ OUStringBuffer aBuf;
++ aBuf.append(OUString( ResId::toString( ScResId(SCSTR_DDEDOC_NOT_LOADED))));
++ aBuf.append(OUString::createFromAscii("\n\n"));
++ aBuf.append(OUString::createFromAscii("Source : "));
++ aBuf.append(aFile);
++ aBuf.append(OUString::createFromAscii("\nElement : "));
++ aBuf.append(aElem);
++ aBuf.append(OUString::createFromAscii("\nType : "));
++ aBuf.append(aType);
++ ErrorBox aBox(pWin, WB_OK | RET_OK, aBuf.makeStringAndClear());
++ aBox.Execute();
++ }
++ }
++
++ pMgr->CloseCachedComps();
++
++ return bAny;
++}
++
++bool DocumentLinkManager::updateDdeLink( const rtl::OUString& rAppl, const rtl::OUString& rTopic, const rtl::OUString& rItem )
++{
++ if (!mpImpl->mpLinkManager)
++ return false;
++
++ sfx2::LinkManager* pMgr = mpImpl->mpLinkManager.get();
++ const sfx2::SvBaseLinks& rLinks = pMgr->GetLinks();
++
++ bool bFound = false;
++ for (size_t i = 0, n = rLinks.Count(); i < n; ++i)
++ {
++ ::sfx2::SvBaseLink* pBase = *rLinks[i];
++ ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>(pBase);
++ if (!pDdeLink)
++ continue;
++
++ if ( OUString(pDdeLink->GetAppl()) == rAppl &&
++ OUString(pDdeLink->GetTopic()) == rTopic &&
++ OUString(pDdeLink->GetItem()) == rItem )
++ {
++ pDdeLink->TryUpdate();
++ bFound = true; // Could be multiple (Mode), so continue searching
++ }
++ }
++
++ return bFound;
++}
++
++size_t DocumentLinkManager::getDdeLinkCount() const
++{
++ if (!mpImpl->mpLinkManager)
++ return 0;
++
++ size_t nDdeCount = 0;
++ const sfx2::SvBaseLinks& rLinks = mpImpl->mpLinkManager->GetLinks();
++ for (size_t i = 0, n = rLinks.Count(); i < n; ++i)
++ {
++ ::sfx2::SvBaseLink* pBase = *rLinks[i];
++ ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>(pBase);
++ if (!pDdeLink)
++ continue;
++
++ ++nDdeCount;
++ }
++
++ return nDdeCount;
++}
++
++void DocumentLinkManager::disconnectDdeLinks()
++{
++ if (!mpImpl->mpLinkManager)
++ return;
++
++ const sfx2::SvBaseLinks& rLinks = mpImpl->mpLinkManager->GetLinks();
++ for (size_t i = 0, n = rLinks.Count(); i < n; ++i)
++ {
++ ::sfx2::SvBaseLink* pBase = *rLinks[i];
++ ScDdeLink* pDdeLink = dynamic_cast<ScDdeLink*>(pBase);
++ if (pDdeLink)
++ pDdeLink->Disconnect();
++ }
++}
++
++}
++
++/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
+index ffb64a3..c8411d8 100644
+--- a/sc/source/ui/view/tabvwsh4.cxx
++++ b/sc/source/ui/view/tabvwsh4.cxx
+@@ -96,6 +96,7 @@
+ #include "docoptio.hxx"
+ #include "markdata.hxx"
+ #include "preview.hxx"
++#include <documentlinkmgr.hxx>
+
+ #include <com/sun/star/document/XDocumentProperties.hpp>
+
+@@ -1644,8 +1645,11 @@ void ScTabViewShell::Construct( sal_uInt8 nForceDesignMode )
+ bLink = true;
+ }
+ if (!bLink)
+- if (pDoc->HasDdeLinks() || pDoc->HasAreaLinks())
+- bLink = sal_True;
++ {
++ const sc::DocumentLinkManager& rMgr = pDoc->GetDocLinkManager();
++ if (rMgr.hasDdeOrOleLinks() || pDoc->HasAreaLinks())
++ bLink = true;
++ }
+ if (bLink)
+ {
+ if ( !pFirst )
+diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
+index 4d68ef1..9dc9d5b 100644
+--- a/sd/source/core/drawdoc.cxx
++++ b/sd/source/core/drawdoc.cxx
+@@ -719,6 +719,12 @@ void SdDrawDocument::UpdateAllLinks()
+ {
+ 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( pDocLockedInsertingLinks == this )
+diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx
+index a486f56..1019733 100644
+--- a/sd/source/ui/docshell/docshel4.cxx
++++ b/sd/source/ui/docshell/docshel4.cxx
+@@ -311,6 +311,13 @@ sal_Bool DrawDocShell::Load( SfxMedium& rMedium )
+ }
+
+ bRet = SfxObjectShell::Load( rMedium );
++ if (bRet)
++ {
++ comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = getEmbeddedObjectContainer();
++ rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
++
++ bRet = SdXMLFilter( rMedium, *this, true, SDXMLMODE_Normal, SotStorage::GetVersion( rMedium.GetStorage() ) ).Import( nError );
++ }
+ if( bRet )
+ {
+ bRet = SdXMLFilter( rMedium, *this, sal_True, SDXMLMODE_Normal, SotStorage::GetVersion( rMedium.GetStorage() ) ).Import( nError );
+diff --git a/svx/inc/svx/svdoole2.hxx b/svx/inc/svx/svdoole2.hxx
+index 6681e36..1a4e773 100644
+--- a/svx/inc/svx/svdoole2.hxx
++++ b/svx/inc/svx/svdoole2.hxx
+@@ -39,6 +39,8 @@
+ #include <vcl/gdimtf.hxx>
+ #include <sot/storage.hxx>
+ #include "svx/svxdllapi.h"
++#include <sfx2/lnkbase.hxx>
++#include <sfx2/linkmgr.hxx>
+
+ //************************************************************
+ // SdrOle2Obj
+@@ -186,6 +188,21 @@ public:
+ void SetWindow(const com::sun::star::uno::Reference < com::sun::star::awt::XWindow >& _xWindow);
+ };
+
++class SVX_DLLPUBLIC SdrEmbedObjectLink : public sfx2::SvBaseLink
++{
++ SdrOle2Obj* pObj;
++
++public:
++ explicit SdrEmbedObjectLink(SdrOle2Obj* pObj);
++ virtual ~SdrEmbedObjectLink();
++
++ virtual void Closed();
++ virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
++ const String& rMimeType, const com::sun::star::uno::Any & rValue );
++
++ bool Connect() { return GetRealObject() != nullptr; }
++};
++
+ #endif //_SVDOOLE2_HXX
+
+ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
+index db0322d..16d5df0 100644
+--- a/svx/source/svdraw/svdoole2.cxx
++++ b/svx/source/svdraw/svdoole2.cxx
+@@ -594,25 +594,6 @@ void SdrLightEmbeddedClient_Impl::setWindow(const uno::Reference< awt::XWindow >
+ m_xWindow = _xWindow;
+ }
+
+-////////////////////////////////////////////////////////////////////////////////////////////////////
+-
+-class SdrEmbedObjectLink : public sfx2::SvBaseLink
+-{
+- SdrOle2Obj* pObj;
+-
+-public:
+- SdrEmbedObjectLink(SdrOle2Obj* pObj);
+- virtual ~SdrEmbedObjectLink();
+-
+- virtual void Closed();
+- virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
+- const String& rMimeType, const ::com::sun::star::uno::Any & rValue );
+-
+- sal_Bool Connect() { return GetRealObject() != NULL; }
+-};
+-
+-// -----------------------------------------------------------------------------
+-
+ SdrEmbedObjectLink::SdrEmbedObjectLink(SdrOle2Obj* pObject):
+ ::sfx2::SvBaseLink( ::sfx2::LINKUPDATE_ONCALL, SOT_FORMATSTR_ID_SVXB ),
+ pObj(pObject)
+diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx
+index ad517c2..997621e 100644
+--- a/svx/source/unodraw/unoshap4.cxx
++++ b/svx/source/unodraw/unoshap4.cxx
+@@ -475,7 +475,7 @@ sal_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
+@@ -539,7 +539,7 @@ sal_Bool SvxOle2Shape::createLink( const ::rtl::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/inc/IDocumentLinksAdministration.hxx b/sw/inc/IDocumentLinksAdministration.hxx
+index fb3d3c8..bb36db5 100644
+--- a/sw/inc/IDocumentLinksAdministration.hxx
++++ b/sw/inc/IDocumentLinksAdministration.hxx
+@@ -53,7 +53,7 @@ namespace sfx2 { class SvLinkSource; class LinkManager; }
+ /** #i42634# Moved common code of SwReader::Read() and
+ SwDocShell::UpdateLinks() to new SwDoc::UpdateLinks():
+ */
+- virtual void UpdateLinks(sal_Bool bUI) = 0;
++ virtual void UpdateLinks() = 0;
+
+ /** SS fuers Linken von Dokumentteilen / ?? for linking of parts of documents.
+ */
+diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
+index 7943925..9529754 100644
+--- a/sw/inc/doc.hxx
++++ b/sw/inc/doc.hxx
+@@ -793,7 +793,7 @@ public:
+ virtual void SetVisibleLinks(bool bFlag);
+ virtual sfx2::LinkManager& GetLinkManager();
+ virtual const sfx2::LinkManager& GetLinkManager() const;
+- virtual void UpdateLinks(sal_Bool bUI);
++ virtual void UpdateLinks();
+ virtual bool GetData(const String& rItem, const String& rMimeType, ::com::sun::star::uno::Any& rValue) const;
+ virtual bool SetData(const String& rItem, const String& rMimeType, const ::com::sun::star::uno::Any& rValue);
+ virtual ::sfx2::SvLinkSource* CreateLinkSource(const String& rItem);
+diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
+index e40671b..1671098 100644
+--- a/sw/source/core/doc/docnew.cxx
++++ b/sw/source/core/doc/docnew.cxx
+@@ -118,6 +118,7 @@
+
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::document;
++using namespace rtl;
+
+ const sal_Char sFrmFmtStr[] = "Frameformat";
+ const sal_Char sEmptyPageStr[] = "Empty Page";
+@@ -902,58 +903,62 @@ IGrammarContact* getGrammarContact( const SwTxtNode& rTxtNode )
+
+ // #i42634# Moved common code of SwReader::Read() and SwDocShell::UpdateLinks()
+ // to new SwDoc::UpdateLinks():
+-void SwDoc::UpdateLinks( sal_Bool bUI )
++void SwDoc::UpdateLinks( )
+ {
+- SfxObjectCreateMode eMode;
+- sal_uInt16 nLinkMode = getLinkUpdateMode( true );
+- if ( GetDocShell()) {
+- sal_uInt16 nUpdateDocMode = GetDocShell()->GetUpdateDocMode();
+- if( (nLinkMode != NEVER || document::UpdateDocMode::FULL_UPDATE == nUpdateDocMode) &&
+- GetLinkManager().GetLinks().Count() &&
+- SFX_CREATE_MODE_INTERNAL !=
+- ( eMode = GetDocShell()->GetCreateMode()) &&
+- SFX_CREATE_MODE_ORGANIZER != eMode &&
+- SFX_CREATE_MODE_PREVIEW != eMode &&
+- !GetDocShell()->IsPreview() )
+- {
+- ViewShell* pVSh = 0;
+- sal_Bool bAskUpdate = nLinkMode == MANUAL;
+- sal_Bool bUpdate = sal_True;
+- switch(nUpdateDocMode)
+- {
+- case document::UpdateDocMode::NO_UPDATE: bUpdate = sal_False;break;
+- case document::UpdateDocMode::QUIET_UPDATE:bAskUpdate = sal_False; break;
+- case document::UpdateDocMode::FULL_UPDATE: bAskUpdate = sal_True; break;
+- }
+- if (nLinkMode == AUTOMATIC && !bAskUpdate)
+- {
+- SfxMedium * medium = GetDocShell()->GetMedium();
+- if (!SvtSecurityOptions().isTrustedLocationUriForUpdatingLinks(
+- rtl::OUString(medium == nullptr ? String() : medium->GetName())))
+- {
+- bAskUpdate = true;
+- }
+- }
+- if( bUpdate && (bUI || !bAskUpdate) )
+- {
+- SfxMedium* pMedium = GetDocShell()->GetMedium();
+- SfxFrame* pFrm = pMedium ? pMedium->GetLoadTargetFrame() : 0;
+- Window* pDlgParent = pFrm ? &pFrm->GetWindow() : 0;
+- if( GetCurrentViewShell() && !GetEditShell( &pVSh ) && !pVSh ) //swmod 071108//swmod 071225
+- {
+- ViewShell aVSh( *this, 0, 0 );
+-
+- SET_CURR_SHELL( &aVSh );
+- GetLinkManager().UpdateAllLinks( bAskUpdate , sal_True, sal_False, pDlgParent );
+- }
+- else
+- GetLinkManager().UpdateAllLinks( bAskUpdate, sal_True, sal_False, pDlgParent );
+- }
+- }
+- }
+-
++ if (!GetDocShell())
++ return;
++ SfxObjectCreateMode eMode = GetDocShell()->GetCreateMode();
++ if (eMode == SfxObjectCreateMode::SFX_CREATE_MODE_INTERNAL)
++ return;
++ if (eMode == SfxObjectCreateMode::SFX_CREATE_MODE_ORGANIZER)
++ return;
++ if (eMode == SfxObjectCreateMode::SFX_CREATE_MODE_PREVIEW)
++ return;
++ if (GetDocShell()->IsPreview())
++ return;
++ if (GetLinkManager().GetLinks().Count() == 0)
++ return;
++ sal_uInt16 nLinkMode = getLinkUpdateMode(true);
++ sal_uInt16 nUpdateDocMode = 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 = GetDocShell()->GetMedium();
++ if (!SvtSecurityOptions().isTrustedLocationUriForUpdatingLinks(
++ medium == nullptr ? String() : medium->GetName()))
++ {
++ bAskUpdate = true;
++ }
++ }
++ comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = GetDocShell()->getEmbeddedObjectContainer();
++ if (bUpdate)
++ {
++ rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true);
++
++ SfxMedium* pMedium = GetDocShell()->GetMedium();
++ SfxFrame* pFrame = pMedium ? pMedium->GetLoadTargetFrame() : nullptr;
++
++ Window* pDlgParent = pFrame ? &pFrame->GetWindow() : nullptr;
++
++ GetLinkManager().UpdateAllLinks( bAskUpdate, true, false, pDlgParent );
++ }
++ else
++ {
++ rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
++ }
+ }
+
++
+ void SwDoc::SetApplyWorkaroundForB6375613( bool p_bApplyWorkaroundForB6375613 )
+ {
+ if ( mbApplyWorkaroundForB6375613 != p_bApplyWorkaroundForB6375613 )
+diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx
+index 5fe2355..1eb6e1c 100644
+--- a/sw/source/filter/basflt/shellio.cxx
++++ b/sw/source/filter/basflt/shellio.cxx
+@@ -376,7 +376,8 @@ sal_uLong SwReader::Read( const Reader& rOptions )
+ // #i42634# Moved common code of SwReader::Read() and
+ // SwDocShell::UpdateLinks() to new SwDoc::UpdateLinks():
+ // ATM still with Update
+- pDoc->UpdateLinks( sal_True );
++ //pDoc->getIDocumentLinksAdministration().UpdateLinks();
++ pDoc->UpdateLinks();
+
+ // not insert: set the redline mode read from settings.xml
+ eOld = static_cast<RedlineMode_t>(
+diff --git a/sw/source/ui/app/docsh.cxx b/sw/source/ui/app/docsh.cxx
+index 17ff4c0..d5b41c0 100644
+--- a/sw/source/ui/app/docsh.cxx
++++ b/sw/source/ui/app/docsh.cxx
+@@ -1204,7 +1204,7 @@ void SwDocShell::CalcLayoutForOLEObjects()
+ // read by the binary filter:
+ void SwDocShell::UpdateLinks()
+ {
+- GetDoc()->UpdateLinks(sal_True);
++ GetDoc()->UpdateLinks();
+ // #i50703# Update footnote numbers
+ SwTxtFtn::SetUniqueSeqRefNo( *GetDoc() );
+ SwNodeIndex aTmp( GetDoc()->GetNodes() );
diff --git a/patches/series b/patches/series
index 8da4485..e655a03 100644
--- a/patches/series
+++ b/patches/series
@@ -75,3 +75,4 @@ lwpfix4.diff
lwpfix5.diff
rtf-use-after-free.diff
poly-bounds.diff
+olefix.diff
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-openoffice/libreoffice.git
More information about the Pkg-openoffice-commits
mailing list