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

Justin Luth (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 23 16:49:51 UTC 2021


 sw/source/filter/ww8/wrtw8num.cxx                |   47 +++------------
 sw/source/filter/ww8/ww8atr.cxx                  |   29 +++++++++
 sw/source/filter/ww8/ww8par3.cxx                 |   71 ++++++++++++++++++++---
 writerfilter/source/dmapper/ConversionHelper.cxx |    4 -
 4 files changed, 103 insertions(+), 48 deletions(-)

New commits:
commit 1d50b8a7e93178e1ceec0bf95ed6794f73e2f184
Author:     Justin Luth <justin_luth at sil.org>
AuthorDate: Wed Jun 23 13:47:20 2021 +0200
Commit:     Justin Luth <justin_luth at sil.org>
CommitDate: Wed Jun 23 18:49:08 2021 +0200

    tdf#120629 doc {im,ex}port: accept known numberingTypes
    
    I cross-checked with what was imported via DOCX
    and took inspiration from tdf#141341 to consolidate
    these two nearly-identical functions that otherwise
    would need to be kept in sync (and never are)..
    
    Change-Id: I7e021d7c9d68597da5b0ce1311ae243fc003e4f7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117736
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_luth at sil.org>

diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx
index 6cb95976c655..fc04626bd5d6 100644
--- a/sw/source/filter/ww8/wrtw8num.cxx
+++ b/sw/source/filter/ww8/wrtw8num.cxx
@@ -238,24 +238,13 @@ void MSWordExportBase::NumberingDefinitions()
 /**
  * Converts the SVX numbering type to MSONFC.
  *
- * This is used for paragraph numbering purposes.
+ * This is used for special paragraph numbering considerations.
  */
-static sal_uInt8 GetLevelNFC(  sal_uInt16 eNumType, const SfxItemSet *pOutSet)
+static sal_uInt8 GetLevelNFC(sal_uInt16 eNumType, const SfxItemSet* pOutSet, sal_uInt8 nDefault)
 {
-    sal_uInt8 nRet = 0;
+    sal_uInt8 nRet = nDefault;
     switch( eNumType )
     {
-    case SVX_NUM_CHARS_UPPER_LETTER:
-    case SVX_NUM_CHARS_UPPER_LETTER_N:  nRet = 3;       break;
-    case SVX_NUM_CHARS_LOWER_LETTER:
-    case SVX_NUM_CHARS_LOWER_LETTER_N:  nRet = 4;       break;
-    case SVX_NUM_ROMAN_UPPER:           nRet = 1;       break;
-    case SVX_NUM_ROMAN_LOWER:           nRet = 2;       break;
-
-    case SVX_NUM_BITMAP:
-    case SVX_NUM_CHAR_SPECIAL:         nRet = 23;      break;
-    case SVX_NUM_FULL_WIDTH_ARABIC: nRet = 14; break;
-    case SVX_NUM_CIRCLE_NUMBER: nRet = 18;break;
     case SVX_NUM_NUMBER_LOWER_ZH:
         nRet = 35;
         if ( pOutSet ) {
@@ -266,27 +255,14 @@ static sal_uInt8 GetLevelNFC(  sal_uInt16 eNumType, const SfxItemSet *pOutSet)
             }
         }
         break;
-    case SVX_NUM_NUMBER_UPPER_ZH: nRet = 38; break;
-    case SVX_NUM_NUMBER_UPPER_ZH_TW: nRet = 34;break;
-    case SVX_NUM_TIAN_GAN_ZH: nRet = 30; break;
-    case SVX_NUM_DI_ZI_ZH: nRet = 31; break;
-    case SVX_NUM_NUMBER_TRADITIONAL_JA: nRet = 16; break;
-    case SVX_NUM_AIU_FULLWIDTH_JA: nRet = 20; break;
-    case SVX_NUM_AIU_HALFWIDTH_JA: nRet = 12; break;
-    case SVX_NUM_IROHA_FULLWIDTH_JA: nRet = 21; break;
-    case SVX_NUM_IROHA_HALFWIDTH_JA: nRet = 13; break;
-    case style::NumberingType::HANGUL_SYLLABLE_KO: nRet = 24; break;// ganada
-    case style::NumberingType::HANGUL_JAMO_KO: nRet = 25; break;// chosung
-    case style::NumberingType::HANGUL_CIRCLED_SYLLABLE_KO: nRet = 24; break;
-    case style::NumberingType::HANGUL_CIRCLED_JAMO_KO: nRet = 25; break;
-    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;
+
+    // LVLF can't contain 0x08, msonfcHex.
+    case style::NumberingType::SYMBOL_CHICAGO:
+        // No SVX_NUM_SYMBOL_CHICAGO here: LVLF can't contain 0x09, msonfcChiManSty.
+        nRet = 0;
         break;
+    // LVLF can't contain 0x0F / 15, msonfcSbChar / decimalHalfWidth.
+    // LVLF can't contain 0x13 / 19, msonfcDArabic / decimalFullWidth2
     }
     return nRet;
 }
