summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-11-25 14:53:04 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-11-26 13:41:12 +0100
commit18a2d02f7969878fa90e0dcffd15ea5261b2369f (patch)
tree99bb768cb57a45477f31d04c9d016d9d591bc3be /svtools
parent1cc5c6587e72581c83f7289a95e906a3a1be38b6 (diff)
sw: allow viewing OLE objects in protected sections
The problem was that we don't allow even opening embedded objects in protected sections, which means the content of multi-page embedded objects can't even be viewed in protected sections, which probably goes too far. Fix this relaxing the condition in SwEditWin::MouseButtonDown() to allow launching the OLE object on double-click, and then make sure that the native data is not updated in SfxInPlaceClient_Impl::saveObject() and the replacement image is not updated in svt::EmbedEventListener_Impl::stateChanged(). This is complicated by only the Writer layout knowing if a given OLE object is anchored in a protected frame, so pass down a callback to sfx2/ and svtools/ to check if the OLE object is protected. Not copying the protected bit has the benefit of behaving correctly if the section turns into non-protected: copying would not work properly, as SfxInPlaceClient is created on demand, so not re-created when the protectedness of the section is changed. (cherry picked from commit 4f9f1ac33366817df61c488a9f36b09c592ee939) Conflicts: sw/source/core/ole/ndole.cxx Change-Id: Ib3a8f2092d27dc1ebd3ef355c95a4a473988b163
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/misc/embedhlp.cxx21
1 files changed, 20 insertions, 1 deletions
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx
index f8dcf1356621..d71754238cea 100644
--- a/svtools/source/misc/embedhlp.cxx
+++ b/svtools/source/misc/embedhlp.cxx
@@ -135,9 +135,16 @@ void SAL_CALL EmbedEventListener_Impl::stateChanged( const lang::EventObject&,
uno::Reference < util::XModifiable > xMod( pObject->GetObject()->getComponent(), uno::UNO_QUERY );
if ( nNewState == embed::EmbedStates::RUNNING )
{
+ bool bProtected = false;
+ if (pObject->GetIsProtectedHdl().IsSet())
+ {
+ bProtected = pObject->GetIsProtectedHdl().Call(nullptr);
+ }
+
// TODO/LATER: container must be set before!
// When is this event created? Who sets the new container when it changed?
- if( ( pObject->GetViewAspect() != embed::Aspects::MSOLE_ICON ) && nOldState != embed::EmbedStates::LOADED && !pObject->IsChart() )
+ if ((pObject->GetViewAspect() != embed::Aspects::MSOLE_ICON)
+ && nOldState != embed::EmbedStates::LOADED && !pObject->IsChart() && !bProtected)
// get new replacement after deactivation
pObject->UpdateReplacement();
@@ -239,6 +246,8 @@ struct EmbeddedObjectRef_Impl
sal_uInt32 mnGraphicVersion;
awt::Size aDefaultSizeForChart_In_100TH_MM;//#i103460# charts do not necessarily have an own size within ODF files, in this case they need to use the size settings from the surrounding frame, which is made available with this member
+ Link<LinkParamNone*, bool> m_aIsProtectedHdl;
+
EmbeddedObjectRef_Impl() :
pContainer(nullptr),
nViewAspect(embed::Aspects::MSOLE_CONTENT),
@@ -394,6 +403,16 @@ bool EmbeddedObjectRef::IsLocked() const
return mpImpl->bIsLocked;
}
+void EmbeddedObjectRef::SetIsProtectedHdl(const Link<LinkParamNone*, bool>& rProtectedHdl)
+{
+ mpImpl->m_aIsProtectedHdl = rProtectedHdl;
+}
+
+Link<LinkParamNone*, bool> EmbeddedObjectRef::GetIsProtectedHdl() const
+{
+ return mpImpl->m_aIsProtectedHdl;
+}
+
void EmbeddedObjectRef::GetReplacement( bool bUpdate )
{
Graphic aOldGraphic;