[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 6 commits - i18npool/qa i18npool/source include/editeng include/svtools offapi/com sw/qa sw/source writerfilter/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue May 19 09:31:30 UTC 2020


 i18npool/qa/cppunit/test_defaultnumberingprovider.cxx                 |   58 ++++++++
 i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx |   17 +-
 include/editeng/svxenum.hxx                                           |    4 
 include/svtools/rtfkeywd.hxx                                          |   12 +
 offapi/com/sun/star/style/NumberingType.idl                           |   14 +
 sw/qa/extras/odfexport/data/arabic-zero3-numbering.odt                |binary
 sw/qa/extras/odfexport/odfexport.cxx                                  |   13 +
 sw/qa/extras/ooxmlexport/data/arabic-zero3-numbering.docx             |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx                            |   13 +
 sw/qa/extras/rtfexport/rtfexport5.cxx                                 |   32 ++++
 sw/source/filter/ww8/docxattributeoutput.cxx                          |   30 +++-
 sw/source/filter/ww8/docxexport.cxx                                   |    5 
 sw/source/filter/ww8/rtfattributeoutput.cxx                           |   71 ++++++++++
 sw/source/filter/ww8/rtfattributeoutput.hxx                           |    4 
 sw/source/filter/ww8/rtfexport.cxx                                    |    5 
 writerfilter/source/dmapper/ConversionHelper.cxx                      |   12 +
 writerfilter/source/dmapper/ConversionHelper.hxx                      |    1 
 writerfilter/source/dmapper/DomainMapper.cxx                          |   43 +++++-
 writerfilter/source/dmapper/NumberingManager.cxx                      |   46 +++++-
 writerfilter/source/dmapper/NumberingManager.hxx                      |    3 
 writerfilter/source/ooxml/model.xml                                   |   10 +
 writerfilter/source/rtftok/rtfdispatchflag.cxx                        |   23 ++-
 writerfilter/source/rtftok/rtfdispatchvalue.cxx                       |   11 -
 23 files changed, 393 insertions(+), 34 deletions(-)

New commits:
commit e654b1e27eb1690104d360dfc1a7d7ef84dd220f
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Mar 20 13:38:45 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue May 19 11:30:10 2020 +0200

    sw pad-to-4 numbering: add doc model, UNO API and layout
    
    This is the actual numbering the customer needed, pad-to-2 and pad-to-3
    was added just for compleness (since Word has it and it's related).
    
    (cherry picked from commit fcef4857e042ff3c9dd8a6c60cf1a58e07f3224c)
    
    Change-Id: I7fdf67488955ab3ee0db169f11fffd21d9cc1e3b

diff --git a/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
index 4418a283de2b..e5991ee6461d 100644
--- a/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
+++ b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
@@ -81,6 +81,35 @@ CPPUNIT_TEST_FIXTURE(I18npoolDefaultnumberingproviderTest, testArabicZero3)
     CPPUNIT_ASSERT_EQUAL(OUString("100"), aActual);
 }
 
+CPPUNIT_TEST_FIXTURE(I18npoolDefaultnumberingproviderTest, testArabicZero4)
+{
+    uno::Reference<uno::XComponentContext> xComponentContext
+        = comphelper::getComponentContext(getMultiServiceFactory());
+
+    // 100 -> "0100"
+    uno::Reference<text::XNumberingFormatter> xFormatter(
+        text::DefaultNumberingProvider::create(xComponentContext), uno::UNO_QUERY);
+    uno::Sequence<beans::PropertyValue> aProperties = {
+        comphelper::makePropertyValue("NumberingType",
+                                      static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO4)),
+        comphelper::makePropertyValue("Value", static_cast<sal_Int32>(100)),
+    };
+    lang::Locale aLocale;
+    OUString aActual = xFormatter->makeNumberingString(aProperties, aLocale);
+    // Without the accompanying fix in place, this test would have failed with a
+    // lang.IllegalArgumentException, support for ARABIC_ZERO4 was missing.
+    CPPUNIT_ASSERT_EQUAL(OUString("0100"), aActual);
+
+    // 1000 -> "1000"
+    aProperties = {
+        comphelper::makePropertyValue("NumberingType",
+                                      static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO4)),
+        comphelper::makePropertyValue("Value", static_cast<sal_Int32>(1000)),
+    };
+    aActual = xFormatter->makeNumberingString(aProperties, aLocale);
+    CPPUNIT_ASSERT_EQUAL(OUString("1000"), aActual);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index 39b7954cee7a..5f79508a6766 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -945,6 +945,10 @@ DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyVal
                result += lcl_formatArabicZero(number, 3);
                break;
 
+          case ARABIC_ZERO4:
+               result += lcl_formatArabicZero(number, 4);
+               break;
+
           default:
                OSL_ASSERT(false);
                throw IllegalArgumentException();
