summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-01-17 21:09:41 +0000
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-01-20 12:45:13 +0100
commit7edfb1b85cef5e5435cd2bf46e1b91b68f1e6427 (patch)
tree1d486afbecd0e8641e1794a8b760f0728d7d256d /test
parent38e621f124e5d3c537c15a25cfd099d08094e2b4 (diff)
calc doc with saved zoom in settings causes disjoint invalidations...
in multiple views, while the invalidations rectangles should be reported at the same place from each view. on load, ScTabView::SetZoom gets called with the zoom stored in the document settings, which both calls sets Zoom on the ViewData, and then calls ZoomChanged, which syncs the GridWindows MapMode from the ViewData derived GetDrawMapMode(). Later lok sets zoom via setClientArea which leaves the GridWindows MapMode untouched and out of sync with the newly changed ViewData MapMode. Typically then, on e.g. on deleting text in one view then ScViewFunc::DeleteContents or similar is called which calls ScTabView::UpdateCopySourceOverlay which calls ScGridWindow::UpdateCopySourceOverlay and that sets the GridWindow MapMode to the DrawMapMode but then *for lokit* returns early (among a few other unlikely early return cases) while every other similar func restores the orig GridWindow mode before returning. So the view which is used to make the change ends up with GridWindows synced to the ViewData MapMode, which looks like accident. While the other view remains with GridWindows with MapModes unsynced with that views ViewData MapMode. So on invalidate, the view that was used to make the change has GridWindows with MapModes that report the correct rectangle, while the other unsynced view will report an incorrect rectangle, until something happens in that view to get it to exec UpdateCopySourceOverlay and get synced. Here add the sync to ScModelObj::setClientZoom so the two MapModes remain synced once that is called. Change-Id: I2da59f50ae2b0e3ea6b7ef8b54debdab1ee98266 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162312 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162322 Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'test')
-rw-r--r--test/Library_test.mk1
-rw-r--r--test/source/cppunitasserthelper.cxx60
2 files changed, 61 insertions, 0 deletions
diff --git a/test/Library_test.mk b/test/Library_test.mk
index 268a68744eaf..c51bd826e658 100644
--- a/test/Library_test.mk
+++ b/test/Library_test.mk
@@ -56,6 +56,7 @@ $(eval $(call gb_Library_add_exception_objects,test,\
test/source/helper/form \
test/source/helper/shape \
test/source/helper/transferable \
+ test/source/cppunitasserthelper \
))
# vim: set noet sw=4 ts=4:
diff --git a/test/source/cppunitasserthelper.cxx b/test/source/cppunitasserthelper.cxx
new file mode 100644
index 000000000000..b3119b5b26d8
--- /dev/null
+++ b/test/source/cppunitasserthelper.cxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#include <test/cppunitasserthelper.hxx>
+
+CPPUNIT_NS_BEGIN
+
+void AssertRectEqualWithTolerance(std::string_view sInfo, const tools::Rectangle& rExpected,
+ const tools::Rectangle& rActual, const sal_Int32 nTolerance)
+{
+ // Left
+ OString sMsg = OString::Concat(sInfo) + " Left expected " + OString::number(rExpected.Left())
+ + " actual " + OString::number(rActual.Left()) + " Tolerance "
+ + OString::number(nTolerance);
+ CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
+ std::abs(rExpected.Left() - rActual.Left()) <= nTolerance);
+
+ // Top
+ sMsg = OString::Concat(sInfo) + " Top expected " + OString::number(rExpected.Top()) + " actual "
+ + OString::number(rActual.Top()) + " Tolerance " + OString::number(nTolerance);
+ CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), std::abs(rExpected.Top() - rActual.Top()) <= nTolerance);
+
+ // Width
+ sMsg = OString::Concat(sInfo) + " Width expected " + OString::number(rExpected.GetWidth())
+ + " actual " + OString::number(rActual.GetWidth()) + " Tolerance "
+ + OString::number(nTolerance);
+ CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
+ std::abs(rExpected.GetWidth() - rActual.GetWidth()) <= nTolerance);
+
+ // Height
+ sMsg = OString::Concat(sInfo) + " Height expected " + OString::number(rExpected.GetHeight())
+ + " actual " + OString::number(rActual.GetHeight()) + " Tolerance "
+ + OString::number(nTolerance);
+ CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
+ std::abs(rExpected.GetHeight() - rActual.GetHeight()) <= nTolerance);
+}
+
+void AssertPointEqualWithTolerance(std::string_view sInfo, const Point rExpected,
+ const Point rActual, const sal_Int32 nTolerance)
+{
+ // X
+ OString sMsg = OString::Concat(sInfo) + " X expected " + OString::number(rExpected.X())
+ + " actual " + OString::number(rActual.X()) + " Tolerance "
+ + OString::number(nTolerance);
+ CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), std::abs(rExpected.X() - rActual.X()) <= nTolerance);
+ // Y
+ sMsg = OString::Concat(sInfo) + " Y expected " + OString::number(rExpected.Y()) + " actual "
+ + OString::number(rActual.Y()) + " Tolerance " + OString::number(nTolerance);
+ CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), std::abs(rExpected.Y() - rActual.Y()) <= nTolerance);
+}
+
+CPPUNIT_NS_END
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */