Kaydet (Commit) 6d38fc3d authored tarafından Miklos Vajna's avatar Miklos Vajna

Related: tdf#121664 RTF filter: fix line numbering start value handling

Writer and RTF is 1-based, OOXML is 0-based. So it means we do an offset
roundtrip during import, and no offsets are needed on export.

Change-Id: I52cf65f268940d1d43ae76e58d0c7e6de3a54073
Reviewed-on: https://gerrit.libreoffice.org/65827
Tested-by: Jenkins
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
üst 92edea09
{\rtf1
\sectd \linemod3\linex0\linestarts2
\pard\plain
This is the first line. \par
This is the second line.\par
This is the third line.\par
This is the fourth line.\par
}
...@@ -199,6 +199,15 @@ DECLARE_RTFEXPORT_TEST(testTdf121623, "tdf121623.rtf") ...@@ -199,6 +199,15 @@ DECLARE_RTFEXPORT_TEST(testTdf121623, "tdf121623.rtf")
CPPUNIT_ASSERT_EQUAL(1, getPages()); CPPUNIT_ASSERT_EQUAL(1, getPages());
} }
DECLARE_RTFEXPORT_TEST(testTdf66543, "tdf66543.rtf")
{
// Without the accompanying fix in place, this test would have failed with
// 'Expected: 2; Actual : 3' after import (off-by-one), then with
// 'Expected: 2; Actual : 0' (export not implemented).
CPPUNIT_ASSERT_EQUAL(sal_Int32(2),
getProperty<sal_Int32>(getParagraph(1), "ParaLineNumberStartValue"));
}
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -1200,7 +1200,7 @@ void RtfAttributeOutput::SectionFormProtection(bool bProtected) ...@@ -1200,7 +1200,7 @@ void RtfAttributeOutput::SectionFormProtection(bool bProtected)
m_aSectionBreaks.append(static_cast<sal_Int32>(!bProtected)); m_aSectionBreaks.append(static_cast<sal_Int32>(!bProtected));
} }
void RtfAttributeOutput::SectionLineNumbering(sal_uLong /*nRestartNo*/, void RtfAttributeOutput::SectionLineNumbering(sal_uLong nRestartNo,
const SwLineNumberInfo& rLnNumInfo) const SwLineNumberInfo& rLnNumInfo)
{ {
m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LINEMOD); m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LINEMOD);
...@@ -1209,6 +1209,12 @@ void RtfAttributeOutput::SectionLineNumbering(sal_uLong /*nRestartNo*/, ...@@ -1209,6 +1209,12 @@ void RtfAttributeOutput::SectionLineNumbering(sal_uLong /*nRestartNo*/,
m_rExport.OutLong(rLnNumInfo.GetPosFromLeft()); m_rExport.OutLong(rLnNumInfo.GetPosFromLeft());
if (!rLnNumInfo.IsRestartEachPage()) if (!rLnNumInfo.IsRestartEachPage())
m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LINECONT); m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LINECONT);
if (nRestartNo > 0)
{
m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LINESTARTS);
m_rExport.OutLong(nRestartNo);
}
} }
void RtfAttributeOutput::SectionTitlePage() void RtfAttributeOutput::SectionTitlePage()
......
...@@ -852,7 +852,13 @@ ErrCode RtfExport::ExportDocument_Impl() ...@@ -852,7 +852,13 @@ ErrCode RtfExport::ExportDocument_Impl()
// line numbering // line numbering
const SwLineNumberInfo& rLnNumInfo = m_pDoc->GetLineNumberInfo(); const SwLineNumberInfo& rLnNumInfo = m_pDoc->GetLineNumberInfo();
if (rLnNumInfo.IsPaintLineNumbers()) if (rLnNumInfo.IsPaintLineNumbers())
AttrOutput().SectionLineNumbering(0, rLnNumInfo); {
sal_uLong nLnNumRestartNo = 0;
if (const WW8_SepInfo* pSectionInfo = m_pSections->CurrentSectionInfo())
nLnNumRestartNo = pSectionInfo->nLnNumRestartNo;
AttrOutput().SectionLineNumbering(nLnNumRestartNo, rLnNumInfo);
}
{ {
// write the footnotes and endnotes-out Info // write the footnotes and endnotes-out Info
......
...@@ -1033,10 +1033,14 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) ...@@ -1033,10 +1033,14 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
NS_ooxml::LN_CT_LineNumber_distance, pIntValue); NS_ooxml::LN_CT_LineNumber_distance, pIntValue);
break; break;
case RTF_LINESTARTS: case RTF_LINESTARTS:
{
// OOXML <w:lnNumType w:start="..."/> is 0-based, RTF is 1-based.
auto pStart = tools::make_ref<RTFValue>(nParam - 1);
putNestedAttribute(m_aStates.top().aSectionSprms, putNestedAttribute(m_aStates.top().aSectionSprms,
NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_EG_SectPrContents_lnNumType,
NS_ooxml::LN_CT_LineNumber_start, pIntValue); NS_ooxml::LN_CT_LineNumber_start, pStart);
break; }
break;
case RTF_REVAUTH: case RTF_REVAUTH:
case RTF_REVAUTHDEL: case RTF_REVAUTHDEL:
{ {
......
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