[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Dec 21 07:06:29 UTC 2016


 sw/qa/extras/ww8export/data/tdf104805.doc |binary
 sw/qa/extras/ww8export/ww8export2.cxx     |   17 +++++++++++++++++
 sw/source/filter/ww8/ww8par3.cxx          |   14 +++++++++++---
 3 files changed, 28 insertions(+), 3 deletions(-)

New commits:
commit 4849df7b4ca22978f6e15d03d3eca822f343fc5e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Dec 20 10:46:51 2016 +0100

    tdf#104805 DOC import: fix non-0-starting LVL.xst with none-type prev level
    
    Interesting parts of the bugdoc:
    
    - it has a numbering definition with two levels
    - first level's type is none
    - second level has a numbering string: "\x01."
    
    Usually these placeholder bytes in the numbering string start from 0x00,
    but there it starts at 0x01, which means the layout has to replace it
    with the numbering from the second level.
    
    Mapping from the spec to the code:
    
    - nLevelB is an index into rgbxchNums
    - aOfsNumsXCH is rgbxchNums
    - sNumString is xst
    
    So when the rNotReallyThere added in commit
    251ba90d863c2695c9f46ef922e49d72a65da9ea (INTEGRATION: CWS
    soberfilterteam06 (1.44.26); FILE MERGED, 2003-05-19) wants to clear out
    indexes from aOfsNumsXCH, it talks about numbering levels. The old code
    assumed that nLevelB is the same as nPosValue, which is true in many
    cases (when the levels are like 1, 1.1, 1.1.1), but not in this
    particular case, where nLevelB is 0, but nPosValue is 1.
    
    (cherry picked from commit 19d08bbf704332d727cfbe8e101e7d14c62326a0)
    
    Change-Id: I590d9b2725a3330c26a04a526ce22d95970a974f
    Reviewed-on: https://gerrit.libreoffice.org/32237
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ww8export/data/tdf104805.doc b/sw/qa/extras/ww8export/data/tdf104805.doc
new file mode 100644
index 0000000..a2dd81d
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf104805.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index 9e12ee9..f2f5aa7 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -40,6 +40,23 @@ DECLARE_WW8EXPORT_TEST(testTdf89377, "tdf89377_tableWithBreakBeforeParaStyle.doc
     CPPUNIT_ASSERT_EQUAL( 2, getPages() );
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf104805, "tdf104805.doc")
+{
+    uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WW8Num1"), uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
+    uno::Sequence<beans::PropertyValue> aNumberingRule;
+    xLevels->getByIndex(1) >>= aNumberingRule; // 2nd level
+    for (const auto& rPair : aNumberingRule)
+    {
+        if (rPair.Name == "Prefix")
+            // This was "." instead of empty, so the second paragraph was
+            // rendered as ".1" instead of "1.".
+            CPPUNIT_ASSERT_EQUAL(OUString(), rPair.Value.get<OUString>());
+        else if (rPair.Name == "Suffix")
+            CPPUNIT_ASSERT_EQUAL(OUString("."), rPair.Value.get<OUString>());
+    }
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 5c34fe8..497f544 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -812,13 +812,21 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, SfxItemSet*& rpItemSet,
     for(nLevelB = 0; nLevelB < nMaxLevel; ++nLevelB)
         aOfsNumsXCH.push_back(aLVL.aOfsNumsXCH[nLevelB]);
 
+    // nLevelB is an index in the aOfsNumsXCH array.
     for(nLevelB = 0; nLevelB <= nLevel; ++nLevelB)
     {
+        // nPos is a one-based character offset to a level placeholder in
+        // sNumString.
         sal_uInt8 nPos = aOfsNumsXCH[nLevelB];
-        if (nPos && nPos < sNumString.getLength()  && sNumString[nPos-1] < nMaxLevel)
+        if (nPos && nPos < sNumString.getLength())
         {
-            if (rNotReallyThere[nLevelB])
-                aOfsNumsXCH[nLevelB] = 0;
+            // nPosValue is the actual numbering level.
+            sal_Unicode nPosValue = sNumString[nPos-1];
+            if (nPosValue < nMaxLevel)
+            {
+                if (rNotReallyThere[nPosValue])
+                    aOfsNumsXCH[nLevelB] = 0;
+            }
         }
     }
     myIter aIter = std::remove(aOfsNumsXCH.begin(), aOfsNumsXCH.end(), 0);


More information about the Libreoffice-commits mailing list