1*9877b273SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9877b273SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9877b273SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9877b273SAndrew Rist * distributed with this work for additional information 6*9877b273SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9877b273SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9877b273SAndrew Rist * "License"); you may not use this file except in compliance 9*9877b273SAndrew Rist * with the License. You may obtain a copy of the License at 10*9877b273SAndrew Rist * 11*9877b273SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*9877b273SAndrew Rist * 13*9877b273SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9877b273SAndrew Rist * software distributed under the License is distributed on an 15*9877b273SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9877b273SAndrew Rist * KIND, either express or implied. See the License for the 17*9877b273SAndrew Rist * specific language governing permissions and limitations 18*9877b273SAndrew Rist * under the License. 19*9877b273SAndrew Rist * 20*9877b273SAndrew Rist *************************************************************/ 21*9877b273SAndrew Rist 22*9877b273SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef COMPHELPER_ACCESSIBLE_WRAPPER_HXX 25cdf0e10cSrcweir #define COMPHELPER_ACCESSIBLE_WRAPPER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <comphelper/proxyaggregation.hxx> 28cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp> 29cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleContext.hpp> 30cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> 31cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleEventListener.hpp> 32cdf0e10cSrcweir #include <cppuhelper/compbase3.hxx> 33cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx> 34cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 35cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx> 36cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 37cdf0e10cSrcweir #include <comphelper/sequence.hxx> 38cdf0e10cSrcweir #include <comphelper/uno3.hxx> 39cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx> 40cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx> 41cdf0e10cSrcweir #include <comphelper/accessibleeventnotifier.hxx> 42cdf0e10cSrcweir #include <comphelper/stl_types.hxx> 43cdf0e10cSrcweir #include "comphelper/comphelperdllapi.h" 44cdf0e10cSrcweir 45cdf0e10cSrcweir //............................................................................. 46cdf0e10cSrcweir namespace comphelper 47cdf0e10cSrcweir { 48cdf0e10cSrcweir //............................................................................. 49cdf0e10cSrcweir 50cdf0e10cSrcweir //========================================================================= 51cdf0e10cSrcweir //= OAccessibleWrapper 52cdf0e10cSrcweir //========================================================================= 53cdf0e10cSrcweir 54cdf0e10cSrcweir class OAccessibleContextWrapper; 55cdf0e10cSrcweir class OWrappedAccessibleChildrenManager; 56cdf0e10cSrcweir 57cdf0e10cSrcweir struct OAccessibleWrapper_Base : 58cdf0e10cSrcweir public ::cppu::ImplHelper1 < ::com::sun::star::accessibility::XAccessible > 59cdf0e10cSrcweir {}; 60cdf0e10cSrcweir 61cdf0e10cSrcweir /** a class which aggregates a proxy for an XAccessible, and wrapping the context returned by this 62cdf0e10cSrcweir XAccessible. 63cdf0e10cSrcweir */ 64cdf0e10cSrcweir class COMPHELPER_DLLPUBLIC OAccessibleWrapper:public OAccessibleWrapper_Base 65cdf0e10cSrcweir ,public OComponentProxyAggregation 66cdf0e10cSrcweir 67cdf0e10cSrcweir { 68cdf0e10cSrcweir private: 69cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 70cdf0e10cSrcweir m_xParentAccessible; 71cdf0e10cSrcweir ::com::sun::star::uno::WeakReference< ::com::sun::star::accessibility::XAccessibleContext > 72cdf0e10cSrcweir m_aContext; 73cdf0e10cSrcweir 74cdf0e10cSrcweir protected: 75cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 76cdf0e10cSrcweir m_xInnerAccessible; 77cdf0e10cSrcweir 78cdf0e10cSrcweir public: 79cdf0e10cSrcweir /** ctor 80cdf0e10cSrcweir @param _rxORB 81cdf0e10cSrcweir a service factory 82cdf0e10cSrcweir 83cdf0e10cSrcweir @param _rxInnerAccessible 84cdf0e10cSrcweir the object to wrap 85cdf0e10cSrcweir 86cdf0e10cSrcweir @param _rxParentAccessible 87cdf0e10cSrcweir The XAccessible which is our parent 88cdf0e10cSrcweir */ 89cdf0e10cSrcweir OAccessibleWrapper( 90cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, 91cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxInnerAccessible, 92cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParentAccessible 93cdf0e10cSrcweir ); 94cdf0e10cSrcweir DECLARE_XINTERFACE() 95cdf0e10cSrcweir DECLARE_XTYPEPROVIDER() 96cdf0e10cSrcweir 97cdf0e10cSrcweir // returns the context without creating it 98cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > 99cdf0e10cSrcweir getContextNoCreate( ) const; 100cdf0e10cSrcweir 101cdf0e10cSrcweir protected: 102cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL 103cdf0e10cSrcweir getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException); 104cdf0e10cSrcweir 105cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > getParent() const106cdf0e10cSrcweir getParent() const { return m_xParentAccessible; } 107cdf0e10cSrcweir 108cdf0e10cSrcweir // own overridables 109cdf0e10cSrcweir virtual OAccessibleContextWrapper* createAccessibleContext( 110cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >& _rxInnerContext 111cdf0e10cSrcweir ); 112cdf0e10cSrcweir 113cdf0e10cSrcweir protected: 114cdf0e10cSrcweir ~OAccessibleWrapper( ); 115cdf0e10cSrcweir 116cdf0e10cSrcweir private: 117cdf0e10cSrcweir COMPHELPER_DLLPRIVATE OAccessibleWrapper( ); // never implemented 118cdf0e10cSrcweir COMPHELPER_DLLPRIVATE OAccessibleWrapper( const OAccessibleWrapper& ); // never implemented 119cdf0e10cSrcweir COMPHELPER_DLLPRIVATE OAccessibleWrapper& operator=( const OAccessibleWrapper& ); // never implemented 120cdf0e10cSrcweir }; 121cdf0e10cSrcweir 122cdf0e10cSrcweir //========================================================================= 123cdf0e10cSrcweir //= OAccessibleContextWrapperHelper 124cdf0e10cSrcweir //========================================================================= 125cdf0e10cSrcweir 126cdf0e10cSrcweir typedef ::cppu::ImplHelper1 < ::com::sun::star::accessibility::XAccessibleEventListener 127cdf0e10cSrcweir > OAccessibleContextWrapperHelper_Base; 128cdf0e10cSrcweir 129cdf0e10cSrcweir /** Helper for wrapping an XAccessibleContext by aggregating a proxy for it. 130cdf0e10cSrcweir 131cdf0e10cSrcweir <p>This class does not have own ref counting. In addition, it does not implement 132cdf0e10cSrcweir the XAccesibleContext interface, but provides all the methods from this interface 133cdf0e10cSrcweir which must be implemented using the inner context (such as getAccessibleChild*).</p> 134cdf0e10cSrcweir 135cdf0e10cSrcweir <p>Children of the aggregated XAccessibleContext are wrapped, too.</p> 136cdf0e10cSrcweir 137cdf0e10cSrcweir <p>AccessibleEvents fired by the inner context are multiplexed, especially, any references to 138cdf0e10cSrcweir children in such events are translated. This means that even in such events, no un-wrapped object 139cdf0e10cSrcweir will ever leave this class - if the aggregated context notifies an child event, the child passed 140cdf0e10cSrcweir to the event is wrapped</p> 141cdf0e10cSrcweir 142cdf0e10cSrcweir @seealso OAccessibleContextWrapper 143cdf0e10cSrcweir */ 144cdf0e10cSrcweir class COMPHELPER_DLLPUBLIC OAccessibleContextWrapperHelper 145cdf0e10cSrcweir :private OComponentProxyAggregationHelper 146cdf0e10cSrcweir ,public OAccessibleContextWrapperHelper_Base 147cdf0e10cSrcweir { 148cdf0e10cSrcweir protected: 149cdf0e10cSrcweir /// the context we're wrapping (properly typed, in opposite to OComponentProxyAggregationHelper::m_xInner) 150cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > 151cdf0e10cSrcweir m_xInnerContext; 152cdf0e10cSrcweir /// the XAccessible which created this context 153cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 154cdf0e10cSrcweir m_xOwningAccessible; 155cdf0e10cSrcweir /// the XAccessible which is to be returned in getAccessibleParent 156cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 157cdf0e10cSrcweir m_xParentAccessible; 158cdf0e10cSrcweir 159cdf0e10cSrcweir OWrappedAccessibleChildrenManager* m_pChildMapper; // for mapping children from our inner context to our callers 160cdf0e10cSrcweir 161cdf0e10cSrcweir protected: 162cdf0e10cSrcweir /** ctor 163cdf0e10cSrcweir 164cdf0e10cSrcweir @param _rxORB 165cdf0e10cSrcweir a service factory 166cdf0e10cSrcweir 167cdf0e10cSrcweir @param _rxInnerAccessibleContext 168cdf0e10cSrcweir the object to wrap 169cdf0e10cSrcweir 170cdf0e10cSrcweir @param _rxOwningAccessible 171cdf0e10cSrcweir The XAccessible which created this object. This is necessary because children 172cdf0e10cSrcweir of our wrapped context meed to be wrapped, too, and if they're asked for a parent, 173cdf0e10cSrcweir they of course should return the proper parent<br/> 174cdf0e10cSrcweir The object will be held with a hard reference 175cdf0e10cSrcweir 176cdf0e10cSrcweir @param _rxParentAccessible 177cdf0e10cSrcweir The XAccessible to return in the getAccessibleParent call 178cdf0e10cSrcweir */ 179cdf0e10cSrcweir OAccessibleContextWrapperHelper( 180cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, 181cdf0e10cSrcweir ::cppu::OBroadcastHelper& _rBHelper, 182cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >& _rxInnerAccessibleContext, 183cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxOwningAccessible, 184cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParentAccessible 185cdf0e10cSrcweir ); 186cdf0e10cSrcweir 187cdf0e10cSrcweir /// to be called from within your ctor - does the aggregation of a proxy for m_xInnerContext 188cdf0e10cSrcweir void aggregateProxy( 189cdf0e10cSrcweir oslInterlockedCount& _rRefCount, 190cdf0e10cSrcweir ::cppu::OWeakObject& _rDelegator 191cdf0e10cSrcweir ); 192cdf0e10cSrcweir 193cdf0e10cSrcweir protected: 194cdf0e10cSrcweir // XInterface 195cdf0e10cSrcweir ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException); 196cdf0e10cSrcweir 197cdf0e10cSrcweir // XTypeProvider 198cdf0e10cSrcweir DECLARE_XTYPEPROVIDER( ) 199cdf0e10cSrcweir 200cdf0e10cSrcweir // XAccessibleContext 201cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); 202cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 203cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException); 204cdf0e10cSrcweir 205cdf0e10cSrcweir // XAccessibleEventListener 206cdf0e10cSrcweir virtual void SAL_CALL notifyEvent( const ::com::sun::star::accessibility::AccessibleEventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException); 207cdf0e10cSrcweir 208cdf0e10cSrcweir // XEventListener 209cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 210cdf0e10cSrcweir 211cdf0e10cSrcweir // XComponent/OComponentProxyAggregationHelper 212cdf0e10cSrcweir virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException ); 213cdf0e10cSrcweir 214cdf0e10cSrcweir // own overridables 215cdf0e10cSrcweir /** notify an accessible event which has been translated (if necessary) 216cdf0e10cSrcweir 217cdf0e10cSrcweir <p>Usually, you derive your clas from both OAccessibleContextWrapperHelper and XAccessibleEventBroadcaster, 218cdf0e10cSrcweir and simply call all your XAccessibleEventListener with the given event.</p> 219cdf0e10cSrcweir 220cdf0e10cSrcweir <p>The mutex of the BroadcastHelper passed to the instance's ctor is <em>not</em> locked when calling 221cdf0e10cSrcweir into this method</p> 222cdf0e10cSrcweir */ 223cdf0e10cSrcweir virtual void notifyTranslatedEvent( const ::com::sun::star::accessibility::AccessibleEventObject& _rEvent ) throw (::com::sun::star::uno::RuntimeException) = 0; 224cdf0e10cSrcweir 225cdf0e10cSrcweir protected: 226cdf0e10cSrcweir ~OAccessibleContextWrapperHelper( ); 227cdf0e10cSrcweir 228cdf0e10cSrcweir OAccessibleContextWrapperHelper( ); // never implemented 229cdf0e10cSrcweir OAccessibleContextWrapperHelper( const OAccessibleContextWrapperHelper& ); // never implemented 230cdf0e10cSrcweir OAccessibleContextWrapperHelper& operator=( const OAccessibleContextWrapperHelper& ); // never implemented 231cdf0e10cSrcweir }; 232cdf0e10cSrcweir 233cdf0e10cSrcweir //========================================================================= 234cdf0e10cSrcweir //= OAccessibleContextWrapper 235cdf0e10cSrcweir //========================================================================= 236cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::accessibility::XAccessibleEventBroadcaster 237cdf0e10cSrcweir , ::com::sun::star::accessibility::XAccessibleContext 238cdf0e10cSrcweir > OAccessibleContextWrapper_CBase; 239cdf0e10cSrcweir 240cdf0e10cSrcweir class COMPHELPER_DLLPUBLIC OAccessibleContextWrapper 241cdf0e10cSrcweir :public OBaseMutex 242cdf0e10cSrcweir ,public OAccessibleContextWrapper_CBase 243cdf0e10cSrcweir ,public OAccessibleContextWrapperHelper 244cdf0e10cSrcweir { 245cdf0e10cSrcweir private: 246cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::TClientId m_nNotifierClient; // for notifying AccessibleEvents 247cdf0e10cSrcweir 248cdf0e10cSrcweir public: 249cdf0e10cSrcweir /** ctor 250cdf0e10cSrcweir 251cdf0e10cSrcweir @param _rxORB 252cdf0e10cSrcweir a service factory 253cdf0e10cSrcweir 254cdf0e10cSrcweir @param _rxInnerAccessibleContext 255cdf0e10cSrcweir the object to wrap 256cdf0e10cSrcweir 257cdf0e10cSrcweir @param _rxOwningAccessible 258cdf0e10cSrcweir The XAccessible which created this object. This is necessary because children 259cdf0e10cSrcweir of our wrapped context meed to be wrapped, too, and if they're asked for a parent, 260cdf0e10cSrcweir they of course should return the proper parent<br/> 261cdf0e10cSrcweir The object will be held with a hard reference 262cdf0e10cSrcweir 263cdf0e10cSrcweir @param _rxParentAccessible 264cdf0e10cSrcweir The XAccessible to return in the getAccessibleParent call 265cdf0e10cSrcweir */ 266cdf0e10cSrcweir OAccessibleContextWrapper( 267cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, 268cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >& _rxInnerAccessibleContext, 269cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxOwningAccessible, 270cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParentAccessible 271cdf0e10cSrcweir ); 272cdf0e10cSrcweir 273cdf0e10cSrcweir // XInterface 274cdf0e10cSrcweir DECLARE_XINTERFACE( ) 275cdf0e10cSrcweir // XTypeProvider 276cdf0e10cSrcweir DECLARE_XTYPEPROVIDER( ) 277cdf0e10cSrcweir 278cdf0e10cSrcweir // XAccessibleContext 279cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); 280cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 281cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException); 282cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException); 283cdf0e10cSrcweir virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException); 284cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException); 285cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException); 286cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException); 287cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException); 288cdf0e10cSrcweir virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException); 289cdf0e10cSrcweir 290cdf0e10cSrcweir // XAccessibleEventBroadcaster 291cdf0e10cSrcweir using WeakComponentImplHelperBase::addEventListener; 292cdf0e10cSrcweir virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 293cdf0e10cSrcweir using WeakComponentImplHelperBase::removeEventListener; 294cdf0e10cSrcweir virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 295cdf0e10cSrcweir 296cdf0e10cSrcweir // OAccessibleContextWrapper 297cdf0e10cSrcweir virtual void notifyTranslatedEvent( const ::com::sun::star::accessibility::AccessibleEventObject& _rEvent ) throw (::com::sun::star::uno::RuntimeException); 298cdf0e10cSrcweir 299cdf0e10cSrcweir // XComponent/OComponentProxyAggregationHelper 300cdf0e10cSrcweir virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException ); 301cdf0e10cSrcweir 302cdf0e10cSrcweir // OComponentHelper 303cdf0e10cSrcweir using OAccessibleContextWrapperHelper::disposing; 304cdf0e10cSrcweir virtual void SAL_CALL disposing() throw (::com::sun::star::uno::RuntimeException); 305cdf0e10cSrcweir 306cdf0e10cSrcweir protected: 307cdf0e10cSrcweir virtual ~OAccessibleContextWrapper(); 308cdf0e10cSrcweir 309cdf0e10cSrcweir private: 310cdf0e10cSrcweir COMPHELPER_DLLPRIVATE OAccessibleContextWrapper(); // never implemented 311cdf0e10cSrcweir COMPHELPER_DLLPRIVATE OAccessibleContextWrapper( const OAccessibleContextWrapper& ); // never implemented 312cdf0e10cSrcweir COMPHELPER_DLLPRIVATE OAccessibleContextWrapper& operator=( const OAccessibleContextWrapper& ); // never implemented 313cdf0e10cSrcweir }; 314cdf0e10cSrcweir 315cdf0e10cSrcweir //========================================================================= 316cdf0e10cSrcweir //= OWrappedAccessibleChildrenManager 317cdf0e10cSrcweir //========================================================================= 318cdf0e10cSrcweir 319cdf0e10cSrcweir typedef ::std::map < ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 320cdf0e10cSrcweir , ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 321cdf0e10cSrcweir , OInterfaceCompare< ::com::sun::star::accessibility::XAccessible > 322cdf0e10cSrcweir > AccessibleMap; 323cdf0e10cSrcweir // TODO: think about if we should hold these objects weak 324cdf0e10cSrcweir 325cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1 < ::com::sun::star::lang::XEventListener 326cdf0e10cSrcweir > OWrappedAccessibleChildrenManager_Base; 327cdf0e10cSrcweir /** manages wrapping XAccessible's to XAccessible's 328cdf0e10cSrcweir */ 329cdf0e10cSrcweir class COMPHELPER_DLLPUBLIC OWrappedAccessibleChildrenManager : public OWrappedAccessibleChildrenManager_Base 330cdf0e10cSrcweir { 331cdf0e10cSrcweir protected: 332cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > 333cdf0e10cSrcweir m_xORB; 334cdf0e10cSrcweir ::com::sun::star::uno::WeakReference< ::com::sun::star::accessibility::XAccessible > 335cdf0e10cSrcweir m_aOwningAccessible; // the XAccessible which belongs to the XAccessibleContext which we work for 336cdf0e10cSrcweir AccessibleMap m_aChildrenMap; // for caching children 337cdf0e10cSrcweir sal_Bool m_bTransientChildren; // are we prohibited to cache our children? 338cdf0e10cSrcweir 339cdf0e10cSrcweir public: 340cdf0e10cSrcweir /// ctor 341cdf0e10cSrcweir OWrappedAccessibleChildrenManager( 342cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB 343cdf0e10cSrcweir ); 344cdf0e10cSrcweir 345cdf0e10cSrcweir /** specifies if the children are to be consideren transient (i.e.: not cached) 346cdf0e10cSrcweir <p>to be called only once per lifetime</p> 347cdf0e10cSrcweir */ 348cdf0e10cSrcweir void setTransientChildren( sal_Bool _bSet = sal_True ); 349cdf0e10cSrcweir 350cdf0e10cSrcweir /** sets the XAccessible which belongs to the XAccessibleContext which we work for 351cdf0e10cSrcweir <p>to be called only once per lifetime</p> 352cdf0e10cSrcweir */ 353cdf0e10cSrcweir void setOwningAccessible( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxAcc ); 354cdf0e10cSrcweir 355cdf0e10cSrcweir /// retrieves a wrapper for the given accessible 356cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 357cdf0e10cSrcweir getAccessibleWrapperFor( 358cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxKey, 359cdf0e10cSrcweir sal_Bool _bCreate = sal_True 360cdf0e10cSrcweir ); 361cdf0e10cSrcweir 362cdf0e10cSrcweir /// erases the given key from the map (if it is present there) 363cdf0e10cSrcweir void removeFromCache( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxKey ); 364cdf0e10cSrcweir 365cdf0e10cSrcweir /// invalidates (i.e. empties) the map 366cdf0e10cSrcweir void invalidateAll( ); 367cdf0e10cSrcweir 368cdf0e10cSrcweir /** disposes (i.e. cleares) the manager 369cdf0e10cSrcweir 370cdf0e10cSrcweir <p>Note that the XAccessibleContext's of the mapped XAccessible objects are disposed, too.</p> 371cdf0e10cSrcweir */ 372cdf0e10cSrcweir void dispose(); 373cdf0e10cSrcweir 374cdf0e10cSrcweir /** handles a notification as got from the parent of the children we're managing 375cdf0e10cSrcweir <p>This applies only to the notifications which have a direct impact on our map.</p> 376cdf0e10cSrcweir */ 377cdf0e10cSrcweir void handleChildNotification( const ::com::sun::star::accessibility::AccessibleEventObject& _rEvent ); 378cdf0e10cSrcweir 379cdf0e10cSrcweir /** translates events as got from the parent of the children we're managing 380cdf0e10cSrcweir <p>This applies only to the notifications which deal with child objects which we manage.</p> 381cdf0e10cSrcweir */ 382cdf0e10cSrcweir void translateAccessibleEvent( 383cdf0e10cSrcweir const ::com::sun::star::accessibility::AccessibleEventObject& _rEvent, 384cdf0e10cSrcweir ::com::sun::star::accessibility::AccessibleEventObject& _rTranslatedEvent 385cdf0e10cSrcweir ); 386cdf0e10cSrcweir 387cdf0e10cSrcweir protected: 388cdf0e10cSrcweir // XEventListener 389cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 390cdf0e10cSrcweir 391cdf0e10cSrcweir protected: 392cdf0e10cSrcweir void implTranslateChildEventValue( const ::com::sun::star::uno::Any& _rInValue, ::com::sun::star::uno::Any& _rOutValue ); 393cdf0e10cSrcweir 394cdf0e10cSrcweir protected: 395cdf0e10cSrcweir ~OWrappedAccessibleChildrenManager( ); 396cdf0e10cSrcweir 397cdf0e10cSrcweir private: 398cdf0e10cSrcweir COMPHELPER_DLLPRIVATE OWrappedAccessibleChildrenManager( ); // never implemented 399cdf0e10cSrcweir COMPHELPER_DLLPRIVATE OWrappedAccessibleChildrenManager( const OWrappedAccessibleChildrenManager& ); // never implemented 400cdf0e10cSrcweir COMPHELPER_DLLPRIVATE OWrappedAccessibleChildrenManager& operator=( const OWrappedAccessibleChildrenManager& ); // never implemented 401cdf0e10cSrcweir }; 402cdf0e10cSrcweir 403cdf0e10cSrcweir //............................................................................. 404cdf0e10cSrcweir } // namespace accessibility 405cdf0e10cSrcweir //............................................................................. 406cdf0e10cSrcweir 407cdf0e10cSrcweir #endif // COMPHELPER_ACCESSIBLE_WRAPPER_HXX 408