[Libreoffice-commits] core.git: compilerplugins/clang include/svx svx/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Nov 27 12:53:32 UTC 2018


 compilerplugins/clang/unusedenumconstants.readonly.results |   14 -
 include/svx/langbox.hxx                                    |   15 --
 svx/source/dialog/langbox.cxx                              |   94 ++-----------
 3 files changed, 19 insertions(+), 104 deletions(-)

New commits:
commit e54d65dea830ca33cf88ae53941a83987afbb48a
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Nov 26 11:11:24 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Nov 27 13:53:07 2018 +0100

    remove unused SvxLanguageListFlags enum values
    
    Change-Id: I89a6244c01be811bfdfc443f687708ed6aec8a10
    Reviewed-on: https://gerrit.libreoffice.org/64083
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/compilerplugins/clang/unusedenumconstants.readonly.results b/compilerplugins/clang/unusedenumconstants.readonly.results
index b7c602053fa7..090a2720967a 100644
--- a/compilerplugins/clang/unusedenumconstants.readonly.results
+++ b/compilerplugins/clang/unusedenumconstants.readonly.results
@@ -516,20 +516,6 @@ include/svx/flagsdef.hxx:119
     enum TabulatorDisableFlags FillSolidLine
 include/svx/flagsdef.hxx:120
     enum TabulatorDisableFlags FillSpecial
-include/svx/langbox.hxx:34
-    enum SvxLanguageListFlags EMPTY
-include/svx/langbox.hxx:40
-    enum SvxLanguageListFlags SPELL_AVAIL
-include/svx/langbox.hxx:41
-    enum SvxLanguageListFlags HYPH_AVAIL
-include/svx/langbox.hxx:42
-    enum SvxLanguageListFlags THES_AVAIL
-include/svx/langbox.hxx:45
-    enum SvxLanguageListFlags HYPH_USED
-include/svx/langbox.hxx:46
-    enum SvxLanguageListFlags THES_USED
-include/svx/langbox.hxx:47
-    enum SvxLanguageListFlags ALSO_PRIMARY_ONLY
 include/svx/ruler.hxx:60
     enum SvxRulerDragFlags OBJECT_LEFT_INDENT_ONLY
 include/svx/sdtakitm.hxx:31
diff --git a/include/svx/langbox.hxx b/include/svx/langbox.hxx
index 23893feaaeab..93ab480bf460 100644
--- a/include/svx/langbox.hxx
+++ b/include/svx/langbox.hxx
@@ -37,21 +37,12 @@ enum class SvxLanguageListFlags
     CTL               = 0x0004,
     CJK               = 0x0008,
     FBD_CHARS         = 0x0010,
-    SPELL_AVAIL       = 0x0020,
-    HYPH_AVAIL        = 0x0040,
-    THES_AVAIL        = 0x0080,
-    ONLY_KNOWN        = 0x0100,  // list only locales provided by I18N
-    SPELL_USED        = 0x0200,
-    HYPH_USED         = 0x0400,
-    THES_USED         = 0x0800,
-    ALSO_PRIMARY_ONLY = 0x1000,  // Do not exclude primary-only
-                                 // languages that do not form a
-                                 // locale, such as Arabic as
-                                 // opposed to Arabic-Egypt.
+    ONLY_KNOWN        = 0x0020,  // list only locales provided by I18N
+    SPELL_USED        = 0x0040,
 };
 namespace o3tl
 {
-    template<> struct typed_flags<SvxLanguageListFlags> : is_typed_flags<SvxLanguageListFlags, 0x1fff> {};
+    template<> struct typed_flags<SvxLanguageListFlags> : is_typed_flags<SvxLanguageListFlags, 0x007f> {};
 }
 
 // load language strings from resource
diff --git a/svx/source/dialog/langbox.cxx b/svx/source/dialog/langbox.cxx
index abac537091ad..a1317ed144f4 100644
--- a/svx/source/dialog/langbox.cxx
+++ b/svx/source/dialog/langbox.cxx
@@ -89,13 +89,6 @@ static std::vector< LanguageType > lcl_LocaleSeqToLangSeq( Sequence< css::lang::
 }
 
 
