[Libreoffice-commits] core.git: 9 commits - oox/source sfx2/source svl/source unodevtools/source unotools/source

Eike Rathke erack at redhat.com
Thu Jul 11 10:16:15 PDT 2013


 oox/source/core/xmlfilterbase.cxx                     |    7 ++-
 sfx2/source/doc/SfxDocumentMetaData.cxx               |   16 +------
 sfx2/source/doc/doctemplates.cxx                      |   37 ++----------------
 sfx2/source/menu/thessubmenu.cxx                      |    8 ---
 svl/source/config/asiancfg.cxx                        |    5 --
 unodevtools/source/skeletonmaker/cppcompskeleton.cxx  |    1 
 unodevtools/source/skeletonmaker/javacompskeleton.cxx |    1 
 unotools/source/config/fontcfg.cxx                    |   24 -----------
 8 files changed, 20 insertions(+), 79 deletions(-)

New commits:
commit 5e60674857d3d290f172b8c133c69aeba003b1ce
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jul 11 19:14:32 2013 +0200

    use LanguageTag to convert
    
    Change-Id: I11007c31e5b4eea39ce27876de8a65fbf563a5e9

diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx
index a529bdc..205746d 100644
--- a/unotools/source/config/fontcfg.cxx
+++ b/unotools/source/config/fontcfg.cxx
@@ -124,19 +124,9 @@ DefaultFontConfiguration::DefaultFontConfiguration()
                 // fill config hash with empty interfaces
                 int nLocales = aLocales.getLength();
                 const OUString* pLocaleStrings = aLocales.getConstArray();
-                Locale aLoc;
                 for( int i = 0; i < nLocales; i++ )
                 {
-                    sal_Int32 nIndex = 0;
-                    aLoc.Language = pLocaleStrings[i].getToken( 0, sal_Unicode('-'), nIndex ).toAsciiLowerCase();
-                    if( nIndex != -1 )
-                        aLoc.Country = pLocaleStrings[i].getToken( 0, sal_Unicode('-'), nIndex ).toAsciiUpperCase();
-                    else
-                        aLoc.Country = OUString();
-                    if( nIndex != -1 )
-                        aLoc.Variant = pLocaleStrings[i].getToken( 0, sal_Unicode('-'), nIndex ).toAsciiUpperCase();
-                    else
-                        aLoc.Variant = OUString();
+                    Locale aLoc( LanguageTag( pLocaleStrings[i]).getLocale( false));
                     m_aConfig[ aLoc ] = LocaleAccess();
                     m_aConfig[ aLoc ].aConfigLocaleString = pLocaleStrings[i];
                 }
@@ -389,19 +379,9 @@ FontSubstConfiguration::FontSubstConfiguration() :
                 // fill config hash with empty interfaces
                 int nLocales = aLocales.getLength();
                 const OUString* pLocaleStrings = aLocales.getConstArray();
-                Locale aLoc;
                 for( int i = 0; i < nLocales; i++ )
                 {
-                    sal_Int32 nIndex = 0;
-                    aLoc.Language = pLocaleStrings[i].getToken( 0, sal_Unicode('-'), nIndex ).toAsciiLowerCase();
-                    if( nIndex != -1 )
-                        aLoc.Country = pLocaleStrings[i].getToken( 0, sal_Unicode('-'), nIndex ).toAsciiUpperCase();
-                    else
-                        aLoc.Country = OUString();
-                    if( nIndex != -1 )
-                        aLoc.Variant = pLocaleStrings[i].getToken( 0, sal_Unicode('-'), nIndex ).toAsciiUpperCase();
-                    else
-                        aLoc.Variant = OUString();
+                    Locale aLoc( LanguageTag( pLocaleStrings[i]).getLocale( false));
                     m_aSubst[ aLoc ] = LocaleSubst();
                     m_aSubst[ aLoc ].aConfigLocaleString = pLocaleStrings[i];
                 }
commit 0f80c06463e63af9f52501469c0c2090b662ae55
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jul 11 19:04:04 2013 +0200

    added FIXME-BCP47 comment
    
    Change-Id: I77416a9e275dc204b3b82807d27b5276ad4f497f

diff --git a/unodevtools/source/skeletonmaker/javacompskeleton.cxx b/unodevtools/source/skeletonmaker/javacompskeleton.cxx
index 86ba705..7306b12 100644
--- a/unodevtools/source/skeletonmaker/javacompskeleton.cxx
+++ b/unodevtools/source/skeletonmaker/javacompskeleton.cxx
@@ -402,6 +402,7 @@ void generateXCompatibilityNamesBodies(std::ostream& o)
         "toString(\n                        xNameAccess.getByName(sLocale));\n\n"
         "                    com.sun.star.lang.Locale aLocale = \n"
         "                        new com.sun.star.lang.Locale();\n\n"
