summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-09-03 14:31:18 +0200
committerMichael Stahl <mstahl@redhat.com>2015-09-03 16:32:00 +0200
commit327ab3c03343a52734980b26821e4ca7f6553f2e (patch)
treee093ba8207c68a2ba4e91d0c0ff74917194d65ee /sfx2
parent3fb50fbe2b4951034bbe5b75aef5c88e8cd22382 (diff)
sfx2: remove duplicative ModelCollectionEnumeration
Use the comphelper equivalent. Change-Id: Iba0567948aeec1299191c759da6aa89b4aa014d8
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/notify/globalevents.cxx83
1 files changed, 8 insertions, 75 deletions
diff --git a/sfx2/source/notify/globalevents.cxx b/sfx2/source/notify/globalevents.cxx
index d1f4a474b78f..1caafe174cba 100644
--- a/sfx2/source/notify/globalevents.cxx
+++ b/sfx2/source/notify/globalevents.cxx
@@ -33,6 +33,7 @@
#include <cppuhelper/interfacecontainer.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <rtl/ref.hxx>
+#include <comphelper/enumhelper.hxx>
#include <sfx2/app.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/sfxbasemodel.hxx>
@@ -55,28 +56,6 @@ public:
typedef ::std::vector< css::uno::Reference< css::frame::XModel > > TModelList;
-class ModelCollectionEnumeration : public ModelCollectionMutexBase
- , public ::cppu::WeakImplHelper< css::container::XEnumeration >
-{
-private:
- TModelList m_lModels;
- TModelList::iterator m_pEnumerationIt;
-
-public:
- ModelCollectionEnumeration();
- virtual ~ModelCollectionEnumeration();
- void setModelList(const TModelList& rList);
-
- // css.container.XEnumeration
- virtual sal_Bool SAL_CALL hasMoreElements()
- throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- virtual css::uno::Any SAL_CALL nextElement()
- throw(css::container::NoSuchElementException,
- css::lang::WrappedTargetException ,
- css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
-};
-
//TODO: remove support of obsolete document::XEventBroadcaster/Listener
class SfxGlobalEvents_Impl : public ModelCollectionMutexBase
@@ -178,55 +157,6 @@ private:
TModelList::iterator impl_searchDoc(const css::uno::Reference< css::frame::XModel >& xModel);
};
-ModelCollectionEnumeration::ModelCollectionEnumeration()
- : ModelCollectionMutexBase( )
- , m_pEnumerationIt (m_lModels.begin())
-{
-}
-
-ModelCollectionEnumeration::~ModelCollectionEnumeration()
-{
-}
-
-void ModelCollectionEnumeration::setModelList(const TModelList& rList)
-{
- // SAFE ->
- ::osl::ResettableMutexGuard aLock(m_aLock);
- m_lModels = rList;
- m_pEnumerationIt = m_lModels.begin();
- aLock.clear();
- // <- SAFE
-}
-
-sal_Bool SAL_CALL ModelCollectionEnumeration::hasMoreElements()
- throw(uno::RuntimeException, std::exception)
-{
- // SAFE ->
- ::osl::ResettableMutexGuard aLock(m_aLock);
- return (m_pEnumerationIt != m_lModels.end());
- // <- SAFE
-}
-
-uno::Any SAL_CALL ModelCollectionEnumeration::nextElement()
- throw(container::NoSuchElementException,
- lang::WrappedTargetException ,
- uno::RuntimeException, std::exception )
-{
- // SAFE ->
- ::osl::ResettableMutexGuard aLock(m_aLock);
- if (m_pEnumerationIt == m_lModels.end())
- throw container::NoSuchElementException(
- OUString("End of model enumeration reached."),
- static_cast< container::XEnumeration* >(this));
- uno::Reference< frame::XModel > xModel(*m_pEnumerationIt, uno::UNO_QUERY);
- ++m_pEnumerationIt;
- aLock.clear();
- // <- SAFE
-
- return uno::makeAny(xModel);
-}
-
-
SfxGlobalEvents_Impl::SfxGlobalEvents_Impl( const uno::Reference < uno::XComponentContext >& rxContext)
: ModelCollectionMutexBase( )
, m_xJobExecutorListener( task::theJobExecutor::get( rxContext ), uno::UNO_QUERY_THROW )
@@ -429,11 +359,14 @@ uno::Reference< container::XEnumeration > SAL_CALL SfxGlobalEvents_Impl::createE
{
// SAFE ->
::osl::ResettableMutexGuard aLock(m_aLock);
- ModelCollectionEnumeration* pEnum = new ModelCollectionEnumeration();
- pEnum->setModelList(m_lModels);
+ uno::Sequence<uno::Any> models(m_lModels.size());
+ for (size_t i = 0; i < m_lModels.size(); ++i)
+ {
+ models[i] = uno::makeAny(m_lModels[i]);
+ }
uno::Reference< container::XEnumeration > xEnum(
- static_cast< container::XEnumeration* >(pEnum),
- uno::UNO_QUERY);
+ static_cast<container::XEnumeration*>(
+ new ::comphelper::OAnyEnumeration(models)));
aLock.clear();
// <- SAFE