diff --git a/include/editeng/svxenum.hxx b/include/editeng/svxenum.hxx
index eced6c884afa..b020ebd26e50 100644
--- a/include/editeng/svxenum.hxx
+++ b/include/editeng/svxenum.hxx
@@ -208,6 +208,7 @@ enum SvxNumType : sal_Int16
     SVX_NUM_SYMBOL_CHICAGO        = css::style::NumberingType::SYMBOL_CHICAGO,
     SVX_NUM_ARABIC_ZERO           = css::style::NumberingType::ARABIC_ZERO,
     SVX_NUM_ARABIC_ZERO3          = css::style::NumberingType::ARABIC_ZERO3,
+    SVX_NUM_ARABIC_ZERO4          = css::style::NumberingType::ARABIC_ZERO4,
 };
 
 #endif
diff --git a/offapi/com/sun/star/style/NumberingType.idl b/offapi/com/sun/star/style/NumberingType.idl
index 2ecf03734e10..e19bd25aecd3 100644
--- a/offapi/com/sun/star/style/NumberingType.idl
+++ b/offapi/com/sun/star/style/NumberingType.idl
@@ -506,6 +506,13 @@ published constants NumberingType
         @since LibreOffice 7.0
      */
     const short ARABIC_ZERO3 = 65;
+
+    /** Numbering is in Arabic numbers, padded with zero to have a length of at least four, as
+        "0001, 0002, ..., 1000, 1001, ...".
+
+        @since LibreOffice 7.0
+     */
+    const short ARABIC_ZERO4 = 66;
 };
 
 
commit c62f573b3ecb89cc842ea88b61e99863a33d4212
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Mar 19 17:54:26 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue May 19 11:30:10 2020 +0200

    sw pad-to-3 numbering: add DOCX filter
    
    There is no NS_ooxml::LN_Value_ST_NumberFormat_foo code for this on the
    import side, rather the number format code is set to
    NS_ooxml::LN_Value_ST_NumberFormat_custom, then a separate
    NS_ooxml::LN_CT_NumFmt_format contains the number format string.
    
    Declare w14 as an XML namespace on the export side, even if we write no
    <w14:something> elements. This is needed by <mc:Choice Requires="w14">,
    which refers to an XML namespace in the OOXML markup. (Interestingly
    officeotron doesn't check for this, though.)
    
    (cherry picked from commit 52ed1091be05d5a07a021403095c52f0f3986ed6)
    
    Change-Id: If5fbcea4f163bd4d1a1ed820e15ceb61dc9c0519

diff --git a/sw/qa/extras/ooxmlexport/data/arabic-zero3-numbering.docx b/sw/qa/extras/ooxmlexport/data/arabic-zero3-numbering.docx
new file mode 100644
index 000000000000..bd95186a6091
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/arabic-zero3-numbering.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 71e17ec25964..379ae540bb46 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -121,6 +121,19 @@ DECLARE_ODFEXPORT_TEST(testArabicZeroNumbering, "arabic-zero-numbering.docx")
                          aMap["NumberingType"].get<sal_uInt16>());
 }
 
+DECLARE_ODFEXPORT_TEST(testArabicZero3Numbering, "arabic-zero3-numbering.docx")
+{
+    auto xNumberingRules
+        = getProperty<uno::Reference<container::XIndexAccess>>(getParagraph(1), "NumberingRules");
+    comphelper::SequenceAsHashMap aMap(xNumberingRules->getByIndex(0));
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 65
+    // - Actual  : 4
+    // i.e. numbering type was ARABIC, not ARABIC_ZERO3.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO3),
+                         aMap["NumberingType"].get<sal_uInt16>());
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testArabicZeroNumberingFootnote)
 {
     // Create a document, set footnote numbering type to ARABIC_ZERO.
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index c4f01bbcb804..fafd5c5d189b 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6321,7 +6321,7 @@ static OString impl_NumberingType( sal_uInt16 nNumberingType )
 }
 
 // Converting Level Numbering Format Code to string
