diff options
Diffstat (limited to 'sw/qa/extras/odfexport/odfexport.cxx')
-rw-r--r-- | sw/qa/extras/odfexport/odfexport.cxx | 33 |
1 files changed, 33 insertions, 0 deletions
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(); |