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

Justin Luth (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 1 15:59:18 UTC 2021


 sw/qa/extras/ooxmlexport/data/tdf141231_arabicHebrewNumbering.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx                         |    7 ++
 writerfilter/source/dmapper/ConversionHelper.cxx                   |    5 +
 writerfilter/source/dmapper/ConversionHelper.hxx                   |    3 -
 writerfilter/source/dmapper/DomainMapper.cxx                       |   26 +---------
 5 files changed, 15 insertions(+), 26 deletions(-)

New commits:
commit 4f7bc49bce261f1cf206d25f0299fd080a9f5d28
Author:     Justin Luth <justin_luth at sil.org>
AuthorDate: Tue Mar 30 09:51:05 2021 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Apr 1 17:58:33 2021 +0200

    tdf#141341 writerfilter: use all NumberingTypes for pgNumFmt
    
    We have a nice conversion function to translate from OOXML
    to writer's numbering formats, so lets use that
    for the page/section's numbering format too.
    
    Change-Id: Ibf2aaae5d66c971b54440862b1156c00202663e2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113350
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf141231_arabicHebrewNumbering.docx b/sw/qa/extras/ooxmlexport/data/tdf141231_arabicHebrewNumbering.docx
new file mode 100755
index 000000000000..01bc2667a195
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf141231_arabicHebrewNumbering.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index afd0b94e5d0b..17928387f16c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -73,6 +73,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf138892_noNumbering, "tdf138892_noNumbering.docx"
     CPPUNIT_ASSERT_MESSAGE("Para3: <blank line>", getProperty<OUString>(getParagraph(3), "NumberingStyleName").isEmpty());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf141231_arabicHebrewNumbering, "tdf141231_arabicHebrewNumbering.docx")
+{
+    // The page's numbering type: instead of Hebrew, this was default style::NumberingType::ARABIC (4).
+    auto nActual = getProperty<sal_Int16>(getStyles("PageStyles")->getByName("Standard"), "NumberingType");
+    CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_HEBREW, nActual);
+}
+
 DECLARE_OOXMLEXPORT_TEST(testGutterLeft, "gutter-left.docx")
 {
     uno::Reference<beans::XPropertySet> xPageStyle;
diff --git a/writerfilter/source/dmapper/ConversionHelper.cxx b/writerfilter/source/dmapper/ConversionHelper.cxx
index 809e85c90372..852f58152b75 100644
--- a/writerfilter/source/dmapper/ConversionHelper.cxx
+++ b/writerfilter/source/dmapper/ConversionHelper.cxx
@@ -475,7 +475,8 @@ sal_Int16 convertTableJustification( sal_Int32 nIntValue )
     return nOrient;
 }
 
-sal_Int16 ConvertNumberingType(sal_Int32 nFmt)
+// Return the suggested default if the given format has no known conversion
+sal_Int16 ConvertNumberingType(const sal_Int32 nFmt, const sal_Int16 nDefault)
 {
     sal_Int16 nRet;
     switch(nFmt)
@@ -594,7 +595,7 @@ sal_Int16 ConvertNumberingType(sal_Int32 nFmt)
         case NS_ooxml::LN_Value_ST_NumberFormat_decimalZero:
             nRet = style::NumberingType::ARABIC_ZERO;
             break;
-        default: nRet = style::NumberingType::ARABIC;
+        default: nRet = nDefault;
     }
 /*  TODO: Lots of additional values are available - some are supported in the I18 framework
     NS_ooxml::LN_Value_ST_NumberFormat_hex = 91685;
diff --git a/writerfilter/source/dmapper/ConversionHelper.hxx b/writerfilter/source/dmapper/ConversionHelper.hxx
index ad0cd615fbec..72c0efe0d540 100644
--- a/writerfilter/source/dmapper/ConversionHelper.hxx
+++ b/writerfilter/source/dmapper/ConversionHelper.hxx
@@ -21,6 +21,7 @@
 #include <sal/types.h>
 #include <rtl/ustring.hxx>
 #include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/style/NumberingType.hpp>
 #include <com/sun/star/table/BorderLine2.hpp>
 #include <com/sun/star/text/RubyAdjust.hpp>
 
@@ -49,7 +50,7 @@ namespace writerfilter::dmapper::ConversionHelper{
     SAL_DLLPUBLIC_EXPORT sal_uInt32 convertTwipToMM100Unsigned(sal_Int32 _t);
     sal_Int16 convertTableJustification( sal_Int32 nIntValue );
     css::text::RubyAdjust convertRubyAlign( sal_Int32 nIntValue );
-    sal_Int16 ConvertNumberingType(sal_Int32 nFmt);
+    sal_Int16 ConvertNumberingType(const sal_Int32 nFmt, const sal_Int16 nDefault = css::style::NumberingType::ARABIC);
     sal_Int16 ConvertCustomNumberFormat(std::u16string_view rFormat);
 
     css::util::DateTime ConvertDateStringToDateTime(const OUString& rDateTime);
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index a70c5e81d5af..2561120adb2d 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1074,29 +1074,9 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
         case NS_ooxml::LN_CT_PageNumber_fmt:
             if (pSectionContext)
             {
-                switch (nIntValue)
-                {
-                case NS_ooxml::LN_Value_ST_NumberFormat_decimal:
-                    // 1, 2, ...
-                    pSectionContext->SetPageNumberType(style::NumberingType::ARABIC);
-                break;
-                case NS_ooxml::LN_Value_ST_NumberFormat_upperLetter:
-                    // A, B, ...
-                    pSectionContext->SetPageNumberType(style::NumberingType::CHARS_UPPER_LETTER_N);
-                break;
-                case NS_ooxml::LN_Value_ST_NumberFormat_lowerLetter:
-                    // a, b, ...
-                    pSectionContext->SetPageNumberType(style::NumberingType::CHARS_LOWER_LETTER_N);
-                break;
-                case NS_ooxml::LN_Value_ST_NumberFormat_upperRoman:
-                    // I, II, ...
-                    pSectionContext->SetPageNumberType(style::NumberingType::ROMAN_UPPER);
-                break;
-                case NS_ooxml::LN_Value_ST_NumberFormat_lowerRoman:
-                    // i, ii, ...
-                    pSectionContext->SetPageNumberType(style::NumberingType::ROMAN_LOWER);
-                break;
-                }
+                sal_Int16 nNumberType = ConversionHelper::ConvertNumberingType(nIntValue, -1);
+                if (nNumberType != -1)
+                    pSectionContext->SetPageNumberType(nNumberType);
             }
         break;
         case NS_ooxml::LN_CT_FtnEdn_type:


More information about the Libreoffice-commits mailing list