diff options
Diffstat (limited to 'linguistic/source/dicimp.cxx')
-rwxr-xr-x | linguistic/source/dicimp.cxx | 184 |
1 files changed, 92 insertions, 92 deletions
diff --git a/linguistic/source/dicimp.cxx b/linguistic/source/dicimp.cxx index 01c6838a4d3d..05924609384f 100755 --- a/linguistic/source/dicimp.cxx +++ b/linguistic/source/dicimp.cxx @@ -74,32 +74,32 @@ static const sal_Char* pVerStr5 = "WBSWG5"; static const sal_Char* pVerStr6 = "WBSWG6"; static const sal_Char* pVerOOo7 = "OOoUserDict1"; -static const INT16 DIC_VERSION_DONTKNOW = -1; -static const INT16 DIC_VERSION_2 = 2; -static const INT16 DIC_VERSION_5 = 5; -static const INT16 DIC_VERSION_6 = 6; -static const INT16 DIC_VERSION_7 = 7; +static const sal_Int16 DIC_VERSION_DONTKNOW = -1; +static const sal_Int16 DIC_VERSION_2 = 2; +static const sal_Int16 DIC_VERSION_5 = 5; +static const sal_Int16 DIC_VERSION_6 = 6; +static const sal_Int16 DIC_VERSION_7 = 7; static sal_Bool getTag(const ByteString &rLine, const sal_Char *pTagName, ByteString &rTagValue) { xub_StrLen nPos = rLine.Search( pTagName ); if (nPos == STRING_NOTFOUND) - return FALSE; + return sal_False; rTagValue = rLine.Copy( nPos + sal::static_int_cast< xub_StrLen >(strlen( pTagName )) ).EraseLeadingAndTrailingChars(); - return TRUE; + return sal_True; } -INT16 ReadDicVersion( SvStreamPtr &rpStream, USHORT &nLng, BOOL &bNeg ) +sal_Int16 ReadDicVersion( SvStreamPtr &rpStream, sal_uInt16 &nLng, sal_Bool &bNeg ) { // Sniff the header - INT16 nDicVersion = DIC_VERSION_DONTKNOW; + sal_Int16 nDicVersion = DIC_VERSION_DONTKNOW; sal_Char pMagicHeader[MAX_HEADER_LENGTH]; nLng = LANGUAGE_NONE; - bNeg = FALSE; + bNeg = sal_False; if (!rpStream.get() || rpStream->GetError()) return -1; @@ -140,9 +140,9 @@ INT16 ReadDicVersion( SvStreamPtr &rpStream, USHORT &nLng, BOOL &bNeg ) if (getTag(aLine, "type: ", aTagValue)) { if (aTagValue == "negative") - bNeg = TRUE; + bNeg = sal_True; else - bNeg = FALSE; + bNeg = sal_False; } if (aLine.Search ("---") != STRING_NOTFOUND) // end of header @@ -153,7 +153,7 @@ INT16 ReadDicVersion( SvStreamPtr &rpStream, USHORT &nLng, BOOL &bNeg ) } else { - USHORT nLen; + sal_uInt16 nLen; rpStream->Seek (nSniffPos ); @@ -187,7 +187,7 @@ INT16 ReadDicVersion( SvStreamPtr &rpStream, USHORT &nLng, BOOL &bNeg ) // Negative Flag sal_Char nTmp; *rpStream >> nTmp; - bNeg = (BOOL)nTmp; + bNeg = (sal_Bool)nTmp; } } @@ -210,15 +210,15 @@ DictionaryNeo::DictionaryNeo() : { nCount = 0; nDicVersion = DIC_VERSION_DONTKNOW; - bNeedEntries = FALSE; - bIsModified = bIsActive = FALSE; - bIsReadonly = FALSE; + bNeedEntries = sal_False; + bIsModified = bIsActive = sal_False; + bIsReadonly = sal_False; } DictionaryNeo::DictionaryNeo(const OUString &rName, - INT16 nLang, DictionaryType eType, + sal_Int16 nLang, DictionaryType eType, const OUString &rMainURL, - BOOL bWriteable) : + sal_Bool bWriteable) : aDicEvtListeners( GetLinguMutex() ), aDicName (rName), aMainURL (rMainURL), @@ -227,13 +227,13 @@ DictionaryNeo::DictionaryNeo(const OUString &rName, { nCount = 0; nDicVersion = DIC_VERSION_DONTKNOW; - bNeedEntries = TRUE; - bIsModified = bIsActive = FALSE; + bNeedEntries = sal_True; + bIsModified = bIsActive = sal_False; bIsReadonly = !bWriteable; if( rMainURL.getLength() > 0 ) { - BOOL bExists = FileExists( rMainURL ); + sal_Bool bExists = FileExists( rMainURL ); if( !bExists ) { // save new dictionaries with in Format 7 (UTF8 plain text) @@ -246,14 +246,14 @@ DictionaryNeo::DictionaryNeo(const OUString &rName, "DictionaryNeo: dictionaries should be writeable if they are to be saved" ); if (!bIsReadonly) saveEntries( rMainURL ); - bNeedEntries = FALSE; + bNeedEntries = sal_False; } } else { // non persistent dictionaries (like IgnoreAllList) should always be writable - bIsReadonly = FALSE; - bNeedEntries = FALSE; + bIsReadonly = sal_False; + bNeedEntries = sal_False; } } @@ -261,16 +261,16 @@ DictionaryNeo::~DictionaryNeo() { } -ULONG DictionaryNeo::loadEntries(const OUString &rMainURL) +sal_uLong DictionaryNeo::loadEntries(const OUString &rMainURL) { MutexGuard aGuard( GetLinguMutex() ); - // counter check that it is safe to set bIsModified to FALSE at + // counter check that it is safe to set bIsModified to sal_False at // the end of the function DBG_ASSERT(!bIsModified, "lng : dictionary already modified!"); // function should only be called once in order to load entries from file - bNeedEntries = FALSE; + bNeedEntries = sal_False; if (rMainURL.getLength() == 0) return 0; @@ -291,15 +291,15 @@ ULONG DictionaryNeo::loadEntries(const OUString &rMainURL) (void) e; } if (!xStream.is()) - return static_cast< ULONG >(-1); + return static_cast< sal_uLong >(-1); SvStreamPtr pStream = SvStreamPtr( utl::UcbStreamHelper::CreateStream( xStream ) ); - ULONG nErr = sal::static_int_cast< ULONG >(-1); + sal_uLong nErr = sal::static_int_cast< sal_uLong >(-1); // Header einlesen - BOOL bNegativ; - USHORT nLang; + sal_Bool bNegativ; + sal_uInt16 nLang; nDicVersion = ReadDicVersion(pStream, nLang, bNegativ); if (0 != (nErr = pStream->GetError())) return nErr; @@ -317,7 +317,7 @@ ULONG DictionaryNeo::loadEntries(const OUString &rMainURL) DIC_VERSION_5 == nDicVersion || DIC_VERSION_2 == nDicVersion) { - USHORT nLen = 0; + sal_uInt16 nLen = 0; sal_Char aWordBuf[ BUFSIZE ]; // Das erste Wort einlesen @@ -345,7 +345,7 @@ ULONG DictionaryNeo::loadEntries(const OUString &rMainURL) String aText( aDummy, eEnc ); uno::Reference< XDictionaryEntry > xEntry = new DicEntry( aText, bNegativ ); - addEntry_Impl( xEntry , TRUE ); //! don't launch events here + addEntry_Impl( xEntry , sal_True ); //! don't launch events here } *pStream >> nLen; @@ -382,7 +382,7 @@ ULONG DictionaryNeo::loadEntries(const OUString &rMainURL) rtl::OUString aText = rtl::OStringToOUString (aLine, RTL_TEXTENCODING_UTF8); uno::Reference< XDictionaryEntry > xEntry = new DicEntry( aText, eDicType == DictionaryType_NEGATIVE ); - addEntry_Impl( xEntry , TRUE ); //! don't launch events here + addEntry_Impl( xEntry , sal_True ); //! don't launch events here } } @@ -391,7 +391,7 @@ ULONG DictionaryNeo::loadEntries(const OUString &rMainURL) // since this routine should be called only initialy (prior to any // modification to be saved) we reset the bIsModified flag here that // was implicitly set by addEntry_Impl - bIsModified = FALSE; + bIsModified = sal_False; return pStream->GetError(); } @@ -411,7 +411,7 @@ static ByteString formatForSave( } -ULONG DictionaryNeo::saveEntries(const OUString &rURL) +sal_uLong DictionaryNeo::saveEntries(const OUString &rURL) { MutexGuard aGuard( GetLinguMutex() ); @@ -435,10 +435,10 @@ ULONG DictionaryNeo::saveEntries(const OUString &rURL) (void) e; } if (!xStream.is()) - return static_cast< ULONG >(-1); + return static_cast< sal_uLong >(-1); SvStreamPtr pStream = SvStreamPtr( utl::UcbStreamHelper::CreateStream( xStream ) ); - ULONG nErr = sal::static_int_cast< ULONG >(-1); + sal_uLong nErr = sal::static_int_cast< sal_uLong >(-1); // // Always write as the latest version, i.e. DIC_VERSION_7 @@ -467,7 +467,7 @@ ULONG DictionaryNeo::saveEntries(const OUString &rURL) if (0 != (nErr = pStream->GetError())) return nErr; const uno::Reference< XDictionaryEntry > *pEntry = aEntries.getConstArray(); - for (INT32 i = 0; i < nCount; i++) + for (sal_Int32 i = 0; i < nCount; i++) { ByteString aOutStr = formatForSave(pEntry[i], eEnc); pStream->WriteLine (aOutStr); @@ -482,7 +482,7 @@ ULONG DictionaryNeo::saveEntries(const OUString &rURL) return nErr; } -void DictionaryNeo::launchEvent(INT16 nEvent, +void DictionaryNeo::launchEvent(sal_Int16 nEvent, uno::Reference< XDictionaryEntry > xEntry) { MutexGuard aGuard( GetLinguMutex() ); @@ -503,7 +503,7 @@ void DictionaryNeo::launchEvent(INT16 nEvent, int DictionaryNeo::cmpDicEntry(const OUString& rWord1, const OUString &rWord2, - BOOL bSimilarOnly) + sal_Bool bSimilarOnly) { MutexGuard aGuard( GetLinguMutex() ); @@ -515,7 +515,7 @@ int DictionaryNeo::cmpDicEntry(const OUString& rWord1, OUString aWord1( rWord1 ), aWord2( rWord2 ); - INT32 nLen1 = aWord1.getLength(), + sal_Int32 nLen1 = aWord1.getLength(), nLen2 = aWord2.getLength(); if (bSimilarOnly) { @@ -527,7 +527,7 @@ int DictionaryNeo::cmpDicEntry(const OUString& rWord1, } const sal_Unicode cIgnChar = '='; - INT32 nIdx1 = 0, + sal_Int32 nIdx1 = 0, nIdx2 = 0, nNumIgnChar1 = 0, nNumIgnChar2 = 0; @@ -578,17 +578,17 @@ int DictionaryNeo::cmpDicEntry(const OUString& rWord1, nNumIgnChar2++; } - nRes = ((INT32) nLen1 - nNumIgnChar1) - ((INT32) nLen2 - nNumIgnChar2); + nRes = ((sal_Int32) nLen1 - nNumIgnChar1) - ((sal_Int32) nLen2 - nNumIgnChar2); } return nRes; } -BOOL DictionaryNeo::seekEntry(const OUString &rWord, - INT32 *pPos, BOOL bSimilarOnly) +sal_Bool DictionaryNeo::seekEntry(const OUString &rWord, + sal_Int32 *pPos, sal_Bool bSimilarOnly) { // look for entry with binary search. - // return TRUE if found FALSE else. + // return sal_True if found sal_False else. // if pPos != NULL it will become the position of the found entry, or // if that was not found the position where it has to be inserted // to keep the entries sorted @@ -596,7 +596,7 @@ BOOL DictionaryNeo::seekEntry(const OUString &rWord, MutexGuard aGuard( GetLinguMutex() ); const uno::Reference< XDictionaryEntry > *pEntry = aEntries.getConstArray(); - INT32 nUpperIdx = getCount(), + sal_Int32 nUpperIdx = getCount(), nMidIdx, nLowerIdx = 0; if( nUpperIdx > 0 ) @@ -612,66 +612,66 @@ BOOL DictionaryNeo::seekEntry(const OUString &rWord, if(nCmp == 0) { if( pPos ) *pPos = nMidIdx; - return TRUE; + return sal_True; } else if(nCmp > 0) nLowerIdx = nMidIdx + 1; else if( nMidIdx == 0 ) { if( pPos ) *pPos = nLowerIdx; - return FALSE; + return sal_False; } else nUpperIdx = nMidIdx - 1; } } if( pPos ) *pPos = nLowerIdx; - return FALSE; + return sal_False; } -BOOL DictionaryNeo::isSorted() +sal_Bool DictionaryNeo::isSorted() { - BOOL bRes = TRUE; + sal_Bool bRes = sal_True; const uno::Reference< XDictionaryEntry > *pEntry = aEntries.getConstArray(); - INT32 nEntries = getCount(); - INT32 i; + sal_Int32 nEntries = getCount(); + sal_Int32 i; for (i = 1; i < nEntries; i++) { if (cmpDicEntry( pEntry[i-1]->getDictionaryWord(), pEntry[i]->getDictionaryWord() ) > 0) { - bRes = FALSE; + bRes = sal_False; break; } } return bRes; } -BOOL DictionaryNeo::addEntry_Impl(const uno::Reference< XDictionaryEntry > xDicEntry, - BOOL bIsLoadEntries) +sal_Bool DictionaryNeo::addEntry_Impl(const uno::Reference< XDictionaryEntry > xDicEntry, + sal_Bool bIsLoadEntries) { MutexGuard aGuard( GetLinguMutex() ); - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; if ( bIsLoadEntries || (!bIsReadonly && xDicEntry.is()) ) { - BOOL bIsNegEntry = xDicEntry->isNegative(); - BOOL bAddEntry = !isFull() && + sal_Bool bIsNegEntry = xDicEntry->isNegative(); + sal_Bool bAddEntry = !isFull() && ( ( eDicType == DictionaryType_POSITIVE && !bIsNegEntry ) || ( eDicType == DictionaryType_NEGATIVE && bIsNegEntry ) || ( eDicType == DictionaryType_MIXED ) ); // look for position to insert entry at // if there is already an entry do not insert the new one - INT32 nPos = 0; - BOOL bFound = FALSE; + sal_Int32 nPos = 0; + sal_Bool bFound = sal_False; if (bAddEntry) { bFound = seekEntry( xDicEntry->getDictionaryWord(), &nPos ); if (bFound) - bAddEntry = FALSE; + bAddEntry = sal_False; } if (bAddEntry) @@ -683,7 +683,7 @@ BOOL DictionaryNeo::addEntry_Impl(const uno::Reference< XDictionaryEntry > xDicE uno::Reference< XDictionaryEntry > *pEntry = aEntries.getArray(); // shift old entries right - INT32 i; + sal_Int32 i; for (i = nCount - 1; i >= nPos; i--) pEntry[ i+1 ] = pEntry[ i ]; // insert new entry at specified position @@ -692,8 +692,8 @@ BOOL DictionaryNeo::addEntry_Impl(const uno::Reference< XDictionaryEntry > xDicE nCount++; - bIsModified = TRUE; - bRes = TRUE; + bIsModified = sal_True; + bRes = sal_True; if (!bIsLoadEntries) launchEvent( DictionaryEventFlags::ADD_ENTRY, xDicEntry ); @@ -748,13 +748,13 @@ void SAL_CALL DictionaryNeo::setActive( sal_Bool bActivate ) if (bIsActive != bActivate) { bIsActive = bActivate != 0; - INT16 nEvent = bIsActive ? + sal_Int16 nEvent = bIsActive ? DictionaryEventFlags::ACTIVATE_DIC : DictionaryEventFlags::DEACTIVATE_DIC; // remove entries from memory if dictionary is deactivated - if (bIsActive == FALSE) + if (bIsActive == sal_False) { - BOOL bIsEmpty = nCount == 0; + sal_Bool bIsEmpty = nCount == 0; // save entries first if necessary if (bIsModified && hasLocation() && !isReadonly()) @@ -802,11 +802,11 @@ void SAL_CALL DictionaryNeo::setLocale( const Locale& aLocale ) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); - INT16 nLanguageP = LocaleToLanguage( aLocale ); + sal_Int16 nLanguageP = LocaleToLanguage( aLocale ); if (!bIsReadonly && nLanguage != nLanguageP) { nLanguage = nLanguageP; - bIsModified = TRUE; // new language needs to be saved with dictionary + bIsModified = sal_True; // new language needs to be saved with dictionary launchEvent( DictionaryEventFlags::CHG_LANGUAGE, NULL ); } @@ -821,8 +821,8 @@ uno::Reference< XDictionaryEntry > SAL_CALL DictionaryNeo::getEntry( if (bNeedEntries) loadEntries( aMainURL ); - INT32 nPos; - BOOL bFound = seekEntry( aWord, &nPos, TRUE ); + sal_Int32 nPos; + sal_Bool bFound = seekEntry( aWord, &nPos, sal_True ); DBG_ASSERT( nCount <= aEntries.getLength(), "lng : wrong number of entries"); DBG_ASSERT(!bFound || nPos < nCount, "lng : index out of range"); @@ -836,7 +836,7 @@ sal_Bool SAL_CALL DictionaryNeo::addEntry( { MutexGuard aGuard( GetLinguMutex() ); - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; if (!bIsReadonly) { @@ -855,7 +855,7 @@ sal_Bool SAL_CALL { MutexGuard aGuard( GetLinguMutex() ); - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; if (!bIsReadonly) { @@ -892,15 +892,15 @@ sal_Bool SAL_CALL DictionaryNeo::remove( const OUString& aWord ) { MutexGuard aGuard( GetLinguMutex() ); - BOOL bRemoved = FALSE; + sal_Bool bRemoved = sal_False; if (!bIsReadonly) { if (bNeedEntries) loadEntries( aMainURL ); - INT32 nPos; - BOOL bFound = seekEntry( aWord, &nPos ); + sal_Int32 nPos; + sal_Bool bFound = seekEntry( aWord, &nPos ); DBG_ASSERT( nCount < aEntries.getLength(), "lng : wrong number of entries"); DBG_ASSERT(!bFound || nPos < nCount, "lng : index out of range"); @@ -917,7 +917,7 @@ sal_Bool SAL_CALL DictionaryNeo::remove( const OUString& aWord ) //! the following call reduces the length of the sequence by 1 also lcl_SequenceRemoveElementAt( aEntries, nPos ); - bRemoved = bIsModified = TRUE; + bRemoved = bIsModified = sal_True; launchEvent( DictionaryEventFlags::DEL_ENTRY, xDicEntry ); } @@ -962,8 +962,8 @@ void SAL_CALL DictionaryNeo::clear( ) aEntries = uno::Sequence< uno::Reference< XDictionaryEntry > > ( 32 ); nCount = 0; - bNeedEntries = FALSE; - bIsModified = TRUE; + bNeedEntries = sal_False; + bIsModified = sal_True; launchEvent( DictionaryEventFlags::ENTRIES_CLEARED , NULL ); } @@ -975,10 +975,10 @@ sal_Bool SAL_CALL DictionaryNeo::addDictionaryEventListener( { MutexGuard aGuard( GetLinguMutex() ); - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; if (xListener.is()) { - INT32 nLen = aDicEvtListeners.getLength(); + sal_Int32 nLen = aDicEvtListeners.getLength(); bRes = aDicEvtListeners.addInterface( xListener ) != nLen; } return bRes; @@ -990,10 +990,10 @@ sal_Bool SAL_CALL DictionaryNeo::removeDictionaryEventListener( { MutexGuard aGuard( GetLinguMutex() ); - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; if (xListener.is()) { - INT32 nLen = aDicEvtListeners.getLength(); + sal_Int32 nLen = aDicEvtListeners.getLength(); bRes = aDicEvtListeners.removeInterface( xListener ) != nLen; } return bRes; @@ -1036,7 +1036,7 @@ void SAL_CALL DictionaryNeo::store() #endif } else - bIsModified = FALSE; + bIsModified = sal_False; } } @@ -1056,7 +1056,7 @@ void SAL_CALL DictionaryNeo::storeAsURL( else { aMainURL = aURL; - bIsModified = FALSE; + bIsModified = sal_False; bIsReadonly = IsReadOnly( getLocation() ); } } @@ -1080,18 +1080,18 @@ void SAL_CALL DictionaryNeo::storeToURL( DicEntry::DicEntry() { - bIsNegativ = FALSE; + bIsNegativ = sal_False; } DicEntry::DicEntry(const OUString &rDicFileWord, - BOOL bIsNegativWord) + sal_Bool bIsNegativWord) { if (rDicFileWord.getLength()) splitDicFileWord( rDicFileWord, aDicWord, aReplacement ); bIsNegativ = bIsNegativWord; } -DicEntry::DicEntry(const OUString &rDicWord, BOOL bNegativ, +DicEntry::DicEntry(const OUString &rDicWord, sal_Bool bNegativ, const OUString &rRplcText) : aDicWord (rDicWord), aReplacement (rRplcText), |