summaryrefslogtreecommitdiffstats
path: root/sc/qa/unit
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 05:03:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 05:03:24 +0000
commite3cf16e6fbf8d39cad8762f002b6db1d4f61ed36 (patch)
tree3c1753125149dcf36ba42a57f1574369e8524225 /sc/qa/unit
parentAdding debian version 4:24.2.2-3. (diff)
downloadlibreoffice-e3cf16e6fbf8d39cad8762f002b6db1d4f61ed36.tar.xz
libreoffice-e3cf16e6fbf8d39cad8762f002b6db1d4f61ed36.zip
Merging upstream version 4:24.2.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sc/qa/unit')
-rw-r--r--sc/qa/unit/data/ods/tdf160368.odsbin0 -> 25405 bytes
-rw-r--r--sc/qa/unit/data/ods/tdf160369_groupshape.odsbin0 -> 97614 bytes
-rw-r--r--sc/qa/unit/parallelism.cxx88
-rw-r--r--sc/qa/unit/scshapetest.cxx68
-rw-r--r--sc/qa/unit/ucalc_parallelism.cxx3
5 files changed, 159 insertions, 0 deletions
diff --git a/sc/qa/unit/data/ods/tdf160368.ods b/sc/qa/unit/data/ods/tdf160368.ods
new file mode 100644
index 0000000000..f9da81d278
--- /dev/null
+++ b/sc/qa/unit/data/ods/tdf160368.ods
Binary files differ
diff --git a/sc/qa/unit/data/ods/tdf160369_groupshape.ods b/sc/qa/unit/data/ods/tdf160369_groupshape.ods
new file mode 100644
index 0000000000..8c26fe8ce5
--- /dev/null
+++ b/sc/qa/unit/data/ods/tdf160369_groupshape.ods
Binary files differ
diff --git a/sc/qa/unit/parallelism.cxx b/sc/qa/unit/parallelism.cxx
new file mode 100644
index 0000000000..0ced71c442
--- /dev/null
+++ b/sc/qa/unit/parallelism.cxx
@@ -0,0 +1,88 @@
+/* -*- 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 <sal/config.h>
+
+#include "helper/qahelper.hxx"
+
+#include <document.hxx>
+#include <formulagroup.hxx>
+
+#include <officecfg/Office/Calc.hxx>
+
+using namespace sc;
+
+// test-suite suitable for loading documents to test parallelism in
+// with access only to exported symbols
+
+class ScParallelismTest : public ScModelTestBase
+{
+public:
+ ScParallelismTest()
+ : ScModelTestBase("sc/qa/unit/data")
+ {
+ }
+
+ virtual void setUp() override;
+ virtual void tearDown() override;
+
+private:
+ bool getThreadingFlag() const;
+ void setThreadingFlag(bool bSet);
+
+ bool m_bThreadingFlagCfg;
+};
+
+bool ScParallelismTest::getThreadingFlag() const
+{
+ return officecfg::Office::Calc::Formula::Calculation::UseThreadedCalculationForFormulaGroups::
+ get();
+}
+
+void ScParallelismTest::setThreadingFlag(bool bSet)
+{
+ std::shared_ptr<comphelper::ConfigurationChanges> xBatch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Calc::Formula::Calculation::UseThreadedCalculationForFormulaGroups::set(
+ bSet, xBatch);
+ xBatch->commit();
+}
+
+void ScParallelismTest::setUp()
+{
+ ScModelTestBase::setUp();
+
+ sc::FormulaGroupInterpreter::disableOpenCL_UnitTestsOnly();
+
+ m_bThreadingFlagCfg = getThreadingFlag();
+ if (!m_bThreadingFlagCfg)
+ setThreadingFlag(true);
+}
+
+void ScParallelismTest::tearDown()
+{
+ // Restore threading flag
+ if (!m_bThreadingFlagCfg)
+ setThreadingFlag(false);
+
+ ScModelTestBase::tearDown();
+}
+
+// Dependency range in this document was detected as I9:I9 instead of expected I9:I367
+CPPUNIT_TEST_FIXTURE(ScParallelismTest, testTdf160368)
+{
+ createScDoc("ods/tdf160368.ods");
+ ScDocShell* pDocSh = getScDocShell();
+ // without fix: ScFormulaCell::MaybeInterpret(): Assertion `!rDocument.IsThreadedGroupCalcInProgress()' failed.
+ pDocSh->DoHardRecalc();
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index 5e48270053..c5b4b098c8 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -1231,6 +1231,74 @@ CPPUNIT_TEST_FIXTURE(ScShapeTest, testTdf160003_copy_page_anchored)
CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount());
}
+CPPUNIT_TEST_FIXTURE(ScShapeTest, testTdf160369_groupshape)
+{
+ // The document contains a group spanning range C5:F12. It is currently anchored to page to
+ // make sure its position does not change. When the group was anchored 'To Cell' and rows or
+ // columns were hidden before the group, saving changed the anchor position and anchor
+ // offset. This happened both with using 'resize with cell' and not.
+ createScDoc("ods/tdf160369_groupshape.ods");
+
+ // Get document and group object
+ ScDocument* pDoc = getScDoc();
+ SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
+
+ // Anchor group 'To Cell (resize with cell)' to prepare the test.
+ ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, 0 /*SCTAB*/, true /*bResizeWithCell*/);
+
+ // Hide rows 3 and 4 (UI number), which are before the group
+ // Hide column D, which is inside the group
+ pDoc->SetRowHidden(2, 3, 0, true);
+ pDoc->SetDrawPageSize(0); // trigger recalcpos, otherwise shapes are not changed
+ pDoc->SetColHidden(3, 3, 0, true);
+ pDoc->SetDrawPageSize(0);
+
+ // Get geometry of the group
+ ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pObj);
+ ScAddress aOrigStart = (*pObjData).maStart;
+ ScAddress aOrigEnd = (*pObjData).maEnd;
+ tools::Rectangle aOrigRect = pObj->GetSnapRect();
+
+ // Save document but do not reload. Saving alone had already caused the error.
+ save("calc8");
+
+ // Get geometry of the group again
+ ScDrawObjData* pAfterObjData = ScDrawLayer::GetObjData(pObj);
+ ScAddress aAfterStart = (*pAfterObjData).maStart;
+ ScAddress aAfterEnd = (*pAfterObjData).maEnd;
+ tools::Rectangle aAfterRect = pObj->GetSnapRect();
+
+ // verify Orig equals After
+ CPPUNIT_ASSERT_EQUAL(aOrigStart, aAfterStart);
+ CPPUNIT_ASSERT_EQUAL(aOrigEnd, aAfterEnd);
+ CPPUNIT_ASSERT_RECTANGLE_EQUAL_WITH_TOLERANCE(aOrigRect, aAfterRect, 1);
+
+ // The same but with saveAndReload.
+ createScDoc("ods/tdf160369_groupshape.ods");
+ pDoc = getScDoc();
+ pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
+ ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, 0 /*SCTAB*/, true /*bResizeWithCell*/);
+ pDoc->SetRowHidden(2, 3, 0, true);
+ pDoc->SetDrawPageSize(0); // trigger recalcpos, otherwise shapes are not changed
+ pDoc->SetColHidden(3, 3, 0, true);
+ pDoc->SetDrawPageSize(0);
+
+ saveAndReload("calc8");
+
+ // Verify geometry is same as before save
+ pDoc = getScDoc();
+ pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
+ pAfterObjData = ScDrawLayer::GetObjData(pObj);
+ aAfterStart = (*pAfterObjData).maStart;
+ aAfterEnd = (*pAfterObjData).maEnd;
+ aAfterRect = pObj->GetSnapRect();
+
+ // verify Orig equals After
+ CPPUNIT_ASSERT_EQUAL(aOrigStart, aAfterStart);
+ CPPUNIT_ASSERT_EQUAL(aOrigEnd, aAfterEnd);
+ CPPUNIT_ASSERT_RECTANGLE_EQUAL_WITH_TOLERANCE(aOrigRect, aAfterRect, 1);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/unit/ucalc_parallelism.cxx b/sc/qa/unit/ucalc_parallelism.cxx
index 2ee55708db..8996fb5fdc 100644
--- a/sc/qa/unit/ucalc_parallelism.cxx
+++ b/sc/qa/unit/ucalc_parallelism.cxx
@@ -21,6 +21,9 @@
using namespace css;
using namespace css::uno;
+// test-suite suitable for creating documents to test parallelism in
+// with access to internal unexported symbols
+
class ScParallelismTest : public ScUcalcTestBase
{
public: