[PATCH] fd0#47896 - Too many languages in Format/Language

Rob Snelders programming at ertai.nl
Sun May 27 06:51:33 PDT 2012


Change-Id: I67a21d4b16c27dd68a2a87a6bcbac438da617f47
---
 cui/source/tabpages/chardlg.cxx |    7 ++++---
 svx/inc/svx/langbox.hxx         |   37 +++++++++++++++++++------------------
 svx/source/dialog/langbox.cxx   |   26 ++++++++++++++++++++++++--
 3 files changed, 47 insertions(+), 23 deletions(-)

diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx
index c127824..48a8548 100644
--- a/cui/source/tabpages/chardlg.cxx
+++ b/cui/source/tabpages/chardlg.cxx
@@ -400,9 +400,9 @@ SvxCharNamePage::SvxCharNamePage( Window* pParent, const SfxItemSet& rInSet ) :
 
     FreeResource();
 
-    m_pWestFontLanguageLB->SetLanguageList( LANG_LIST_WESTERN,  sal_True, sal_False, sal_True );
-    m_pEastFontLanguageLB->SetLanguageList( LANG_LIST_CJK,      sal_True, sal_False, sal_True );
-    m_pCTLFontLanguageLB->SetLanguageList( LANG_LIST_CTL,       sal_True, sal_False, sal_True );
+    m_pWestFontLanguageLB->SetLanguageList( LANG_LIST_SPELL_USED_WESTERN, sal_True, sal_False, sal_True );
+    m_pEastFontLanguageLB->SetLanguageList( LANG_LIST_SPELL_USED_CJK,     sal_True, sal_False, sal_True );
+    m_pCTLFontLanguageLB->SetLanguageList( LANG_LIST_SPELL_USED_CTL,      sal_True, sal_False, sal_True );
 
     Initialize();
 }
@@ -907,6 +907,7 @@ void SvxCharNamePage::Reset_Impl( const SfxItemSet& rSet, LanguageGroup eLangGrp
             const SvxLanguageItem& rItem = (SvxLanguageItem&)rSet.Get( nWhich );
             LanguageType eLangType = (LanguageType)rItem.GetValue();
             DBG_ASSERT( eLangType != LANGUAGE_SYSTEM, "LANGUAGE_SYSTEM not allowed" );
+            pLangBox->InsertLanguageIfNotFound( eLangType );
             if ( eLangType != LANGUAGE_DONTKNOW )
                 pLangBox->SelectLanguage( eLangType );
             break;
diff --git a/svx/inc/svx/langbox.hxx b/svx/inc/svx/langbox.hxx
index 7baf253..7ee0f34 100644
--- a/svx/inc/svx/langbox.hxx
+++ b/svx/inc/svx/langbox.hxx
@@ -38,24 +38,24 @@
 
 class SvtLanguageTable;
 
-#define LANG_LIST_EMPTY             0x0000
-#define LANG_LIST_ALL               0x0001
-#define LANG_LIST_WESTERN           0x0002
-#define LANG_LIST_CTL               0x0004
-#define LANG_LIST_CJK               0x0008
-#define LANG_LIST_FBD_CHARS         0x0010
-#define LANG_LIST_SPELL_AVAIL       0x0020
-#define LANG_LIST_HYPH_AVAIL        0x0040
-#define LANG_LIST_THES_AVAIL        0x0080
-#define LANG_LIST_ONLY_KNOWN        0x0100  // list only locales provided by I18N
-#define LANG_LIST_SPELL_USED        0x0200
-#define LANG_LIST_HYPH_USED         0x0400
-#define LANG_LIST_THES_USED         0x0800
-#define LANG_LIST_ALSO_PRIMARY_ONLY 0x1000  // Do not exclude primary-only
-                                            // languages that do not form a
-                                            // locale, such as Arabic as
-                                            // opposed to Arabic-Egypt.
-
+#define LANG_LIST_EMPTY              0x0000
+#define LANG_LIST_ALL                0x0001
+#define LANG_LIST_WESTERN            0x0002
+#define LANG_LIST_CTL                0x0004
+#define LANG_LIST_CJK                0x0008
+#define LANG_LIST_FBD_CHARS          0x0010
+#define LANG_LIST_SPELL_AVAIL        0x0020
+#define LANG_LIST_HYPH_AVAIL         0x0040
+#define LANG_LIST_THES_AVAIL         0x0080
+#define LANG_LIST_ONLY_KNOWN         0x0100  // list only locales provided by I18N
+#define LANG_LIST_SPELL_USED         0x0200
+#define LANG_LIST_HYPH_USED          0x0400
+#define LANG_LIST_THES_USED          0x0800
+#define LANG_LIST_ALSO_PRIMARY_ONLY  0x1000  // Do not exclude primary-only languages that do not form a
+                                             // locale, such as Arabic as opposed to Arabic-Egypt.
+#define LANG_LIST_SPELL_USED_WESTERN 0x2000
+#define LANG_LIST_SPELL_USED_CTL     0x4000
+#define LANG_LIST_SPELL_USED_CJK     0x8000
 
 // load language strings from resource
 SVX_DLLPUBLIC String    GetDicInfoStr( const String& rName, const sal_uInt16 nLang, sal_Bool bNeg );
@@ -87,6 +87,7 @@ public:
                             sal_Bool bHasLangNone, sal_Bool bLangNoneIsLangAll = sal_False,
                             sal_Bool bCheckSpellAvail = sal_False );
 
