[Libreoffice-commits] .: sw/qa

Miklos Vajna vmiklos at kemper.freedesktop.org
Fri Apr 6 07:58:17 PDT 2012


 sw/qa/extras/ooxmltok/data/n751017.docx |binary
 sw/qa/extras/ooxmltok/ooxmltok.cxx      |   52 ++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

New commits:
commit 46e7e5a505ddc2933316ba1d42895155a26e8b67
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Apr 6 16:55:34 2012 +0200

    n#751017 testcase

diff --git a/sw/qa/extras/ooxmltok/data/n751017.docx b/sw/qa/extras/ooxmltok/data/n751017.docx
new file mode 100644
index 0000000..cdd81cf
Binary files /dev/null and b/sw/qa/extras/ooxmltok/data/n751017.docx differ
diff --git a/sw/qa/extras/ooxmltok/ooxmltok.cxx b/sw/qa/extras/ooxmltok/ooxmltok.cxx
index 364d66d..5beb577 100644
--- a/sw/qa/extras/ooxmltok/ooxmltok.cxx
+++ b/sw/qa/extras/ooxmltok/ooxmltok.cxx
@@ -28,7 +28,10 @@
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/text/SetVariableType.hpp>
 #include <com/sun/star/text/TextContentAnchorType.hpp>
+#include <com/sun/star/text/XDependentTextField.hpp>
+#include <com/sun/star/text/XTextFieldsSupplier.hpp>
 
 #include <test/bootstrapfixture.hxx>
 #include <unotest/macros_test.hxx>
@@ -46,11 +49,13 @@ public:
     virtual void tearDown();
     void testN751054();
     void testN751117();
+    void testN751017();
 
     CPPUNIT_TEST_SUITE(OoxmlModelTest);
 #if !defined(MACOSX) && !defined(WNT)
     CPPUNIT_TEST(testN751054);
     CPPUNIT_TEST(testN751117);
+    CPPUNIT_TEST(testN751017);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -119,6 +124,53 @@ void OoxmlModelTest::testN751117()
     CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.drawing.LineShape"));
 }
 
+void OoxmlModelTest::testN751017()
+{
+    load("n751017.docx");
+    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XNameAccess> xMasters(xTextFieldsSupplier->getTextFieldMasters());
+    // Make sure we have a variable named foo.
+    CPPUNIT_ASSERT(xMasters->hasByName("com.sun.star.text.FieldMaster.SetExpression.foo"));
+
+    uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
+    uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+    bool bFoundSet(false), bFoundGet(false);
+    while (xFields->hasMoreElements())
+    {
+        uno::Reference<lang::XServiceInfo> xServiceInfo(xFields->nextElement(), uno::UNO_QUERY);
+        uno::Reference<beans::XPropertySet> xPropertySet(xServiceInfo, uno::UNO_QUERY);
+        sal_Int16 nValue = 0;
+        OUString aValue;
+        if (xServiceInfo->supportsService("com.sun.star.text.TextField.SetExpression"))
+        {
+            bFoundSet = true;
+            uno::Reference<text::XDependentTextField> xDependentTextField(xServiceInfo, uno::UNO_QUERY);
+            uno::Reference<beans::XPropertySet> xMasterProps(xDependentTextField->getTextFieldMaster());
+
+            // First step: did we set foo to "bar"?
+            xMasterProps->getPropertyValue("Name") >>= aValue;
+            CPPUNIT_ASSERT_EQUAL(OUString("foo"), aValue);
+            xPropertySet->getPropertyValue("SubType") >>= nValue;
+            CPPUNIT_ASSERT_EQUAL(text::SetVariableType::STRING, nValue);
+            xPropertySet->getPropertyValue("Content") >>= aValue;
+            CPPUNIT_ASSERT_EQUAL(OUString("bar"), aValue);
+        }
+        else if (xServiceInfo->supportsService("com.sun.star.text.TextField.GetExpression"))
+        {
+            // Second step: check the value of foo.
+            bFoundGet = true;
+            xPropertySet->getPropertyValue("Content") >>= aValue;
+            CPPUNIT_ASSERT_EQUAL(OUString("foo"), aValue);
+            xPropertySet->getPropertyValue("SubType") >>= nValue;
+            CPPUNIT_ASSERT_EQUAL(text::SetVariableType::STRING, nValue);
+            xPropertySet->getPropertyValue("CurrentPresentation") >>= aValue;
+            CPPUNIT_ASSERT_EQUAL(OUString("bar"), aValue);
+        }
+    }
+    CPPUNIT_ASSERT(bFoundSet);
+    CPPUNIT_ASSERT(bFoundGet);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(OoxmlModelTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list