From e8a004d54dc939b257b2851a78c324269e2a3973 Mon Sep 17 00:00:00 2001 From: "Armin Le Grand (Allotropia)" Date: Fri, 25 Feb 2022 18:46:23 +0100 Subject: Advanced Diagram support: Disable enter Diagram (Groups) Groups which are in Diagram mode should not be entered, to do so disable at UI and - for security reasons - also at the executing mehod. Groups in Diagram mode can still be UnGrouped (which will remove the Diagram status & data) Adapted testRegenerateDiagram() to directly act on the model data to test the same as before. Using triggering of UI events to enter the diagram group object needs reorganization, but model op's will always be possible Change-Id: I199f3821c2a8308a6f015997ce9eaef87623c46a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130541 Tested-by: Jenkins Reviewed-by: Armin Le Grand --- svx/source/svdraw/svdedtv.cxx | 8 ++++++ svx/source/svdraw/svdpagv.cxx | 65 ++++++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 32 deletions(-) (limited to 'svx/source/svdraw') diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx index 47f5c971e543..c59b1e6be864 100644 --- a/svx/source/svdraw/svdedtv.cxx +++ b/svx/source/svdraw/svdedtv.cxx @@ -676,6 +676,14 @@ void SdrEditView::CheckPossibilities() if (pNode1!=nullptr || pNode2!=nullptr) m_bMoveAllowed=false; } } + + // Don't allow enter Diagrams + if (1 == nMarkCount && m_bGrpEnterPossible) + { + auto* pGroup(dynamic_cast(GetMarkedObjectByIndex(0))); + if(nullptr != pGroup && pGroup->isDiagram()) + m_bGrpEnterPossible = false; + } } diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx index 791a1fc30e70..022975f3e5b1 100644 --- a/svx/source/svdraw/svdpagv.cxx +++ b/svx/source/svdraw/svdpagv.cxx @@ -726,51 +726,52 @@ void SdrPageView::SetCurrentGroupAndList(SdrObject* pNewGroup, SdrObjList* pNewL bool SdrPageView::EnterGroup(SdrObject* pObj) { - bool bRet(false); + if(!pObj || !pObj->IsGroupObject()) + return false; + + // Don't allow enter Diagrams + auto* pGroup(dynamic_cast(pObj)); + if(nullptr != pGroup && pGroup->isDiagram()) + return false; - if(pObj && pObj->IsGroupObject()) + const bool bGlueInvalidate(GetView().ImpIsGlueVisible()); + + if (bGlueInvalidate) { - bool bGlueInvalidate(GetView().ImpIsGlueVisible()); + GetView().GlueInvalidate(); + } - if(bGlueInvalidate) - { - GetView().GlueInvalidate(); - } + // deselect all + GetView().UnmarkAll(); - // deselect all - GetView().UnmarkAll(); + // set current group and list + SdrObjList* pNewObjList = pObj->GetSubList(); + SetCurrentGroupAndList(pObj, pNewObjList); - // set current group and list - SdrObjList* pNewObjList = pObj->GetSubList(); - SetCurrentGroupAndList(pObj, pNewObjList); + // select contained object if only one object is contained, + // else select nothing and let the user decide what to do next + if(pNewObjList && pNewObjList->GetObjCount() == 1) + { + SdrObject* pFirstObject = pNewObjList->GetObj(0); - // select contained object if only one object is contained, - // else select nothing and let the user decide what to do next - if(pNewObjList && pNewObjList->GetObjCount() == 1) + if(GetView().GetSdrPageView()) { - SdrObject* pFirstObject = pNewObjList->GetObj(0); - - if(GetView().GetSdrPageView()) - { - GetView().MarkObj(pFirstObject, GetView().GetSdrPageView()); - } + GetView().MarkObj(pFirstObject, GetView().GetSdrPageView()); } + } - // build new handles - GetView().AdjustMarkHdl(); - - // invalidate only when view wants to visualize group entering - InvalidateAllWin(); + // build new handles + GetView().AdjustMarkHdl(); - if (bGlueInvalidate) - { - GetView().GlueInvalidate(); - } + // invalidate only when view wants to visualize group entering + InvalidateAllWin(); - bRet = true; + if (bGlueInvalidate) + { + GetView().GlueInvalidate(); } - return bRet; + return true; } void SdrPageView::LeaveOneGroup() -- cgit