[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jan 3 08:12:48 UTC 2019


 sw/qa/extras/rtfexport/data/tdf66543.rtf        |    8 ++++++++
 sw/qa/extras/rtfexport/rtfexport3.cxx           |    9 +++++++++
 sw/source/filter/ww8/rtfattributeoutput.cxx     |    8 +++++++-
 sw/source/filter/ww8/rtfexport.cxx              |    8 +++++++-
 writerfilter/source/rtftok/rtfdispatchvalue.cxx |    8 ++++++--
 5 files changed, 37 insertions(+), 4 deletions(-)

New commits:
commit 6d38fc3dd500841caed9305285dab614163212ca
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Jan 2 23:16:29 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Jan 3 09:12:24 2019 +0100

    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 at collabora.com>

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
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index a72fd00db2c3..2e7e198f3540 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -1033,10 +1033,14 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
                                    NS_ooxml::LN_CT_LineNumber_distance, pIntValue);
             break;
         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,
                                NS_ooxml::LN_EG_SectPrContents_lnNumType,
-                               NS_ooxml::LN_CT_LineNumber_start, pIntValue);
-            break;
+                               NS_ooxml::LN_CT_LineNumber_start, pStart);
+        }
+        break;
         case RTF_REVAUTH:
         case RTF_REVAUTHDEL:
         {


More information about the Libreoffice-commits mailing list