[Libreoffice-commits] .: 5 commits - sfx2/inc sfx2/source svx/inc svx/source

August Sodora augsod at kemper.freedesktop.org
Wed Jan 11 19:19:50 PST 2012


 sfx2/inc/sfx2/docfile.hxx        |    5 ---
 sfx2/inc/sfx2/docinsert.hxx      |   15 ---------
 sfx2/source/doc/docinsert.cxx    |   39 ++++++------------------
 svx/inc/svx/numfmtsh.hxx         |    8 -----
 svx/inc/svx/srchdlg.hxx          |    4 +-
 svx/source/dialog/srchdlg.cxx    |   52 +++++++++++++-------------------
 svx/source/items/clipfmtitem.cxx |   62 +++++++++++++++++----------------------
 7 files changed, 62 insertions(+), 123 deletions(-)

New commits:
commit 8be35fc8c1f24a05deb6ba850ad42ca17352350e
Author: August Sodora <augsod at gmail.com>
Date:   Wed Jan 11 22:18:58 2012 -0500

    SvStringsDtor->std::vector

diff --git a/sfx2/inc/sfx2/docinsert.hxx b/sfx2/inc/sfx2/docinsert.hxx
index 292b396..6ec9627 100644
--- a/sfx2/inc/sfx2/docinsert.hxx
+++ b/sfx2/inc/sfx2/docinsert.hxx
@@ -39,20 +39,11 @@
 namespace sfx2 { class FileDialogHelper; }
 class SfxMedium;
 class SfxItemSet;
-class SvStringsDtor;
 
 typedef ::std::vector< SfxMedium* > SfxMediumList;
 
-// ============================================================================
-
 namespace sfx2 {
 
-// ============================================================================
-
-// ============================================================================
-// DocumentInserter
-// ============================================================================
-
 class SFX2_DLLPUBLIC DocumentInserter
 {
 private:
@@ -65,7 +56,7 @@ private:
 
     sfx2::FileDialogHelper* m_pFileDlg;
     SfxItemSet*             m_pItemSet;
-    SvStringsDtor*          m_pURLList;
+    std::vector<rtl::OUString> m_pURLList;
 
     DECL_LINK(              DialogClosedHdl, sfx2::FileDialogHelper* );
 
@@ -82,12 +73,8 @@ public:
     inline String           GetFilter() const { return m_sFilter; }
 };
 
-// ============================================================================
-
 } // namespace sfx2
 
-// ============================================================================
-
 #endif // _SFX_DOCINSERT_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/docinsert.cxx b/sfx2/source/doc/docinsert.cxx
index c103116..d40f65a 100644
--- a/sfx2/source/doc/docinsert.cxx
+++ b/sfx2/source/doc/docinsert.cxx
@@ -57,16 +57,8 @@ using namespace ::com::sun::star::uno;
 // implemented in 'sfx2/source/appl/appopen.cxx'
 extern sal_uInt32 CheckPasswd_Impl( SfxObjectShell* pDoc, SfxItemPool &rPool, SfxMedium* pFile );
 
