Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi,

Attached are 2 patches to covert come SvStrings to std::vector.

Code contributed under the LGPLv3+ / MPL.

Regards,
Brad
From f123824f996945e4fc7710f6347bad797f26e237 Mon Sep 17 00:00:00 2001
From: Brad Sowden <code@sowden.org>
Date: Tue, 27 Dec 2011 19:19:51 +1300
Subject: [PATCH 1/2] fdo#38831 Convert some SvStrings to std::vector

---
 sw/source/ui/inc/glosbib.hxx  |    8 ++-
 sw/source/ui/misc/glosbib.cxx |   97 ++++++++++++++++++-----------------------
 2 files changed, 47 insertions(+), 58 deletions(-)

diff --git a/sw/source/ui/inc/glosbib.hxx b/sw/source/ui/inc/glosbib.hxx
index c886ad6..a7f9c49 100644
--- a/sw/source/ui/inc/glosbib.hxx
+++ b/sw/source/ui/inc/glosbib.hxx
@@ -38,6 +38,8 @@
 #include <vcl/button.hxx>
 #include <vcl/fixed.hxx>
 
+#include <vector>
+
 class SwGlossaryHdl;
 class SvStrings;
 
@@ -82,9 +84,9 @@ class SwGlossaryGroupDlg : public SvxStandardDialog
     PushButton      aDelPB;
     PushButton      aRenamePB;
 
-    SvStrings*      pRemovedArr;
-    SvStrings*      pInsertedArr;
-    SvStrings*      pRenamedArr;
+    std::vector<String*> *pRemovedArr;
+    std::vector<String*> *pInsertedArr;
+    std::vector<String*> *pRenamedArr;
 
     SwGlossaryHdl   *pGlosHdl;
 
diff --git a/sw/source/ui/misc/glosbib.cxx b/sw/source/ui/misc/glosbib.cxx
index c3967b3..18f10d2 100644
--- a/sw/source/ui/misc/glosbib.cxx
+++ b/sw/source/ui/misc/glosbib.cxx
@@ -30,8 +30,6 @@
 #undef SW_DLLIMPLEMENTATION
 #endif
 
-
-
 #define _SVSTDARR_STRINGS
 #include <tools/urlobj.hxx>
 #include <tools/stream.hxx>
@@ -146,17 +144,20 @@ SwGlossaryGroupDlg::~SwGlossaryGroupDlg()
 
     if(pInsertedArr)
     {
-        pInsertedArr->DeleteAndDestroy(0, pInsertedArr->Count());
+        for(std::vector<String*>::const_iterator it(pInsertedArr->begin()); it != 
pInsertedArr->end(); ++it)
+            delete *it;
         delete pInsertedArr;
     }
     if(pRemovedArr)
     {
-        pRemovedArr->DeleteAndDestroy(0, pRemovedArr->Count());
+        for(std::vector<String*>::const_iterator it(pRemovedArr->begin()); it != 
pRemovedArr->end(); ++it)
+            delete *it;
         delete pRemovedArr;
     }
     if(pRenamedArr)
     {
-        pRenamedArr->DeleteAndDestroy(0, pRenamedArr->Count());
+        for(std::vector<String*>::const_iterator it(pRenamedArr->begin()); it != 
pRenamedArr->end(); ++it)
+            delete *it;
         delete pRenamedArr;
     }
 
@@ -169,13 +170,11 @@ void SwGlossaryGroupDlg::Apply()
 
     String aActGroup = SwGlossaryDlg::GetCurrGroup();
 
