26#include <com/sun/star/uno/Any.hxx>
27#include <com/sun/star/lang/Locale.hpp>
51 lang::Locale aLocale1, aLocale2;
53 if( ( r1 >>= aLocale1 ) && ( r2 >>= aLocale2 ) )
55 bool bEmptyOrScriptVariant1 = (aLocale1.Variant.isEmpty() || aLocale1.Variant[0] ==
'-');
56 bool bEmptyOrScriptVariant2 = (aLocale2.Variant.isEmpty() || aLocale2.Variant[0] ==
'-');
57 if (bEmptyOrScriptVariant1 && bEmptyOrScriptVariant2)
58 bRet = ( aLocale1.Language == aLocale2.Language );
61 OUString aLanguage1, aLanguage2;
62 if (bEmptyOrScriptVariant1)
63 aLanguage1 = aLocale1.Language;
66 if (bEmptyOrScriptVariant2)
67 aLanguage2 = aLocale2.Language;
70 bRet = ( aLanguage1 == aLanguage2 );
84 if (aLocale.Variant.isEmpty())
85 aLocale.Language = rStrImpValue;
88 if (!aLocale.Language.isEmpty() || aLocale.Variant[0] !=
'-')
91 "XMLCharLanguageHdl::importXML - attempt to import language twice");
95 aLocale.Variant = rStrImpValue + aLocale.Variant;
96 if (!aLocale.Country.isEmpty())
97 aLocale.Variant +=
"-" + aLocale.Country;
109 lang::Locale aLocale;
110 if(!(rValue >>= aLocale))
113 if (aLocale.Variant.isEmpty())
114 rStrExpValue = aLocale.Language;
118 OUString aScript, aCountry;
123 if (rStrExpValue.isEmpty())
127 if( rStrExpValue.isEmpty() )
141 lang::Locale aLocale1, aLocale2;
143 if( ( r1 >>= aLocale1 ) && ( r2 >>= aLocale2 ) )
145 bool bEmptyVariant1 = aLocale1.Variant.isEmpty();
146 bool bEmptyVariant2 = aLocale2.Variant.isEmpty();
147 if (bEmptyVariant1 && bEmptyVariant2)
149 else if (bEmptyVariant1 != bEmptyVariant2)
153 OUString aScript1, aScript2;
154 if (aLocale1.Variant[0] ==
'-')
155 aScript1 = aLocale1.Variant.copy(1);
158 if (aLocale2.Variant[0] ==
'-')
159 aScript2 = aLocale2.Variant.copy(1);
162 bRet = ( aScript1 == aScript2 );
171 lang::Locale aLocale;
178 if (aLocale.Variant.isEmpty())
180 if (aLocale.Language.isEmpty())
182 SAL_INFO(
"xmloff.style",
"XMLCharScriptHdl::importXML - script but no language yet");
185 aLocale.Variant =
"-" + rStrImpValue;
189 aLocale.Variant = aLocale.Language +
"-" + rStrImpValue;
190 if (!aLocale.Country.isEmpty())
191 aLocale.Variant +=
"-" + aLocale.Country;
195 else if (aLocale.Variant[0] ==
'-')
197 SAL_WARN(
"xmloff.style",
"XMLCharScriptHdl::importXML - attempt to insert script twice: "
198 << rStrImpValue <<
" -> " << aLocale.Variant);
206#if OSL_DEBUG_LEVEL > 0 || defined(DBG_UTIL)
210 SAL_WARN(
"xmloff.style",
"XMLCharScriptHdl::importXML - attempt to insert script over bcp47: "
211 << rStrImpValue <<
" -> " << aLanguageTag.
getBcp47());
224 lang::Locale aLocale;
225 if(!(rValue >>= aLocale))
230 if (aLocale.Variant.isEmpty())
240 OUString aLanguage, aCountry;
245 return !aLanguage.isEmpty() && !rStrExpValue.isEmpty();
256 lang::Locale aLocale1, aLocale2;
258 if( ( r1 >>= aLocale1 ) && ( r2 >>= aLocale2 ) )
259 bRet = ( aLocale1.Country == aLocale2.Country );
266 lang::Locale aLocale;
271 if (aLocale.Country.isEmpty())
273 aLocale.Country = rStrImpValue;
274 if (aLocale.Variant.getLength() >= 7 && aLocale.Language ==
I18NLANGTAG_QLT)
278 sal_Int32
i = aLocale.Variant.indexOf(
'-');
279 if (2 <=
i &&
i < aLocale.Variant.getLength())
281 i = aLocale.Variant.indexOf(
'-',
i+1);
283 aLocale.Variant +=
"-" + rStrImpValue;
295 lang::Locale aLocale;
296 if(!(rValue >>= aLocale))
299 if (aLocale.Variant.isEmpty())
300 rStrExpValue = aLocale.Country;
304 OUString aLanguage, aScript;
309 if (rStrExpValue.isEmpty())
313 if( rStrExpValue.isEmpty() )
327 lang::Locale aLocale1, aLocale2;
329 if( ( r1 >>= aLocale1 ) && ( r2 >>= aLocale2 ) )
330 bRet = ( aLocale1.Variant == aLocale2.Variant );
337 lang::Locale aLocale;
350 if (rStrImpValue.getLength() < 7)
352 SAL_WARN(
"xmloff.style",
"rfc-language-tag too short: {" << rStrImpValue <<
"} Set: "
353 << aLocale.Language <<
","<< aLocale.Country <<
","<< aLocale.Variant);
358 sal_Int32
h = rStrImpValue.indexOf(
'-');
360 if (2 <=
h &&
h <= 3)
361 aLang = rStrImpValue.copy(0,
h);
362 else if (
h < 0 && 2 <= rStrImpValue.getLength() && rStrImpValue.getLength() <= 3)
363 aLang = rStrImpValue;
365 if (!aLang.isEmpty() && aLang.getLength() + 3 == rStrImpValue.getLength())
366 aCoun = rStrImpValue.copy( aLang.getLength() + 1);
368 if ((!aLang.isEmpty() && aLang != aLocale.Language) ||
369 (!aCoun.isEmpty() && aCoun != aLocale.Country))
372 if (aLocale.Language.isEmpty())
373 aLocale.Language = aLang;
374 if (aLocale.Country.isEmpty())
375 aLocale.Country = aCoun;
376 if (aLang != aLocale.Language || aCoun != aLocale.Country)
379 aLocale.Variant = rStrImpValue;
383 else if (aLang.isEmpty() && aCoun.isEmpty())
386 aLocale.Variant = rStrImpValue;
390 SAL_WARN(
"xmloff.style",
"rfc-language-tag too short: now set: "
391 << aLocale.Language <<
","<< aLocale.Country <<
","<< aLocale.Variant);
395 aLocale.Variant = rStrImpValue;
407 lang::Locale aLocale;
408 if(!(rValue >>= aLocale))
412 if (aLocale.Variant.isEmpty())
418 rStrExpValue = aLocale.Variant;
OUString getLanguage() const
OUString getScript() const
const OUString & getBcp47(bool bResolveSystem=true) const
void getIsoLanguageScriptCountry(OUString &rLanguage, OUString &rScript, OUString &rCountry) const
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
ODF version, only when exporting.
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
virtual bool equals(const css::uno::Any &r1, const css::uno::Any &r2) const override
Compares two Any's in case of the given XML-data-type.
virtual ~XMLCharCountryHdl() override
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
virtual bool equals(const css::uno::Any &r1, const css::uno::Any &r2) const override
Compares two Any's in case of the given XML-data-type.
virtual ~XMLCharLanguageHdl() override
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
virtual bool equals(const css::uno::Any &r1, const css::uno::Any &r2) const override
Compares two Any's in case of the given XML-data-type.
virtual ~XMLCharRfcLanguageTagHdl() override
virtual ~XMLCharScriptHdl() override
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
virtual bool equals(const css::uno::Any &r1, const css::uno::Any &r2) const override
Compares two Any's in case of the given XML-data-type.
constexpr OUStringLiteral I18NLANGTAG_QLT
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
Handling of tokens in XML:
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken