[Libreoffice-commits] .: editeng/inc editeng/source

August Sodora augsod at kemper.freedesktop.org
Fri Dec 23 13:24:46 PST 2011


 editeng/inc/editeng/svxacorr.hxx |    5 +++--
 editeng/source/misc/svxacorr.cxx |   25 ++++++++++---------------
 2 files changed, 13 insertions(+), 17 deletions(-)

New commits:
commit 4586cd75646bb2396490d670d11b0b2e30fe4796
Author: August Sodora <augsod at gmail.com>
Date:   Fri Dec 23 16:17:40 2011 -0500

    DECLARE_TABLE->std::map

diff --git a/editeng/inc/editeng/svxacorr.hxx b/editeng/inc/editeng/svxacorr.hxx
index ed0d528..aabc644 100644
--- a/editeng/inc/editeng/svxacorr.hxx
+++ b/editeng/inc/editeng/svxacorr.hxx
@@ -39,13 +39,14 @@
 #include <editeng/swafopt.hxx>
 #include "editeng/editengdllapi.h"
 
+#include <map>
+
 class CharClass;
 class SfxPoolItem;
 class SvxAutoCorrect;
 class SvStringsISortDtor;
 class SfxObjectShell;
 class SvxAutoCorrLanguageTable_Impl;
-class SvxAutoCorrLastFileAskTable_Impl;
 class SotStorageRef;
 class SotStorage;
 class Window;
@@ -208,7 +209,7 @@ class EDITENG_DLLPUBLIC SvxAutoCorrect
 
     // all languages in a table
     SvxAutoCorrLanguageTable_Impl* pLangTable;
-    SvxAutoCorrLastFileAskTable_Impl* pLastFileTable;
+    std::map<LanguageType, long>* pLastFileTable;
     CharClass* pCharClass;
 
     bool bRunNext;
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index e8cd59c..c2d937a 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -120,9 +120,6 @@ TYPEINIT0(SvxAutoCorrect)
 typedef SvxAutoCorrectLanguageLists* SvxAutoCorrectLanguageListsPtr;
 DECLARE_TABLE( SvxAutoCorrLanguageTable_Impl,  SvxAutoCorrectLanguageListsPtr)
 
-DECLARE_TABLE( SvxAutoCorrLastFileAskTable_Impl, long )
-
-
 inline int IsWordDelim( const sal_Unicode c )
 {
     return ' ' == c || '\t' == c || 0x0a == c ||
@@ -345,7 +342,7 @@ SvxAutoCorrect::SvxAutoCorrect( const String& rShareAutocorrFile,
     : sShareAutoCorrFile( rShareAutocorrFile ),
     sUserAutoCorrFile( rUserAutocorrFile ),
     pLangTable( new SvxAutoCorrLanguageTable_Impl ),
-    pLastFileTable( new SvxAutoCorrLastFileAskTable_Impl ),
+    pLastFileTable( new std::map<LanguageType, long> ),
     pCharClass( 0 ), bRunNext( false ),
     cStartDQuote( 0 ), cEndDQuote( 0 ), cStartSQuote( 0 ), cEndSQuote( 0 )
 {
@@ -362,7 +359,7 @@ SvxAutoCorrect::SvxAutoCorrect( const SvxAutoCorrect& rCpy )
     aSwFlags( rCpy.aSwFlags ),
 
     pLangTable( new SvxAutoCorrLanguageTable_Impl ),
-    pLastFileTable( new SvxAutoCorrLastFileAskTable_Impl ),
+    pLastFileTable( new std::map<LanguageType, long> ),
     pCharClass( 0 ), bRunNext( false ),
 
     nFlags( rCpy.nFlags & ~(ChgWordLstLoad|CplSttLstLoad|WrdSttLstLoad)),
@@ -1618,12 +1615,11 @@ sal_Bool SvxAutoCorrect::CreateLanguageFile( LanguageType eLang, sal_Bool bNewFi
     SvxAutoCorrectLanguageListsPtr pLists = 0;
 
     Time nMinTime( 0, 2 ), nAktTime( Time::SYSTEM ), nLastCheckTime( Time::EMPTY );
-    sal_uLong nFndPos;
-    if( TABLE_ENTRY_NOTFOUND !=
-                    pLastFileTable->SearchKey( sal_uLong( eLang ), &nFndPos ) &&
-        ( nLastCheckTime.SetTime( pLastFileTable->GetObject( nFndPos )),
-            nLastCheckTime < nAktTime ) &&
-        ( nAktTime - nLastCheckTime ) < nMinTime )
+
+    std::map<LanguageType, long>::iterator nFndPos = pLastFileTable->find(eLang);
+    if(nFndPos != pLastFileTable->end() &&
+       (nLastCheckTime.SetTime(nFndPos->second), nLastCheckTime < nAktTime) &&
+       nAktTime - nLastCheckTime < nMinTime)
     {
         // no need to test the file, because the last check is not older then
         // 2 minutes.
@@ -1633,7 +1629,7 @@ sal_Bool SvxAutoCorrect::CreateLanguageFile( LanguageType eLang, sal_Bool bNewFi
             pLists = new SvxAutoCorrectLanguageLists( *this, sShareDirFile,
                                                         sUserDirFile, eLang );
             pLangTable->Insert( sal_uLong(eLang), pLists );
-            pLastFileTable->Remove( sal_uLong( eLang ) );
+            pLastFileTable->erase(nFndPos);
         }
     }
     else if( ( FStatHelper::IsDocument( sUserDirFile ) ||
@@ -1644,12 +1640,11 @@ sal_Bool SvxAutoCorrect::CreateLanguageFile( LanguageType eLang, sal_Bool bNewFi
         pLists = new SvxAutoCorrectLanguageLists( *this, sShareDirFile,
                                                     sUserDirFile, eLang );
         pLangTable->Insert( sal_uLong(eLang), pLists );
-        pLastFileTable->Remove( sal_uLong( eLang ) );
+        pLastFileTable->erase(nFndPos);
     }
     else if( !bNewFile )
     {
-        if( !pLastFileTable->Insert( sal_uLong( eLang ), nAktTime.GetTime() ))
-            pLastFileTable->Replace( sal_uLong( eLang ), nAktTime.GetTime() );
+        pLastFileTable[eLang] = { std::make_pair(eLang, nAktTime.GetTime()) };
     }
     return pLists != 0;
 }


More information about the Libreoffice-commits mailing list