diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-01-21 20:19:32 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-01-21 22:13:33 +0100 |
commit | a1e4a1120135eab16ba8d07e708f4860a3fe4cfc (patch) | |
tree | 05a8da51f59038023b72c87b80eeddaab1fc101d /sw | |
parent | officecfg: namespace prefix make variable FILES (diff) | |
download | core-a1e4a1120135eab16ba8d07e708f4860a3fe4cfc.tar.gz core-a1e4a1120135eab16ba8d07e708f4860a3fe4cfc.zip |
SwGlossaries: some cleanup
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/ui/dochdl/gloshdl.cxx | 7 | ||||
-rw-r--r-- | sw/source/ui/inc/glosbib.hxx | 2 | ||||
-rw-r--r-- | sw/source/ui/inc/glosdoc.hxx | 12 | ||||
-rw-r--r-- | sw/source/ui/misc/glosbib.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/misc/glosdoc.cxx | 111 | ||||
-rw-r--r-- | sw/source/ui/misc/glossary.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/uno/unoatxt.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/utlui/gloslst.cxx | 10 |
8 files changed, 76 insertions, 84 deletions
diff --git a/sw/source/ui/dochdl/gloshdl.cxx b/sw/source/ui/dochdl/gloshdl.cxx index b3e81a9e9267..401ae6b8c2ea 100644 --- a/sw/source/ui/dochdl/gloshdl.cxx +++ b/sw/source/ui/dochdl/gloshdl.cxx @@ -136,11 +136,12 @@ 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 std::vector<String*> *pPathArr = rStatGlossaries.GetPathArray(); + const std::vector<String> & rPathArr = + rStatGlossaries.GetPathArray(); sal_uInt16 nCurrentPath = USHRT_MAX; - for( size_t nPath = 0; nPath < pPathArr->size(); nPath++ ) + for (size_t nPath = 0; nPath < rPathArr.size(); ++nPath) { - if(sCurEntryPath == *(*pPathArr)[nPath]) + if (sCurEntryPath == rPathArr[nPath]) { nCurrentPath = static_cast<sal_uInt16>(nPath); break; diff --git a/sw/source/ui/inc/glosbib.hxx b/sw/source/ui/inc/glosbib.hxx index b1c27053009a..423a0588fb0c 100644 --- a/sw/source/ui/inc/glosbib.hxx +++ b/sw/source/ui/inc/glosbib.hxx @@ -104,7 +104,7 @@ protected: public: SwGlossaryGroupDlg(Window * pParent, - const std::vector<String*> *pPathArr, + std::vector<String> const& rPathArr, SwGlossaryHdl *pGlosHdl); ~SwGlossaryGroupDlg(); diff --git a/sw/source/ui/inc/glosdoc.hxx b/sw/source/ui/inc/glosdoc.hxx index 114c9bc24b79..f84ffae2475f 100644 --- a/sw/source/ui/inc/glosdoc.hxx +++ b/sw/source/ui/inc/glosdoc.hxx @@ -61,12 +61,12 @@ class SW_DLLPUBLIC SwGlossaries String m_aPath; String m_sOldErrPath; String m_sErrPath; - std::vector<String*> m_aPathArr; - std::vector<String*> *m_pGlosArr; + std::vector<String> m_PathArr; + std::vector<String> m_GlosArr; sal_Bool m_bError; SW_DLLPRIVATE SwTextBlocks* GetGlosDoc(const String &rName, sal_Bool bCreate = sal_True) const; - SW_DLLPRIVATE std::vector<String*>* GetNameList(); + SW_DLLPRIVATE std::vector<String> & GetNameList(); // implementation in unoatxt.cxx SW_DLLPRIVATE void RemoveFileFromList( const String& rGroup ); @@ -121,8 +121,8 @@ public: sal_Bool FindGroupName(String & rGroup); SwTextBlocks* GetGroupDoc(const String &rName, - sal_Bool bCreate = sal_False) const; - SwTextBlocks* GetDefGroupDoc() const {return GetGroupDoc(GetDefName());} + sal_Bool bCreate = sal_False); + SwTextBlocks* GetDefGroupDoc() { return GetGroupDoc(GetDefName()); } void PutGroupDoc(SwTextBlocks *pBlock); static String GetDefName(); static String GetExtension(); @@ -137,7 +137,7 @@ public: void UpdateGlosPath(sal_Bool bFull); void ShowError(); inline sal_uLong IsGlosPathErr() { return m_bError; } - const std::vector<String*>* GetPathArray() const { return &m_aPathArr; } + std::vector<String> const& GetPathArray() const { return m_PathArr; } }; diff --git a/sw/source/ui/misc/glosbib.cxx b/sw/source/ui/misc/glosbib.cxx index 4d09b00d6a13..3b4d58f4e173 100644 --- a/sw/source/ui/misc/glosbib.cxx +++ b/sw/source/ui/misc/glosbib.cxx @@ -59,7 +59,7 @@ #define RENAME_TOKEN_DELIM (sal_Unicode)1 SwGlossaryGroupDlg::SwGlossaryGroupDlg(Window * pParent, - const std::vector<String*> *pPathArr, + std::vector<String> const& rPathArr, SwGlossaryHdl *pHdl) : SvxStandardDialog(pParent, SW_RES(DLG_BIB_BASE)), aBibFT( this, SW_RES(FT_BIB)), @@ -96,9 +96,9 @@ SwGlossaryGroupDlg::SwGlossaryGroupDlg(Window * pParent, aPathLB.SetSelectHdl(LINK(this, SwGlossaryGroupDlg, ModifyHdl)); aRenamePB.SetClickHdl(LINK(this, SwGlossaryGroupDlg, RenameHdl)); - for( size_t i = 0; i < pPathArr->size(); i++ ) + for (size_t i = 0; i < rPathArr.size(); ++i) { - String sPath(*(*pPathArr)[i]); + String sPath(rPathArr[i]); INetURLObject aTempURL(sPath); sPath = aTempURL.GetMainURL(INetURLObject::DECODE_WITH_CHARSET ); aPathLB.InsertEntry(sPath); diff --git a/sw/source/ui/misc/glosdoc.cxx b/sw/source/ui/misc/glosdoc.cxx index e84455dde29a..f07fe52cc9f4 100644 --- a/sw/source/ui/misc/glosdoc.cxx +++ b/sw/source/ui/misc/glosdoc.cxx @@ -114,7 +114,7 @@ String SwGlossaries::GetDefName() ------------------------------------------------------------------------*/ sal_uInt16 SwGlossaries::GetGroupCnt() { - return static_cast<sal_uInt16>(GetNameList()->size()); + return static_cast<sal_uInt16>(GetNameList().size()); } /*------------------------------------------------------------------------ @@ -143,7 +143,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_aPathArr[nPath] ) + if (!SWUnoHelper::UCB_IsCaseSensitiveFileName( m_PathArr[nPath] ) && rSCmp.isEqual( rGroup, sTemp.GetToken( 0, GLOS_DELIM) ) ) { rGroup = sTemp; @@ -155,8 +155,9 @@ sal_Bool SwGlossaries::FindGroupName(String & rGroup) String SwGlossaries::GetGroupName(sal_uInt16 nGroupId) { - OSL_ENSURE(static_cast<size_t>(nGroupId) < m_pGlosArr->size(), "Textbausteinarray ueberindiziert"); - return *(*m_pGlosArr)[nGroupId]; + OSL_ENSURE(static_cast<size_t>(nGroupId) < m_GlosArr.size(), + "SwGlossaries::GetGroupName: index out of bounds"); + return m_GlosArr[nGroupId]; } String SwGlossaries::GetGroupTitle( const String& rGroupName ) @@ -178,20 +179,20 @@ String SwGlossaries::GetGroupTitle( const String& rGroupName ) Description: supplies the group rName's text block document ------------------------------------------------------------------------*/ SwTextBlocks* SwGlossaries::GetGroupDoc(const String &rName, - sal_Bool bCreate) const + sal_Bool bCreate) { // insert to the list of text blocks if applicable - if(bCreate && m_pGlosArr) + if(bCreate && !m_GlosArr.empty()) { - std::vector<String*>::const_iterator it(m_pGlosArr->begin()); - for(; it != m_pGlosArr->end(); ++it) + std::vector<String>::const_iterator it(m_GlosArr.begin()); + for (; it != m_GlosArr.end(); ++it) { - if(**it == rName) + if (*it == rName) break; } - if( it == m_pGlosArr->end() ) + if (it == m_GlosArr.end()) { // block not in the list - m_pGlosArr->push_back(new String(rName)); + m_GlosArr.push_back(rName); } } return GetGlosDoc( rName, bCreate ); @@ -212,16 +213,16 @@ 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( static_cast<size_t>(nNewPath) >= m_aPathArr.size() ) + if (static_cast<size_t>(nNewPath) >= m_PathArr.size()) return sal_False; - String sNewFilePath(*m_aPathArr[nNewPath]); + String sNewFilePath(m_PathArr[nNewPath]); String sNewGroup = lcl_CheckFileName(sNewFilePath, rGroupName.GetToken(0, GLOS_DELIM)); sNewGroup += GLOS_DELIM; sNewGroup += rGroupName.GetToken(1, GLOS_DELIM); SwTextBlocks *pBlock = GetGlosDoc( sNewGroup ); if(pBlock) { - GetNameList()->push_back(new String(sNewGroup)); + GetNameList().push_back(sNewGroup); pBlock->SetName(rTitle); PutGroupDoc(pBlock); rGroupName = sNewGroup; @@ -235,9 +236,9 @@ sal_Bool SwGlossaries::RenameGroupDoc( { sal_Bool bRet = sal_False; sal_uInt16 nOldPath = (sal_uInt16)rOldGroup.GetToken(1, GLOS_DELIM).ToInt32(); - if( static_cast<size_t>(nOldPath) < m_aPathArr.size() ) + if (static_cast<size_t>(nOldPath) < m_PathArr.size()) { - String sOldFileURL(*m_aPathArr[nOldPath]); + String sOldFileURL(m_PathArr[nOldPath]); sOldFileURL += INET_PATH_TOKEN; sOldFileURL += rOldGroup.GetToken(0, GLOS_DELIM); sOldFileURL += SwGlossaries::GetExtension(); @@ -246,9 +247,9 @@ sal_Bool SwGlossaries::RenameGroupDoc( if(bExist) { sal_uInt16 nNewPath = (sal_uInt16)rNewGroup.GetToken(1, GLOS_DELIM).ToInt32(); - if( static_cast<size_t>(nNewPath) < m_aPathArr.size() ) + if (static_cast<size_t>(nNewPath) < m_PathArr.size()) { - String sNewFilePath(*m_aPathArr[nNewPath]); + String sNewFilePath(m_PathArr[nNewPath]); String sNewFileName = lcl_CheckFileName( sNewFilePath, rNewGroup.GetToken(0, GLOS_DELIM)); const sal_uInt16 nFileNameLen = sNewFileName.Len(); @@ -270,10 +271,14 @@ sal_Bool SwGlossaries::RenameGroupDoc( rNewGroup = sNewFileName.Copy(0, nFileNameLen); rNewGroup += GLOS_DELIM; rNewGroup += String::CreateFromInt32(nNewPath); - if(!m_pGlosArr) + if (m_GlosArr.empty()) + { GetNameList(); + } else - m_pGlosArr->push_back(new String(rNewGroup)); + { + m_GlosArr.push_back(rNewGroup); + } sNewFilePath += INET_PATH_TOKEN; sNewFilePath += sNewFileName ; @@ -294,9 +299,9 @@ sal_Bool SwGlossaries::RenameGroupDoc( sal_Bool SwGlossaries::DelGroupDoc(const String &rName) { sal_uInt16 nPath = (sal_uInt16)rName.GetToken(1, GLOS_DELIM).ToInt32(); - if( static_cast<size_t>(nPath) >= m_aPathArr.size() ) + if (static_cast<size_t>(nPath) >= m_PathArr.size()) return sal_False; - String sFileURL(*m_aPathArr[nPath]); + String sFileURL(m_PathArr[nPath]); String aTmp( rName.GetToken(0, GLOS_DELIM)); String aName(aTmp); aName += GLOS_DELIM; @@ -316,16 +321,6 @@ sal_Bool SwGlossaries::DelGroupDoc(const String &rName) SwGlossaries::~SwGlossaries() { - if( m_pGlosArr ) - { - for(std::vector<String*>::const_iterator it(m_pGlosArr->begin()); it != m_pGlosArr->end(); ++it) - delete *it; - delete m_pGlosArr; - } - - for(std::vector<String*>::const_iterator it(m_aPathArr.begin()); it != m_aPathArr.end(); ++it) - delete *it; - InvalidateUNOOjects(); } @@ -336,9 +331,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( static_cast<size_t>(nPath) < m_aPathArr.size() ) + if (static_cast<size_t>(nPath) < m_PathArr.size()) { - String sFileURL(*m_aPathArr[nPath]); + String sFileURL(m_PathArr[nPath]); String aTmp( rName.GetToken(0, GLOS_DELIM)); aTmp += SwGlossaries::GetExtension(); sFileURL += INET_PATH_TOKEN; @@ -369,17 +364,16 @@ SwTextBlocks* SwGlossaries::GetGlosDoc( const String &rName, sal_Bool bCreate ) /*------------------------------------------------------------------------ Description: access to the list of names; read in if applicable ------------------------------------------------------------------------*/ -std::vector<String*>* SwGlossaries::GetNameList() +std::vector<String> & SwGlossaries::GetNameList() { - if( !m_pGlosArr ) + if (m_GlosArr.empty()) { - m_pGlosArr = new std::vector<String*>; String sExt( SwGlossaries::GetExtension() ); - for( size_t i = 0; i < m_aPathArr.size(); ++i ) + for (size_t i = 0; i < m_PathArr.size(); ++i) { std::vector<String*> aFiles; - SWUnoHelper::UCB_GetFileListOfFolder( *m_aPathArr[i], aFiles, &sExt ); + SWUnoHelper::UCB_GetFileListOfFolder(m_PathArr[i], aFiles, &sExt); for( std::vector<String*>::const_iterator filesIt(aFiles.begin()); filesIt != aFiles.end(); ++filesIt) { @@ -387,26 +381,25 @@ std::vector<String*>* SwGlossaries::GetNameList() String sName( pTitle->Copy( 0, pTitle->Len() - sExt.Len() )); sName += GLOS_DELIM; sName += String::CreateFromInt32( static_cast<sal_Int16>(i) ); - m_pGlosArr->push_back( new String(sName) ); + m_GlosArr.push_back(sName); // don't need any more these pointers delete pTitle; } } - if( m_pGlosArr->empty() ) + if (m_GlosArr.empty()) { // the standard block is inside of the path's first part - String *pTmp = new String( SwGlossaries::GetDefName() ); - (*pTmp) += GLOS_DELIM; - (*pTmp) += '0'; - m_pGlosArr->push_back( pTmp ); + String tmp( SwGlossaries::GetDefName() ); + tmp += GLOS_DELIM; + tmp += '0'; + m_GlosArr.push_back( tmp ); } } - return m_pGlosArr; + return m_GlosArr; } -SwGlossaries::SwGlossaries() : - m_pGlosArr(0) +SwGlossaries::SwGlossaries() { UpdateGlosPath(sal_True); } @@ -435,9 +428,7 @@ void SwGlossaries::UpdateGlosPath(sal_Bool bFull) { m_aPath = aNewPath; - for(std::vector<String*>::const_iterator it(m_aPathArr.begin()); it != m_aPathArr.end(); ++it) - delete *it; - m_aPathArr.clear(); + m_PathArr.clear(); sal_uInt16 nTokenCount = comphelper::string::getTokenCount(m_aPath, SVT_SEARCHPATH_DELIMITER); std::vector<String*> aDirArr; @@ -460,7 +451,7 @@ void SwGlossaries::UpdateGlosPath(sal_Bool bFull) m_sErrPath += String(aTemp.GetFull()); } else - m_aPathArr.push_back(new String(sPth)); + m_PathArr.push_back(sPth); } for(std::vector<String*>::const_iterator it(aDirArr.begin()); it != aDirArr.end(); ++it) delete *it; @@ -479,11 +470,9 @@ void SwGlossaries::UpdateGlosPath(sal_Bool bFull) else m_bError = sal_False; - if(m_pGlosArr) + if (!m_GlosArr.empty()) { - for(std::vector<String*>::const_iterator it(m_pGlosArr->begin()); it != m_pGlosArr->end(); ++it) - delete *it; - DELETEZ(m_pGlosArr); + m_GlosArr.clear(); GetNameList(); } } @@ -503,11 +492,12 @@ String SwGlossaries::GetExtension() void SwGlossaries::RemoveFileFromList( const String& rGroup ) { - if(m_pGlosArr) + if (!m_GlosArr.empty()) { - for(std::vector<String*>::iterator it(m_pGlosArr->begin()); it != m_pGlosArr->end(); ++it) + for (std::vector<String>::iterator it(m_GlosArr.begin()); + it != m_GlosArr.end(); ++it) { - if(**it == rGroup) + if (*it == rGroup) { rtl::OUString aUName = rGroup; { @@ -552,8 +542,7 @@ void SwGlossaries::RemoveFileFromList( const String& rGroup ) } } - delete *it; - m_pGlosArr->erase(it); + m_GlosArr.erase(it); break; } } diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx index c80a663b8517..3ed816f8defd 100644 --- a/sw/source/ui/misc/glossary.cxx +++ b/sw/source/ui/misc/glossary.cxx @@ -939,10 +939,10 @@ void SwGlTreeListBox::RequestHelp( const HelpEvent& rHEvt ) if(!GetParent(pEntry)) { GroupUserData* pData = (GroupUserData*)pEntry->GetUserData(); - const std::vector<String*>* pPathArr = ::GetGlossaries()->GetPathArray(); - if( !pPathArr->empty() ) + const std::vector<String> & rPathArr = ::GetGlossaries()->GetPathArray(); + if( !rPathArr.empty() ) { - sMsg = (*(*pPathArr)[pData->nPathIdx]); + sMsg = rPathArr[pData->nPathIdx]; sMsg += INET_PATH_TOKEN; sMsg += pData->sGroupName; sMsg += SwGlossaries::GetExtension(); diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx index 34a7fdc06e14..8914d1d2b4bf 100644 --- a/sw/source/ui/uno/unoatxt.cxx +++ b/sw/source/ui/uno/unoatxt.cxx @@ -1073,7 +1073,8 @@ void SwAutoTextEventDescriptor::replaceByName( (nEvent == SW_EVENT_START_INS_GLOSSARY) , "Unknown event ID" ); - const SwGlossaries* pGlossaries = rAutoTextEntry.GetGlossaries(); + SwGlossaries *const pGlossaries = + const_cast<SwGlossaries*>(rAutoTextEntry.GetGlossaries()); SwTextBlocks* pBlocks = pGlossaries->GetGroupDoc( rAutoTextEntry.GetGroupName() ); OSL_ENSURE( NULL != pBlocks, @@ -1111,7 +1112,8 @@ void SwAutoTextEventDescriptor::getByName( (nEvent == SW_EVENT_START_INS_GLOSSARY) , "Unknown event ID" ); - const SwGlossaries* pGlossaries = rAutoTextEntry.GetGlossaries(); + SwGlossaries *const pGlossaries = + const_cast<SwGlossaries*>(rAutoTextEntry.GetGlossaries()); SwTextBlocks* pBlocks = pGlossaries->GetGroupDoc( rAutoTextEntry.GetGroupName() ); OSL_ENSURE( NULL != pBlocks, diff --git a/sw/source/ui/utlui/gloslst.cxx b/sw/source/ui/utlui/gloslst.cxx index 485406f3b1cb..cc8704570163 100644 --- a/sw/source/ui/utlui/gloslst.cxx +++ b/sw/source/ui/utlui/gloslst.cxx @@ -270,7 +270,7 @@ void SwGlossaryList::Update() ClearGroups(); } SwGlossaries* pGlossaries = ::GetGlossaries(); - const std::vector<String*>* pPathArr = pGlossaries->GetPathArray(); + const std::vector<String> & rPathArr = pGlossaries->GetPathArray(); String sExt( SwGlossaries::GetExtension() ); if(!bFilled) { @@ -279,13 +279,13 @@ void SwGlossaryList::Update() { String sGrpName = pGlossaries->GetGroupName(i); sal_uInt16 nPath = (sal_uInt16)sGrpName.GetToken(1, GLOS_DELIM).ToInt32(); - if( static_cast<size_t>(nPath) < pPathArr->size() ) + if( static_cast<size_t>(nPath) < rPathArr.size() ) { AutoTextGroup* pGroup = new AutoTextGroup; pGroup->sName = sGrpName; FillGroup(pGroup, pGlossaries); - String sName = *(*pPathArr)[nPath]; + String sName = rPathArr[nPath]; sName += INET_PATH_TOKEN; sName += pGroup->sName.GetToken(0, GLOS_DELIM); sName += sExt; @@ -301,13 +301,13 @@ void SwGlossaryList::Update() } else { - for( size_t nPath = 0; nPath < pPathArr->size(); nPath++ ) + for( size_t nPath = 0; nPath < rPathArr.size(); nPath++ ) { std::vector<String> aFoundGroupNames; std::vector<String*> aFiles; SvPtrarr aDateTimeArr( 16 ); - SWUnoHelper::UCB_GetFileListOfFolder( *(*pPathArr)[nPath], aFiles, + SWUnoHelper::UCB_GetFileListOfFolder( rPathArr[nPath], aFiles, &sExt, &aDateTimeArr ); for( size_t nFiles = 0; nFiles < aFiles.size(); ++nFiles ) { |