diff options
author | Jan Holesovsky <kendy@collabora.com> | 2013-09-18 18:30:47 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2013-09-18 19:11:16 +0200 |
commit | a19bcc4c876b1f94c27e55c3813cfc878df3e377 (patch) | |
tree | b31699373c70af7c781ce6a5aad3d7c334f24ba8 /sw | |
parent | e7f9230b6f841c6c366779f6d33686cfee78f6b9 (diff) |
DOCX styles: Unit test for the styleId's.
Change-Id: I309a9c7ed0ad633ca58dce542d5fa2db883a17ec
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/style-inheritance.docx | bin | 0 -> 26321 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 21 |
2 files changed, 18 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/style-inheritance.docx b/sw/qa/extras/ooxmlexport/data/style-inheritance.docx Binary files differnew file mode 100644 index 000000000000..65ca38aedd57 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/style-inheritance.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 66b3935a2fda..f103cdaf852b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -117,6 +117,7 @@ public: void testA4AndBorders(); void testFdo68787(); void testCharacterBorder(); + void testStyleInheritance(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -132,7 +133,7 @@ private: * xml stream, and asserting an XPath expression. This method returns the * xml stream, so that you can do the asserting. */ - xmlDocPtr parseExport(); + xmlDocPtr parseExport(const OUString& rStreamName = OUString("word/document.xml")); void assertXPath(xmlDocPtr pXmlDoc, OString aXPath, OString aAttribute = OString(), OUString aExpectedValue = OUString()); }; @@ -210,6 +211,7 @@ void Test::run() {"a4andborders.docx", &Test::testA4AndBorders}, {"fdo68787.docx", &Test::testFdo68787}, {"charborder.odt", &Test::testCharacterBorder}, + {"style-inheritance.docx", &Test::testStyleInheritance}, }; // Don't test the first import of these, for some reason those tests fail const char* aBlacklist[] = { @@ -231,7 +233,7 @@ void Test::run() } } -xmlDocPtr Test::parseExport() +xmlDocPtr Test::parseExport(const OUString& rStreamName) { // Create the zip file. utl::TempFile aTempFile; @@ -239,7 +241,7 @@ xmlDocPtr Test::parseExport() // Read the XML stream we're interested in. uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), aTempFile.GetURL()); - uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName("word/document.xml"), uno::UNO_QUERY); + uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName(rStreamName), uno::UNO_QUERY); boost::shared_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, sal_True)); pStream->Seek(STREAM_SEEK_TO_END); sal_Size nSize = pStream->Tell(); @@ -1323,6 +1325,19 @@ void Test::testCharacterBorder() } } +void Test::testStyleInheritance() +{ + // This document has several issues to fix, more checks will be here to + // test its various aspects + + // Check that now styleId's are more like what MSO produces + xmlDocPtr pXmlStyles = parseExport("word/styles.xml"); + // the 1st style always must be Normal + assertXPath(pXmlStyles, "/w:styles/w:style[1]", "styleId", "Normal"); + // some random style later + assertXPath(pXmlStyles, "/w:styles/w:style[4]", "styleId", "Heading3"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); |