+        /* FIXME-BCP47: this will break. */
         "                    String tokens[] = sLocale.split(\"-\");\n"
         "                    int nToken = tokens.length;\n"
         "                    if (nToken >= 1) aLocale.Language = tokens[0];\n"
commit 7d0f6f671e7f9027b46e9a87e4b3608429ed64ad
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jul 11 19:01:44 2013 +0200

    added FIXME-BCP47 comment
    
    Change-Id: I202c53a094ac7ddcbd1fa0d2367058aba56820ed

diff --git a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx
index 98166ee..3228a8c 100644
--- a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx
+++ b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx
@@ -386,6 +386,7 @@ void generateXCompatibilityNamesBodies(std::ostream& o, const OString & classnam
         "xNameAccess->getByName(sLocale) >>= sCompatibilityName;\n\n"
         "                css::lang::Locale aLocale;\n                "
         "::sal_Int32 nIndex = 0, nToken = 0;\n                "
+        /* FIXME-BCP47: this will break. */
         "do {\n                    ::rtl::OUString aToken = sLocale.getToken(0, '-', "
         "nIndex);\n                    switch (nToken++) {\n                    "
         "case 0:\n                        aLocale.Language = aToken;\n"
commit 759d56352faf463bba11369f1a7be8bed3814f90
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jul 11 18:50:13 2013 +0200

    use LanguageTag to convert
    
    Change-Id: I721f1018e6380a3102b6dd20052001b1e950421b

diff --git a/svl/source/config/asiancfg.cxx b/svl/source/config/asiancfg.cxx
index 99e36eb..695f762 100644
--- a/svl/source/config/asiancfg.cxx
+++ b/svl/source/config/asiancfg.cxx
@@ -105,10 +105,7 @@ css::uno::Sequence< css::lang::Locale > SvxAsianConfig::GetStartEndCharLocales()
         getElementNames());
     css::uno::Sequence< css::lang::Locale > ls(ns.getLength());
     for (sal_Int32 i = 0; i < ns.getLength(); ++i) {
-        sal_Int32 n = 0;
-        ls[i].Language = ns[i].getToken(0, '-', n);
-        ls[i].Country = ns[i].getToken(0, '-', n);
-        ls[i].Variant = ns[i].getToken(0, '-', n);
+        ls[i] = LanguageTag( ns[i]).getLocale( false);
     }
     return ls;
 }
commit 96a5c866a94590c993629013c41f00b7d496f70e
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jul 11 18:47:22 2013 +0200

    use LanguageTag to convert
    
    Change-Id: Id32a8a75cd24a8acc4dada689a5688767de6745b

diff --git a/sfx2/source/menu/thessubmenu.cxx b/sfx2/source/menu/thessubmenu.cxx
index 287ed20..3c22420 100644
--- a/sfx2/source/menu/thessubmenu.cxx
+++ b/sfx2/source/menu/thessubmenu.cxx
@@ -53,13 +53,7 @@ void SfxThesSubMenuHelper::GetLocale(
     xub_StrLen nDelimPos  )
 {
     String aIsoLang( rLookUpString.Copy( nDelimPos + 1) );
-    const xub_StrLen nPos = aIsoLang.Search( '-' );
-    if (nPos != STRING_NOTFOUND)
-    {
-        rLocale.Language    = aIsoLang.Copy( 0, nPos );
-        rLocale.Country     = aIsoLang.Copy( nPos + 1 );
-        rLocale.Variant     = String::EmptyString();
-    }
+    rLocale = LanguageTag( aIsoLang).getLocale();
 }
 
 
commit a0ab8e389cca3db9fef0547925cdcc6d71e9b43d
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jul 11 18:44:25 2013 +0200

    write bcp47 for dc:language
    
    Change-Id: I859eaaba3c852127422bd0d0e0db0f9bd62e0d55

diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index c9c7892..97b6dc2 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -506,8 +506,11 @@ writeElement( FSHelperPtr pDoc, sal_Int32 nXmlElement, Sequence< OUString > aIte
 static void
 writeElement( FSHelperPtr pDoc, sal_Int32 nXmlElement, const LanguageTag& rLanguageTag )
 {
-    // TODO: what to do with .Country and .Variant
-    writeElement( pDoc, nXmlElement, rLanguageTag.getLanguage() );
+    // dc:language, Dublin Core recommends "such as RFC 4646", which is BCP 47
+    // and obsoleted by RFC 5646, see
+    // http://dublincore.org/documents/dcmi-terms/#terms-language
+    // http://dublincore.org/documents/dcmi-terms/#elements-language
+    writeElement( pDoc, nXmlElement, rLanguageTag.getBcp47() );
 }
 
 static void
commit f758c53e87a2e29ccd4d8e11f1426e1d805b2032
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jul 11 18:35:28 2013 +0200

    use LanguageTag to convert
    
    Change-Id: I9209b659eb88df5610882a476dc12ac45527e568

diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx
index f410703..f1e96c6 100644
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -70,6 +70,7 @@
 #include "sot/storage.hxx"
 #include "sfx2/docfile.hxx"
 #include "sax/tools/converter.hxx"
+#include "i18nlangtag/languagetag.hxx"
 
 #include <utility>
 #include <vector>
@@ -1515,15 +1516,7 @@ css::lang::Locale SAL_CALL
         SfxDocumentMetaData::getLanguage() throw (css::uno::RuntimeException)
 {
     ::osl::MutexGuard g(m_aMutex);
-    css::lang::Locale loc;
-    OUString text = getMetaText("dc:language");
-    sal_Int32 ix = text.indexOf(static_cast<sal_Unicode> ('-'));
-    if (ix == -1) {
-        loc.Language = text;
-    } else {
-        loc.Language = text.copy(0, ix);
-        loc.Country = text.copy(ix+1);
-    }
+    css::lang::Locale loc( LanguageTag( getMetaText("dc:language")).getLocale( false));
     return loc;
 }
 
@@ -1531,10 +1524,7 @@ void SAL_CALL
 SfxDocumentMetaData::setLanguage(const css::lang::Locale & the_value)
         throw (css::uno::RuntimeException)
 {
-    OUString text = the_value.Language;
-    if (!the_value.Country.isEmpty()) {
-        text += OUString("-").concat(the_value.Country);
-    }
+    OUString text( LanguageTag( the_value).getBcp47( false));
     setMetaTextAndNotify("dc:language", text);
 }
 
commit b49892872ef2c73c3f2b745c00baa1c735837ec1
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jul 11 18:25:40 2013 +0200

    comparing Locales without Variant is now insufficient
    
    Previous code also had some odd notion of inequality ...
    
    Change-Id: I0e75035a0618a3a0a177d22296155b9ae2a26185

diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx
index 18ebc72..78d8ac2 100644
--- a/sfx2/source/doc/doctemplates.cxx
+++ b/sfx2/source/doc/doctemplates.cxx
@@ -1133,9 +1133,10 @@ void SfxDocTplService_Impl::setLocale( const Locale &rLocale )
 {
     ::osl::MutexGuard aGuard( maMutex );
 
-    if ( mbLocaleSet &&
-         ( maLocale.Language != rLocale.Language ) &&
-         ( maLocale.Country != rLocale.Country ) )
+    if ( mbLocaleSet && (
+         ( maLocale.Language != rLocale.Language ) ||
+         ( maLocale.Country  != rLocale.Country  ) ||
+         ( maLocale.Variant  != rLocale.Variant  ) ) )
         mbIsInitialized = sal_False;
 
     maLocale    = rLocale;
commit 3dd16c6838778b8a947cc5daddc89a354712cb47
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jul 11 18:22:27 2013 +0200

    use LanguageTag to convert
    
    Change-Id: I689bb64664ee36b2e3e8386ebd20cdd95c51142b

diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx
index 62c28cc..18ebc72 100644
--- a/sfx2/source/doc/doctemplates.cxx
+++ b/sfx2/source/doc/doctemplates.cxx
@@ -401,9 +401,7 @@ void SfxDocTplService_Impl::init_Impl()
         getDefaultLocale();
 
     // convert locale to string
-    OUString aLang = maLocale.Language;
-    aLang += OUString( '-' );
-    aLang += maLocale.Country;
+    OUString aLang = LanguageTag( maLocale).getBcp47();
 
     // set maRootContent to the root of the templates hierarchy. Create the
     // entry if necessary
@@ -490,31 +488,7 @@ void SfxDocTplService_Impl::getDefaultLocale()
         ::osl::MutexGuard aGuard( maMutex );
         if ( !mbLocaleSet )
         {
-            OUString aLocale( utl::ConfigManager::getLocale() );
-            if ( !aLocale.isEmpty() )
-            {
-                sal_Int32 nPos = aLocale.indexOf( sal_Unicode( '-' ) );
-                if ( nPos != -1 )
-                {
-                    maLocale.Language = aLocale.copy( 0, nPos );
-                    nPos = aLocale.indexOf( sal_Unicode( '_' ), nPos + 1 );
-                    if ( nPos != -1 )
-                    {
-                        maLocale.Country
-                            = aLocale.copy( maLocale.Language.getLength() + 1,
-                                            nPos - maLocale.Language.getLength() - 1 );
-                        maLocale.Variant
-                            = aLocale.copy( nPos + 1 );
-                    }
-                    else
-                    {
-                        maLocale.Country
-                            = aLocale.copy( maLocale.Language.getLength() + 1 );
-                    }
-                }
-
-            }
-
+            maLocale = LanguageTag( utl::ConfigManager::getLocale()).getLocale( false);
             mbLocaleSet = sal_True;
         }
     }


More information about the Libreoffice-commits mailing list