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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Mar 6 17:21:25 UTC 2020


 include/svtools/rtfkeywd.hxx                |   12 ++++
 sw/qa/extras/rtfexport/rtfexport5.cxx       |   32 ++++++++++++
 sw/source/filter/ww8/rtfattributeoutput.cxx |   71 ++++++++++++++++++++++++++++
 sw/source/filter/ww8/rtfattributeoutput.hxx |    4 +
 sw/source/filter/ww8/rtfexport.cxx          |    5 +
 5 files changed, 122 insertions(+), 2 deletions(-)

New commits:
commit 4ba09be7e260ce2a79a23465db7b2837422cde30
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Mar 6 16:16:56 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Mar 6 18:20:45 2020 +0100

    sw chicago numbering: add RTF footnote export
    
    Chicago numbering is not supported for paragraph numbering (same as
    DOC), so focus on footnote/endnote export only.
    
    There is markup in RTF to store doc-global footnote/endnote numbering
    type and the same for per-section. DOC writes both, then Writer only
    reads the global setting and Word only reads the per-section setting.
    
    This means only export is needed here, import already handled the
    doc-global markup, and that's enough.
    
    Change-Id: I3590560ca913e04078988fe4784e50fa5cbf17bf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90112
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/include/svtools/rtfkeywd.hxx b/include/svtools/rtfkeywd.hxx
index 8a4a3f6b4c7b..fa297843e6be 100644
--- a/include/svtools/rtfkeywd.hxx
+++ b/include/svtools/rtfkeywd.hxx
@@ -411,6 +411,12 @@
 #define OOO_STRING_SVTOOLS_RTF_AFTNNCHI "\\aftnnchi"
 #define OOO_STRING_SVTOOLS_RTF_AFTNNRLC "\\aftnnrlc"
 #define OOO_STRING_SVTOOLS_RTF_AFTNNRUC "\\aftnnruc"
+#define OOO_STRING_SVTOOLS_RTF_SAFTNNALC "\\saftnnalc"
+#define OOO_STRING_SVTOOLS_RTF_SAFTNNAR "\\saftnnar"
+#define OOO_STRING_SVTOOLS_RTF_SAFTNNAUC "\\saftnnauc"
+#define OOO_STRING_SVTOOLS_RTF_SAFTNNCHI "\\saftnnchi"
+#define OOO_STRING_SVTOOLS_RTF_SAFTNNRLC "\\saftnnrlc"
+#define OOO_STRING_SVTOOLS_RTF_SAFTNNRUC "\\saftnnruc"
 #define OOO_STRING_SVTOOLS_RTF_AFTNRESTART "\\aftnrestart"
 #define OOO_STRING_SVTOOLS_RTF_AFTNRSTCONT "\\aftnrstcont"
 #define OOO_STRING_SVTOOLS_RTF_AFTNSEP "\\aftnsep"
@@ -552,6 +558,12 @@
 #define OOO_STRING_SVTOOLS_RTF_FTNNCHI "\\ftnnchi"
 #define OOO_STRING_SVTOOLS_RTF_FTNNRLC "\\ftnnrlc"
 #define OOO_STRING_SVTOOLS_RTF_FTNNRUC "\\ftnnruc"
+#define OOO_STRING_SVTOOLS_RTF_SFTNNALC "\\sftnnalc"
+#define OOO_STRING_SVTOOLS_RTF_SFTNNAR "\\sftnnar"
+#define OOO_STRING_SVTOOLS_RTF_SFTNNAUC "\\sftnnauc"
+#define OOO_STRING_SVTOOLS_RTF_SFTNNCHI "\\sftnnchi"
+#define OOO_STRING_SVTOOLS_RTF_SFTNNRLC "\\sftnnrlc"
+#define OOO_STRING_SVTOOLS_RTF_SFTNNRUC "\\sftnnruc"
 #define OOO_STRING_SVTOOLS_RTF_FTNRSTCONT "\\ftnrstcont"
 #define OOO_STRING_SVTOOLS_RTF_FTNRSTPG "\\ftnrstpg"
 #define OOO_STRING_SVTOOLS_RTF_FTTRUETYPE "\\fttruetype"
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx
index bae656e26a70..05825abdc621 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -29,6 +29,7 @@
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
 #include <com/sun/star/text/WritingMode2.hpp>
 #include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/text/XTextContentAppend.hpp>
 
 #include <rtl/ustring.hxx>
 #include <vcl/svapp.hxx>
