sw/inc/IDocumentSettingAccess.hxx                           |    2 +
 sw/qa/core/layout/flycnt.cxx                                |    6 ++--
 sw/qa/extras/layout/data/tdf155229_row_height_at_least.docx |binary
 sw/qa/extras/layout/layout3.cxx                             |   12 ++++++++
 sw/source/core/doc/DocumentSettingManager.cxx               |   13 ++++++++
 sw/source/core/inc/DocumentSettingManager.hxx               |    1 
 sw/source/core/layout/tabfrm.cxx                            |   10 ++++++
 sw/source/filter/ww8/ww8par.cxx                             |    3 ++
 sw/source/uibase/uno/SwXDocumentSettings.cxx                |   18 +++++++++++-
 writerfilter/source/dmapper/DomainMapper.cxx                |    2 +
 10 files changed, 62 insertions(+), 5 deletions(-)

New commits:
commit 7ed59c84c7ead0e9e756ba81772610407a3045ed
Author:     Oliver Specht <oliver.spe...@cib.de>
AuthorDate: Thu Jun 27 08:57:43 2024 +0200
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Tue Jul 30 00:21:34 2024 +0200

    tdf#155229 Calculate row height incl. border if 'atLeast' is set
    
    Word includes the width of horizontal borders when calculation row height
    in case the row height is set as "atLeast"
    
    Change-Id: I37778e5cdc6e083e94a17f50bd0b75a291ededcd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170927
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    Tested-by: allotropia jenkins <jenk...@allotropia.de>

diff --git a/sw/inc/IDocumentSettingAccess.hxx 
b/sw/inc/IDocumentSettingAccess.hxx
index 39bcd7efcbeb..133fd12811b7 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -135,6 +135,8 @@ enum class DocumentSettingId
     USE_VARIABLE_WIDTH_NBSP,
     // overlap background shapes if anchored in body
     PAINT_HELL_OVER_HEADER_FOOTER,
+    // tdf#155229 calculate minimum row height including horizontal border 
width
+    MIN_ROW_HEIGHT_INCL_BORDER,
 };
 
 /** Provides access to settings of a document
diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index 455012ea4948..7fedd5b2499c 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -450,10 +450,10 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyWidow)
     SwFrame* pTab2 = pPage2Fly->GetLower();
     SwFrame* pRow2 = pTab2->GetLower();
     // Without the accompanying fix in place, this test would have failed with:
-    // - Expected: 1014
+    // - Expected: 1029
     // - Actual  : 553
-    // i.e. <w:trHeight w:val="1014"> from the file was ignored.
-    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(1014), 
pRow2->getFrameArea().Height());
+    // i.e. <w:trHeight w:val="1029"> from the file was ignored
+    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(1029), 
pRow2->getFrameArea().Height());
     SwFrame* pCell2 = pRow2->GetLower();
     auto pText2 = dynamic_cast<SwTextFrame*>(pCell2->GetLower());
     // And then similarly this was 1, not 2.
diff --git a/sw/qa/extras/layout/data/tdf155229_row_height_at_least.docx 
b/sw/qa/extras/layout/data/tdf155229_row_height_at_least.docx
new file mode 100755
index 000000000000..a42031a41f5b
Binary files /dev/null and 
b/sw/qa/extras/layout/data/tdf155229_row_height_at_least.docx differ
diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 997a63f9a831..25e541bfcf0c 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -2638,6 +2638,18 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, 
TestCrashHyphenation)
     createSwDoc("crashHyphen.fodt");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, TestTdf155229RowAtLeast)
+{
+    createSwDoc("tdf155229_row_height_at_least.docx");
+
+    xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+    sal_Int32 nTableHeight
+        = getXPath(pXmlDoc, 
"/root/page[1]/body/tab[1]/row[11]/infos/bounds"_ostr, "bottom"_ostr)
+              .toInt32();
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(15494), nTableHeight);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx 
b/sw/source/core/doc/DocumentSettingManager.cxx
index f3dfbef0e3c5..b893434a54b9 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -108,7 +108,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc 
&rDoc)
     mbNoNumberingShowFollowBy(false),
     mbDropCapPunctuation(true),
     mbUseVariableWidthNBSP(false),
-    mbPaintHellOverHeaderFooter(false)
+    mbPaintHellOverHeaderFooter(false),
+    mbMinRowHeightInclBorder(false)
 
     // COMPATIBILITY FLAGS END
 {
@@ -265,6 +266,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ 
DocumentSettingId id) const
         case DocumentSettingId::DROP_CAP_PUNCTUATION: return 
mbDropCapPunctuation;
         case DocumentSettingId::USE_VARIABLE_WIDTH_NBSP: return 
mbUseVariableWidthNBSP;
         case DocumentSettingId::PAINT_HELL_OVER_HEADER_FOOTER: return 
mbPaintHellOverHeaderFooter;
+        case DocumentSettingId::MIN_ROW_HEIGHT_INCL_BORDER: return 
mbMinRowHeightInclBorder;
         default:
             OSL_FAIL("Invalid setting id");
     }
@@ -486,6 +488,10 @@ void sw::DocumentSettingManager::set(/*[in]*/ 
DocumentSettingId id, /*[in]*/ boo
             mbPaintHellOverHeaderFooter = value;
             break;
 
