diff options
author | Balazs Varga <balazs.varga.extern@allotropia.de> | 2022-11-25 14:03:45 +0100 |
---|---|---|
committer | Balazs Varga <balazs.varga.extern@allotropia.de> | 2022-11-26 22:41:04 +0100 |
commit | c9807faad6a154b57a99adfdf9b02bd9e588250f (patch) | |
tree | 680ee4aef2c3fda8e8502bb093af07574bda6085 /sc | |
parent | 21b88575af9e11115a6b124d8d9cb4e0a95e9fea (diff) |
Related: tdf#46444 tdf#152081 sc: add unit test for note hiding
Add unit test for column hiding with notes and undo that.
Change-Id: I880ca1565dbefea5e8776b0d137da409ce816ac1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143299
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/data/ods/tdf152081_UndoHideColsWithNotes.ods | bin | 0 -> 12142 bytes | |||
-rw-r--r-- | sc/qa/unit/scshapetest.cxx | 31 | ||||
-rw-r--r-- | sc/source/core/data/drwlayer.cxx | 2 |
3 files changed, 32 insertions, 1 deletions
diff --git a/sc/qa/unit/data/ods/tdf152081_UndoHideColsWithNotes.ods b/sc/qa/unit/data/ods/tdf152081_UndoHideColsWithNotes.ods Binary files differnew file mode 100644 index 000000000000..6d2b480db7b6 --- /dev/null +++ b/sc/qa/unit/data/ods/tdf152081_UndoHideColsWithNotes.ods diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx index af3d7308ee0e..58a9623ec4ec 100644 --- a/sc/qa/unit/scshapetest.cxx +++ b/sc/qa/unit/scshapetest.cxx @@ -61,6 +61,7 @@ public: void testLoadVerticalFlip(); void testTdf117948_CollapseBeforeShape(); void testTdf137355_UndoHideRows(); + void testTdf152081_UndoHideColsWithNotes(); void testTdf115655_HideDetail(); void testFitToCellSize(); void testCustomShapeCellAnchoredRotatedShape(); @@ -88,6 +89,7 @@ public: CPPUNIT_TEST(testLoadVerticalFlip); CPPUNIT_TEST(testTdf117948_CollapseBeforeShape); CPPUNIT_TEST(testTdf137355_UndoHideRows); + CPPUNIT_TEST(testTdf152081_UndoHideColsWithNotes); CPPUNIT_TEST(testTdf115655_HideDetail); CPPUNIT_TEST(testFitToCellSize); CPPUNIT_TEST(testCustomShapeCellAnchoredRotatedShape); @@ -945,6 +947,35 @@ void ScShapeTest::testTdf137355_UndoHideRows() aSnapRectUndo, 1); } +void ScShapeTest::testTdf152081_UndoHideColsWithNotes() +{ + createScDoc("tdf152081_UndoHideColsWithNotes.ods"); + + // Get document and shape + ScDocument* pDoc = getScDoc(); + SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0); + + CPPUNIT_ASSERT_MESSAGE("Load: Note object should be visible", pObj->IsVisible()); + + // Hide B column + uno::Sequence<beans::PropertyValue> aPropertyValues = { + comphelper::makePropertyValue("ToPoint", OUString("$B$2:$B$2")), + }; + dispatchCommand(mxComponent, ".uno:GoToCell", aPropertyValues); + ScTabViewShell* pViewShell = getViewShell(); + pViewShell->GetViewData().GetDispatcher().Execute(FID_COL_HIDE); + + // Check object is invisible + CPPUNIT_ASSERT_MESSAGE("Hide: Note object should be invisible", !pObj->IsVisible()); + + // Undo + pViewShell->GetViewData().GetDispatcher().Execute(SID_UNDO); + + // Check object is visible + CPPUNIT_ASSERT_MESSAGE("Undo: Note object should exist", pObj); + CPPUNIT_ASSERT_MESSAGE("Undo: Note object should be visible", pObj->IsVisible()); +} + void ScShapeTest::testTdf115655_HideDetail() { // The document contains an image inside a cell anchored "To Cell (resize with cell)". The cell diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index 9474d5859407..ec4fee275ed1 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -1035,7 +1035,7 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati additional boolean stating if the cells are already moved. */ /* tdf #152081 Do not change hidden objects. That would produce zero height or width and loss of caption.*/ - if (pObj->IsVisible() && bUpdateNoteCaptionPos) + if (bUpdateNoteCaptionPos && pObj->IsVisible()) { /* When inside an undo action, there may be pending note captions where cell note is already deleted (thus document cannot find |