@@ -1072,6 +1073,37 @@ DECLARE_RTFEXPORT_TEST(testTdf104744, "tdf104744.rtf")
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270), aRule["IndentAt"].get<sal_Int32>());
 }
 
+CPPUNIT_TEST_FIXTURE(SwModelTestBase, testChicagoNumberingFootnote)
+{
+    // Create a document, set footnote numbering type to SYMBOL_CHICAGO.
+    loadURL("private:factory/swriter", nullptr);
+    uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xFootnoteSettings
+        = xFootnotesSupplier->getFootnoteSettings();
+    sal_uInt16 nNumberingType = style::NumberingType::SYMBOL_CHICAGO;
+    xFootnoteSettings->setPropertyValue("NumberingType", uno::makeAny(nNumberingType));
+
+    // Insert a footnote.
+    uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
+    uno::Reference<text::XTextContent> xFootnote(
+        xFactory->createInstance("com.sun.star.text.Footnote"), uno::UNO_QUERY);
+    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+    uno::Reference<text::XTextContentAppend> xTextContentAppend(xTextDocument->getText(),
+                                                                uno::UNO_QUERY);
+    xTextContentAppend->appendTextContent(xFootnote, {});
+
+    reload("Rich Text Format", "");
+    xFootnotesSupplier.set(mxComponent, uno::UNO_QUERY);
+    sal_uInt16 nExpected = style::NumberingType::SYMBOL_CHICAGO;
+    auto nActual
+        = getProperty<sal_uInt16>(xFootnotesSupplier->getFootnoteSettings(), "NumberingType");
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 63
+    // - Actual  : 4
+    // i.e. the numbering type was ARABIC, not SYMBOL_CHICAGO.
+    CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
+}
+
 DECLARE_RTFEXPORT_TEST(testTdf105852, "tdf105852.rtf")
 {
     uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index fd1bb3656e3a..bfbb71a23f84 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -1359,6 +1359,77 @@ void RtfAttributeOutput::SectionType(sal_uInt8 nBreakCode)
         m_rExport.Strm().WriteOString(m_aSectionBreaks.makeStringAndClear());
 }
 
