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

Mark Hung marklh9 at gmail.com
Tue Nov 18 02:24:51 PST 2014


 sw/qa/extras/ooxmlimport/data/chtoutline.docx    |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx         |   24 +++++++++++++++++++++++
 writerfilter/source/dmapper/NumberingManager.cxx |   10 ++++-----
 3 files changed, 29 insertions(+), 5 deletions(-)

New commits:
commit 29a91e4739496e1db5995fdece6a3ffa89e42774
Author: Mark Hung <marklh9 at gmail.com>
Date:   Mon Nov 17 13:13:10 2014 -0800

    Fix outline numbering for ooxml import filter.
    
    Conflicts:
    	sw/qa/extras/ooxmlimport/ooxmlimport.cxx
    Reviewed on:
    	https://gerrit.libreoffice.org/12519
    
    Change-Id: Ifd8a562bcee4f57cc99ed3215e6d8d6dd95216b0

diff --git a/sw/qa/extras/ooxmlimport/data/chtoutline.docx b/sw/qa/extras/ooxmlimport/data/chtoutline.docx
new file mode 100644
index 0000000..92fdaf7
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/chtoutline.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 640e468..a0650a1 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -2532,6 +2532,30 @@ DECLARE_OOXMLIMPORT_TEST(testFdo85542, "fdo85542.docx")
     uno::Reference<text::XTextRange> xTextNeighborhood(xNeighborhoodCursor, uno::UNO_QUERY);
     CPPUNIT_ASSERT_EQUAL(xTextNeighborhood->getString(), OUString("AB"));
 }
+
+DECLARE_OOXMLIMPORT_TEST(testChtOutlineNumberingOoxml, "chtoutline.docx")
+{
+    const sal_Unicode aExpectedPrefix[2] = { 0x7b2c, 0x0020 };
+    const sal_Unicode aExpectedSuffix[2] = { 0x0020, 0x7ae0 };
+    uno::Reference< text::XChapterNumberingSupplier > xChapterNumberingSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference< container::XIndexAccess> xLevels(xChapterNumberingSupplier->getChapterNumberingRules());
+    uno::Sequence<beans::PropertyValue> aProps;
+    xLevels->getByIndex(0) >>= aProps; // 1st level
+
+    OUString aSuffix,aPrefix;
+    for (int i = 0; i < aProps.getLength(); ++i)
+    {
+        const beans::PropertyValue& rProp = aProps[i];
+
+        if (rProp.Name == "Suffix")
+            aSuffix = rProp.Value.get<OUString>();
+        if (rProp.Name == "Prefix")
+            aPrefix = rProp.Value.get<OUString>();
+    }
+    CPPUNIT_ASSERT_EQUAL(OUString(aExpectedPrefix,SAL_N_ELEMENTS(aExpectedPrefix)), aPrefix);
+    CPPUNIT_ASSERT_EQUAL(OUString(aExpectedSuffix,SAL_N_ELEMENTS(aExpectedSuffix)), aSuffix);
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 586b9a1..2d5618d 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -147,11 +147,11 @@ void ListLevel::SetParaStyle( boost::shared_ptr< StyleSheetEntry > pStyle )
     // AFAICT .docx spec does not identify which numberings or paragraph
     // styles are actually the ones to be used for outlines (chapter numbering),
     // it only kind of says somewhere that they should be named Heading1 to Heading9.
-    const OUString styleId = pStyle->sStyleIdentifierD;
-    m_outline = ( styleId.getLength() == RTL_CONSTASCII_LENGTH( "Heading1" )
-        && styleId.match( "Heading", 0 )
-        && styleId[ RTL_CONSTASCII_LENGTH( "Heading" ) ] >= '1'
-        && styleId[ RTL_CONSTASCII_LENGTH( "Heading" ) ] <= '9' );
+    const OUString styleId= pStyle->sConvertedStyleName;
+    m_outline = ( styleId.getLength() == RTL_CONSTASCII_LENGTH( "Heading 1" )
+        && styleId.match( "Heading ", 0 )
+        && styleId[ RTL_CONSTASCII_LENGTH( "Heading " ) ] >= '1'
+        && styleId[ RTL_CONSTASCII_LENGTH( "Heading " ) ] <= '9' );
 }
 
 sal_Int16 ListLevel::GetParentNumbering( const OUString& sText, sal_Int16 nLevel,


More information about the Libreoffice-commits mailing list