diff options
author | Daisuke Nishino <niboshi000@gmail.com> | 2011-11-06 19:19:48 +0900 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-11-07 12:27:32 +0000 |
commit | 6401ca3325d386067ab86dc36c5cea169449570e (patch) | |
tree | 3e66244f63a1bbdfae27da5250484382848a65cc | |
parent | 0a590fc4f0ae79faeea402ec4868cfd89b5f0371 (diff) |
Get rid of SvStringsSort
-rw-r--r-- | svl/inc/svl/svstdarr.hxx | 5 | ||||
-rw-r--r-- | svl/source/memtools/svarray.cxx | 1 | ||||
-rw-r--r-- | svl/source/misc/inettype.cxx | 72 | ||||
-rw-r--r-- | sw/inc/doc.hxx | 3 | ||||
-rw-r--r-- | sw/inc/editsh.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/doc/doctxm.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/edit/edtox.cxx | 3 | ||||
-rw-r--r-- | sw/source/ui/index/swuiidxmrk.cxx | 14 | ||||
-rw-r--r-- | unusedcode.easy | 5 |
9 files changed, 44 insertions, 71 deletions
diff --git a/svl/inc/svl/svstdarr.hxx b/svl/inc/svl/svstdarr.hxx index 50349f4b9a3a..3d3cc80d9057 100644 --- a/svl/inc/svl/svstdarr.hxx +++ b/svl/inc/svl/svstdarr.hxx @@ -57,11 +57,6 @@ SV_DECL_PTRARR_DEL_VISIBILITY( SvStringsDtor, StringPtr, 1, 1, SVL_DLLPUBLIC ) #define _SVSTDARR_STRINGSDTOR_DECL #endif -#ifndef _SVSTDARR_STRINGSSORT_DECL -SV_DECL_PTRARR_SORT_VISIBILITY( SvStringsSort, StringPtr, 1, 1, SVL_DLLPUBLIC ) -#define _SVSTDARR_STRINGSSORT_DECL -#endif - #ifndef _SVSTDARR_STRINGSSORTDTOR_DECL SV_DECL_PTRARR_SORT_DEL_VISIBILITY( SvStringsSortDtor, StringPtr, 1, 1, SVL_DLLPUBLIC ) #define _SVSTDARR_STRINGSSORTDTOR_DECL diff --git a/svl/source/memtools/svarray.cxx b/svl/source/memtools/svarray.cxx index 95df58a363a4..d1aeda7179d5 100644 --- a/svl/source/memtools/svarray.cxx +++ b/svl/source/memtools/svarray.cxx @@ -63,7 +63,6 @@ sal_uInt16 SvPtrarr::GetPos( const VoidPtr& aElement ) const SV_IMPL_PTRARR( SvStrings, StringPtr ) SV_IMPL_PTRARR( SvStringsDtor, StringPtr ) -SV_IMPL_OP_PTRARR_SORT( SvStringsSort, StringPtr ) SV_IMPL_OP_PTRARR_SORT( SvStringsSortDtor, StringPtr ) // ---------------- strings ------------------------------------- diff --git a/svl/source/misc/inettype.cxx b/svl/source/misc/inettype.cxx index 7bd7f5b12a87..c5a760374312 100644 --- a/svl/source/misc/inettype.cxx +++ b/svl/source/misc/inettype.cxx @@ -34,6 +34,8 @@ #include <svl/inettype.hxx> #include <svl/svl.hrc> +#include <boost/ptr_container/ptr_map.hpp> + #include "getstringresource.hxx" #ifndef _SVSTDARR_STRINGSSORT_DECL @@ -62,30 +64,33 @@ struct TypeIDMapEntry }; //============================================================================ -struct TypeNameMapEntry: public UniString +struct TypeNameMapEntry { UniString m_aExtension; INetContentType m_eTypeID; - TypeNameMapEntry(const UniString & rType): - UniString(rType), m_eTypeID(CONTENT_TYPE_UNKNOWN) {} + TypeNameMapEntry(): + m_eTypeID(CONTENT_TYPE_UNKNOWN) {} }; //============================================================================ -struct ExtensionMapEntry: public UniString +struct ExtensionMapEntry { INetContentType m_eTypeID; - ExtensionMapEntry(const UniString & rExt): - UniString(rExt), m_eTypeID(CONTENT_TYPE_UNKNOWN) {} + ExtensionMapEntry(): + m_eTypeID(CONTENT_TYPE_UNKNOWN) {} }; //============================================================================ class Registration { + typedef boost::ptr_map<UniString, TypeNameMapEntry> TypeNameMap; + typedef boost::ptr_map<UniString, ExtensionMapEntry> ExtensionMap; + Table m_aTypeIDMap; // map TypeID to TypeName, Presentation - SvStringsSort m_aTypeNameMap; // map TypeName to TypeID, Extension - SvStringsSort m_aExtensionMap; // map Extension to TypeID + TypeNameMap m_aTypeNameMap; // map TypeName to TypeID, Extension + ExtensionMap m_aExtensionMap; // map Extension to TypeID sal_uInt32 m_nNextDynamicID; public: @@ -527,15 +532,6 @@ Registration::~Registration() delete static_cast< TypeIDMapEntry * >(m_aTypeIDMap.GetObject(i)); } m_aTypeIDMap.Clear(); - {for (sal_uInt16 i = 0; i < m_aTypeNameMap.Count(); ++i) - delete static_cast< TypeNameMapEntry * >(m_aTypeNameMap.GetObject(i)); - } - m_aTypeNameMap.Remove(sal_uInt16(0), m_aTypeNameMap.Count()); - {for (sal_uInt16 i = 0; i < m_aExtensionMap.Count(); ++i) - delete - static_cast< ExtensionMapEntry * >(m_aExtensionMap.GetObject(i)); - } - m_aExtensionMap.Remove(sal_uInt16(0), m_aExtensionMap.Count()); } //============================================================================ @@ -545,12 +541,10 @@ TypeNameMapEntry * Registration::getExtensionEntry(UniString const & { UniString aTheTypeName = rTypeName; aTheTypeName.ToLowerAscii(); - sal_uInt16 nPos; Registration &rRegistration = theRegistration::get(); - if (rRegistration.m_aTypeNameMap.Seek_Entry(&aTheTypeName, &nPos)) - return static_cast< TypeNameMapEntry * >(rRegistration. - m_aTypeNameMap. - GetObject(nPos)); + typename TypeNameMap::iterator it = rRegistration.m_aTypeNameMap.find(aTheTypeName); + if (it != rRegistration.m_aTypeNameMap.end()) + return it->second; return 0; } @@ -581,18 +575,17 @@ INetContentType Registration::RegisterContentType(UniString const & rTypeName, pTypeIDMapEntry->m_aSystemFileType = *pSystemFileType; rRegistration.m_aTypeIDMap.Insert(eTypeID, pTypeIDMapEntry); - TypeNameMapEntry * pTypeNameMapEntry = new TypeNameMapEntry(aTheTypeName); + std::auto_ptr<TypeNameMapEntry> pTypeNameMapEntry(new TypeNameMapEntry()); if (pExtension) pTypeNameMapEntry->m_aExtension = *pExtension; pTypeNameMapEntry->m_eTypeID = eTypeID; - rRegistration.m_aTypeNameMap.Insert(pTypeNameMapEntry); + rRegistration.m_aTypeNameMap.insert(aTheTypeName, pTypeNameMapEntry); if (pExtension) { - ExtensionMapEntry * pExtensionMapEntry - = new ExtensionMapEntry(*pExtension); + std::auto_ptr<ExtensionMapEntry> pExtensionMapEntry(new ExtensionMapEntry()); pExtensionMapEntry->m_eTypeID = eTypeID; - rRegistration.m_aExtensionMap.Insert(pExtensionMapEntry); + rRegistration.m_aExtensionMap.insert(*pExtension, pExtensionMapEntry); } return eTypeID; @@ -606,13 +599,10 @@ INetContentType Registration::GetContentType(UniString const & rTypeName) UniString aTheTypeName = rTypeName; aTheTypeName.ToLowerAscii(); - sal_uInt16 nPos; - return rRegistration.m_aTypeNameMap.Seek_Entry(&aTheTypeName, &nPos) ? - static_cast< TypeNameMapEntry * >(rRegistration. - m_aTypeNameMap. - GetObject(nPos))-> - m_eTypeID : - CONTENT_TYPE_UNKNOWN; + typename TypeNameMap::iterator it = rRegistration.m_aTypeNameMap.find(aTheTypeName); + return it != rRegistration.m_aTypeNameMap.end() + ? it->second->m_eTypeID + : CONTENT_TYPE_UNKNOWN; } //============================================================================ @@ -646,16 +636,10 @@ INetContentType Registration::GetContentType4Extension(UniString const & { Registration &rRegistration = theRegistration::get(); - sal_uInt16 nPos; - return rRegistration. - m_aExtensionMap. - Seek_Entry(const_cast< UniString * >(&rExtension), - &nPos) ? - static_cast< ExtensionMapEntry * >(rRegistration. - m_aExtensionMap. - GetObject(nPos))-> - m_eTypeID : - CONTENT_TYPE_UNKNOWN; + typename ExtensionMap::iterator it = rRegistration.m_aExtensionMap.find(rExtension); + return it != rRegistration.m_aExtensionMap.end() + ? it->second->m_eTypeID + : CONTENT_TYPE_UNKNOWN; } //============================================================================ diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 6a03eb504dde..e4848f5bf68e 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -109,7 +109,6 @@ class SdrUndoAction; class VirtualDevice; class SfxPrinter; class SvNumberFormatter; -class SvStringsSort; class SvxMacro; class SvxMacroTableDtor; class SwAutoCompleteWord; @@ -1408,7 +1407,7 @@ public: void SetDefaultTOXBase(const SwTOXBase& rBase); // Key for management of index. - sal_uInt16 GetTOIKeys( SwTOIKeyType eTyp, SvStringsSort& rArr ) const; + sal_uInt16 GetTOIKeys( SwTOIKeyType eTyp, std::vector<String>& rArr ) const; // Sort table text. sal_Bool SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions&); diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index f821dcac0969..70af368d9fa4 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -66,7 +66,6 @@ class SwNewDBMgr; struct SwDocStat; class SvStringsDtor; -class SvStringsSort; class SwAutoCompleteWord; class SwFmtRefMark; @@ -416,7 +415,7 @@ public: void ApplyAutoMark(); // Key for managing index. - sal_uInt16 GetTOIKeys( SwTOIKeyType eTyp, SvStringsSort& rArr ) const; + sal_uInt16 GetTOIKeys( SwTOIKeyType eTyp, std::vector<String>& rArr ) const; void SetOutlineNumRule(const SwNumRule&); const SwNumRule* GetOutlineNumRule() const; diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index e8818e9d84bd..68ff6b9e6620 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -104,10 +104,9 @@ typedef LinkStruct* LinkStructPtr; SV_DECL_PTRARR(LinkStructArr, LinkStructPtr, 0, 5 ) SV_IMPL_PTRARR(LinkStructArr, LinkStructPtr) -sal_uInt16 SwDoc::GetTOIKeys( SwTOIKeyType eTyp, SvStringsSort& rArr ) const +sal_uInt16 SwDoc::GetTOIKeys( SwTOIKeyType eTyp, std::vector<String>& rArr ) const { - if( rArr.Count() ) - rArr.Remove( sal_uInt16(0), rArr.Count() ); + rArr.clear(); // dann mal ueber den Pool und alle Primary oder Secondary heraussuchen const SwTxtTOXMark* pMark; @@ -129,10 +128,10 @@ sal_uInt16 SwDoc::GetTOIKeys( SwTOIKeyType eTyp, SvStringsSort& rArr ) const pStr = &((SwTOXMark*)pItem)->GetSecondaryKey(); if( pStr->Len() ) - rArr.Insert( (StringPtr)pStr ); + rArr.push_back( *pStr ); } - return rArr.Count(); + return rArr.size(); } /*-------------------------------------------------------------------- diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx index 1e26155d2aca..0cde96d7440a 100644 --- a/sw/source/core/edit/edtox.cxx +++ b/sw/source/core/edit/edtox.cxx @@ -62,7 +62,6 @@ #include <statstr.hrc> #include <bookmrk.hxx> - using namespace ::com::sun::star; using namespace ::com::sun::star::i18n; using namespace ::com::sun::star::lang; @@ -254,7 +253,7 @@ const SwTOXType* SwEditShell::GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const Beschreibung: Schluessel fuer Stichwortverzeichnisse verwalten --------------------------------------------------------------------*/ -sal_uInt16 SwEditShell::GetTOIKeys( SwTOIKeyType eTyp, SvStringsSort& rArr ) const +sal_uInt16 SwEditShell::GetTOIKeys( SwTOIKeyType eTyp, std::vector<String>& rArr ) const { return GetDoc()->GetTOIKeys( eTyp, rArr ); } diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx index 18daaa1be444..6ecced311f7b 100644 --- a/sw/source/ui/index/swuiidxmrk.cxx +++ b/sw/source/ui/index/swuiidxmrk.cxx @@ -253,15 +253,19 @@ void SwIndexMarkDlg::InitControls() aTypeDCB.InsertEntry( pSh->GetTOXType(TOX_USER, i)->GetTypeName() ); // read keywords primary - SvStringsSort aArr; + std::vector<String> aArr; nCount = pSh->GetTOIKeys( TOI_PRIMARY, aArr ); - for(i=0; i < nCount; ++i) - aKeyDCB.InsertEntry( *aArr[ i ] ); + std::sort(aArr.begin(), aArr.end()); + for(typename std::vector<String>::iterator it = aArr.begin(); it != aArr.end(); ++it) { + aKeyDCB.InsertEntry( *it ); + } // read keywords secondary nCount = pSh->GetTOIKeys( TOI_SECONDARY, aArr ); - for(i=0; i < nCount; ++i) - aKey2DCB.InsertEntry( *aArr[ i ] ); + std::sort(aArr.begin(), aArr.end()); + for(typename std::vector<String>::iterator it = aArr.begin(); it != aArr.end(); ++it) { + aKey2DCB.InsertEntry( *it ); + } UpdateLanguageDependenciesForPhoneticReading(); diff --git a/unusedcode.easy b/unusedcode.easy index 058c9ce61e95..de04ee92ffab 100644 --- a/unusedcode.easy +++ b/unusedcode.easy @@ -738,11 +738,6 @@ SvStringsISort::Insert(SvStringsISort const*, unsigned short, unsigned short) SvStringsISort::Remove(String* const&, unsigned short) SvStringsISort::Remove(unsigned short, unsigned short) SvStringsISortDtor::Insert(String* const*, unsigned short) -SvStringsSort::DeleteAndDestroy(unsigned short, unsigned short) -SvStringsSort::Insert(String* const&, unsigned short&) -SvStringsSort::Insert(String* const*, unsigned short) -SvStringsSort::Insert(SvStringsSort const*, unsigned short, unsigned short) -SvStringsSort::Remove(String* const&, unsigned short) SvStringsSortDtor::Insert(String* const&, unsigned short&) SvStringsSortDtor::Insert(String* const*, unsigned short) SvStringsSortDtor::Insert(SvStringsSortDtor const*, unsigned short, unsigned short) |