diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2014-06-19 22:34:55 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-06-24 09:45:22 +0200 |
commit | 22c818bd9fa79a2c008719cc0a858ba2a74b0d82 (patch) | |
tree | 5329ba6d332d8859cacb4545b7e9cacd454e97da | |
parent | 51fb76a0beacee9d8a43abca493af1b8d2652b53 (diff) |
fdo#76260 - a better approach for getting element names.
Don't do lots more work than we need to to build the list of names.
It appears that the [] operator does a lot of apparently un-necessary
work.
(cherry picked from commit 9e5e9dd1b276043d2e9f45c01d72b2e89d8abdf2)
Signed-off-by: Miklos Vajna <vmiklos@collabora.co.uk>
Conflicts:
sw/source/core/unocore/unostyle.cxx
Change-Id: Id603fb4e717dc7130468465493edccfe51d384c7
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 15a463995f61..ae28998bcb11 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -69,6 +69,7 @@ #include <comphelper/servicehelper.hxx> #include <cppuhelper/supportsservice.hxx> +#include <comphelper/sequenceasvector.hxx> //UUUU #include <unobrushitemhelper.hxx> @@ -787,23 +788,22 @@ uno::Any SwXStyleFamily::getByName(const OUString& rName) uno::Sequence< OUString > SwXStyleFamily::getElementNames(void) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - uno::Sequence< OUString > aRet; + comphelper::SequenceAsVector< OUString > aRet; if(pBasePool) { - SfxStyleSheetIteratorPtr pIterator = pBasePool->CreateIterator(eFamily, SFXSTYLEBIT_ALL); - sal_uInt16 nCount = pIterator->Count(); - aRet.realloc(nCount); - OUString* pArray = aRet.getArray(); + SfxStyleSheetIteratorPtr pIt = pBasePool->CreateIterator(eFamily, SFXSTYLEBIT_ALL); OUString aString; - for(sal_uInt16 i = 0; i < nCount; i++) + for (SfxStyleSheetBase* pStyle = pIt->First(); pStyle; pStyle = pIt->Next()) { - SwStyleNameMapper::FillProgName((*pIterator)[i]->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true ); - pArray[i] = aString; + SwStyleNameMapper::FillProgName(pStyle->GetName(), aString, + lcl_GetSwEnumFromSfxEnum ( eFamily ), true); + aRet.push_back(aString); } } else throw uno::RuntimeException(); - return aRet; + + return aRet.getAsConstList(); } sal_Bool SwXStyleFamily::hasByName(const OUString& rName) throw( uno::RuntimeException, std::exception ) |