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

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


 sw/qa/extras/ww8export/ww8export3.cxx |   33 ++++++-
 sw/source/filter/ww8/wrtw8num.cxx     |    5 +
 sw/source/filter/ww8/wrtw8sty.cxx     |    8 +
 sw/source/filter/ww8/wrtww8.hxx       |    6 +
 sw/source/filter/ww8/ww8atr.cxx       |    4 
 sw/source/filter/ww8/ww8par.cxx       |   18 ---
 sw/source/filter/ww8/ww8par.hxx       |    2 
 sw/source/filter/ww8/ww8par3.cxx      |  160 +++++++++++++++++++++-------------
 8 files changed, 160 insertions(+), 76 deletions(-)

New commits:
commit 6c9968885c10e5d1a6ef193ac45d349e598d6e49
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Mar 5 15:57:33 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Apr 3 09:19:26 2020 +0200

    sw padded numbering: add DOC footnote filter
    
    Import side: remove the duplication between SwWW8ImplReader::CoreLoad()
    and WW8ListManager::ReadLVL(). The CoreLoad() version did not support
    reading 0x16 as it did a "& 0xf" on the value before parsing.
    
    Export side: Writer supports footnote numbering type per-document, Word
    supports it per-section. So next to the per-document export add a
    per-section one, that's what Word actually reads. Similar code was there
    already for DOCX.
    
    (cherry picked from commit 5c7d0c5bafd244f1bfb3930e0229f1f3f2371c82)
    
    Conflicts:
            sw/source/filter/ww8/ww8par.cxx
    
    Change-Id: Ic94e953cfee4514aabe507a8bcf75445bf05f401
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91563
    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 b9531e3159bc..8d1378dab410 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -17,6 +17,7 @@
 #include <com/sun/star/text/XTextTable.hpp>
 #include <com/sun/star/text/XTextTablesSupplier.hpp>
 #include <com/sun/star/text/WritingMode2.hpp>
+#include <com/sun/star/text/XTextContentAppend.hpp>
 
 #include <drawdoc.hxx>
 #include <svx/xfillit0.hxx>
@@ -48,7 +49,7 @@ DECLARE_WW8EXPORT_TEST(testTdf37778_readonlySection, "tdf37778_readonlySection.d
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of Sections", sal_Int32(0), xSections->getCount());
     }
 
-DECLARE_ODFEXPORT_TEST(testArabicZeroNumbering, "arabic-zero-numbering.doc")
+DECLARE_WW8EXPORT_TEST(testArabicZeroNumbering, "arabic-zero-numbering.doc")
 {
     auto xNumberingRules
         = getProperty<uno::Reference<container::XIndexAccess>>(getParagraph(1), "NumberingRules");
@@ -61,6 +62,36 @@ DECLARE_ODFEXPORT_TEST(testArabicZeroNumbering, "arabic-zero-numbering.doc")
                          aMap["NumberingType"].get<sal_uInt16>());
 }
 
+CPPUNIT_TEST_FIXTURE(SwModelTestBase, testArabicZeroNumberingFootnote)
+{
+    // Create a document, set footnote numbering type to ARABIC_ZERO.
+    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::ARABIC_ZERO;
+    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::ARABIC_ZERO;
+    auto nActual = getProperty<sal_uInt16>(xFootnotesSupplier->getFootnoteSettings(), "NumberingType");
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 64
+    // - Actual  : 4
+    // i.e. the numbering type was ARABIC, not ARABIC_ZERO.
+    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 1302a68e7404..e149bb266534 100644
--- a/sw/source/filter/ww8/wrtw8num.cxx
+++ b/sw/source/filter/ww8/wrtw8num.cxx
@@ -185,6 +185,11 @@ void MSWordExportBase::NumberingDefinitions()
     }
 }
 