-    if(pRemovedArr && pRemovedArr->Count())
+    if(pRemovedArr)
     {
-        sal_uInt16 nCount = pRemovedArr->Count();
-        for(sal_uInt16 i = 0; i < nCount; ++i)
+        for(std::vector<String*>::const_iterator it(pRemovedArr->begin()); it != 
pRemovedArr->end(); ++it)
         {
-            const String* pDelEntry = (*pRemovedArr)[i];
-            const String sDelGroup = pDelEntry->GetToken(0, '\t');
+            const String sDelGroup = (*it)->GetToken(0, '\t');
             if( sDelGroup == aActGroup )
             {
                 //when the current group is deleted, the current group has to be relocated
@@ -187,7 +186,7 @@ void SwGlossaryGroupDlg::Apply()
                 }
             }
             String sMsg(SW_RES(STR_QUERY_DELETE_GROUP1));
-            String sTitle(pDelEntry->GetToken(1, '\t'));
+            String sTitle( (*it)->GetToken(1, '\t') );
             if(sTitle.Len())
                 sMsg += sTitle;
             else
@@ -200,29 +199,26 @@ void SwGlossaryGroupDlg::Apply()
 
     }
     //don't rename before there was one
-    if(pRenamedArr && pRenamedArr->Count())
+    if(pRenamedArr)
     {
-        sal_uInt16 nCount = pRenamedArr->Count();
-        for(sal_uInt16 i = 0; i < nCount; ++i)
+        for(std::vector<String*>::const_iterator it(pRenamedArr->begin()); it != 
pRenamedArr->end(); ++it)
         {
-            String * pEntry = (*pRenamedArr)[i];
             xub_StrLen nStrSttPos = 0;
-            String sOld( pEntry->GetToken(0, RENAME_TOKEN_DELIM, nStrSttPos ) );
-            String sNew( pEntry->GetToken(0, RENAME_TOKEN_DELIM, nStrSttPos) );
-            String sTitle( pEntry->GetToken(0, RENAME_TOKEN_DELIM, nStrSttPos) );
+            String sOld( (*it)->GetToken(0, RENAME_TOKEN_DELIM, nStrSttPos ) );
+            String sNew( (*it)->GetToken(0, RENAME_TOKEN_DELIM, nStrSttPos) );
+            String sTitle( (*it)->GetToken(0, RENAME_TOKEN_DELIM, nStrSttPos) );
             pGlosHdl->RenameGroup(sOld, sNew, sTitle);
-            if(!i)
+            if( it == pRenamedArr->begin() )
                 sCreatedGroup = sNew;
         }
     }
