[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Dec 20 18:35:04 UTC 2016


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

New commits:
commit 4c6904c4e491d4211d06f65b759433c59fe0de6b
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)
    
    Conflicts:
    	sw/qa/extras/ww8export/ww8export2.cxx
    
    Change-Id: I590d9b2725a3330c26a04a526ce22d95970a974f
    Reviewed-on: https://gerrit.libreoffice.org/32233
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

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/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index 792f582..4ac070b 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -691,6 +691,23 @@ DECLARE_WW8EXPORT_TEST(testTdf99474, "tdf99474.odt")
     CPPUNIT_ASSERT_EQUAL(COL_AUTO, charColor);
 }
 
+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 eaefccb..b04c165 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