sw/inc/doc.hxx | 22 +++++----- sw/inc/editsh.hxx | 6 +- sw/source/core/doc/docfld.cxx | 79 +++++++++++++++++-------------------- sw/source/core/edit/edfld.cxx | 6 +- sw/source/ui/app/apphdl.cxx | 13 ++---- sw/source/ui/dbui/dbmgr.cxx | 4 - sw/source/ui/dbui/mmconfigitem.cxx | 6 +- sw/source/ui/fldui/changedb.cxx | 17 ++++--- sw/source/ui/uiview/view2.cxx | 8 +-- 9 files changed, 79 insertions(+), 82 deletions(-)
New commits: commit a8c8eae8d507bd254a476f5c4cd107793a725866 Author: August Sodora <aug...@gmail.com> Date: Fri Jan 13 00:20:39 2012 -0500 SvStringsDtor->std::vector diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index e85ba27..47b55ec 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -652,16 +652,16 @@ private: // Database fields: void UpdateDBNumFlds( SwDBNameInfField& rDBFld, SwCalc& rCalc ); - void AddUsedDBToList( SvStringsDtor& rDBNameList, - const SvStringsDtor& rUsedDBNames ); - void AddUsedDBToList( SvStringsDtor& rDBNameList, const String& rDBName ); - sal_Bool IsNameInArray( const SvStringsDtor& rOldNames, const String& rName ); - void GetAllDBNames( SvStringsDtor& rAllDBNames ); - void ReplaceUsedDBs( const SvStringsDtor& rUsedDBNames, + void AddUsedDBToList( std::vector<String>& rDBNameList, + const std::vector<String>& rUsedDBNames ); + void AddUsedDBToList( std::vector<String>& rDBNameList, const String& rDBName ); + sal_Bool IsNameInArray( const std::vector<String>& rOldNames, const String& rName ); + void GetAllDBNames( std::vector<String>& rAllDBNames ); + void ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, const String& rNewName, String& rFormel ); - SvStringsDtor& FindUsedDBs( const SvStringsDtor& rAllDBNames, + std::vector<String>& FindUsedDBs( const std::vector<String>& rAllDBNames, const String& rFormel, - SvStringsDtor& rUsedDBNames ); + std::vector<String>& rUsedDBNames ); void InitDrawModel(); void ReleaseDrawModel(); @@ -1129,13 +1129,13 @@ public: */ void SetNewDBMgr( SwNewDBMgr* pNewMgr ) { pNewDBMgr = pNewMgr; } SwNewDBMgr* GetNewDBMgr() const { return pNewDBMgr; } - void ChangeDBFields( const SvStringsDtor& rOldNames, + void ChangeDBFields( const std::vector<String>& rOldNames, const String& rNewName ); void SetInitDBFields(sal_Bool b); // Find out which databases are used by fields. - void GetAllUsedDB( SvStringsDtor& rDBNameList, - const SvStringsDtor* pAllDBNames = 0 ); + void GetAllUsedDB( std::vector<String>& rDBNameList, + const std::vector<String>* pAllDBNames = 0 ); void ChgDBData( const SwDBData& rNewData ); SwDBData GetDBData(); diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index 11e3376..173de37 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -346,10 +346,10 @@ public: SwDBData GetDBData() const; const SwDBData& GetDBDesc() const; void ChgDBData(const SwDBData& SwDBData); - void ChangeDBFields( const SvStringsDtor& rOldNames, + void ChangeDBFields( const std::vector<String>& rOldNames, const String& rNewName ); - void GetAllUsedDB( SvStringsDtor& rDBNameList, - SvStringsDtor* pAllDBNames = 0 ); + void GetAllUsedDB( std::vector<String>& rDBNameList, + std::vector<String>* pAllDBNames = 0 ); sal_Bool IsAnyDatabaseFieldInDoc()const; diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 670190f..198e794 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -1665,11 +1665,11 @@ String lcl_DBDataToString(const SwDBData& rData) return sRet; } -void SwDoc::GetAllUsedDB( SvStringsDtor& rDBNameList, - const SvStringsDtor* pAllDBNames ) +void SwDoc::GetAllUsedDB( std::vector<String>& rDBNameList, + const std::vector<String>* pAllDBNames ) { - SvStringsDtor aUsedDBNames; - SvStringsDtor aAllDBNames; + std::vector<String> aUsedDBNames; + std::vector<String> aAllDBNames; if( !pAllDBNames ) { @@ -1687,7 +1687,7 @@ void SwDoc::GetAllUsedDB( SvStringsDtor& rDBNameList, String aCond( pSect->GetCondition() ); AddUsedDBToList( rDBNameList, FindUsedDBs( *pAllDBNames, aCond, aUsedDBNames ) ); - aUsedDBNames.DeleteAndDestroy( 0, aUsedDBNames.Count() ); + aUsedDBNames.clear(); } } @@ -1727,7 +1727,7 @@ void SwDoc::GetAllUsedDB( SvStringsDtor& rDBNameList, case RES_HIDDENPARAFLD: AddUsedDBToList(rDBNameList, FindUsedDBs( *pAllDBNames, pFld->GetPar1(), aUsedDBNames )); - aUsedDBNames.DeleteAndDestroy( 0, aUsedDBNames.Count() ); + aUsedDBNames.clear(); break; case RES_SETEXPFLD: @@ -1735,13 +1735,13 @@ void SwDoc::GetAllUsedDB( SvStringsDtor& rDBNameList, case RES_TABLEFLD: AddUsedDBToList(rDBNameList, FindUsedDBs( *pAllDBNames, pFld->GetFormula(), aUsedDBNames )); - aUsedDBNames.DeleteAndDestroy( 0, aUsedDBNames.Count() ); + aUsedDBNames.clear(); break; } } } -void SwDoc::GetAllDBNames( SvStringsDtor& rAllDBNames ) +void SwDoc::GetAllDBNames( std::vector<String>& rAllDBNames ) { SwNewDBMgr* pMgr = GetNewDBMgr(); @@ -1752,13 +1752,13 @@ void SwDoc::GetAllDBNames( SvStringsDtor& rAllDBNames ) String* pStr = new String( pParam->sDataSource ); (*pStr) += DB_DELIM; (*pStr) += (String)pParam->sCommand; - rAllDBNames.Insert( pStr, rAllDBNames.Count() ); + rAllDBNames.push_back(*pStr); } } -SvStringsDtor& SwDoc::FindUsedDBs( const SvStringsDtor& rAllDBNames, +std::vector<String>& SwDoc::FindUsedDBs( const std::vector<String>& rAllDBNames, const String& rFormel, - SvStringsDtor& rUsedDBNames ) + std::vector<String>& rUsedDBNames ) { const CharClass& rCC = GetAppCharClass(); String sFormel( rFormel); @@ -1767,49 +1767,48 @@ SvStringsDtor& SwDoc::FindUsedDBs( const SvStringsDtor& rAllDBNames, #endif xub_StrLen nPos; - for (sal_uInt16 i = 0; i < rAllDBNames.Count(); ++i ) + for (sal_uInt16 i = 0; i < rAllDBNames.size(); ++i ) { - const String* pStr = rAllDBNames.GetObject(i); + String pStr(rAllDBNames[i]); - if( STRING_NOTFOUND != (nPos = sFormel.Search( *pStr )) && - sFormel.GetChar( nPos + pStr->Len() ) == '.' && + if( STRING_NOTFOUND != (nPos = sFormel.Search( pStr )) && + sFormel.GetChar( nPos + pStr.Len() ) == '.' && (!nPos || !rCC.isLetterNumeric( sFormel, nPos - 1 ))) { // Look up table name xub_StrLen nEndPos; - nPos += pStr->Len() + 1; + nPos += pStr.Len() + 1; if( STRING_NOTFOUND != (nEndPos = sFormel.Search('.', nPos)) ) { - String* pDBNm = new String( *pStr ); - pDBNm->Append( DB_DELIM ); - pDBNm->Append( sFormel.Copy( nPos, nEndPos - nPos )); - rUsedDBNames.Insert( pDBNm, rUsedDBNames.Count() ); + pStr.Append( DB_DELIM ); + pStr.Append( sFormel.Copy( nPos, nEndPos - nPos )); + rUsedDBNames.push_back(pStr); } } } return rUsedDBNames; } -void SwDoc::AddUsedDBToList( SvStringsDtor& rDBNameList, - const SvStringsDtor& rUsedDBNames ) +void SwDoc::AddUsedDBToList( std::vector<String>& rDBNameList, + const std::vector<String>& rUsedDBNames ) { - for (sal_uInt16 i = 0; i < rUsedDBNames.Count(); i++) - AddUsedDBToList( rDBNameList, *rUsedDBNames.GetObject(i) ); + for (sal_uInt16 i = 0; i < rUsedDBNames.size(); ++i) + AddUsedDBToList( rDBNameList, rUsedDBNames[i] ); } -void SwDoc::AddUsedDBToList( SvStringsDtor& rDBNameList, const String& rDBName) +void SwDoc::AddUsedDBToList( std::vector<String>& rDBNameList, const String& rDBName) { if( !rDBName.Len() ) return; #ifdef UNX - for( sal_uInt16 i = 0; i < rDBNameList.Count(); ++i ) - if( rDBName == rDBNameList.GetObject(i)->GetToken(0) ) + for( sal_uInt16 i = 0; i < rDBNameList.size(); ++i ) + if( rDBName == rDBNameList[i].GetToken(0) ) return; #else const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore(); - for( sal_uInt16 i = 0; i < rDBNameList.Count(); ++i ) - if( rSCmp.isEqual( rDBName, rDBNameList.GetObject(i)->GetToken(0) ) ) + for( sal_uInt16 i = 0; i < rDBNameList.size(); ++i ) + if( rSCmp.isEqual( rDBName, rDBNameList[i].GetToken(0) ) ) return; #endif @@ -1818,11 +1817,10 @@ void SwDoc::AddUsedDBToList( SvStringsDtor& rDBNameList, const String& rDBName) aData.sCommand = rDBName.GetToken(1, DB_DELIM); aData.nCommandType = -1; GetNewDBMgr()->CreateDSData(aData); - String* pNew = new String( rDBName ); - rDBNameList.Insert( pNew, rDBNameList.Count() ); + rDBNameList.push_back(rDBName); } -void SwDoc::ChangeDBFields( const SvStringsDtor& rOldNames, +void SwDoc::ChangeDBFields( const std::vector<String>& rOldNames, const String& rNewName ) { SwDBData aNewDBData; @@ -1924,7 +1922,7 @@ void SwDoc::ChangeDBFields( const SvStringsDtor& rOldNames, SetModified(); } -void SwDoc::ReplaceUsedDBs( const SvStringsDtor& rUsedDBNames, +void SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, const String& rNewName, String& rFormel ) { const CharClass& rCC = GetAppCharClass(); @@ -1935,10 +1933,9 @@ void SwDoc::ReplaceUsedDBs( const SvStringsDtor& rUsedDBNames, sNewName = sNewName.GetToken(0, DB_DELIM); String sUpperNewNm( sNewName ); - - for( sal_uInt16 i = 0; i < rUsedDBNames.Count(); ++i ) + for( sal_uInt16 i = 0; i < rUsedDBNames.size(); ++i ) { - String sDBName( *rUsedDBNames.GetObject( i ) ); + String sDBName( rUsedDBNames[i] ); sDBName.SearchAndReplace( DB_DELIM, '.'); //cut off command type @@ -1965,16 +1962,16 @@ void SwDoc::ReplaceUsedDBs( const SvStringsDtor& rUsedDBNames, } } -sal_Bool SwDoc::IsNameInArray( const SvStringsDtor& rArr, const String& rName ) +sal_Bool SwDoc::IsNameInArray( const std::vector<String>& rArr, const String& rName ) { #ifdef UNX - for( sal_uInt16 i = 0; i < rArr.Count(); ++i ) - if( rName == *rArr[ i ] ) + for( sal_uInt16 i = 0; i < rArr.size(); ++i ) + if( rName == rArr[ i ] ) return sal_True; #else const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore(); - for( sal_uInt16 i = 0; i < rArr.Count(); ++i ) - if( rSCmp.isEqual( rName, *rArr[ i] )) + for( sal_uInt16 i = 0; i < rArr.size(); ++i ) + if( rSCmp.isEqual( rName, rArr[ i] )) return sal_True; #endif return sal_False; diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx index 06f0a7b..49967fb 100644 --- a/sw/source/core/edit/edfld.cxx +++ b/sw/source/core/edit/edfld.cxx @@ -432,13 +432,13 @@ void SwEditShell::ChgDBData(const SwDBData& rNewData) GetDoc()->ChgDBData(rNewData); } -void SwEditShell::GetAllUsedDB( SvStringsDtor& rDBNameList, - SvStringsDtor* pAllDBNames ) +void SwEditShell::GetAllUsedDB( std::vector<String>& rDBNameList, + std::vector<String>* pAllDBNames ) { GetDoc()->GetAllUsedDB( rDBNameList, pAllDBNames ); } -void SwEditShell::ChangeDBFields( const SvStringsDtor& rOldNames, +void SwEditShell::ChangeDBFields( const std::vector<String>& rOldNames, const String& rNewName ) { GetDoc()->ChangeDBFields( rOldNames, rNewName ); diff --git a/sw/source/ui/app/apphdl.cxx b/sw/source/ui/app/apphdl.cxx index a0cc954..716300e 100644 --- a/sw/source/ui/app/apphdl.cxx +++ b/sw/source/ui/app/apphdl.cxx @@ -368,12 +368,12 @@ void SwMailMergeWizardExecutor::ExecuteMailMergeWizard( const SfxItemSet * pArgs } else { - SvStringsDtor aDBNameList(5, 1); - SvStringsDtor aAllDBNames(5, 5); + std::vector<String> aDBNameList; + std::vector<String> aAllDBNames; m_pView->GetWrtShell().GetAllUsedDB( aDBNameList, &aAllDBNames ); - if(aDBNameList.Count()) + if(!aDBNameList.empty()) { - String sDBName = *aDBNameList[0]; + String sDBName(aDBNameList[0]); SwDBData aDBData; aDBData.sDataSource = sDBName.GetToken(0, DB_DELIM); aDBData.sCommand = sDBName.GetToken(1, DB_DELIM); @@ -711,10 +711,9 @@ void SwModule::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) // Are database fields contained? // Get all used databases for the first time SwDoc *pDoc = pDocSh->GetDoc(); - SvStringsDtor aDBNameList; + std::vector<String> aDBNameList; pDoc->GetAllUsedDB( aDBNameList ); - sal_uInt16 nCount = aDBNameList.Count(); - if (nCount) + if(!aDBNameList.empty()) { // Open database beamer ShowDBObj(pWrtSh->GetView(), pDoc->GetDBData()); } diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index e7490b0..9b184c8 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -417,8 +417,8 @@ sal_Bool SwNewDBMgr::MergeNew(const SwMergeDescriptor& rMergeDesc ) if (IsInitDBFields()) { // with database fields without DB-Name, use DB-Name from Doc - SvStringsDtor aDBNames(1, 1); - aDBNames.Insert( new String(), 0); + std::vector<String> aDBNames; + aDBNames.push_back(String()); SwDBData aInsertData = rMergeDesc.rSh.GetDBData(); String sDBName = aInsertData.sDataSource; sDBName += DB_DELIM; diff --git a/sw/source/ui/dbui/mmconfigitem.cxx b/sw/source/ui/dbui/mmconfigitem.cxx index 4e2630a..e214569 100644 --- a/sw/source/ui/dbui/mmconfigitem.cxx +++ b/sw/source/ui/dbui/mmconfigitem.cxx @@ -1704,10 +1704,10 @@ void SwMailMergeConfigItem::SetSourceView(SwView* pView) if(pView) { - SvStringsDtor aDBNameList(5, 1); - SvStringsDtor aAllDBNames(5, 5); + std::vector<String> aDBNameList; + std::vector<String> aAllDBNames; pView->GetWrtShell().GetAllUsedDB( aDBNameList, &aAllDBNames ); - if(aDBNameList.Count()) + if(!aDBNameList.empty()) { // if fields are available there is usually no need of an addressblock and greeting if(!m_pImpl->bUserSettingWereOverwritten) diff --git a/sw/source/ui/fldui/changedb.cxx b/sw/source/ui/fldui/changedb.cxx index 5db57e0..1f657a7 100644 --- a/sw/source/ui/fldui/changedb.cxx +++ b/sw/source/ui/fldui/changedb.cxx @@ -129,27 +129,27 @@ void SwChangeDBDlg::FillDBPopup() String sTableName(rDBData.sCommand); aAvailDBTLB.Select(sDBName, sTableName, aEmptyStr); - SvStringsDtor aAllDBNames(5, 5); + std::vector<String> aAllDBNames; Sequence< ::rtl::OUString > aDBNames = xDBContext->getElementNames(); const ::rtl::OUString* pDBNames = aDBNames.getConstArray(); sal_Int32 nDBCount = aDBNames.getLength(); for(sal_Int32 i = 0; i < nDBCount; i++) { - aAllDBNames.Insert(new String(pDBNames[i]), aAllDBNames.Count()); + aAllDBNames.push_back(pDBNames[i]); } - SvStringsDtor aDBNameList(5, 1); + std::vector<String> aDBNameList; pSh->GetAllUsedDB( aDBNameList, &aAllDBNames ); - sal_uInt16 nCount = aDBNameList.Count(); + size_t nCount = aDBNameList.size(); aUsedDBTLB.Clear(); SvLBoxEntry *pFirst = 0; SvLBoxEntry *pLast = 0; - for (sal_uInt16 k = 0; k < nCount; k++) + for(size_t k = 0; k < nCount; k++) { - sDBName = *aDBNameList.GetObject(k); + sDBName = aDBNameList[k]; sDBName = sDBName.GetToken(0); pLast = Insert(sDBName); if (!pFirst) @@ -218,7 +218,8 @@ void SwChangeDBDlg::Apply() void SwChangeDBDlg::UpdateFlds() { - SvStringsDtor aDBNames( (sal_uInt8)aUsedDBTLB.GetSelectionCount(), 1 ); + std::vector<String> aDBNames; + aDBNames.reserve(aUsedDBTLB.GetSelectionCount()); SvLBoxEntry* pEntry = aUsedDBTLB.FirstSelected(); while( pEntry ) @@ -232,7 +233,7 @@ void SwChangeDBDlg::UpdateFlds() *pTmp += DB_DELIM; int nCommandType = (int)(sal_uLong)pEntry->GetUserData(); *pTmp += String::CreateFromInt32(nCommandType); - aDBNames.Insert(pTmp, aDBNames.Count() ); + aDBNames.push_back(*pTmp); } pEntry = aUsedDBTLB.NextSelected(pEntry); } diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index 95be5d0..9f5ed0d 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -2269,12 +2269,12 @@ void SwView::GenerateFormLetter(sal_Bool bUseCurrentDocument) SwDBData aData; SwWrtShell &rSh = GetWrtShell(); - SvStringsDtor aDBNameList(5, 1); - SvStringsDtor aAllDBNames(5, 5); + std::vector<String> aDBNameList; + std::vector<String> aAllDBNames; rSh.GetAllUsedDB( aDBNameList, &aAllDBNames ); - if ( aDBNameList.Count( ) ) + if(!aDBNameList.empty()) { - String sDBName = *aDBNameList[0]; + String sDBName(aDBNameList[0]); aData.sDataSource = sDBName.GetToken(0, DB_DELIM); aData.sCommand = sDBName.GetToken(1, DB_DELIM); aData.nCommandType = sDBName.GetToken(2, DB_DELIM ).ToInt32(); _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits