Convert SV_DECL_PTRARR(SwEvtLstnrArray) to std::vector

Change-Id: Ifd81de26432d2e7ceed1a643e3c2009e97f8a5b2
This commit is contained in:
Noel Grandin
2012-05-10 16:04:18 +02:00
committed by Michael Stahl
parent d61282d4a9
commit b16ce6e60f
4 changed files with 19 additions and 17 deletions

View File

@@ -30,6 +30,7 @@
#include <svl/svarray.hxx>
#include <com/sun/star/uno/Reference.h>
#include <vector>
namespace com{namespace sun{namespace star{
namespace lang
@@ -41,7 +42,7 @@ namespace com{namespace sun{namespace star{
// Managing the EventListeners.
typedef ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > * XEventListenerPtr;
SV_DECL_PTRARR(SwEvtLstnrArray, XEventListenerPtr, 4)
typedef std::vector<XEventListenerPtr> SwEvtLstnrArray;
class SwEventListenerContainer
{

View File

@@ -37,8 +37,6 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
SV_IMPL_PTRARR(SwEvtLstnrArray, XEventListenerPtr);
SwEventListenerContainer::SwEventListenerContainer( uno::XInterface* _pxParent) :
pListenerArr(0),
pxParent(_pxParent)
@@ -47,9 +45,11 @@ SwEventListenerContainer::SwEventListenerContainer( uno::XInterface* _pxParent)
SwEventListenerContainer::~SwEventListenerContainer()
{
if(pListenerArr && pListenerArr->Count())
if(pListenerArr && !pListenerArr->empty())
{
pListenerArr->DeleteAndDestroy(0, pListenerArr->Count());
for(SwEvtLstnrArray::iterator it = pListenerArr->begin(); it != pListenerArr->end(); ++it)
delete *it;
pListenerArr->clear();
}
delete pListenerArr;
}
@@ -60,7 +60,7 @@ void SwEventListenerContainer::AddListener(const uno::Reference< lang::XEvent
pListenerArr = new SwEvtLstnrArray;
uno::Reference< lang::XEventListener > * pInsert = new uno::Reference< lang::XEventListener > ;
*pInsert = rxListener;
pListenerArr->Insert(pInsert, pListenerArr->Count());
pListenerArr->push_back(pInsert);
}
sal_Bool SwEventListenerContainer::RemoveListener(const uno::Reference< lang::XEventListener > & rxListener)
@@ -70,13 +70,13 @@ sal_Bool SwEventListenerContainer::RemoveListener(const uno::Reference< lang:
else
{
lang::XEventListener* pLeft = rxListener.get();
for(sal_uInt16 i = 0; i < pListenerArr->Count(); i++)
for(sal_uInt16 i = 0; i < pListenerArr->size(); i++)
{
XEventListenerPtr pElem = pListenerArr->GetObject(i);
lang::XEventListener* pRight = pElem->get();
XEventListenerPtr pElem = (*pListenerArr)[i];
lang::XEventListener* pRight = pElem->get();
if(pLeft == pRight)
{
pListenerArr->Remove(i);
pListenerArr->erase(pListenerArr->begin() + i);
delete pElem;
return sal_True;
}
@@ -91,12 +91,13 @@ void SwEventListenerContainer::Disposing()
return;
lang::EventObject aObj(pxParent);
for(sal_uInt16 i = 0; i < pListenerArr->Count(); i++)
for(sal_uInt16 i = 0; i < pListenerArr->size(); i++)
{
XEventListenerPtr pElem = pListenerArr->GetObject(i);
XEventListenerPtr pElem = (*pListenerArr)[i];
(*pElem)->disposing(aObj);
delete pElem;
}
pListenerArr->DeleteAndDestroy(0, pListenerArr->Count());
pListenerArr->clear();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -5020,11 +5020,11 @@ void SwChartEventListenerContainer::ChartDataChanged()
aEvent.StartRow = 0;
aEvent.EndRow = 1;
for(sal_uInt16 i = 0; i < pListenerArr->Count(); i++)
for(sal_uInt16 i = 0; i < pListenerArr->size(); i++)
{
try
{
XEventListenerPtr pElem = pListenerArr->GetObject(i);
XEventListenerPtr pElem = (*pListenerArr)[i];
uno::Reference<lang::XEventListener> xEventListener = *pElem;
uno::Reference<chart::XChartDataChangeEventListener> xChartEventListener = (chart::XChartDataChangeEventListener*)(*pElem).get();
xChartEventListener->chartDataChanged( aEvent );

View File

@@ -49,9 +49,9 @@ void SwRefreshListenerContainer::Refreshed ()
return;
lang::EventObject aObj(pxParent);
for(sal_uInt16 i = 0, nEnd = pListenerArr->Count(); i < nEnd ; i++)
for(sal_uInt16 i = 0, nEnd = pListenerArr->size(); i < nEnd ; i++)
{
Reference < XRefreshListener > xRefreshListener = Reference < XRefreshListener > ( *pListenerArr->GetObject(i), UNO_QUERY );
Reference < XRefreshListener > xRefreshListener = Reference < XRefreshListener > ( *(*pListenerArr)[i], UNO_QUERY );
xRefreshListener->refreshed(aObj);
}
}