-static OString impl_LevelNFC( sal_uInt16 nNumberingType , const SfxItemSet *pOutSet)
+static OString impl_LevelNFC(sal_uInt16 nNumberingType, const SfxItemSet* pOutSet, OString& rFormat)
 {
     OString aType;
 
@@ -6374,6 +6374,10 @@ static OString impl_LevelNFC( sal_uInt16 nNumberingType , const SfxItemSet *pOut
         case style::NumberingType::TEXT_ORDINAL: aType="ordinalText"; break;
         case style::NumberingType::SYMBOL_CHICAGO: aType="chicago"; break;
         case style::NumberingType::ARABIC_ZERO: aType = "decimalZero"; break;
+        case style::NumberingType::ARABIC_ZERO3:
+            aType = "custom";
+            rFormat = "001, 002, 003, ...";
+            break;
 /*
         Fallback the rest to decimal.
         case style::NumberingType::NATIVE_NUMBERING:
@@ -6787,10 +6791,30 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
                 FSNS( XML_w, XML_val ), m_rExport.m_pStyles->GetStyleId(nId) );
     }
     // format
-    OString aFormat( impl_LevelNFC( nNumberingType ,pOutSet) );
+    OString aCustomFormat;
+    OString aFormat(impl_LevelNFC(nNumberingType, pOutSet, aCustomFormat));
 
     if ( !aFormat.isEmpty() )
-        m_pSerializer->singleElementNS(XML_w, XML_numFmt, FSNS(XML_w, XML_val), aFormat);
+    {
+        if (aCustomFormat.isEmpty())
+        {
+            m_pSerializer->singleElementNS(XML_w, XML_numFmt, FSNS(XML_w, XML_val), aFormat);
+        }
+        else
+        {
+            m_pSerializer->startElementNS(XML_mc, XML_AlternateContent);
+            m_pSerializer->startElementNS(XML_mc, XML_Choice, XML_Requires, "w14");
+
+            m_pSerializer->singleElementNS(XML_w, XML_numFmt, FSNS(XML_w, XML_val), aFormat,
+                                           FSNS(XML_w, XML_format), aCustomFormat);
+
+            m_pSerializer->endElementNS(XML_mc, XML_Choice);
+            m_pSerializer->startElementNS(XML_mc, XML_Fallback);
+            m_pSerializer->singleElementNS(XML_w, XML_numFmt, FSNS(XML_w, XML_val), "decimal");
+            m_pSerializer->endElementNS(XML_mc, XML_Fallback);
+            m_pSerializer->endElementNS(XML_mc, XML_AlternateContent);
+        }
+    }
 
     // suffix
     const char *pSuffix = nullptr;
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index b0f1ccf51627..a46b3eb779a2 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -762,7 +762,10 @@ void DocxExport::WriteNumbering()
             FSNS( XML_xmlns, XML_w ), m_pFilter->getNamespaceURL(OOX_NS(doc)).toUtf8(),
             FSNS( XML_xmlns, XML_o ), m_pFilter->getNamespaceURL(OOX_NS(vmlOffice)).toUtf8(),
             FSNS( XML_xmlns, XML_r ), m_pFilter->getNamespaceURL(OOX_NS(officeRel)).toUtf8(),
-            FSNS( XML_xmlns, XML_v ), m_pFilter->getNamespaceURL(OOX_NS(vml)).toUtf8() );
+            FSNS( XML_xmlns, XML_v ), m_pFilter->getNamespaceURL(OOX_NS(vml)).toUtf8(),
+            FSNS( XML_xmlns, XML_mc ), m_pFilter->getNamespaceURL(OOX_NS(mce)).toUtf8(),
+            FSNS( XML_xmlns, XML_w14 ), m_pFilter->getNamespaceURL(OOX_NS(w14)).toUtf8(),
+            FSNS( XML_mc, XML_Ignorable ), "w14" );
 
     BulletDefinitions();
 
diff --git a/writerfilter/source/dmapper/ConversionHelper.cxx b/writerfilter/source/dmapper/ConversionHelper.cxx
index 81d0dce54fa9..d8ca06e5ed34 100644
--- a/writerfilter/source/dmapper/ConversionHelper.cxx
+++ b/writerfilter/source/dmapper/ConversionHelper.cxx
@@ -614,6 +614,18 @@ sal_Int16 ConvertNumberingType(sal_Int32 nFmt)
     return nRet;
 }
 
+sal_Int16 ConvertCustomNumberFormat(const OUString& rFormat)
+{
+    sal_Int16 nRet = -1;
+
+    if (rFormat == "001, 002, 003, ...")
+    {
+        nRet = style::NumberingType::ARABIC_ZERO3;
+    }
+
+    return nRet;
+}
+
 util::DateTime ConvertDateStringToDateTime( const OUString& rDateTime )
 {
     util::DateTime aDateTime;
diff --git a/writerfilter/source/dmapper/ConversionHelper.hxx b/writerfilter/source/dmapper/ConversionHelper.hxx
index 25ca7f8b8ce9..fd7a85870d2b 100644
--- a/writerfilter/source/dmapper/ConversionHelper.hxx
+++ b/writerfilter/source/dmapper/ConversionHelper.hxx
@@ -51,6 +51,7 @@ namespace ConversionHelper{
     sal_Int16 convertTableJustification( sal_Int32 nIntValue );
     css::text::RubyAdjust convertRubyAlign( sal_Int32 nIntValue );
     sal_Int16 ConvertNumberingType(sal_Int32 nFmt);
+    sal_Int16 ConvertCustomNumberFormat(const OUString& rFormat);
 
     css::util::DateTime ConvertDateStringToDateTime(const OUString& rDateTime);
 } // namespace ConversionHelper
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index e3feb55ee2ef..5a74e421a31b 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -130,6 +130,8 @@ void ListLevel::SetValue( Id nId, sal_Int32 nValue )
     m_bHasValues = true;
 }
 
+void ListLevel::SetCustomNumberFormat(const OUString& rValue) { m_aCustomNumberFormat = rValue; }
+
 bool ListLevel::HasValues() const
 {
     return m_bHasValues;
@@ -190,7 +192,15 @@ uno::Sequence<beans::PropertyValue> ListLevel::GetLevelProperties(bool bDefaults
     if( m_nIStartAt >= 0)
         aNumberingProperties.push_back(lcl_makePropVal<sal_Int16>(PROP_START_WITH, m_nIStartAt) );
 
-    sal_Int16 nNumberFormat = ConversionHelper::ConvertNumberingType(m_nNFC);
+    sal_Int16 nNumberFormat = -1;
+    if (m_nNFC == NS_ooxml::LN_Value_ST_NumberFormat_custom)
+    {
+        nNumberFormat = ConversionHelper::ConvertCustomNumberFormat(m_aCustomNumberFormat);
+    }
+    else
+    {
+        nNumberFormat = ConversionHelper::ConvertNumberingType(m_nNFC);
+    }
     if( m_nNFC >= 0)
     {
         if (m_xGraphicBitmap.is())
@@ -692,8 +702,17 @@ void ListsManager::lcl_attribute( Id nName, Value& rVal )
         case NS_ooxml::LN_CT_Lvl_isLgl:
         case NS_ooxml::LN_CT_Lvl_legacy:
             if ( pCurrentLvl.get( ) )
-                pCurrentLvl->SetValue( nName, sal_Int32( nIntValue ) );
-        break;
+            {
+                if (nName == NS_ooxml::LN_CT_NumFmt_format)
+                {
+                    pCurrentLvl->SetCustomNumberFormat(rVal.getString());
+                }
+                else
+                {
+                    pCurrentLvl->SetValue(nName, sal_Int32(nIntValue));
+                }
+            }
+            break;
         case NS_ooxml::LN_CT_Num_numId:
             m_pCurrentDefinition->SetId( rVal.getString().toInt32( ) );
         break;
diff --git a/writerfilter/source/dmapper/NumberingManager.hxx b/writerfilter/source/dmapper/NumberingManager.hxx
index 3949c3bf7dcd..88ce887869a1 100644
--- a/writerfilter/source/dmapper/NumberingManager.hxx
+++ b/writerfilter/source/dmapper/NumberingManager.hxx
@@ -45,6 +45,8 @@ class ListLevel : public PropertyMap
     sal_Int32                                     m_nIStartAt;       //LN_CT_Lvl_start
     sal_Int32                                     m_nStartOverride;
     sal_Int32                                     m_nNFC;            //LN_CT_Lvl_numFmt
+    /// LN_CT_NumFmt_format, in case m_nNFC is custom.
+    OUString m_aCustomNumberFormat;
     sal_Int16                                     m_nXChFollow;      //LN_IXCHFOLLOW
     OUString                               m_sBulletChar;
     css::awt::Size                         m_aGraphicSize;
@@ -69,6 +71,7 @@ public:
 
     // Setters for the import
     void SetValue( Id nId, sal_Int32 nValue );
+    void SetCustomNumberFormat(const OUString& rValue);
     void SetBulletChar( const OUString& sValue ) { m_sBulletChar = sValue; };
     void SetGraphicSize( const css::awt::Size& aValue ) { m_aGraphicSize = aValue; };
 
commit 0acdc84c5053dc32c0f65ec416f3f21502537496
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Mar 16 17:25:31 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue May 19 11:30:09 2020 +0200

    DOCX import: tokenize <w:numFmt w:val="custom" w:format="...">
    
    Which means CT_NumFmt has to be a property resource, not a single value,
    and also ST_NumberFormat needs to recognize "custom" as a valid value.
    
    Adapt the RTF tokenizer to emit the new token format.
    
    This is needed (but not enough) to support markup like this:
    
    <w:numFmt w:val="custom" w:format="001, 002, 003, ..."/>
    
    (cherry picked from commit 496197fe4dff2cd94ceeb42fc04d0263ac8d8971)
    
    Conflicts:
            writerfilter/source/dmapper/NumberingManager.cxx
            writerfilter/source/rtftok/rtfdispatchvalue.cxx
    
    Change-Id: I767e4b92fc41f9425f446d6eaad1d875e2233964

diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 72ec656a7574..a749169dc009 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1180,6 +1180,37 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
             m_pImpl->startOrEndPermissionRange(nIntValue);
             break;
         }
+        case NS_ooxml::LN_CT_NumFmt_val:
+        {
+            try
+            {
+                uno::Reference<beans::XPropertySet> xFtnEdnSettings;
+                if (m_pImpl->IsInFootnoteProperties())
+                {
+                    uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(
+                        m_pImpl->GetTextDocument(), uno::UNO_QUERY);
+                    if (xFootnotesSupplier.is())
+                        xFtnEdnSettings = xFootnotesSupplier->getFootnoteSettings();
+                }
+                else
+                {
+                    uno::Reference<text::XEndnotesSupplier> xEndnotesSupplier(
+                        m_pImpl->GetTextDocument(), uno::UNO_QUERY);
+                    if (xEndnotesSupplier.is())
+                        xFtnEdnSettings = xEndnotesSupplier->getEndnoteSettings();
+                }
+                if (xFtnEdnSettings.is())
+                {
+                    sal_Int16 nNumType = ConversionHelper::ConvertNumberingType(nIntValue);
+                    xFtnEdnSettings->setPropertyValue(getPropertyName(PROP_NUMBERING_TYPE),
+                                                      uno::makeAny(nNumType));
+                }
+            }
+            catch (const uno::Exception&)
+            {
+            }
+        }
+        break;
         default:
             SAL_WARN("writerfilter", "DomainMapper::lcl_attribute: unhandled token: " << nName);
     }
@@ -2290,10 +2321,18 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext )
     //endnotes in word can be at section end or document end - writer supports only the latter
     // -> so this property can be ignored
     break;
-    case NS_ooxml::LN_EG_FtnEdnNumProps_numStart:
-    case NS_ooxml::LN_EG_FtnEdnNumProps_numRestart:
     case NS_ooxml::LN_CT_FtnProps_numFmt:
     case NS_ooxml::LN_CT_EdnProps_numFmt:
+    {
+        writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
+        if (pProperties.get())
+        {
+            pProperties->resolve(*this);
+        }
+    }
+    break;
+    case NS_ooxml::LN_EG_FtnEdnNumProps_numStart:
+    case NS_ooxml::LN_EG_FtnEdnNumProps_numRestart:
     {
         try
         {
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 764fe2a387a7..e3feb55ee2ef 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -105,7 +105,7 @@ void ListLevel::SetValue( Id nId, sal_Int32 nValue )
         case NS_ooxml::LN_CT_NumLvl_startOverride:
             m_nStartOverride = nValue;
             break;
-        case NS_ooxml::LN_CT_Lvl_numFmt:
+        case NS_ooxml::LN_CT_NumFmt_val:
             m_nNFC = nValue;
         break;
         case NS_ooxml::LN_CT_Lvl_isLgl:
@@ -687,6 +687,8 @@ void ListsManager::lcl_attribute( Id nName, Value& rVal )
         break;
         case NS_ooxml::LN_CT_Lvl_start:
         case NS_ooxml::LN_CT_Lvl_numFmt:
+        case NS_ooxml::LN_CT_NumFmt_format:
+        case NS_ooxml::LN_CT_NumFmt_val:
         case NS_ooxml::LN_CT_Lvl_isLgl:
         case NS_ooxml::LN_CT_Lvl_legacy:
             if ( pCurrentLvl.get( ) )
@@ -909,18 +911,29 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
                 bIsStartVisited = true;
             break;
             case NS_ooxml::LN_CT_Lvl_numFmt:
-            case NS_ooxml::LN_CT_Lvl_isLgl:
-            case NS_ooxml::LN_CT_Lvl_legacy:
+            {
+                writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
+                if (pProperties.get())
+                {
+                    pProperties->resolve(*this);
+                }
                 if (ListLevel::Pointer pCurrentLevel = m_pCurrentDefinition->GetCurrentLevel())
                 {
-                    pCurrentLevel->SetValue( nSprmId, nIntValue );
                     if( !bIsStartVisited )
                     {
                         pCurrentLevel->SetValue( NS_ooxml::LN_CT_Lvl_start, 0 );
                         bIsStartVisited = true;
                     }
                 }
+            }
             break;
+            case NS_ooxml::LN_CT_Lvl_isLgl:
+            case NS_ooxml::LN_CT_Lvl_legacy:
+                if (ListLevel::Pointer pCurrentLevel = m_pCurrentDefinition->GetCurrentLevel())
+                {
+                    pCurrentLevel->SetValue(nSprmId, nIntValue);
+                }
+                break;
             case NS_ooxml::LN_CT_Lvl_suff:
             {
                 if (ListLevel::Pointer pCurrentLevel = m_pCurrentDefinition->GetCurrentLevel())
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 17c8f5217fec..eb84d6e6a4e8 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -12880,6 +12880,7 @@
           <value>thaiNumbers</value>
           <!-- Thai Counting System -->
           <value>thaiCounting</value>
+          <value>custom</value>
         </choice>
       </define>
       <define name="ST_PageOrientation">
@@ -14795,6 +14796,9 @@
         </attribute>
       </define>
       <define name="CT_NumFmt">
+        <attribute name="format">
+          <data type="string"/>
+        </attribute>
         <attribute name="val">
           <ref name="ST_NumberFormat"/>
         </attribute>
@@ -17750,6 +17754,7 @@
       <value tokenid="ooxml:Value_ST_NumberFormat_thaiLetters">thaiLetters</value>
       <value tokenid="ooxml:Value_ST_NumberFormat_thaiNumbers">thaiNumbers</value>
       <value tokenid="ooxml:Value_ST_NumberFormat_thaiCounting">thaiCounting</value>
+      <value tokenid="ooxml:Value_ST_NumberFormat_custom">custom</value>
     </resource>
     <resource name="ST_PageOrientation" resource="List">
       <value tokenid="ooxml:Value_ST_PageOrientation_portrait">portrait</value>
@@ -18522,8 +18527,9 @@
     <resource name="CT_EdnPos" resource="Value">
       <attribute name="val" tokenid="ooxml:CT_EdnPos_val" action="setValue"/>
     </resource>
-    <resource name="CT_NumFmt" resource="Value">
-      <attribute name="val" tokenid="ooxml:CT_NumFmt_val" action="setValue"/>
+    <resource name="CT_NumFmt" resource="Properties">
+      <attribute name="format" tokenid="ooxml:CT_NumFmt_format"/>
+      <attribute name="val" tokenid="ooxml:CT_NumFmt_val"/>
     </resource>
     <resource name="ST_RestartNumber" resource="List">
       <value tokenid="ooxml:Value_ST_RestartNumber_continuous">continuous</value>
diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx
index 894716b2897c..35fe4b381283 100644
--- a/writerfilter/source/rtftok/rtfdispatchflag.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx
@@ -294,10 +294,13 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
     }
     if (nParam >= 0)
     {
-        auto pValue = new RTFValue(nParam);
+        auto pInner = new RTFValue(nParam);
+        RTFSprms aAttributes;
+        aAttributes.set(NS_ooxml::LN_CT_NumFmt_val, pInner);
+        auto pOuter = new RTFValue(aAttributes);
         putNestedSprm(m_aDefaultState.getParagraphSprms(),
                       NS_ooxml::LN_EG_SectPrContents_footnotePr, NS_ooxml::LN_CT_FtnProps_numFmt,
-                      pValue);
+                      pOuter);
         return RTFError::OK;
     }
 
@@ -351,9 +354,12 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
     }
     if (nParam >= 0)
     {
-        auto pValue = new RTFValue(nParam);
+        auto pInner = new RTFValue(nParam);
+        RTFSprms aAttributes;
+        aAttributes.set(NS_ooxml::LN_CT_NumFmt_val, pInner);
+        auto pOuter = new RTFValue(aAttributes);
         putNestedSprm(m_aDefaultState.getParagraphSprms(), NS_ooxml::LN_EG_SectPrContents_endnotePr,
-                      NS_ooxml::LN_CT_EdnProps_numFmt, pValue);
+                      NS_ooxml::LN_CT_EdnProps_numFmt, pOuter);
         return RTFError::OK;
     }
 
@@ -1087,16 +1093,17 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
         case RTF_PNDEC:
         {
             auto pValue = new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_decimal);
-            m_aStates.top().getTableSprms().set(NS_ooxml::LN_CT_Lvl_numFmt, pValue);
+            putNestedAttribute(m_aStates.top().getTableSprms(), NS_ooxml::LN_CT_Lvl_numFmt,
+                               NS_ooxml::LN_CT_NumFmt_val, pValue);
         }
         break;
         case RTF_PNLVLBLT:
         {
             m_aStates.top().getTableAttributes().set(NS_ooxml::LN_CT_AbstractNum_nsid,
                                                      new RTFValue(1));
-            m_aStates.top().getTableSprms().set(
-                NS_ooxml::LN_CT_Lvl_numFmt,
-                new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_bullet));
+            putNestedAttribute(m_aStates.top().getTableSprms(), NS_ooxml::LN_CT_Lvl_numFmt,
+                               NS_ooxml::LN_CT_NumFmt_val,
+                               new RTFValue(NS_ooxml::LN_Value_ST_NumberFormat_bullet));
         }
         break;
         case RTF_LANDSCAPE:
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index 4f7c71ecf73e..7f458bf5ca94 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -137,10 +137,6 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
             pIntValue = new RTFValue(nValue);
             break;
         }
-        case RTF_LEVELNFC:
-            nSprm = NS_ooxml::LN_CT_Lvl_numFmt;
-            pIntValue = new RTFValue(getNumberFormat(nParam));
-            break;
         case RTF_LEVELSTARTAT:
             nSprm = NS_ooxml::LN_CT_Lvl_start;
             break;
@@ -159,6 +155,13 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
         m_aStates.top().getTableSprms().set(nSprm, pIntValue);
         return RTFError::OK;
     }
+    if (nKeyword == RTF_LEVELNFC)
+    {
+        pIntValue = new RTFValue(getNumberFormat(nParam));
+        putNestedAttribute(m_aStates.top().getTableSprms(), NS_ooxml::LN_CT_Lvl_numFmt,
+                           NS_ooxml::LN_CT_NumFmt_val, pIntValue);
+        return RTFError::OK;
+    }
     // Trivial character sprms.
     switch (nKeyword)
     {
commit 34c10f30268b515e7bf7fcecb4241c36a6512e15
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Mar 18 10:18:42 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue May 19 11:30:09 2020 +0200

    sw pad-to-3 numbering: add ODF filter
    
    This makes the UI work as well.
    
    (cherry picked from commit 086bfde59232076644995ae862cd43865419ad98)
    
    Change-Id: I8d64b88e57ba3e4fd61afba892f0ee2267f1c8b2

diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index 8dfc18291491..39b7954cee7a 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -1044,6 +1044,7 @@ static const Supported_NumberingType aSupportedTypes[] =
         {style::NumberingType::CHARS_GREEK_UPPER_LETTER,   C_GR_A ", " C_GR_B ", ... (gr)", LANG_ALL},
         {style::NumberingType::CHARS_GREEK_LOWER_LETTER,   S_GR_A ", " S_GR_B ", ... (gr)", LANG_ALL},
         {style::NumberingType::ARABIC_ZERO, "01, 02, 03, ...", LANG_ALL},
+        {style::NumberingType::ARABIC_ZERO3, "001, 002, 003, ...", LANG_ALL},
 };
 static const sal_Int32 nSupported_NumberingTypes = SAL_N_ELEMENTS(aSupportedTypes);
 
diff --git a/sw/qa/extras/odfexport/data/arabic-zero3-numbering.odt b/sw/qa/extras/odfexport/data/arabic-zero3-numbering.odt
new file mode 100644
index 000000000000..0bdca270eece
Binary files /dev/null and b/sw/qa/extras/odfexport/data/arabic-zero3-numbering.odt differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 0d5c28f07ebd..550d7079a089 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -2348,5 +2348,18 @@ DECLARE_ODFEXPORT_TEST(testArabicZeroNumbering, "arabic-zero-numbering.odt")
                          aMap["NumberingType"].get<sal_uInt16>());
 }
 
+DECLARE_ODFEXPORT_TEST(testArabicZero3Numbering, "arabic-zero3-numbering.odt")
+{
+    auto xNumberingRules
+        = getProperty<uno::Reference<container::XIndexAccess>>(getParagraph(1), "NumberingRules");
+    comphelper::SequenceAsHashMap aMap(xNumberingRules->getByIndex(0));
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 65
+    // - Actual  : 4
+    // i.e. numbering type was ARABIC, not ARABIC_ZERO3.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO3),
+                         aMap["NumberingType"].get<sal_uInt16>());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 007709e54e13863e78502c5ce35590e889fada91
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Mar 17 17:01:05 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue May 19 11:30:09 2020 +0200

    sw pad-to-3 numbering: add doc model, UNO API and layout
    
    This is similar to the existing padded numbering, but that one padded to
    2.  Another difference is pad-to-2 has more file format support:
    pad-to-3 is not supported in DOC and RTF.
    
    (cherry picked from commit f4dd9ecdc21696b360dedf7fefa371c8858c1830)
    
    Change-Id: Ie2ac2691c58a89e181d24d7002cf873ebab380c4

diff --git a/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
index 2a1cb55502e2..4418a283de2b 100644
--- a/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
+++ b/i18npool/qa/cppunit/test_defaultnumberingprovider.cxx
@@ -52,6 +52,35 @@ CPPUNIT_TEST_FIXTURE(I18npoolDefaultnumberingproviderTest, testArabicZero)
     CPPUNIT_ASSERT_EQUAL(OUString("10"), aActual);
 }
 
+CPPUNIT_TEST_FIXTURE(I18npoolDefaultnumberingproviderTest, testArabicZero3)
+{
+    uno::Reference<uno::XComponentContext> xComponentContext
+        = comphelper::getComponentContext(getMultiServiceFactory());
+
+    // 10 -> "010"
+    uno::Reference<text::XNumberingFormatter> xFormatter(
+        text::DefaultNumberingProvider::create(xComponentContext), uno::UNO_QUERY);
+    uno::Sequence<beans::PropertyValue> aProperties = {
+        comphelper::makePropertyValue("NumberingType",
+                                      static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO3)),
+        comphelper::makePropertyValue("Value", static_cast<sal_Int32>(10)),
+    };
+    lang::Locale aLocale;
+    OUString aActual = xFormatter->makeNumberingString(aProperties, aLocale);
+    // Without the accompanying fix in place, this test would have failed with a
+    // lang.IllegalArgumentException, support for ARABIC_ZERO3 was missing.
+    CPPUNIT_ASSERT_EQUAL(OUString("010"), aActual);
+
+    // 100 -> "100"
+    aProperties = {
+        comphelper::makePropertyValue("NumberingType",
+                                      static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO3)),
+        comphelper::makePropertyValue("Value", static_cast<sal_Int32>(100)),
+    };
+    aActual = xFormatter->makeNumberingString(aProperties, aLocale);
+    CPPUNIT_ASSERT_EQUAL(OUString("100"), aActual);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index 797d7360a283..8dfc18291491 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -553,11 +553,11 @@ bool should_ignore( const OUString& s )
 }
 
 /**
- * Turn nNumber into a string and pad the result to 2 using zero characters.
+ * Turn nNumber into a string and pad the result to nLimit by inserting zero characters at the
+ * start.
  */
-static OUString lcl_formatArabicZero(sal_Int32 nNumber)
+static OUString lcl_formatArabicZero(sal_Int32 nNumber, sal_Int32 nLimit)
 {
-    sal_Int32 nLimit = 2;
     OUString aRet = OUString::number(nNumber);
     sal_Int32 nDiff = nLimit - aRet.getLength();
 
@@ -938,7 +938,11 @@ DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyVal
              break;
 
           case ARABIC_ZERO:
-               result += lcl_formatArabicZero(number);
+               result += lcl_formatArabicZero(number, 2);
+               break;
+
+          case ARABIC_ZERO3:
+               result += lcl_formatArabicZero(number, 3);
                break;
 
           default:
diff --git a/include/editeng/svxenum.hxx b/include/editeng/svxenum.hxx
index f425e97cde0c..eced6c884afa 100644
--- a/include/editeng/svxenum.hxx
+++ b/include/editeng/svxenum.hxx
@@ -206,7 +206,8 @@ enum SvxNumType : sal_Int16
     SVX_NUM_TEXT_CARDINAL         = css::style::NumberingType::TEXT_CARDINAL,
     SVX_NUM_TEXT_ORDINAL          = css::style::NumberingType::TEXT_ORDINAL,
     SVX_NUM_SYMBOL_CHICAGO        = css::style::NumberingType::SYMBOL_CHICAGO,
-    SVX_NUM_ARABIC_ZERO           = css::style::NumberingType::ARABIC_ZERO
+    SVX_NUM_ARABIC_ZERO           = css::style::NumberingType::ARABIC_ZERO,
+    SVX_NUM_ARABIC_ZERO3          = css::style::NumberingType::ARABIC_ZERO3,
 };
 
 #endif
diff --git a/offapi/com/sun/star/style/NumberingType.idl b/offapi/com/sun/star/style/NumberingType.idl
index 66159a818e66..2ecf03734e10 100644
--- a/offapi/com/sun/star/style/NumberingType.idl
+++ b/offapi/com/sun/star/style/NumberingType.idl
@@ -499,6 +499,13 @@ published constants NumberingType
         @since LibreOffice 7.0
      */
     const short ARABIC_ZERO = 64;
+
+    /** Numbering is in Arabic numbers, padded with zero to have a length of at least three, as
+        "001, 002, ..., 100, 101, ...".
+
+        @since LibreOffice 7.0
+     */
+    const short ARABIC_ZERO3 = 65;
 };
 
 
commit 47bb90ad09553d8d36bdc22616c00f82a6f6d87c
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Mar 6 16:16:56 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue May 19 11:30:09 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)
    
    Change-Id: I3590560ca913e04078988fe4784e50fa5cbf17bf

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 75678fb6971b..fb9555c5a1ee 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>
@@ -1069,6 +1070,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 edd666e28cf9..9f174bd6d14d 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.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 4ea8b3845bcd..791fdf8d2678 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 366cc18b3b0c..81550b420f0f 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -827,6 +827,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);
@@ -888,7 +889,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:
@@ -921,7 +922,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