[Libreoffice-commits] .: 3 commits - svl/inc svl/source sw/inc sw/source
Caolán McNamara
caolan at kemper.freedesktop.org
Sat Jul 28 09:18:36 PDT 2012
svl/inc/svl/brdcst.hxx | 25 ++++++-----
svl/inc/svl/zforlist.hxx | 2
svl/source/notify/brdcst.cxx | 71 ++++++++-------------------------
svl/source/notify/lstner.cxx | 12 ++---
sw/inc/shellio.hxx | 1
sw/source/core/access/acccell.cxx | 2
sw/source/core/access/acctable.cxx | 4 -
sw/source/core/unocore/swunohelper.cxx | 2
8 files changed, 43 insertions(+), 76 deletions(-)
New commits:
commit b806b638b931888c080c076c78970cac13f75057
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Jul 28 16:58:57 2012 +0100
update comments about SvPtrArr
Change-Id: I627f65581f457f0b1485bc30abcd5e4a10434d14
diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx
index 5bfbb72..7349114 100644
--- a/sw/inc/shellio.hxx
+++ b/sw/inc/shellio.hxx
@@ -54,7 +54,6 @@ class SfxFilter;
class SfxItemPool;
class SfxItemSet;
class SfxMedium;
-class SvPtrarr;
class SvStream;
class SvxFontItem;
class SvxMacroTableDtor;
diff --git a/sw/source/core/access/acccell.cxx b/sw/source/core/access/acccell.cxx
index 4c6b622..914a766 100644
--- a/sw/source/core/access/acccell.cxx
+++ b/sw/source/core/access/acccell.cxx
@@ -71,7 +71,7 @@ sal_Bool SwAccessibleCell::IsSelected()
const SwCellFrm *pCFrm =
static_cast< const SwCellFrm * >( GetFrm() );
SwTableBox *pBox =
- const_cast< SwTableBox *>( pCFrm->GetTabBox() ); //SVPtrArr!
+ const_cast< SwTableBox *>( pCFrm->GetTabBox() );
bRet = pCSh->GetTableCrsr()->GetBoxes().find( pBox ) != pCSh->GetTableCrsr()->GetBoxes().end();
}
}
diff --git a/sw/source/core/access/acctable.cxx b/sw/source/core/access/acctable.cxx
index 744b42e..735c314 100644
--- a/sw/source/core/access/acctable.cxx
+++ b/sw/source/core/access/acctable.cxx
@@ -294,7 +294,7 @@ void SwAccessibleTableData_Impl::GetSelection(
const SwCellFrm *pCFrm =
static_cast < const SwCellFrm * >( pLower );
SwTableBox *pBox =
- const_cast< SwTableBox *>( pCFrm->GetTabBox() ); //SVPtrArr!
+ const_cast< SwTableBox *>( pCFrm->GetTabBox() );
if( rSelBoxes.find( pBox ) == rSelBoxes.end() )
{
const Int32Set_Impl rRowsOrCols =
@@ -1198,7 +1198,7 @@ sal_Bool SAL_CALL SwAccessibleTable::isAccessibleSelected(
{
const SwCellFrm *pCFrm = static_cast < const SwCellFrm * >( pFrm );
SwTableBox *pBox =
- const_cast< SwTableBox *>( pCFrm->GetTabBox() ); //SVPtrArr!
+ const_cast< SwTableBox *>( pCFrm->GetTabBox() );
bRet = pSelBoxes->find( pBox ) != pSelBoxes->end();
}
}
diff --git a/sw/source/core/unocore/swunohelper.cxx b/sw/source/core/unocore/swunohelper.cxx
index b5f2bb8..01fb192 100644
--- a/sw/source/core/unocore/swunohelper.cxx
+++ b/sw/source/core/unocore/swunohelper.cxx
@@ -199,7 +199,7 @@ sal_Bool UCB_IsDirectory( const String& rURL )
// get a list of files from the folder of the URL
// options: pExtension = 0 -> all, else this specific extension
// pDateTime != 0 -> returns also the modified date/time of
- // the files in a SvPtrarr -->
+ // the files in a std::vector<String*> -->
// !! objects must be deleted from the caller!!
bool UCB_GetFileListOfFolder( const String& rURL,
std::vector<String*>& rList,
commit eed641ac455b7715d9544636c428050cc15488f9
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Jul 28 16:57:50 2012 +0100
update comment about SvPtrArr
Change-Id: I1944a04a5732d328f542c0819b43edc6fad9f7ac
diff --git a/svl/inc/svl/zforlist.hxx b/svl/inc/svl/zforlist.hxx
index 83becb9..7ac39d6 100644
--- a/svl/inc/svl/zforlist.hxx
+++ b/svl/inc/svl/zforlist.hxx
@@ -671,7 +671,7 @@ public:
/// Return the decimal separator matching the locale of the given format
String GetFormatDecimalSep( sal_uInt32 nFormat ) const;
- /// Return a <type>SvPtrArr</type> with pointers to <type>NfCurrencyEntry</type> entries
+ /// Return a <type>NfCurrencyTable</type> with pointers to <type>NfCurrencyEntry</type> entries
static const NfCurrencyTable& GetTheCurrencyTable();
/** Searches, according to the default locale currency, an entry of the
commit 50cf7caee5bc6d8e066580d13c72b40926fcb69a
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Jul 28 16:57:19 2012 +0100
convert SfxListenerArr_Impl from SvPtrarr to std::vector
Change-Id: I7f46731d880da30dc2dda011b31818437c955f2d
diff --git a/svl/inc/svl/brdcst.hxx b/svl/inc/svl/brdcst.hxx
index 007d4c0..d434a83 100644
--- a/svl/inc/svl/brdcst.hxx
+++ b/svl/inc/svl/brdcst.hxx
@@ -21,25 +21,22 @@
#include "svl/svldllapi.h"
#include <tools/rtti.hxx>
-#include <svl/svarray.hxx>
+#include <vector>
class SfxListener;
class SfxHint;
-#ifndef _SFX_BRDCST_CXX
-typedef SvPtrarr SfxListenerArr_Impl;
-#endif
-
//-------------------------------------------------------------------------
class SVL_DLLPUBLIC SfxBroadcaster
{
-friend class SfxListener;
+ friend class SfxListener;
+ typedef std::vector<SfxListener*> SfxListenerArr_Impl;
SfxListenerArr_Impl aListeners;
private:
- sal_Bool AddListener( SfxListener& rListener );
+ void AddListener( SfxListener& rListener );
void RemoveListener( SfxListener& rListener );
const SfxBroadcaster& operator=(const SfxBroadcaster &); // verboten
@@ -55,10 +52,18 @@ public:
virtual ~SfxBroadcaster();
void Broadcast( const SfxHint &rHint );
- sal_Bool HasListeners() const;
- sal_uInt16 GetListenerCount() const { return aListeners.Count(); }
+ bool HasListeners() const
+ {
+ return !aListeners.empty();
+ }
+ size_t GetListenerCount() const
+ {
+ return aListeners.size();
+ }
SfxListener* GetListener( sal_uInt16 nNo ) const
- { return (SfxListener*) aListeners[nNo]; }
+ {
+ return aListeners[nNo];
+ }
};
#endif
diff --git a/svl/source/notify/brdcst.cxx b/svl/source/notify/brdcst.cxx
index 7cd424b..62fc638 100644
--- a/svl/source/notify/brdcst.cxx
+++ b/svl/source/notify/brdcst.cxx
@@ -25,10 +25,8 @@
#include <svl/smplhint.hxx>
#include <svl/lstner.hxx>
-SV_DECL_PTRARR( SfxListenerArr_Impl, SfxListener*, 0 )
-
-#define _SFX_BRDCST_CXX
#include <svl/brdcst.hxx>
+#include <algorithm>
//====================================================================
DBG_NAME(SfxBroadcaster)
@@ -44,16 +42,11 @@ void SfxBroadcaster::Broadcast( const SfxHint &rHint )
{
DBG_CHKTHIS(SfxBroadcaster, 0);
- // is anybody to notify?
- if ( aListeners.Count() /*! || aGlobListeners.Count() */ )
+ // notify all registered listeners exactly once
+ for (size_t n = 0; n < aListeners.size(); ++n)
{
- // notify all registered listeners exactly once
- for ( sal_uInt16 n = 0; n < aListeners.Count(); ++n )
- {
- SfxListener* pListener = aListeners[n];
- if ( pListener )
- pListener->Notify( *this, rHint );
- }
+ SfxListener* pListener = aListeners[n];
+ pListener->Notify( *this, rHint );
}
}
@@ -66,11 +59,10 @@ SfxBroadcaster::~SfxBroadcaster()
Broadcast( SfxSimpleHint(SFX_HINT_DYING) );
// remove all still registered listeners
- for ( sal_uInt16 nPos = 0; nPos < aListeners.Count(); ++nPos )
+ for (size_t nPos = 0; nPos < aListeners.size(); ++nPos)
{
SfxListener *pListener = aListeners[nPos];
- if ( pListener )
- pListener->RemoveBroadcaster_Impl(*this);
+ pListener->RemoveBroadcaster_Impl(*this);
}
}
@@ -92,11 +84,10 @@ SfxBroadcaster::SfxBroadcaster( const SfxBroadcaster &rBC )
{
DBG_CTOR(SfxBroadcaster, 0);
- for ( sal_uInt16 n = 0; n < rBC.aListeners.Count(); ++n )
+ for (size_t n = 0; n < rBC.aListeners.size(); ++n)
{
SfxListener *pListener = rBC.aListeners[n];
- if ( pListener )
- pListener->StartListening( *this );
+ pListener->StartListening( *this );
}
}
@@ -104,25 +95,11 @@ SfxBroadcaster::SfxBroadcaster( const SfxBroadcaster &rBC )
// add a new SfxListener to the list
-sal_Bool SfxBroadcaster::AddListener( SfxListener& rListener )
+void SfxBroadcaster::AddListener( SfxListener& rListener )
{
DBG_CHKTHIS(SfxBroadcaster, 0);
- const SfxListener *pListener = &rListener;
- const SfxListener *pNull = 0;
- sal_uInt16 nFreePos = aListeners.GetPos( pNull );
- if ( nFreePos < aListeners.Count() )
- aListeners.GetData()[nFreePos] = pListener;
- else if ( aListeners.Count() < (USHRT_MAX-1) )
- aListeners.Insert( pListener, aListeners.Count() );
- else
- {
- OSL_FAIL( "array overflow" );
- return sal_False;
- }
- DBG_ASSERT( USHRT_MAX != aListeners.GetPos(pListener),
- "AddListener failed" );
- return sal_True;
+ aListeners.push_back(&rListener);
}
//--------------------------------------------------------------------
@@ -140,12 +117,10 @@ void SfxBroadcaster::ListenersGone()
void SfxBroadcaster::Forward(SfxBroadcaster& rBC, const SfxHint& rHint)
{
- const sal_uInt16 nCount = aListeners.Count();
- for ( sal_uInt16 i = 0; i < nCount; ++i )
+ for (size_t i = 0; i < aListeners.size(); ++i)
{
SfxListener *pListener = aListeners[i];
- if ( pListener )
- pListener->Notify( rBC, rHint );
+ pListener->Notify( rBC, rHint );
}
}
@@ -157,23 +132,13 @@ void SfxBroadcaster::RemoveListener( SfxListener& rListener )
{
{DBG_CHKTHIS(SfxBroadcaster, 0);}
const SfxListener *pListener = &rListener;
- sal_uInt16 nPos = aListeners.GetPos(pListener);
- DBG_ASSERT( nPos != USHRT_MAX, "RemoveListener: Listener unknown" );
- aListeners.GetData()[nPos] = 0;
- if ( !HasListeners() )
- ListenersGone();
-}
-//--------------------------------------------------------------------
+ SfxListenerArr_Impl::iterator aIter = std::remove(aListeners.begin(), aListeners.end(), pListener);
+ DBG_ASSERT( aIter != aListeners.end(), "RemoveListener: Listener unknown" );
+ aListeners.erase(aIter, aListeners.end());
-sal_Bool SfxBroadcaster::HasListeners() const
-{
- for ( sal_uInt16 n = 0; n < aListeners.Count(); ++n )
- if ( aListeners.GetObject(n) != 0 )
- return sal_True;
- return sal_False;
+ if ( !HasListeners() )
+ ListenersGone();
}
-//--------------------------------------------------------------------
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/notify/lstner.cxx b/svl/source/notify/lstner.cxx
index 5d3d6b8..0e645ec 100644
--- a/svl/source/notify/lstner.cxx
+++ b/svl/source/notify/lstner.cxx
@@ -85,15 +85,13 @@ sal_Bool SfxListener::StartListening( SfxBroadcaster& rBroadcaster, sal_Bool bPr
if ( !bPreventDups || !IsListening( rBroadcaster ) )
{
- if ( rBroadcaster.AddListener(*this) )
- {
- aBCs.push_back( &rBroadcaster );
-
- DBG_ASSERT( IsListening(rBroadcaster), "StartListening failed" );
- return sal_True;
- }
+ rBroadcaster.AddListener(*this);
+ aBCs.push_back( &rBroadcaster );
+ DBG_ASSERT( IsListening(rBroadcaster), "StartListening failed" );
+ return sal_True;
}
+
return sal_False;
}
More information about the Libreoffice-commits
mailing list