diff options
author | Noel Grandin <noel@peralex.com> | 2012-05-10 16:04:18 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-05-14 19:49:15 +0200 |
commit | b16ce6e60ffcfea13f025b2cee0011be76f42023 (patch) | |
tree | 00876fd03e8a6c5cd118b0267a8c8032f09b42fe /sw | |
parent | d61282d4a91b441a5859be1ae8ba2abad2aab36e (diff) |
Convert SV_DECL_PTRARR(SwEvtLstnrArray) to std::vector
Change-Id: Ifd81de26432d2e7ceed1a643e3c2009e97f8a5b2
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/unoevtlstnr.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/unoevtlstnr.cxx | 25 | ||||
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 4 | ||||
-rw-r--r-- | sw/source/ui/uno/RefreshListenerContainer.cxx | 4 |
4 files changed, 19 insertions, 17 deletions
diff --git a/sw/inc/unoevtlstnr.hxx b/sw/inc/unoevtlstnr.hxx index 8db97ebe2ec6..c52fe5ee4d51 100644 --- a/sw/inc/unoevtlstnr.hxx +++ b/sw/inc/unoevtlstnr.hxx @@ -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 { diff --git a/sw/source/core/unocore/unoevtlstnr.cxx b/sw/source/core/unocore/unoevtlstnr.cxx index 8e4f79a193bd..a95b31101c9f 100644 --- a/sw/source/core/unocore/unoevtlstnr.cxx +++ b/sw/source/core/unocore/unoevtlstnr.cxx @@ -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: */ diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 83381619f877..f0099aa0a639 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -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 ); diff --git a/sw/source/ui/uno/RefreshListenerContainer.cxx b/sw/source/ui/uno/RefreshListenerContainer.cxx index fb80e90b8443..32d8961b8e6c 100644 --- a/sw/source/ui/uno/RefreshListenerContainer.cxx +++ b/sw/source/ui/uno/RefreshListenerContainer.cxx @@ -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); } } |