diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 05:03:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 05:09:28 +0000 |
commit | 97ac77f067910fa5e8206d75160fa63546a9358d (patch) | |
tree | e6fa64b43e8150ef65578afa4f1f40f3e19f7fa3 /sc/qa | |
parent | Releasing progress-linux version 4:24.2.2-3~progress7.99u1. (diff) | |
download | libreoffice-97ac77f067910fa5e8206d75160fa63546a9358d.tar.xz libreoffice-97ac77f067910fa5e8206d75160fa63546a9358d.zip |
Merging upstream version 4:24.2.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/extras/scpdfexport.cxx | 14 | ||||
-rw-r--r-- | sc/qa/extras/testdocuments/tdf159094.ods | bin | 0 -> 10716 bytes | |||
-rwxr-xr-x | sc/qa/uitest/pasteSpecial/tdf160765.py | 75 | ||||
-rw-r--r-- | sc/qa/unit/data/ods/tdf160368.ods | bin | 0 -> 25405 bytes | |||
-rw-r--r-- | sc/qa/unit/data/ods/tdf160369_groupshape.ods | bin | 0 -> 97614 bytes | |||
-rw-r--r-- | sc/qa/unit/parallelism.cxx | 88 | ||||
-rw-r--r-- | sc/qa/unit/scshapetest.cxx | 68 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_parallelism.cxx | 3 |
8 files changed, 248 insertions, 0 deletions
diff --git a/sc/qa/extras/scpdfexport.cxx b/sc/qa/extras/scpdfexport.cxx index bcca563ec9..78084b30b3 100644 --- a/sc/qa/extras/scpdfexport.cxx +++ b/sc/qa/extras/scpdfexport.cxx @@ -58,6 +58,7 @@ private: // unit tests public: + void testMediaShapeScreen_Tdf159094(); void testExportRange_Tdf120161(); void testExportFitToPage_Tdf103516(); void testUnoCommands_Tdf120161(); @@ -69,6 +70,7 @@ public: void testForcepoint97(); CPPUNIT_TEST_SUITE(ScPDFExportTest); + CPPUNIT_TEST(testMediaShapeScreen_Tdf159094); CPPUNIT_TEST(testExportRange_Tdf120161); CPPUNIT_TEST(testExportFitToPage_Tdf103516); CPPUNIT_TEST(testUnoCommands_Tdf120161); @@ -199,6 +201,18 @@ void ScPDFExportTest::setFont(ScFieldEditEngine& rEE, sal_Int32 nStart, sal_Int3 rEE.QuickSetAttribs(aItemSet, aSel); } +void ScPDFExportTest::testMediaShapeScreen_Tdf159094() +{ + loadFromFile(u"tdf159094.ods"); + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + + // A1:B8 + ScRange aRange(0, 0, 0, 1, 7, 0); + + // Without the fix, this test would crash on export media file to pdf + exportToPDF(xModel, aRange); +} + // Selection was not taken into account during export into PDF void ScPDFExportTest::testExportRange_Tdf120161() { diff --git a/sc/qa/extras/testdocuments/tdf159094.ods b/sc/qa/extras/testdocuments/tdf159094.ods Binary files differnew file mode 100644 index 0000000000..c267b21521 --- /dev/null +++ b/sc/qa/extras/testdocuments/tdf159094.ods diff --git a/sc/qa/uitest/pasteSpecial/tdf160765.py b/sc/qa/uitest/pasteSpecial/tdf160765.py new file mode 100755 index 0000000000..0b56be4c2d --- /dev/null +++ b/sc/qa/uitest/pasteSpecial/tdf160765.py @@ -0,0 +1,75 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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/. +# + +from uitest.framework import UITestCase + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.paste_special import reset_default_values + +class tdf160765(UITestCase): + def test_tdf160765_undo_paste_comment(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") + + # Write text to cell A1 and B1 + enter_text_to_cell(xGridWin, "A1", "A1 sample text") + enter_text_to_cell(xGridWin, "B1", "B1 sample text") + + # Insert a comment in cell B1 + xArgs = mkPropertyValues({"Text": "Comment 1"}) + self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs) + + # Insert a comment in cell A2 + xGridWin.executeAction("SELECT", mkPropertyValues({"CELL":"A2"})) + xArgs = mkPropertyValues({"Text": "Comment 2"}) + self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs) + + # Copy cell A2 to clipboard + xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + self.xUITest.executeCommand(".uno:Copy") + + # Set cursor to cells and paste data using special options (check only comments) + targetCells = ["A1", "B1"] + for index, targetCell in enumerate(targetCells): + xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": targetCell})) + with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") as xPasteSpecialDlg: + reset_default_values(self, xPasteSpecialDlg) + xDateTimeChkBox = xPasteSpecialDlg.getChild("datetime") + xDateTimeChkBox.executeAction("CLICK", tuple()) + xTextChkBox = xPasteSpecialDlg.getChild("text") + xTextChkBox.executeAction("CLICK", tuple()) + xNumbersChkBox = xPasteSpecialDlg.getChild("numbers") + xNumbersChkBox.executeAction("CLICK", tuple()) + xCommentsChkBox = xPasteSpecialDlg.getChild("comments") + xCommentsChkBox.executeAction("CLICK", tuple()) + + # Undo both inserted comments + self.xUITest.executeCommand(".uno:Undo") + # Without the fix in place, this test would have failed with + # AssertionError: 'Comment 1' != '' + # i.e., the cell does not contain any comment + self.assertEqual("Comment 1", get_cell_by_position(document, 0, 1, 0).Annotation.String) + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual("", get_cell_by_position(document, 0, 0, 0).Annotation.String) + + # Redo both inserted comments + self.xUITest.executeCommand(".uno:Redo") + # Without the fix in place, this test would have failed with + # AssertionError: 'Comment 2' != '' + # i.e., the cell does not contain the restored comment + self.assertEqual("Comment 2", get_cell_by_position(document, 0, 0, 0).Annotation.String) + self.xUITest.executeCommand(".uno:Redo") + # Without the fix in place, this test would have failed with + # AssertionError: 'Comment 2' != '' + # i.e., the cell does not contain the restored comment + self.assertEqual("Comment 2", get_cell_by_position(document, 0, 0, 0).Annotation.String) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/unit/data/ods/tdf160368.ods b/sc/qa/unit/data/ods/tdf160368.ods Binary files differnew file mode 100644 index 0000000000..f9da81d278 --- /dev/null +++ b/sc/qa/unit/data/ods/tdf160368.ods diff --git a/sc/qa/unit/data/ods/tdf160369_groupshape.ods b/sc/qa/unit/data/ods/tdf160369_groupshape.ods Binary files differnew file mode 100644 index 0000000000..8c26fe8ce5 --- /dev/null +++ b/sc/qa/unit/data/ods/tdf160369_groupshape.ods 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: |