sw/source/core/table/swnewtable.cxx |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

New commits:
commit 2f52d9abd5c08e0fb31faa25db20906349c17df1
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri Oct 7 16:13:05 2022 +0200
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Mon Oct 10 14:34:58 2022 +0200

    tdf#145871 sw: ODF import: don't convert subtables if outer row ...
    
    ... has fixed or min height.
    
    The code had 2 obvious problems: the fixed height on the outer row
    wasn't cleared if the inner row didn't have a fixed height, and the code
    to set lastSize on the last row erroneously set the first row's height
    as well due to sharing the row format.
    
    But it turns out that this doesn't work anyway in case any of the inner
    rows are variable sized, because without layout it's not possible to
    determine the height of these rows, and so the lastSize is going to be
    too large in many cases.
    
    (regression from commit e366c928819c44b5c253c45dca6dae40b71c9808)
    
    Change-Id: I42ac7c14236562f9cae228efc0e98dc2fa8c2a23
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141079
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 4757dfc2a520f63fba0b27cc161fe732231dbd0e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141061
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/source/core/table/swnewtable.cxx 
b/sw/source/core/table/swnewtable.cxx
index f3bcc71f48f9..c632f86b693b 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -2133,6 +2133,11 @@ void SwTable::ConvertSubtableBox(sal_uInt16 const nRow, 
sal_uInt16 const nBox)
     assert(!pSubTableBox->GetTabLines().empty());
     // are relative (%) heights possible? apparently not
     SwFormatFrameSize const 
outerSize(pSourceLine->GetFrameFormat()->GetFrameSize());
+    if (outerSize.GetHeightSizeType() != SwFrameSize::Variable)
+    {   // tdf#145871 clear fixed size in first row
+        pSourceLine->ClaimFrameFormat();
+        pSourceLine->GetFrameFormat()->ResetFormatAttr(RES_FRM_SIZE);
+    }
     tools::Long minHeights(0);
     {
         SwFrameFormat const& 
rSubLineFormat(*pSubTableBox->GetTabLines()[0]->GetFrameFormat());
@@ -2171,12 +2176,14 @@ void SwTable::ConvertSubtableBox(sal_uInt16 const nRow, 
sal_uInt16 const nBox)
             && outerSize.GetHeightSizeType() != SwFrameSize::Variable
             && minHeights < outerSize.GetHeight())
         {
+            assert(false); // this should be impossible currently, such 
subtable isn't converted because layout is needed to determine how much space 
is taken up by variable height rows
             SwFormatFrameSize 
lastSize(pNewLine->GetFrameFormat()->GetFrameSize());
             lastSize.SetHeight(lastSize.GetHeight() + outerSize.GetHeight() - 
minHeights);
             if (lastSize.GetHeightSizeType() == SwFrameSize::Variable)
             {
                 lastSize.SetHeightSizeType(SwFrameSize::Minimum);
             }
+            pNewLine->ClaimFrameFormat();
             pNewLine->GetFrameFormat()->SetFormatAttr(lastSize);
         }
         SfxPoolItem const* pRowBrush(nullptr);
@@ -2295,6 +2302,7 @@ bool SwTable::CanConvertSubtables() const
                     return false;
                 }
                 haveSubtable = true;
+                bool haveNonFixedInnerLine(false);
                 for (SwTableLine const*const pInnerLine : pBox->GetTabLines())
                 {
                     // bitmap row background will look different
@@ -2311,6 +2319,13 @@ bool SwTable::CanConvertSubtables() const
                             return false;
                         }
                     }
+                    if (SwFormatFrameSize const* pSize = 
rRowFormat.GetItemIfSet(RES_FRM_SIZE))
+                    {
+                        if (pSize->GetHeightSizeType() != SwFrameSize::Fixed)
+                        {
+                            haveNonFixedInnerLine = true;
+                        }
+                    }
                     for (SwTableBox const*const pInnerBox : 
pInnerLine->GetTabBoxes())
                     {
                         if (!pInnerBox->GetTabLines().empty())
@@ -2319,6 +2334,17 @@ bool SwTable::CanConvertSubtables() const
                         }
                     }
                 }
+                if (haveNonFixedInnerLine)
+                {
+                    if (SwFormatFrameSize const* pSize = 
pLine->GetFrameFormat()->GetItemIfSet(RES_FRM_SIZE))
+                    {
+                        if (pSize->GetHeightSizeType() != 
SwFrameSize::Variable)
+                        {
+                            // not possible to distribute fixed outer row 
height on rows without layout
+                            return false;
+                        }
+                    }
+                }
             }
         }
     }

Reply via email to