diff options
-rw-r--r-- | cui/source/tabpages/autocdlg.cxx | 40 | ||||
-rw-r--r-- | editeng/source/misc/SvXMLAutoCorrectExport.cxx | 2 | ||||
-rw-r--r-- | editeng/source/misc/SvXMLAutoCorrectImport.cxx | 5 | ||||
-rw-r--r-- | editeng/source/misc/svxacorr.cxx | 52 | ||||
-rw-r--r-- | include/editeng/svxacorr.hxx | 8 |
5 files changed, 44 insertions, 63 deletions
diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index 0ce6b490ee75..0eeb34914a1d 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -1405,20 +1405,17 @@ sal_Bool OfaAutocorrExceptPage::FillItemSet( SfxItemSet& ) sal_uInt16 i; for( i = nCount; i; ) { - OUString* pString = (*pWrdList)[ --i ]; + OUString aString = (*pWrdList)[ --i ]; - if( !lcl_FindInArray(rArrays.aDoubleCapsStrings, *pString)) + if( !lcl_FindInArray(rArrays.aDoubleCapsStrings, aString)) { - delete (*pWrdList)[ i ]; pWrdList->erase(i); } } for(std::vector<OUString>::iterator it = rArrays.aDoubleCapsStrings.begin(); it != rArrays.aDoubleCapsStrings.end(); ++it) { - OUString* s = new OUString(*it); - if(!pWrdList->insert(s).second) - delete s; + pWrdList->insert(*it); } pAutoCorrect->SaveWrdSttExceptList(eCurLang); } @@ -1431,19 +1428,16 @@ sal_Bool OfaAutocorrExceptPage::FillItemSet( SfxItemSet& ) sal_uInt16 i; for( i = nCount; i; ) { - OUString* pString = (*pCplList)[ --i ]; - if( !lcl_FindInArray(rArrays.aAbbrevStrings, *pString)) + OUString aString = (*pCplList)[ --i ]; + if( !lcl_FindInArray(rArrays.aAbbrevStrings, aString)) { - delete (*pCplList)[ i ]; pCplList->erase(i); } } for(std::vector<OUString>::iterator it = rArrays.aAbbrevStrings.begin(); it != rArrays.aAbbrevStrings.end(); ++it) { - OUString* s = new OUString(*it); - if(!pCplList->insert(s).second) - delete s; + pCplList->insert(*it); } pAutoCorrect->SaveCplSttExceptList(eCurLang); @@ -1460,19 +1454,16 @@ sal_Bool OfaAutocorrExceptPage::FillItemSet( SfxItemSet& ) sal_uInt16 i; for( i = nCount; i; ) { - OUString* pString = (*pWrdList)[ --i ]; - if( USHRT_MAX == m_pDoubleCapsLB->GetEntryPos(*pString) ) + OUString aString = (*pWrdList)[ --i ]; + if( USHRT_MAX == m_pDoubleCapsLB->GetEntryPos(aString) ) { - delete (*pWrdList)[ i ]; pWrdList->erase(i); } } nCount = m_pDoubleCapsLB->GetEntryCount(); for( i = 0; i < nCount; ++i ) { - OUString* pEntry = new OUString( m_pDoubleCapsLB->GetEntry( i ) ); - if( !pWrdList->insert( pEntry ).second) - delete pEntry; + pWrdList->insert( m_pDoubleCapsLB->GetEntry( i ) ); } pAutoCorrect->SaveWrdSttExceptList(eLang); } @@ -1485,19 +1476,16 @@ sal_Bool OfaAutocorrExceptPage::FillItemSet( SfxItemSet& ) sal_uInt16 i; for( i = nCount; i; ) { - OUString* pString = (*pCplList)[ --i ]; - if( USHRT_MAX == m_pAbbrevLB->GetEntryPos(*pString) ) + OUString aString = (*pCplList)[ --i ]; + if( USHRT_MAX == m_pAbbrevLB->GetEntryPos(aString) ) { - delete (*pCplList)[ i ]; pCplList->erase(i); } } nCount = m_pAbbrevLB->GetEntryCount(); for( i = 0; i < nCount; ++i ) { - OUString* pEntry = new OUString( m_pAbbrevLB->GetEntry( i ) ); - if( !pCplList->insert( pEntry ).second) - delete pEntry; + pCplList->insert( m_pAbbrevLB->GetEntry( i ) ); } pAutoCorrect->SaveCplSttExceptList(eLang); } @@ -1576,11 +1564,11 @@ void OfaAutocorrExceptPage::RefillReplaceBoxes(sal_Bool bFromReset, sal_uInt16 i; for( i = 0; i < pCplList->size(); i++ ) { - m_pAbbrevLB->InsertEntry(*(*pCplList)[i]); + m_pAbbrevLB->InsertEntry((*pCplList)[i]); } for( i = 0; i < pWrdList->size(); i++ ) { - m_pDoubleCapsLB->InsertEntry(*(*pWrdList)[i]); + m_pDoubleCapsLB->InsertEntry((*pWrdList)[i]); } } } diff --git a/editeng/source/misc/SvXMLAutoCorrectExport.cxx b/editeng/source/misc/SvXMLAutoCorrectExport.cxx index 3fb077043733..dfe0e4e8afe6 100644 --- a/editeng/source/misc/SvXMLAutoCorrectExport.cxx +++ b/editeng/source/misc/SvXMLAutoCorrectExport.cxx @@ -100,7 +100,7 @@ sal_uInt32 SvXMLExceptionListExport::exportDoc(enum XMLTokenEnum /*eClass*/) { AddAttribute( XML_NAMESPACE_BLOCKLIST, XML_ABBREVIATED_NAME, - OUString( *rList[i] ) ); + rList[i] ); SvXMLElementExport aBlock( *this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK, sal_True, sal_True); } } diff --git a/editeng/source/misc/SvXMLAutoCorrectImport.cxx b/editeng/source/misc/SvXMLAutoCorrectImport.cxx index ba6124e78b77..912d1878e5f3 100644 --- a/editeng/source/misc/SvXMLAutoCorrectImport.cxx +++ b/editeng/source/misc/SvXMLAutoCorrectImport.cxx @@ -232,10 +232,7 @@ SvXMLExceptionContext::SvXMLExceptionContext( if (!sWord.Len() ) return; - OUString * pNew = new OUString( sWord ); - - if( !rLocalRef.rList.insert( pNew ).second ) - delete pNew; + rLocalRef.rList.insert( sWord ); } SvXMLExceptionContext::~SvXMLExceptionContext ( void ) diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 7a925432c098..52fdb7c46423 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -1741,7 +1741,7 @@ sal_Bool SvxAutoCorrect::FindInWrdSttExceptList( LanguageType eLang, //the language is available - so bring it on SvxAutoCorrectLanguageLists* pList = pLangTable->find(eLang)->second; OUString _sTemp(sWord); - if(pList->GetWrdSttExceptList()->find(&_sTemp) != pList->GetWrdSttExceptList()->end() ) + if(pList->GetWrdSttExceptList()->find(_sTemp) != pList->GetWrdSttExceptList()->end() ) return sal_True; } @@ -1750,7 +1750,7 @@ sal_Bool SvxAutoCorrect::FindInWrdSttExceptList( LanguageType eLang, { //the language is available - so bring it on SvxAutoCorrectLanguageLists* pList = pLangTable->find(nTmpKey1)->second; - if(pList->GetWrdSttExceptList()->find(&sTemp) != pList->GetWrdSttExceptList()->end() ) + if(pList->GetWrdSttExceptList()->find(sTemp) != pList->GetWrdSttExceptList()->end() ) return sal_True; } @@ -1758,7 +1758,7 @@ sal_Bool SvxAutoCorrect::FindInWrdSttExceptList( LanguageType eLang, { //the language is available - so bring it on SvxAutoCorrectLanguageLists* pList = pLangTable->find(nTmpKey2)->second; - if(pList->GetWrdSttExceptList()->find(&sTemp) != pList->GetWrdSttExceptList()->end() ) + if(pList->GetWrdSttExceptList()->find(sTemp) != pList->GetWrdSttExceptList()->end() ) return sal_True; } @@ -1766,7 +1766,7 @@ sal_Bool SvxAutoCorrect::FindInWrdSttExceptList( LanguageType eLang, { //the language is available - so bring it on SvxAutoCorrectLanguageLists* pList = pLangTable->find(LANGUAGE_UNDETERMINED)->second; - if(pList->GetWrdSttExceptList()->find(&sTemp) != pList->GetWrdSttExceptList()->end() ) + if(pList->GetWrdSttExceptList()->find(sTemp) != pList->GetWrdSttExceptList()->end() ) return sal_True; } return sal_False; @@ -1775,21 +1775,21 @@ sal_Bool SvxAutoCorrect::FindInWrdSttExceptList( LanguageType eLang, static sal_Bool lcl_FindAbbreviation( const SvStringsISortDtor* pList, const String& sWord) { OUString sAbk('~'); - SvStringsISortDtor::const_iterator it = pList->find( &sAbk ); + SvStringsISortDtor::const_iterator it = pList->find( sAbk ); sal_uInt16 nPos = it - pList->begin(); if( nPos < pList->size() ) { String sLowerWord( sWord ); sLowerWord.ToLowerAscii(); - const OUString* pAbk; + OUString pAbk; for( sal_uInt16 n = nPos; n < pList->size() && - '~' == (*( pAbk = (*pList)[ n ]))[ 0 ]; + '~' == ( pAbk = (*pList)[ n ])[ 0 ]; ++n ) { // ~ and ~. are not allowed! - if( 2 < pAbk->getLength() && pAbk->getLength() - 1 <= sWord.Len() ) + if( 2 < pAbk.getLength() && pAbk.getLength() - 1 <= sWord.Len() ) { - String sLowerAbk( *pAbk ); sLowerAbk.ToLowerAscii(); + String sLowerAbk( pAbk ); sLowerAbk.ToLowerAscii(); for( xub_StrLen i = sLowerAbk.Len(), ii = sLowerWord.Len(); i; ) { if( !--i ) // agrees @@ -1801,7 +1801,7 @@ static sal_Bool lcl_FindAbbreviation( const SvStringsISortDtor* pList, const Str } } } - OSL_ENSURE( !(nPos && '~' == (*(*pList)[ --nPos ])[ 0 ] ), + OSL_ENSURE( !(nPos && '~' == (*pList)[ --nPos ][ 0 ] ), "Wrongly sorted exception list?" ); return sal_False; } @@ -1819,7 +1819,7 @@ sal_Bool SvxAutoCorrect::FindInCplSttExceptList(LanguageType eLang, { //the language is available - so bring it on const SvStringsISortDtor* pList = pLangTable->find(eLang)->second->GetCplSttExceptList(); - if(bAbbreviation ? lcl_FindAbbreviation(pList, sWord) : pList->find(&sTemp) != pList->end() ) + if(bAbbreviation ? lcl_FindAbbreviation(pList, sWord) : pList->find(sTemp) != pList->end() ) return sal_True; } @@ -1827,7 +1827,7 @@ sal_Bool SvxAutoCorrect::FindInCplSttExceptList(LanguageType eLang, if(nTmpKey1 != eLang && (pLangTable->find(nTmpKey1) != pLangTable->end() || CreateLanguageFile(nTmpKey1, sal_False))) { const SvStringsISortDtor* pList = pLangTable->find(nTmpKey1)->second->GetCplSttExceptList(); - if(bAbbreviation ? lcl_FindAbbreviation(pList, sWord) : pList->find(&sTemp) != pList->end() ) + if(bAbbreviation ? lcl_FindAbbreviation(pList, sWord) : pList->find(sTemp) != pList->end() ) return sal_True; } @@ -1835,7 +1835,7 @@ sal_Bool SvxAutoCorrect::FindInCplSttExceptList(LanguageType eLang, { //the language is available - so bring it on const SvStringsISortDtor* pList = pLangTable->find(nTmpKey2)->second->GetCplSttExceptList(); - if(bAbbreviation ? lcl_FindAbbreviation(pList, sWord) : pList->find(&sTemp) != pList->end() ) + if(bAbbreviation ? lcl_FindAbbreviation(pList, sWord) : pList->find(sTemp) != pList->end() ) return sal_True; } @@ -1843,7 +1843,7 @@ sal_Bool SvxAutoCorrect::FindInCplSttExceptList(LanguageType eLang, { //the language is available - so bring it on const SvStringsISortDtor* pList = pLangTable->find(LANGUAGE_UNDETERMINED)->second->GetCplSttExceptList(); - if(bAbbreviation ? lcl_FindAbbreviation(pList, sWord) : pList->find(&sTemp) != pList->end() ) + if(bAbbreviation ? lcl_FindAbbreviation(pList, sWord) : pList->find(sTemp) != pList->end() ) return sal_True; } return sal_False; @@ -1929,7 +1929,7 @@ void SvxAutoCorrectLanguageLists::LoadXMLExceptList_Imp( SotStorageRef& rStg) { if( rpLst ) - rpLst->DeleteAndDestroyAll(); + rpLst->clear(); else rpLst = new SvStringsISortDtor; @@ -2123,8 +2123,8 @@ SvStringsISortDtor* SvxAutoCorrectLanguageLists::GetCplSttExceptList() sal_Bool SvxAutoCorrectLanguageLists::AddToCplSttExceptList(const String& rNew) { - OUString* pNew = new OUString( rNew ); - if( rNew.Len() && GetCplSttExceptList()->insert( pNew ).second ) + sal_Bool aRet = sal_False; + if( rNew.Len() && GetCplSttExceptList()->insert( rNew ).second ) { MakeUserStorage_Impl(); SotStorageRef xStg = new SotStorage( sUserAutoCorrFile, STREAM_READWRITE, sal_True ); @@ -2136,17 +2136,16 @@ sal_Bool SvxAutoCorrectLanguageLists::AddToCplSttExceptList(const String& rNew) FStatHelper::GetModifiedDateTimeOfFile( sUserAutoCorrFile, &aModifiedDate, &aModifiedTime ); aLastCheckTime = Time( Time::SYSTEM ); + aRet = sal_True; } - else - delete pNew, pNew = 0; - return 0 != pNew; + return aRet; } sal_Bool SvxAutoCorrectLanguageLists::AddToWrdSttExceptList(const String& rNew) { - OUString* pNew = new OUString( rNew ); + sal_Bool aRet = sal_False; SvStringsISortDtor* pExceptList = LoadWrdSttExceptList(); - if( rNew.Len() && pExceptList && pExceptList->insert( pNew ).second ) + if( rNew.Len() && pExceptList && pExceptList->insert( rNew ).second ) { MakeUserStorage_Impl(); SotStorageRef xStg = new SotStorage( sUserAutoCorrFile, STREAM_READWRITE, sal_True ); @@ -2158,10 +2157,9 @@ sal_Bool SvxAutoCorrectLanguageLists::AddToWrdSttExceptList(const String& rNew) FStatHelper::GetModifiedDateTimeOfFile( sUserAutoCorrFile, &aModifiedDate, &aModifiedTime ); aLastCheckTime = Time( Time::SYSTEM ); + aRet = sal_True; } - else - delete pNew, pNew = 0; - return 0 != pNew; + return aRet; } SvStringsISortDtor* SvxAutoCorrectLanguageLists::LoadCplSttExceptList() @@ -2330,7 +2328,7 @@ void SvxAutoCorrectLanguageLists::MakeUserStorage_Impl() if (pTmpWordList) { SaveExceptList_Imp( *pTmpWordList, pXMLImplWrdStt_ExcptLstStr, xDstStg, sal_True ); - pTmpWordList->DeleteAndDestroyAll(); + pTmpWordList->clear(); pTmpWordList = NULL; } @@ -2341,7 +2339,7 @@ void SvxAutoCorrectLanguageLists::MakeUserStorage_Impl() if (pTmpWordList) { SaveExceptList_Imp( *pTmpWordList, pXMLImplCplStt_ExcptLstStr, xDstStg, sal_True ); - pTmpWordList->DeleteAndDestroyAll(); + pTmpWordList->clear(); } GetAutocorrWordList(); diff --git a/include/editeng/svxacorr.hxx b/include/editeng/svxacorr.hxx index 5c2bd776c777..42b42c5efbb3 100644 --- a/include/editeng/svxacorr.hxx +++ b/include/editeng/svxacorr.hxx @@ -46,17 +46,15 @@ class Window; struct CompareSvStringsISortDtor { - bool operator()( OUString* const& lhs, OUString* const& rhs ) const + bool operator()( OUString const& lhs, OUString const& rhs ) const { - return lhs->compareToIgnoreAsciiCase( *rhs ) < 0; + return lhs.compareToIgnoreAsciiCase( rhs ) < 0; } }; class SvStringsISortDtor - : public o3tl::sorted_vector<OUString*, CompareSvStringsISortDtor> + : public o3tl::sorted_vector<OUString, CompareSvStringsISortDtor> { -public: - ~SvStringsISortDtor() { DeleteAndDestroyAll(); } }; // Auto correct flags |