[Libreoffice-commits] .: sw/inc sw/source

August Sodora augsod at kemper.freedesktop.org
Fri Jan 13 20:49:28 PST 2012


 sw/inc/doc.hxx                 |   12 ++++++++++--
 sw/source/core/doc/poolfmt.cxx |   17 ++++++++---------
 2 files changed, 18 insertions(+), 11 deletions(-)

New commits:
commit 169f3b47c0ad339c6983de2e19d94627c9e567d3
Author: August Sodora <augsod at gmail.com>
Date:   Fri Jan 13 23:48:59 2012 -0500

    SvStringsDtor->boost::ptr_vector

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 47b55ec..edf59c3 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -88,6 +88,7 @@ class SwList;
 #include <memory>
 
 #include <boost/scoped_ptr.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
 
 namespace editeng { class SvxBorderLine; }
 
@@ -288,7 +289,7 @@ class SW_DLLPUBLIC SwDoc :
     SwDBData    aDBData;                // database descriptor
     ::com::sun::star::uno::Sequence <sal_Int8 > aRedlinePasswd;
     String      sTOIAutoMarkURL;        // ::com::sun::star::util::URL of table of index AutoMark file
-    SvStringsDtor aPatternNms;          // Array for names of document-templates
+    boost::ptr_vector< boost::nullable<String> > aPatternNms;          // Array for names of document-templates
     com::sun::star::uno::Reference<com::sun::star::container::XNameContainer>
         xXForms;                        // container with XForms models
     mutable com::sun::star::uno::Reference< com::sun::star::linguistic2::XProofreadingIterator > m_xGCIterator;
@@ -1300,7 +1301,14 @@ public:
     sal_uInt16 SetDocPattern( const String& rPatternName );
 
     // Return name of document template. Can be 0!
-    String* GetDocPattern( sal_uInt16 nPos ) const { return aPatternNms[nPos]; }
+    const String* GetDocPattern( sal_uInt16 nPos ) const
+    {
+        if(nPos >= aPatternNms.size())
+            return NULL;
+        if(boost::is_null(aPatternNms.begin() + nPos))
+            return NULL;
+        return &(aPatternNms[nPos]);
+    }
 
     // Delete all unreferenced field types.
     void GCFieldTypes();    // impl. in docfld.cxx
diff --git a/sw/source/core/doc/poolfmt.cxx b/sw/source/core/doc/poolfmt.cxx
index 25fae85..6b5868a 100644
--- a/sw/source/core/doc/poolfmt.cxx
+++ b/sw/source/core/doc/poolfmt.cxx
@@ -2125,21 +2125,20 @@ sal_uInt16 SwDoc::SetDocPattern( const String& rPatternName )
 {
     OSL_ENSURE( rPatternName.Len(), "no Document Template name" );
 
-    sal_uInt16 nNewPos = aPatternNms.Count();
-    for( sal_uInt16 n = 0; n < aPatternNms.Count(); ++n )
-        if( !aPatternNms[n] )
+    size_t nNewPos = aPatternNms.size();
+    for(size_t n = 0; n < aPatternNms.size(); ++n)
+        if( boost::is_null(aPatternNms.begin() + n) )
         {
-            if( nNewPos == aPatternNms.Count() )
+            if( nNewPos == aPatternNms.size() )
                 nNewPos = n;
         }
-        else if( rPatternName == *aPatternNms[n] )
+        else if( rPatternName == aPatternNms[n] )
             return n;
 
-    if( nNewPos < aPatternNms.Count() )
-        aPatternNms.Remove( nNewPos );      // Free space again
+    if( nNewPos < aPatternNms.size() )
+        aPatternNms.erase(aPatternNms.begin() + nNewPos);   // Free space again
 
-    String* pNewNm = new String( rPatternName );
-    aPatternNms.Insert( pNewNm, nNewPos );
+    aPatternNms.insert(aPatternNms.begin() + nNewPos, new String(rPatternName));
     SetModified();
     return nNewPos;
 }


More information about the Libreoffice-commits mailing list