sc/source/core/data/drwlayer.cxx |   24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

New commits:
commit d070070003f0cc9d42f3a6bdd37999bdebca39ac
Author:     Balazs Varga <balazs.varga.ext...@allotropia.de>
AuthorDate: Mon Nov 21 11:12:15 2022 +0100
Commit:     Balazs Varga <balazs.varga.ext...@allotropia.de>
CommitDate: Wed Nov 30 09:53:48 2022 +0100

    tdf#46444 tdf#152081 sc: hide notes in hidden rows or columns
    
    Hide notes in hidden rows or columns just like we do
    in case of other sdrobjects.
    
    TODO: unit test
    
    Change-Id: Ib136324d5d0dd8777fc0912af6d8b9ac39935ac1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143024
    Tested-by: Jenkins
    Reviewed-by: Balazs Varga <balazs.varga.ext...@allotropia.de>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143211
    Tested-by: Gabor Kelemen <kelem...@ubuntu.com>
    Reviewed-by: Gabor Kelemen <kelem...@ubuntu.com>

diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 308ba809f3a9..ed1f9bdf4444 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -997,13 +997,17 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, 
ScDrawObjData& rData, bool bNegati
             position must not be done, if the cell containing the note has not
             been moved yet in the document. The calling code now passes an
             additional boolean stating if the cells are already moved. */
-        if( bUpdateNoteCaptionPos )
+        /*  tdf #152081 Do not change hidden objects. That would produce zero 
height
+            or width and loss of caption.*/
+        if (pObj->IsVisible() && bUpdateNoteCaptionPos)
+        {
             /*  When inside an undo action, there may be pending note captions
                 where cell note is already deleted (thus document cannot find
                 the note object anymore). The caption will be deleted later
                 with drawing undo. */
             if( ScPostIt* pNote = pDoc->GetNote( rData.maStart ) )
                 pNote->UpdateCaptionPos( rData.maStart );
+        }
         return;
     }
 
@@ -2335,12 +2339,9 @@ ScDrawLayer::GetObjectsAnchoredToRows(SCTAB nTab, SCROW 
nStartRow, SCROW nEndRow
     ScRange aRange( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab);
     while (pObject)
     {
-        if (!dynamic_cast<SdrCaptionObj*>(pObject)) // Caption objects are 
handled differently
-        {
-            ScDrawObjData* pObjData = GetObjData(pObject);
-            if (pObjData && aRange.In(pObjData->maStart))
-                aObjects.push_back(pObject);
-        }
+        ScDrawObjData* pObjData = GetObjData(pObject);
+        if (pObjData && aRange.In(pObjData->maStart))
+            aObjects.push_back(pObject);
         pObject = aIter.Next();
     }
     return aObjects;
@@ -2407,12 +2408,9 @@ std::vector<SdrObject*> 
ScDrawLayer::GetObjectsAnchoredToCols(SCTAB nTab, SCCOL
     ScRange aRange(nStartCol, 0, nTab, nEndCol, MAXROW, nTab);
     while (pObject)
     {
-        if (!dynamic_cast<SdrCaptionObj*>(pObject)) // Caption objects are 
handled differently
-        {
-            ScDrawObjData* pObjData = GetObjData(pObject);
-            if (pObjData && aRange.In(pObjData->maStart))
-                aObjects.push_back(pObject);
-        }
+        ScDrawObjData* pObjData = GetObjData(pObject);
+        if (pObjData && aRange.In(pObjData->maStart))
+            aObjects.push_back(pObject);
         pObject = aIter.Next();
     }
     return aObjects;

Reply via email to