+void RtfAttributeOutput::SectFootnoteEndnotePr()
+{
+    WriteFootnoteEndnotePr(true, m_rExport.m_pDoc->GetFootnoteInfo());
+    WriteFootnoteEndnotePr(false, m_rExport.m_pDoc->GetEndNoteInfo());
+}
+
+void RtfAttributeOutput::WriteFootnoteEndnotePr(bool bFootnote, const SwEndNoteInfo& rInfo)
+{
+    const char* pOut = nullptr;
+
+    if (bFootnote)
+    {
+        switch (rInfo.m_aFormat.GetNumberingType())
+        {
+            default:
+                pOut = OOO_STRING_SVTOOLS_RTF_SFTNNAR;
+                break;
+            case SVX_NUM_CHARS_LOWER_LETTER:
+            case SVX_NUM_CHARS_LOWER_LETTER_N:
+                pOut = OOO_STRING_SVTOOLS_RTF_SFTNNALC;
+                break;
+            case SVX_NUM_CHARS_UPPER_LETTER:
+            case SVX_NUM_CHARS_UPPER_LETTER_N:
+                pOut = OOO_STRING_SVTOOLS_RTF_SFTNNAUC;
+                break;
+            case SVX_NUM_ROMAN_LOWER:
+                pOut = OOO_STRING_SVTOOLS_RTF_SFTNNRLC;
+                break;
+            case SVX_NUM_ROMAN_UPPER:
+                pOut = OOO_STRING_SVTOOLS_RTF_SFTNNRUC;
+                break;
+            case SVX_NUM_SYMBOL_CHICAGO:
+                pOut = OOO_STRING_SVTOOLS_RTF_SFTNNCHI;
+                break;
+        }
+    }
+    else
+    {
+        switch (rInfo.m_aFormat.GetNumberingType())
+        {
+            default:
+                pOut = OOO_STRING_SVTOOLS_RTF_SAFTNNAR;
+                break;
+            case SVX_NUM_CHARS_LOWER_LETTER:
+            case SVX_NUM_CHARS_LOWER_LETTER_N:
+                pOut = OOO_STRING_SVTOOLS_RTF_SAFTNNALC;
+                break;
+            case SVX_NUM_CHARS_UPPER_LETTER:
+            case SVX_NUM_CHARS_UPPER_LETTER_N:
+                pOut = OOO_STRING_SVTOOLS_RTF_SAFTNNAUC;
+                break;
+            case SVX_NUM_ROMAN_LOWER:
+                pOut = OOO_STRING_SVTOOLS_RTF_SAFTNNRLC;
+                break;
+            case SVX_NUM_ROMAN_UPPER:
+                pOut = OOO_STRING_SVTOOLS_RTF_SAFTNNRUC;
+                break;
+            case SVX_NUM_SYMBOL_CHICAGO:
+                pOut = OOO_STRING_SVTOOLS_RTF_SAFTNNCHI;
+                break;
+        }
+    }
+
+    m_aSectionBreaks.append(pOut);
+
+    if (!m_bBufferSectionBreaks)
+    {
+        m_rExport.Strm().WriteOString(m_aSectionBreaks.makeStringAndClear());
+    }
+}
+
 void RtfAttributeOutput::NumberingDefinition(sal_uInt16 nId, const SwNumRule& /*rRule*/)
 {
     m_rExport.Strm().WriteChar('{').WriteCharPtr(OOO_STRING_SVTOOLS_RTF_LISTOVERRIDE);
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index 2bf4cd6450f6..2493ce38fbb0 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -198,6 +198,10 @@ public:
     /// The type of breaking.
     void SectionType(sal_uInt8 nBreakCode) override;
 
+    void SectFootnoteEndnotePr() override;
+
+    void WriteFootnoteEndnotePr(bool bFootnote, const SwEndNoteInfo& rInfo);
+
     /// Definition of a numbering instance.
     void NumberingDefinition(sal_uInt16 nId, const SwNumRule& rRule) override;
 
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index c7831f992bf3..ba48c017ef93 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -824,6 +824,7 @@ ErrCode RtfExport::ExportDocument_Impl()
         Strm()
             .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SECTD)
             .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SBKNONE);
+        m_pAttrOutput->SectFootnoteEndnotePr();
         // All sections are unlocked by default
         Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SECTUNLOCKED);
         OutLong(1);
@@ -885,7 +886,7 @@ ErrCode RtfExport::ExportDocument_Impl()
             case SVX_NUM_ROMAN_UPPER:
                 pOut = OOO_STRING_SVTOOLS_RTF_FTNNRUC;
                 break;
-            case SVX_NUM_CHAR_SPECIAL:
+            case SVX_NUM_SYMBOL_CHICAGO:
                 pOut = OOO_STRING_SVTOOLS_RTF_FTNNCHI;
                 break;
             default:
@@ -918,7 +919,7 @@ ErrCode RtfExport::ExportDocument_Impl()
             case SVX_NUM_ROMAN_UPPER:
                 pOut = OOO_STRING_SVTOOLS_RTF_AFTNNRUC;
                 break;
-            case SVX_NUM_CHAR_SPECIAL:
+            case SVX_NUM_SYMBOL_CHICAGO:
                 pOut = OOO_STRING_SVTOOLS_RTF_AFTNNCHI;
                 break;
             default:


More information about the Libreoffice-commits mailing list