diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-07-11 15:17:02 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-07-11 15:18:56 +0200 |
commit | 794caa58a7208921ad8f911d586088213e390fba (patch) | |
tree | b57fe91dbd8d6633ffe97bfba53a1c1190ceac87 /sw/qa | |
parent | 7039abde34942812c44a2e265ddcb79cc5c62be2 (diff) |
add a testcase for the recent writerfilter numbering fix
Change-Id: I41300ec0bf4b7db93912236e0d15fcab97cabd2d
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/ooxmltok/data/numbering1.docx | bin | 0 -> 14346 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmltok/ooxmltok.cxx | 58 |
2 files changed, 58 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmltok/data/numbering1.docx b/sw/qa/extras/ooxmltok/data/numbering1.docx Binary files differnew file mode 100644 index 000000000000..55b4af3e8584 --- /dev/null +++ b/sw/qa/extras/ooxmltok/data/numbering1.docx diff --git a/sw/qa/extras/ooxmltok/ooxmltok.cxx b/sw/qa/extras/ooxmltok/ooxmltok.cxx index a3fd38a59913..28f8dfb483a6 100644 --- a/sw/qa/extras/ooxmltok/ooxmltok.cxx +++ b/sw/qa/extras/ooxmltok/ooxmltok.cxx @@ -76,6 +76,7 @@ public: void testN766481(); void testN766487(); void testN693238(); + void testNumbering1(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -100,6 +101,7 @@ public: CPPUNIT_TEST(testN766481); CPPUNIT_TEST(testN766487); CPPUNIT_TEST(testN693238); + CPPUNIT_TEST(testNumbering1); #endif CPPUNIT_TEST_SUITE_END(); @@ -678,6 +680,62 @@ void Test::testN693238() CPPUNIT_ASSERT_EQUAL(sal_Int32(635), nValue); } +void Test::testNumbering1() +{ + load( "numbering1.docx" ); +/* <w:numPr> in the paragraph itself was overriden by <w:numpr> introduced by the paragraph's <w:pStyle> +enum = ThisComponent.Text.createEnumeration +para = enum.NextElement +xray para.NumberingStyleName +numberingstyle = ThisComponent.NumberingRules.getByIndex(6) +xray numberingstyle.name - should match name above +numbering = numberingstyle.getByIndex(0) +xray numbering(11) - should be 4, arabic +note that the indexes may get off as the implementation evolves, C++ code seaches in loops +*/ + uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY); + // list of paragraphs + uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration(); + uno::Reference<uno::XInterface> paragraph(paraEnum->nextElement(), uno::UNO_QUERY); + uno::Reference<text::XTextRange> text(paragraph, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL( OUString( "Text1." ), text->getString()); + uno::Reference<beans::XPropertySet> xPropertySet( paragraph, uno::UNO_QUERY ); + OUString numberingStyleName; + xPropertySet->getPropertyValue( "NumberingStyleName" ) >>= numberingStyleName; + uno::Reference<text::XNumberingRulesSupplier> xNumberingRulesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> numberingRules(xNumberingRulesSupplier->getNumberingRules(), uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> numberingRule; + for( int i = 0; + i < numberingRules->getCount(); + ++i ) + { + xPropertySet.set( numberingRules->getByIndex( i ), uno::UNO_QUERY ); + OUString name; + xPropertySet->getPropertyValue( "Name" ) >>= name; + if( name == numberingStyleName ) + { + numberingRule.set( numberingRules->getByIndex( i ), uno::UNO_QUERY ); + break; + } + } + CPPUNIT_ASSERT( numberingRule.is()); + uno::Sequence< beans::PropertyValue > numbering; + numberingRule->getByIndex( 0 ) >>= numbering; + sal_Int16 numberingType = style::NumberingType::NUMBER_NONE; + for( int i = 0; + i < numbering.getLength(); + ++i ) + { + if( numbering[ i ].Name == "NumberingType" ) + { + numbering[ i ].Value >>= numberingType; + break; + } + } + CPPUNIT_ASSERT_EQUAL( style::NumberingType::ARABIC, numberingType ); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); |