summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-06-19 22:34:55 +0100
committerMichael Meeks <michael.meeks@collabora.com>2014-06-23 15:42:45 +0100
commit9e5e9dd1b276043d2e9f45c01d72b2e89d8abdf2 (patch)
tree432d7112b03d1e894529f597ef88a3572bde1d80
parent78378af1d404baf78f42930a29dbf8eae22bbe80 (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. Change-Id: Id603fb4e717dc7130468465493edccfe51d384c7
-rw-r--r--sw/source/core/unocore/unostyle.cxx18
1 files changed, 9 insertions, 9 deletions
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index c3e94f9b999b..5e2ba64e9267 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -70,6 +70,7 @@
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <comphelper/sequenceasvector.hxx>
//UUUU
#include <unobrushitemhelper.hxx>
@@ -788,23 +789,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);
- const 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 )