summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2017-04-21 12:12:37 +0200
committerJan Holesovsky <kendy@collabora.com>2017-04-21 12:28:10 +0200
commit26930dfffe791de7d0c88d1a6dcb15498d6f6883 (patch)
tree3dac3573cca90dccf12eb3601ff8ee545830c5ff
parent24fee4879c0df4fb88fad8de4f7d62598888aafe (diff)
related tdf#68604: Unit test for writing the plaintext annotations in DOCX.
Change-Id: I8c747e72ca96ffd097c92326210c39740102ec79
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index e9513d1bbf06..bb6c069d7192 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -234,6 +234,7 @@ public:
void testTdf105625();
void testTdf106736();
void testMsWordCompTrailingBlanks();
+ void testCreateDocxAnnotation();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -359,6 +360,7 @@ public:
CPPUNIT_TEST(testTdf105625);
CPPUNIT_TEST(testTdf106736);
CPPUNIT_TEST(testMsWordCompTrailingBlanks);
+ CPPUNIT_TEST(testCreateDocxAnnotation);
CPPUNIT_TEST_SUITE_END();
private:
@@ -4555,6 +4557,32 @@ void SwUiWriterTest::testMsWordCompTrailingBlanks()
CPPUNIT_ASSERT_EQUAL( true, pDoc->getIDocumentSettingAccess().get( DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS ) );
}
+void SwUiWriterTest::testCreateDocxAnnotation()
+{
+ createDoc();
+
+ // insert an annotation with a text
+ const OUString aSomeText("some text");
+ uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence(
+ {
+ {"Text", uno::makeAny(aSomeText)},
+ {"Author", uno::makeAny(OUString("me"))},
+ });
+ lcl_dispatchCommand(mxComponent, ".uno:InsertAnnotation", aPropertyValues);
+
+ // Save it as DOCX & load it again
+ reload("Office Open XML Text", "create-docx-annotation.docx");
+
+ // get the annotation
+ uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
+ uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+ uno::Reference<beans::XPropertySet> xField(xFields->nextElement(), uno::UNO_QUERY);
+
+ // this was empty insetad of "some text"
+ CPPUNIT_ASSERT_EQUAL(aSomeText, xField->getPropertyValue("Content").get<OUString>());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();