@@ -311,7 +287,8 @@ void WW8AttributeOutput::NumberingLevel( sal_uInt8 /*nLevel*/,
     m_rWW8Export.pTableStrm->WriteUInt32( nStart );
 
     // Type
-    m_rWW8Export.pTableStrm->WriteUChar( GetLevelNFC( nNumberingType ,pOutSet) );
+    sal_uInt8 nNumId = GetLevelNFC(nNumberingType, pOutSet, WW8Export::GetNumId(nNumberingType));
+    m_rWW8Export.pTableStrm->WriteUChar(nNumId);
 
     // Justification
     sal_uInt8 nAlign;
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 80aad82b3545..7a942ddf8e80 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -735,10 +735,37 @@ sal_uInt8 WW8Export::GetNumId( sal_uInt16 eNumType )
     case SVX_NUM_CHARS_LOWER_LETTER_N:  nRet = 4;       break;
     case SVX_NUM_ROMAN_UPPER:           nRet = 1;       break;
     case SVX_NUM_ROMAN_LOWER:           nRet = 2;       break;
+    case style::NumberingType::TEXT_NUMBER: nRet = 5; break;
+    case style::NumberingType::TEXT_CARDINAL: nRet = 6; break;
+    case style::NumberingType::TEXT_ORDINAL: nRet = 7; break;
+    case style::NumberingType::AIU_HALFWIDTH_JA: nRet = 12; break;
+    case style::NumberingType::IROHA_HALFWIDTH_JA: nRet = 13; break;
+    case style::NumberingType::FULLWIDTH_ARABIC: nRet = 14; break;
+    case style::NumberingType::NUMBER_TRADITIONAL_JA: nRet = 16; break;
+    case style::NumberingType::CIRCLE_NUMBER: nRet = 18; break;
+    case style::NumberingType::AIU_FULLWIDTH_JA: nRet = 20; break;
+    case style::NumberingType::IROHA_FULLWIDTH_JA: nRet = 21; break;
 
     case SVX_NUM_BITMAP:
     case SVX_NUM_CHAR_SPECIAL:          nRet = 23;      break;
-
+    case style::NumberingType::HANGUL_SYLLABLE_KO: nRet = 24; break;// ganada
+    case style::NumberingType::HANGUL_JAMO_KO: nRet = 25; break;// chosung
+    case style::NumberingType::HANGUL_CIRCLED_SYLLABLE_KO: nRet = 24; break;
+    case style::NumberingType::HANGUL_CIRCLED_JAMO_KO: nRet = 25; break;
+    case style::NumberingType::TIAN_GAN_ZH: nRet = 30; break;
+    case style::NumberingType::DI_ZI_ZH: nRet = 31; break;
+    case style::NumberingType::NUMBER_UPPER_ZH_TW: nRet = 34;break;
+    case style::NumberingType::NUMBER_UPPER_ZH: nRet = 38; break;
+    case style::NumberingType::NUMBER_HANGUL_KO: nRet = 41; break;
+    case style::NumberingType::NUMBER_UPPER_KO: nRet = 44; break;
+    case style::NumberingType::NUMBER_HEBREW: nRet = 45; break;
+    case style::NumberingType::CHARS_ARABIC: nRet = 46; break;
+    case style::NumberingType::CHARS_HEBREW: nRet = 47; break;
+    case style::NumberingType::CHARS_ARABIC_ABJAD: nRet = 48; break;
+    case style::NumberingType::CHARS_NEPALI: nRet = 49; break;
+    case style::NumberingType::CHARS_THAI: nRet = 53; break;
+    case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_RU: nRet = 58; break;
+    case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_RU: nRet = 59; break;
     // nothing, WW does the same (undocumented)
     case SVX_NUM_NUMBER_NONE:           nRet = 0xff;    break;
     case SVX_NUM_SYMBOL_CHICAGO:
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 5f36371e5b03..64670b780eb0 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -535,14 +535,29 @@ SvxNumType WW8ListManager::GetSvxNumTypeFromMSONFC(sal_uInt16 nNFC)
         case 4:
             nType = SVX_NUM_CHARS_LOWER_LETTER_N;
             break;
-        case 5:
-            // actually: ORDINAL
-            nType = SVX_NUM_ARABIC;
+        case 5: // ordinal
+            nType = SVX_NUM_TEXT_NUMBER;
+            break;
+        case 6: // cardinalText
+            nType = SVX_NUM_TEXT_CARDINAL;
+            break;
+        case 7: // ordinalText
+            nType = SVX_NUM_TEXT_ORDINAL;
             break;
+        //case 8: // hex
+
         case 9:
             // 0x09, msonfcChiManSty
             nType = SVX_NUM_SYMBOL_CHICAGO;
             break;
+        //case 15: // decimalHalfWidth
+        //case 17: // japaneseDigitalTenThousand
+
+        case 18: // decimalEnclosedCircle
+        case 28: // decimalEnclosedCircleChinese
+        case 29: // ideographEnclosedCircle
+            nType = SVX_NUM_CIRCLE_NUMBER;
+            break;
         case 22:
             // 0x16, msonfcArabicLZ
             nType = SVX_NUM_ARABIC_ZERO;
@@ -561,9 +576,11 @@ SvxNumType WW8ListManager::GetSvxNumTypeFromMSONFC(sal_uInt16 nNFC)
         case 30:
             nType = SVX_NUM_TIAN_GAN_ZH;
             break;
-        case 31:
+        case 31: // ideographZodiac
+        case 32: // ideographZodiacTraditional
             nType = SVX_NUM_DI_ZI_ZH;
             break;
+        case 33: // taiwaneseCounting
         case 35:
         case 36:
         case 37:
@@ -578,6 +595,7 @@ SvxNumType WW8ListManager::GetSvxNumTypeFromMSONFC(sal_uInt16 nNFC)
             nType = SVX_NUM_NUMBER_UPPER_ZH;
             break;
         case 10:
+        case 16: // japaneseLegal
             nType = SVX_NUM_NUMBER_TRADITIONAL_JA;
             break;
         case 20:
@@ -598,14 +616,51 @@ SvxNumType WW8ListManager::GetSvxNumTypeFromMSONFC(sal_uInt16 nNFC)
         case 25:
             nType = SVX_NUM_HANGUL_JAMO_KO;
             break;
-        case 41:
+        //case 26: // decimalEnclosedFullstop
+        //case 27: // decimalEnclosedParen
+        //case 40: // decimal (Chinese)
+
+        case 41: // koreanDigital
+        case 42: // koreanCounting
+        case 43: // koreanLegal
             nType = SVX_NUM_NUMBER_HANGUL_KO;
             break;
-        //case 42:
-        //case 43:
-        case 44:
+        case 44: // koreanDigital2
             nType = SVX_NUM_NUMBER_UPPER_KO;
             break;
+        case 45: // hebrew1
+            nType = SVX_NUM_NUMBER_HEBREW;
+            break;
+        case 46: // arabicAlpha
+            nType = SVX_NUM_CHARS_ARABIC;
+            break;
+        case 47: // hebrew2
+            nType = SVX_NUM_CHARS_HEBREW;
+            break;
+        case 48: // arabicAbjad
+            nType = SVX_NUM_CHARS_ARABIC_ABJAD;
+            break;
+        case 49: // hindiVowels
+            nType = SVX_NUM_CHARS_NEPALI; // DOCX imports as NEPAL and exports as PERSIAN
+            break;
+        //case 50: // hindiConsonants
+        //case 51: // hindiNumbers
+        //case 52: // hindiCounting
+
+        case 53: // thaiLetters
+            nType = SVX_NUM_CHARS_THAI;
+            break;
+        //case 54: // thaiNumbers
+        //case 55: // thaiCounting
+        //case 56: // vietnameseCounting
+        //case 57: // numberInDash
+
+        case 58: // russianLower
+            nType = SVX_NUM_CHARS_CYRILLIC_LOWER_LETTER_RU;
+            break;
+        case 59: // russianUpper
+            nType =SVX_NUM_CHARS_CYRILLIC_UPPER_LETTER_RU;
+            break;
         default:
             nType = SVX_NUM_ARABIC;
             break;
diff --git a/writerfilter/source/dmapper/ConversionHelper.cxx b/writerfilter/source/dmapper/ConversionHelper.cxx
index ac877c5d723a..e0385a5c6a65 100644
--- a/writerfilter/source/dmapper/ConversionHelper.cxx
+++ b/writerfilter/source/dmapper/ConversionHelper.cxx
@@ -602,16 +602,12 @@ sal_Int16 ConvertNumberingType(const sal_Int32 nFmt, const sal_Int16 nDefault)
     }
 /*  TODO: Lots of additional values are available - some are supported in the I18 framework
     NS_ooxml::LN_Value_ST_NumberFormat_hex = 91685;
-    NS_ooxml::LN_Value_ST_NumberFormat_decimalFullWidth = 91691;
     NS_ooxml::LN_Value_ST_NumberFormat_decimalHalfWidth = 91692;
     NS_ooxml::LN_Value_ST_NumberFormat_japaneseDigitalTenThousand = 91694;
     NS_ooxml::LN_Value_ST_NumberFormat_decimalEnclosedFullstop = 91703;
     NS_ooxml::LN_Value_ST_NumberFormat_decimalEnclosedParen = 91704;
     NS_ooxml::LN_Value_ST_NumberFormat_ideographZodiacTraditional = 91709;
     NS_ooxml::LN_Value_ST_NumberFormat_taiwaneseDigital = 91713;
-    NS_ooxml::LN_Value_ST_NumberFormat_chineseLegalSimplified = 91715;
-    NS_ooxml::LN_Value_ST_NumberFormat_chineseCountingThousand = 91716;
-    NS_ooxml::LN_Value_ST_NumberFormat_koreanLegal = 91719;
     NS_ooxml::LN_Value_ST_NumberFormat_vietnameseCounting = 91721;
     NS_ooxml::LN_Value_ST_NumberFormat_numberInDash = 91725;
     NS_ooxml::LN_Value_ST_NumberFormat_hindiConsonants = 91731;


More information about the Libreoffice-commits mailing list