Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi,

See attached.

Note 1
------
I made the following change in one place. Is this ok or should I call reserve(10) to be safe?

-        SvStrings aArr( 10, 10 );
+        std::vector<String*> aArr;

Regards,
Brad


From 23613a0ae4e80fdda1fcf1c458b55c526f9fdf58 Mon Sep 17 00:00:00 2001
From: Brad Sowden <code@sowden.org>
Date: Thu, 29 Dec 2011 10:25:56 +1300
Subject: [PATCH 2/8] fdo#38831 convert SvStrings to std::vector misc

---
 sw/inc/SwXMLSectionList.hxx             |    6 +++---
 sw/inc/shellio.hxx                      |    6 +++---
 sw/source/core/swg/SwXMLSectionList.cxx |    9 ++++-----
 sw/source/filter/basflt/shellio.cxx     |    2 +-
 sw/source/filter/inc/fltini.hxx         |    4 ++--
 sw/source/filter/xml/swxml.cxx          |   12 +++---------
 sw/source/ui/dialog/uiregionsw.cxx      |   10 +++++-----
 7 files changed, 21 insertions(+), 28 deletions(-)

diff --git a/sw/inc/SwXMLSectionList.hxx b/sw/inc/SwXMLSectionList.hxx
index 0467864..c59fda7 100644
--- a/sw/inc/SwXMLSectionList.hxx
+++ b/sw/inc/SwXMLSectionList.hxx
@@ -31,7 +31,7 @@
 #include <xmloff/xmlictxt.hxx>
 #include <xmloff/xmlimp.hxx>
 
-class SvStrings;
+class vector;
 
 class SwXMLSectionList : public SvXMLImport
 {
@@ -43,11 +43,11 @@ protected:
                   const ::com::sun::star::uno::Reference<
                     ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
 public:
-    SvStrings & rSectionList;
+    std::vector<String*> &rSectionList;
 
     SwXMLSectionList(
         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > 
xServiceFactory,
-        SvStrings & rNewSectionList );
+        std::vector<String*> &rNewSectionList );
 
     virtual ~SwXMLSectionList ( )
         throw();
diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx
index 56cd063..0b91804 100644
--- a/sw/inc/shellio.hxx
+++ b/sw/inc/shellio.hxx
@@ -56,7 +56,6 @@ class SfxItemSet;
 class SfxMedium;
 class SvPtrarr;
 class SvStream;
-class SvStrings;
 class SvxFontItem;
 class SvxMacroTableDtor;
 class SwCntntNode;
@@ -64,6 +63,7 @@ class SwCrsrShell;
 class SwDoc;
 class SwPaM;
 class SwTextBlocks;
+class vector;
 struct SwPosition;
 struct Writer_Impl;
 
@@ -272,8 +272,8 @@ public:
 
     // Read the sections of the document, which is equal to the medium.
     // Returns the count of it
-    virtual sal_uInt16 GetSectionList( SfxMedium& rMedium,
-                                    SvStrings& rStrings ) const;
+    virtual size_t GetSectionList( SfxMedium& rMedium,
+                                   std::vector<String*>& rStrings ) const;
 
     SotStorageRef getSotStorageRef() { return pStg; };
     void setSotStorageRef(SotStorageRef pStgRef) { pStg = pStgRef; };
diff --git a/sw/source/core/swg/SwXMLSectionList.cxx b/sw/source/core/swg/SwXMLSectionList.cxx
index 1d00774..3a1adfd 100644
--- a/sw/source/core/swg/SwXMLSectionList.cxx
+++ b/sw/source/core/swg/SwXMLSectionList.cxx
@@ -26,12 +26,11 @@
  *
  ************************************************************************/
 
-#define _SVSTDARR_STRINGSDTOR
-#define _SVSTDARR_STRINGS
-#include <svl/svstdarr.hxx>
 #include <SwXMLSectionList.hxx>
 #include <xmloff/nmspmap.hxx>
 #include <xmloff/xmlnmspe.hxx>
+#include <tools/string.hxx>
+#include <vector>
 
 using namespace ::com::sun::star;
 using ::rtl::OUString;
@@ -43,7 +42,7 @@ sal_Char const sXML_np__text[] = "_otext";
 // #110680#
 SwXMLSectionList::SwXMLSectionList(
     const uno::Reference< lang::XMultiServiceFactory > xServiceFactory,
-    SvStrings & rNewSectionList)
+    std::vector<String*> &rNewSectionList)
 :   SvXMLImport( xServiceFactory ),
     rSectionList ( rNewSectionList )
 {
@@ -121,7 +120,7 @@ SvXMLImportContext *SvXMLSectionListContext::CreateChildContext(
                 sName = rAttrValue;
         }
         if ( sName.Len() )
-            rLocalRef.rSectionList.Insert ( new String(sName), rLocalRef.rSectionList.Count() );
+            rLocalRef.rSectionList.push_back( new String(sName) );
     }
 
     pContext = new SvXMLSectionListContext (rLocalRef, nPrefix, rLocalName, xAttrList);
diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx
index 3999f47..35f8409 100644
--- a/sw/source/filter/basflt/shellio.cxx
+++ b/sw/source/filter/basflt/shellio.cxx
@@ -682,7 +682,7 @@ void Reader::ResetFrmFmts( SwDoc& rDoc )
 
     // read the sections of the document, which is equal to the medium.
     // returns the count of it
-sal_uInt16 Reader::GetSectionList( SfxMedium&, SvStrings& ) const
+size_t Reader::GetSectionList( SfxMedium&, std::vector<String*>& ) const
 {
     return 0;
 }
diff --git a/sw/source/filter/inc/fltini.hxx b/sw/source/filter/inc/fltini.hxx
index 5b546c0..47e6cc1 100644
--- a/sw/source/filter/inc/fltini.hxx
+++ b/sw/source/filter/inc/fltini.hxx
@@ -64,8 +64,8 @@ public:
 
     // read the sections of the document, which is equal to the medium.
     // returns the count of it
-    virtual sal_uInt16 GetSectionList( SfxMedium& rMedium,
-                                SvStrings& rStrings ) const;
+    virtual size_t GetSectionList( SfxMedium& rMedium,
+                                   std::vector<String*>& rStrings ) const;
 };
 
 // die speziellen Writer
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
index b6684bd..3f29d8c 100644
--- a/sw/source/filter/xml/swxml.cxx
+++ b/sw/source/filter/xml/swxml.cxx
@@ -27,10 +27,6 @@
  ************************************************************************/
 
 
-
-
-
-#define _SVSTDARR_STRINGS
 #include <rsc/rscsfx.hxx>
 #include <tools/urlobj.hxx>
 #include <com/sun/star/embed/XStorage.hpp>
@@ -51,7 +47,6 @@
 #include <com/sun/star/packages/zip/ZipIOException.hpp>
 #include <com/sun/star/packages/WrongPasswordException.hpp>
 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
-#include <svl/svstdarr.hxx>
 #include <sfx2/docfile.hxx>
 #include <svtools/sfxecode.hxx>
 #include <svl/stritem.hxx>
@@ -1067,8 +1062,8 @@ sal_uLong XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, 
con
 
     // read the sections of the document, which is equal to the medium.
     // returns the count of it
-sal_uInt16 XMLReader::GetSectionList( SfxMedium& rMedium,
-                                    SvStrings& rStrings ) const
+size_t XMLReader::GetSectionList( SfxMedium& rMedium,
+                                  std::vector<String*>& rStrings ) const
 {
     uno::Reference< lang::XMultiServiceFactory > xServiceFactory =
             comphelper::getProcessServiceFactory();
@@ -1095,7 +1090,6 @@ sal_uInt16 XMLReader::GetSectionList( SfxMedium& rMedium,
             if( xXMLParser.is() )
             {
                 // get filter
-                // uno::Reference< xml::sax::XDocumentHandler > xFilter = new SwXMLSectionList( 
rStrings );
                 uno::Reference< xml::sax::XDocumentHandler > xFilter = new SwXMLSectionList( 
xServiceFactory, rStrings );
 
                 // connect parser and filter
@@ -1123,7 +1117,7 @@ sal_uInt16 XMLReader::GetSectionList( SfxMedium& rMedium,
             // re throw ?
         }
     }
-    return rStrings.Count();
+    return rStrings.size();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx
index 9f262d4..8c28df4 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -1494,16 +1494,16 @@ static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox )
     uno::Reference < embed::XStorage > xStg;
     if( rMedium.IsStorage() && (xStg = rMedium.GetStorage()).is() )
     {
-        SvStrings aArr( 10, 10 );
+        std::vector<String*> aArr;
         sal_uInt32 nFormat = SotStorage::GetFormatID( xStg );
         if ( nFormat == SOT_FORMATSTR_ID_STARWRITER_60 || nFormat == 
SOT_FORMATSTR_ID_STARWRITERGLOB_60 ||
             nFormat == SOT_FORMATSTR_ID_STARWRITER_8 || nFormat == 
SOT_FORMATSTR_ID_STARWRITERGLOB_8)
             SwGetReaderXML()->GetSectionList( rMedium, aArr );
 
-        for( sal_uInt16 n = 0; n < aArr.Count(); ++n )
-            rBox.InsertEntry( *aArr[ n ] );
-
-        aArr.DeleteAndDestroy(0, aArr.Count());
+        for(std::vector<String*>::const_iterator it(aArr.begin()); it != aArr.end(); ++it) {
+            rBox.InsertEntry( **it );
+            delete *it;
+        }
     }
 }
 
-- 
1.7.7.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.