From 65fce1128cf99c91c9847d613f11fc9ea2325e08 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 21 Oct 2013 15:49:20 +0200 Subject: [PATCH] AccessibleEventNotifier: remove implementation details from header Change-Id: Ia422df4066e77bbe3a43a380ba978815fe46dc9c --- .../source/misc/accessibleeventnotifier.cxx | 85 +++++++++++++------ .../comphelper/accessibleeventnotifier.hxx | 32 +------ 2 files changed, 59 insertions(+), 58 deletions(-) diff --git a/comphelper/source/misc/accessibleeventnotifier.cxx b/comphelper/source/misc/accessibleeventnotifier.cxx index 14ac88c78448..cafe9795bbcb 100644 --- a/comphelper/source/misc/accessibleeventnotifier.cxx +++ b/comphelper/source/misc/accessibleeventnotifier.cxx @@ -20,8 +20,11 @@ #include #include #include +#include #include +#include + using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::accessibility; @@ -33,35 +36,39 @@ using namespace ::comphelper; //--------------------------------------------------------------------- namespace { + typedef ::std::pair< AccessibleEventNotifier::TClientId, + AccessibleEventObject > ClientEvent; + + typedef ::cppu::OInterfaceContainerHelper EventListeners; + typedef ::std::map< AccessibleEventNotifier::TClientId, EventListeners*, + ::std::less< AccessibleEventNotifier::TClientId > > ClientMap; + + struct lclMutex : public rtl::Static< ::osl::Mutex, lclMutex > {}; struct Clients - : public rtl::Static< AccessibleEventNotifier::ClientMap, Clients > {}; -} + : public rtl::Static< ClientMap, Clients > {}; -//......................................................................... -namespace comphelper -{ -//......................................................................... - - //--------------------------------------------------------------------- - AccessibleEventNotifier::TClientId AccessibleEventNotifier::generateId() + /// generates a new client id + static AccessibleEventNotifier::TClientId generateId() { - TClientId nBiggestUsedId = 0; - TClientId nFreeId = 0; + AccessibleEventNotifier::TClientId nBiggestUsedId = 0; + AccessibleEventNotifier::TClientId nFreeId = 0; // look through all registered clients until we find a "gap" in the ids - // Note that the following relies on the fact the elements in the map are traveled with - // ascending keys (aka client ids) - AccessibleEventNotifier::ClientMap &rClients = Clients::get(); + // Note that the following relies on the fact the elements in the map + // are traveled with ascending keys (aka client ids) + ClientMap &rClients = Clients::get(); for ( ClientMap::const_iterator aLookup = rClients.begin(); aLookup != rClients.end(); ++aLookup ) { - TClientId nCurrent = aLookup->first; - OSL_ENSURE( nCurrent > nBiggestUsedId, "AccessibleEventNotifier::generateId: map is expected to be sorted ascending!" ); + AccessibleEventNotifier::TClientId nCurrent = aLookup->first; + OSL_ENSURE( nCurrent > nBiggestUsedId, + "AccessibleEventNotifier::generateId: " + "map is expected to be sorted ascending!" ); if ( nCurrent - nBiggestUsedId > 1 ) { // found a "gap" @@ -81,6 +88,41 @@ namespace comphelper return nFreeId; } + /** looks up a client in our client map, asserts if it cannot find it or + no event thread is present + + @precond + to be called with our mutex locked + + @param nClient + the id of the client to loopup + @param rPos + out-parameter for the position of the client in the client map + + @return + if and only if the client could be found and + rPos has been filled with it's position + */ + static sal_Bool implLookupClient( + const AccessibleEventNotifier::TClientId nClient, + ClientMap::iterator& rPos ) + { + // look up this client + ClientMap &rClients = Clients::get(); + rPos = rClients.find( nClient ); + OSL_ENSURE( rClients.end() != rPos, + "AccessibleEventNotifier::implLookupClient: invalid client id " + "(did you register your client?)!" ); + + return ( rClients.end() != rPos ); + } +} + +//......................................................................... +namespace comphelper +{ +//......................................................................... + //--------------------------------------------------------------------- AccessibleEventNotifier::TClientId AccessibleEventNotifier::registerClient( ) { @@ -103,17 +145,6 @@ namespace comphelper return nNewClientId; } - //--------------------------------------------------------------------- - sal_Bool AccessibleEventNotifier::implLookupClient( const TClientId _nClient, ClientMap::iterator& _rPos ) - { - // look up this client - AccessibleEventNotifier::ClientMap &rClients = Clients::get(); - _rPos = rClients.find( _nClient ); - OSL_ENSURE( rClients.end() != _rPos, "AccessibleEventNotifier::implLookupClient: invalid client id (did you register your client?)!" ); - - return ( rClients.end() != _rPos ); - } - //--------------------------------------------------------------------- void AccessibleEventNotifier::revokeClient( const TClientId _nClient ) { diff --git a/include/comphelper/accessibleeventnotifier.hxx b/include/comphelper/accessibleeventnotifier.hxx index f0a745baa5a8..19d51aaaf5f2 100644 --- a/include/comphelper/accessibleeventnotifier.hxx +++ b/include/comphelper/accessibleeventnotifier.hxx @@ -22,13 +22,8 @@ #include #include -#include -#include -#include -#include "comphelper/comphelperdllapi.h" -#include -#include +#include //......................................................................... namespace comphelper @@ -44,12 +39,6 @@ namespace comphelper public: typedef sal_uInt32 TClientId; - typedef ::std::pair< TClientId, ::com::sun::star::accessibility::AccessibleEventObject > - ClientEvent; - - typedef ::cppu::OInterfaceContainerHelper EventListeners; - typedef ::std::map< TClientId, EventListeners*, ::std::less< TClientId > > ClientMap; - protected: AccessibleEventNotifier( ); // never implemented ~AccessibleEventNotifier( ); // never implemented @@ -130,25 +119,6 @@ namespace comphelper const ::com::sun::star::accessibility::AccessibleEventObject& _rEvent ) SAL_THROW( ( ) ); - private: - /// generates a new client id - COMPHELPER_DLLPRIVATE static TClientId generateId(); - - /** looks up a client in our client map, asserts if it cannot find it or no event thread is present - - @precond - to be called with our mutex locked - - @param _nClient - the id of the client to loopup - @param _rPos - out-parameter for the position of the client in the client map - - @return - if and only if the client could be found and _rPos has been filled with - it's position - */ - COMPHELPER_DLLPRIVATE static sal_Bool implLookupClient( const TClientId _nClient, ClientMap::iterator& _rPos ); }; //.........................................................................