From 3fb50fbe2b4951034bbe5b75aef5c88e8cd22382 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Thu, 3 Sep 2015 13:54:47 +0200 Subject: [PATCH] basic: remove over-engineered XEnumeration service ... that was causing duplicate WeakImplHelper symbols now. Change-Id: Ibbf84a2059f30bfeb5c265adcafb4b56d2534dc8 --- basic/source/basmgr/vbahelper.cxx | 55 +++++++++---------------------- include/basic/vbahelper.hxx | 1 - 2 files changed, 15 insertions(+), 41 deletions(-) diff --git a/basic/source/basmgr/vbahelper.cxx b/basic/source/basmgr/vbahelper.cxx index 09e07def3a9c..d62c79e3004b 100644 --- a/basic/source/basmgr/vbahelper.cxx +++ b/basic/source/basmgr/vbahelper.cxx @@ -28,7 +28,6 @@ #include #include #include -#include #include namespace basic { @@ -48,24 +47,12 @@ uno::Reference< frame::XModuleManager2 > lclCreateModuleManager() return frame::ModuleManager::create(xContext); } +typedef ::std::vector> ModelVector; - -/** Implementation of an enumeration of all open documents of the same type. - */ -class DocumentsEnumeration : public ::cppu::WeakImplHelper< container::XEnumeration > -{ -public: - explicit DocumentsEnumeration( const uno::Reference< frame::XModel >& rxModel ); - virtual sal_Bool SAL_CALL hasMoreElements() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE; - virtual uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE; -private: - typedef ::std::vector< uno::Reference< frame::XModel > > ModelVector; - ModelVector maModels; - ModelVector::iterator maModelIt; -}; - -DocumentsEnumeration::DocumentsEnumeration( const uno::Reference< frame::XModel >& rxModel ) +static ModelVector CreateDocumentsEnumeration( + const uno::Reference< frame::XModel >& rxModel) { + ModelVector models; try { uno::Reference< frame::XModuleManager2 > xModuleManager( lclCreateModuleManager() ); @@ -77,29 +64,15 @@ DocumentsEnumeration::DocumentsEnumeration( const uno::Reference< frame::XModel { uno::Reference< frame::XModel > xCurrModel( xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); if( xModuleManager->identify( xCurrModel ) == aIdentifier ) - maModels.push_back( xCurrModel ); + models.push_back( xCurrModel ); } } catch(const uno::Exception& ) { } - maModelIt = maModels.begin(); + return models; } -sal_Bool SAL_CALL DocumentsEnumeration::hasMoreElements() throw (uno::RuntimeException, std::exception) -{ - return maModelIt != maModels.end(); -} - -uno::Any SAL_CALL DocumentsEnumeration::nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) -{ - if( maModelIt == maModels.end() ) - throw container::NoSuchElementException(); - return uno::Any( *maModelIt++ ); -} - - - /** Locks or unlocks the controllers of the specified document model. */ void lclLockControllers( const uno::Reference< frame::XModel >& rxModel, bool bLockControllers ) @@ -156,15 +129,17 @@ typedef void (*ModifyDocumentFunc)( const uno::Reference< frame::XModel >&, bool */ void lclIterateDocuments( ModifyDocumentFunc pModifyDocumentFunc, const uno::Reference< frame::XModel >& rxModel, bool bModificator ) { - uno::Reference< container::XEnumeration > xDocumentsEnum( new DocumentsEnumeration( rxModel ) ); + ModelVector models(CreateDocumentsEnumeration(rxModel)); // iterate over all open documents - while( xDocumentsEnum->hasMoreElements() ) try - { - uno::Reference< frame::XModel > xCurrModel( xDocumentsEnum->nextElement(), uno::UNO_QUERY_THROW ); - pModifyDocumentFunc( xCurrModel, bModificator ); - } - catch(const uno::Exception& ) + for (auto const& xCurrModel : models) { + try + { + pModifyDocumentFunc(xCurrModel, bModificator); + } + catch (const uno::Exception&) + { + } } } diff --git a/include/basic/vbahelper.hxx b/include/basic/vbahelper.hxx index ee2dea3a9653..a4572fc96f30 100644 --- a/include/basic/vbahelper.hxx +++ b/include/basic/vbahelper.hxx @@ -20,7 +20,6 @@ #ifndef INCLUDED_BASIC_VBAHELPER_HXX #define INCLUDED_BASIC_VBAHELPER_HXX -#include #include #include #include