Kaydet (Commit) 19d08bbf authored tarafından Miklos Vajna's avatar Miklos Vajna

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
251ba90d (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.

Change-Id: I590d9b2725a3330c26a04a526ce22d95970a974f
Reviewed-on: https://gerrit.libreoffice.org/32220Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 7c2eb642
This diff was suppressed by a .gitattributes entry.
...@@ -40,6 +40,23 @@ DECLARE_WW8EXPORT_TEST(testTdf89377, "tdf89377_tableWithBreakBeforeParaStyle.doc ...@@ -40,6 +40,23 @@ DECLARE_WW8EXPORT_TEST(testTdf89377, "tdf89377_tableWithBreakBeforeParaStyle.doc
CPPUNIT_ASSERT_EQUAL( 2, getPages() ); 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(); CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -798,13 +798,21 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, SfxItemSet*& rpItemSet, ...@@ -798,13 +798,21 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, SfxItemSet*& rpItemSet,
for(nLevelB = 0; nLevelB < nMaxLevel; ++nLevelB) for(nLevelB = 0; nLevelB < nMaxLevel; ++nLevelB)
aOfsNumsXCH.push_back(aLVL.aOfsNumsXCH[nLevelB]); aOfsNumsXCH.push_back(aLVL.aOfsNumsXCH[nLevelB]);
// nLevelB is an index in the aOfsNumsXCH array.
for(nLevelB = 0; nLevelB <= nLevel; ++nLevelB) for(nLevelB = 0; nLevelB <= nLevel; ++nLevelB)
{ {
// nPos is a one-based character offset to a level placeholder in
// sNumString.
sal_uInt8 nPos = aOfsNumsXCH[nLevelB]; sal_uInt8 nPos = aOfsNumsXCH[nLevelB];
if (nPos && nPos < sNumString.getLength() && sNumString[nPos-1] < nMaxLevel) if (nPos && nPos < sNumString.getLength())
{ {
if (rNotReallyThere[nLevelB]) // nPosValue is the actual numbering level.
aOfsNumsXCH[nLevelB] = 0; sal_Unicode nPosValue = sNumString[nPos-1];
if (nPosValue < nMaxLevel)
{
if (rNotReallyThere[nPosValue])
aOfsNumsXCH[nLevelB] = 0;
}
} }
} }
myIter aIter = std::remove(aOfsNumsXCH.begin(), aOfsNumsXCH.end(), 0); myIter aIter = std::remove(aOfsNumsXCH.begin(), aOfsNumsXCH.end(), 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment