summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-09-03 13:54:47 +0200
committerMichael Stahl <mstahl@redhat.com>2015-09-03 16:31:59 +0200
commit3fb50fbe2b4951034bbe5b75aef5c88e8cd22382 (patch)
treea414d405fb5b635324e896ee495eba8e6e115d55 /basic
parent6eff03b7d8b77b797f57f2344163ff67a99631f9 (diff)
basic: remove over-engineered XEnumeration service
... that was causing duplicate WeakImplHelper symbols now. Change-Id: Ibbf84a2059f30bfeb5c265adcafb4b56d2534dc8
Diffstat (limited to 'basic')
-rw-r--r--basic/source/basmgr/vbahelper.cxx55
1 files changed, 15 insertions, 40 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 <com/sun/star/frame/ModuleManager.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <comphelper/processfactory.hxx>
-#include <cppuhelper/implbase.hxx>
#include <rtl/instance.hxx>
namespace basic {
@@ -48,24 +47,12 @@ uno::Reference< frame::XModuleManager2 > lclCreateModuleManager()
return frame::ModuleManager::create(xContext);
}
+typedef ::std::vector<uno::Reference<frame::XModel>> 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();
-}
-
-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++ );
+ return models;
}
-
-
/** 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&)
+ {
+ }
}
}