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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Sat Feb 6 14:17:24 UTC 2021


 include/svtools/rtfkeywd.hxx                   |    1 +
 sw/qa/extras/rtfexport/data/gutter-top.rtf     |    4 ++++
 sw/qa/extras/rtfexport/rtfexport4.cxx          |   14 ++++++++++++++
 sw/source/filter/ww8/rtfexport.cxx             |    7 +++++++
 writerfilter/source/rtftok/rtfdispatchflag.cxx |    3 +++
 5 files changed, 29 insertions(+)

New commits:
commit faf0635def4ef603563f7288cb29d24e3f2ce1e3
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Feb 5 17:27:26 2021 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Sat Feb 6 15:16:38 2021 +0100

    tdf#91920 sw page gutter margin, from top: add RTF export
    
    The documentation for \gutterprl is "Parallel gutter.", but it seems
    that's what Word use to convert between RTF and DOCX's <w:gutterAtTop/>.
    
    Change-Id: I06d80f234c6f52950db8a047bfc88910b808977d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110484
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/include/svtools/rtfkeywd.hxx b/include/svtools/rtfkeywd.hxx
index 1f96630cb4f8..b02395e45a5d 100644
--- a/include/svtools/rtfkeywd.hxx
+++ b/include/svtools/rtfkeywd.hxx
@@ -1223,5 +1223,6 @@
 #define LO_STRING_SVTOOLS_RTF_SBAUTO "\\sbauto"
 #define LO_STRING_SVTOOLS_RTF_SAAUTO "\\saauto"
 #define LO_STRING_SVTOOLS_RTF_HTMAUTSP "\\htmautsp"
+#define LO_STRING_SVTOOLS_RTF_GUTTERPRL "\\gutterprl"
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/rtfexport/data/gutter-top.rtf b/sw/qa/extras/rtfexport/data/gutter-top.rtf
new file mode 100644
index 000000000000..9c9a78ce2d03
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/gutter-top.rtf
@@ -0,0 +1,4 @@
+{\rtf1
+\paperw12240\paperh15840\margl1440\margr1440\margt1440\margb1440\gutter720\gutterprl
+\pard\plain Half inch gutter on the top\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx b/sw/qa/extras/rtfexport/rtfexport4.cxx
index 2bfdf0a13c87..669deb82f144 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -400,6 +400,20 @@ CPPUNIT_TEST_FIXTURE(Test, testGutterLeft)
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270), nGutterMargin);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testGutterTop)
+{
+    load(mpTestDocumentPath, "gutter-top.rtf");
+    reload(mpFilter, "gutter-left.rtf");
+    uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xSettings(
+        xFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY);
+    bool bGutterAtTop{};
+    xSettings->getPropertyValue("GutterAtTop") >>= bGutterAtTop;
+    // Without the accompanying fix in place, this test would have failed, becase the gutter was
+    // at the left.
+    CPPUNIT_ASSERT(bGutterAtTop);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index 7f4ceb97dd5f..616f28ab0aa7 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -726,6 +726,13 @@ ErrCode RtfExport::ExportDocument_Impl()
     // Mirror margins?
     if ((UseOnPage::Mirror & m_rDoc.GetPageDesc(0).ReadUseOn()) == UseOnPage::Mirror)
         Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_MARGMIRROR);
+
+    // Gutter at top?
+    if (m_rDoc.getIDocumentSettingAccess().get(DocumentSettingId::GUTTER_AT_TOP))
+    {
+        Strm().WriteCharPtr(LO_STRING_SVTOOLS_RTF_GUTTERPRL);
+    }
+
     // Init sections
     m_pSections = new MSWordSections(*this);
 
diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx
index 8797a08442d8..30f97530a56c 100644
--- a/writerfilter/source/rtftok/rtfdispatchflag.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx
@@ -1224,6 +1224,9 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
             m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_longerSpaceSequence,
                                       new RTFValue(0));
             break;
+        case RTF_GUTTERPRL:
+            m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_gutterAtTop, new RTFValue(1));
+            break;
         default:
         {
             SAL_INFO("writerfilter", "TODO handle flag '" << keywordToString(nKeyword) << "'");


More information about the Libreoffice-commits mailing list