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_ACCESSIBLEBROWSEBOX_HXX
26cdf0e10cSrcweir #define ACCESSIBILITY_EXT_ACCESSIBLEBROWSEBOX_HXX
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <accessibility/extended/AccessibleBrowseBoxBase.hxx>
29cdf0e10cSrcweir #include <cppuhelper/weakref.hxx>
30cdf0e10cSrcweir #include <svtools/accessibletableprovider.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <memory>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir // ============================================================================
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace accessibility {
38cdf0e10cSrcweir 
39cdf0e10cSrcweir 	class AccessibleBrowseBoxImpl;
40cdf0e10cSrcweir 	class AccessibleBrowseBoxTable;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir // ============================================================================
43cdf0e10cSrcweir 
44cdf0e10cSrcweir /** This class represents the complete accessible BrowseBox object. */
45cdf0e10cSrcweir class AccessibleBrowseBox : public AccessibleBrowseBoxBase
46cdf0e10cSrcweir {
47cdf0e10cSrcweir     friend class AccessibleBrowseBoxAccess;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir protected:
50cdf0e10cSrcweir     AccessibleBrowseBox(
51cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent,
52cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxCreator,
53cdf0e10cSrcweir         ::svt::IAccessibleTableProvider& _rBrowseBox
54cdf0e10cSrcweir     );
55cdf0e10cSrcweir 
56cdf0e10cSrcweir     virtual ~AccessibleBrowseBox();
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     /** sets the XAccessible which created the context
59cdf0e10cSrcweir 
60cdf0e10cSrcweir         <p>To be called only once, and only if in the ctor NULL was passed.</p>
61cdf0e10cSrcweir     */
62cdf0e10cSrcweir     void    setCreator(
63cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxCreator
64cdf0e10cSrcweir     );
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     /** Cleans up members. */
67cdf0e10cSrcweir     using AccessibleBrowseBoxBase::disposing;
68cdf0e10cSrcweir     virtual void SAL_CALL disposing();
69cdf0e10cSrcweir 
70cdf0e10cSrcweir protected:
71cdf0e10cSrcweir     // XAccessibleContext -----------------------------------------------------
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     /** @return  The count of visible children. */
74cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getAccessibleChildCount()
75cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     /** @return  The XAccessible interface of the specified child. */
78cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
79cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible > SAL_CALL
80cdf0e10cSrcweir     getAccessibleChild( sal_Int32 nChildIndex )
81cdf0e10cSrcweir         throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
82cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException );
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     /** @return  The role of this object (a table). */
85cdf0e10cSrcweir //    virtual sal_Int16 SAL_CALL getAccessibleRole()
86cdf0e10cSrcweir //        throw ( ::com::sun::star::uno::RuntimeException );
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     // XAccessibleComponent ---------------------------------------------------
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     /** @return
91cdf0e10cSrcweir 			The accessible child rendered under the given point.
92cdf0e10cSrcweir 	*/
93cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
94cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible > SAL_CALL
95cdf0e10cSrcweir     getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint )
96cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     /** Grabs the focus to the BrowseBox. */
99cdf0e10cSrcweir     virtual void SAL_CALL grabFocus()
100cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     /** @return  The key bindings associated with this object. */
103cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding()
104cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     // XServiceInfo -----------------------------------------------------------
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     /** @return
109cdf0e10cSrcweir 			The name of this class.
110cdf0e10cSrcweir 	*/
111cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName()
112cdf0e10cSrcweir         throw ( ::com::sun::star::uno::RuntimeException );
113cdf0e10cSrcweir 
114cdf0e10cSrcweir public:
115cdf0e10cSrcweir 	// helper functions
116cdf0e10cSrcweir 	/** commitHeaderBarEvent commit the event at all listeners of the column/row header bar
117cdf0e10cSrcweir 		@param nEventId
118cdf0e10cSrcweir 			the event id
119cdf0e10cSrcweir 		@param rNewValue
120cdf0e10cSrcweir 			the new value
121cdf0e10cSrcweir 		@param rOldValue
122cdf0e10cSrcweir 			the old value
123cdf0e10cSrcweir 	*/
124cdf0e10cSrcweir 	void commitHeaderBarEvent(sal_Int16 nEventId,
125cdf0e10cSrcweir             const ::com::sun::star::uno::Any& rNewValue,
126cdf0e10cSrcweir             const ::com::sun::star::uno::Any& rOldValue,sal_Bool _bColumnHeaderBar = sal_True);
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 	// helper functions
129cdf0e10cSrcweir 	/** commitTableEvent commit the event at all listeners of the table
130cdf0e10cSrcweir 		@param nEventId
131cdf0e10cSrcweir 			the event id
132cdf0e10cSrcweir 		@param rNewValue
133cdf0e10cSrcweir 			the new value
134cdf0e10cSrcweir 		@param rOldValue
135cdf0e10cSrcweir 			the old value
136cdf0e10cSrcweir 	*/
137cdf0e10cSrcweir 	void commitTableEvent(sal_Int16 nEventId,
138cdf0e10cSrcweir             const ::com::sun::star::uno::Any& rNewValue,
139cdf0e10cSrcweir             const ::com::sun::star::uno::Any& rOldValue);
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	/** returns the accessible object for the row or the column header bar
142cdf0e10cSrcweir 	*/
143cdf0e10cSrcweir 	inline ::com::sun::star::uno::Reference<
144cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible >
getHeaderBar(::svt::AccessibleBrowseBoxObjType _eObjType)145cdf0e10cSrcweir 		getHeaderBar( ::svt::AccessibleBrowseBoxObjType _eObjType )
146cdf0e10cSrcweir 		{
147cdf0e10cSrcweir 			return implGetHeaderBar(_eObjType);
148cdf0e10cSrcweir 		}
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	/** returns the accessible object for the table representation
151cdf0e10cSrcweir 	*/
152cdf0e10cSrcweir 	inline ::com::sun::star::uno::Reference<
153cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible >
getTable()154cdf0e10cSrcweir 		getTable( )
155cdf0e10cSrcweir 		{
156cdf0e10cSrcweir 			return implGetTable();
157cdf0e10cSrcweir 		}
158cdf0e10cSrcweir 
159cdf0e10cSrcweir protected:
160cdf0e10cSrcweir     // internal virtual methods -----------------------------------------------
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     /** @attention  This method requires locked mutex's and a living object.
163cdf0e10cSrcweir         @return  The bounding box (VCL rect.) relative to the parent window. */
164cdf0e10cSrcweir     virtual Rectangle implGetBoundingBox();
165cdf0e10cSrcweir     /** @attention  This method requires locked mutex's and a living object.
166cdf0e10cSrcweir         @return  The bounding box (VCL rect.) in screen coordinates. */
167cdf0e10cSrcweir     virtual Rectangle implGetBoundingBoxOnScreen();
168cdf0e10cSrcweir 
169cdf0e10cSrcweir     // internal helper methods ------------------------------------------------
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     /** This method creates (once) and returns the accessible data table child.
172cdf0e10cSrcweir         @attention  This method requires locked mutex's and a living object.
173cdf0e10cSrcweir         @return  The XAccessible interface of the data table. */
174cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
175cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible > implGetTable();
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     /** This method creates (once) and returns the specified header bar.
178cdf0e10cSrcweir         @attention  This method requires locked mutex's and a living object.
179cdf0e10cSrcweir         @return  The XAccessible interface of the header bar. */
180cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
181cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible >
182cdf0e10cSrcweir         implGetHeaderBar( ::svt::AccessibleBrowseBoxObjType eObjType );
183cdf0e10cSrcweir 
184cdf0e10cSrcweir     /** This method returns one of the children that are always present:
185cdf0e10cSrcweir         Data table, row and column header bar or corner control.
186cdf0e10cSrcweir         @attention  This method requires locked mutex's and a living object.
187cdf0e10cSrcweir         @return  The XAccessible interface of the specified child. */
188cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
189cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible >
190cdf0e10cSrcweir     implGetFixedChild( sal_Int32 nChildIndex );
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     /** This method creates and returns an accessible table.
193cdf0e10cSrcweir         @return  An AccessibleBrowseBoxTable. */
194cdf0e10cSrcweir     virtual AccessibleBrowseBoxTable*	createAccessibleTable();
195cdf0e10cSrcweir 
196cdf0e10cSrcweir private:
197cdf0e10cSrcweir     // members ----------------------------------------------------------------
198cdf0e10cSrcweir 	::std::auto_ptr< AccessibleBrowseBoxImpl > m_pImpl;
199cdf0e10cSrcweir };
200cdf0e10cSrcweir 
201cdf0e10cSrcweir // ============================================================================
202cdf0e10cSrcweir /** the XAccessible which creates/returns an AccessibleBrowseBox
203cdf0e10cSrcweir 
204cdf0e10cSrcweir     <p>The instance holds it's XAccessibleContext with a hard reference, while
205cdf0e10cSrcweir     the contxt holds this instance weak.</p>
206cdf0e10cSrcweir */
207cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1	<	::com::sun::star::accessibility::XAccessible
208cdf0e10cSrcweir 							    >	AccessibleBrowseBoxAccess_Base;
209cdf0e10cSrcweir 
210cdf0e10cSrcweir class AccessibleBrowseBoxAccess :public AccessibleBrowseBoxAccess_Base
211cdf0e10cSrcweir                                 ,public ::svt::IAccessibleBrowseBox
212cdf0e10cSrcweir {
213cdf0e10cSrcweir private:
214cdf0e10cSrcweir     ::osl::Mutex                m_aMutex;
215cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
216cdf0e10cSrcweir                                         m_xParent;
217cdf0e10cSrcweir     ::svt::IAccessibleTableProvider&    m_rBrowseBox;
218cdf0e10cSrcweir 
219cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
220cdf0e10cSrcweir                                 m_xContext;
221cdf0e10cSrcweir     AccessibleBrowseBox*        m_pContext;
222cdf0e10cSrcweir                                     // note that this pointer is valid as long as m_xContext is valid!
223cdf0e10cSrcweir 
224cdf0e10cSrcweir public:
225cdf0e10cSrcweir     AccessibleBrowseBoxAccess(
226cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent,
227cdf0e10cSrcweir         ::svt::IAccessibleTableProvider& _rBrowseBox
228cdf0e10cSrcweir     );
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     /// checks whether the accessible context is still alive
231cdf0e10cSrcweir     bool                            isContextAlive() const;
232cdf0e10cSrcweir 
233cdf0e10cSrcweir     /// returns the AccessibleContext belonging to this Accessible
getContext()234cdf0e10cSrcweir     inline AccessibleBrowseBox*            getContext()         { return m_pContext; }
getContext() const235cdf0e10cSrcweir     inline const AccessibleBrowseBox*      getContext() const   { return m_pContext; }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir protected:
238cdf0e10cSrcweir     virtual ~AccessibleBrowseBoxAccess();
239cdf0e10cSrcweir 
240cdf0e10cSrcweir     // XAccessible
241cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
242cdf0e10cSrcweir         SAL_CALL getAccessibleContext() throw ( ::com::sun::star::uno::RuntimeException );
243cdf0e10cSrcweir 
244cdf0e10cSrcweir     // IAccessibleBrowseBox
245cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
getMyself()246cdf0e10cSrcweir         getMyself()
247cdf0e10cSrcweir     {
248cdf0e10cSrcweir         return this;
249cdf0e10cSrcweir     }
250cdf0e10cSrcweir     void dispose();
isAlive() const251cdf0e10cSrcweir     virtual sal_Bool isAlive() const
252cdf0e10cSrcweir     {
253cdf0e10cSrcweir         return isContextAlive();
254cdf0e10cSrcweir     }
255cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
getHeaderBar(::svt::AccessibleBrowseBoxObjType _eObjType)256cdf0e10cSrcweir 		getHeaderBar( ::svt::AccessibleBrowseBoxObjType _eObjType )
257cdf0e10cSrcweir     {
258cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccessible;
259cdf0e10cSrcweir         AccessibleBrowseBox* pContext( getContext() );
260cdf0e10cSrcweir         if ( pContext )
261cdf0e10cSrcweir             xAccessible = pContext->getHeaderBar( _eObjType );
262cdf0e10cSrcweir         return xAccessible;
263cdf0e10cSrcweir     }
264cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
getTable()265cdf0e10cSrcweir         getTable()
266cdf0e10cSrcweir     {
267cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccessible;
268cdf0e10cSrcweir         AccessibleBrowseBox* pContext( getContext() );
269cdf0e10cSrcweir         if ( pContext )
270cdf0e10cSrcweir             xAccessible = pContext->getTable();
271cdf0e10cSrcweir         return xAccessible;
272cdf0e10cSrcweir     }
commitHeaderBarEvent(sal_Int16 nEventId,const::com::sun::star::uno::Any & rNewValue,const::com::sun::star::uno::Any & rOldValue,sal_Bool _bColumnHeaderBar)273cdf0e10cSrcweir 	virtual void commitHeaderBarEvent( sal_Int16 nEventId, const ::com::sun::star::uno::Any& rNewValue,
274cdf0e10cSrcweir         const ::com::sun::star::uno::Any& rOldValue, sal_Bool _bColumnHeaderBar )
275cdf0e10cSrcweir     {
276cdf0e10cSrcweir         AccessibleBrowseBox* pContext( getContext() );
277cdf0e10cSrcweir         if ( pContext )
278cdf0e10cSrcweir             pContext->commitHeaderBarEvent( nEventId, rNewValue, rOldValue, _bColumnHeaderBar );
279cdf0e10cSrcweir     }
commitTableEvent(sal_Int16 nEventId,const::com::sun::star::uno::Any & rNewValue,const::com::sun::star::uno::Any & rOldValue)280cdf0e10cSrcweir 	virtual void commitTableEvent( sal_Int16 nEventId,
281cdf0e10cSrcweir         const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue )
282cdf0e10cSrcweir     {
283cdf0e10cSrcweir         AccessibleBrowseBox* pContext( getContext() );
284cdf0e10cSrcweir         if ( pContext )
285cdf0e10cSrcweir             pContext->commitTableEvent( nEventId, rNewValue, rOldValue );
286cdf0e10cSrcweir     }
commitEvent(sal_Int16 nEventId,const::com::sun::star::uno::Any & rNewValue,const::com::sun::star::uno::Any & rOldValue)287cdf0e10cSrcweir     virtual void commitEvent( sal_Int16 nEventId,
288cdf0e10cSrcweir         const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue )
289cdf0e10cSrcweir     {
290cdf0e10cSrcweir         AccessibleBrowseBox* pContext( getContext() );
291cdf0e10cSrcweir         if ( pContext )
292cdf0e10cSrcweir             pContext->commitEvent( nEventId, rNewValue, rOldValue );
293cdf0e10cSrcweir     }
294cdf0e10cSrcweir 
295cdf0e10cSrcweir private:
296cdf0e10cSrcweir 	AccessibleBrowseBoxAccess();												// never implemented
297cdf0e10cSrcweir 	AccessibleBrowseBoxAccess( const AccessibleBrowseBoxAccess& );			    // never implemented
298cdf0e10cSrcweir 	AccessibleBrowseBoxAccess& operator=( const AccessibleBrowseBoxAccess& );	// never implemented
299cdf0e10cSrcweir };
300cdf0e10cSrcweir 
301cdf0e10cSrcweir // ============================================================================
302cdf0e10cSrcweir } // namespace accessibility
303cdf0e10cSrcweir 
304cdf0e10cSrcweir // ============================================================================
305cdf0e10cSrcweir 
306cdf0e10cSrcweir #endif
307cdf0e10cSrcweir 
308