-// =======================================================================
-
 namespace sfx2 {
 
-// =======================================================================
-
-// =======================================================================
-// DocumentInserter
-// =======================================================================
-
 DocumentInserter::DocumentInserter(
     const String& rFactory, bool const bEnableMultiSelection) :
 
@@ -77,8 +69,6 @@ DocumentInserter::DocumentInserter(
     , m_nError                  ( ERRCODE_NONE )
     , m_pFileDlg                ( NULL )
     , m_pItemSet                ( NULL )
-    , m_pURLList                ( NULL )
-
 {
 }
 
@@ -91,7 +81,6 @@ void DocumentInserter::StartExecuteModal( const Link& _rDialogClosedLink )
 {
     m_aDialogClosedLink = _rDialogClosedLink;
     m_nError = ERRCODE_NONE;
-    DELETEZ( m_pURLList );
     if ( !m_pFileDlg )
     {
         m_pFileDlg = new FileDialogHelper(
@@ -104,10 +93,10 @@ void DocumentInserter::StartExecuteModal( const Link& _rDialogClosedLink )
 SfxMedium* DocumentInserter::CreateMedium()
 {
     SfxMedium* pMedium = NULL;
-    if ( !m_nError && m_pItemSet && m_pURLList && m_pURLList->Count() > 0 )
+    if (!m_nError && m_pItemSet && !m_pURLList.empty())
     {
-        DBG_ASSERT( m_pURLList->Count() == 1, "DocumentInserter::CreateMedium(): invalid URL list count" );
-        String sURL = *( m_pURLList->GetObject(0) );
+        DBG_ASSERT( m_pURLList.size() == 1, "DocumentInserter::CreateMedium(): invalid URL list count" );
+        String sURL(m_pURLList[0]);
         pMedium = new SfxMedium(
                 sURL, SFX_STREAM_READONLY, sal_False,
                 SFX_APP()->GetFilterMatcher().GetFilter4FilterName( m_sFilter ), m_pItemSet );
@@ -137,15 +126,12 @@ SfxMedium* DocumentInserter::CreateMedium()
 SfxMediumList* DocumentInserter::CreateMediumList()
 {
     SfxMediumList* pMediumList = new SfxMediumList;
-    if ( !m_nError && m_pItemSet && m_pURLList && m_pURLList->Count() > 0 )
+    if (!m_nError && m_pItemSet && !m_pURLList.empty())
     {
-        sal_Int32 i = 0;
-        sal_Int32 nCount = m_pURLList->Count();
-        for ( ; i < nCount; ++i )
+        for(std::vector<rtl::OUString>::const_iterator i = m_pURLList.begin(); i != m_pURLList.end(); ++i)
         {
-            String sURL = *( m_pURLList->GetObject( static_cast< sal_uInt16 >(i) ) );
             SfxMedium* pMedium = new SfxMedium(
-                    sURL, SFX_STREAM_READONLY, sal_False,
+                    *i, SFX_STREAM_READONLY, sal_False,
                     SFX_APP()->GetFilterMatcher().GetFilter4FilterName( m_sFilter ), m_pItemSet );
 
             pMedium->UseInteractionHandler( sal_True );
@@ -168,21 +154,20 @@ SfxMediumList* DocumentInserter::CreateMediumList()
     return pMediumList;
 }
 
-void impl_FillURLList( sfx2::FileDialogHelper* _pFileDlg, SvStringsDtor*& _rpURLList )
+void impl_FillURLList( sfx2::FileDialogHelper* _pFileDlg, std::vector<rtl::OUString>& _rpURLList )
 {
     DBG_ASSERT( _pFileDlg, "DocumentInserter::fillURLList(): invalid file dialog" );
-    DBG_ASSERT( !_rpURLList, "DocumentInserter::fillURLList(): URLList already exists" );
+
     Sequence < ::rtl::OUString > aPathSeq = _pFileDlg->GetSelectedFiles();
 
     if ( aPathSeq.getLength() )
     {
-        _rpURLList = new SvStringsDtor;
+        _rpURLList.clear();
 
         for ( sal_uInt16 i = 0; i < aPathSeq.getLength(); ++i )
         {
             INetURLObject aPathObj( aPathSeq[i] );
-            String* pURL = new String( aPathObj.GetMainURL( INetURLObject::NO_DECODE ) );
-            _rpURLList->Insert( pURL, _rpURLList->Count() );
+            _rpURLList.push_back(aPathObj.GetMainURL(INetURLObject::NO_DECODE));
         }
     }
 }
@@ -295,10 +280,6 @@ IMPL_LINK( DocumentInserter, DialogClosedHdl, sfx2::FileDialogHelper*, EMPTYARG
     return 0;
 }
 
-// =======================================================================
-
 } // namespace sfx2
 
-// =======================================================================
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit f8e071697ca2fe5e8cd91a5c87fdb720562902af
Author: August Sodora <augsod at gmail.com>
Date:   Wed Jan 11 22:12:32 2012 -0500

    Remove unnecessary forward declaration

diff --git a/sfx2/inc/sfx2/docfile.hxx b/sfx2/inc/sfx2/docfile.hxx
index f05e7e4..b07b97e 100644
--- a/sfx2/inc/sfx2/docfile.hxx
+++ b/sfx2/inc/sfx2/docfile.hxx
@@ -64,11 +64,6 @@ class SfxFrame;
 class Timer;
 class SfxItemSet;
 class DateTime;
-class SvStringsDtor;
-
-//____________________________________________________________________________________________________________________________________
-//  defines for namespaces
-//____________________________________________________________________________________________________________________________________
 
 #define OUSTRING                    ::rtl::OUString
 #define XMULTISERVICEFACTORY        ::com::sun::star::lang::XMultiServiceFactory
commit 0313e253956635eeff280ebff219c78cfb16724b
Author: August Sodora <augsod at gmail.com>
Date:   Wed Jan 11 22:03:21 2012 -0500

    SvStringsDtor->boost::ptr_vector

diff --git a/svx/source/items/clipfmtitem.cxx b/svx/source/items/clipfmtitem.cxx
index 2dd89e2..d8f7f64 100644
--- a/svx/source/items/clipfmtitem.cxx
+++ b/svx/source/items/clipfmtitem.cxx
@@ -30,15 +30,15 @@
 #include <svx/clipfmtitem.hxx>
 #include <com/sun/star/frame/status/ClipboardFormats.hpp>
 
-#include <vector>
+#include <boost/ptr_container/ptr_vector.hpp>
 
 struct SvxClipboardFmtItem_Impl
 {
-    SvStringsDtor aFmtNms;
+    boost::ptr_vector<boost::nullable<String>> aFmtNms;
     std::vector<sal_uIntPtr> aFmtIds;
     static String sEmptyStr;
 
-    SvxClipboardFmtItem_Impl() : aFmtNms( 8, 8 ) {}
+    SvxClipboardFmtItem_Impl() {}
     SvxClipboardFmtItem_Impl( const SvxClipboardFmtItem_Impl& );
 };
 
@@ -48,15 +48,9 @@ TYPEINIT1_FACTORY( SvxClipboardFmtItem, SfxPoolItem , new  SvxClipboardFmtItem(0
 
 SvxClipboardFmtItem_Impl::SvxClipboardFmtItem_Impl(
                             const SvxClipboardFmtItem_Impl& rCpy )
-    : aFmtIds(rCpy.aFmtIds)
+    : aFmtNms(rCpy.aFmtNms)
+    , aFmtIds(rCpy.aFmtIds)
 {
-    for( sal_uInt16 n = 0, nEnd = rCpy.aFmtNms.Count(); n < nEnd; ++n )
-    {
-        String* pStr = rCpy.aFmtNms[ n ];
-        if( pStr )
-            pStr = new String( *pStr );
-        aFmtNms.Insert( pStr, n );
-    }
 }
 
 SvxClipboardFmtItem::SvxClipboardFmtItem( sal_uInt16 nId )
@@ -101,7 +95,7 @@ bool SvxClipboardFmtItem::PutValue( const ::com::sun::star::uno::Any& rVal, sal_
         sal_uInt16 nCount = sal_uInt16( aClipFormats.Identifiers.getLength() );
 
         pImpl->aFmtIds.clear();
-        pImpl->aFmtNms.Remove( 0, pImpl->aFmtNms.Count() );
+        pImpl->aFmtNms.clear();
         for ( sal_uInt16 n=0; n < nCount; n++ )
             AddClipbrdFormat( sal_uIntPtr( aClipFormats.Identifiers[n] ), aClipFormats.Names[n], n );
 
@@ -113,24 +107,24 @@ bool SvxClipboardFmtItem::PutValue( const ::com::sun::star::uno::Any& rVal, sal_
 
 int SvxClipboardFmtItem::operator==( const SfxPoolItem& rComp ) const
 {
-    int nRet = 0;
     const SvxClipboardFmtItem& rCmp = (SvxClipboardFmtItem&)rComp;
-    if( rCmp.pImpl->aFmtNms.Count() == pImpl->aFmtNms.Count() )
+    if(rCmp.pImpl->aFmtNms.size() != pImpl->aFmtNms.size())
+        return 0;
+
+    int nRet = 1;
+    const String* pStr1, *pStr2;
+    for( sal_uInt16 n = 0, nEnd = rCmp.pImpl->aFmtNms.size(); n < nEnd; ++n )
     {
-        nRet = 1;
-        const String* pStr1, *pStr2;
-        for( sal_uInt16 n = 0, nEnd = rCmp.pImpl->aFmtNms.Count(); n < nEnd; ++n )
+        if( pImpl->aFmtIds[ n ] != rCmp.pImpl->aFmtIds[ n ] ||
+            ( (0 == ( pStr1 = &(pImpl->aFmtNms[n]) )) ^
+              (0 == ( pStr2 = &(rCmp.pImpl->aFmtNms[n]) ) )) ||
+            ( pStr1 && *pStr1 != *pStr2 ))
         {
-            if( pImpl->aFmtIds[ n ] != rCmp.pImpl->aFmtIds[ n ] ||
-                ( (0 == ( pStr1 = pImpl->aFmtNms[ n ] )) ^
-                  (0 == ( pStr2 = rCmp.pImpl->aFmtNms[ n ] ) )) ||
-                ( pStr1 && *pStr1 != *pStr2 ))
-            {
-                nRet = 0;
-                break;
-            }
+            nRet = 0;
+            break;
         }
     }
+
     return nRet;
 }
 
@@ -141,20 +135,20 @@ SfxPoolItem* SvxClipboardFmtItem::Clone( SfxItemPool * /*pPool*/ ) const
 
 void SvxClipboardFmtItem::AddClipbrdFormat( sal_uIntPtr nId, sal_uInt16 nPos )
 {
-    if( nPos > pImpl->aFmtNms.Count() )
-        nPos = pImpl->aFmtNms.Count();
-    String* pStr = 0;
-    pImpl->aFmtNms.Insert( pStr, nPos );
+    if( nPos > pImpl->aFmtNms.size() )
+        nPos = pImpl->aFmtNms.size();
+
+    pImpl->aFmtNms.insert(pImpl->aFmtNms.begin() + nPos, NULL);
     pImpl->aFmtIds.insert( pImpl->aFmtIds.begin()+nPos, nId );
 }
 
 void SvxClipboardFmtItem::AddClipbrdFormat( sal_uIntPtr nId, const String& rName,
                             sal_uInt16 nPos )
 {
-    if( nPos > pImpl->aFmtNms.Count() )
-        nPos = pImpl->aFmtNms.Count();
-    String* pStr = new String( rName );
-    pImpl->aFmtNms.Insert( pStr, nPos );
+    if( nPos > pImpl->aFmtNms.size() )
+        nPos = pImpl->aFmtNms.size();
+
+    pImpl->aFmtNms.insert(pImpl->aFmtNms.begin() + nPos, new String(rName));
     pImpl->aFmtIds.insert( pImpl->aFmtIds.begin()+nPos, nId );
 }
 
@@ -170,7 +164,7 @@ sal_uIntPtr SvxClipboardFmtItem::GetClipbrdFormatId( sal_uInt16 nPos ) const
 
 const String& SvxClipboardFmtItem::GetClipbrdFormatName( sal_uInt16 nPos ) const
 {
-    const String* pS = pImpl->aFmtNms[ nPos ];
+    const String* pS = &(pImpl->aFmtNms[nPos]);
     return pS ? *pS : SvxClipboardFmtItem_Impl::sEmptyStr;
 }
 
commit 74461daea9d80e51f3a78d2f0971137c6e8116fd
Author: August Sodora <augsod at gmail.com>
Date:   Wed Jan 11 21:52:16 2012 -0500

    Remove unnecessary forward declaration

diff --git a/svx/inc/svx/numfmtsh.hxx b/svx/inc/svx/numfmtsh.hxx
index 3ae23f4..e9b4772 100644
--- a/svx/inc/svx/numfmtsh.hxx
+++ b/svx/inc/svx/numfmtsh.hxx
@@ -28,8 +28,6 @@
 #ifndef _SVX_NUMFMTSH_HXX
 #define _SVX_NUMFMTSH_HXX
 
-// include ---------------------------------------------------------------
-
 #include <tools/string.hxx>
 #include <i18npool/lang.h>
 
@@ -39,14 +37,10 @@
 
 #include <vector>
 
-// forward ---------------------------------------------------------------
-
 class Color;
 class SvNumberFormatter;
 class SvNumberFormatTable;
-class SvStringsDtor;
 class NfCurrencyEntry;
-// enum ------------------------------------------------------------------
 
 enum SvxNumberValueType
 {
@@ -55,8 +49,6 @@ enum SvxNumberValueType
     SVX_VALUE_TYPE_STRING
 };
 
-// define ----------------------------------------------------------------
-
 // sort order of the category ListBox entries in the TabPage
 #define CAT_ALL             0
 #define CAT_USERDEFINED     1
commit 117d60e26ed0cb6d55ee110939b97f063f0036d8
Author: August Sodora <augsod at gmail.com>
Date:   Wed Jan 11 21:51:34 2012 -0500

    SvStringsDtor->std::vector

diff --git a/svx/inc/svx/srchdlg.hxx b/svx/inc/svx/srchdlg.hxx
index ad2cea4..ffa8bf5 100644
--- a/svx/inc/svx/srchdlg.hxx
+++ b/svx/inc/svx/srchdlg.hxx
@@ -219,8 +219,8 @@ private:
     String          aLayoutStr;
     String aCalcStr;
 
-    SvStringsDtor   aSearchStrings;
-    SvStringsDtor   aReplaceStrings;
+    std::vector<rtl::OUString> aSearchStrings;
+    std::vector<rtl::OUString> aReplaceStrings;
 
     SearchDlg_Impl*         pImpl;
     SearchAttrItemList*     pSearchList;
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index a46a75c..305436b 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -139,9 +139,7 @@ struct SearchDlg_Impl
     ~SearchDlg_Impl() { delete[] pRanges; }
 };
 
-// -----------------------------------------------------------------------
-
-void ListToStrArr_Impl( sal_uInt16 nId, SvStringsDtor& rStrLst, ComboBox& rCBox )
+void ListToStrArr_Impl( sal_uInt16 nId, std::vector<rtl::OUString>& rStrLst, ComboBox& rCBox )
 {
     SfxStringListItem* pSrchItem =
         (SfxStringListItem*)SFX_APP()->GetItem( nId );
@@ -152,22 +150,19 @@ void ListToStrArr_Impl( sal_uInt16 nId, SvStringsDtor& rStrLst, ComboBox& rCBox
 
         for ( sal_uInt16 i = 0; i < aLst.size(); ++i )
         {
-            String* pTmp = new String(aLst[i]);
-            rStrLst.Insert( pTmp, rStrLst.Count() );
-            rCBox.InsertEntry( *pTmp );
+            rStrLst.push_back(aLst[i]);
+            rCBox.InsertEntry(aLst[i]);
         }
     }
 }
 
-// -----------------------------------------------------------------------
-
-void StrArrToList_Impl( sal_uInt16 nId, const SvStringsDtor& rStrLst )
+void StrArrToList_Impl( sal_uInt16 nId, const std::vector<rtl::OUString>& rStrLst )
 {
-    DBG_ASSERT( rStrLst.Count(), "check in advance");
+    DBG_ASSERT( !rStrLst.empty(), "check in advance");
     std::vector<String> aLst;
 
-    for ( sal_uInt16 i = 0; i < rStrLst.Count(); ++i )
-        aLst.push_back( *rStrLst[ i ]);
+    for (std::vector<rtl::OUString>::const_iterator i = rStrLst.begin(); i != rStrLst.end(); ++i)
+        aLst.push_back(String(*i));
 
     SFX_APP()->PutItem( SfxStringListItem( nId, &aLst ) );
 }
@@ -586,10 +581,10 @@ void SvxSearchDialog::Construct_Impl()
 sal_Bool SvxSearchDialog::Close()
 {
     // remember strings speichern
-    if ( aSearchStrings.Count() )
+    if (!aSearchStrings.empty())
         StrArrToList_Impl( SID_SEARCHDLG_SEARCHSTRINGS, aSearchStrings );
 
-    if ( aReplaceStrings.Count() )
+    if (!aReplaceStrings.empty())
         StrArrToList_Impl( SID_SEARCHDLG_REPLACESTRINGS, aReplaceStrings );
 
     // save settings to configuration
@@ -1130,19 +1125,19 @@ void SvxSearchDialog::Init_Impl( int bSearchPattern )
 
         if ( pSearchItem->GetSearchString().Len() && bSetSearch )
             aSearchLB.SetText( pSearchItem->GetSearchString() );
-        else if ( aSearchStrings.Count() )
+        else if (!aSearchStrings.empty())
         {
             bool bAttributes =
                 ( ( pSearchList && pSearchList->Count() ) ||
                   ( pReplaceList && pReplaceList->Count() ) );
 
             if ( bSetSearch && !bAttributes )
-                aSearchLB.SetText( *aSearchStrings[ 0 ] );
+                aSearchLB.SetText(aSearchStrings[0]);
 
             String aReplaceTxt = pSearchItem->GetReplaceString();
 
-            if ( aReplaceStrings.Count() )
-                aReplaceTxt = *aReplaceStrings[ 0 ];
+            if (!aReplaceStrings.empty())
+                aReplaceTxt = aReplaceStrings[0];
 
             if ( bSetReplace && !bAttributes )
                 aReplaceLB.SetText( aReplaceTxt );
@@ -1737,31 +1732,26 @@ void SvxSearchDialog::Remember_Impl( const String &rStr,sal_Bool _bSearch )
     if ( !rStr.Len() )
         return;
 
-    SvStringsDtor* pArr = _bSearch ? &aSearchStrings : &aReplaceStrings;
+    std::vector<rtl::OUString>* pArr = _bSearch ? &aSearchStrings : &aReplaceStrings;
     ComboBox* pListBox = _bSearch ? &aSearchLB : &aReplaceLB;
 
     // ignore identical strings
-    for ( sal_uInt16 i = 0; i < pArr->Count(); ++i )
+    for (std::vector<rtl::OUString>::const_iterator i = pArr->begin(); i != pArr->end(); ++i)
     {
-        if ( COMPARE_EQUAL == (*pArr)[i]->CompareTo( rStr ) )
+        if ((*i).equals(rStr))
             return;
     }
 
     // delete oldest entry at maximum occupancy (ListBox and Array)
-    String* pInsStr;
-
-    if ( pArr->Count() >= REMEMBER_SIZE )
+    if(REMEMBER_SIZE < pArr->size())
     {
-        pInsStr = (*pArr)[REMEMBER_SIZE - 1];
         pListBox->RemoveEntry( sal_uInt16(REMEMBER_SIZE - 1) );
-        pArr->Remove( REMEMBER_SIZE - 1 );
-        *pInsStr = rStr;
+        (*pArr)[REMEMBER_SIZE - 1] = rStr;
+        pArr->erase(pArr->begin() + REMEMBER_SIZE - 1);
     }
-    else
-        pInsStr = new String( rStr );
 
-    pArr->Insert( pInsStr, 0 );
-    pListBox->InsertEntry( *pInsStr, 0 );
+    pArr->insert(pArr->begin(), rStr);
+    pListBox->InsertEntry(rStr, 0);
 }
 
 // -----------------------------------------------------------------------


More information about the Libreoffice-commits mailing list