sc/qa/unit/data/ods/tdf152081_UndoHideColsWithNotes.ods |binary
 sc/qa/unit/scshapetest.cxx                              |   31 ++++++++++++++++
 sc/source/core/data/drwlayer.cxx                        |    2 -
 3 files changed, 32 insertions(+), 1 deletion(-)

New commits:
commit c9807faad6a154b57a99adfdf9b02bd9e588250f
Author:     Balazs Varga <balazs.varga.ext...@allotropia.de>
AuthorDate: Fri Nov 25 14:03:45 2022 +0100
Commit:     Balazs Varga <balazs.varga.ext...@allotropia.de>
CommitDate: Sat Nov 26 22:41:04 2022 +0100

    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.ext...@allotropia.de>

diff --git a/sc/qa/unit/data/ods/tdf152081_UndoHideColsWithNotes.ods 
b/sc/qa/unit/data/ods/tdf152081_UndoHideColsWithNotes.ods
new file mode 100644
index 000000000000..6d2b480db7b6
Binary files /dev/null and 
b/sc/qa/unit/data/ods/tdf152081_UndoHideColsWithNotes.ods differ
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

Reply via email to