From 4a46a74a3de0ac7df5d3ce949dda5e809c1729ab Mon Sep 17 00:00:00 2001 From: "Armin Le Grand (Allotropia)" Date: Tue, 22 Mar 2022 11:59:09 +0100 Subject: [PATCH] Advanced Diagram support: Enhanced Ungroup for Diagram A Diagram has a 'filler' BG object as 1st object in the Group to guarantee the Diagram's dimensions. It has no FillStyle or LineStyle and is Move/Size-Protected. When Un-Grouping the Diagram and thus removing it's Diagram-Functionality that filler-BG Object is not useful and needs to be removed. Do that in an UNDO- supporting way to allow seamless UNDO/REDO actions. Change-Id: I1c5052de59dafb6ba1b35a68123bdabd10bf7885 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131930 Tested-by: Jenkins Reviewed-by: Armin Le Grand --- svx/source/svdraw/svdedtv2.cxx | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx index 0700847fe920..a046a6b3a59e 100644 --- a/svx/source/svdraw/svdedtv2.cxx +++ b/svx/source/svdraw/svdedtv2.cxx @@ -1910,12 +1910,36 @@ void SdrEditView::UnGroupMarked() } size_t nDstCnt=pGrp->GetOrdNum(); SdrObjList* pDstLst=pM->GetPageView()->GetObjList(); + size_t nObjCount=pSrcLst->GetObjCount(); + auto* pGroup(dynamic_cast(pGrp)); + const bool bIsDiagram(nullptr != pGroup && pGroup->isDiagram()); + + // If the Group is a Diagram, it has a filler BG object to guarantee + // the Diagam's dimensions. Identify that shape & delete it, it is not + // useful for any further processing + if(bIsDiagram && nObjCount) + { + SdrObject* pObj(pSrcLst->GetObj(0)); + + if(nullptr != pObj && !pObj->IsGroupObject() && + !pObj->HasFillStyle() && !pObj->HasLineStyle() && + pObj->IsMoveProtect() && pObj->IsResizeProtect()) + { + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); + + pObj = pSrcLst->RemoveObject(0); + + if( !bUndo ) + SdrObject::Free(pObj); + + nObjCount = pSrcLst->GetObjCount(); + } + } // FIRST move contained objects to parent of group, so that // the contained objects are NOT migrated to the UNDO-ItemPool // when AddUndo(new SdrUndoDelObj(*pGrp)) is called. - const size_t nObjCount=pSrcLst->GetObjCount(); - if( bUndo ) { for (size_t no=nObjCount; no>0;) @@ -1925,6 +1949,7 @@ void SdrEditView::UnGroupMarked() AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoRemoveObject(*pObj)); } } + for (size_t no=0; noRemoveObject(0);