summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorArmin Le Grand (Allotropia) <Armin.Le.Grand@me.com>2022-05-23 15:48:41 +0200
committerArmin Le Grand <Armin.Le.Grand@me.com>2022-05-25 09:59:17 +0200
commit8b4b852a35149b1cfffc681cbb4f57d4c0b671b3 (patch)
tree66dc1121c200bc0baa7caa135cee60cb02a67f80 /svx
parent2682828f73a6c759735613ec924357424baeae24 (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')
-rw-r--r--svx/Library_svxcore.mk1
-rw-r--r--svx/source/diagram/IDiagramHelper.cxx152
-rw-r--r--svx/source/svdraw/svdedtv.cxx5
-rw-r--r--svx/source/svdraw/svdedtv2.cxx3
-rw-r--r--svx/source/svdraw/svdmrkv.cxx7
-rw-r--r--svx/source/svdraw/svdmrkv1.cxx3
-rw-r--r--svx/source/svdraw/svdobj.cxx5
-rw-r--r--svx/source/svdraw/svdogrp.cxx24
-rw-r--r--svx/source/svdraw/svdpagv.cxx3
-rw-r--r--svx/source/svdraw/svdundo.cxx17
10 files changed, 190 insertions, 30 deletions
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index 4102c1ddc96e..5cacdf82ebcc 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -111,6 +111,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
svx/source/customshapes/EnhancedCustomShapeGeometry \
svx/source/customshapes/EnhancedCustomShapeTypeNames \
svx/source/diagram/datamodel \
+ svx/source/diagram/IDiagramHelper \
svx/source/dialog/dialmgr \
svx/source/dialog/dlgutil \
svx/source/dialog/hexcolorcontrol \
diff --git a/svx/source/diagram/IDiagramHelper.cxx b/svx/source/diagram/IDiagramHelper.cxx
new file mode 100644
index 000000000000..3c5f7462204d
--- /dev/null
+++ b/svx/source/diagram/IDiagramHelper.cxx
@@ -0,0 +1,152 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svx/diagram/IDiagramHelper.hxx>
+#include <svx/svdogrp.hxx>
+
+#include <svx/svdhdl.hxx>
+#include <svx/svdmrkv.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/sdrpagewindow.hxx>
+#include <svx/sdrpaintwindow.hxx>
+#include <svx/sdr/overlay/overlaypolypolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+
+namespace {
+
+class DiagramFrameHdl final : public SdrHdl
+{
+ basegfx::B2DHomMatrix maTransformation;
+
+ // create marker for this kind
+ virtual void CreateB2dIAObject() override;
+
+public:
+ DiagramFrameHdl(const basegfx::B2DHomMatrix& rTransformation);
+ // virtual ~DiagramFrameHdl() override;
+};
+
+void DiagramFrameHdl::CreateB2dIAObject()
+{
+ // first throw away old one
+ GetRidOfIAObject();
+
+ SdrMarkView* pView = pHdlList->GetView();
+
+ if(!pView || pView->areMarkHandlesHidden())
+ return;
+
+ SdrPageView* pPageView = pView->GetSdrPageView();
+
+ if(!pPageView)
+ return;
+
+ for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++)
+ {
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
+
+ if(rPageWindow.GetPaintWindow().OutputToWindow())
+ {
+ const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager();
+ if (xManager.is())
+ {
+ OutputDevice& rOutDev(rPageWindow.GetPaintWindow().GetOutputDevice());
+ const basegfx::B2DVector aDiscreteInLogic(rOutDev.GetInverseViewTransformation() * basegfx::B2DVector(1.0, 0.0));
+ const double fDiscretePixelSize(aDiscreteInLogic.getLength());
+ const double fOuterDistance(7.0);
+ const double fInnerDistance(5.0);
+
+ basegfx::B2DRange aRange(0.0, 0.0, 1.0, 1.0);
+ aRange.transform(maTransformation);
+
+ basegfx::B2DRange aOuterRange(aRange);
+ aOuterRange.grow(fDiscretePixelSize * fOuterDistance);
+
+ basegfx::B2DRange aInnerRange(aRange);
+ aInnerRange.grow(fDiscretePixelSize * fInnerDistance);
+
+ basegfx::B2DPolyPolygon aPolyPolygon;
+ aPolyPolygon.append(basegfx::utils::createPolygonFromRect(aOuterRange));
+ aPolyPolygon.append(basegfx::utils::createPolygonFromRect(aInnerRange));
+
+ const StyleSettings& rStyles(rOutDev.GetSettings().GetStyleSettings());
+ Color aFillColor(rStyles.GetHighlightColor());
+ Color aLineColor(aFillColor);
+ aFillColor.IncreaseLuminance(10);
+ aLineColor.DecreaseLuminance(30);
+
+ std::unique_ptr<sdr::overlay::OverlayObject> pNewOverlayObject(
+ new sdr::overlay::OverlayPolyPolygon(
+ aPolyPolygon,
+ aLineColor, // Line
+ fDiscretePixelSize * 2.0,
+ aFillColor)); // Fill
+
+ // OVERLAYMANAGER
+ insertNewlyCreatedOverlayObjectForSdrHdl(
+ std::move(pNewOverlayObject),
+ rPageWindow.GetObjectContact(),
+ *xManager);
+ }
+ }
+ }
+}
+
+DiagramFrameHdl::DiagramFrameHdl(const basegfx::B2DHomMatrix& rTransformation)
+: SdrHdl(Point(), SdrHdlKind::Move)
+, maTransformation(rTransformation)
+{
+}
+
+// DiagramFrameHdl::~DiagramFrameHdl()
+// {
+// }
+
+} // end of anonymous namespace
+
+namespace svx { namespace diagram {
+
+IDiagramHelper::IDiagramHelper()
+: mbUseDiagramThemeData(false)
+, mbUseDiagramModelData(true)
+, mbForceThemePtrRecreation(false)
+{
+}
+
+IDiagramHelper::~IDiagramHelper() {}
+
+void IDiagramHelper::anchorToSdrObjGroup(SdrObjGroup& rTarget)
+{
+ rTarget.mp_DiagramHelper.reset(this);
+}
+
+void IDiagramHelper::AddAdditionalVisualization(const SdrObjGroup& rTarget, SdrHdlList& rHdlList)
+{
+ // create an extra frame visuaization here
+ basegfx::B2DHomMatrix aTransformation;
+ basegfx::B2DPolyPolygon aPolyPolygon;
+ rTarget.TRGetBaseGeometry(aTransformation, aPolyPolygon);
+
+ std::unique_ptr<SdrHdl> pHdl(new DiagramFrameHdl(aTransformation));
+ rHdlList.AddHdl(std::move(pHdl));
+}
+
+}} // end of namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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()