+        case DocumentSettingId::MIN_ROW_HEIGHT_INCL_BORDER:
+            mbMinRowHeightInclBorder = value;
+            break;
+
         // COMPATIBILITY FLAGS END
 
         case DocumentSettingId::BROWSE_MODE: //can be used temporary 
(load/save) when no SwViewShell is available
@@ -1066,6 +1072,11 @@ void 
sw::DocumentSettingManager::dumpAsXml(xmlTextWriterPtr pWriter) const
                                 
BAD_CAST(OString::boolean(mbPaintHellOverHeaderFooter).getStr()));
     (void)xmlTextWriterEndElement(pWriter);
 
+    (void)xmlTextWriterStartElement(pWriter, 
BAD_CAST("mbMinRowHeightInclBorder"));
+    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
+                                
BAD_CAST(OString::boolean(mbMinRowHeightInclBorder).getStr()));
+    (void)xmlTextWriterEndElement(pWriter);
+
     (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mbContinuousEndnotes"));
     (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
                                 
BAD_CAST(OString::boolean(mbContinuousEndnotes).getStr()));
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx 
b/sw/source/core/inc/DocumentSettingManager.hxx
index 5dfb4928b12f..5d5ccc7480cb 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -185,6 +185,7 @@ class DocumentSettingManager final :
     bool mbDropCapPunctuation; // tdf#150200, tdf#150438
     bool mbUseVariableWidthNBSP : 1; // tdf#41652
     bool mbPaintHellOverHeaderFooter : 1; // tdf#160198
+    bool mbMinRowHeightInclBorder : 1; // tdf#155229
 
 public:
 
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 39d936cf7a23..f1971b6a53ef 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -196,6 +196,8 @@ static bool lcl_InnerCalcLayout( SwFrame *pFrame,
 // cell height.
 static SwTwips lcl_CalcMinRowHeight( const SwRowFrame *pRow,
                                      const bool _bConsiderObjs );
+static sal_uInt16 lcl_GetTopSpace( const SwRowFrame& rRow );
+
 static SwTwips lcl_CalcTopAndBottomMargin( const SwLayoutFrame&, const 
SwBorderAttrs& );
 
 static SwTwips lcl_calcHeightOfRowBeforeThisFrame(const SwRowFrame& rRow);
@@ -4786,6 +4788,9 @@ static SwTwips lcl_CalcMinCellHeight( const SwLayoutFrame 
*_pCell,
 static SwTwips lcl_CalcMinRowHeight( const SwRowFrame* _pRow,
                                      const bool _bConsiderObjs )
 {
+    //calc min height including width of horizontal border
+    const bool bMinRowHeightInclBorder =
+        
_pRow->GetFormat()->GetDoc()->GetDocumentSettingManager().get(DocumentSettingId::MIN_ROW_HEIGHT_INCL_BORDER);
     SwTwips nHeight = 0;
     if ( !_pRow->IsRowSpanLine() )
     {
@@ -4827,6 +4832,11 @@ static SwTwips lcl_CalcMinRowHeight( const SwRowFrame* 
_pRow,
             {
                 nHeight = rSz.GetHeight() - 
lcl_calcHeightOfRowBeforeThisFrame(*_pRow);
             }
+            if (bMinRowHeightInclBorder)
+            {
+                //get horizontal border(s)
+                nHeight += lcl_GetTopSpace(*_pRow);
+            }
         }
     }
 
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 9d88a21b9299..b42e013c3bcd 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1870,6 +1870,9 @@ void SwWW8ImplReader::ImportDop()
         DocumentSettingId::FOOTNOTE_IN_COLUMN_TO_PAGEEND, true);
     m_rDoc.getIDocumentSettingAccess().set(
         DocumentSettingId::EMPTY_DB_FIELD_HIDES_PARA, false);
+    // tdf#155229 calculate minimum row height including horizontal border 
width
+    m_rDoc.getIDocumentSettingAccess().set(
+        DocumentSettingId::MIN_ROW_HEIGHT_INCL_BORDER, true);
 
     // Import Default Tabs
     tools::Long nDefTabSiz = m_xWDop->dxaTab;
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx 
b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index c07c6e448f12..151b155e8c54 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -161,7 +161,8 @@ enum SwDocumentSettingsPropertyHandles
     HANDLE_USE_VARIABLE_WIDTH_NBSP,
     HANDLE_APPLY_TEXT_ATTR_TO_EMPTY_LINE_AT_END_OF_PARAGRAPH,
     HANDLE_DO_NOT_MIRROR_RTL_DRAW_OBJS,
-    HANDLE_PAINT_HELL_OVER_HEADER_FOOTER
+    HANDLE_PAINT_HELL_OVER_HEADER_FOOTER,
+    HANDLE_MIN_ROW_HEIGHT_INCL_BORDER
 };
 
 }
@@ -270,6 +271,7 @@ static rtl::Reference<MasterPropertySetInfo> 
lcl_createSettingsInfo()
         { OUString("ApplyTextAttrToEmptyLineAtEndOfParagraph"), 
HANDLE_APPLY_TEXT_ATTR_TO_EMPTY_LINE_AT_END_OF_PARAGRAPH, 
cppu::UnoType<bool>::get(), 0 },
         { OUString("DoNotMirrorRtlDrawObjs"), 
HANDLE_DO_NOT_MIRROR_RTL_DRAW_OBJS, cppu::UnoType<bool>::get(), 0 },
         { OUString("PaintHellOverHeaderFooter"), 
HANDLE_PAINT_HELL_OVER_HEADER_FOOTER, cppu::UnoType<bool>::get(), 0 },
+        { OUString("MinRowHeightInclBorder"), 
HANDLE_MIN_ROW_HEIGHT_INCL_BORDER, cppu::UnoType<bool>::get(), 0 },
 
 /*
  * As OS said, we don't have a view when we need to set this, so I have to
@@ -1162,6 +1164,14 @@ void SwXDocumentSettings::_setSingleValue( const 
comphelper::PropertyInfo & rInf
                     DocumentSettingId::PAINT_HELL_OVER_HEADER_FOOTER, bTmp);
         }
         break;
+        case HANDLE_MIN_ROW_HEIGHT_INCL_BORDER:
+        {
+            bool bTmp;
+            if (rValue >>= bTmp)
+                mpDoc->getIDocumentSettingAccess().set(
+                    DocumentSettingId::MIN_ROW_HEIGHT_INCL_BORDER, bTmp);
+        }
+        break;
         default:
             throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
     }
@@ -1744,6 +1754,12 @@ void SwXDocumentSettings::_getSingleValue( const 
comphelper::PropertyInfo & rInf
                 DocumentSettingId::PAINT_HELL_OVER_HEADER_FOOTER);
         }
         break;
+        case HANDLE_MIN_ROW_HEIGHT_INCL_BORDER:
+        {
+            rValue <<= mpDoc->getIDocumentSettingAccess().get(
+                DocumentSettingId::MIN_ROW_HEIGHT_INCL_BORDER);
+        }
+        break;
         default:
             throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
     }
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index c54098678333..6fb318b597b7 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -147,6 +147,8 @@ DomainMapper::DomainMapper( const uno::Reference< 
uno::XComponentContext >& xCon
         
m_pImpl->SetDocumentSettingsProperty("PaintHellOverHeaderFooter",uno::Any(true));
         
m_pImpl->SetDocumentSettingsProperty(u"IgnoreTabsAndBlanksForLineCalculation"_ustr,uno::Any(true));
         
m_pImpl->SetDocumentSettingsProperty(u"EmptyDbFieldHidesPara"_ustr,uno::Any(false));
+        // calculate table row height with 'atLeast' including horizontal 
border width
+        
m_pImpl->SetDocumentSettingsProperty(u"MinRowHeightInclBorder"_ustr,uno::Any(true));
     }
 
     // Initialize RDF metadata, to be able to add statements during the import.

Reply via email to