From 33686f67da4bc640014cb51888fbf90f83375e97 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 21 Dec 2023 14:55:02 +0000 Subject: make use of toplevel docmodel's UserAllowsLinkUpdate property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia560c123c2f9dd08acb7eeaafccee332dd16300e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161133 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- embeddedobj/source/commonembedding/persistence.cxx | 35 ++++++++++++++++++++++ embeddedobj/source/inc/commonembobj.hxx | 2 ++ 2 files changed, 37 insertions(+) (limited to 'embeddedobj') diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx index 6859de216c24..0ce42dce7be7 100644 --- a/embeddedobj/source/commonembedding/persistence.cxx +++ b/embeddedobj/source/commonembedding/persistence.cxx @@ -362,8 +362,43 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::InitNewDocument_Impl() return xDocument; } +bool OCommonEmbeddedObject::getAllowLinkUpdate() const +{ + // assume we can update if we can't determine a parent + bool bAllowLinkUpdate(true); + + try + { + uno::Reference xParent(m_xParent, uno::UNO_QUERY); + while (xParent) + { + uno::Reference xGrandParent(xParent->getParent(), uno::UNO_QUERY); + if (!xGrandParent) + break; + xParent = xGrandParent; + } + + uno::Reference xPropSet(xParent, uno::UNO_QUERY); + if (xPropSet.is()) + { + uno::Any aAny = xPropSet->getPropertyValue("AllowLinkUpdate"); + aAny >>= bAllowLinkUpdate; + } + } + catch (const uno::Exception&) + { + } + + SAL_WARN_IF(!bAllowLinkUpdate, "embeddedobj.common", "getAllowLinkUpdate is false"); + + return bAllowLinkUpdate; +} + uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadLink_Impl() { + if (!getAllowLinkUpdate()) + return nullptr; + sal_Int32 nLen = m_bLinkHasPassword ? 3 : 2; uno::Sequence< beans::PropertyValue > aArgs( m_aDocMediaDescriptor.getLength() + nLen ); auto pArgs = aArgs.getArray(); diff --git a/embeddedobj/source/inc/commonembobj.hxx b/embeddedobj/source/inc/commonembobj.hxx index bbd2de63ec70..ac6c27d10a11 100644 --- a/embeddedobj/source/inc/commonembobj.hxx +++ b/embeddedobj/source/inc/commonembobj.hxx @@ -254,6 +254,8 @@ private: int ShowMsgDialog(TranslateId Msg, const OUString& sFileName); + bool getAllowLinkUpdate() const; + protected: void SetInplaceActiveState(); -- cgit