-    if(pInsertedArr && pInsertedArr->Count())
+    if(pInsertedArr)
     {
-        sal_uInt16 nCount = pInsertedArr->Count();
-        for(sal_uInt16 i = 0; i < nCount; ++i)
+        for(std::vector<String*>::const_iterator it(pInsertedArr->begin()); it != 
pInsertedArr->end(); ++it)
         {
-            String sNewGroup = *(*pInsertedArr)[i];
+            String sNewGroup = **it;
             String sNewTitle = sNewGroup.GetToken(0, GLOS_DELIM);
-            if( *(*pInsertedArr)[i] != aActGroup )
+            if( sNewGroup != aActGroup )
             {
                 pGlosHdl->NewGroup(sNewGroup, sNewTitle);
                 if(!sCreatedGroup.Len())
@@ -264,8 +260,8 @@ IMPL_LINK( SwGlossaryGroupDlg, NewHdl, Button*, EMPTYARG )
     sGroup += String::CreateFromInt32(aPathLB.GetSelectEntryPos());
     OSL_ENSURE(!pGlosHdl->FindGroupName(sGroup), "group already available!");
     if(!pInsertedArr)
-        pInsertedArr = new SvStrings;
-    pInsertedArr->Insert(new String(sGroup), pInsertedArr->Count());
+        pInsertedArr = new std::vector<String*>;
+    pInsertedArr->push_back(new String(sGroup));
     String sTemp(aNameED.GetText());
     sTemp += '\t';
     sTemp += aPathLB.GetSelectEntry();
@@ -294,15 +290,13 @@ IMPL_LINK( SwGlossaryGroupDlg, DeleteHdl, Button*, pButton  )
     String sEntry(pUserData->sGroupName);
     // if the name to be deleted is among the new ones - get rid of it
     sal_Bool bDelete = sal_True;
-    if(pInsertedArr && pInsertedArr->Count())
+    if(pInsertedArr)
     {
-        sal_uInt16 nCount = pInsertedArr->Count();
-        for(sal_uInt16 i = 0; i < nCount; ++i)
+        for(std::vector<String*>::iterator it(pInsertedArr->begin()); it != pInsertedArr->end(); 
++it)
         {
-            const String* pTemp = (*pInsertedArr)[i];
-            if(*pTemp == sEntry)
+            if( **it == sEntry )
             {
-                pInsertedArr->Remove(i);
+                pInsertedArr->erase(it);
                 bDelete = sal_False;
                 break;
             }
@@ -312,16 +306,13 @@ IMPL_LINK( SwGlossaryGroupDlg, DeleteHdl, Button*, pButton  )
     // it should probably be renamed?
     if(bDelete)
     {
-        if(pRenamedArr && pRenamedArr->Count())
+        if(pRenamedArr)
         {
-            sal_uInt16 nCount = pRenamedArr->Count();
-            for(sal_uInt16 i = 0; i < nCount; ++i)
+            for(std::vector<String*>::iterator it(pRenamedArr->begin()); it != pRenamedArr->end(); 
++it)
             {
-                const String* pTemp = (*pRenamedArr)[i];
-                String sTemp( pTemp->GetToken(0, RENAME_TOKEN_DELIM ));
-                if(sTemp == sEntry)
+                if( (*it)->GetToken(0, RENAME_TOKEN_DELIM) == sEntry )
                 {
-                    pRenamedArr->Remove(i);
+                    pRenamedArr->erase(it);
                     bDelete = sal_False;
                     break;
                 }
@@ -331,11 +322,11 @@ IMPL_LINK( SwGlossaryGroupDlg, DeleteHdl, Button*, pButton  )
     if(bDelete)
     {
         if(!pRemovedArr)
-            pRemovedArr = new SvStrings;
+            pRemovedArr = new std::vector<String*>;
         String sGroupEntry(pUserData->sGroupName);
         sGroupEntry += '\t';
         sGroupEntry += pUserData->sGroupTitle;
-        pRemovedArr->Insert(new String(sGroupEntry), pRemovedArr->Count());
+        pRemovedArr->push_back(new String(sGroupEntry));
     }
     delete pUserData;
     aGroupTLB.GetModel()->Remove(pEntry);
@@ -362,16 +353,14 @@ IMPL_LINK( SwGlossaryGroupDlg, RenameHdl, Button *, EMPTYARG )
 
     // if the name to be renamed is among the new ones - replace
     sal_Bool bDone = sal_False;
-    if(pInsertedArr && pInsertedArr->Count())
+    if(pInsertedArr)
     {
-        sal_uInt16 nCount = pInsertedArr->Count();
-        for(sal_uInt16 i = 0; i < nCount; ++i)
+        for(std::vector<String*>::iterator it(pInsertedArr->begin()); it != pInsertedArr->end(); 
++it)
         {
-            const String* pTemp = (*pInsertedArr)[i];
-            if(*pTemp == sEntry)
+            if( **it == sEntry )
             {
-                pInsertedArr->Remove(i);
-                pInsertedArr->Insert(new String(sNewName), pInsertedArr->Count());
+                pInsertedArr->erase(it);
+                pInsertedArr->push_back(new String(sNewName));
                 bDone = sal_True;
                 break;
             }
@@ -380,12 +369,12 @@ IMPL_LINK( SwGlossaryGroupDlg, RenameHdl, Button *, EMPTYARG )
     if(!bDone)
     {
         if(!pRenamedArr)
-            pRenamedArr = new SvStrings;
+            pRenamedArr = new std::vector<String*>;
         sEntry += RENAME_TOKEN_DELIM;
         sEntry += sNewName;
         sEntry += RENAME_TOKEN_DELIM;
         sEntry += sNewTitle;
-        pRenamedArr->Insert(new String(sEntry), pRenamedArr->Count());
+        pRenamedArr->push_back(new String(sEntry));
     }
     delete (GlosBibUserData*)pEntry->GetUserData();
     aGroupTLB.GetModel()->Remove(pEntry);
@@ -467,13 +456,11 @@ sal_Bool SwGlossaryGroupDlg::IsDeleteAllowed(const String &rGroup)
     // as well! Because for non existing region names ReadOnly issues
     // sal_True.
 
-    if(pInsertedArr && pInsertedArr->Count())
+    if(pInsertedArr)
     {
-        sal_uInt16 nCount = pInsertedArr->Count();
-        for(sal_uInt16 i = 0; i < nCount; ++i)
+        for(std::vector<String*>::const_iterator it(pInsertedArr->begin()); it != 
pInsertedArr->end(); ++it)
         {
-            const String* pTemp = (*pInsertedArr)[i];
-            if(*pTemp == rGroup)
+            if( **it == rGroup )
             {
                 bDel = sal_True;
                 break;
-- 
1.7.7.4

From 469d3fba3126883ec0a34a39038691eb82862766 Mon Sep 17 00:00:00 2001
From: Brad Sowden <code@sowden.org>
Date: Tue, 27 Dec 2011 23:18:50 +1300
Subject: [PATCH 2/2] fdo#38831 Convert some SvStrings to std::vector (part 2)

---
 sw/source/ui/dochdl/gloshdl.cxx |    6 +--
 sw/source/ui/inc/glosbib.hxx    |    3 +-
 sw/source/ui/inc/glosdoc.hxx    |    6 ++--
 sw/source/ui/misc/glosbib.cxx   |   10 ++----
 sw/source/ui/misc/glosdoc.cxx   |   64 ++++++++++++++------------------------
 sw/source/ui/misc/glossary.cxx  |    5 +--
 sw/source/ui/utlui/gloslst.cxx  |    6 ++--
 7 files changed, 39 insertions(+), 61 deletions(-)

diff --git a/sw/source/ui/dochdl/gloshdl.cxx b/sw/source/ui/dochdl/gloshdl.cxx
index efd545f..2b17a32 100644
--- a/sw/source/ui/dochdl/gloshdl.cxx
+++ b/sw/source/ui/dochdl/gloshdl.cxx
@@ -38,8 +38,6 @@
 #include <svl/macitem.hxx>
 #include <sfx2/fcontnr.hxx>
 #include <sfx2/docfile.hxx>
-#define _SVSTDARR_STRINGS
-#include <svl/svstdarr.hxx>
 #include <svl/urihelper.hxx>
 #include <unotools/transliterationwrapper.hxx>
 #include <poolfmt.hxx>
@@ -138,9 +136,9 @@ void SwGlossaryHdl::SetCurGroup(const String &rGrp, sal_Bool bApi, sal_Bool bAlw
             String sCurBase = aTemp.getBase();
             aTemp.removeSegment();
             const String sCurEntryPath = aTemp.GetMainURL(INetURLObject::NO_DECODE);
-            const SvStrings* pPathArr = rStatGlossaries.GetPathArray();
+            const std::vector<String*> *pPathArr = rStatGlossaries.GetPathArray();
             sal_uInt16 nCurrentPath = USHRT_MAX;
-            for(sal_uInt16 nPath = 0; nPath < pPathArr->Count(); nPath++)
+            for(sal_uInt16 nPath = 0; nPath < pPathArr->size(); nPath++)
             {
                 if(sCurEntryPath == *(*pPathArr)[nPath])
                 {
diff --git a/sw/source/ui/inc/glosbib.hxx b/sw/source/ui/inc/glosbib.hxx
index a7f9c49..83c2706 100644
--- a/sw/source/ui/inc/glosbib.hxx
+++ b/sw/source/ui/inc/glosbib.hxx
@@ -41,7 +41,6 @@
 #include <vector>
 
 class SwGlossaryHdl;
-class SvStrings;
 
 class FEdit : public Edit
 {
@@ -104,7 +103,7 @@ protected:
 
 public:
     SwGlossaryGroupDlg(Window * pParent,
-                        const SvStrings* pPathArr,
+                        const std::vector<String*> *pPathArr,
                         SwGlossaryHdl *pGlosHdl);
     ~SwGlossaryGroupDlg();
 
diff --git a/sw/source/ui/inc/glosdoc.hxx b/sw/source/ui/inc/glosdoc.hxx
index b85e6fa..2cea838 100644
--- a/sw/source/ui/inc/glosdoc.hxx
+++ b/sw/source/ui/inc/glosdoc.hxx
@@ -66,7 +66,7 @@ class SW_DLLPUBLIC SwGlossaries
     String                  m_aPath;
     String                  m_sOldErrPath;
     String                  m_sErrPath;
-    SvStrings               *m_pPathArr;
+    std::vector<String*>    m_vPathArr;
     SvStrings               *m_pGlosArr;
     sal_Bool                    m_bError;
 
@@ -141,8 +141,8 @@ public:
     void            SaveGroupDoc(const String &rGrpName, const String& rLongName );
     void            UpdateGlosPath(sal_Bool bFull);
     void            ShowError();
-    inline sal_uLong    IsGlosPathErr() { return m_bError; }
-    const SvStrings*    GetPathArray() const {return m_pPathArr;}
+    inline sal_uLong            IsGlosPathErr() { return m_bError; }
+    const std::vector<String*>* GetPathArray() const { return &m_vPathArr; }
 };
 
 
diff --git a/sw/source/ui/misc/glosbib.cxx b/sw/source/ui/misc/glosbib.cxx
index 18f10d2..956b826 100644
--- a/sw/source/ui/misc/glosbib.cxx
+++ b/sw/source/ui/misc/glosbib.cxx
@@ -30,7 +30,6 @@
 #undef SW_DLLIMPLEMENTATION
 #endif
 
-#define _SVSTDARR_STRINGS
 #include <tools/urlobj.hxx>
 #include <tools/stream.hxx>
 #include <vcl/msgbox.hxx>
@@ -59,7 +58,7 @@
 #define RENAME_TOKEN_DELIM      (sal_Unicode)1
 
 SwGlossaryGroupDlg::SwGlossaryGroupDlg(Window * pParent,
-                        const SvStrings* pPathArr,
+                        const std::vector<String*> *pPathArr,
                         SwGlossaryHdl *pHdl) :
     SvxStandardDialog(pParent, SW_RES(DLG_BIB_BASE)),
     aBibFT(     this, SW_RES(FT_BIB)),
@@ -81,8 +80,6 @@ SwGlossaryGroupDlg::SwGlossaryGroupDlg(Window * pParent,
     pRenamedArr(0),
     pGlosHdl(pHdl)
 {
-    sal_uInt16 i;
-
     FreeResource();
 
     long nTabs[] =
@@ -100,7 +97,8 @@ SwGlossaryGroupDlg::SwGlossaryGroupDlg(Window * pParent,
     aNameED.SetModifyHdl(LINK(this, SwGlossaryGroupDlg, ModifyHdl));
     aPathLB.SetSelectHdl(LINK(this, SwGlossaryGroupDlg, ModifyHdl));
     aRenamePB.SetClickHdl(LINK(this, SwGlossaryGroupDlg, RenameHdl));
-    for( i = 0; i < pPathArr->Count(); i++)
+
+    for( sal_uInt16 i = 0; i < pPathArr->size(); i++)
     {
         String sPath(*(*pPathArr)[i]);
         INetURLObject aTempURL(sPath);
@@ -119,7 +117,7 @@ SwGlossaryGroupDlg::SwGlossaryGroupDlg(Window * pParent,
     aPathLB.Enable(sal_True);
 
     const sal_uInt16 nCount = pHdl->GetGroupCnt();
-    for(i = 0; i < nCount; ++i)
+    for( sal_uInt16 i = 0; i < nCount; ++i)
     {
         String sTitle;
         String sGroup = pHdl->GetGroupName(i, &sTitle);
diff --git a/sw/source/ui/misc/glosdoc.cxx b/sw/source/ui/misc/glosdoc.cxx
index 661ddc1..e6320b7 100644
--- a/sw/source/ui/misc/glosdoc.cxx
+++ b/sw/source/ui/misc/glosdoc.cxx
@@ -144,7 +144,7 @@ sal_Bool SwGlossaries::FindGroupName(String & rGroup)
         String sTemp( GetGroupName( i ));
         sal_uInt16 nPath = (sal_uInt16)sTemp.GetToken(1, GLOS_DELIM).ToInt32();
 
-        if( !SWUnoHelper::UCB_IsCaseSensitiveFileName( *(*m_pPathArr)[nPath] )
+        if( !SWUnoHelper::UCB_IsCaseSensitiveFileName( *m_vPathArr[nPath] )
              && rSCmp.isEqual( rGroup, sTemp.GetToken( 0, GLOS_DELIM) ) )
         {
             rGroup = sTemp;
@@ -218,9 +218,9 @@ void SwGlossaries::PutGroupDoc(SwTextBlocks *pBlock) {
 sal_Bool SwGlossaries::NewGroupDoc(String& rGroupName, const String& rTitle)
 {
     sal_uInt16 nNewPath = (sal_uInt16)rGroupName.GetToken(1, GLOS_DELIM).ToInt32();
-    if(nNewPath >= m_pPathArr->Count())
+    if(nNewPath >= m_vPathArr.size())
         return sal_False;
-    String sNewFilePath(*(*m_pPathArr)[nNewPath]);
+    String sNewFilePath(*m_vPathArr[nNewPath]);
     String sNewGroup = lcl_CheckFileName(sNewFilePath, rGroupName.GetToken(0, GLOS_DELIM));
     sNewGroup += GLOS_DELIM;
     sNewGroup += rGroupName.GetToken(1, GLOS_DELIM);
@@ -244,9 +244,9 @@ sal_Bool    SwGlossaries::RenameGroupDoc(
 {
     sal_Bool bRet = sal_False;
     sal_uInt16 nOldPath = (sal_uInt16)rOldGroup.GetToken(1, GLOS_DELIM).ToInt32();
-    if(nOldPath < m_pPathArr->Count())
+    if(nOldPath < m_vPathArr.size())
     {
-        String sOldFileURL(*(*m_pPathArr)[nOldPath]);
+        String sOldFileURL(*m_vPathArr[nOldPath]);
         sOldFileURL += INET_PATH_TOKEN;
         sOldFileURL += rOldGroup.GetToken(0, GLOS_DELIM);
         sOldFileURL += SwGlossaries::GetExtension();
@@ -255,9 +255,9 @@ sal_Bool    SwGlossaries::RenameGroupDoc(
         if(bExist)
         {
             sal_uInt16 nNewPath = (sal_uInt16)rNewGroup.GetToken(1, GLOS_DELIM).ToInt32();
-            if( nNewPath < m_pPathArr->Count())
+            if( nNewPath < m_vPathArr.size())
             {
-                String sNewFilePath(*(*m_pPathArr)[nNewPath]);
+                String sNewFilePath(*m_vPathArr[nNewPath]);
                 String sNewFileName = lcl_CheckFileName(
                                     sNewFilePath, rNewGroup.GetToken(0, GLOS_DELIM));
                 const sal_uInt16 nFileNameLen = sNewFileName.Len();
@@ -304,9 +304,9 @@ sal_Bool    SwGlossaries::RenameGroupDoc(
 sal_Bool SwGlossaries::DelGroupDoc(const String &rName)
 {
     sal_uInt16 nPath = (sal_uInt16)rName.GetToken(1, GLOS_DELIM).ToInt32();
-    if(nPath >= m_pPathArr->Count())
+    if(nPath >= m_vPathArr.size())
         return sal_False;
-    String sFileURL(*(*m_pPathArr)[nPath]);
+    String sFileURL(*m_vPathArr[nPath]);
     String aTmp( rName.GetToken(0, GLOS_DELIM));
     String aName(aTmp);
     aName += GLOS_DELIM;
@@ -324,9 +324,6 @@ sal_Bool SwGlossaries::DelGroupDoc(const String &rName)
     return bRemoved;
 }
 
-/*------------------------------------------------------------------------
-    Description: DTOR
-------------------------------------------------------------------------*/
 SwGlossaries::~SwGlossaries()
 {
     sal_uInt16 nCount = m_pGlosArr? m_pGlosArr->Count() : 0;
@@ -337,14 +334,11 @@ SwGlossaries::~SwGlossaries()
         String *pTmp = (*m_pGlosArr)[i];
         delete pTmp;
     }
-    nCount = m_pPathArr? m_pPathArr->Count() : 0;
-    for(i = 0; i < nCount; ++i)
-    {
-        String *pTmp = (*m_pPathArr)[i];
-        delete pTmp;
-    }
+
+    for(std::vector<String*>::const_iterator it(m_vPathArr.begin()); it != m_vPathArr.end(); ++it)
+        delete *it;
+
     delete m_pGlosArr;
-    delete m_pPathArr;
 
     InvalidateUNOOjects();
 }
@@ -356,9 +350,9 @@ SwTextBlocks* SwGlossaries::GetGlosDoc( const String &rName, sal_Bool bCreate )
 {
     sal_uInt16 nPath = (sal_uInt16)rName.GetToken(1, GLOS_DELIM).ToInt32();
     SwTextBlocks *pTmp = 0;
-    if(nPath < m_pPathArr->Count())
+    if(nPath < m_vPathArr.size())
     {
-        String sFileURL(*(*m_pPathArr)[nPath]);
+        String sFileURL(*m_vPathArr[nPath]);
         String aTmp( rName.GetToken(0, GLOS_DELIM));
         aTmp += SwGlossaries::GetExtension();
         sFileURL += INET_PATH_TOKEN;
@@ -395,12 +389,11 @@ SvStrings* SwGlossaries::GetNameList()
     {
         m_pGlosArr = new SvStrings;
         String sExt( SwGlossaries::GetExtension() );
-        for( sal_uInt16 i = 0; i < m_pPathArr->Count(); i++ )
+        for( sal_uInt16 i = 0; i < m_vPathArr.size(); i++ )
         {
             SvStrings aFiles( 16, 16 );
 
-            SWUnoHelper::UCB_GetFileListOfFolder( *(*m_pPathArr)[i], aFiles,
-                                                    &sExt );
+            SWUnoHelper::UCB_GetFileListOfFolder( *m_vPathArr[i], aFiles, &sExt );
             for( sal_uInt16 nFiles = 0, nFEnd = aFiles.Count();
                     nFiles < nFEnd; ++nFiles )
             {
@@ -426,14 +419,9 @@ SvStrings* SwGlossaries::GetNameList()
     return m_pGlosArr;
 }
 
-/*------------------------------------------------------------------------
-    Description: CTOR
-------------------------------------------------------------------------*/
 SwGlossaries::SwGlossaries() :
-    m_pPathArr(0),
     m_pGlosArr(0)
 {
-    m_pPathArr = new SvStrings;
     UpdateGlosPath(sal_True);
 }
 
@@ -460,18 +448,14 @@ void SwGlossaries::UpdateGlosPath(sal_Bool bFull)
     if (bFull || bPathChanged)
     {
         m_aPath = aNewPath;
-        sal_uInt16 nCount = m_pPathArr? m_pPathArr->Count() : 0;
-        sal_uInt16 i;
 
-        for( i = nCount; i; --i)
-        {
-            String *pTmp = (*m_pPathArr)[i - 1];
-            m_pPathArr->Remove(i - 1);
-            delete pTmp;
-        }
+        for(std::vector<String*>::const_iterator it(m_vPathArr.begin()); it != m_vPathArr.end(); 
++it)
+            delete *it;
+        m_vPathArr.clear();
+
         sal_uInt16 nTokenCount = m_aPath.GetTokenCount(SVT_SEARCHPATH_DELIMITER);
         SvStrings aDirArr;
-        for( i = 0; i < nTokenCount; i++ )
+        for( sal_uInt16 i = 0; i < nTokenCount; i++ )
         {
             String sPth(m_aPath.GetToken(i, SVT_SEARCHPATH_DELIMITER));
             sPth = URIHelper::SmartRel2Abs(
@@ -490,7 +474,7 @@ void SwGlossaries::UpdateGlosPath(sal_Bool bFull)
                 m_sErrPath += String(aTemp.GetFull());
             }
             else
-                m_pPathArr->Insert(new String(sPth), m_pPathArr->Count());
+                m_vPathArr.push_back(new String(sPth));
         }
         aDirArr.DeleteAndDestroy(0, aDirArr.Count());
 
@@ -510,7 +494,7 @@ void SwGlossaries::UpdateGlosPath(sal_Bool bFull)
 
         if(m_pGlosArr)
         {
-            for(i = 0; i < m_pGlosArr->Count(); ++i)
+            for(sal_uInt16 i = 0; i < m_pGlosArr->Count(); ++i)
             {
                 delete (String *)(*m_pGlosArr)[i];
             }
diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx
index fe61a0b..66c5bea 100644
--- a/sw/source/ui/misc/glossary.cxx
+++ b/sw/source/ui/misc/glossary.cxx
@@ -32,7 +32,6 @@
 #endif
 
 #define _SVSTDARR_STRINGSDTOR
-#define _SVSTDARR_STRINGS
 #include <hintids.hxx>
 
 #include <vcl/menu.hxx>
@@ -941,8 +940,8 @@ void SwGlTreeListBox::RequestHelp( const HelpEvent& rHEvt )
             if(!GetParent(pEntry))
             {
                 GroupUserData* pData = (GroupUserData*)pEntry->GetUserData();
-                const SvStrings* pPathArr = ::GetGlossaries()->GetPathArray();
-                if(pPathArr->Count())
+                const std::vector<String*>* pPathArr = ::GetGlossaries()->GetPathArray();
+                if( !pPathArr->empty() )
                 {
                     sMsg = (*(*pPathArr)[pData->nPathIdx]);
                     sMsg += INET_PATH_TOKEN;
diff --git a/sw/source/ui/utlui/gloslst.cxx b/sw/source/ui/utlui/gloslst.cxx
index 1d1720f..20651ca 100644
--- a/sw/source/ui/utlui/gloslst.cxx
+++ b/sw/source/ui/utlui/gloslst.cxx
@@ -291,7 +291,7 @@ void SwGlossaryList::Update()
         ClearGroups();
     }
     SwGlossaries* pGlossaries = ::GetGlossaries();
-    const SvStrings* pPathArr = pGlossaries->GetPathArray();
+    const std::vector<String*>* pPathArr = pGlossaries->GetPathArray();
     String sExt( SwGlossaries::GetExtension() );
     if(!bFilled)
     {
@@ -300,7 +300,7 @@ void SwGlossaryList::Update()
         {
             String sGrpName = pGlossaries->GetGroupName(i);
             sal_uInt16 nPath = (sal_uInt16)sGrpName.GetToken(1, GLOS_DELIM).ToInt32();
-            if(nPath < pPathArr->Count())
+            if(nPath < pPathArr->size())
             {
                 AutoTextGroup* pGroup = new AutoTextGroup;
                 pGroup->sName = sGrpName;
@@ -322,7 +322,7 @@ void SwGlossaryList::Update()
     }
     else
     {
-        for(sal_uInt16 nPath = 0; nPath < pPathArr->Count(); nPath++)
+        for(sal_uInt16 nPath = 0; nPath < pPathArr->size(); nPath++)
         {
             SvStringsDtor aFoundGroupNames;
             SvStrings aFiles( 16, 16 );
-- 
1.7.7.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.