[Libreoffice-commits] core.git: chart2/source comphelper/source cppuhelper/qa cppuhelper/source dbaccess/source desktop/source embedserv/source include/cppuhelper sc/source sd/source sfx2/source svx/source toolkit/source ucb/source
Noel Grandin
noelgrandin at gmail.com
Mon Jun 29 00:25:51 PDT 2015
chart2/source/model/main/ChartModel.cxx | 5
comphelper/source/misc/accessibleeventnotifier.cxx | 13 --
cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx | 19 +--
cppuhelper/source/gcc3.map | 6 +
cppuhelper/source/interfacecontainer.cxx | 108 +++++++-----------
dbaccess/source/core/api/RowSet.cxx | 13 --
dbaccess/source/inc/apitools.hxx | 13 --
desktop/source/deployment/registry/dp_backend.cxx | 6 -
embedserv/source/embed/intercept.cxx | 12 --
include/cppuhelper/interfacecontainer.h | 16 ++
sc/source/ui/unoobj/fielduno.cxx | 66 +++--------
sd/source/core/stlsheet.cxx | 11 -
sfx2/source/doc/SfxDocumentMetaData.cxx | 8 -
svx/source/table/tabledesign.cxx | 4
svx/source/unodraw/unoshcol.cxx | 4
toolkit/source/awt/vclxtoolkit.cxx | 24 ++--
toolkit/source/controls/controlmodelcontainerbase.cxx | 10 -
ucb/source/ucp/file/filrset.cxx | 12 +-
18 files changed, 148 insertions(+), 202 deletions(-)
New commits:
commit e57314f61f67b093510c5a8a8f34a62126ba8734
Author: Noel Grandin <noelgrandin at gmail.com>
Date: Sat May 16 11:12:48 2015 +0200
return and use std::vector from OInterfaceContainerHelper
since most of the time we don’t need a heavyweight uno::Sequence.
Adds a new method getElementsAsVector().
Change-Id: I9e72bef0c0c723ffd0dd7d4152db5baec6784a7a
Reviewed-on: https://gerrit.libreoffice.org/15747
Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
Tested-by: Noel Grandin <noelgrandin at gmail.com>
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index e38dfce..31e3786 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -227,10 +227,9 @@ bool ChartModel::impl_isControllerConnected( const uno::Reference< frame::XContr
{
try
{
- uno::Sequence< uno::Reference<uno::XInterface> > aSeq = m_aControllers.getElements();
- for( sal_Int32 nN = aSeq.getLength(); nN--; )
+ for( uno::Reference<uno::XInterface> & rInterface : m_aControllers.getElements() )
{
- if( aSeq[nN] == xController )
+ if( rInterface == xController )
return true;
}
}
diff --git a/comphelper/source/misc/accessibleeventnotifier.cxx b/comphelper/source/misc/accessibleeventnotifier.cxx
index d8a3b36..224c44d 100644
--- a/comphelper/source/misc/accessibleeventnotifier.cxx
+++ b/comphelper/source/misc/accessibleeventnotifier.cxx
@@ -255,7 +255,7 @@ namespace comphelper
void AccessibleEventNotifier::addEvent( const TClientId _nClient, const AccessibleEventObject& _rEvent )
{
- Sequence< Reference< XInterface > > aListeners;
+ std::vector< Reference< XInterface > > aListeners;
// --- <mutex lock> -------------------------------
{
@@ -267,25 +267,22 @@ namespace comphelper
return;
// since we're synchronous, again, we want to notify immediately
- aListeners = aClientPos->second->getElements();
+ aListeners = aClientPos->second->getElementsAsVector();
}
// --- </mutex lock> ------------------------------
- // default handling: loop through all listeners, and notify them
- const Reference< XInterface >* pListeners = aListeners.getConstArray();
- const Reference< XInterface >* pListenersEnd = pListeners + aListeners.getLength();
- while ( pListeners != pListenersEnd )
+ // default handling: loop through all listeners, and notify them
+ for ( const Reference< XInterface > & rL : aListeners )
{
try
{
- static_cast< XAccessibleEventListener* >( pListeners->get() )->notifyEvent( _rEvent );
+ static_cast< XAccessibleEventListener* >( rL.get() )->notifyEvent( _rEvent );
}
catch( const Exception& )
{
// no assertion, because a broken access remote bridge or something like this
// can cause this exception
}
- ++pListeners;
}
}
diff --git a/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx b/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx
index ff7c792..e98aab2 100644
--- a/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx
+++ b/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx
@@ -112,12 +112,11 @@ namespace cppu_ifcontainer
pContainer->addInterface(xRef);
aListeners.push_back(xRef);
}
- Sequence< Reference< XInterface > > aElements;
- aElements = pContainer->getElements();
+ std::vector< Reference< XInterface > > aElements = pContainer->getElementsAsVector();
CPPUNIT_ASSERT_MESSAGE("query contents",
- (int)aElements.getLength() == nTests);
- if ((int)aElements.getLength() == nTests)
+ (int)aElements.size() == nTests);
+ if ((int)aElements.size() == nTests)
{
for (i = 0; i < nTests; i++)
{
@@ -157,8 +156,8 @@ namespace cppu_ifcontainer
pHelper = pContainer->getContainer(pTypes[i]);
CPPUNIT_ASSERT_MESSAGE("no helper", pHelper != NULL);
- Sequence<Reference< XInterface > > aSeq = pHelper->getElements();
- CPPUNIT_ASSERT_MESSAGE("wrong num elements", aSeq.getLength() == 2);
+ std::vector<Reference< XInterface > > aSeq = pHelper->getElementsAsVector();
+ CPPUNIT_ASSERT_MESSAGE("wrong num elements", aSeq.size() == 2);
CPPUNIT_ASSERT_MESSAGE("match", aSeq[0] == xRefs[i*2]);
CPPUNIT_ASSERT_MESSAGE("match", aSeq[1] == xRefs[i*2+1]);
}
@@ -175,8 +174,8 @@ namespace cppu_ifcontainer
pHelper = pContainer->getContainer(pTypes[i]);
CPPUNIT_ASSERT_MESSAGE("no helper", pHelper != NULL);
- Sequence<Reference< XInterface > > aSeq = pHelper->getElements();
- CPPUNIT_ASSERT_MESSAGE("wrong num elements", aSeq.getLength() == 1);
+ std::vector<Reference< XInterface > > aSeq = pHelper->getElementsAsVector();
+ CPPUNIT_ASSERT_MESSAGE("wrong num elements", aSeq.size() == 1);
CPPUNIT_ASSERT_MESSAGE("match", aSeq[0] == xRefs[i*2]);
}
@@ -191,8 +190,8 @@ namespace cppu_ifcontainer
pHelper = pContainer->getContainer(pTypes[i]);
CPPUNIT_ASSERT_MESSAGE("no helper", pHelper != NULL);
- Sequence<Reference< XInterface > > aSeq = pHelper->getElements();
- CPPUNIT_ASSERT_MESSAGE("wrong num elements", aSeq.getLength() == 0);
+ std::vector<Reference< XInterface > > aSeq = pHelper->getElementsAsVector();
+ CPPUNIT_ASSERT_MESSAGE("wrong num elements", aSeq.size() == 0);
}
delete pContainer;
diff --git a/cppuhelper/source/gcc3.map b/cppuhelper/source/gcc3.map
index 12c29834a..1a15f35 100644
--- a/cppuhelper/source/gcc3.map
+++ b/cppuhelper/source/gcc3.map
@@ -430,6 +430,12 @@ global:
_ZN4cppu15supportsServiceEPN3com3sun4star4lang12XServiceInfoERKN3rtl8OUStringE; # cppu::supportsService(com::sun::star::lang::XServiceInfo*, rtl::OUString const&)
} UDK_3.8;
+
+PRIVATE_cppuhelper.1 { # LibreOffice 5.1
+ global:
+ _ZNK4cppu25OInterfaceContainerHelper19getElementsAsVectorEv; # std::vector< Reference<XInterface> > OInterfaceContainerHelper::getElementsAsVector() const
+};
+
# Unique libstdc++ symbols:
GLIBCXX_3.4 {
global:
diff --git a/cppuhelper/source/interfacecontainer.cxx b/cppuhelper/source/interfacecontainer.cxx
index 5bd20a4..93a3836 100644
--- a/cppuhelper/source/interfacecontainer.cxx
+++ b/cppuhelper/source/interfacecontainer.cxx
@@ -28,6 +28,7 @@
#include <memory>
#include <com/sun/star/lang/XEventListener.hpp>
+#include <iterator>
using namespace osl;
@@ -36,32 +37,6 @@ using namespace com::sun::star::lang;
namespace cppu
{
-/**
- * Reallocate the sequence.
- */
-static void realloc( Sequence< Reference< XInterface > > & rSeq, sal_Int32 nNewLen )
-{
- rSeq.realloc( nNewLen );
-}
-
-/**
- * Remove an element from an interface sequence.
- */
-static void sequenceRemoveElementAt( Sequence< Reference< XInterface > > & rSeq, sal_Int32 index )
-{
- sal_Int32 nNewLen = rSeq.getLength() - 1;
-
- Sequence< Reference< XInterface > > aDestSeq( rSeq.getLength() - 1 );
- // getArray on a const sequence is faster
- const Reference< XInterface > * pSource = ((const Sequence< Reference< XInterface > > &)rSeq).getConstArray();
- Reference< XInterface > * pDest = aDestSeq.getArray();
- sal_Int32 i = 0;
- for( ; i < index; i++ )
- pDest[i] = pSource[i];
- for( sal_Int32 j = i ; j < nNewLen; j++ )
- pDest[j] = pSource[j+1];
- rSeq = aDestSeq;
-}
#ifdef _MSC_VER
#pragma warning( disable: 4786 )
@@ -79,7 +54,7 @@ OInterfaceIteratorHelper::OInterfaceIteratorHelper( OInterfaceContainerHelper &
if( bIsList )
{
rCont.bInUse = sal_True;
- nRemain = aData.pAsSequence->getLength();
+ nRemain = aData.pAsVector->size();
}
else if( aData.pAsInterface )
{
@@ -96,7 +71,7 @@ OInterfaceIteratorHelper::~OInterfaceIteratorHelper()
{
MutexGuard aGuard( rCont.rMutex );
// bResetInUse protect the iterator against recursion
- bShared = aData.pAsSequence == rCont.aData.pAsSequence && rCont.bIsList;
+ bShared = aData.pAsVector == rCont.aData.pAsVector && rCont.bIsList;
if( bShared )
{
OSL_ENSURE( rCont.bInUse, "OInterfaceContainerHelper must be in use" );
@@ -108,7 +83,7 @@ OInterfaceIteratorHelper::~OInterfaceIteratorHelper()
{
if( bIsList )
// Sequence owned by the iterator
- delete aData.pAsSequence;
+ delete aData.pAsVector;
else if( aData.pAsInterface )
// Interface is acquired by the iterator
aData.pAsInterface->release();
@@ -121,8 +96,7 @@ XInterface * OInterfaceIteratorHelper::next()
{
nRemain--;
if( bIsList )
- // typecase to const,so the getArray method is faster
- return aData.pAsSequence->getConstArray()[nRemain].get();
+ return (*aData.pAsVector)[nRemain].get();
else if( aData.pAsInterface )
return aData.pAsInterface;
}
@@ -135,8 +109,8 @@ void OInterfaceIteratorHelper::remove()
if( bIsList )
{
OSL_ASSERT( nRemain >= 0 &&
- nRemain < aData.pAsSequence->getLength() );
- XInterface * p = aData.pAsSequence->getConstArray()[nRemain].get();
+ nRemain < static_cast<sal_Int32>(aData.pAsVector->size()) );
+ XInterface * p = (*aData.pAsVector)[nRemain].get();
rCont.removeInterface( * reinterpret_cast< const Reference< XInterface > * >( &p ) );
}
else
@@ -157,7 +131,7 @@ OInterfaceContainerHelper::~OInterfaceContainerHelper()
{
OSL_ENSURE( !bInUse, "~OInterfaceContainerHelper but is in use" );
if( bIsList )
- delete aData.pAsSequence;
+ delete aData.pAsVector;
else if( aData.pAsInterface )
aData.pAsInterface->release();
}
@@ -166,17 +140,30 @@ sal_Int32 OInterfaceContainerHelper::getLength() const
{
MutexGuard aGuard( rMutex );
if( bIsList )
- return aData.pAsSequence->getLength();
+ return aData.pAsVector->size();
else if( aData.pAsInterface )
return 1;
return 0;
}
-Sequence< Reference<XInterface> > OInterfaceContainerHelper::getElements() const
+std::vector< Reference<XInterface> > OInterfaceContainerHelper::getElementsAsVector() const
+{
+ MutexGuard aGuard( rMutex );
+ if( bIsList )
+ return *aData.pAsVector;
+ else if( aData.pAsInterface )
+ {
+ Reference<XInterface> x( aData.pAsInterface );
+ return { x };
+ }
+ return std::vector< Reference< XInterface > >();
+}
+
+css::uno::Sequence< Reference<XInterface> > OInterfaceContainerHelper::getElements() const
{
MutexGuard aGuard( rMutex );
if( bIsList )
- return *aData.pAsSequence;
+ return css::uno::Sequence< Reference<XInterface> >( aData.pAsVector->data(), static_cast<sal_Int32>(aData.pAsVector->size()) );
else if( aData.pAsInterface )
{
Reference<XInterface> x( aData.pAsInterface );
@@ -193,7 +180,7 @@ void OInterfaceContainerHelper::copyAndResetInUse()
// this should be the worst case. If a iterator is active
// and a new Listener is added.
if( bIsList )
- aData.pAsSequence = new Sequence< Reference< XInterface > >( *aData.pAsSequence );
+ aData.pAsVector = new std::vector< Reference< XInterface > >( *aData.pAsVector );
else if( aData.pAsInterface )
aData.pAsInterface->acquire();
@@ -210,19 +197,16 @@ sal_Int32 OInterfaceContainerHelper::addInterface( const Reference<XInterface> &
if( bIsList )
{
- sal_Int32 nLen = aData.pAsSequence->getLength();
- realloc( *aData.pAsSequence, nLen +1 );
- aData.pAsSequence->getArray()[ nLen ] = rListener;
- return nLen +1;
+ aData.pAsVector->push_back( rListener );
+ return aData.pAsVector->size();
}
else if( aData.pAsInterface )
{
- Sequence< Reference< XInterface > > * pSeq = new Sequence< Reference< XInterface > >( 2 );
- Reference<XInterface> * pArray = pSeq->getArray();
- pArray[0] = aData.pAsInterface;
- pArray[1] = rListener;
+ std::vector< Reference< XInterface > > * pSeq = new std::vector< Reference< XInterface > >( 2 );
+ (*pSeq)[0] = aData.pAsInterface;
+ (*pSeq)[1] = rListener;
aData.pAsInterface->release();
- aData.pAsSequence = pSeq;
+ aData.pAsVector = pSeq;
bIsList = sal_True;
return 2;
}
@@ -244,43 +228,41 @@ sal_Int32 OInterfaceContainerHelper::removeInterface( const Reference<XInterface
if( bIsList )
{
- const Reference<XInterface> * pL = aData.pAsSequence->getConstArray();
- sal_Int32 nLen = aData.pAsSequence->getLength();
- sal_Int32 i;
- for( i = 0; i < nLen; i++ )
+ // It is not valid to compare the pointer directly, but it's faster.
+ bool bFound = false;
+ for( auto it = std::begin(*aData.pAsVector); it != std::end(*aData.pAsVector); ++it )
{
- // It is not valid to compare the pointer directly, but it's faster.
- if( pL[i].get() == rListener.get() )
+ if( (*it).get() == rListener.get() )
{
- sequenceRemoveElementAt( *aData.pAsSequence, i );
+ aData.pAsVector->erase(it);
+ bFound = true;
break;
}
}
-
- if( i == nLen )
+ if (!bFound)
{
// interface not found, use the correct compare method
- for( i = 0; i < nLen; i++ )
+ for( auto it = std::begin(*aData.pAsVector); it != std::end(*aData.pAsVector); ++it )
{
- if( pL[i] == rListener )
+ if( *it == rListener )
{
- sequenceRemoveElementAt(*aData.pAsSequence, i );
+ aData.pAsVector->erase(it);
break;
}
}
}
- if( aData.pAsSequence->getLength() == 1 )
+ if( aData.pAsVector->size() == 1 )
{
- XInterface * p = aData.pAsSequence->getConstArray()[0].get();
+ XInterface * p = (*aData.pAsVector)[0].get();
p->acquire();
- delete aData.pAsSequence;
+ delete aData.pAsVector;
aData.pAsInterface = p;
bIsList = sal_False;
return 1;
}
else
- return aData.pAsSequence->getLength();
+ return aData.pAsVector->size();
}
else if( aData.pAsInterface && Reference<XInterface>( aData.pAsInterface ) == rListener )
{
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index f1723a9..8220327 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -104,22 +104,15 @@ com_sun_star_comp_dba_ORowSet_get_implementation(css::uno::XComponentContext* co
}
#define NOTIFY_LISTERNERS_CHECK(_rListeners,T,method) \
- Sequence< Reference< XInterface > > aListenerSeq = _rListeners.getElements(); \
- \
- const Reference< XInterface >* pxIntBegin = aListenerSeq.getConstArray(); \
- const Reference< XInterface >* pxInt = pxIntBegin + aListenerSeq.getLength(); \
+ std::vector< Reference< XInterface > > aListenerSeq = _rListeners.getElementsAsVector(); \
\
_rGuard.clear(); \
bool bCheck = true; \
- while( pxInt > pxIntBegin && bCheck ) \
+ for( auto iter = aListenerSeq.rbegin(); iter != aListenerSeq.rend() && bCheck; ++iter ) \
{ \
try \
{ \
- while( pxInt > pxIntBegin && bCheck ) \
- { \
- --pxInt; \
- bCheck = static_cast< T* >( pxInt->get() )->method(aEvt); \
- } \
+ bCheck = static_cast< T* >( (*iter).get() )->method(aEvt); \
} \
catch( RuntimeException& ) \
{ \
diff --git a/dbaccess/source/inc/apitools.hxx b/dbaccess/source/inc/apitools.hxx
index 6672420..583fff3 100644
--- a/dbaccess/source/inc/apitools.hxx
+++ b/dbaccess/source/inc/apitools.hxx
@@ -328,21 +328,14 @@ public:
return new ::cppu::OPropertyArrayHelper(aDescriptor);
#define NOTIFY_LISTERNERS(_rListeners,T,method) \
- Sequence< Reference< XInterface > > aListenerSeq = _rListeners.getElements(); \
- \
- const Reference< XInterface >* pxIntBegin = aListenerSeq.getConstArray(); \
- const Reference< XInterface >* pxInt = pxIntBegin + aListenerSeq.getLength(); \
+ std::vector< Reference< XInterface > > aListenerSeq = _rListeners.getElementsAsVector(); \
\
_rGuard.clear(); \
- while( pxInt > pxIntBegin ) \
+ for( auto iter = aListenerSeq.rbegin(); iter != aListenerSeq.rend(); ++iter ) \
{ \
try \
{ \
- while( pxInt > pxIntBegin ) \
- { \
- --pxInt; \
- static_cast< T* >( pxInt->get() )->method(aEvt); \
- } \
+ static_cast< T* >( (*iter).get() )->method(aEvt); \
} \
catch( RuntimeException& ) \
{ \
diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx
index 720e8ab..6963e86 100644
--- a/desktop/source/deployment/registry/dp_backend.cxx
+++ b/desktop/source/deployment/registry/dp_backend.cxx
@@ -596,10 +596,10 @@ void Package::fireModified()
::cppu::OInterfaceContainerHelper * container = rBHelper.getContainer(
cppu::UnoType<util::XModifyListener>::get() );
if (container != 0) {
- Sequence< Reference<XInterface> > elements(
- container->getElements() );
+ std::vector< Reference<XInterface> > elements(
+ container->getElementsAsVector() );
lang::EventObject evt( static_cast<OWeakObject *>(this) );
- for ( sal_Int32 pos = 0; pos < elements.getLength(); ++pos )
+ for ( sal_Int32 pos = 0; pos < (sal_Int32)elements.size(); ++pos )
{
Reference<util::XModifyListener> xListener(
elements[ pos ], UNO_QUERY );
diff --git a/embedserv/source/embed/intercept.cxx b/embedserv/source/embed/intercept.cxx
index 20dcfd1..e335d12 100644
--- a/embedserv/source/embed/intercept.cxx
+++ b/embedserv/source/embed/intercept.cxx
@@ -218,10 +218,10 @@ void Interceptor::generateFeatureStateEvent()
cppu::OInterfaceContainerHelper* pICH =
m_pStatCL->getContainer(m_aInterceptedURL[i]);
- uno::Sequence<uno::Reference<uno::XInterface> > aSeq;
+ std::vector<uno::Reference<uno::XInterface> > aSeq;
if(pICH)
- aSeq = pICH->getElements();
- if(!aSeq.getLength())
+ aSeq = pICH->getElementsAsVector();
+ if(aSeq.empty())
continue;
frame::FeatureStateEvent aStateEvent;
@@ -249,13 +249,11 @@ void Interceptor::generateFeatureStateEvent()
}
- for(sal_Int32 k = 0; k < aSeq.getLength(); ++k)
+ for(uno::Reference<uno::XInterface> & x : aSeq)
{
- uno::Reference<frame::XStatusListener>
- Control(aSeq[k],uno::UNO_QUERY);
+ uno::Reference<frame::XStatusListener> Control(x,uno::UNO_QUERY);
if(Control.is())
Control->statusChanged(aStateEvent);
-
}
}
}
diff --git a/include/cppuhelper/interfacecontainer.h b/include/cppuhelper/interfacecontainer.h
index a29eba0..74338f6 100644
--- a/include/cppuhelper/interfacecontainer.h
+++ b/include/cppuhelper/interfacecontainer.h
@@ -47,7 +47,7 @@ namespace detail {
*/
union element_alias
{
- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > *pAsSequence;
+ std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > *pAsVector;
::com::sun::star::uno::XInterface * pAsInterface;
element_alias() : pAsInterface(0) {}
};
@@ -155,10 +155,18 @@ public:
*/
sal_Int32 SAL_CALL getLength() const;
+#ifdef LIBO_INTERNAL_ONLY
/**
Return all interfaces added to this container.
+ @since LibreOffice 5.1
+ Not exposed because std::vector is problematic for an ABI
**/
- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > SAL_CALL getElements() const;
+ std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > SAL_CALL getElementsAsVector() const;
+#endif
+ /**
+ Return all interfaces added to this container.
+ **/
+ css::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > SAL_CALL getElements() const;
/** Inserts an element into the container. The position is not specified, thus it is not
specified in which order events are fired.
@@ -236,14 +244,14 @@ public:
private:
friend class OInterfaceIteratorHelper;
/**
- bIsList == TRUE -> aData.pAsSequence of type Sequence< XInterfaceSequence >,
+ bIsList == TRUE -> aData.pAsVector of type std::vector< XInterface >,
otherwise aData.pAsInterface == of type (XEventListener *)
*/
detail::element_alias aData;
::osl::Mutex & rMutex;
/** TRUE -> used by an iterator. */
sal_Bool bInUse;
- /** TRUE -> aData.pAsSequence is of type Sequence< XInterfaceSequence >. */
+ /** TRUE -> aData.pAsVector is of type std::vector< XInterface >. */
sal_Bool bIsList;
OInterfaceContainerHelper( const OInterfaceContainerHelper & )
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index 94c29dc..b5ec70b 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -410,32 +410,19 @@ void SAL_CALL ScCellFieldsObj::refresh( )
if (mpRefreshListeners)
{
// Call all listeners.
- uno::Sequence< uno::Reference< uno::XInterface > > aListeners(mpRefreshListeners->getElements());
- sal_uInt32 nLength(aListeners.getLength());
- if (nLength)
+ std::vector< uno::Reference< uno::XInterface > > aListeners(mpRefreshListeners->getElementsAsVector());
+ if (!aListeners.empty())
{
- const uno::Reference< uno::XInterface >* pInterfaces = aListeners.getConstArray();
- if (pInterfaces)
+ lang::EventObject aEvent;
+ aEvent.Source.set(uno::Reference< util::XRefreshable >(this));
+ for (auto & x : aListeners)
{
- lang::EventObject aEvent;
- aEvent.Source.set(uno::Reference< util::XRefreshable >(this));
- sal_uInt32 i(0);
- while (i < nLength)
+ try
+ {
+ static_cast< util::XRefreshListener* >(x.get())->refreshed(aEvent);
+ }
+ catch(uno::RuntimeException&)
{
- try
- {
- while(i < nLength)
- {
- static_cast< util::XRefreshListener* >(pInterfaces->get())->refreshed(aEvent);
- ++pInterfaces;
- ++i;
- }
- }
- catch(uno::RuntimeException&)
- {
- ++pInterfaces;
- ++i;
- }
}
}
}
@@ -590,32 +577,19 @@ void SAL_CALL ScHeaderFieldsObj::refresh( )
if (mpRefreshListeners)
{
// Call all listeners.
- uno::Sequence< uno::Reference< uno::XInterface > > aListeners(mpRefreshListeners->getElements());
- sal_uInt32 nLength(aListeners.getLength());
- if (nLength)
+ std::vector< uno::Reference< uno::XInterface > > aListeners(mpRefreshListeners->getElementsAsVector());
+ if (!aListeners.empty())
{
- const uno::Reference< uno::XInterface >* pInterfaces = aListeners.getConstArray();
- if (pInterfaces)
+ lang::EventObject aEvent;
+ aEvent.Source.set(uno::Reference< util::XRefreshable >(this));
+ for (auto & x : aListeners)
{
- lang::EventObject aEvent;
- aEvent.Source.set(uno::Reference< util::XRefreshable >(this));
- sal_uInt32 i(0);
- while (i < nLength)
+ try
+ {
+ static_cast< util::XRefreshListener* >(x.get())->refreshed(aEvent);
+ }
+ catch(uno::RuntimeException&)
{
- try
- {
- while(i < nLength)
- {
- static_cast< util::XRefreshListener* >(pInterfaces->get())->refreshed(aEvent);
- ++pInterfaces;
- ++i;
- }
- }
- catch(uno::RuntimeException&)
- {
- ++pInterfaces;
- ++i;
- }
}
}
}
diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx
index 4ed6289..86d9ba3 100644
--- a/sd/source/core/stlsheet.cxx
+++ b/sd/source/core/stlsheet.cxx
@@ -345,14 +345,13 @@ bool SdStyleSheet::IsUsed() const
OInterfaceContainerHelper * pContainer = mrBHelper.getContainer( cppu::UnoType<XModifyListener>::get() );
if( pContainer )
{
- Sequence< Reference< XInterface > > aModifyListeners( pContainer->getElements() );
- Reference< XInterface > *p = aModifyListeners.getArray();
- sal_Int32 nCount = aModifyListeners.getLength();
- while( nCount-- && !bResult )
+ for( auto & x : pContainer->getElements() )
{
- Reference< XStyle > xStyle( *p++, UNO_QUERY );
- if( xStyle.is() )
+ Reference< XStyle > xStyle( x, UNO_QUERY );
+ if( xStyle.is() ) {
bResult = xStyle->isInUse();
+ break;
+ }
}
}
}
diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx
index 54b4a90..a8b567f 100644
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -2282,11 +2282,11 @@ void SfxDocumentMetaData::createUserDefined()
m_xUserDefined, css::uno::UNO_QUERY);
if (xMB.is())
{
- const css::uno::Sequence<css::uno::Reference<css::uno::XInterface> >
- listeners(m_NotifyListeners.getElements());
- for (css::uno::Reference< css::uno::XInterface > const * iter = listeners.begin(); iter != listeners.end(); ++iter) {
+ const std::vector<css::uno::Reference<css::uno::XInterface> >
+ listeners(m_NotifyListeners.getElementsAsVector());
+ for (css::uno::Reference< css::uno::XInterface > const & iter : listeners) {
xMB->addModifyListener(
- css::uno::Reference< css::util::XModifyListener >(*iter,
+ css::uno::Reference< css::util::XModifyListener >(iter,
css::uno::UNO_QUERY));
}
}
diff --git a/svx/source/table/tabledesign.cxx b/svx/source/table/tabledesign.cxx
index 66c0544..2f0dbc9 100644
--- a/svx/source/table/tabledesign.cxx
+++ b/svx/source/table/tabledesign.cxx
@@ -235,10 +235,10 @@ sal_Bool SAL_CALL TableDesignStyle::isInUse() throw (RuntimeException, std::exce
OInterfaceContainerHelper * pContainer = rBHelper.getContainer( cppu::UnoType<XModifyListener>::get() );
if( pContainer )
{
- Sequence< Reference< XInterface > > aListener( pContainer->getElements() );
+ std::vector< Reference< XInterface > > aListener( pContainer->getElementsAsVector() );
aGuard.clear();
- sal_Int32 nIndex = aListener.getLength();
+ sal_Int32 nIndex = aListener.size();
while( --nIndex >= 0 )
{
TableDesignUser* pUser = dynamic_cast< TableDesignUser* >( aListener[nIndex].get() );
diff --git a/svx/source/unodraw/unoshcol.cxx b/svx/source/unodraw/unoshcol.cxx
index 20133ca..1a94ecf 100644
--- a/svx/source/unodraw/unoshcol.cxx
+++ b/svx/source/unodraw/unoshcol.cxx
@@ -229,10 +229,10 @@ uno::Any SAL_CALL SvxShapeCollection::getByIndex( sal_Int32 Index )
if( Index < 0 || Index >= getCount() )
throw lang::IndexOutOfBoundsException();
- uno::Sequence< Reference< uno::XInterface> > xElements( maShapeContainer.getElements() );
+ std::vector< Reference< uno::XInterface> > xElements( maShapeContainer.getElementsAsVector() );
- return uno::makeAny( Reference< drawing::XShape>(static_cast< drawing::XShape* >( xElements.getArray()[Index].get())) );
+ return uno::makeAny( Reference< drawing::XShape>(static_cast< drawing::XShape* >( xElements[Index].get())) );
}
// XElementAccess
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx
index cf14157..ce25b2b 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -1757,13 +1757,13 @@ void VCLXToolkit::callTopWindowListeners(
= static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow();
if (pWindow->IsTopWindow())
{
- css::uno::Sequence< css::uno::Reference< css::uno::XInterface > >
- aListeners(m_aTopWindowListeners.getElements());
- if (aListeners.hasElements())
+ std::vector< css::uno::Reference< css::uno::XInterface > >
+ aListeners(m_aTopWindowListeners.getElementsAsVector());
+ if (!aListeners.empty())
{
css::lang::EventObject aAwtEvent(
static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()));
- for (::sal_Int32 i = 0; i < aListeners.getLength(); ++i)
+ for (::sal_Int32 i = 0; i < (sal_Int32)aListeners.size(); ++i)
{
css::uno::Reference< css::awt::XTopWindowListener >
xListener(aListeners[i], css::uno::UNO_QUERY);
@@ -1786,10 +1786,10 @@ void VCLXToolkit::callTopWindowListeners(
long VCLXToolkit::callKeyHandlers(::VclSimpleEvent const * pEvent,
bool bPressed)
{
- css::uno::Sequence< css::uno::Reference< css::uno::XInterface > >
- aHandlers(m_aKeyHandlers.getElements());
+ std::vector< css::uno::Reference< css::uno::XInterface > >
+ aHandlers(m_aKeyHandlers.getElementsAsVector());
- if (aHandlers.hasElements())
+ if (!aHandlers.empty())
{
vcl::Window * pWindow = static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow();
@@ -1809,7 +1809,7 @@ long VCLXToolkit::callKeyHandlers(::VclSimpleEvent const * pEvent,
pKeyEvent->GetKeyCode().GetCode(), pKeyEvent->GetCharCode(),
sal::static_int_cast< sal_Int16 >(
pKeyEvent->GetKeyCode().GetFunction()));
- for (::sal_Int32 i = 0; i < aHandlers.getLength(); ++i)
+ for (::sal_Int32 i = 0; i < (sal_Int32)aHandlers.size(); ++i)
{
css::uno::Reference< css::awt::XKeyHandler > xHandler(
aHandlers[i], css::uno::UNO_QUERY);
@@ -1838,9 +1838,9 @@ void VCLXToolkit::callFocusListeners(::VclSimpleEvent const * pEvent,
= static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow();
if (pWindow->IsTopWindow())
{
- css::uno::Sequence< css::uno::Reference< css::uno::XInterface > >
- aListeners(m_aFocusListeners.getElements());
- if (aListeners.hasElements())
+ std::vector< css::uno::Reference< css::uno::XInterface > >
+ aListeners(m_aFocusListeners.getElementsAsVector());
+ if (!aListeners.empty())
{
// Ignore the interior of compound controls when determining the
// window that gets the focus next (see implementation in
@@ -1859,7 +1859,7 @@ void VCLXToolkit::callFocusListeners(::VclSimpleEvent const * pEvent,
static_cast< css::awt::XWindow * >(pWindow->GetWindowPeer()),
static_cast<sal_Int16>(pWindow->GetGetFocusFlags()),
xNext, false);
- for (::sal_Int32 i = 0; i < aListeners.getLength(); ++i)
+ for (size_t i = 0; i < aListeners.size(); ++i)
{
css::uno::Reference< css::awt::XFocusListener > xListener(
aListeners[i], css::uno::UNO_QUERY);
diff --git a/toolkit/source/controls/controlmodelcontainerbase.cxx b/toolkit/source/controls/controlmodelcontainerbase.cxx
index a7eff04..b064aff 100644
--- a/toolkit/source/controls/controlmodelcontainerbase.cxx
+++ b/toolkit/source/controls/controlmodelcontainerbase.cxx
@@ -916,13 +916,11 @@ void ControlModelContainerBase::implNotifyTabModelChange( const OUString& _rAcce
aEvent.Changes[ 0 ].Accessor <<= _rAccessor;
- Sequence< Reference< XInterface > > aChangeListeners( maChangeListeners.getElements() );
- const Reference< XInterface >* pListener = aChangeListeners.getConstArray();
- const Reference< XInterface >* pListenerEnd = aChangeListeners.getConstArray() + aChangeListeners.getLength();
- for ( ; pListener != pListenerEnd; ++pListener )
+ std::vector< Reference< XInterface > > aChangeListeners( maChangeListeners.getElementsAsVector() );
+ for ( Reference< XInterface > & rListener : aChangeListeners )
{
- if ( pListener->is() )
- static_cast< XChangesListener* >( pListener->get() )->changesOccurred( aEvent );
+ if ( rListener.is() )
+ static_cast< XChangesListener* >( rListener.get() )->changesOccurred( aEvent );
}
}
diff --git a/ucb/source/ucp/file/filrset.cxx b/ucb/source/ucp/file/filrset.cxx
index e4d8159..820fda5 100644
--- a/ucb/source/ucp/file/filrset.cxx
+++ b/ucb/source/ucp/file/filrset.cxx
@@ -162,11 +162,11 @@ XResultSet_impl::dispose()
void XResultSet_impl::rowCountChanged()
{
sal_Int32 aOldValue,aNewValue;
- uno::Sequence< uno::Reference< uno::XInterface > > seq;
+ std::vector< uno::Reference< uno::XInterface > > seq;
{
osl::MutexGuard aGuard( m_aMutex );
if( m_pRowCountListeners )
- seq = m_pRowCountListeners->getElements();
+ seq = m_pRowCountListeners->getElementsAsVector();
aNewValue = m_aItems.size();
aOldValue = aNewValue-1;
}
@@ -176,7 +176,7 @@ void XResultSet_impl::rowCountChanged()
aEv.PropertyHandle = -1;
aEv.OldValue <<= aOldValue;
aEv.NewValue <<= aNewValue;
- for( sal_Int32 i = 0; i < seq.getLength(); ++i )
+ for( sal_Int32 i = 0; i < (sal_Int32)seq.size(); ++i )
{
uno::Reference< beans::XPropertyChangeListener > listener(
seq[i], uno::UNO_QUERY );
@@ -188,11 +188,11 @@ void XResultSet_impl::rowCountChanged()
void XResultSet_impl::isFinalChanged()
{
- uno::Sequence< uno::Reference< XInterface > > seq;
+ std::vector< uno::Reference< XInterface > > seq;
{
osl::MutexGuard aGuard( m_aMutex );
if( m_pIsFinalListeners )
- seq = m_pIsFinalListeners->getElements();
+ seq = m_pIsFinalListeners->getElementsAsVector();
m_bRowCountFinal = true;
}
beans::PropertyChangeEvent aEv;
@@ -203,7 +203,7 @@ void XResultSet_impl::isFinalChanged()
bool tval = true;
aEv.OldValue <<= fval;
aEv.NewValue <<= tval;
- for( sal_Int32 i = 0; i < seq.getLength(); ++i )
+ for( sal_Int32 i = 0; i < (sal_Int32)seq.size(); ++i )
{
uno::Reference< beans::XPropertyChangeListener > listener(
seq[i], uno::UNO_QUERY );
More information about the Libreoffice-commits
mailing list