sw/source/core/frmedt/tblsel.cxx |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

New commits:
commit f60126a6bfae5dad4a11afcc94ddf4a58c5ce8ab
Author:     Oliver Specht <oliver.spe...@cib.de>
AuthorDate: Thu Apr 18 16:04:49 2024 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri May 10 11:05:36 2024 +0200

    tdf#159027: Fix calculation in tables with merged cells
    
    Calculation in tables with merged cells over multiple pages is fixed.
    It's more a workaround than a fix as it skips an empty SwRowFrame
    returned from SwTabFrame::GetFirstNonHeadlineRow()
    
    Change-Id: If11838da9769e0f6b0e54da8f422b4884684e30f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166254
    Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx
index 669762ffacc3..74ec7fe7a106 100644
--- a/sw/source/core/frmedt/tblsel.cxx
+++ b/sw/source/core/frmedt/tblsel.cxx
@@ -1878,9 +1878,18 @@ void MakeSelUnions( SwSelUnions& rUnions, const 
SwLayoutFrame *pStart,
             // erroneous results could occur during split/merge.
             // To prevent these we will determine the first and last row
             // within the union and use their values for a new union
-            const SwLayoutFrame* pRow = pTable->IsFollow() ?
-                                      pTable->GetFirstNonHeadlineRow() :
-                                      static_cast<const 
SwLayoutFrame*>(pTable->Lower());
+            const SwLayoutFrame* pRow = nullptr;
+            if (pTable->IsFollow())
+            {
+                SwRowFrame* pRowFrame = pTable->GetFirstNonHeadlineRow();
+                //tdf#159027: follow returns a frame without height if
+                // merged cells are invoved
+                if (pRowFrame->getFrameArea().IsEmpty())
+                    pRowFrame = static_cast<SwRowFrame*>(pRowFrame->GetNext());
+                pRow = pRowFrame;
+            }
+            else
+                pRow = static_cast<const SwLayoutFrame*>(pTable->Lower());
 
             while ( pRow && !pRow->getFrameArea().Overlaps( aUnion ) )
                 pRow = static_cast<const SwLayoutFrame*>(pRow->GetNext());

Reply via email to