+    sal_uInt16          InsertLanguageIfNotFound( const LanguageType eLangType, sal_uInt16 nPos = LISTBOX_APPEND );
     sal_uInt16          InsertLanguage( const LanguageType eLangType, sal_uInt16 nPos = LISTBOX_APPEND );
     sal_uInt16          InsertDefaultLanguage( sal_Int16 nType, sal_uInt16 nPos = LISTBOX_APPEND );
     sal_uInt16          InsertLanguage( const LanguageType eLangType,
diff --git a/svx/source/dialog/langbox.cxx b/svx/source/dialog/langbox.cxx
index 0ec2329..8d02234 100644
--- a/svx/source/dialog/langbox.cxx
+++ b/svx/source/dialog/langbox.cxx
@@ -237,7 +237,10 @@ void SvxLanguageBox::SetLanguageList( sal_Int16 nLangList,
                 aThesAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
             }
         }
-        if (LANG_LIST_SPELL_USED & nLangList)
+        if ((LANG_LIST_SPELL_USED & nLangList) ||
+            (LANG_LIST_SPELL_USED_WESTERN & nLangList) ||
+            (LANG_LIST_SPELL_USED_CTL & nLangList) ||
+            (LANG_LIST_SPELL_USED_CJK & nLangList))
         {
             Reference< XSpellChecker1 > xTmp1( SvxGetSpellChecker(), UNO_QUERY );
             if (xTmp1.is())
@@ -311,7 +314,16 @@ void SvxLanguageBox::SetLanguageList( sal_Int16 nLangList,
                   ((nLangList & LANG_LIST_HYPH_USED) != 0 &&
                    lcl_SeqHasLang(aHyphUsedLang, nLangType)) ||
                   ((nLangList & LANG_LIST_THES_USED) != 0 &&
-                   lcl_SeqHasLang(aThesUsedLang, nLangType))) )
+                   lcl_SeqHasLang(aThesUsedLang, nLangType)) ||
+                  ((nLangList & LANG_LIST_SPELL_USED_WESTERN) != 0 &&
+                   (SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType) == SCRIPTTYPE_LATIN) &&
+                   lcl_SeqHasLang(aSpellUsedLang, nLangType)) ||
+                  ((nLangList & LANG_LIST_SPELL_USED_CTL) != 0 &&
+                   (SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType) == SCRIPTTYPE_COMPLEX) &&
+                   lcl_SeqHasLang(aSpellUsedLang, nLangType)) ||
+                  ((nLangList & LANG_LIST_SPELL_USED_CJK) != 0 &&
+                   (SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType) == SCRIPTTYPE_ASIAN) &&
+                   lcl_SeqHasLang(aSpellUsedLang, nLangType))) )
                 InsertLanguage( nLangType );
         }
 
@@ -322,6 +334,16 @@ void SvxLanguageBox::SetLanguageList( sal_Int16 nLangList,
 
 //------------------------------------------------------------------------
 
+sal_uInt16 SvxLanguageBox::InsertLanguageIfNotFound( const LanguageType nLangType, sal_uInt16 nPos )
+{
+    LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( nLangType);
+    sal_uInt16 nAt = TypeToPos_Impl( nLang, *this );
+    if ( nAt == LISTBOX_ENTRY_NOTFOUND )
+        return InsertLanguage( nLangType, nPos );
+    else
+        return nAt;
+}
+
 sal_uInt16 SvxLanguageBox::InsertLanguage( const LanguageType nLangType, sal_uInt16 nPos )
 {
     return ImplInsertLanguage( nLangType, nPos, ::com::sun::star::i18n::ScriptType::WEAK );
-- 
1.7.5.4


--------------010607050603070303060106--


More information about the LibreOffice mailing list