diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2022-04-08 13:12:50 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2022-04-08 13:12:50 +0900 |
commit | 1906d7e72cc23f5b5bb7739a3c64395a914bf483 (patch) | |
tree | 649e68c8ed2d4a82ec2406d84e319bd730494b70 | |
parent | 4633b77fd0a16a493ffb619a83eb0c2d0a87a876 (diff) |
sc: add an overlay to show sparklines in a sparkline groupfeature/sparklines
This adds an overlay that shows/selects all sparklines in a
sparkline group for the cursor cell sparkline, if the cursor cell
has an associated sparkline.
Change-Id: I60a5873ebdf8606f262d217caf6011c4a003801a
-rw-r--r-- | sc/source/ui/inc/gridwin.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 71 |
2 files changed, 74 insertions, 0 deletions
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index 988bf55d2a17..5871fd036fcf 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -106,6 +106,7 @@ class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::Window, public DropTargetHel std::unique_ptr<sdr::overlay::OverlayObjectList> mpOODragRect; std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOHeader; std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOShrink; + std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOSparklineGroup; std::optional<tools::Rectangle> mpAutoFillRect; @@ -462,6 +463,8 @@ public: const std::vector<editeng::MisspellRanges>* GetAutoSpellData( SCCOL nPosX, SCROW nPosY ); bool InsideVisibleRange( SCCOL nPosX, SCROW nPosY ); + void UpdateSparklineGroupOverlay(); + void DeleteSparklineGroupOverlay(); void DeleteCopySourceOverlay(); void UpdateCopySourceOverlay(); void DeleteCursorOverlay(); diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index e676dcfadd42..608e55afbde5 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -128,6 +128,7 @@ #include <datamapper.hxx> #include <inputopt.hxx> #include <queryparam.hxx> +#include <SparklineList.hxx> #include <officecfg/Office/Common.hxx> @@ -6027,6 +6028,7 @@ void ScGridWindow::CursorChanged() // now, just re-create them UpdateCursorOverlay(); + UpdateSparklineGroupOverlay(); } void ScGridWindow::ImpCreateOverlayObjects() @@ -6038,6 +6040,7 @@ void ScGridWindow::ImpCreateOverlayObjects() UpdateDragRectOverlay(); UpdateHeaderOverlay(); UpdateShrinkOverlay(); + UpdateSparklineGroupOverlay(); } void ScGridWindow::ImpDestroyOverlayObjects() @@ -6049,6 +6052,7 @@ void ScGridWindow::ImpDestroyOverlayObjects() DeleteDragRectOverlay(); DeleteHeaderOverlay(); DeleteShrinkOverlay(); + DeleteSparklineGroupOverlay(); } void ScGridWindow::UpdateAllOverlays() @@ -6966,6 +6970,73 @@ void ScGridWindow::UpdateShrinkOverlay() SetMapMode( aOldMode ); } +void ScGridWindow::DeleteSparklineGroupOverlay() +{ + mpOOSparklineGroup.reset(); +} + +void ScGridWindow::UpdateSparklineGroupOverlay() +{ + MapMode aDrawMode = GetDrawMapMode(); + + MapMode aOldMode = GetMapMode(); + if (aOldMode != aDrawMode) + SetMapMode(aDrawMode); + + DeleteSparklineGroupOverlay(); + + ScAddress aCurrentAddress = mrViewData.GetCurPos(); + + ScDocument& rDocument = mrViewData.GetDocument(); + if (auto pSparkline = rDocument.GetSparkline(aCurrentAddress)) + { + auto* pList = rDocument.GetSparklineList(aCurrentAddress.Tab()); + if (pList) + { + auto const& pSparklines = pList->getSparklinesFor(pSparkline->getSparklineGroup()); + + Color aColor = SvtOptionsDrawinglayer::getHilightColor(); + + mpOOSparklineGroup.reset(new sdr::overlay::OverlayObjectList); + rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager(); + if (xOverlayManager.is()) + { + std::vector<basegfx::B2DRange> aRanges; + + for (auto const& pCurrentSparkline : pSparklines) + { + SCCOL nColumn = pCurrentSparkline->getColumn(); + SCROW nRow = pCurrentSparkline->getRow(); + + Point aStart = mrViewData.GetScrPos(nColumn, nRow, eWhich); + Point aEnd = mrViewData.GetScrPos(nColumn + 1, nRow + 1, eWhich); + aEnd.AdjustX(-1); + aEnd.AdjustY(-1); + + tools::Rectangle aPixRect = tools::Rectangle(aStart, aEnd); + + const basegfx::B2DHomMatrix aTransform(GetOutDev()->GetInverseViewTransformation()); + basegfx::B2DRange aRB(aPixRect.Left(), aPixRect.Top(), aPixRect.Right() + 1, aPixRect.Bottom() + 1); + + aRB.transform(aTransform); + aRanges.push_back(aRB); + } + + std::unique_ptr<sdr::overlay::OverlayObject> pOverlay(new sdr::overlay::OverlaySelection( + sdr::overlay::OverlayType::Transparent, + aColor, std::move(aRanges), true)); + + + xOverlayManager->add(*pOverlay); + mpOOSparklineGroup->append(std::move(pOverlay)); + } + } + } + + if (aOldMode != aDrawMode) + SetMapMode(aOldMode); +} + // #i70788# central method to get the OverlayManager safely rtl::Reference<sdr::overlay::OverlayManager> ScGridWindow::getOverlayManager() const { |