[Libreoffice-commits] .: sw/CppunitTest_sw_subsequent_ww8tok.mk sw/qa

Miklos Vajna vmiklos at kemper.freedesktop.org
Mon Jun 11 00:18:36 PDT 2012


 sw/CppunitTest_sw_subsequent_ww8tok.mk |   11 +++++++
 sw/qa/extras/ww8tok/data/n757905.doc   |binary
 sw/qa/extras/ww8tok/ww8tok.cxx         |   47 +++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+)

New commits:
commit cb03de1c9e6f50fe1f6bf0b7c69c446020bab1d2
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Jun 11 09:13:58 2012 +0100

    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

diff --git a/sw/CppunitTest_sw_subsequent_ww8tok.mk b/sw/CppunitTest_sw_subsequent_ww8tok.mk
index 80e0089..893f4a4 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 0000000..0fb7b09
Binary files /dev/null and b/sw/qa/extras/ww8tok/data/n757905.doc differ
diff --git a/sw/qa/extras/ww8tok/ww8tok.cxx b/sw/qa/extras/ww8tok/ww8tok.cxx
index 08c77c0..a63ff14 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();


More information about the Libreoffice-commits mailing list