diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2022-04-08 13:12:50 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2022-04-08 12:29:01 +0200 |
commit | 34a97838137f6e54405722d607b7f414084f526e (patch) | |
tree | 3b106622c89427dcb6f650691d5d607560bd618e | |
parent | a21ef822f9769ded6ff834dbfa347cf0e5f913fd (diff) |
sc: add an overlay to show sparklines in a sparkline group
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
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132692
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | sc/source/ui/inc/gridwin.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 67 |
2 files changed, 70 insertions, 0 deletions
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index b4117736484e..93d7abd095a3 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 6ce6a6d6c421..516c9ef16d50 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> @@ -6034,6 +6035,7 @@ void ScGridWindow::CursorChanged() // now, just re-create them UpdateCursorOverlay(); + UpdateSparklineGroupOverlay(); } void ScGridWindow::ImpCreateOverlayObjects() @@ -6045,6 +6047,7 @@ void ScGridWindow::ImpCreateOverlayObjects() UpdateDragRectOverlay(); UpdateHeaderOverlay(); UpdateShrinkOverlay(); + UpdateSparklineGroupOverlay(); } void ScGridWindow::ImpDestroyOverlayObjects() @@ -6056,6 +6059,7 @@ void ScGridWindow::ImpDestroyOverlayObjects() DeleteDragRectOverlay(); DeleteHeaderOverlay(); DeleteShrinkOverlay(); + DeleteSparklineGroupOverlay(); } void ScGridWindow::UpdateAllOverlays() @@ -6973,6 +6977,69 @@ 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)) + { + mpOOSparklineGroup.reset(new sdr::overlay::OverlayObjectList); + + rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager(); + if (xOverlayManager.is()) + { + auto* pList = rDocument.GetSparklineList(aCurrentAddress.Tab()); + if (pList) + { + auto const& pSparklines = pList->getSparklinesFor(pSparkline->getSparklineGroup()); + + Color aColor = SvtOptionsDrawinglayer::getHilightColor(); + + std::vector<basegfx::B2DRange> aRanges; + const basegfx::B2DHomMatrix aTransform(GetOutDev()->GetInverseViewTransformation()); + + 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); + + basegfx::B2DRange aRange(aStart.X(), aStart.Y(), aEnd.X(), aEnd.Y()); + + aRange.transform(aTransform); + aRanges.push_back(aRange); + } + + 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 { |