[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 2 commits - include/svtools sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 3 07:20:41 UTC 2020


 include/svtools/rtfkeywd.hxx                |   12 ++++
 sw/qa/extras/rtfexport/rtfexport3.cxx       |   32 ++++++++++++
 sw/qa/extras/ww8export/ww8export3.cxx       |   30 +++++++++++
 sw/source/filter/ww8/rtfattributeoutput.cxx |   71 ++++++++++++++++++++++++++++
 sw/source/filter/ww8/rtfattributeoutput.hxx |    4 +
 sw/source/filter/ww8/rtfexport.cxx          |    5 +
 sw/source/filter/ww8/wrtw8num.cxx           |    1 
 sw/source/filter/ww8/ww8atr.cxx             |    4 +
 sw/source/filter/ww8/ww8par3.cxx            |    4 +
 9 files changed, 161 insertions(+), 2 deletions(-)

New commits:
commit 140f286303118d0436efd51806e63415454424cc
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 Apr 3 09:20:22 2020 +0200

    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.
    
    (cherry picked from commit 4ba09be7e260ce2a79a23465db7b2837422cde30)
    
    Conflicts:
            sw/qa/extras/rtfexport/rtfexport5.cxx
    
    Change-Id: I3590560ca913e04078988fe4784e50fa5cbf17bf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91590
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/include/svtools/rtfkeywd.hxx b/include/svtools/rtfkeywd.hxx
index ec6053f14434..991bcca060e7 100644
--- a/include/svtools/rtfkeywd.hxx
+++ b/include/svtools/rtfkeywd.hxx
@@ -410,6 +410,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"
@@ -551,6 +557,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/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx
index 40f7c9e25c81..4d2c808e3756 100644
--- a/sw/qa/extras/rtfexport/rtfexport3.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport3.cxx
@@ -18,6 +18,7 @@
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
 #include <com/sun/star/text/XTextColumns.hpp>
 #include <com/sun/star/text/TextContentAnchorType.hpp>
+#include <com/sun/star/text/XTextContentAppend.hpp>
 
 class Test : public SwModelTestBase
 {
@@ -290,6 +291,37 @@ DECLARE_RTFEXPORT_TEST(testBtlrFrame, "btlr-frame.odt")
     CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, nActual);
 }
 
+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);
+}
+
 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 13c1a8c72478..cb74fd9c6c13 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -1326,6 +1326,77 @@ void RtfAttributeOutput::SectionType(sal_uInt8 nBreakCode)
         m_rExport.Strm().WriteCharPtr(m_aSectionBreaks.makeStringAndClear().getStr());
 }
 
+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.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.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 aab5b08b53e9..52b98d940cc6 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -195,6 +195,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 d4a3b0b1ced5..6c30f6c7df03 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -838,6 +838,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);
@@ -893,7 +894,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:
@@ -926,7 +927,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:
commit 2fc6d0bcc5d7b34a91ae7b2006d9a1571523b723
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Mar 6 10:44:19 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Apr 3 09:20:07 2020 +0200

    sw chicago numbering: add DOC footnote export
    
    Note that chicago numbering can't be used for paragraph numbering. It
    would be possible technically, but the spec && bffvalidator && Word
    agrees on forbidding that.
    
    (cherry picked from commit 9a1dd2e242794b4f26d207efc80a2f5bc088ab7c)
    
    Change-Id: Ic3de51f9724d399542f4fe6ac48e70e94c6ea4ba
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91589
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index 8d1378dab410..37df1b5352ae 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -92,6 +92,36 @@ CPPUNIT_TEST_FIXTURE(SwModelTestBase, testArabicZeroNumberingFootnote)
     CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
 }
 
+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("MS Word 97", "");
+    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_WW8EXPORT_TEST(testTdf122429_header, "tdf122429_header.doc")
 {
     uno::Reference<container::XNameAccess> pageStyles = getStyles("PageStyles");
diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx
index e149bb266534..6c8e88285cdd 100644
--- a/sw/source/filter/ww8/wrtw8num.cxx
+++ b/sw/source/filter/ww8/wrtw8num.cxx
@@ -232,6 +232,7 @@ static sal_uInt8 GetLevelNFC(  sal_uInt16 eNumType, const SfxItemSet *pOutSet)
     case style::NumberingType::NUMBER_HANGUL_KO: nRet = 41; break;
     case style::NumberingType::NUMBER_UPPER_KO: nRet = 44; break;
     case SVX_NUM_NUMBER_NONE:           nRet = 0xff;    break;
+    // No SVX_NUM_SYMBOL_CHICAGO here: LVLF can't contain 0x09, msonfcChiManSty.
     case SVX_NUM_ARABIC_ZERO:
         // 0x16, msonfcArabicLZ
         nRet = 22;
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 0d1b6e4c1189..cf15052ac156 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -704,6 +704,10 @@ sal_uInt8 WW8Export::GetNumId( sal_uInt16 eNumType )
 
     // nothing, WW does the same (undocumented)
     case SVX_NUM_NUMBER_NONE:           nRet = 0xff;    break;
+    case SVX_NUM_SYMBOL_CHICAGO:
+        // 0x09, msonfcChiManSty
+        nRet = 9;
+        break;
     case SVX_NUM_ARABIC_ZERO:
         // 0x16, msonfcArabicLZ
         nRet = 22;
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 848b8334d6b2..ecb14691640f 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -540,6 +540,10 @@ SvxNumType WW8ListManager::GetSvxNumTypeFromMSONFC(sal_uInt16 nNFC)
             // actually: ORDINAL
             nType = SVX_NUM_ARABIC;
             break;
+        case 9:
+            // 0x09, msonfcChiManSty
+            nType = SVX_NUM_SYMBOL_CHICAGO;
+            break;
         case 22:
             // 0x16, msonfcArabicLZ
             nType = SVX_NUM_ARABIC_ZERO;


More information about the Libreoffice-commits mailing list