summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-01-02 23:16:29 +0100
committerMiklos Vajna <vmiklos@collabora.com>2019-01-03 09:12:24 +0100
commit6d38fc3dd500841caed9305285dab614163212ca (patch)
tree691dd6ad3c194d2b9761c0a95fab1bd8218fa3ac /sw
parent92edea090128839f54a7f628662529e66d657ab4 (diff)
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: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtfexport/data/tdf66543.rtf8
-rw-r--r--sw/qa/extras/rtfexport/rtfexport3.cxx9
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx8
-rw-r--r--sw/source/filter/ww8/rtfexport.cxx8
4 files changed, 31 insertions, 2 deletions
diff --git a/sw/qa/extras/rtfexport/data/tdf66543.rtf b/sw/qa/extras/rtfexport/data/tdf66543.rtf
new file mode 100644
index 000000000000..19d742bb1fc9
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf66543.rtf
@@ -0,0 +1,8 @@
+{\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
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx
index 3a5105f03357..6ada28d4476f 100644
--- a/sw/qa/extras/rtfexport/rtfexport3.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport3.cxx
@@ -199,6 +199,15 @@ DECLARE_RTFEXPORT_TEST(testTdf121623, "tdf121623.rtf")
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();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index dd5ccc9e9de2..f55f4a7db918 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -1200,7 +1200,7 @@ void RtfAttributeOutput::SectionFormProtection(bool bProtected)
m_aSectionBreaks.append(static_cast<sal_Int32>(!bProtected));
}
-void RtfAttributeOutput::SectionLineNumbering(sal_uLong /*nRestartNo*/,
+void RtfAttributeOutput::SectionLineNumbering(sal_uLong nRestartNo,
const SwLineNumberInfo& rLnNumInfo)
{
m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LINEMOD);
@@ -1209,6 +1209,12 @@ void RtfAttributeOutput::SectionLineNumbering(sal_uLong /*nRestartNo*/,
m_rExport.OutLong(rLnNumInfo.GetPosFromLeft());
if (!rLnNumInfo.IsRestartEachPage())
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()
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index 6d095309d73f..4e8b344c30df 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -852,7 +852,13 @@ ErrCode RtfExport::ExportDocument_Impl()
// line numbering
const SwLineNumberInfo& rLnNumInfo = m_pDoc->GetLineNumberInfo();
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