[Libreoffice-commits] .: sw/CppunitTest_sw_subsequent_odfexport.mk sw/CppunitTest_sw_subsequent_odfimport.mk sw/CppunitTest_sw_subsequent_ooxmlexport.mk sw/CppunitTest_sw_subsequent_rtfexport.mk sw/CppunitTest_sw_subsequent_ww8export.mk sw/qa

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Nov 18 02:09:42 PST 2012


 sw/CppunitTest_sw_subsequent_odfexport.mk   |    1 
 sw/CppunitTest_sw_subsequent_odfimport.mk   |    1 
 sw/CppunitTest_sw_subsequent_ooxmlexport.mk |    1 
 sw/CppunitTest_sw_subsequent_rtfexport.mk   |    1 
 sw/CppunitTest_sw_subsequent_ww8export.mk   |    1 
 sw/qa/extras/inc/swmodeltestbase.hxx        |  238 ++++++++++++++++++++++++++++
 sw/qa/extras/odfexport/odfexport.cxx        |    3 
 sw/qa/extras/odfimport/odfimport.cxx        |    2 
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx    |    3 
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx    |    7 
 sw/qa/extras/rtfexport/rtfexport.cxx        |    5 
 sw/qa/extras/rtfimport/rtfimport.cxx        |    6 
 sw/qa/extras/swmodeltestbase.hxx            |  238 ----------------------------
 sw/qa/extras/ww8export/ww8export.cxx        |    4 
 sw/qa/extras/ww8import/ww8import.cxx        |    6 
 15 files changed, 258 insertions(+), 259 deletions(-)

New commits:
commit 66d3da3505ef4964be9a4dbe0363af8f0c519270
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Sun Nov 18 11:07:45 2012 +0100

    sw: move swmodeltestbase.hxx to qa/extras/inc/
    
    If we already have such an include dir, let's have all headers there.
    
    Change-Id: I2100b5308e7fdad9d98cfde76434ff485aca20c7

diff --git a/sw/CppunitTest_sw_subsequent_odfexport.mk b/sw/CppunitTest_sw_subsequent_odfexport.mk
index 5149659..64e6318 100644
--- a/sw/CppunitTest_sw_subsequent_odfexport.mk
+++ b/sw/CppunitTest_sw_subsequent_odfexport.mk
@@ -54,6 +54,7 @@ $(eval $(call gb_CppunitTest_use_externals,sw_subsequent_odfexport,\
 $(eval $(call gb_CppunitTest_set_include,sw_subsequent_odfexport,\
     -I$(SRCDIR)/sw/inc \
     -I$(SRCDIR)/sw/source/core/inc \
+    -I$(SRCDIR)/sw/qa/extras/inc \
     $$(INCLUDE) \
 ))
 
diff --git a/sw/CppunitTest_sw_subsequent_odfimport.mk b/sw/CppunitTest_sw_subsequent_odfimport.mk
index 189817e..f7ad4eb 100644
--- a/sw/CppunitTest_sw_subsequent_odfimport.mk
+++ b/sw/CppunitTest_sw_subsequent_odfimport.mk
@@ -53,6 +53,7 @@ $(eval $(call gb_CppunitTest_use_externals,sw_subsequent_odfimport,\
 $(eval $(call gb_CppunitTest_set_include,sw_subsequent_odfimport,\
     -I$(SRCDIR)/sw/inc \
     -I$(SRCDIR)/sw/source/core/inc \
+	-I$(SRCDIR)/sw/qa/extras/inc \
     $$(INCLUDE) \
 ))
 
diff --git a/sw/CppunitTest_sw_subsequent_ooxmlexport.mk b/sw/CppunitTest_sw_subsequent_ooxmlexport.mk
index 288795e..576bb5a 100644
--- a/sw/CppunitTest_sw_subsequent_ooxmlexport.mk
+++ b/sw/CppunitTest_sw_subsequent_ooxmlexport.mk
@@ -54,6 +54,7 @@ $(eval $(call gb_CppunitTest_use_externals,sw_subsequent_ooxmlexport,\
 $(eval $(call gb_CppunitTest_set_include,sw_subsequent_ooxmlexport,\
     -I$(SRCDIR)/sw/inc \
     -I$(SRCDIR)/sw/source/core/inc \
+	-I$(SRCDIR)/sw/qa/extras/inc \
     $$(INCLUDE) \
 ))
 
diff --git a/sw/CppunitTest_sw_subsequent_rtfexport.mk b/sw/CppunitTest_sw_subsequent_rtfexport.mk
index f5ac911..a214830 100644
--- a/sw/CppunitTest_sw_subsequent_rtfexport.mk
+++ b/sw/CppunitTest_sw_subsequent_rtfexport.mk
@@ -53,6 +53,7 @@ $(eval $(call gb_CppunitTest_use_externals,sw_subsequent_rtfexport,\
 $(eval $(call gb_CppunitTest_set_include,sw_subsequent_rtfexport,\
     -I$(SRCDIR)/sw/inc \
     -I$(SRCDIR)/sw/source/core/inc \
+	-I$(SRCDIR)/sw/qa/extras/inc \
     $$(INCLUDE) \
 ))
 
diff --git a/sw/CppunitTest_sw_subsequent_ww8export.mk b/sw/CppunitTest_sw_subsequent_ww8export.mk
index 68fd485..340afec 100644
--- a/sw/CppunitTest_sw_subsequent_ww8export.mk
+++ b/sw/CppunitTest_sw_subsequent_ww8export.mk
@@ -54,6 +54,7 @@ $(eval $(call gb_CppunitTest_use_externals,sw_subsequent_ww8export,\
 $(eval $(call gb_CppunitTest_set_include,sw_subsequent_ww8export,\
     -I$(SRCDIR)/sw/inc \
     -I$(SRCDIR)/sw/source/core/inc \
+	-I$(SRCDIR)/sw/qa/extras/inc \
     $$(INCLUDE) \
 ))
 
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
new file mode 100644
index 0000000..2a7f4d6
--- /dev/null
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -0,0 +1,238 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Miklos Vajna <vmiklos at suse.cz> (SUSE, Inc.)
+ * Portions created by the Initial Developer are Copyright (C) 2012 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+
+#include <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+#include <rtl/ustrbuf.hxx>
+
+#include <unotxdoc.hxx>
+#include <docsh.hxx>
+#include <doc.hxx>
+#include <rootfrm.hxx>
+
+#include <libxml/xmlwriter.h>
+#include <libxml/xpath.h>
+
+using namespace com::sun::star;
+
+/// Base class for filter tests loading or roundtriping a document, then asserting the document model.
+class SwModelTestBase : public test::BootstrapFixture, public unotest::MacrosTest
+{
+public:
+    SwModelTestBase()
+        : mpXmlBuffer(0)
+    {
+    }
+
+    ~SwModelTestBase()
+    {
+        if (mpXmlBuffer)
+            xmlBufferFree(mpXmlBuffer);
+    }
+
+    virtual void setUp()
+    {
+        test::BootstrapFixture::setUp();
+
+        mxDesktop.set(getMultiServiceFactory()->createInstance("com.sun.star.frame.Desktop"), uno::UNO_QUERY);
+        CPPUNIT_ASSERT(mxDesktop.is());
+    }
+
+    virtual void tearDown()
+    {
+        if (mxComponent.is())
+            mxComponent->dispose();
+
+        test::BootstrapFixture::tearDown();
+    }
+
+private:
+    void dumpLayout()
+    {
+        // create the xml writer
+        mpXmlBuffer = xmlBufferCreate();
+        xmlTextWriterPtr pXmlWriter = xmlNewTextWriterMemory(mpXmlBuffer, 0);
+        xmlTextWriterStartDocument(pXmlWriter, NULL, NULL, NULL);
+
+        // create the dump
+        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);
+    }
+
+
+protected:
+    /// Get the length of the whole document.
+    int getLength()
+    {
+        uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+        uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
+        uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+        OUStringBuffer aBuf;
+        while (xParaEnum->hasMoreElements())
+        {
+            uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
+            uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration();
+            while (xRangeEnum->hasMoreElements())
+            {
+                uno::Reference<text::XTextRange> xRange(xRangeEnum->nextElement(), uno::UNO_QUERY);
+                aBuf.append(xRange->getString());
+            }
+        }
+        return aBuf.getLength();
+    }
+
+    /// Get a family of styles, see com.sun.star.style.StyleFamilies for possible values.
+    uno::Reference<container::XNameAccess> getStyles(OUString aFamily)
+    {
+        uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent, uno::UNO_QUERY);
+        uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
+        uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName(aFamily), uno::UNO_QUERY);
+        return xStyleFamily;
+    }
+
+    /**
+     * Extract a value from the layout dump using an XPath expression and an attribute name.
+     *
+     * If the attribute is omitted, the text of the node is returned.
+     */
+    OUString parseDump(rtl::OString aXPath, rtl::OString aAttribute = OString())
+    {
+        if (!mpXmlBuffer)
+            dumpLayout();
+
+        xmlDocPtr pXmlDoc = xmlParseMemory((const char*)xmlBufferContent(mpXmlBuffer), xmlBufferLength(mpXmlBuffer));;
+
+        xmlXPathContextPtr pXmlXpathCtx = xmlXPathNewContext(pXmlDoc);
+        xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(aXPath.getStr()), pXmlXpathCtx);
+        xmlNodeSetPtr pXmlNodes = pXmlXpathObj->nodesetval;
+        CPPUNIT_ASSERT_EQUAL(1, xmlXPathNodeSetGetLength(pXmlNodes));
+        xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
+        OUString aRet;
+        if (aAttribute.getLength())
+            aRet = OUString::createFromAscii((const char*)xmlGetProp(pXmlNode, BAD_CAST(aAttribute.getStr())));
+        else
+            aRet = OUString::createFromAscii((const char*)XML_GET_CONTENT(pXmlNode));
+
+        xmlFreeDoc(pXmlDoc);
+
+        return aRet;
+    }
+
+    template< typename T >
+    T getProperty( uno::Any obj, const OUString& name ) const
+    {
+        uno::Reference< beans::XPropertySet > properties( obj, uno::UNO_QUERY );
+        T data = T();
+        properties->getPropertyValue( name ) >>= data;
+        return data;
+    }
+
+    template< typename T >
+    T getProperty( uno::Reference< uno::XInterface > obj, const OUString& name ) const
+    {
+        uno::Reference< beans::XPropertySet > properties( obj, uno::UNO_QUERY );
+        T data = T();
+        properties->getPropertyValue( name ) >>= data;
+        return data;
+    }
+
+    /// Get number of paragraphs of the document.
+    int getParagraphs()
+    {
+        uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+        uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
+        uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+        int nRet = 0;
+        while (xParaEnum->hasMoreElements())
+        {
+            xParaEnum->nextElement();
+            nRet++;
+        }
+        return nRet;
+    }
+
+    // Get paragraph (counted from 1), optionally check it contains the given text.
+    uno::Reference< text::XTextRange > getParagraph( int number, OUString content = OUString() ) const
+    {
+        uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
+        uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY);
+        uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
+        for( int i = 1;
+             i < number;
+             ++i )
+            paraEnum->nextElement();
+        uno::Reference< text::XTextRange > paragraph( paraEnum->nextElement(), uno::UNO_QUERY );
+        if( !content.isEmpty())
+            CPPUNIT_ASSERT_EQUAL( content, paragraph->getString());
+        return paragraph;
+    }
+
+    /// Get run (counted from 1) of a paragraph, optionally check it contains the given text.
+    uno::Reference<text::XTextRange> getRun(uno::Reference<text::XTextRange> xParagraph, int number, OUString content = OUString()) const
+    {
+        uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY);
+        uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
+        for (int i = 1; i < number; ++i)
+            xRunEnum->nextElement();
+        uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
+        if( !content.isEmpty())
+            CPPUNIT_ASSERT_EQUAL( content, xRun->getString());
+        return xRun;
+    }
+
+    /// Get math formula string of a run.
+    OUString getFormula(uno::Reference<text::XTextRange> xRun) const
+    {
+        uno::Reference<container::XContentEnumerationAccess> xContentEnumAccess(xRun, uno::UNO_QUERY);
+        uno::Reference<container::XEnumeration> xContentEnum(xContentEnumAccess->createContentEnumeration(""), uno::UNO_QUERY);
+        uno::Reference<beans::XPropertySet> xFormula(xContentEnum->nextElement(), uno::UNO_QUERY);
+        return getProperty<OUString>(getProperty< uno::Reference<beans::XPropertySet> >(xFormula, "Model"), "Formula");
+    }
+
+    uno::Reference<lang::XComponent> mxComponent;
+    xmlBufferPtr mpXmlBuffer;
+
+    template< typename T >
+    struct MethodEntry
+    {
+        const char* pName;
+        void (T::*pMethod)();
+    };
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 7964ea9..7d93b3b 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -25,9 +25,8 @@
  * instead of those above.
  */
 
-#include "../swmodeltestbase.hxx"
-
 #include <unotools/tempfile.hxx>
+#include <swmodeltestbase.hxx>
 
 class Test : public SwModelTestBase
 {
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index 2332826..05584bf 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -25,10 +25,10 @@
  * instead of those above.
  */
 
-#include "../swmodeltestbase.hxx"
 #include <com/sun/star/table/XCell.hpp>
 #include <com/sun/star/table/BorderLine.hpp>
 #include <com/sun/star/text/XTextTable.hpp>
+#include <swmodeltestbase.hxx>
 
 typedef std::map<OUString, com::sun::star::uno::Sequence< com::sun::star::table::BorderLine> > AllBordersMap;
 typedef std::pair<OUString, com::sun::star::uno::Sequence< com::sun::star::table::BorderLine> > StringSequencePair;
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 8fe1985..e578be8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -25,8 +25,6 @@
  * instead of those above.
  */
 
-#include "../swmodeltestbase.hxx"
-
 #include <com/sun/star/frame/XStorable.hpp>
 #include <com/sun/star/style/TabStop.hpp>
 #include <com/sun/star/view/XViewSettingsSupplier.hpp>
@@ -39,6 +37,7 @@
 #include <com/sun/star/table/BorderLine2.hpp>
 
 #include <unotools/tempfile.hxx>
+#include <swmodeltestbase.hxx>
 
 class Test : public SwModelTestBase
 {
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index a36bdb7..2c98832 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -25,9 +25,6 @@
  * instead of those above.
  */
 
-#include "../swmodeltestbase.hxx"
-#include "bordertest.hxx"
-
 #include <com/sun/star/awt/XBitmap.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
@@ -54,9 +51,11 @@
 #include <com/sun/star/view/XSelectionSupplier.hpp>
 #include <com/sun/star/table/BorderLine2.hpp>
 
-
 #include <vcl/svapp.hxx>
 
+#include <swmodeltestbase.hxx>
+#include <bordertest.hxx>
+
 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
 
 class Test : public SwModelTestBase
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index de5bfe6..c2d8830 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -25,8 +25,6 @@
  * instead of those above.
  */
 
-#include "../swmodeltestbase.hxx"
-
 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
 #include <com/sun/star/frame/XStorable.hpp>
@@ -36,8 +34,7 @@
 
 #include <unotools/tempfile.hxx>
 #include <vcl/svapp.hxx>
-
-using rtl::OUStringBuffer;
+#include <swmodeltestbase.hxx>
 
 class Test : public SwModelTestBase
 {
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index c8eec60..e114af2 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -25,9 +25,6 @@
  * instead of those above.
  */
 
-#include "../swmodeltestbase.hxx"
-#include "bordertest.hxx"
-
 #include <com/sun/star/document/XFilter.hpp>
 #include <com/sun/star/document/XImporter.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
@@ -61,6 +58,9 @@
 #include <unotools/ucbstreamhelper.hxx>
 #include <unotools/streamwrap.hxx>
 
+#include <swmodeltestbase.hxx>
+#include <bordertest.hxx>
+
 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
 
 class Test : public SwModelTestBase
diff --git a/sw/qa/extras/swmodeltestbase.hxx b/sw/qa/extras/swmodeltestbase.hxx
deleted file mode 100644
index 2a7f4d6..0000000
--- a/sw/qa/extras/swmodeltestbase.hxx
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Initial Developer of the Original Code is
- *       Miklos Vajna <vmiklos at suse.cz> (SUSE, Inc.)
- * Portions created by the Initial Developer are Copyright (C) 2012 the
- * Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <com/sun/star/container/XContentEnumerationAccess.hpp>
-#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
-#include <com/sun/star/text/XTextDocument.hpp>
-#include <com/sun/star/text/XTextRange.hpp>
-
-#include <test/bootstrapfixture.hxx>
-#include <unotest/macros_test.hxx>
-#include <rtl/ustrbuf.hxx>
-
-#include <unotxdoc.hxx>
-#include <docsh.hxx>
-#include <doc.hxx>
-#include <rootfrm.hxx>
-
-#include <libxml/xmlwriter.h>
-#include <libxml/xpath.h>
-
-using namespace com::sun::star;
-
-/// Base class for filter tests loading or roundtriping a document, then asserting the document model.
-class SwModelTestBase : public test::BootstrapFixture, public unotest::MacrosTest
-{
-public:
-    SwModelTestBase()
-        : mpXmlBuffer(0)
-    {
-    }
-
-    ~SwModelTestBase()
-    {
-        if (mpXmlBuffer)
-            xmlBufferFree(mpXmlBuffer);
-    }
-
-    virtual void setUp()
-    {
-        test::BootstrapFixture::setUp();
-
-        mxDesktop.set(getMultiServiceFactory()->createInstance("com.sun.star.frame.Desktop"), uno::UNO_QUERY);
-        CPPUNIT_ASSERT(mxDesktop.is());
-    }
-
-    virtual void tearDown()
-    {
-        if (mxComponent.is())
-            mxComponent->dispose();
-
-        test::BootstrapFixture::tearDown();
-    }
-
-private:
-    void dumpLayout()
-    {
-        // create the xml writer
-        mpXmlBuffer = xmlBufferCreate();
-        xmlTextWriterPtr pXmlWriter = xmlNewTextWriterMemory(mpXmlBuffer, 0);
-        xmlTextWriterStartDocument(pXmlWriter, NULL, NULL, NULL);
-
-        // create the dump
-        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);
-    }
-
-
-protected:
-    /// Get the length of the whole document.
-    int getLength()
-    {
-        uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
-        uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
-        uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
-        OUStringBuffer aBuf;
-        while (xParaEnum->hasMoreElements())
-        {
-            uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
-            uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration();
-            while (xRangeEnum->hasMoreElements())
-            {
-                uno::Reference<text::XTextRange> xRange(xRangeEnum->nextElement(), uno::UNO_QUERY);
-                aBuf.append(xRange->getString());
-            }
-        }
-        return aBuf.getLength();
-    }
-
-    /// Get a family of styles, see com.sun.star.style.StyleFamilies for possible values.
-    uno::Reference<container::XNameAccess> getStyles(OUString aFamily)
-    {
-        uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent, uno::UNO_QUERY);
-        uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
-        uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName(aFamily), uno::UNO_QUERY);
-        return xStyleFamily;
-    }
-
-    /**
-     * Extract a value from the layout dump using an XPath expression and an attribute name.
-     *
-     * If the attribute is omitted, the text of the node is returned.
-     */
-    OUString parseDump(rtl::OString aXPath, rtl::OString aAttribute = OString())
-    {
-        if (!mpXmlBuffer)
-            dumpLayout();
-
-        xmlDocPtr pXmlDoc = xmlParseMemory((const char*)xmlBufferContent(mpXmlBuffer), xmlBufferLength(mpXmlBuffer));;
-
-        xmlXPathContextPtr pXmlXpathCtx = xmlXPathNewContext(pXmlDoc);
-        xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(aXPath.getStr()), pXmlXpathCtx);
-        xmlNodeSetPtr pXmlNodes = pXmlXpathObj->nodesetval;
-        CPPUNIT_ASSERT_EQUAL(1, xmlXPathNodeSetGetLength(pXmlNodes));
-        xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
-        OUString aRet;
-        if (aAttribute.getLength())
-            aRet = OUString::createFromAscii((const char*)xmlGetProp(pXmlNode, BAD_CAST(aAttribute.getStr())));
-        else
-            aRet = OUString::createFromAscii((const char*)XML_GET_CONTENT(pXmlNode));
-
-        xmlFreeDoc(pXmlDoc);
-
-        return aRet;
-    }
-
-    template< typename T >
-    T getProperty( uno::Any obj, const OUString& name ) const
-    {
-        uno::Reference< beans::XPropertySet > properties( obj, uno::UNO_QUERY );
-        T data = T();
-        properties->getPropertyValue( name ) >>= data;
-        return data;
-    }
-
-    template< typename T >
-    T getProperty( uno::Reference< uno::XInterface > obj, const OUString& name ) const
-    {
-        uno::Reference< beans::XPropertySet > properties( obj, uno::UNO_QUERY );
-        T data = T();
-        properties->getPropertyValue( name ) >>= data;
-        return data;
-    }
-
-    /// Get number of paragraphs of the document.
-    int getParagraphs()
-    {
-        uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
-        uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
-        uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
-        int nRet = 0;
-        while (xParaEnum->hasMoreElements())
-        {
-            xParaEnum->nextElement();
-            nRet++;
-        }
-        return nRet;
-    }
-
-    // Get paragraph (counted from 1), optionally check it contains the given text.
-    uno::Reference< text::XTextRange > getParagraph( int number, OUString content = OUString() ) const
-    {
-        uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
-        uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY);
-        uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
-        for( int i = 1;
-             i < number;
-             ++i )
-            paraEnum->nextElement();
-        uno::Reference< text::XTextRange > paragraph( paraEnum->nextElement(), uno::UNO_QUERY );
-        if( !content.isEmpty())
-            CPPUNIT_ASSERT_EQUAL( content, paragraph->getString());
-        return paragraph;
-    }
-
-    /// Get run (counted from 1) of a paragraph, optionally check it contains the given text.
-    uno::Reference<text::XTextRange> getRun(uno::Reference<text::XTextRange> xParagraph, int number, OUString content = OUString()) const
-    {
-        uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY);
-        uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
-        for (int i = 1; i < number; ++i)
-            xRunEnum->nextElement();
-        uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
-        if( !content.isEmpty())
-            CPPUNIT_ASSERT_EQUAL( content, xRun->getString());
-        return xRun;
-    }
-
-    /// Get math formula string of a run.
-    OUString getFormula(uno::Reference<text::XTextRange> xRun) const
-    {
-        uno::Reference<container::XContentEnumerationAccess> xContentEnumAccess(xRun, uno::UNO_QUERY);
-        uno::Reference<container::XEnumeration> xContentEnum(xContentEnumAccess->createContentEnumeration(""), uno::UNO_QUERY);
-        uno::Reference<beans::XPropertySet> xFormula(xContentEnum->nextElement(), uno::UNO_QUERY);
-        return getProperty<OUString>(getProperty< uno::Reference<beans::XPropertySet> >(xFormula, "Model"), "Formula");
-    }
-
-    uno::Reference<lang::XComponent> mxComponent;
-    xmlBufferPtr mpXmlBuffer;
-
-    template< typename T >
-    struct MethodEntry
-    {
-        const char* pName;
-        void (T::*pMethod)();
-    };
-};
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index 7a205f1..679f765 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -25,8 +25,6 @@
  * instead of those above.
  */
 
-#include "../swmodeltestbase.hxx"
-
 #include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
 #include <com/sun/star/frame/XStorable.hpp>
 #include <com/sun/star/drawing/XControlShape.hpp>
@@ -35,6 +33,8 @@
 
 #include <unotools/tempfile.hxx>
 
+#include <swmodeltestbase.hxx>
+
 class Test : public SwModelTestBase
 {
 public:
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index 13fea52..b47e525 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -25,9 +25,6 @@
  * instead of those above.
  */
 
-#include "../swmodeltestbase.hxx"
-#include "bordertest.hxx"
-
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/table/BorderLine2.hpp>
 #include <com/sun/star/table/TableBorder.hpp>
@@ -37,6 +34,9 @@
 
 #include <vcl/svapp.hxx>
 
+#include <swmodeltestbase.hxx>
+#include <bordertest.hxx>
+
 class Test : public SwModelTestBase
 {
 public:


More information about the Libreoffice-commits mailing list