[PATCH 3/8] fdo#38831 convert SvStrings to std::vector unofield.cxx

Brad Sowden code at sowden.org
Wed Dec 28 13:54:13 PST 2011


---
 sw/source/core/unocore/unofield.cxx |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 6b0ddc7..51d6fe7 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -85,7 +85,6 @@
 #include <tools/datetime.hxx>
 #include <tools/urlobj.hxx>
 #include <svx/dataaccessdescriptor.hxx>
-#define _SVSTDARR_STRINGS
 #include <svl/svstdarr.hxx>
 #include <osl/mutex.hxx>
 #include <vcl/svapp.hxx>
@@ -95,6 +94,7 @@
 #include <fmtmeta.hxx> // MetaFieldManager
 #include <switerator.hxx>
 #include <rtl/strbuf.hxx>
+#include <vector>
 
 using ::rtl::OUString;
 using namespace ::com::sun::star;
@@ -2539,7 +2539,7 @@ uno::Sequence< OUString > SwXTextFieldMasters::getElementNames(void)
     const SwFldTypes* pFldTypes = GetDoc()->GetFldTypes();
     sal_uInt16 nCount = pFldTypes->Count();
 
-    SvStrings aFldNames;
+    std::vector<String*> aFldNames;
     String* pString = new String();
     sal_uInt16 i;
 
@@ -2549,22 +2549,21 @@ uno::Sequence< OUString > SwXTextFieldMasters::getElementNames(void)
 
         if (SwXTextFieldMasters::getInstanceName(rFldType, *pString))
         {
-            aFldNames.Insert(pString, aFldNames.Count());
+            aFldNames.push_back(pString);
             pString = new String();
         }
     }
     delete pString;
 
-    uno::Sequence< OUString > aSeq(aFldNames.Count());
+    uno::Sequence< OUString > aSeq( static_cast<sal_uInt16>(aFldNames.size()) );
     OUString* pArray = aSeq.getArray();
-    for(i = 0; i < aFldNames.Count();i++)
+    for(std::vector<String*>::const_iterator it(aFldNames.begin()); it != aFldNames.end(); ++it)
     {
-        pArray[i] = *aFldNames.GetObject(i);
+        pArray[i] = **it;
+        delete *it;
     }
-    aFldNames.DeleteAndDestroy(0, aFldNames.Count());
 
     return aSeq;
-
 }
 
 sal_Bool SwXTextFieldMasters::hasByName(const OUString& rName) throw( uno::RuntimeException )
-- 
1.7.7.4


--------------070407020004070208090302--


More information about the LibreOffice mailing list