Kaydet (Commit) 65fce112 authored tarafından Michael Stahl's avatar Michael Stahl

AccessibleEventNotifier: remove implementation details from header

Change-Id: Ia422df4066e77bbe3a43a380ba978815fe46dc9c
üst 3f291812
...@@ -20,8 +20,11 @@ ...@@ -20,8 +20,11 @@
#include <comphelper/accessibleeventnotifier.hxx> #include <comphelper/accessibleeventnotifier.hxx>
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <rtl/instance.hxx> #include <rtl/instance.hxx>
#include <cppuhelper/interfacecontainer.h>
#include <comphelper/guarding.hxx> #include <comphelper/guarding.hxx>
#include <map>
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang; using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::accessibility; using namespace ::com::sun::star::accessibility;
...@@ -33,35 +36,39 @@ using namespace ::comphelper; ...@@ -33,35 +36,39 @@ using namespace ::comphelper;
//--------------------------------------------------------------------- //---------------------------------------------------------------------
namespace 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 struct lclMutex
: public rtl::Static< ::osl::Mutex, lclMutex > {}; : public rtl::Static< ::osl::Mutex, lclMutex > {};
struct Clients struct Clients
: public rtl::Static< AccessibleEventNotifier::ClientMap, Clients > {}; : public rtl::Static< ClientMap, Clients > {};
}
//.........................................................................
namespace comphelper
{
//.........................................................................
//--------------------------------------------------------------------- /// generates a new client id
AccessibleEventNotifier::TClientId AccessibleEventNotifier::generateId() static AccessibleEventNotifier::TClientId generateId()
{ {
TClientId nBiggestUsedId = 0; AccessibleEventNotifier::TClientId nBiggestUsedId = 0;
TClientId nFreeId = 0; AccessibleEventNotifier::TClientId nFreeId = 0;
// look through all registered clients until we find a "gap" in the ids // 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 // Note that the following relies on the fact the elements in the map
// ascending keys (aka client ids) // are traveled with ascending keys (aka client ids)
AccessibleEventNotifier::ClientMap &rClients = Clients::get(); ClientMap &rClients = Clients::get();
for ( ClientMap::const_iterator aLookup = rClients.begin(); for ( ClientMap::const_iterator aLookup = rClients.begin();
aLookup != rClients.end(); aLookup != rClients.end();
++aLookup ++aLookup
) )
{ {
TClientId nCurrent = aLookup->first; AccessibleEventNotifier::TClientId nCurrent = aLookup->first;
OSL_ENSURE( nCurrent > nBiggestUsedId, "AccessibleEventNotifier::generateId: map is expected to be sorted ascending!" ); OSL_ENSURE( nCurrent > nBiggestUsedId,
"AccessibleEventNotifier::generateId: "
"map is expected to be sorted ascending!" );
if ( nCurrent - nBiggestUsedId > 1 ) if ( nCurrent - nBiggestUsedId > 1 )
{ // found a "gap" { // found a "gap"
...@@ -81,6 +88,41 @@ namespace comphelper ...@@ -81,6 +88,41 @@ namespace comphelper
return nFreeId; 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
<TRUE/> if and only if the client could be found and
<arg>rPos</arg> 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( ) AccessibleEventNotifier::TClientId AccessibleEventNotifier::registerClient( )
{ {
...@@ -103,17 +145,6 @@ namespace comphelper ...@@ -103,17 +145,6 @@ namespace comphelper
return nNewClientId; 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 ) void AccessibleEventNotifier::revokeClient( const TClientId _nClient )
{ {
......
...@@ -22,13 +22,8 @@ ...@@ -22,13 +22,8 @@
#include <com/sun/star/accessibility/AccessibleEventObject.hpp> #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
#include <com/sun/star/accessibility/XAccessibleEventListener.hpp> #include <com/sun/star/accessibility/XAccessibleEventListener.hpp>
#include <osl/thread.hxx>
#include <osl/conditn.hxx>
#include <cppuhelper/interfacecontainer.h>
#include "comphelper/comphelperdllapi.h"
#include <map> #include <comphelper/comphelperdllapi.h>
#include <list>
//......................................................................... //.........................................................................
namespace comphelper namespace comphelper
...@@ -44,12 +39,6 @@ namespace comphelper ...@@ -44,12 +39,6 @@ namespace comphelper
public: public:
typedef sal_uInt32 TClientId; 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: protected:
AccessibleEventNotifier( ); // never implemented AccessibleEventNotifier( ); // never implemented
~AccessibleEventNotifier( ); // never implemented ~AccessibleEventNotifier( ); // never implemented
...@@ -130,25 +119,6 @@ namespace comphelper ...@@ -130,25 +119,6 @@ namespace comphelper
const ::com::sun::star::accessibility::AccessibleEventObject& _rEvent const ::com::sun::star::accessibility::AccessibleEventObject& _rEvent
) SAL_THROW( ( ) ); ) 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
<TRUE/> if and only if the client could be found and <arg>_rPos</arg> has been filled with
it's position
*/
COMPHELPER_DLLPRIVATE static sal_Bool implLookupClient( const TClientId _nClient, ClientMap::iterator& _rPos );
}; };
//......................................................................... //.........................................................................
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment