svx/source/dialog/framelinkarray.cxx |   26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

New commits:
commit f625928c346109216045d08b4dda30dbada005f5
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Dec 12 15:23:16 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Dec 13 08:27:14 2023 +0100

    tdf#158636 Wrong border behaviour when cells are merged
    
    regression from
        commit e27d4cc31e04be4c47b5085dfa2363ee45457e8a
        Author: Noel Grandin <noel.gran...@collabora.co.uk>
        Date:   Mon Jun 19 12:23:55 2023 +0200
        tdf#150534 reduce the memory consumption of cells when calculating
    
    where I accidentally removed a line in lclSetMergedRange that
    set mbMergedOrg to true.
    
    And then the singlevalfields plugin spotted that
    mbMergedOrig had only value, and so it got removed in:
        commit 884a2cd39a7c0433a5bbbf4e83e2a9b16cdad71c
        Author: Noel Grandin <noel.gran...@collabora.co.uk>
        Date:   Fri Jun 30 15:36:51 2023 +0200
        loplugin:singlevalfields
    
    Change-Id: I9fc057f63e14df36c73d25c421ddbec72f7723e7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160619
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/svx/source/dialog/framelinkarray.cxx 
b/svx/source/dialog/framelinkarray.cxx
index 21afef6441f5..fa5829438698 100644
--- a/svx/source/dialog/framelinkarray.cxx
+++ b/svx/source/dialog/framelinkarray.cxx
@@ -64,6 +64,7 @@ public:
     SvxRotateMode       meRotMode;
     double              mfOrientation;
 
+    bool                mbMergeOrig;
     bool                mbOverlapX;
     bool                mbOverlapY;
 
@@ -88,7 +89,7 @@ public:
     const Style& GetStyleTLBR() const { return maTLBR; }
     const Style& GetStyleBLTR() const { return maBLTR; }
 
-    bool                IsMerged() const { return mbOverlapX || mbOverlapY; }
+    bool                IsMerged() const { return mbMergeOrig || mbOverlapX || 
mbOverlapY; }
     bool                IsRotated() const { return mfOrientation != 0.0; }
 
     void                MirrorSelfX();
@@ -206,6 +207,7 @@ Cell::Cell() :
     mnAddBottom( 0 ),
     meRotMode(SvxRotateMode::SVX_ROTATE_MODE_STANDARD ),
     mfOrientation( 0.0 ),
+    mbMergeOrig( false ),
     mbOverlapX( false ),
     mbOverlapY( false )
 {
@@ -229,6 +231,7 @@ bool Cell::operator==(const Cell& rOther) const
         && mnAddBottom == rOther.mnAddBottom
         && meRotMode == rOther.meRotMode
         && mfOrientation == rOther.mfOrientation
+        && mbMergeOrig == rOther.mbMergeOrig
         && mbOverlapX == rOther.mbOverlapX
         && mbOverlapY == rOther.mbOverlapY;
 }
@@ -248,6 +251,7 @@ size_t Cell::hashCode() const
     o3tl::hash_combine(seed, mnAddBottom);
     o3tl::hash_combine(seed, meRotMode);
     o3tl::hash_combine(seed, mfOrientation);
+    o3tl::hash_combine(seed, mbMergeOrig);
     o3tl::hash_combine(seed, mbOverlapX);
     o3tl::hash_combine(seed, mbOverlapY);
     return seed;
@@ -352,7 +356,7 @@ struct ArrayImpl
 
     bool                HasCellRotation() const;
 
-    Cell* createOrFind(const Cell& rCell);
+    const Cell* createOrFind(const Cell& rCell);
 };
 
 static void lclSetMergedRange( ArrayImpl& rImpl, CellVec& rCells, sal_Int32 
nWidth, sal_Int32 nFirstCol, sal_Int32 nFirstRow, sal_Int32 nLastCol, sal_Int32 
nLastRow )
@@ -363,12 +367,14 @@ static void lclSetMergedRange( ArrayImpl& rImpl, CellVec& 
rCells, sal_Int32 nWid
         {
             const Cell* pCell = rCells[ nRow * nWidth + nCol ];
             Cell aTempCell(*pCell);
+            aTempCell.mbMergeOrig = false;
             aTempCell.mbOverlapX = nCol > nFirstCol;
             aTempCell.mbOverlapY = nRow > nFirstRow;
             rCells[ nRow * nWidth + nCol ] = rImpl.createOrFind(aTempCell);
         }
     }
     Cell aTempCell(*rCells[ nFirstRow * nWidth + nFirstCol ]);
+    aTempCell.mbMergeOrig = true;
     rCells[ nFirstRow * nWidth + nFirstCol ] = rImpl.createOrFind(aTempCell);
 }
 
@@ -399,7 +405,7 @@ ArrayImpl::~ArrayImpl()
         delete pCell;
 }
 
-Cell* ArrayImpl::createOrFind(const Cell& rCell)
+const Cell* ArrayImpl::createOrFind(const Cell& rCell)
 {
     auto it = maRegisteredCells.find(const_cast<Cell*>(&rCell));
     if (it != maRegisteredCells.end())
@@ -1142,6 +1148,20 @@ void Array::MirrorSelfX()
             aNewCells.push_back( mxImpl->createOrFind(aTempCell) );
         }
     }
+    for( nRow = 0; nRow < mxImpl->mnHeight; ++nRow )
+    {
+        for( nCol = 0; nCol < mxImpl->mnWidth; ++nCol )
+        {
+            if( mxImpl->GetCell( nCol, nRow )->mbMergeOrig )
+            {
+                sal_Int32 nLastCol = mxImpl->GetMergedLastCol( nCol, nRow );
+                sal_Int32 nLastRow = mxImpl->GetMergedLastRow( nCol, nRow );
+                lclSetMergedRange( *mxImpl, aNewCells, mxImpl->mnWidth,
+                    mxImpl->GetMirrorCol( nLastCol ), nRow,
+                    mxImpl->GetMirrorCol( nCol ), nLastRow );
+            }
+        }
+    }
     mxImpl->maCells.swap( aNewCells );
 
     std::reverse( mxImpl->maWidths.begin(), mxImpl->maWidths.end() );

Reply via email to