diff options
author | Eike Rathke <erack@redhat.com> | 2014-06-03 14:17:17 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2014-06-03 14:48:45 +0200 |
commit | fecde4c7099fdb7c5ee396b0f68ec517f3a08955 (patch) | |
tree | 8d60af84c27de0ec4972fa4c8b6c5e9aa1c81376 /i18nlangtag | |
parent | fix spelling of field name mbColseByEdit->mbCloseByEdit (diff) | |
download | core-fecde4c7099fdb7c5ee396b0f68ec517f3a08955.tar.gz core-fecde4c7099fdb7c5ee396b0f68ec517f3a08955.zip |
add bDisallowPrivate parameter to LanguageTag::isValidBcp47()
Change-Id: I0924b0fa268c38c238226d082cf26595bba72f0c
Diffstat (limited to 'i18nlangtag')
-rw-r--r-- | i18nlangtag/source/languagetag/languagetag.cxx | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx index 483cf98af7da..237fdcadfa7a 100644 --- a/i18nlangtag/source/languagetag/languagetag.cxx +++ b/i18nlangtag/source/languagetag/languagetag.cxx @@ -2691,8 +2691,10 @@ com::sun::star::lang::Locale LanguageTag::convertToLocaleWithFallback( const OUS // static -bool LanguageTag::isValidBcp47( const OUString& rString, OUString* o_pCanonicalized ) +bool LanguageTag::isValidBcp47( const OUString& rString, OUString* o_pCanonicalized, bool bDisallowPrivate ) { + bool bValid = false; + struct guard { lt_tag_t* mpLangtag; @@ -2716,17 +2718,24 @@ bool LanguageTag::isValidBcp47( const OUString& rString, OUString* o_pCanonicali SAL_WARN_IF( !pTag, "i18nlangtag", "LanguageTag:isValidBcp47: could not canonicalize '" << rString << "'"); if (pTag) { + bValid = true; + if (bDisallowPrivate) + { + const lt_string_t* pPrivate = lt_tag_get_privateuse( aVar.mpLangtag); + if (pPrivate && lt_string_length( pPrivate) > 0) + bValid = false; + } if (o_pCanonicalized) *o_pCanonicalized = OUString::createFromAscii( pTag); free( pTag); - return true; + return bValid; } } else { SAL_INFO( "i18nlangtag", "LanguageTag:isValidBcp47: could not parse '" << rString << "'"); } - return false; + return bValid; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |