summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-12-20 10:46:51 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-12-21 07:05:55 +0000
commit4849df7b4ca22978f6e15d03d3eca822f343fc5e (patch)
treecd62e33e89ce7349a2856d1afa0232949322ec7c
parent53a3a4a7ce2f7e55615f186c06ec565232f655fd (diff)
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@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/ww8export/data/tdf104805.docbin0 -> 22528 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export2.cxx17
-rw-r--r--sw/source/filter/ww8/ww8par3.cxx14
3 files changed, 28 insertions, 3 deletions
diff --git a/sw/qa/extras/ww8export/data/tdf104805.doc b/sw/qa/extras/ww8export/data/tdf104805.doc
new file mode 100644
index 000000000000..a2dd81dd0d28
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/tdf104805.doc
Binary files differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index 9e12ee9f8bec..f2f5aa7cd991 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 5c34fe8c74aa..497f5445d159 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);