[Libreoffice-commits] core.git: 5 commits - include/vcl vcl/source vcl/unx
Eike Rathke
erack at redhat.com
Thu Jul 11 17:24:06 PDT 2013
include/vcl/builder.hxx | 2 -
vcl/source/gdi/pdfwriter_impl.cxx | 53 ++++++++++++++++++++++-----------
vcl/source/window/builder.cxx | 16 +++++----
vcl/unx/generic/app/wmadaptor.cxx | 13 --------
vcl/unx/generic/printer/ppdparser.cxx | 5 +++
vcl/unx/gtk/a11y/atktextattributes.cxx | 7 +++-
6 files changed, 57 insertions(+), 39 deletions(-)
New commits:
commit 15e35498e602e9a844ea4067044f8f8efd72755b
Author: Eike Rathke <erack at redhat.com>
Date: Fri Jul 12 02:22:16 2013 +0200
use LanguageTag to convert, and some FIXME-BCP47 comments
Change-Id: I63abfdfbd9f94993ce583ebd4cf8ef44d2068112
diff --git a/vcl/unx/gtk/a11y/atktextattributes.cxx b/vcl/unx/gtk/a11y/atktextattributes.cxx
index a5612b4..130c866 100644
--- a/vcl/unx/gtk/a11y/atktextattributes.cxx
+++ b/vcl/unx/gtk/a11y/atktextattributes.cxx
@@ -707,15 +707,18 @@ Kerning2Stretch(const uno::Any& rAny)
static gchar*
Locale2String(const uno::Any& rAny)
{
+ /* FIXME-BCP47: support language tags? And why is country lowercase? */
lang::Locale aLocale = rAny.get<lang::Locale> ();
+ LanguageTag aLanguageTag( aLocale);
return g_strdup_printf( "%s-%s",
- OUStringToOString( aLocale.Language, RTL_TEXTENCODING_ASCII_US).getStr(),
- OUStringToOString( aLocale.Country, RTL_TEXTENCODING_ASCII_US).toAsciiLowerCase().getStr() );
+ OUStringToOString( aLanguageTag.getLanguage(), RTL_TEXTENCODING_ASCII_US).getStr(),
+ OUStringToOString( aLanguageTag.getCountry(), RTL_TEXTENCODING_ASCII_US).toAsciiLowerCase().getStr() );
}
static bool
String2Locale( uno::Any& rAny, const gchar * value )
{
+ /* FIXME-BCP47: support language tags? */
bool ret = false;
gchar ** str_array = g_strsplit_set( value, "-.@", -1 );
commit ae32dd4f7d2dc4592c54390f75a5f3479c899f18
Author: Eike Rathke <erack at redhat.com>
Date: Fri Jul 12 02:11:55 2013 +0200
some FIXME-BCP47 comments
Change-Id: I0c9a532ac4eec9730f7ae17b02742a381fa0a667
diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx
index 2092ea1..a8eeb2a 100644
--- a/vcl/unx/generic/printer/ppdparser.cxx
+++ b/vcl/unx/generic/printer/ppdparser.cxx
@@ -149,6 +149,7 @@ namespace psp
}
#endif
}
+ /* FIXME-BCP47: using Variant, uppercase? */
aLoc.Language = aLoc.Language.toAsciiLowerCase();
aLoc.Country = aLoc.Country.toAsciiUpperCase();
aLoc.Variant = aLoc.Variant.toAsciiUpperCase();
@@ -180,6 +181,7 @@ namespace psp
{
OUString aK( aKey.makeStringAndClear() );
com::sun::star::lang::Locale aLoc;
+ /* FIXME-BCP47: using Variant, uppercase? */
aLoc.Language = i_rLocale.Language.toAsciiLowerCase();
aLoc.Country = i_rLocale.Country.toAsciiUpperCase();
aLoc.Variant = i_rLocale.Variant.toAsciiUpperCase();
@@ -217,6 +219,7 @@ namespace psp
const translation_map& rMap( it->second );
com::sun::star::lang::Locale aLoc( normalizeInputLocale( i_rLocale, true ) );
+ /* FIXME-BCP47: use LanguageTag::getFallbackStrings()? */
for( int nTry = 0; nTry < 4; nTry++ )
{
translation_map::const_iterator tr = rMap.find( aLoc );
@@ -1016,6 +1019,8 @@ void PPDParser::parse( ::std::list< OString >& rLines )
String aUniKey(OStringToOUString(aKey, RTL_TEXTENCODING_MS_1252));
// handle CUPS extension for globalized PPDs
+ /* FIXME-BCP47: really only ISO 639-1 two character language codes?
+ * goodnight.. */
bool bIsGlobalizedLine = false;
com::sun::star::lang::Locale aTransLocale;
if( ( aUniKey.Len() > 3 && aUniKey.GetChar( 2 ) == '.' ) ||
commit 5a795e01e02995880391a56d67065a0621d4b622
Author: Eike Rathke <erack at redhat.com>
Date: Fri Jul 12 01:57:33 2013 +0200
use LanguageTag::getGlibcLocaleString()
Change-Id: I3770056e3a8039dae5c5cfe686f445d4668b5995
diff --git a/vcl/unx/generic/app/wmadaptor.cxx b/vcl/unx/generic/app/wmadaptor.cxx
index 86dcf8d..eabea01 100644
--- a/vcl/unx/generic/app/wmadaptor.cxx
+++ b/vcl/unx/generic/app/wmadaptor.cxx
@@ -984,23 +984,12 @@ void WMAdaptor::setWMName( X11SalFrame* pFrame, const String& rWMName ) const
OString aTitle(OUStringToOString(rWMName,
osl_getThreadTextEncoding()));
- /* FIXME-BCP47: what slumbering dogs may we wake up here? */
OString aWMLocale;
rtl_Locale* pLocale = NULL;
osl_getProcessLocale( &pLocale );
if( pLocale )
{
- OUString aLocaleString( pLocale->Language );
- OUString aCountry( pLocale->Country );
- OUString aVariant( pLocale->Variant );
-
- if( !aCountry.isEmpty() )
- {
- aLocaleString += OUString("_");
- aLocaleString += aCountry;
- }
- if( !aVariant.isEmpty() )
- aLocaleString += aVariant;
+ OUString aLocaleString( LanguageTag( *pLocale).getGlibcLocaleString( OUString()));
aWMLocale = OUStringToOString( aLocaleString, RTL_TEXTENCODING_ISO_8859_1 );
}
else
commit cde58731dc2e0da78cf761ff95a5df214296d041
Author: Eike Rathke <erack at redhat.com>
Date: Fri Jul 12 01:47:40 2013 +0200
use LanguageTag, and a FIXME-BCP47 comment in loadTranslations()
Change-Id: I9fd4c0a3887dd3d7ac756f0399a8a030d116f68a
diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx
index 3708a34..bdf0c82 100644
--- a/include/vcl/builder.hxx
+++ b/include/vcl/builder.hxx
@@ -211,7 +211,7 @@ private:
std::vector<MnemonicWidgetMap> m_aMnemonicWidgetMaps;
};
- void loadTranslations(const com::sun::star::lang::Locale &rLocale, const OUString &rUri);
+ void loadTranslations(const LanguageTag &rLanguageTag, const OUString &rUri);
OString getTranslation(const OString &rId, const OString &rProperty) const;
OString m_sID;
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 37d54a0..d7d384a 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -81,9 +81,11 @@ namespace
}
}
-void VclBuilder::loadTranslations(const com::sun::star::lang::Locale &rLocale, const OUString& rUri)
+void VclBuilder::loadTranslations(const LanguageTag &rLanguageTag, const OUString& rUri)
{
- for (int i = rLocale.Country.isEmpty() ? 1 : 0; i < 2; ++i)
+ /* FIXME-BCP47: support language tags with
+ * LanguageTag::getFallbackStrings() ? */
+ for (int i = rLanguageTag.getCountry().isEmpty() ? 1 : 0; i < 2; ++i)
{
OUStringBuffer aTransBuf;
sal_Int32 nLastSlash = rUri.lastIndexOf('/');
@@ -94,11 +96,11 @@ void VclBuilder::loadTranslations(const com::sun::star::lang::Locale &rLocale, c
aTransBuf.append('.');
nLastSlash = 0;
}
- aTransBuf.append("/res/").append(rLocale.Language);
+ aTransBuf.append("/res/").append(rLanguageTag.getLanguage());
switch (i)
{
case 0:
- aTransBuf.append('-').append(rLocale.Country);
+ aTransBuf.append('-').append(rLanguageTag.getCountry());
break;
default:
break;
@@ -157,10 +159,10 @@ VclBuilder::VclBuilder(Window *pParent, OUString sUIDir, OUString sUIFile, OStri
OUString sUri = sUIDir + sUIFile;
- com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILanguageTag().getLocale();
- bool bEN_US = aLocale.Language == "en" && aLocale.Country == "US" && aLocale.Variant.isEmpty();
+ const LanguageTag& rLanguageTag = Application::GetSettings().GetUILanguageTag();
+ bool bEN_US = (rLanguageTag.getBcp47() == "en-US");
if (!bEN_US)
- loadTranslations(aLocale, sUri);
+ loadTranslations(rLanguageTag, sUri);
try
{
commit 562880754bc8b59b752a6ca40ee4323240f74ac9
Author: Eike Rathke <erack at redhat.com>
Date: Fri Jul 12 01:34:16 2013 +0200
restrict to ISO language-country
Change-Id: I0dbcb4bd75fa270acee409524d6b1dd12547ff0d
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index ab8f4d1..1718965 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2731,16 +2731,28 @@ sal_Int32 PDFWriterImpl::emitStructure( PDFStructureElement& rEle )
}
if( !rEle.m_aLocale.Language.isEmpty() )
{
- OUStringBuffer aLocBuf( 16 );
- aLocBuf.append( rEle.m_aLocale.Language.toAsciiLowerCase() );
- if( !rEle.m_aLocale.Country.isEmpty() )
- {
- aLocBuf.append( sal_Unicode('-') );
- aLocBuf.append( rEle.m_aLocale.Country );
+ /* PDF allows only RFC 3066, which is only partly BCP 47 and does not
+ * include script tags and others.
+ * http://pdf.editme.com/pdfua-naturalLanguageSpecification
+ * http://partners.adobe.com/public/developer/en/pdf/PDFReference16.pdf#page=886
+ * https://www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf#M13.9.19332.1Heading.97.Natural.Language.Specification
+ * */
+ LanguageTag aLanguageTag( rEle.m_aLocale);
+ OUString aLanguage, aScript, aCountry;
+ aLanguageTag.getIsoLanguageScriptCountry( aLanguage, aScript, aCountry);
+ if (!aLanguage.isEmpty())
+ {
+ OUStringBuffer aLocBuf( 16 );
+ aLocBuf.append( aLanguage );
+ if( !aCountry.isEmpty() )
+ {
+ aLocBuf.append( sal_Unicode('-') );
+ aLocBuf.append( aCountry );
+ }
+ aLine.append( "/Lang" );
+ appendLiteralStringEncrypt( aLocBuf.makeStringAndClear(), rEle.m_nObject, aLine );
+ aLine.append( "\n" );
}
- aLine.append( "/Lang" );
- appendLiteralStringEncrypt( aLocBuf.makeStringAndClear(), rEle.m_nObject, aLine );
- aLine.append( "\n" );
}
if( ! rEle.m_aKids.empty() )
{
@@ -5783,16 +5795,23 @@ bool PDFWriterImpl::emitCatalog()
}
if( !m_aContext.DocumentLocale.Language.isEmpty() )
{
- OUStringBuffer aLocBuf( 16 );
- aLocBuf.append( m_aContext.DocumentLocale.Language.toAsciiLowerCase() );
- if( !m_aContext.DocumentLocale.Country.isEmpty() )
+ /* PDF allows only RFC 3066, see above in emitStructure(). */
+ LanguageTag aLanguageTag( m_aContext.DocumentLocale);
+ OUString aLanguage, aScript, aCountry;
+ aLanguageTag.getIsoLanguageScriptCountry( aLanguage, aScript, aCountry);
+ if (!aLanguage.isEmpty())
{
- aLocBuf.append( sal_Unicode('-') );
- aLocBuf.append( m_aContext.DocumentLocale.Country );
+ OUStringBuffer aLocBuf( 16 );
+ aLocBuf.append( aLanguage );
+ if( !aCountry.isEmpty() )
+ {
+ aLocBuf.append( sal_Unicode('-') );
+ aLocBuf.append( aCountry );
+ }
+ aLine.append( "/Lang" );
+ appendLiteralStringEncrypt( aLocBuf.makeStringAndClear(), m_nCatalogObject, aLine );
+ aLine.append( "\n" );
}
- aLine.append( "/Lang" );
- appendLiteralStringEncrypt( aLocBuf.makeStringAndClear(), m_nCatalogObject, aLine );
- aLine.append( "\n" );
}
if( m_aContext.Tagged && m_aContext.Version > PDFWriter::PDF_1_3 )
{
More information about the Libreoffice-commits
mailing list