diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-12-21 14:55:02 +0000 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-12-21 21:14:25 +0100 |
commit | 33686f67da4bc640014cb51888fbf90f83375e97 (patch) | |
tree | 044e57ae7ad79cde6ec445ad662abd3d94b5ec9e /embeddedobj | |
parent | b45f360fcffe076ccec7be790604665c80f7380e (diff) |
make use of toplevel docmodel's UserAllowsLinkUpdate property
Change-Id: Ia560c123c2f9dd08acb7eeaafccee332dd16300e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161133
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'embeddedobj')
-rw-r--r-- | embeddedobj/source/commonembedding/persistence.cxx | 35 | ||||
-rw-r--r-- | embeddedobj/source/inc/commonembobj.hxx | 2 |
2 files changed, 37 insertions, 0 deletions
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<container::XChild> xParent(m_xParent, uno::UNO_QUERY); + while (xParent) + { + uno::Reference<container::XChild> xGrandParent(xParent->getParent(), uno::UNO_QUERY); + if (!xGrandParent) + break; + xParent = xGrandParent; + } + + uno::Reference<beans::XPropertySet> 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(); |