diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2024-02-27 08:29:31 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-03-01 15:26:58 +0100 |
commit | 36d9d58f6883d1616a6cc9a88485721bf127f2ff (patch) | |
tree | 714eeb153f9fc180824e71323e96fdcbfe1bb104 /sw | |
parent | fe0b935313b28003117a2d219fd2fe359947a11e (diff) |
Related: tdf#150408 DOC filter: handle legal numbering
The bugdoc's 2nd para started with 'Sect I.01', while Word rendered this
as 'Sect 1.01'.
The reason for this difference is that there is an "is legal" boolean
property on the numbering that we ignored from [MS-DOC] during
import/export.
Fix the problem by WW8ListManager::ReadLVL() and
WW8AttributeOutput::NumberingLevel() to handle this, building on top of
the existing DOCX work.
RTF still needs doing.
(cherry picked from commit a73b3994fb6a2cc10b2d65cbaad201762610cecc)
Change-Id: I57ec402c1dd829251afa639ddfa7fc6620da1125
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164214
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ww8export/data/listWithLgl.doc | bin | 0 -> 23552 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export4.cxx | 24 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8num.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par3.cxx | 11 |
4 files changed, 43 insertions, 1 deletions
diff --git a/sw/qa/extras/ww8export/data/listWithLgl.doc b/sw/qa/extras/ww8export/data/listWithLgl.doc Binary files differnew file mode 100644 index 000000000000..94de2967febc --- /dev/null +++ b/sw/qa/extras/ww8export/data/listWithLgl.doc diff --git a/sw/qa/extras/ww8export/ww8export4.cxx b/sw/qa/extras/ww8export/ww8export4.cxx index d47c934d9dd6..d31bf17a31f6 100644 --- a/sw/qa/extras/ww8export/ww8export4.cxx +++ b/sw/qa/extras/ww8export/ww8export4.cxx @@ -228,6 +228,30 @@ DECLARE_WW8EXPORT_TEST(testInlinePageBreakFirstLine, "inlinePageBreakFirstLine.d CPPUNIT_ASSERT(IsFirstLine(aTextNodes[2])); } +CPPUNIT_TEST_FIXTURE(Test, testLegalNumbering) +{ + auto verify = [this]() { + // Second level's numbering should use Arabic numbers for first level reference + auto xPara = getParagraph(1); + CPPUNIT_ASSERT_EQUAL(OUString("CH I"), getProperty<OUString>(xPara, "ListLabelString")); + xPara = getParagraph(2); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: Sect 1.01 + // - Actual : Sect I.01 + // i.e. fLegal was ignored on import/export. + CPPUNIT_ASSERT_EQUAL(OUString("Sect 1.01"), getProperty<OUString>(xPara, "ListLabelString")); + xPara = getParagraph(3); + CPPUNIT_ASSERT_EQUAL(OUString("CH II"), getProperty<OUString>(xPara, "ListLabelString")); + xPara = getParagraph(4); + CPPUNIT_ASSERT_EQUAL(OUString("Sect 2.01"), getProperty<OUString>(xPara, "ListLabelString")); + }; + + createSwDoc("listWithLgl.doc"); + verify(); + saveAndReload(mpFilter); + verify(); +} + DECLARE_WW8EXPORT_TEST(testNonInlinePageBreakFirstLine, "nonInlinePageBreakFirstLine.doc") { SwDoc* pDoc = getSwDoc(); diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx index 8d59434db652..681961a3770c 100644 --- a/sw/source/filter/ww8/wrtw8num.cxx +++ b/sw/source/filter/ww8/wrtw8num.cxx @@ -279,7 +279,7 @@ void WW8AttributeOutput::NumberingLevel( sal_uInt8 /*nLevel*/, sal_Int16 nListTabPos, const OUString &rNumberingString, const SvxBrushItem* pBrush, //For i120928,to transfer graphic of bullet - bool /*isLegal*/ + bool isLegal ) { // Start value @@ -303,6 +303,13 @@ void WW8AttributeOutput::NumberingLevel( sal_uInt8 /*nLevel*/, nAlign = 0; break; } + + if (isLegal) + { + // 3rd bit. + nAlign |= 0x04; + } + m_rWW8Export.m_pTableStrm->WriteUChar( nAlign ); // Write the rgbxchNums[9], positions of placeholders for paragraph diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index d0a294b14450..41b203f92496 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -368,6 +368,8 @@ struct WW8LVL // only THE entries, WE need! short nDxaLeft1; // first line indent sal_uInt8 nNFC; // number format code + /// Legal numbering: whether this level overrides the nfc of all inherited level numbers. + bool fLegal; // Offset of fieldcodes in Num-X-String sal_uInt8 aOfsNumsXCH[WW8ListManager::nMaxLevel]; sal_uInt8 nLenGrpprlChpx; // length, in bytes, of the LVL's grpprlChpx @@ -662,7 +664,15 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet m_rSt.ReadUChar( aLVL.nNFC ); m_rSt.ReadUChar( aBits1 ); if( ERRCODE_NONE != m_rSt.GetError() ) return false; + // 1st..2nd bits. aLVL.nAlign = (aBits1 & 0x03); + + if (aBits1 & 0x04) + { + // 3rd bit. + aLVL.fLegal = true; + } + if( aBits1 & 0x10 ) aLVL.bV6Prev = true; if( aBits1 & 0x20 ) aLVL.bV6PrSp = true; if( aBits1 & 0x40 ) aLVL.bV6 = true; @@ -898,6 +908,7 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet if( bSetStartNo && 0 <= aLVL.nStartAt) rNumFormat.SetStart(o3tl::narrowing<sal_uInt16>(aLVL.nStartAt)); rNumFormat.SetNumberingType( nType ); + rNumFormat.SetIsLegal(aLVL.fLegal); rNumFormat.SetNumAdjust( eAdj ); if( style::NumberingType::CHAR_SPECIAL == nType ) |