summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-01-19 11:43:36 +0000
committerAndras Timar <andras.timar@collabora.com>2024-01-23 15:42:26 +0100
commit4031c9206fc738d3dd2367f1ca8f24a14b18ebd0 (patch)
tree4e436e9efa2d480dc6305b3338c196ead0872fc9 /sc
parenta6e6cb064fd450c5ee0a9f6809e986b189875ac8 (diff)
use a ScopeGuard to restore the original map mode
in all these cases the original map mode was always restored so there is no change for these examples. Change-Id: Iec24b2cd269b9408dac6404e054b3bb989ec7744 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162306 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> (cherry picked from commit 30ed30b1117a41f016aa5b09ce21d2cb3004fdc3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162275 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/view/gridwin.cxx82
1 files changed, 48 insertions, 34 deletions
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index c307b2a0ce59..30be376c86e5 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -6625,10 +6625,16 @@ void ScGridWindow::DeleteSelectionOverlay()
void ScGridWindow::UpdateSelectionOverlay()
{
- MapMode aDrawMode = GetDrawMapMode();
- MapMode aOldMode = GetMapMode();
- if ( aOldMode != aDrawMode )
- SetMapMode( aDrawMode );
+ const MapMode aDrawMode = GetDrawMapMode();
+ const MapMode aOldMode = GetMapMode();
+ comphelper::ScopeGuard aMapModeGuard(
+ [&aOldMode, &aDrawMode, this] {
+ if (aOldMode != aDrawMode)
+ SetMapMode(aOldMode);
+ }
+ );
+ if (aOldMode != aDrawMode)
+ SetMapMode(aDrawMode);
DeleteSelectionOverlay();
std::vector<tools::Rectangle> aRects;
@@ -6700,9 +6706,6 @@ void ScGridWindow::UpdateSelectionOverlay()
ScInputHandler::SendReferenceMarks(pViewShell, aReferenceMarks);
}
}
-
- if ( aOldMode != aDrawMode )
- SetMapMode( aOldMode );
}
void ScGridWindow::UpdateHighlightOverlay()
@@ -6865,10 +6868,16 @@ void ScGridWindow::UpdateDragRectOverlay()
bool bInPrintTwips = comphelper::LibreOfficeKit::isCompatFlagSet(
comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
- MapMode aDrawMode = GetDrawMapMode();
- MapMode aOldMode = GetMapMode();
- if ( aOldMode != aDrawMode )
- SetMapMode( aDrawMode );
+ const MapMode aDrawMode = GetDrawMapMode();
+ const MapMode aOldMode = GetMapMode();
+ comphelper::ScopeGuard aMapModeGuard(
+ [&aOldMode, &aDrawMode, this] {
+ if (aOldMode != aDrawMode)
+ SetMapMode(aOldMode);
+ }
+ );
+ if (aOldMode != aDrawMode)
+ SetMapMode(aDrawMode);
DeleteDragRectOverlay();
@@ -7021,9 +7030,6 @@ void ScGridWindow::UpdateDragRectOverlay()
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, aRectsString);
}
}
-
- if ( aOldMode != aDrawMode )
- SetMapMode( aOldMode );
}
void ScGridWindow::DeleteHeaderOverlay()
@@ -7033,10 +7039,16 @@ void ScGridWindow::DeleteHeaderOverlay()
void ScGridWindow::UpdateHeaderOverlay()
{
- MapMode aDrawMode = GetDrawMapMode();
- MapMode aOldMode = GetMapMode();
- if ( aOldMode != aDrawMode )
- SetMapMode( aDrawMode );
+ const MapMode aDrawMode = GetDrawMapMode();
+ const MapMode aOldMode = GetMapMode();
+ comphelper::ScopeGuard aMapModeGuard(
+ [&aOldMode, &aDrawMode, this] {
+ if (aOldMode != aDrawMode)
+ SetMapMode(aOldMode);
+ }
+ );
+ if (aOldMode != aDrawMode)
+ SetMapMode(aDrawMode);
DeleteHeaderOverlay();
@@ -7067,9 +7079,6 @@ void ScGridWindow::UpdateHeaderOverlay()
mpOOHeader->append(std::move(pOverlay));
}
}
-
- if ( aOldMode != aDrawMode )
- SetMapMode( aOldMode );
}
void ScGridWindow::DeleteShrinkOverlay()
@@ -7079,10 +7088,16 @@ void ScGridWindow::DeleteShrinkOverlay()
void ScGridWindow::UpdateShrinkOverlay()
{
- MapMode aDrawMode = GetDrawMapMode();
- MapMode aOldMode = GetMapMode();
- if ( aOldMode != aDrawMode )
- SetMapMode( aDrawMode );
+ const MapMode aDrawMode = GetDrawMapMode();
+ const MapMode aOldMode = GetMapMode();
+ comphelper::ScopeGuard aMapModeGuard(
+ [&aOldMode, &aDrawMode, this] {
+ if (aOldMode != aDrawMode)
+ SetMapMode(aOldMode);
+ }
+ );
+ if (aOldMode != aDrawMode)
+ SetMapMode(aDrawMode);
DeleteShrinkOverlay();
@@ -7134,9 +7149,6 @@ void ScGridWindow::UpdateShrinkOverlay()
mpOOShrink->append(std::move(pOverlay));
}
}
-
- if ( aOldMode != aDrawMode )
- SetMapMode( aOldMode );
}
void ScGridWindow::DeleteSparklineGroupOverlay()
@@ -7146,9 +7158,14 @@ void ScGridWindow::DeleteSparklineGroupOverlay()
void ScGridWindow::UpdateSparklineGroupOverlay()
{
- MapMode aDrawMode = GetDrawMapMode();
-
- MapMode aOldMode = GetMapMode();
+ const MapMode aDrawMode = GetDrawMapMode();
+ const MapMode aOldMode = GetMapMode();
+ comphelper::ScopeGuard aMapModeGuard(
+ [&aOldMode, &aDrawMode, this] {
+ if (aOldMode != aDrawMode)
+ SetMapMode(aOldMode);
+ }
+ );
if (aOldMode != aDrawMode)
SetMapMode(aDrawMode);
@@ -7197,9 +7214,6 @@ void ScGridWindow::UpdateSparklineGroupOverlay()
}
}
}
-
- if (aOldMode != aDrawMode)
- SetMapMode(aOldMode);
}
// #i70788# central method to get the OverlayManager safely