[Libreoffice-commits] core.git: sw/qa
László Németh
nemeth at numbertext.org
Fri Feb 9 22:31:49 UTC 2018
sw/qa/extras/odfexport/data/referencelanguage.odt |binary
sw/qa/extras/odfexport/odfexport.cxx | 33 ++++++++++++++++++++++
2 files changed, 33 insertions(+)
New commits:
commit 48cf115778b29ab916dd884d0bfcfeffd03e7603
Author: László Németh <nemeth at numbertext.org>
Date: Wed Feb 7 11:26:36 2018 +0100
tdf#115319 unit test for references with Hungarian articles
Change-Id: I74b4640eb1845875261b7858cef4bdc059608d69
Reviewed-on: https://gerrit.libreoffice.org/48945
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/qa/extras/odfexport/data/referencelanguage.odt b/sw/qa/extras/odfexport/data/referencelanguage.odt
new file mode 100644
index 000000000000..dcdd626fe3cf
Binary files /dev/null and b/sw/qa/extras/odfexport/data/referencelanguage.odt differ
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();
More information about the Libreoffice-commits
mailing list