diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-06-11 09:13:58 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-06-11 09:18:32 +0200 |
commit | cb03de1c9e6f50fe1f6bf0b7c69c446020bab1d2 (patch) | |
tree | da52e6a48e35d3393bc6deff0fd26e559195319d /sw/qa | |
parent | d3f063cc86b50ac9adf08eb46dd2caf7975ed43c (diff) |
n#757905 testcase
Tricky, as we need to test the layout here. Will refactor a bit once we
have more such tests.
Change-Id: I19ecd282b64f2e3f8bb4bba88b5b3493b606872a
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/ww8tok/data/n757905.doc | bin | 0 -> 28160 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8tok/ww8tok.cxx | 47 |
2 files changed, 47 insertions, 0 deletions
diff --git a/sw/qa/extras/ww8tok/data/n757905.doc b/sw/qa/extras/ww8tok/data/n757905.doc Binary files differnew file mode 100644 index 000000000000..0fb7b097cd00 --- /dev/null +++ b/sw/qa/extras/ww8tok/data/n757905.doc diff --git a/sw/qa/extras/ww8tok/ww8tok.cxx b/sw/qa/extras/ww8tok/ww8tok.cxx index 08c77c0afdd3..a63ff1437147 100644 --- a/sw/qa/extras/ww8tok/ww8tok.cxx +++ b/sw/qa/extras/ww8tok/ww8tok.cxx @@ -36,6 +36,14 @@ #include <vcl/svapp.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> +#include <doc.hxx> +#include <rootfrm.hxx> + +#include <libxml/xmlwriter.h> +#include <libxml/xpath.h> + using rtl::OString; using rtl::OUString; using rtl::OUStringBuffer; @@ -48,6 +56,7 @@ public: void testN750255(); void testN652364(); void testN757118(); + void testN757905(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -56,6 +65,7 @@ public: CPPUNIT_TEST(testN750255); CPPUNIT_TEST(testN652364); CPPUNIT_TEST(testN757118); + CPPUNIT_TEST(testN757905); #endif CPPUNIT_TEST_SUITE_END(); @@ -208,6 +218,43 @@ xray ThisComponent.DrawPage.getByIndex(0).BoundRect CPPUNIT_ASSERT( abs( boundRect2.Width - boundRect4.Width ) < 5 ); } +void Test::testN757905() +{ + // The problem was that the paragraph had only a single fly + // (as-character-anchored), and the height of that was smallar than the + // paragraph height. When in Word-compat mode, we should take the max of + // the two, not just the height of the fly. + + // create xml writer + xmlBufferPtr pXmlBuffer = xmlBufferCreate(); + xmlTextWriterPtr pXmlWriter = xmlNewTextWriterMemory(pXmlBuffer, 0); + xmlTextWriterStartDocument(pXmlWriter, NULL, NULL, NULL); + + // create dump + load("n757905.doc"); + SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + SwDoc* pDoc = pTxtDoc->GetDocShell()->GetDoc(); + SwRootFrm* pLayout = pDoc->GetCurrentLayout(); + pLayout->dumpAsXml(pXmlWriter); + + // delete xml writer + xmlTextWriterEndDocument(pXmlWriter); + xmlFreeTextWriter(pXmlWriter); + + // parse the dump + xmlDocPtr pXmlDoc = xmlParseMemory((const char*)xmlBufferContent(pXmlBuffer), xmlBufferLength(pXmlBuffer));; + xmlXPathContextPtr pXmlXpathCtx = xmlXPathNewContext(pXmlDoc); + xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST("/root/page/body/txt/infos/bounds"), pXmlXpathCtx); + xmlNodeSetPtr pXmlNodes = pXmlXpathObj->nodesetval; + xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0]; + OUString aHeight = OUString::createFromAscii((const char*)xmlGetProp(pXmlNode, BAD_CAST("height"))); + CPPUNIT_ASSERT(sal_Int32(31) < aHeight.toInt32()); + + // delete dump + xmlFreeDoc(pXmlDoc); + xmlBufferFree(pXmlBuffer); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); |