diff options
author | László Németh <nemeth@numbertext.org> | 2018-02-07 11:26:36 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2018-02-09 23:31:23 +0100 |
commit | 48cf115778b29ab916dd884d0bfcfeffd03e7603 (patch) | |
tree | 8c745ec3a08f85fcc830e339669b377bc7bbe91f | |
parent | 05e3feb495ff3078c80b1af6aad7c33ac5340b01 (diff) |
tdf#115319 unit test for references with Hungarian articles
Change-Id: I74b4640eb1845875261b7858cef4bdc059608d69
Reviewed-on: https://gerrit.libreoffice.org/48945
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r-- | sw/qa/extras/odfexport/data/referencelanguage.odt | bin | 0 -> 17461 bytes | |||
-rw-r--r-- | sw/qa/extras/odfexport/odfexport.cxx | 33 |
2 files changed, 33 insertions, 0 deletions
diff --git a/sw/qa/extras/odfexport/data/referencelanguage.odt b/sw/qa/extras/odfexport/data/referencelanguage.odt Binary files differnew file mode 100644 index 000000000000..dcdd626fe3cf --- /dev/null +++ b/sw/qa/extras/odfexport/data/referencelanguage.odt diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 4051d31349d5..c0ca863162c4 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -1877,6 +1877,39 @@ DECLARE_ODFEXPORT_TEST(testTdf77961, "tdf77961.odt") CPPUNIT_ASSERT_EQUAL( false , getProperty<bool>(xStyle, "GridPrint")); } +DECLARE_ODFEXPORT_TEST(testReferenceLanguage, "referencelanguage.odt") +{ + // Test loext:reference-language attribute of reference fields + // (used from LibreOffice 6.1, and proposed for next ODF) + const char* aFieldTexts[] = { "A 2", "Az 50-esek", + "A 2018-asok", "Az egyebek", "A fejezetek", + u8"Az „Őseinket...”", "a 2", + "Az v", "az 1", "Az e", "az 1", + "Az (5)", "az 1", "A 2", "az 1" }; + uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + // update "A (4)" to "Az (5)" + uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY)->refresh(); + + uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); + uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); + + uno::Any aHu = uno::makeAny(OUString("Hu")); + uno::Any ahu = uno::makeAny(OUString("hu")); + for (sal_uInt32 i = 0; i < SAL_N_ELEMENTS(aFieldTexts); i++) + { + uno::Any aField = xFields->nextElement(); + uno::Reference<lang::XServiceInfo> xServiceInfo(aField, uno::UNO_QUERY); + if (xServiceInfo->supportsService("com.sun.star.text.textfield.GetReference")) + { + uno::Reference<beans::XPropertySet> xPropertySet(aField, uno::UNO_QUERY); + uno::Any aLang = xPropertySet->getPropertyValue("ReferenceFieldLanguage"); + CPPUNIT_ASSERT_EQUAL(true, aLang == aHu || aLang == ahu); + uno::Reference<text::XTextContent> xField(aField, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(aFieldTexts[i]), xField->getAnchor()->getString()); + } + } +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); |