-static bool lcl_SeqHasLang( const std::vector< LanguageType > & rLangSeq, LanguageType nLang )
-{
-    for (auto const & i : rLangSeq)
-        if (i == nLang)
-            return true;
-    return false;
-}
 static bool lcl_SeqHasLang( const Sequence< sal_Int16 > & rLangSeq, sal_Int16 nLang )
 {
     sal_Int32 i = -1;
@@ -180,15 +173,14 @@ SvxLanguageBoxBase::~SvxLanguageBoxBase()
 
 namespace {
 
-bool lcl_isPrerequisite( LanguageType nLangType, SvxLanguageListFlags nLangList )
+bool lcl_isPrerequisite( LanguageType nLangType )
 {
     return
         nLangType != LANGUAGE_DONTKNOW &&
         nLangType != LANGUAGE_SYSTEM &&
         nLangType != LANGUAGE_NONE &&
         !MsLangId::isLegacy( nLangType) &&
-        (MsLangId::getSubLanguage( nLangType) ||
-         bool(nLangList & SvxLanguageListFlags::ALSO_PRIMARY_ONLY));
+        MsLangId::getSubLanguage( nLangType);
 }
 
 bool lcl_isScriptTypeRequested( LanguageType nLangType, SvxLanguageListFlags nLangList )
@@ -210,7 +202,7 @@ void SvxLanguageBoxBase::AddLanguages( const std::vector< LanguageType >& rLangu
 {
     for ( auto const & nLangType : rLanguageTypes )
     {
-        if (lcl_isPrerequisite( nLangType, nLangList))
+        if (lcl_isPrerequisite( nLangType ))
         {
             LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( nLangType );
             if (lcl_isScriptTypeRequested( nLang, nLangList))
@@ -244,24 +236,22 @@ void SvxLanguageBoxBase::SetLanguageList( SvxLanguageListFlags nLangList,
     std::vector< LanguageType > aHyphAvailLang;
     std::vector< LanguageType > aThesAvailLang;
     Sequence< sal_Int16 > aSpellUsedLang;
-    std::vector< LanguageType > aHyphUsedLang;
-    std::vector< LanguageType > aThesUsedLang;
     Reference< XAvailableLocales > xAvail( LinguMgr::GetLngSvcMgr(), UNO_QUERY );
     if (xAvail.is())
     {
         Sequence< css::lang::Locale > aTmp;
 
-        if (bAddAvailable || (SvxLanguageListFlags::SPELL_AVAIL & nLangList))
+        if (bAddAvailable)
         {
             aTmp = xAvail->getAvailableLocales( SN_SPELLCHECKER );
             aSpellAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
         }
-        if (bAddAvailable || (SvxLanguageListFlags::HYPH_AVAIL  & nLangList))
+        if (bAddAvailable)
         {
             aTmp = xAvail->getAvailableLocales( SN_HYPHENATOR );
             aHyphAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
         }
-        if (bAddAvailable || (SvxLanguageListFlags::THES_AVAIL  & nLangList))
+        if (bAddAvailable)
         {
             aTmp = xAvail->getAvailableLocales( SN_THESAURUS );
             aThesAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
@@ -273,22 +263,6 @@ void SvxLanguageBoxBase::SetLanguageList( SvxLanguageListFlags nLangList,
         if (xTmp1.is())
             aSpellUsedLang = xTmp1->getLanguages();
     }
-    if (SvxLanguageListFlags::HYPH_USED  & nLangList)
-    {
-        Reference< XHyphenator > xTmp( LinguMgr::GetHyphenator() );
-        if (xTmp.is()) {
-            Sequence < css::lang::Locale > aLocaleSequence( xTmp->getLocales() );
-            aHyphUsedLang = lcl_LocaleSeqToLangSeq( aLocaleSequence );
-        }
-    }
-    if (SvxLanguageListFlags::THES_USED  & nLangList)
-    {
-        Reference< XThesaurus > xTmp( LinguMgr::GetThesaurus() );
-        if (xTmp.is()) {
-            Sequence < css::lang::Locale > aLocaleSequence( xTmp->getLocales() );
-            aThesUsedLang = lcl_LocaleSeqToLangSeq( aLocaleSequence );
-        }
-    }
 
     std::vector<LanguageType> aKnown;
     sal_uInt32 nCount;
@@ -308,22 +282,13 @@ void SvxLanguageBoxBase::SetLanguageList( SvxLanguageListFlags nLangList,
             nLangType = aKnown[i];
         else
             nLangType = SvtLanguageTable::GetLanguageTypeAtIndex( i );
-        if ( lcl_isPrerequisite( nLangType, nLangList) &&
+        if ( lcl_isPrerequisite( nLangType ) &&
              (lcl_isScriptTypeRequested( nLangType, nLangList) ||
               (bool(nLangList & SvxLanguageListFlags::FBD_CHARS) &&
                MsLangId::hasForbiddenCharacters(nLangType)) ||
-              (bool(nLangList & SvxLanguageListFlags::SPELL_AVAIL) &&
-               lcl_SeqHasLang(aSpellAvailLang, nLangType)) ||
-              (bool(nLangList & SvxLanguageListFlags::HYPH_AVAIL) &&
-               lcl_SeqHasLang(aHyphAvailLang, nLangType)) ||
-              (bool(nLangList & SvxLanguageListFlags::THES_AVAIL) &&
-               lcl_SeqHasLang(aThesAvailLang, nLangType)) ||
               (bool(nLangList & SvxLanguageListFlags::SPELL_USED) &&
-               lcl_SeqHasLang(aSpellUsedLang, static_cast<sal_uInt16>(nLangType))) ||
-              (bool(nLangList & SvxLanguageListFlags::HYPH_USED) &&
-               lcl_SeqHasLang(aHyphUsedLang, nLangType)) ||
-              (bool(nLangList & SvxLanguageListFlags::THES_USED) &&
-               lcl_SeqHasLang(aThesUsedLang, nLangType))) )
+               lcl_SeqHasLang(aSpellUsedLang, static_cast<sal_uInt16>(nLangType)))
+              ) )
             InsertLanguage( nLangType );
     }
 
@@ -535,7 +500,7 @@ void LanguageBox::AddLanguages(const std::vector< LanguageType >& rLanguageTypes
 {
     for ( auto const & nLangType : rLanguageTypes )
     {
-        if (lcl_isPrerequisite( nLangType, nLangList))
+        if (lcl_isPrerequisite( nLangType ))
         {
             LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( nLangType );
             if (lcl_isScriptTypeRequested( nLang, nLangList))
@@ -579,24 +544,22 @@ void LanguageBox::SetLanguageList( SvxLanguageListFlags nLangList,
     std::vector< LanguageType > aHyphAvailLang;
     std::vector< LanguageType > aThesAvailLang;
     Sequence< sal_Int16 > aSpellUsedLang;
-    std::vector< LanguageType > aHyphUsedLang;
-    std::vector< LanguageType > aThesUsedLang;
     Reference< XAvailableLocales > xAvail( LinguMgr::GetLngSvcMgr(), UNO_QUERY );
     if (xAvail.is())
     {
         Sequence< css::lang::Locale > aTmp;
 
-        if (bAddAvailable || (SvxLanguageListFlags::SPELL_AVAIL & nLangList))
+        if (bAddAvailable)
         {
             aTmp = xAvail->getAvailableLocales( SN_SPELLCHECKER );
             aSpellAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
         }
-        if (bAddAvailable || (SvxLanguageListFlags::HYPH_AVAIL  & nLangList))
+        if (bAddAvailable)
         {
             aTmp = xAvail->getAvailableLocales( SN_HYPHENATOR );
             aHyphAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
         }
-        if (bAddAvailable || (SvxLanguageListFlags::THES_AVAIL  & nLangList))
+        if (bAddAvailable)
         {
             aTmp = xAvail->getAvailableLocales( SN_THESAURUS );
             aThesAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
@@ -608,22 +571,6 @@ void LanguageBox::SetLanguageList( SvxLanguageListFlags nLangList,
         if (xTmp1.is())
             aSpellUsedLang = xTmp1->getLanguages();
     }
-    if (SvxLanguageListFlags::HYPH_USED  & nLangList)
-    {
-        Reference< XHyphenator > xTmp( LinguMgr::GetHyphenator() );
-        if (xTmp.is()) {
-            Sequence < css::lang::Locale > aLocaleSequence( xTmp->getLocales() );
-            aHyphUsedLang = lcl_LocaleSeqToLangSeq( aLocaleSequence );
-        }
-    }
-    if (SvxLanguageListFlags::THES_USED  & nLangList)
-    {
-        Reference< XThesaurus > xTmp( LinguMgr::GetThesaurus() );
-        if (xTmp.is()) {
-            Sequence < css::lang::Locale > aLocaleSequence( xTmp->getLocales() );
-            aThesUsedLang = lcl_LocaleSeqToLangSeq( aLocaleSequence );
-        }
-    }
 
     std::vector<LanguageType> aKnown;
     sal_uInt32 nCount;
@@ -645,22 +592,13 @@ void LanguageBox::SetLanguageList( SvxLanguageListFlags nLangList,
             nLangType = aKnown[i];
         else
             nLangType = SvtLanguageTable::GetLanguageTypeAtIndex( i );
-        if ( lcl_isPrerequisite( nLangType, nLangList) &&
+        if ( lcl_isPrerequisite( nLangType ) &&
              (lcl_isScriptTypeRequested( nLangType, nLangList) ||
               (bool(nLangList & SvxLanguageListFlags::FBD_CHARS) &&
                MsLangId::hasForbiddenCharacters(nLangType)) ||
-              (bool(nLangList & SvxLanguageListFlags::SPELL_AVAIL) &&
-               lcl_SeqHasLang(aSpellAvailLang, nLangType)) ||
-              (bool(nLangList & SvxLanguageListFlags::HYPH_AVAIL) &&
-               lcl_SeqHasLang(aHyphAvailLang, nLangType)) ||
-              (bool(nLangList & SvxLanguageListFlags::THES_AVAIL) &&
-               lcl_SeqHasLang(aThesAvailLang, nLangType)) ||
               (bool(nLangList & SvxLanguageListFlags::SPELL_USED) &&
-               lcl_SeqHasLang(aSpellUsedLang, static_cast<sal_uInt16>(nLangType))) ||
-              (bool(nLangList & SvxLanguageListFlags::HYPH_USED) &&
-               lcl_SeqHasLang(aHyphUsedLang, nLangType)) ||
-              (bool(nLangList & SvxLanguageListFlags::THES_USED) &&
-               lcl_SeqHasLang(aThesUsedLang, nLangType))) )
+               lcl_SeqHasLang(aSpellUsedLang, static_cast<sal_uInt16>(nLangType)))
+              ) )
         {
             aEntries.push_back(BuildEntry(nLangType));
             if (aEntries.back().sString.isEmpty())


More information about the Libreoffice-commits mailing list