summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-06-11 09:13:58 +0100
committerMiklos Vajna <vmiklos@suse.cz>2012-06-11 09:18:32 +0200
commitcb03de1c9e6f50fe1f6bf0b7c69c446020bab1d2 (patch)
treeda52e6a48e35d3393bc6deff0fd26e559195319d /sw
parentd3f063cc86b50ac9adf08eb46dd2caf7975ed43c (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')
-rw-r--r--sw/CppunitTest_sw_subsequent_ww8tok.mk11
-rw-r--r--sw/qa/extras/ww8tok/data/n757905.docbin0 -> 28160 bytes
-rw-r--r--sw/qa/extras/ww8tok/ww8tok.cxx47
3 files changed, 58 insertions, 0 deletions
diff --git a/sw/CppunitTest_sw_subsequent_ww8tok.mk b/sw/CppunitTest_sw_subsequent_ww8tok.mk
index 80e00891f266..893f4a40e87c 100644
--- a/sw/CppunitTest_sw_subsequent_ww8tok.mk
+++ b/sw/CppunitTest_sw_subsequent_ww8tok.mk
@@ -39,9 +39,20 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_subsequent_ww8tok, \
sal \
test \
unotest \
+ sw \
$(gb_STDLIBS) \
))
+$(eval $(call gb_CppunitTest_use_externals,sw_subsequent_ww8tok,\
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_subsequent_ww8tok,\
+ -I$(SRCDIR)/sw/inc \
+ -I$(SRCDIR)/sw/source/core/inc \
+ $$(INCLUDE) \
+))
+
$(eval $(call gb_CppunitTest_use_api,sw_subsequent_ww8tok,\
offapi \
udkapi \
diff --git a/sw/qa/extras/ww8tok/data/n757905.doc b/sw/qa/extras/ww8tok/data/n757905.doc
new file mode 100644
index 000000000000..0fb7b097cd00
--- /dev/null
+++ b/sw/qa/extras/ww8tok/data/n757905.doc
Binary files differ
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();