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

Michael Stahl mstahl at redhat.com
Mon Aug 31 14:54:52 PDT 2015


 sw/inc/rubylist.hxx              |    6 ++++--
 sw/source/core/doc/docruby.cxx   |    9 ++++-----
 sw/source/uibase/uno/unotxvw.cxx |    6 +++---
 3 files changed, 11 insertions(+), 10 deletions(-)

New commits:
commit 5331e767c7de8ece7e596fefb451a73bae8b583c
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Aug 31 23:49:03 2015 +0200

    sw: convert boost::ptr_vector to std::vector<std::unique_ptr>
    
    Change-Id: I7fc96e3b7754bb3f4718f9142c75ee82aef0a22c

diff --git a/sw/inc/rubylist.hxx b/sw/inc/rubylist.hxx
index 38572b2..9de8d05 100644
--- a/sw/inc/rubylist.hxx
+++ b/sw/inc/rubylist.hxx
@@ -21,7 +21,9 @@
 
 #include <swtypes.hxx>
 #include <fmtruby.hxx>
-#include <boost/ptr_container/ptr_vector.hpp>
+
+#include <memory>
+#include <vector>
 
 class SwRubyListEntry
 {
@@ -39,7 +41,7 @@ public:
     void SetRubyAttr( const SwFormatRuby& rAttr )  { m_aRubyAttr = rAttr; }
 };
 
-class SwRubyList : public boost::ptr_vector<SwRubyListEntry> {};
+class SwRubyList : public std::vector<std::unique_ptr<SwRubyListEntry>> {};
 
 #endif  //_ INCLUDED_SW_INC_RUBYLIST_HXX
 
diff --git a/sw/source/core/doc/docruby.cxx b/sw/source/core/doc/docruby.cxx
index f959d18..b3372f0 100644
--- a/sw/source/core/doc/docruby.cxx
+++ b/sw/source/core/doc/docruby.cxx
@@ -60,7 +60,7 @@ sal_uInt16 SwDoc::FillRubyList( const SwPaM& rPam, SwRubyList& rList,
         {
             SwPaM aPam( *pStt );
             do {
-                SwRubyListEntry* pNew = new SwRubyListEntry;
+                std::unique_ptr<SwRubyListEntry> pNew(new SwRubyListEntry);
                 if( pEnd != pStt )
                 {
                     aPam.SetMark();
@@ -68,12 +68,11 @@ sal_uInt16 SwDoc::FillRubyList( const SwPaM& rPam, SwRubyList& rList,
                 }
                 if( _SelectNextRubyChars( aPam, *pNew, nMode ))
                 {
-                    rList.push_back( pNew );
+                    rList.push_back(std::move(pNew));
                     aPam.DeleteMark();
                 }
                 else
                 {
-                    delete pNew;
                      if( *aPam.GetPoint() < *pEnd )
                      {
                         // goto next paragraph
@@ -121,7 +120,7 @@ sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList,
                 }
                 if( _SelectNextRubyChars( aPam, aCheckEntry, nMode ))
                 {
-                    const SwRubyListEntry* pEntry = &rList[ nListEntry++ ];
+                    const SwRubyListEntry* pEntry = rList[ nListEntry++ ].get();
                     if( aCheckEntry.GetRubyAttr() != pEntry->GetRubyAttr() )
                     {
                         // set/reset the attribute
@@ -153,7 +152,7 @@ sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList,
                      }
                      else
                     {
-                        const SwRubyListEntry* pEntry = &rList[ nListEntry++ ];
+                        const SwRubyListEntry* pEntry = rList[ nListEntry++ ].get();
 
                         // set/reset the attribute
                         if( !pEntry->GetRubyAttr().GetText().isEmpty() &&
diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx
index 684c95e..bc17d71 100644
--- a/sw/source/uibase/uno/unotxvw.cxx
+++ b/sw/source/uibase/uno/unotxvw.cxx
@@ -547,7 +547,7 @@ Sequence< Sequence< PropertyValue > > SwXTextView::getRubyList( sal_Bool /*bAuto
     OUString aString;
     for(sal_uInt16 n = 0; n < nCount; n++)
     {
-        const SwRubyListEntry* pEntry = &aList[n];
+        const SwRubyListEntry* pEntry = aList[n].get();
 
         const OUString& rEntryText = pEntry->GetText();
         const SwFormatRuby& rAttr = pEntry->GetRubyAttr();
@@ -591,7 +591,7 @@ void SAL_CALL SwXTextView::setRubyList(
     const Sequence<PropertyValue>* pRubyList = rRubyList.getConstArray();
     for(sal_Int32 nPos = 0; nPos < rRubyList.getLength(); nPos++)
     {
-        SwRubyListEntry* pEntry = new SwRubyListEntry;
+        std::unique_ptr<SwRubyListEntry> pEntry(new SwRubyListEntry);
         const PropertyValue* pProperties = pRubyList[nPos].getConstArray();
         OUString sTmp;
         for(sal_Int32 nProp = 0; nProp < pRubyList[nPos].getLength(); nProp++)
@@ -633,7 +633,7 @@ void SAL_CALL SwXTextView::setRubyList(
                 pEntry->GetRubyAttr().SetPosition(bValue ? 0 : 1);
             }
         }
-        aList.insert(aList.begin() + nPos, pEntry);
+        aList.insert(aList.begin() + nPos, std::move(pEntry));
     }
     SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
     pDoc->SetRubyList( *rSh.GetCrsr(), aList, 0 );


More information about the Libreoffice-commits mailing list