1*a462bbb7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*a462bbb7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*a462bbb7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*a462bbb7SAndrew Rist  * distributed with this work for additional information
6*a462bbb7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*a462bbb7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*a462bbb7SAndrew Rist  * "License"); you may not use this file except in compliance
9*a462bbb7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*a462bbb7SAndrew Rist  *
11*a462bbb7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*a462bbb7SAndrew Rist  *
13*a462bbb7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*a462bbb7SAndrew Rist  * software distributed under the License is distributed on an
15*a462bbb7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*a462bbb7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*a462bbb7SAndrew Rist  * specific language governing permissions and limitations
18*a462bbb7SAndrew Rist  * under the License.
19*a462bbb7SAndrew Rist  *
20*a462bbb7SAndrew Rist  *************************************************************/
21*a462bbb7SAndrew Rist 
22*a462bbb7SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #ifndef ACCESSIBILITY_EXT_ACCESSIBLEBROWSEBOXBASE_HXX
26cdf0e10cSrcweir #define ACCESSIBILITY_EXT_ACCESSIBLEBROWSEBOXBASE_HXX
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <svtools/AccessibleBrowseBoxObjType.hxx>
29cdf0e10cSrcweir #include <tools/debug.hxx>
30cdf0e10cSrcweir #include <rtl/ustring.hxx>
31cdf0e10cSrcweir #include <tools/gen.hxx>
32cdf0e10cSrcweir #include <vcl/svapp.hxx>
33cdf0e10cSrcweir #include <cppuhelper/compbase5.hxx>
34cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
35cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
36cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
37cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
38cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
39cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
40cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp>
41cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleContext.hpp>
42cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
43cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
44cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
45cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
46cdf0e10cSrcweir #include <com/sun/star/awt/XFocusListener.hpp>
47cdf0e10cSrcweir #include <comphelper/accessibleeventnotifier.hxx>
48cdf0e10cSrcweir #include <comphelper/uno3.hxx>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir // ============================================================================
51cdf0e10cSrcweir 
52cdf0e10cSrcweir class Window;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir namespace utl {
55cdf0e10cSrcweir     class AccessibleStateSetHelper;
56cdf0e10cSrcweir }
57cdf0e10cSrcweir 
58cdf0e10cSrcweir namespace svt {
59cdf0e10cSrcweir     class IAccessibleTableProvider;
60cdf0e10cSrcweir }
61cdf0e10cSrcweir 
62cdf0e10cSrcweir // ============================================================================
63cdf0e10cSrcweir 
64cdf0e10cSrcweir namespace accessibility {
65cdf0e10cSrcweir 
66cdf0e10cSrcweir // ============================================================================
67cdf0e10cSrcweir 
68cdf0e10cSrcweir /** Aquire the solar mutex. */
69cdf0e10cSrcweir class BBSolarGuard : public ::vos::OGuard
70cdf0e10cSrcweir {
71cdf0e10cSrcweir public:
BBSolarGuard()72cdf0e10cSrcweir     inline BBSolarGuard() : ::vos::OGuard( Application::GetSolarMutex() ) {}
73cdf0e10cSrcweir };
74cdf0e10cSrcweir 
75cdf0e10cSrcweir // ============================================================================
76cdf0e10cSrcweir 
77cdf0e10cSrcweir typedef ::cppu::WeakAggComponentImplHelper5<
78cdf0e10cSrcweir             ::com::sun::star::accessibility::XAccessibleContext,
79cdf0e10cSrcweir             ::com::sun::star::accessibility::XAccessibleComponent,
80cdf0e10cSrcweir             ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
81cdf0e10cSrcweir 	    ::com::sun::star::awt::XFocusListener,
82cdf0e10cSrcweir             ::com::sun::star::lang::XServiceInfo >
83cdf0e10cSrcweir         AccessibleBrowseBoxImplHelper;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir /** The BrowseBox accessible objects inherit from this base class. It
86cdf0e10cSrcweir     implements basic functionality for various Accessibility interfaces and
87cdf0e10cSrcweir     the event broadcaster and contains the ::osl::Mutex. */
88cdf0e10cSrcweir class AccessibleBrowseBoxBase :
89cdf0e10cSrcweir     public ::comphelper::OBaseMutex,
90cdf0e10cSrcweir     public AccessibleBrowseBoxImplHelper
91cdf0e10cSrcweir {
92cdf0e10cSrcweir public:
93cdf0e10cSrcweir     /** Constructor sets specified name and description. If the constant of a
94cdf0e10cSrcweir         text is BBTEXT_NONE, the derived class has to set the text via
95cdf0e10cSrcweir         implSetName() and implSetDescription() (in Ctor) or later via
96cdf0e10cSrcweir         setAccessibleName() and setAccessibleDescription() (these methods
97cdf0e10cSrcweir         notify the listeners about the change).
98cdf0e10cSrcweir         @param rxParent  XAccessible interface of the parent object.
99cdf0e10cSrcweir         @param rBrowseBox  The BrowseBox control.
100cdf0e10cSrcweir         @param eNameText  The constant for the name text.
101cdf0e10cSrcweir         @param eDescrText  The constant for the description text. */
102cdf0e10cSrcweir     AccessibleBrowseBoxBase(
103cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
104cdf0e10cSrcweir             ::com::sun::star::accessibility::XAccessible >& rxParent,
105cdf0e10cSrcweir         ::svt::IAccessibleTableProvider&                  rBrowseBox,
106cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow,
107cdf0e10cSrcweir         ::svt::AccessibleBrowseBoxObjType  eObjType );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     /** Constructor sets specified name and description.
110cdf0e10cSrcweir         @param rxParent  XAccessible interface of the parent object.
111cdf0e10cSrcweir         @param rBrowseBox  The BrowseBox control.
112cdf0e10cSrcweir         @param rName  The name of this object.
113cdf0e10cSrcweir         @param rDescription  The description text of this object. */
114cdf0e10cSrcweir     AccessibleBrowseBoxBase(
115cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
116cdf0e10cSrcweir             ::com::sun::star::accessibility::XAccessible >& rxParent,
117cdf0e10cSrcweir         ::svt::IAccessibleTableProvider&                  rBrowseBox,
118cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow,
119cdf0e10cSrcweir         ::svt::AccessibleBrowseBoxObjType  eObjType,
120cdf0e10cSrcweir         const ::rtl::OUString&      rName,
121cdf0e10cSrcweir         const ::rtl::OUString&      rDescription );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir protected:
124cdf0e10cSrcweir     virtual ~AccessibleBrowseBoxBase();
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     /** Commits DeFunc event to listeners and cleans up members. */
127cdf0e10cSrcweir     virtual void SAL_CALL disposing();
128cdf0e10cSrcweir 
129cdf0e10cSrcweir public:
130cdf0e10cSrcweir     // XAccessibleContext -----------------------------------------------------
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     /** @return  A reference to the parent accessible object. */
133cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
134cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible > SAL_CALL
135cdf0e10cSrcweir     getAccessibleParent()
136cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     /** @return  The index of this object among the parent's children. */
139cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getAccessibleIndexInParent()
140cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     /** @return
143cdf0e10cSrcweir 			The description of this object.
144cdf0e10cSrcweir 	*/
145cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getAccessibleDescription()
146cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     /** @return
149cdf0e10cSrcweir 			The name of this object.
150cdf0e10cSrcweir 	*/
151cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getAccessibleName()
152cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     /** @return
155cdf0e10cSrcweir 			The relation set (the BrowseBox does not have one).
156cdf0e10cSrcweir 	*/
157cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference<
158cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL
159cdf0e10cSrcweir     getAccessibleRelationSet()
160cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     /** @return  The set of current states. */
163cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference<
164cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL
165cdf0e10cSrcweir     getAccessibleStateSet()
166cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     /** @return  The parent's locale. */
169cdf0e10cSrcweir     virtual ::com::sun::star::lang::Locale SAL_CALL getLocale()
170cdf0e10cSrcweir         throw ( ::com::sun::star::accessibility::IllegalAccessibleComponentStateException,
171cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 	/** @return
174cdf0e10cSrcweir 			The role of this object. Panel, ROWHEADER, COLUMNHEADER, TABLE, TABLE_CELL are supported.
175cdf0e10cSrcweir 	*/
176cdf0e10cSrcweir     virtual sal_Int16 SAL_CALL getAccessibleRole()
177cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     /*  Derived classes have to implement:
180cdf0e10cSrcweir         -   getAccessibleChildCount,
181cdf0e10cSrcweir         -   getAccessibleChild,
182cdf0e10cSrcweir         -   getAccessibleRole.
183cdf0e10cSrcweir         Derived classes may overwrite getAccessibleIndexInParent to increase
184cdf0e10cSrcweir         performance. */
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     // XAccessibleComponent ---------------------------------------------------
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     /** @return
189cdf0e10cSrcweir         <TRUE/>, if the point lies within the bounding box of this object. */
190cdf0e10cSrcweir     virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& rPoint )
191cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
192cdf0e10cSrcweir 
193cdf0e10cSrcweir     /** @return  The bounding box of this object. */
194cdf0e10cSrcweir     virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds()
195cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
196cdf0e10cSrcweir 
197cdf0e10cSrcweir     /** @return
198cdf0e10cSrcweir         The upper left corner of the bounding box relative to the parent. */
199cdf0e10cSrcweir     virtual ::com::sun::star::awt::Point SAL_CALL getLocation()
200cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
201cdf0e10cSrcweir 
202cdf0e10cSrcweir     /** @return
203cdf0e10cSrcweir         The upper left corner of the bounding box in screen coordinates. */
204cdf0e10cSrcweir     virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen()
205cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
206cdf0e10cSrcweir 
207cdf0e10cSrcweir     /** @return  The size of the bounding box. */
208cdf0e10cSrcweir     virtual ::com::sun::star::awt::Size SAL_CALL getSize()
209cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
210cdf0e10cSrcweir 
211cdf0e10cSrcweir     /** @return  <TRUE/>, if the object is showing. */
212cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isShowing()
213cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
214cdf0e10cSrcweir 
215cdf0e10cSrcweir     /** @return  <TRUE/>, if the object is visible. */
216cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isVisible()
217cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
218cdf0e10cSrcweir 
219cdf0e10cSrcweir     /** @return  <TRUE/>, if the object can accept the focus. */
220cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isFocusTraversable()
221cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 	virtual sal_Int32 SAL_CALL getForeground(  ) throw (::com::sun::star::uno::RuntimeException);
224cdf0e10cSrcweir 	virtual sal_Int32 SAL_CALL getBackground(  ) throw (::com::sun::star::uno::RuntimeException);
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 	// XFocusListener
227cdf0e10cSrcweir 	virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
228cdf0e10cSrcweir     virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException);
229cdf0e10cSrcweir     virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException);
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     /*  Derived classes have to implement:
232cdf0e10cSrcweir         -   getAccessibleAt,
233cdf0e10cSrcweir         -   grabFocus,
234cdf0e10cSrcweir         -   getAccessibleKeyBinding. */
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 	/** @return
237cdf0e10cSrcweir 		No key bindings supported by default.
238cdf0e10cSrcweir 	*/
239cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding()
240cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
241cdf0e10cSrcweir 	/** @return
242cdf0e10cSrcweir 			The accessible child rendered under the given point.
243cdf0e10cSrcweir 	*/
244cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
245cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible > SAL_CALL
246cdf0e10cSrcweir     getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint )
247cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
248cdf0e10cSrcweir 
249cdf0e10cSrcweir     // XAccessibleEventBroadcaster --------------------------------------------
250cdf0e10cSrcweir 
251cdf0e10cSrcweir     /** Adds a new event listener */
252cdf0e10cSrcweir     using cppu::WeakAggComponentImplHelperBase::addEventListener;
253cdf0e10cSrcweir     virtual void SAL_CALL addEventListener(
254cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
255cdf0e10cSrcweir                 ::com::sun::star::accessibility::XAccessibleEventListener>& rxListener )
256cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
257cdf0e10cSrcweir 
258cdf0e10cSrcweir     /** Removes an event listener. */
259cdf0e10cSrcweir     using cppu::WeakAggComponentImplHelperBase::removeEventListener;
260cdf0e10cSrcweir     virtual void SAL_CALL removeEventListener(
261cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference<
262cdf0e10cSrcweir                 ::com::sun::star::accessibility::XAccessibleEventListener>& rxListener )
263cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
264cdf0e10cSrcweir 
265cdf0e10cSrcweir     // XTypeProvider ----------------------------------------------------------
266cdf0e10cSrcweir 
267cdf0e10cSrcweir     /** @return  An unique implementation ID. */
268cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
269cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
270cdf0e10cSrcweir 
271cdf0e10cSrcweir     // XServiceInfo -----------------------------------------------------------
272cdf0e10cSrcweir 
273cdf0e10cSrcweir     /** @return  Whether the specified service is supported by this class. */
274cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName )
275cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
276cdf0e10cSrcweir 
277cdf0e10cSrcweir     /** @return  A list of all supported services. */
278cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
279cdf0e10cSrcweir     getSupportedServiceNames()
280cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
281cdf0e10cSrcweir 
282cdf0e10cSrcweir     /*  Derived classes have to implement:
283cdf0e10cSrcweir         -   getImplementationName. */
284cdf0e10cSrcweir 
285cdf0e10cSrcweir     // helper methods ---------------------------------------------------------
286cdf0e10cSrcweir 
287cdf0e10cSrcweir     /** @return  The BrowseBox object type. */
288cdf0e10cSrcweir     inline ::svt::AccessibleBrowseBoxObjType getType() const;
289cdf0e10cSrcweir 
290cdf0e10cSrcweir     /** Changes the name of the object and notifies listeners. */
291cdf0e10cSrcweir     void setAccessibleName( const ::rtl::OUString& rName );
292cdf0e10cSrcweir     /** Changes the description of the object and notifies listeners. */
293cdf0e10cSrcweir     void setAccessibleDescription( const ::rtl::OUString& rDescription );
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 	/** Commits an event to all listeners. */
296cdf0e10cSrcweir     void commitEvent(
297cdf0e10cSrcweir             sal_Int16 nEventId,
298cdf0e10cSrcweir             const ::com::sun::star::uno::Any& rNewValue,
299cdf0e10cSrcweir 
300cdf0e10cSrcweir     const ::com::sun::star::uno::Any& rOldValue );
301cdf0e10cSrcweir     /** @return  <TRUE/>, if the object is not disposed or disposing. */
302cdf0e10cSrcweir     sal_Bool isAlive() const;
303cdf0e10cSrcweir 
304cdf0e10cSrcweir protected:
305cdf0e10cSrcweir     // internal virtual methods -----------------------------------------------
306cdf0e10cSrcweir 
307cdf0e10cSrcweir     /** Determines whether the BrowseBox control is really showing inside of
308cdf0e10cSrcweir         its parent accessible window. Derived classes may implement different
309cdf0e10cSrcweir         behaviour.
310cdf0e10cSrcweir         @attention  This method requires locked mutex's and a living object.
311cdf0e10cSrcweir         @return  <TRUE/>, if the object is really showing. */
312cdf0e10cSrcweir     virtual sal_Bool implIsShowing();
313cdf0e10cSrcweir 
314cdf0e10cSrcweir     /** Derived classes return the bounding box relative to the parent window.
315cdf0e10cSrcweir         @attention  This method requires locked mutex's and a living object.
316cdf0e10cSrcweir         @return  The bounding box (VCL rect.) relative to the parent window. */
317cdf0e10cSrcweir     virtual Rectangle implGetBoundingBox() = 0;
318cdf0e10cSrcweir     /** Derived classes return the bounding box in screen coordinates.
319cdf0e10cSrcweir         @attention  This method requires locked mutex's and a living object.
320cdf0e10cSrcweir         @return  The bounding box (VCL rect.) in screen coordinates. */
321cdf0e10cSrcweir     virtual Rectangle implGetBoundingBoxOnScreen() = 0;
322cdf0e10cSrcweir 
323cdf0e10cSrcweir     /** Creates a new AccessibleStateSetHelper and fills it with states of the
324cdf0e10cSrcweir         current object. This method calls FillStateSet at the BrowseBox which
325cdf0e10cSrcweir         fills it with more states depending on the object type. Derived classes
326cdf0e10cSrcweir         may overwrite this method and add more states.
327cdf0e10cSrcweir         @attention  This method requires locked mutex's.
328cdf0e10cSrcweir         @return  A filled AccessibleStateSetHelper. */
329cdf0e10cSrcweir     virtual ::utl::AccessibleStateSetHelper* implCreateStateSetHelper();
330cdf0e10cSrcweir 
331cdf0e10cSrcweir     // internal helper methods ------------------------------------------------
332cdf0e10cSrcweir 
333cdf0e10cSrcweir     /** @throws <type>DisposedException</type>  If the object is not alive. */
334cdf0e10cSrcweir     void ensureIsAlive() const
335cdf0e10cSrcweir         throw ( ::com::sun::star::lang::DisposedException );
336cdf0e10cSrcweir 
337cdf0e10cSrcweir     /** @return  The ::osl::Mutex member provided by the class OBaseMutex. */
338cdf0e10cSrcweir     inline ::osl::Mutex& getOslMutex();
339cdf0e10cSrcweir     /** @return  Pointer to the global ::osl::Mutex. */
340cdf0e10cSrcweir     static inline ::osl::Mutex* getOslGlobalMutex();
341cdf0e10cSrcweir 
342cdf0e10cSrcweir     /** Changes the name of the object (flat assignment, no notify).
343cdf0e10cSrcweir         @attention  This method requires a locked mutex. */
344cdf0e10cSrcweir     inline void implSetName( const ::rtl::OUString& rName );
345cdf0e10cSrcweir     /** Changes the description of the object (flat assignment, no notify).
346cdf0e10cSrcweir         @attention  This method requires a locked mutex. */
347cdf0e10cSrcweir     inline void implSetDescription( const ::rtl::OUString& rDescription );
348cdf0e10cSrcweir 
349cdf0e10cSrcweir     /** Locks all mutex's and calculates the bounding box relative to the
350cdf0e10cSrcweir         parent window.
351cdf0e10cSrcweir         @return  The bounding box (VCL rect.) relative to the parent object. */
352cdf0e10cSrcweir     Rectangle getBoundingBox()
353cdf0e10cSrcweir         throw ( ::com::sun::star::lang::DisposedException );
354cdf0e10cSrcweir     /** Locks all mutex's and calculates the bounding box in screen
355cdf0e10cSrcweir         coordinates.
356cdf0e10cSrcweir         @return  The bounding box (VCL rect.) in screen coordinates. */
357cdf0e10cSrcweir     Rectangle getBoundingBoxOnScreen()
358cdf0e10cSrcweir         throw ( ::com::sun::star::lang::DisposedException );
359cdf0e10cSrcweir 
360cdf0e10cSrcweir     /** Creates a new UUID, if rId is empty.
361cdf0e10cSrcweir         @attention  This method requires locked global mutex to prevent double
362cdf0e10cSrcweir                     creation of an UUID. */
363cdf0e10cSrcweir     static void implCreateUuid( ::com::sun::star::uno::Sequence< sal_Int8 >& rId );
364cdf0e10cSrcweir 
getClientId() const365cdf0e10cSrcweir 	::comphelper::AccessibleEventNotifier::TClientId getClientId() const { return m_aClientId; }
setClientId(::comphelper::AccessibleEventNotifier::TClientId _aNewClientId)366cdf0e10cSrcweir 	void setClientId(::comphelper::AccessibleEventNotifier::TClientId _aNewClientId) { m_aClientId = _aNewClientId; }
367cdf0e10cSrcweir 
368cdf0e10cSrcweir public:
369cdf0e10cSrcweir 	// public versions of internal helper methods, with access control
AccessControlaccessibility::AccessibleBrowseBoxBase::AccessControl370cdf0e10cSrcweir 	struct AccessControl { friend class SolarMethodGuard; private: AccessControl() { } };
371cdf0e10cSrcweir 
getMutex(const AccessControl &)372cdf0e10cSrcweir 	inline ::osl::Mutex&	getMutex( const AccessControl& ) { return getOslMutex(); }
ensureIsAlive(const AccessControl &)373cdf0e10cSrcweir 	inline void             ensureIsAlive( const AccessControl& ) { ensureIsAlive(); }
374cdf0e10cSrcweir 
375cdf0e10cSrcweir protected:
376cdf0e10cSrcweir     // members ----------------------------------------------------------------
377cdf0e10cSrcweir 
378cdf0e10cSrcweir     /** The parent accessible object. */
379cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
380cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible > mxParent;
381cdf0e10cSrcweir     /** The VCL BrowseBox control. */
382cdf0e10cSrcweir     ::svt::IAccessibleTableProvider* mpBrowseBox;
383cdf0e10cSrcweir 
384cdf0e10cSrcweir 	/** This is the window which get all the nice focus events
385cdf0e10cSrcweir 	*/
386cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xFocusWindow;
387cdf0e10cSrcweir 
388cdf0e10cSrcweir private:
389cdf0e10cSrcweir     /** Localized name. */
390cdf0e10cSrcweir     ::rtl::OUString maName;
391cdf0e10cSrcweir     /** Localized description text. */
392cdf0e10cSrcweir     ::rtl::OUString maDescription;
393cdf0e10cSrcweir 
394cdf0e10cSrcweir     /** The type of this object (for names, descriptions, state sets, ...). */
395cdf0e10cSrcweir     ::svt::AccessibleBrowseBoxObjType meObjType;
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 	::comphelper::AccessibleEventNotifier::TClientId	m_aClientId;
398cdf0e10cSrcweir };
399cdf0e10cSrcweir 
400cdf0e10cSrcweir // ============================================================================
401cdf0e10cSrcweir // a version of AccessibleBrowseBoxBase which implements not only the XAccessibleContext,
402cdf0e10cSrcweir // but also the XAccessible
403cdf0e10cSrcweir 
404cdf0e10cSrcweir typedef ::cppu::ImplHelper1	<	::com::sun::star::accessibility::XAccessible
405cdf0e10cSrcweir 							>	BrowseBoxAccessibleElement_Base;
406cdf0e10cSrcweir 
407cdf0e10cSrcweir class BrowseBoxAccessibleElement
408cdf0e10cSrcweir 			:public AccessibleBrowseBoxBase
409cdf0e10cSrcweir 			,public BrowseBoxAccessibleElement_Base
410cdf0e10cSrcweir {
411cdf0e10cSrcweir protected:
412cdf0e10cSrcweir     /** Constructor sets specified name and description. If the constant of a
413cdf0e10cSrcweir         text is BBTEXT_NONE, the derived class has to set the text via
414cdf0e10cSrcweir         implSetName() and implSetDescription() (in Ctor) or later via
415cdf0e10cSrcweir         setAccessibleName() and setAccessibleDescription() (these methods
416cdf0e10cSrcweir         notify the listeners about the change).
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 		@param rxParent  XAccessible interface of the parent object.
419cdf0e10cSrcweir         @param rBrowseBox  The BrowseBox control.
420cdf0e10cSrcweir         @param eNameText  The constant for the name text.
421cdf0e10cSrcweir         @param eDescrText  The constant for the description text.
422cdf0e10cSrcweir 	*/
423cdf0e10cSrcweir     BrowseBoxAccessibleElement(
424cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
425cdf0e10cSrcweir             ::com::sun::star::accessibility::XAccessible >& rxParent,
426cdf0e10cSrcweir         ::svt::IAccessibleTableProvider&                  rBrowseBox,
427cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow,
428cdf0e10cSrcweir         ::svt::AccessibleBrowseBoxObjType  eObjType );
429cdf0e10cSrcweir 
430cdf0e10cSrcweir     /** Constructor sets specified name and description.
431cdf0e10cSrcweir 
432cdf0e10cSrcweir 		@param rxParent  XAccessible interface of the parent object.
433cdf0e10cSrcweir         @param rBrowseBox  The BrowseBox control.
434cdf0e10cSrcweir         @param rName  The name of this object.
435cdf0e10cSrcweir         @param rDescription  The description text of this object.
436cdf0e10cSrcweir 	*/
437cdf0e10cSrcweir     BrowseBoxAccessibleElement(
438cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
439cdf0e10cSrcweir             ::com::sun::star::accessibility::XAccessible >& rxParent,
440cdf0e10cSrcweir         ::svt::IAccessibleTableProvider&                  rBrowseBox,
441cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow,
442cdf0e10cSrcweir         ::svt::AccessibleBrowseBoxObjType  eObjType,
443cdf0e10cSrcweir         const ::rtl::OUString&      rName,
444cdf0e10cSrcweir         const ::rtl::OUString&      rDescription );
445cdf0e10cSrcweir 
446cdf0e10cSrcweir public:
447cdf0e10cSrcweir 	// XInterface
448cdf0e10cSrcweir 	DECLARE_XINTERFACE( )
449cdf0e10cSrcweir 	// XTypeProvider
450cdf0e10cSrcweir 	DECLARE_XTYPEPROVIDER( )
451cdf0e10cSrcweir 
452cdf0e10cSrcweir protected:
453cdf0e10cSrcweir     virtual ~BrowseBoxAccessibleElement();
454cdf0e10cSrcweir 
455cdf0e10cSrcweir protected:
456cdf0e10cSrcweir 	// XAccessible ------------------------------------------------------------
457cdf0e10cSrcweir 
458cdf0e10cSrcweir 	/** @return  The XAccessibleContext interface of this object. */
459cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference<
460cdf0e10cSrcweir 		::com::sun::star::accessibility::XAccessibleContext > SAL_CALL
461cdf0e10cSrcweir 	getAccessibleContext()
462cdf0e10cSrcweir 		throw ( ::com::sun::star::uno::RuntimeException );
463cdf0e10cSrcweir 
464cdf0e10cSrcweir private:
465cdf0e10cSrcweir 	BrowseBoxAccessibleElement();												// never implemented
466cdf0e10cSrcweir 	BrowseBoxAccessibleElement( const BrowseBoxAccessibleElement& );			// never implemented
467cdf0e10cSrcweir 	BrowseBoxAccessibleElement& operator=( const BrowseBoxAccessibleElement& );	// never implemented
468cdf0e10cSrcweir };
469cdf0e10cSrcweir 
470cdf0e10cSrcweir // ============================================================================
471cdf0e10cSrcweir // a helper class for protecting methods which need to lock the solar mutex in addition to the own mutex
472cdf0e10cSrcweir 
473cdf0e10cSrcweir typedef ::osl::MutexGuard OslMutexGuard;
474cdf0e10cSrcweir 
475cdf0e10cSrcweir class SolarMethodGuard : public BBSolarGuard, public OslMutexGuard
476cdf0e10cSrcweir {
477cdf0e10cSrcweir public:
SolarMethodGuard(AccessibleBrowseBoxBase & _rOwner,bool _bEnsureAlive=true)478cdf0e10cSrcweir 	inline SolarMethodGuard( AccessibleBrowseBoxBase& _rOwner, bool _bEnsureAlive = true )
479cdf0e10cSrcweir 		:BBSolarGuard( )
480cdf0e10cSrcweir 		,OslMutexGuard( _rOwner.getMutex( AccessibleBrowseBoxBase::AccessControl() ) )
481cdf0e10cSrcweir 	{
482cdf0e10cSrcweir 		if ( _bEnsureAlive )
483cdf0e10cSrcweir 			_rOwner.ensureIsAlive( AccessibleBrowseBoxBase::AccessControl() );
484cdf0e10cSrcweir 	}
485cdf0e10cSrcweir };
486cdf0e10cSrcweir 
487cdf0e10cSrcweir // inlines --------------------------------------------------------------------
488cdf0e10cSrcweir 
getType() const489cdf0e10cSrcweir inline ::svt::AccessibleBrowseBoxObjType AccessibleBrowseBoxBase::getType() const
490cdf0e10cSrcweir {
491cdf0e10cSrcweir     return meObjType;
492cdf0e10cSrcweir }
493cdf0e10cSrcweir 
getOslMutex()494cdf0e10cSrcweir inline ::osl::Mutex& AccessibleBrowseBoxBase::getOslMutex()
495cdf0e10cSrcweir {
496cdf0e10cSrcweir     return m_aMutex;
497cdf0e10cSrcweir }
498cdf0e10cSrcweir 
getOslGlobalMutex()499cdf0e10cSrcweir inline ::osl::Mutex* AccessibleBrowseBoxBase::getOslGlobalMutex()
500cdf0e10cSrcweir {
501cdf0e10cSrcweir     return ::osl::Mutex::getGlobalMutex();
502cdf0e10cSrcweir }
503cdf0e10cSrcweir 
implSetName(const::rtl::OUString & rName)504cdf0e10cSrcweir inline void AccessibleBrowseBoxBase::implSetName(
505cdf0e10cSrcweir         const ::rtl::OUString& rName )
506cdf0e10cSrcweir {
507cdf0e10cSrcweir     maName = rName;
508cdf0e10cSrcweir }
509cdf0e10cSrcweir 
implSetDescription(const::rtl::OUString & rDescription)510cdf0e10cSrcweir inline void AccessibleBrowseBoxBase::implSetDescription(
511cdf0e10cSrcweir         const ::rtl::OUString& rDescription )
512cdf0e10cSrcweir {
513cdf0e10cSrcweir     maDescription = rDescription;
514cdf0e10cSrcweir }
515cdf0e10cSrcweir 
516cdf0e10cSrcweir // ============================================================================
517cdf0e10cSrcweir 
518cdf0e10cSrcweir } // namespace accessibility
519cdf0e10cSrcweir 
520cdf0e10cSrcweir // ============================================================================
521cdf0e10cSrcweir 
522cdf0e10cSrcweir #endif
523cdf0e10cSrcweir 
524