From 46e7e5a505ddc2933316ba1d42895155a26e8b67 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 6 Apr 2012 16:55:34 +0200 Subject: n#751017 testcase --- sw/qa/extras/ooxmltok/data/n751017.docx | Bin 0 -> 10194 bytes sw/qa/extras/ooxmltok/ooxmltok.cxx | 52 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 sw/qa/extras/ooxmltok/data/n751017.docx (limited to 'sw') diff --git a/sw/qa/extras/ooxmltok/data/n751017.docx b/sw/qa/extras/ooxmltok/data/n751017.docx new file mode 100644 index 000000000000..cdd81cf84ddb 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 364d66d59a43..5beb57735f9d 100644 --- a/sw/qa/extras/ooxmltok/ooxmltok.cxx +++ b/sw/qa/extras/ooxmltok/ooxmltok.cxx @@ -28,7 +28,10 @@ #include #include #include +#include #include +#include +#include #include #include @@ -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 xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xMasters(xTextFieldsSupplier->getTextFieldMasters()); + // Make sure we have a variable named foo. + CPPUNIT_ASSERT(xMasters->hasByName("com.sun.star.text.FieldMaster.SetExpression.foo")); + + uno::Reference xFieldsAccess(xTextFieldsSupplier->getTextFields()); + uno::Reference xFields(xFieldsAccess->createEnumeration()); + bool bFoundSet(false), bFoundGet(false); + while (xFields->hasMoreElements()) + { + uno::Reference xServiceInfo(xFields->nextElement(), uno::UNO_QUERY); + uno::Reference xPropertySet(xServiceInfo, uno::UNO_QUERY); + sal_Int16 nValue = 0; + OUString aValue; + if (xServiceInfo->supportsService("com.sun.star.text.TextField.SetExpression")) + { + bFoundSet = true; + uno::Reference xDependentTextField(xServiceInfo, uno::UNO_QUERY); + uno::Reference 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(); -- cgit