+/**
+ * Converts the SVX numbering type to MSONFC.
+ *
+ * This is used for paragraph numbering purposes.
+ */
 static sal_uInt8 GetLevelNFC(  sal_uInt16 eNumType, const SfxItemSet *pOutSet)
 {
     sal_uInt8 nRet = 0;
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 2768429ea5a5..9fd09a9b92a2 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1317,6 +1317,7 @@ void WW8AttributeOutput::StartSection()
 void WW8AttributeOutput::SectFootnoteEndnotePr()
 {
     const SwFootnoteInfo& rInfo = m_rWW8Export.m_pDoc->GetFootnoteInfo();
+    const SwEndNoteInfo& rEndNoteInfo = m_rWW8Export.m_pDoc->GetEndNoteInfo();
     m_rWW8Export.InsUInt16( NS_sprm::sprmSRncFtn );
     switch( rInfo.eNum )
     {
@@ -1324,6 +1325,13 @@ void WW8AttributeOutput::SectFootnoteEndnotePr()
     case FTNNUM_CHAPTER:  m_rWW8Export.pO->push_back( sal_uInt8/*rncRstSect*/ (1) ); break;
     default:              m_rWW8Export.pO->push_back( sal_uInt8/*rncCont*/ (0) ); break;
     }
+
+    m_rWW8Export.InsUInt16(NS_sprm::sprmSNfcFtnRef);
+    sal_uInt8 nId = WW8Export::GetNumId(rInfo.aFormat.GetNumberingType());
+    SwWW8Writer::InsUInt16(*m_rWW8Export.pO, nId);
+    m_rWW8Export.InsUInt16(NS_sprm::sprmSNfcEdnRef);
+    nId = WW8Export::GetNumId(rEndNoteInfo.aFormat.GetNumberingType());
+    SwWW8Writer::InsUInt16(*m_rWW8Export.pO, nId);
 }
 
 void WW8AttributeOutput::SectionFormProtection( bool bProtected )
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 4d7a465c9696..2026ee14d24d 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -1110,7 +1110,11 @@ public:
     void SetHdFtIndex(unsigned int nHdFtIndex) { m_nHdFtIndex = nHdFtIndex; }
     void IncrementHdFtIndex() { ++m_nHdFtIndex; }
 
-    /// Convert the SVX numbering type to id
+    /**
+     * Converts the SVX numbering type to MSONFC.
+     *
+     * This is used for section, footnote and endnote numbering purposes.
+     */
     static sal_uInt8 GetNumId( sal_uInt16 eNumType );
 
     /// Guess the script (asian/western).
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index f7fad56a52f6..0d1b6e4c1189 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_ARABIC_ZERO:
+        // 0x16, msonfcArabicLZ
+        nRet = 22;
+        break;
     }
     return nRet;
 }
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 1c3474a8b7a0..7cc101289b76 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -5075,16 +5075,6 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
 
     m_xSBase.reset(new WW8ScannerBase(m_pStrm,m_pTableStream,m_pDataStream, m_xWwFib.get()));
 
-    static const SvxNumType eNumTA[16] =
-    {
-        SVX_NUM_ARABIC, SVX_NUM_ROMAN_UPPER, SVX_NUM_ROMAN_LOWER,
-        SVX_NUM_CHARS_UPPER_LETTER_N, SVX_NUM_CHARS_LOWER_LETTER_N,
-        SVX_NUM_ARABIC, SVX_NUM_ARABIC, SVX_NUM_ARABIC,
-        SVX_NUM_ARABIC, SVX_NUM_ARABIC, SVX_NUM_ARABIC,
-        SVX_NUM_ARABIC, SVX_NUM_ARABIC, SVX_NUM_ARABIC,
-        SVX_NUM_ARABIC, SVX_NUM_ARABIC
-    };
-
     if (m_xSBase->AreThereFootnotes())
     {
         static const SwFootnoteNum eNumA[4] =
@@ -5097,8 +5087,8 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
 
         aInfo.ePos = FTNPOS_PAGE;
         aInfo.eNum = eNumA[m_xWDop->rncFootnote];
-        sal_uInt16 nfcFootnoteRef = m_xWDop->nfcFootnoteRef & 0xF;
-        aInfo.aFormat.SetNumberingType( eNumTA[nfcFootnoteRef] );
+        sal_uInt16 nfcFootnoteRef = m_xWDop->nfcFootnoteRef;
+        aInfo.aFormat.SetNumberingType( WW8ListManager::GetSvxNumTypeFromMSONFC(nfcFootnoteRef)  );
         if( m_xWDop->nFootnote )
             aInfo.nFootnoteOffset = m_xWDop->nFootnote - 1;
         m_rDoc.SetFootnoteInfo( aInfo );
@@ -5107,8 +5097,8 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
     {
         SwEndNoteInfo aInfo;
         aInfo = m_rDoc.GetEndNoteInfo(); // Same as for Footnote
-        sal_uInt16 nfcEdnRef = m_xWDop->nfcEdnRef & 0xF;
-        aInfo.aFormat.SetNumberingType( eNumTA[nfcEdnRef] );
+        sal_uInt16 nfcEdnRef = m_xWDop->nfcEdnRef;
+        aInfo.aFormat.SetNumberingType( WW8ListManager::GetSvxNumTypeFromMSONFC(nfcEdnRef) );
         if( m_xWDop->nEdn )
             aInfo.nFootnoteOffset = m_xWDop->nEdn - 1;
         m_rDoc.SetEndNoteInfo( aInfo );
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index ee5a8b68b795..37bb3f2357ec 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -156,6 +156,8 @@ public:
     ~WW8ListManager() COVERITY_NOEXCEPT_FALSE;
     SwNumRule* GetNumRule(size_t i);
     size_t GetWW8LSTInfoNum() const{return maLSTInfos.size();}
+    static SvxNumType GetSvxNumTypeFromMSONFC(sal_uInt16 nMSONFC);
+
 private:
     wwSprmParser const maSprmParser;
     SwWW8ImplReader& rReader;
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 1d9de8283541..848b8334d6b2 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -515,6 +515,102 @@ static OUString sanitizeString(const OUString& rString)
     return rString;
 }
 
+SvxNumType WW8ListManager::GetSvxNumTypeFromMSONFC(sal_uInt16 nNFC)
+{
+    SvxNumType nType(SVX_NUM_ARABIC);
+
+    switch (nNFC)
+    {
+        case 0:
+            nType = SVX_NUM_ARABIC;
+            break;
+        case 1:
+            nType = SVX_NUM_ROMAN_UPPER;
+            break;
+        case 2:
+            nType = SVX_NUM_ROMAN_LOWER;
+            break;
+        case 3:
+            nType = SVX_NUM_CHARS_UPPER_LETTER_N;
+            break;
+        case 4:
+            nType = SVX_NUM_CHARS_LOWER_LETTER_N;
+            break;
+        case 5:
+            // actually: ORDINAL
+            nType = SVX_NUM_ARABIC;
+            break;
+        case 22:
+            // 0x16, msonfcArabicLZ
+            nType = SVX_NUM_ARABIC_ZERO;
+            break;
+        case 23:
+            nType = SVX_NUM_CHAR_SPECIAL;
+
+            break;
+        case 255:
+            nType = SVX_NUM_NUMBER_NONE;
+            break;
+        case 14:
+        case 19:
+            nType = SVX_NUM_FULL_WIDTH_ARABIC;
+            break;
+        case 30:
+            nType = SVX_NUM_TIAN_GAN_ZH;
+            break;
+        case 31:
+            nType = SVX_NUM_DI_ZI_ZH;
+            break;
+        case 35:
+        case 36:
+        case 37:
+        case 11:
+        case 39:
+            nType = SVX_NUM_NUMBER_LOWER_ZH;
+            break;
+        case 34:
+            nType = SVX_NUM_NUMBER_UPPER_ZH_TW;
+            break;
+        case 38:
+            nType = SVX_NUM_NUMBER_UPPER_ZH;
+            break;
+        case 10:
+            nType = SVX_NUM_NUMBER_TRADITIONAL_JA;
+            break;
+        case 20:
+            nType = SVX_NUM_AIU_FULLWIDTH_JA;
+            break;
+        case 12:
+            nType = SVX_NUM_AIU_HALFWIDTH_JA;
+            break;
+        case 21:
+            nType = SVX_NUM_IROHA_FULLWIDTH_JA;
+            break;
+        case 13:
+            nType = SVX_NUM_IROHA_HALFWIDTH_JA;
+            break;
+        case 24:
+            nType = SVX_NUM_HANGUL_SYLLABLE_KO;
+            break;
+        case 25:
+            nType = SVX_NUM_HANGUL_JAMO_KO;
+            break;
+        case 41:
+            nType = SVX_NUM_NUMBER_HANGUL_KO;
+            break;
+        //case 42:
+        //case 43:
+        case 44:
+            nType = SVX_NUM_NUMBER_UPPER_KO;
+            break;
+        default:
+            nType = SVX_NUM_ARABIC;
+            break;
+    }
+
+    return nType;
+}
+
 bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet>& rpItemSet,
     sal_uInt16 nLevelStyle, bool bSetStartNo,
     std::deque<bool> &rNotReallyThere, sal_uInt16 nLevel,
@@ -734,67 +830,11 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet
     if( 0 <= aLVL.nStartAt )
         nStartNo = static_cast<sal_uInt16>(aLVL.nStartAt);
 
-    switch( aLVL.nNFC )
+    nType = GetSvxNumTypeFromMSONFC(aLVL.nNFC);
+    //For i120928,type info
+    if (bIsPicBullet)
     {
-        case 0:
-            nType = SVX_NUM_ARABIC;
-            break;
-        case 1:
-            nType = SVX_NUM_ROMAN_UPPER;
-            break;
-        case 2:
-            nType = SVX_NUM_ROMAN_LOWER;
-            break;
-        case 3:
-            nType = SVX_NUM_CHARS_UPPER_LETTER_N;
-            break;
-        case 4:
-            nType = SVX_NUM_CHARS_LOWER_LETTER_N;
-            break;
-        case 5:
-            // actually: ORDINAL
-            nType = SVX_NUM_ARABIC;
-            break;
-        case 22:
-            // 0x16, msonfcArabicLZ
-            nType = SVX_NUM_ARABIC_ZERO;
-            break;
-        case 23:
-            nType = SVX_NUM_CHAR_SPECIAL;
-            //For i120928,type info
-            if (bIsPicBullet)
-            {
-                nType = SVX_NUM_BITMAP;
-            }
-
-            break;
-        case 255:
-            nType = SVX_NUM_NUMBER_NONE;
-            break;
-        case 14:
-        case 19:nType = SVX_NUM_FULL_WIDTH_ARABIC; break;
-        case 30:nType = SVX_NUM_TIAN_GAN_ZH; break;
-        case 31:nType = SVX_NUM_DI_ZI_ZH; break;
-        case 35:
-        case 36:
-        case 37:
-        case 11:
-        case 39:nType = SVX_NUM_NUMBER_LOWER_ZH; break;
-        case 34:nType = SVX_NUM_NUMBER_UPPER_ZH_TW; break;
-        case 38:nType = SVX_NUM_NUMBER_UPPER_ZH; break;
-        case 10:nType = SVX_NUM_NUMBER_TRADITIONAL_JA; break;
-        case 20:nType = SVX_NUM_AIU_FULLWIDTH_JA; break;
-        case 12:nType = SVX_NUM_AIU_HALFWIDTH_JA; break;
-        case 21:nType = SVX_NUM_IROHA_FULLWIDTH_JA; break;
-        case 13:nType = SVX_NUM_IROHA_HALFWIDTH_JA; break;
-        case 24:nType = SVX_NUM_HANGUL_SYLLABLE_KO; break;
-        case 25:nType = SVX_NUM_HANGUL_JAMO_KO; break;
-        case 41:nType = SVX_NUM_NUMBER_HANGUL_KO; break;
-        //case 42:
-        //case 43:
-        case 44:nType = SVX_NUM_NUMBER_UPPER_KO; break;
-        default:
-                nType= SVX_NUM_ARABIC; break;
+        nType = SVX_NUM_BITMAP;
     }
 
     //If a number level is not going to be used, then record this fact


More information about the Libreoffice-commits mailing list