Kaydet (Commit) 4586cd75 authored tarafından August Sodora's avatar August Sodora

DECLARE_TABLE->std::map

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