sw/qa/extras/ooxmlexport/data/tdf153104.docx |binary
 sw/qa/extras/ooxmlexport/data/tdf153128.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx   |   37 +++++++++++++++++++++++++++
 sw/source/core/text/porlay.cxx               |    8 +++--
 sw/source/filter/ww8/docxattributeoutput.cxx |    8 ++++-
 5 files changed, 48 insertions(+), 5 deletions(-)

New commits:
commit 835f15e299c11faa1b7ea8707c087d922490b83d
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Jan 19 12:16:06 2023 +0300
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Jan 24 09:42:06 2023 +0000

    tdf#153104: fix the "dummy" levels when overriding lower numbering levels
    
    The problem was that Word treats empty w:num/w:lvlOverride elements
    for higher levels as defining corresponding w:startOverride equal
    to 0. This only shows when the first list element has a lower level
    and resets numbering; in this case, implicit higher levels get zero
    value, and the following higher level items start from 1.
    
    This writes the correct w:startOverride values (from the respective
    rule) to the gap-filling levels.
    
    Change-Id: I18db1c6011bf09826ba586aaec16e7939ecb0c6a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145770
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146003

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153104.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153104.docx
new file mode 100644
index 000000000000..d70b09852a83
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf153104.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index cc307634e96c..984f29bbd905 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -220,6 +220,28 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf152200)
     assertXPath(pXmlDoc, "//w:fldChar", 3); // no field characters elsewhere
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf153104)
+{
+    loadAndReload("tdf153104.docx");
+
+    xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+    OUString numId = getXPath(pXmlDoc, 
"/w:document/w:body/w:p[1]/w:pPr/w:numPr/w:numId", "val");
+
+    xmlDocUniquePtr pXmlNum = parseExport("word/numbering.xml");
+    OString numPath = "/w:numbering/w:num[@w:numId='"
+                      + OUStringToOString(numId, RTL_TEXTENCODING_ASCII_US) + 
"']/";
+
+    // Check that first level's w:lvlOverride/w:startOverride is written 
correctly:
+    // the list defines starting value of 10, which must be kept upon second 
level
+    // numbering reset.
+    // Without the fix, this would fail with
+    // - Expected: 1
+    // - Actual  : 0
+    // - In <>, XPath 
'/w:numbering/w:num[@w:numId='3']/w:lvlOverride[@w:ilvl='0']/w:startOverride' 
number of nodes is incorrect
+    assertXPath(pXmlNum, numPath + 
"w:lvlOverride[@w:ilvl='0']/w:startOverride", "val", "10");
+    assertXPath(pXmlNum, numPath + 
"w:lvlOverride[@w:ilvl='1']/w:startOverride", "val", "1");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf126477)
 {
     loadAndReload("embedded_chart.odt");
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 80f09a85562f..7a203c85fbf4 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -7953,10 +7953,14 @@ void DocxAttributeOutput::OverrideNumberingDefinition(
         if (bListsAreDifferent || levelOverride != rLevelOverrides.end())
         {
             // If there are "gaps" in w:lvlOverride numbers, MS Word can have 
issues with numbering.
-            // So we need to emit empty override tokens up to current one.
+            // So we need to emit default override tokens up to current one.
             while (nPreviousOverrideLevel < nLevel)
             {
-                m_pSerializer->singleElementNS(XML_w, XML_lvlOverride, 
FSNS(XML_w, XML_ilvl), OString::number(nPreviousOverrideLevel));
+                const SwNumFormat& rFormat = rRule.Get(nPreviousOverrideLevel);
+                m_pSerializer->startElementNS(XML_w, XML_lvlOverride, 
FSNS(XML_w, XML_ilvl), OString::number(nPreviousOverrideLevel));
+                // tdf#153104: absent startOverride is treated by Word as 
"startOverride value 0".
+                m_pSerializer->singleElementNS(XML_w, XML_startOverride, 
FSNS(XML_w, XML_val), OString::number(rFormat.GetStart()));
+                m_pSerializer->endElementNS(XML_w, XML_lvlOverride);
                 nPreviousOverrideLevel++;
             }
 
commit 060e9ea28aef4998609197eeac58ec74fd32111e
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sat Jan 21 08:04:47 2023 +0300
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Jan 24 09:41:57 2023 +0000

    tdf#153128: do not increase line height, when ignoring whitespace
    
    Since 2006, there is IgnoreTabsAndBlanksForLineCalculation compat flag,
    that handles whitespace-only text portions like in Word, not affecting
    resulting line height.
    
    The implementation, however, did not check if the corrected value is
    no larger than the old one. In the bugdoc, this increased the resulting
    line height.
    
    Change-Id: If855af3e87fd1458d92a36fdbcfa2c681a1075ee
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145919
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145998

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153128.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153128.docx
new file mode 100644
index 000000000000..97f08827d956
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf153128.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 1524539eb309..cc307634e96c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -245,6 +245,21 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf126477)
     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aSeq2.getLength());
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf153128)
+{
+    loadAndReload("tdf153128.docx");
+    calcLayout();
+    sal_Int32 nFirstLineHeight
+        = 
parseDump("/root/page/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion", 
"height")
+              .toInt32();
+    CPPUNIT_ASSERT_GREATER(sal_Int32(0), nFirstLineHeight);
+
+    // The text height is 1 pt, i.e. 20 twip; without the fix, it would fail 
with
+    // - Expected less than: 30
+    // - Actual  : 414
+    CPPUNIT_ASSERT_LESS(sal_Int32(30), nFirstLineHeight);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 8705ac6ecbd1..65f2b4de3bae 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -653,14 +653,16 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, 
SwTextFormatInfo &rInf )
         }
     }
 
-    // #i3952#
+    // #i3952# Whitespace does not increase line height
     if ( bHasBlankPortion && bHasOnlyBlankPortions )
     {
         sal_uInt16 nTmpAscent = GetAscent();
         sal_uInt16 nTmpHeight = Height();
         rLine.GetAttrHandler().GetDefaultAscentAndHeight( rInf.GetVsh(), 
*rInf.GetOut(), nTmpAscent, nTmpHeight );
-        SetAscent( nTmpAscent );
-        Height( nTmpHeight, false );
+        if (nTmpAscent < GetAscent() || GetAscent() <= 0)
+            SetAscent(nTmpAscent);
+        if (nTmpHeight < Height() || Height() <= 0)
+            Height(nTmpHeight, false);
     }
 
     // Robust:

Reply via email to