summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/ndole.hxx3
-rw-r--r--sw/inc/swcli.hxx2
-rw-r--r--sw/source/core/ole/ndole.cxx32
-rw-r--r--sw/source/uibase/app/docsh.cxx16
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx14
-rw-r--r--sw/source/uibase/uiview/swcli.cxx25
6 files changed, 85 insertions, 7 deletions
diff --git a/sw/inc/ndole.hxx b/sw/inc/ndole.hxx
index 8382a42e58dc..e8c7506184f3 100644
--- a/sw/inc/ndole.hxx
+++ b/sw/inc/ndole.hxx
@@ -52,6 +52,8 @@ class SW_DLLPUBLIC SwOLEObj
void SetNode( SwOLENode* pNode );
+ DECL_LINK(IsProtectedHdl, LinkParamNone*, bool);
+
public:
SwOLEObj( const svt::EmbeddedObjectRef& pObj );
SwOLEObj( const OUString &rName, sal_Int64 nAspect );
@@ -69,6 +71,7 @@ public:
const OUString& GetCurrentPersistName() const { return m_aName; }
OUString GetStyleString();
bool IsOleRef() const; ///< To avoid unnecessary loading of object.
+ bool IsProtected() const;
// try to get OLE visualization in form of a Primitive2DSequence
// and the corresponding B2DRange. This data may be locally buffered
diff --git a/sw/inc/swcli.hxx b/sw/inc/swcli.hxx
index 0a6b65a33897..fc77d0885d1e 100644
--- a/sw/inc/swcli.hxx
+++ b/sw/inc/swcli.hxx
@@ -44,6 +44,8 @@ public:
bool IsCheckForOLEInCaption() const { return m_IsOldCheckForOLEInCaption; }
virtual void FormatChanged() override;
+
+ bool IsProtected() const override;
};
#endif
diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx
index 1927872ed0d9..f6ca51279a29 100644
--- a/sw/source/core/ole/ndole.cxx
+++ b/sw/source/core/ole/ndole.cxx
@@ -54,6 +54,7 @@
#include <atomic>
#include <deque>
#include <libxml/xmlwriter.h>
+#include <flyfrm.hxx>
using namespace utl;
using namespace com::sun::star::uno;
@@ -909,6 +910,36 @@ bool SwOLEObj::IsOleRef() const
return m_xOLERef.is();
}
+IMPL_LINK_NOARG(SwOLEObj, IsProtectedHdl, LinkParamNone*, bool) { return IsProtected(); }
+
+bool SwOLEObj::IsProtected() const
+{
+ if (!m_pOLENode)
+ {
+ return false;
+ }
+
+ SwFrame* pFrame = m_pOLENode->getLayoutFrame(nullptr);
+ if (!pFrame)
+ {
+ return false;
+ }
+ SwFrame* pUpper = pFrame->GetUpper();
+ if (!pUpper || !pUpper->IsFlyFrame())
+ {
+ return false;
+ }
+
+ auto pFlyFrame = static_cast<SwFlyFrame*>(pUpper);
+ const SwFrame* pAnchor = pFlyFrame->GetAnchorFrame();
+ if (!pAnchor)
+ {
+ return false;
+ }
+
+ return pAnchor->IsProtected();
+}
+
uno::Reference < embed::XEmbeddedObject > const & SwOLEObj::GetOleRef()
{
if( !m_xOLERef.is() )
@@ -942,6 +973,7 @@ uno::Reference < embed::XEmbeddedObject > const & SwOLEObj::GetOleRef()
}
if (xObj.is())
{
+ m_xOLERef.SetIsProtectedHdl(LINK(this, SwOLEObj, IsProtectedHdl));
m_xOLERef.Assign( xObj, m_xOLERef.GetViewAspect() );
m_xOLERef.AssignToContainer( &p->GetEmbeddedObjectContainer(), m_aName );
m_xListener = new SwOLEListener_Impl( this );
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index aeb522be5fc9..71033ee0af69 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -1134,6 +1134,22 @@ void SwDocShell::GetState(SfxItemSet& rSet)
// OLE-Hdls
IMPL_LINK( SwDocShell, Ole2ModifiedHdl, bool, bNewStatus, void )
{
+ if (m_pWrtShell)
+ {
+ SwOLENode* pOLENode = nullptr;
+ if (!m_pWrtShell->IsTableMode())
+ {
+ pOLENode = m_pWrtShell->GetCursor()->GetNode().GetOLENode();
+ }
+ if (pOLENode)
+ {
+ if (pOLENode->GetOLEObj().IsProtected())
+ {
+ return;
+ }
+ }
+ }
+
if( IsEnableSetModified() )
SetModified( bNewStatus );
}
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 507919f601d7..001ea389f497 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -3245,8 +3245,11 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
case 2:
{
g_bFrameDrag = false;
- if ( !bIsDocReadOnly && rSh.IsInsideSelectedObj(aDocPos) &&
- FlyProtectFlags::NONE == rSh.IsSelObjProtected( FlyProtectFlags::Content|FlyProtectFlags::Parent ) )
+ if (!bIsDocReadOnly && rSh.IsInsideSelectedObj(aDocPos)
+ && (FlyProtectFlags::NONE
+ == rSh.IsSelObjProtected(FlyProtectFlags::Content
+ | FlyProtectFlags::Parent)
+ || rSh.GetSelectionType() == SelectionType::Ole))
{
/* This is no good: on the one hand GetSelectionType is used as flag field
* (take a look into the GetSelectionType method) and on the other hand the
@@ -3266,11 +3269,8 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
// double click on OLE object --> OLE-InPlace
case SelectionType::Ole:
- if (rSh.IsSelObjProtected(FlyProtectFlags::Content) == FlyProtectFlags::NONE)
- {
- RstMBDownFlags();
- rSh.LaunchOLEObj();
- }
+ RstMBDownFlags();
+ rSh.LaunchOLEObj();
return;
case SelectionType::Frame:
diff --git a/sw/source/uibase/uiview/swcli.cxx b/sw/source/uibase/uiview/swcli.cxx
index 05f5f6ccc95a..4dc86bee5faf 100644
--- a/sw/source/uibase/uiview/swcli.cxx
+++ b/sw/source/uibase/uiview/swcli.cxx
@@ -29,6 +29,8 @@
#include <toolkit/helper/vclunohelper.hxx>
+#include <ndole.hxx>
+
using namespace com::sun::star;
SwOleClient::SwOleClient(SwView *pView, SwEditWin *pWin, const svt::EmbeddedObjectRef& xObj)
@@ -164,4 +166,27 @@ void SwOleClient::FormatChanged()
}
}
+bool SwOleClient::IsProtected() const
+{
+ auto pView = dynamic_cast<SwView*>(GetViewShell());
+ if (!pView)
+ {
+ return false;
+ }
+
+ SwWrtShell& rWrtSh = pView->GetWrtShell();
+ if (rWrtSh.IsTableMode())
+ {
+ return false;
+ }
+
+ SwOLENode* pOLENode = rWrtSh.GetCursor()->GetNode().GetOLENode();
+ if (!pOLENode)
+ {
+ return false;
+ }
+
+ return pOLENode->GetOLEObj().IsProtected();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */