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

Miklos Vajna vmiklos at collabora.co.uk
Mon Nov 17 07:56:47 PST 2014


 sw/qa/extras/ooxmlexport/data/num-parent-style.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx            |    6 ++++
 sw/qa/extras/rtfimport/rtfimport.cxx                |    6 ++--
 writerfilter/source/dmapper/DomainMapper.cxx        |   29 ++++++++++++++++++--
 4 files changed, 36 insertions(+), 5 deletions(-)

New commits:
commit c03b691a7cd8eba128204c851b99e0b75c580c0c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Nov 17 16:54:12 2014 +0100

    DOCX import: handle <w:numId> from parent styles as well
    
    Without this, we may miss the <w:numId> of a paragraph and set no
    numbering style name; and that leads to not restarting numberings when
    needed.
    
    Change-Id: I9a4896266c5b7f1d7cc2adc43b84e227c004da7c

diff --git a/sw/qa/extras/ooxmlexport/data/num-parent-style.docx b/sw/qa/extras/ooxmlexport/data/num-parent-style.docx
new file mode 100644
index 0000000..4b8c657
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/num-parent-style.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 851d72e..39c559a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -565,6 +565,12 @@ DECLARE_OOXMLEXPORT_TEST(testOoxmlCjklist35, "cjklist35.docx")
     CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_LOWER_ZH, numFormat);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testNumParentStyle, "num-parent-style.docx")
+{
+    // This was "Outline", i.e. <w:numId> was not imported from the Heading 2 paragraph style.
+    CPPUNIT_ASSERT(getProperty<OUString>(getParagraph(4), "NumberingStyleName").startsWith("WWNum"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index c393ad9..5b00fd6 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1099,6 +1099,30 @@ static bool ExchangeLeftRight( const PropertyMapPtr rContext, DomainMapper_Impl*
     return bExchangeLeftRight;
 }
 
+/// Check if the style or its parent has a list id, recursively.
+static sal_Int32 lcl_getListId(const StyleSheetEntryPtr pEntry, const StyleSheetTablePtr pStyleTable)
+{
+    const StyleSheetPropertyMap* pEntryProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry->pProperties.get());
+    if (!pEntryProperties)
+        return -1;
+
+    sal_Int32 nListId = pEntryProperties->GetListId();
+    // The style itself has a list id.
+    if (nListId >= 0)
+        return nListId;
+
+    // The style has no parent.
+    if (pEntry->sBaseStyleIdentifier.isEmpty())
+        return -1;
+
+    const StyleSheetEntryPtr pParent = pStyleTable->FindStyleSheetByISTD(pEntry->sBaseStyleIdentifier);
+    // No such parent style or loop in the style hierarchy.
+    if (!pParent || pParent == pEntry)
+        return -1;
+
+    return lcl_getListId(pParent, pStyleTable);
+}
+
 void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
 {
     // These SPRM's are not specific to any section, so it's expected that there is no context yet.
@@ -1976,10 +2000,11 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
             OSL_ENSURE( pEntry.get(), "no style sheet found" );
             const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : nullptr);
 
-            if( pStyleSheetProperties && pStyleSheetProperties->GetListId() >= 0 )
+            sal_Int32 nListId = pEntry ? lcl_getListId(pEntry, pStyleTable) : -1;
+            if( pStyleSheetProperties && nListId >= 0 )
             {
                 rContext->Insert( PROP_NUMBERING_STYLE_NAME, uno::makeAny(
-                            ListDef::GetStyleName( pStyleSheetProperties->GetListId( ) ) ), false);
+                            ListDef::GetStyleName( nListId ) ), false);
 
                 // We're inheriting properties from a numbering style. Make sure a possible right margin is inherited from the base style.
                 sal_Int32 nParaRightMargin = 0;
commit 521185705d062e9526a8a3e0bc485c943e83eb0e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Nov 17 08:54:10 2014 +0100

    CppunitTest_sw_rtfimport: indentation fixes
    
    Change-Id: I696489a60729426b9b14df6c9e79a2d8247d21fb

diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 645cf7c..6a1a23b 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2083,7 +2083,7 @@ DECLARE_RTFIMPORT_TEST(testFdo83204, "fdo83204.rtf")
 }
 
 // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 ).
-DECLARE_RTFIMPORT_TEST(testCp950listleveltext1, "cp950listleveltext1.rtf" )
+DECLARE_RTFIMPORT_TEST(testCp950listleveltext1, "cp950listleveltext1.rtf")
 {
     // suffix with Chinese only ( most common case generated by MSO2010 TC)
     const sal_Unicode aExpectedSuffix[1] = { 0x3001 };  // This is a dot that is generally used as suffix of Chinese list number
@@ -2105,7 +2105,7 @@ DECLARE_RTFIMPORT_TEST(testCp950listleveltext1, "cp950listleveltext1.rtf" )
 }
 
 // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 ).
-DECLARE_RTFIMPORT_TEST(testCp950listleveltext2, "cp950listleveltext2.rtf" )
+DECLARE_RTFIMPORT_TEST(testCp950listleveltext2, "cp950listleveltext2.rtf")
 {
     // Prefix and suffix with Chinese only ( tweaked from default in MSO2010 TC)
     const sal_Unicode aExpectedPrefix[2] = { 0x524d, 0x7f6e };
@@ -2133,7 +2133,7 @@ DECLARE_RTFIMPORT_TEST(testCp950listleveltext2, "cp950listleveltext2.rtf" )
 
 
 // This testcase illustrate leveltext with multibyte strings coded in cp950 ( BIG5 )
-DECLARE_RTFIMPORT_TEST(testCp950listleveltext3, "cp950listleveltext3.rtf" )
+DECLARE_RTFIMPORT_TEST(testCp950listleveltext3, "cp950listleveltext3.rtf")
 {
     // Prefix and suffix that mix Chinese and English ( tweaked from default in MSO2010 TC)
     const sal_Unicode aExpectedPrefix[4] = { 0x524d, 0x0061, 0x7f6e, 0x0062 };


More information about the Libreoffice-commits mailing list