diff options
author | Armin Le Grand (Allotropia) <Armin.Le.Grand@me.com> | 2022-05-23 15:48:41 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2022-05-25 09:59:17 +0200 |
commit | 8b4b852a35149b1cfffc681cbb4f57d4c0b671b3 (patch) | |
tree | 66dc1121c200bc0baa7caa135cee60cb02a67f80 /svx/source/svdraw | |
parent | 2682828f73a6c759735613ec924357424baeae24 (diff) |
Advanced Diagram support: Isolated IDiagramHelper, selection visualization
Moved and isolated IDiagramHelper to own file to get SdrObjGroup smaller
and less dependent again, all places adapted. isDiagram() now available
at SdrObject directly, adapted and have less places which need to cast
for SdrObjGroup for check.
Started to add SdrHdl/selection visualization to seleced Diagram. Only
as a start, will need to be extended to look good/better, plus evtl.
functionality in handles/UI.
Corrected error(s) found by failing UnitTests
More clang-notes (static, namespace) I nneeded to follow
Change-Id: If4675b3270d3ee30259fce49deb017dbbaf5c0c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134825
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'svx/source/svdraw')
-rw-r--r-- | svx/source/svdraw/svdedtv.cxx | 5 | ||||
-rw-r--r-- | svx/source/svdraw/svdedtv2.cxx | 3 | ||||
-rw-r--r-- | svx/source/svdraw/svdmrkv.cxx | 7 | ||||
-rw-r--r-- | svx/source/svdraw/svdmrkv1.cxx | 3 | ||||
-rw-r--r-- | svx/source/svdraw/svdobj.cxx | 5 | ||||
-rw-r--r-- | svx/source/svdraw/svdogrp.cxx | 24 | ||||
-rw-r--r-- | svx/source/svdraw/svdpagv.cxx | 3 | ||||
-rw-r--r-- | svx/source/svdraw/svdundo.cxx | 17 |
8 files changed, 37 insertions, 30 deletions
diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx index df42a3d78dea..b019f26ae47a 100644 --- a/svx/source/svdraw/svdedtv.cxx +++ b/svx/source/svdraw/svdedtv.cxx @@ -680,8 +680,9 @@ void SdrEditView::CheckPossibilities() // Don't allow enter Diagrams if (1 == nMarkCount && m_bGrpEnterPossible) { - auto* pGroup(dynamic_cast<SdrObjGroup*>(GetMarkedObjectByIndex(0))); - if(nullptr != pGroup && pGroup->isDiagram()) + SdrObject* pCandidate(GetMarkedObjectByIndex(0)); + + if(nullptr != pCandidate && pCandidate->isDiagram()) m_bGrpEnterPossible = false; } } diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx index d1e216c554d7..47e20d82be6a 100644 --- a/svx/source/svdraw/svdedtv2.cxx +++ b/svx/source/svdraw/svdedtv2.cxx @@ -1911,8 +1911,7 @@ void SdrEditView::UnGroupMarked() size_t nDstCnt=pGrp->GetOrdNum(); SdrObjList* pDstLst=pM->GetPageView()->GetObjList(); size_t nObjCount=pSrcLst->GetObjCount(); - auto* pGroup(dynamic_cast<SdrObjGroup*>(pGrp)); - const bool bIsDiagram(nullptr != pGroup && pGroup->isDiagram()); + const bool bIsDiagram(nullptr != pGrp && pGrp->isDiagram()); // If the Group is a Diagram, it has a filler BG object to guarantee // the Diagam's dimensions. Identify that shape diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index 506125be7d43..01b065f970f1 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -1332,6 +1332,13 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell) } } + // Diagram selection visualization support + // Caution: CppunitTest_sd_tiledrendering shows that mpMarkedObj *can* actually be nullptr (!) + if(nullptr != mpMarkedObj && mpMarkedObj->isDiagram()) + { + mpMarkedObj->AddToHdlList(maHdlList); + } + const size_t nSiz1(maHdlList.GetHdlCount()); // moved setting the missing parameters at SdrHdl here from the diff --git a/svx/source/svdraw/svdmrkv1.cxx b/svx/source/svdraw/svdmrkv1.cxx index 693965b10f81..9c732262bcc9 100644 --- a/svx/source/svdraw/svdmrkv1.cxx +++ b/svx/source/svdraw/svdmrkv1.cxx @@ -308,9 +308,10 @@ void SdrMarkView::UndirtyMrkPnt() const } else { - OSL_FAIL("SdrMarkView::UndirtyMrkPnt(): Selected points on an object that is not a PolyObj!"); if (!rPts.empty()) { + // only fail *if* there are marked points + OSL_FAIL("SdrMarkView::UndirtyMrkPnt(): Selected points on an object that is not a PolyObj!"); rPts.clear(); bChg = true; } diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 000c79937739..e8d41c51b39d 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -199,6 +199,11 @@ struct SdrObject::Impl meRelativeHeightRelation(text::RelOrientation::PAGE_FRAME) {} }; +const std::shared_ptr< svx::diagram::IDiagramHelper >& SdrObject::getDiagramHelper() const +{ + static std::shared_ptr< svx::diagram::IDiagramHelper > aEmpty; + return aEmpty; +} // BaseProperties section diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx index f7fb1eb14f79..7fc8e0b12f80 100644 --- a/svx/source/svdraw/svdogrp.cxx +++ b/svx/source/svdraw/svdogrp.cxx @@ -30,22 +30,13 @@ #include <sdr/contact/viewcontactofgroup.hxx> #include <basegfx/range/b2drange.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> -#include <basegfx/polygon/b2dpolygon.hxx> #include <libxml/xmlwriter.h> #include <vcl/canvastools.hxx> +#include <svx/diagram/IDiagramHelper.hxx> -IDiagramHelper::IDiagramHelper() -: mbUseDiagramThemeData(false) -, mbUseDiagramModelData(true) -, mbForceThemePtrRecreation(false) +const std::shared_ptr< svx::diagram::IDiagramHelper >& SdrObjGroup::getDiagramHelper() const { -} - -IDiagramHelper::~IDiagramHelper() {} - -void IDiagramHelper::anchorToSdrObjGroup(SdrObjGroup& rTarget) -{ - rTarget.mp_DiagramHelper.reset(this); + return mp_DiagramHelper; } // BaseProperties section @@ -95,6 +86,15 @@ SdrObjGroup::SdrObjGroup(SdrModel& rSdrModel, SdrObjGroup const & rSource) maRefPoint = rSource.maRefPoint; } +void SdrObjGroup::AddToHdlList(SdrHdlList& rHdlList) const +{ + // only for diagram, so do nothing for just groups + if(!isDiagram()) + return; + + svx::diagram::IDiagramHelper::AddAdditionalVisualization(*this, rHdlList); +} + SdrObjGroup::~SdrObjGroup() { } diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx index 022975f3e5b1..0e35d09b080e 100644 --- a/svx/source/svdraw/svdpagv.cxx +++ b/svx/source/svdraw/svdpagv.cxx @@ -730,8 +730,7 @@ bool SdrPageView::EnterGroup(SdrObject* pObj) return false; // Don't allow enter Diagrams - auto* pGroup(dynamic_cast<SdrObjGroup*>(pObj)); - if(nullptr != pGroup && pGroup->isDiagram()) + if(nullptr != pObj && pObj->isDiagram()) return false; const bool bGlueInvalidate(GetView().ImpIsGlueVisible()); diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx index b61ad93fde90..bd2ff6d8c1f9 100644 --- a/svx/source/svdraw/svdundo.cxx +++ b/svx/source/svdraw/svdundo.cxx @@ -46,6 +46,7 @@ #include <sal/log.hxx> #include <osl/diagnose.h> #include <svx/diagram/datamodel.hxx> +#include <svx/diagram/IDiagramHelper.hxx> // iterates over all views and unmarks this SdrObject if it is marked @@ -634,12 +635,8 @@ SdrUndoDiagramModelData::SdrUndoDiagramModelData(SdrObject& rNewObj, svx::diagra , m_aStartState(rStartState) , m_aEndState() { - SdrObjGroup* pDiagram(dynamic_cast<SdrObjGroup*>(&rNewObj)); - - if(pDiagram && pDiagram->isDiagram()) - { - m_aEndState = pDiagram->getDiagramHelper()->extractDiagramDataState(); - } + if(rNewObj.isDiagram()) + m_aEndState = rNewObj.getDiagramHelper()->extractDiagramDataState(); } SdrUndoDiagramModelData::~SdrUndoDiagramModelData() @@ -651,14 +648,12 @@ void SdrUndoDiagramModelData::implUndoRedo(bool bUndo) if(nullptr == pObj) return; - SdrObjGroup* pDiagram(dynamic_cast<SdrObjGroup*>(pObj)); - - if(nullptr == pDiagram || !pDiagram->isDiagram()) + if(!pObj->isDiagram()) return; - pDiagram->getDiagramHelper()->applyDiagramDataState( + pObj->getDiagramHelper()->applyDiagramDataState( bUndo ? m_aStartState : m_aEndState); - pDiagram->getDiagramHelper()->reLayout(*pDiagram); + pObj->getDiagramHelper()->reLayout(*static_cast<SdrObjGroup*>(pObj)); } void SdrUndoDiagramModelData::Undo() |