summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-12-03 09:38:14 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-12-03 20:42:00 +0100
commitf9f5c9f0d6af2cb2f39d5bc1513216b8d892977c (patch)
tree38a38137eb99b1177e5dd85d0e948388307e850d /forms
parentff2068892d88091b26f3a3c034bcca49727d5840 (diff)
replace comphelper::OListenerContainer with OInterfaceContainerHelper3
OInterfaceContainerHelper3 is in wide use and can do the same thing with less ceremony Change-Id: I5252738d6b7bda6245c66da46352944ead79bd52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126271 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'forms')
-rw-r--r--forms/Library_frm.mk1
-rw-r--r--forms/source/component/DatabaseForm.cxx24
-rw-r--r--forms/source/component/DatabaseForm.hxx3
-rw-r--r--forms/source/inc/listenercontainers.hxx110
-rw-r--r--forms/source/misc/listenercontainers.cxx58
5 files changed, 16 insertions, 180 deletions
diff --git a/forms/Library_frm.mk b/forms/Library_frm.mk
index 834a2a4eb91f..5739c28c0c80 100644
--- a/forms/Library_frm.mk
+++ b/forms/Library_frm.mk
@@ -106,7 +106,6 @@ $(eval $(call gb_Library_add_exception_objects,frm,\
forms/source/misc/componenttools \
forms/source/misc/InterfaceContainer \
forms/source/misc/limitedformats \
- forms/source/misc/listenercontainers \
forms/source/misc/property \
forms/source/resource/frm_resource \
forms/source/richtext/attributedispatcher \
diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx
index c9281843326c..3aefbd798ade 100644
--- a/forms/source/component/DatabaseForm.cxx
+++ b/forms/source/component/DatabaseForm.cxx
@@ -229,7 +229,7 @@ ODatabaseForm::ODatabaseForm(const Reference<XComponentContext>& _rxContext)
,m_aRowSetApproveListeners(m_aMutex)
,m_aSubmitListeners(m_aMutex)
,m_aErrorListeners(m_aMutex)
- ,m_aResetListeners( *this, m_aMutex )
+ ,m_aResetListeners(m_aMutex)
,m_aPropertyBagHelper( *this )
,m_aParameterManager( m_aMutex, _rxContext )
,m_aFilterManager()
@@ -263,7 +263,7 @@ ODatabaseForm::ODatabaseForm( const ODatabaseForm& _cloneSource )
,m_aRowSetApproveListeners( m_aMutex )
,m_aSubmitListeners( m_aMutex )
,m_aErrorListeners( m_aMutex )
- ,m_aResetListeners( *this, m_aMutex )
+ ,m_aResetListeners( m_aMutex )
,m_aPropertyBagHelper( *this )
,m_aParameterManager( m_aMutex, _cloneSource.m_xContext )
,m_aFilterManager()
@@ -1220,7 +1220,7 @@ void ODatabaseForm::disposing()
EventObject aEvt(static_cast<XWeak*>(this));
m_aLoadListeners.disposeAndClear(aEvt);
m_aRowSetApproveListeners.disposeAndClear(aEvt);
- m_aResetListeners.disposing();
+ m_aResetListeners.disposeAndClear(aEvt);
m_aSubmitListeners.disposeAndClear(aEvt);
m_aErrorListeners.disposeAndClear(aEvt);
@@ -1893,7 +1893,7 @@ void SAL_CALL ODatabaseForm::reset()
return;
}
- if ( !m_aResetListeners.empty() )
+ if ( m_aResetListeners.getLength() )
{
::osl::MutexGuard aResetGuard(m_aResetSafety);
++m_nResetsPending;
@@ -1921,8 +1921,13 @@ void SAL_CALL ODatabaseForm::reset()
void ODatabaseForm::reset_impl(bool _bApproveByListeners)
{
if ( _bApproveByListeners )
- if ( !m_aResetListeners.approveReset() )
- return;
+ {
+ ::comphelper::OInterfaceIteratorHelper3 aIter(m_aResetListeners);
+ EventObject aEvent(*this);
+ while (aIter.hasMoreElements())
+ if (!aIter.next()->approveReset(aEvent))
+ return;
+ }
::osl::ResettableMutexGuard aResetGuard(m_aResetSafety);
// do we have a database connected form and stay on the insert row
@@ -2026,7 +2031,8 @@ void ODatabaseForm::reset_impl(bool _bApproveByListeners)
aResetGuard.clear();
{
- m_aResetListeners.resetted();
+ css::lang::EventObject aEvent( *this );
+ m_aResetListeners.notifyEach(&css::form::XResetListener::resetted, aEvent);
}
aResetGuard.reset();
@@ -2041,13 +2047,13 @@ void ODatabaseForm::reset_impl(bool _bApproveByListeners)
void SAL_CALL ODatabaseForm::addResetListener(const Reference<XResetListener>& _rListener)
{
- m_aResetListeners.addTypedListener( _rListener );
+ m_aResetListeners.addInterface( _rListener );
}
void SAL_CALL ODatabaseForm::removeResetListener(const Reference<XResetListener>& _rListener)
{
- m_aResetListeners.removeTypedListener( _rListener );
+ m_aResetListeners.removeInterface( _rListener );
}
diff --git a/forms/source/component/DatabaseForm.hxx b/forms/source/component/DatabaseForm.hxx
index a0ad6e3b86ae..7d6b86e03277 100644
--- a/forms/source/component/DatabaseForm.hxx
+++ b/forms/source/component/DatabaseForm.hxx
@@ -62,7 +62,6 @@
#include <connectivity/filtermanager.hxx>
#include <connectivity/warningscontainer.hxx>
-#include <listenercontainers.hxx>
#include <comphelper/interfacecontainer3.hxx>
#include <comphelper/propmultiplex.hxx>
#include <comphelper/uno3.hxx>
@@ -154,7 +153,7 @@ class ODatabaseForm :public OFormComponents
::comphelper::OInterfaceContainerHelper3<css::sdb::XRowSetApproveListener> m_aRowSetApproveListeners;
::comphelper::OInterfaceContainerHelper3<css::form::XSubmitListener> m_aSubmitListeners;
::comphelper::OInterfaceContainerHelper3<css::sdb::XSQLErrorListener> m_aErrorListeners;
- ResetListeners m_aResetListeners;
+ ::comphelper::OInterfaceContainerHelper3<css::form::XResetListener> m_aResetListeners;
::osl::Mutex m_aResetSafety;
css::uno::Any m_aCycle;
css::uno::Any m_aIgnoreResult; // set when we are a subform and our master form positioned on a new row
diff --git a/forms/source/inc/listenercontainers.hxx b/forms/source/inc/listenercontainers.hxx
deleted file mode 100644
index f7b0cbb88579..000000000000
--- a/forms/source/inc/listenercontainers.hxx
+++ /dev/null
@@ -1,110 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#pragma once
-
-#include <com/sun/star/form/XResetListener.hpp>
-#include <comphelper/listenernotification.hxx>
-#include <cppuhelper/weak.hxx>
-
-
-namespace frm
-{
-
- template < class LISTENER >
- class EventListeners : public ::comphelper::OListenerContainerBase< LISTENER, css::lang::EventObject >
- {
- public:
- typedef ::comphelper::OListenerContainerBase< LISTENER, css::lang::EventObject >
- EventListeners_Base;
-
- private:
- ::cppu::OWeakObject& m_rInstigator;
-
- protected:
- EventListeners( ::cppu::OWeakObject& _rInstigator, ::osl::Mutex& _rMutex )
- :EventListeners_Base( _rMutex )
- ,m_rInstigator( _rInstigator )
- {
- }
-
- public:
- bool notify()
- {
- css::lang::EventObject aEvent( m_rInstigator );
- return EventListeners_Base::notify( aEvent );
- }
-
- void disposing()
- {
- css::lang::EventObject aEvent( m_rInstigator );
- EventListeners_Base::disposing( aEvent );
- }
- protected:
- using EventListeners_Base::notify;
- using EventListeners_Base::disposing;
- };
-
- typedef EventListeners < css::form::XResetListener
- > ResetListeners_Base;
- class ResetListeners : public ResetListeners_Base
- {
- private:
- enum NotificationType
- {
- eApproval,
- eFinal
- };
- NotificationType m_eCurrentNotificationType;
-
- public:
- ResetListeners( ::cppu::OWeakObject& _rInstigator, ::osl::Mutex& _rMutex )
- :ResetListeners_Base( _rInstigator, _rMutex )
- ,m_eCurrentNotificationType( eApproval )
- {
- }
-
- /** see whether all our listeners approve the reset
- */
- bool approveReset()
- {
- m_eCurrentNotificationType = eApproval;
- return notify();
- }
-
- /** tell all our listeners that the reset happened
- */
- void resetted()
- {
- m_eCurrentNotificationType = eFinal;
- notify();
- }
-
- protected:
- virtual bool implTypedNotify(
- const css::uno::Reference< css::form::XResetListener >& _rxListener,
- const css::lang::EventObject& _rEvent
- ) override;
- };
-
-
-} // namespace frm
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/forms/source/misc/listenercontainers.cxx b/forms/source/misc/listenercontainers.cxx
deleted file mode 100644
index 13adf3e612ad..000000000000
--- a/forms/source/misc/listenercontainers.cxx
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <listenercontainers.hxx>
-#include <osl/diagnose.h>
-
-
-namespace frm
-{
-
-
- using namespace ::com::sun::star::uno;
- using namespace ::com::sun::star::lang;
- using namespace ::com::sun::star::form;
-
-
- //= ResetListeners
-
-
- bool ResetListeners::implTypedNotify( const Reference< XResetListener >& _rxListener,
- const EventObject& _rEvent )
- {
- switch ( m_eCurrentNotificationType )
- {
- case eApproval:
- if ( !_rxListener->approveReset( _rEvent ) )
- return false;
- return true;
- case eFinal:
- _rxListener->resetted( _rEvent );
- break;
- default:
- OSL_FAIL( "ResetListeners::implNotify: invalid notification type!" );
- }
- return true;
- }
-
-
-} // namespace frm
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */