sw/qa/extras/rtfexport/data/listWithLgl.rtf | 23 +++++++++++++++++++++ sw/qa/extras/rtfexport/rtfexport3.cxx | 26 ++++++++++++++++++++++++ sw/source/filter/ww8/rtfattributeoutput.cxx | 7 +++++- writerfilter/source/rtftok/rtfcontrolwords.cxx | 2 - writerfilter/source/rtftok/rtfdispatchvalue.cxx | 3 ++ 5 files changed, 59 insertions(+), 2 deletions(-)
New commits: commit e8487bedb20a429565b4a0e4bd2d6806cc603b7f Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Feb 28 08:34:02 2024 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Feb 28 09:58:29 2024 +0100 Related: tdf#150408 RTF 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 RTF during import/export. Fix the problem by extending RTFDocumentImpl::dispatchTableSprmValue() for the numbering table import + RtfAttributeOutput::NumberingLevel() for the export. The import default for this value was also wrong, given that the default is to enable it when the control word is present. Change-Id: I4dcd23768000ba29d4df314b475b412bb371545e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164078 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/extras/rtfexport/data/listWithLgl.rtf b/sw/qa/extras/rtfexport/data/listWithLgl.rtf new file mode 100644 index 000000000000..4355049eb3dc --- /dev/null +++ b/sw/qa/extras/rtfexport/data/listWithLgl.rtf @@ -0,0 +1,23 @@ +{ tf1 +{\*\listtable +{\list\listtemplateid197063698 +{\listlevel\levelnfc1\levelnfcn1\leveljc0\leveljcn0\levelfollow2\levelstartat1\levelspace0\levelindent0 +{\leveltext\'04CH \'00;} +{\levelnumbers\'04;} + tlchcs1 f0 \ltrchcs0 \s15i0\li0\lin0 } +{\listlevel\levelnfc22\levelnfcn22\leveljc0\leveljcn0\levelfollow0\levelstartat1\levellegal\levelspace0\levelindent0 +{\leveltext\'08Sect \'00.\'01;} +{\levelnumbers +\'06\'08;} + tlchcs1 f0 \ltrchcs0 \s16i720\li0\jclisttab x2160\lin0 } +\listid1297755732} +} +{\*\listoverridetable +{\listoverride\listid1297755732\listoverridecount0\ls1} +} +\paperw12240\paperh15840\margl1440\margr1440\margt1440\margb1440 +\pard\plain\ls1\par +\pard\plaini720 x2160\ls1\ilvl1 Foo\par +\pard\plain\ls1\par +\pard\plaini720 x2160\ls1\ilvl1 Bar\par +} diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx index e88461102dfb..263af642b39f 100644 --- a/sw/qa/extras/rtfexport/rtfexport3.cxx +++ b/sw/qa/extras/rtfexport/rtfexport3.cxx @@ -718,6 +718,32 @@ DECLARE_RTFEXPORT_TEST(testTdf158409, "tdf158409.rtf") CPPUNIT_ASSERT_EQUAL(8.0, getProperty<double>(xRun, "CharHeight")); } +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. \levellegal 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.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 36bb03149c06..b996446b01eb 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -1632,7 +1632,7 @@ void RtfAttributeOutput::NumberingLevel(sal_uInt8 nLevel, sal_uInt16 nStart, const wwFont* pFont, const SfxItemSet* pOutSet, sal_Int16 nIndentAt, sal_Int16 nFirstLineIndex, sal_Int16 /*nListTabPos*/, const OUString& rNumberingString, - const SvxBrushItem* pBrush, bool /*isLegal*/) + const SvxBrushItem* pBrush, bool isLegal) { m_rExport.Strm().WriteOString(SAL_NEWLINE_STRING); if (nLevel > 8) // RTF knows only 9 levels @@ -1771,6 +1771,11 @@ void RtfAttributeOutput::NumberingLevel(sal_uInt8 nLevel, sal_uInt16 nStart, m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LEVELSTARTAT); m_rExport.Strm().WriteNumberAsString(nStart); + if (isLegal) + { + m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LEVELLEGAL); + } + m_rExport.Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_LEVELFOLLOW); m_rExport.Strm().WriteNumberAsString(nFollow); diff --git a/writerfilter/source/rtftok/rtfcontrolwords.cxx b/writerfilter/source/rtftok/rtfcontrolwords.cxx index 3f5a0827bae4..8b035b37bbe2 100644 --- a/writerfilter/source/rtftok/rtfcontrolwords.cxx +++ b/writerfilter/source/rtftok/rtfcontrolwords.cxx @@ -715,7 +715,7 @@ RTFSymbol const aRTFControlWords[] = { { "levelindent", RTFControlType::VALUE, RTFKeyword::LEVELINDENT, 0 }, { "leveljc", RTFControlType::VALUE, RTFKeyword::LEVELJC, 0 }, { "leveljcn", RTFControlType::VALUE, RTFKeyword::LEVELJCN, 0 }, - { "levellegal", RTFControlType::VALUE, RTFKeyword::LEVELLEGAL, 0 }, + { "levellegal", RTFControlType::VALUE, RTFKeyword::LEVELLEGAL, 1 }, { "levelnfc", RTFControlType::VALUE, RTFKeyword::LEVELNFC, 0 }, { "levelnfcn", RTFControlType::VALUE, RTFKeyword::LEVELNFCN, 0 }, { "levelnorestart", RTFControlType::VALUE, RTFKeyword::LEVELNORESTART, 0 }, diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx index f699b0ed39d1..1e7552dd71b1 100644 --- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx +++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx @@ -135,6 +135,9 @@ bool RTFDocumentImpl::dispatchTableSprmValue(RTFKeyword nKeyword, int nParam) nSprm = NS_ooxml::LN_CT_Style_next; pIntValue = new RTFValue(getStyleName(nParam)); break; + case RTFKeyword::LEVELLEGAL: + nSprm = NS_ooxml::LN_CT_Lvl_isLgl; + break; default: break; }