xref: /aoo41x/main/svx/source/inc/charmapacc.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <vos/mutex.hxx>
29 #include <tools/list.hxx>
30 #include <tools/color.hxx>
31 #include <tools/string.hxx>
32 #ifndef _IMAGE_HXX
33 #include <vcl/image.hxx>
34 #endif
35 #include <rtl/uuid.h>
36 #include <comphelper/accessibleselectionhelper.hxx>
37 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
38 
39 #include <vector>
40 class SvxShowCharSet;
41 
42 namespace svx
43 {
44 	typedef	::cppu::ImplHelper1	<	::com::sun::star::accessibility::XAccessible
45 								>	OAccessibleHelper_Base_2;
46 
47 	class SvxShowCharSetAcc;
48 	/** The class SvxShowCharSetVirtualAcc is used as a virtual class which contains the table and the scrollbar.
49 		In the vcl control, the table and the scrollbar exists in one class. This is not feasible for the accessibility api.
50 	*/
51 	class SvxShowCharSetVirtualAcc : public ::comphelper::OAccessibleComponentHelper,
52 									 public OAccessibleHelper_Base_2
53 	{
54 		SvxShowCharSet*		mpParent; // the vcl control
55 		SvxShowCharSetAcc*	m_pTable; // the table, which holds the characters shown by the vcl control
56 		::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xAcc; // the ref to the table
57 	protected:
58 		virtual ~SvxShowCharSetVirtualAcc();
59 
60 		virtual void SAL_CALL disposing();
61 
62 		virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds(  ) throw (::com::sun::star::uno::RuntimeException);
63 	public:
64 		SvxShowCharSetVirtualAcc( SvxShowCharSet* pParent );
65 
66 		// XInterface
67 		DECLARE_XINTERFACE( )
68 		DECLARE_XTYPEPROVIDER( )
69 
70 		// XAccessibleComponent
71 		virtual void SAL_CALL grabFocus(  ) throw (::com::sun::star::uno::RuntimeException);
72 		virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding(  ) throw (::com::sun::star::uno::RuntimeException);
73 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
74 		//OAccessibleContextHelper
75 		// XAccessibleContext - still waiting to be overwritten
76 		virtual sal_Int32 SAL_CALL getAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
77 		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);
78 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent(  ) throw (::com::sun::star::uno::RuntimeException);
79 		virtual sal_Int16 SAL_CALL getAccessibleRole(  ) throw (::com::sun::star::uno::RuntimeException);
80 		virtual ::rtl::OUString SAL_CALL getAccessibleDescription(  ) throw (::com::sun::star::uno::RuntimeException);
81 		virtual ::rtl::OUString SAL_CALL getAccessibleName(  ) throw (::com::sun::star::uno::RuntimeException);
82 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) throw (::com::sun::star::uno::RuntimeException);
83 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) throw (::com::sun::star::uno::RuntimeException);
84 
85 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext(  ) throw (::com::sun::star::uno::RuntimeException) { return this; }
86 		virtual sal_Int32 SAL_CALL getForeground(  ) throw (::com::sun::star::uno::RuntimeException);
87 		virtual sal_Int32 SAL_CALL getBackground(  ) throw (::com::sun::star::uno::RuntimeException);
88 
89 
90 		// call the fireEvent method from the table when it exists.
91 		void SAL_CALL fireEvent(
92 					const sal_Int16 _nEventId,
93 					const ::com::sun::star::uno::Any& _rOldValue,
94 					const ::com::sun::star::uno::Any& _rNewValue
95 				);
96 
97 		// simple access methods
98 		inline SvxShowCharSetAcc*	getTable() const { return m_pTable; }
99 		inline SvxShowCharSet* getCharSetControl() const { return mpParent; }
100 	};
101 
102 
103 	class SvxShowCharSetItemAcc;
104 	// ----------------
105 	// - SvxShowCharSetItem -
106 	// ----------------
107 	/** Simple struct to hold some information about the single items of the table.
108 	*/
109 	struct SvxShowCharSetItem
110 	{
111 		SvxShowCharSet&				mrParent;
112 		sal_uInt16						mnId;
113 		XubString					maText;
114 		Rectangle					maRect;
115 		SvxShowCharSetItemAcc*		m_pItem;
116 		SvxShowCharSetAcc*			m_pParent;
117 		::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xAcc;
118 
119 		SvxShowCharSetItem( SvxShowCharSet& rParent,SvxShowCharSetAcc*	_pParent,sal_uInt16 _nPos );
120 		~SvxShowCharSetItem();
121 
122 		::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >    GetAccessible();
123 		 void                                                                                       ClearAccessible();
124 	};
125 
126 	// -----------------------------------------------------------------------------
127 
128 	typedef	::cppu::ImplHelper2	<	::com::sun::star::accessibility::XAccessible,
129 									::com::sun::star::accessibility::XAccessibleTable
130 								>	OAccessibleHelper_Base;
131 	// ---------------
132 	// - SvxShowCharSetAcc -
133 	// ---------------
134 	/** The table implemtentation of the vcl control.
135 	*/
136 
137 	class SvxShowCharSetAcc : public ::comphelper::OAccessibleSelectionHelper,
138 							  public OAccessibleHelper_Base
139 	{
140 		::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > > m_aChildren;
141 		SvxShowCharSetVirtualAcc* m_pParent; // the virtual parent
142 	protected:
143 		virtual void SAL_CALL disposing();
144 	public:
145 		SvxShowCharSetAcc( SvxShowCharSetVirtualAcc* _pParent );
146 
147 		DECLARE_XINTERFACE( )
148 		DECLARE_XTYPEPROVIDER( )
149 
150 		// XAccessibleComponent
151 		virtual void SAL_CALL grabFocus(  ) throw (::com::sun::star::uno::RuntimeException);
152 		virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding(  ) throw (::com::sun::star::uno::RuntimeException);
153 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
154 
155 		//OAccessibleContextHelper
156 		// XAccessibleContext - still waiting to be overwritten
157 		virtual sal_Int32 SAL_CALL getAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
158 		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);
159 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent(  ) throw (::com::sun::star::uno::RuntimeException);
160 		virtual sal_Int16 SAL_CALL getAccessibleRole(  ) throw (::com::sun::star::uno::RuntimeException);
161 		virtual ::rtl::OUString SAL_CALL getAccessibleDescription(  ) throw (::com::sun::star::uno::RuntimeException);
162 		virtual ::rtl::OUString SAL_CALL getAccessibleName(  ) throw (::com::sun::star::uno::RuntimeException);
163 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) throw (::com::sun::star::uno::RuntimeException);
164 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) throw (::com::sun::star::uno::RuntimeException);
165 
166 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext(  ) throw (::com::sun::star::uno::RuntimeException) { return this; }
167 		virtual sal_Int32 SAL_CALL getForeground(  ) throw (::com::sun::star::uno::RuntimeException);
168 		virtual sal_Int32 SAL_CALL getBackground(  ) throw (::com::sun::star::uno::RuntimeException);
169 
170 		// XAccessibleTable
171 		virtual sal_Int32 SAL_CALL getAccessibleRowCount(  ) throw (::com::sun::star::uno::RuntimeException);
172 		virtual sal_Int32 SAL_CALL getAccessibleColumnCount(  ) throw (::com::sun::star::uno::RuntimeException);
173 		virtual ::rtl::OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
174 		virtual ::rtl::OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
175 		virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
176 		virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
177 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders(  ) throw (::com::sun::star::uno::RuntimeException);
178 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders(  ) throw (::com::sun::star::uno::RuntimeException);
179 		virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows(  ) throw (::com::sun::star::uno::RuntimeException);
180 		virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns(  ) throw (::com::sun::star::uno::RuntimeException);
181 		virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
182 		virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
183 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
184 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleCaption(  ) throw (::com::sun::star::uno::RuntimeException);
185 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleSummary(  ) throw (::com::sun::star::uno::RuntimeException);
186 		virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
187 		virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
188 		virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
189 		virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
190 
191 
192 		inline void SAL_CALL fireEvent(
193 					const sal_Int16 _nEventId,
194 					const ::com::sun::star::uno::Any& _rOldValue,
195 					const ::com::sun::star::uno::Any& _rNewValue
196 				)
197 		{
198 			NotifyAccessibleEvent(_nEventId,_rOldValue,_rNewValue);
199 		}
200 	protected:
201 
202 		virtual ~SvxShowCharSetAcc();
203 
204 		// OCommonAccessibleSelection
205         // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
206 	    virtual sal_Bool
207             implIsSelected( sal_Int32 nAccessibleChildIndex )
208             throw (::com::sun::star::uno::RuntimeException);
209 
210 	    // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
211         virtual void
212             implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect )
213             throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
214 
215 		// OCommonAccessibleComponent
216 		/// implements the calculation of the bounding rectangle - still waiting to be overwritten
217 		virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds(  ) throw (::com::sun::star::uno::RuntimeException);
218 	};
219 
220 	// ----------------
221 	// - SvxShowCharSetItemAcc -
222 	// ----------------
223 	/** The child implementation of the table.
224 	*/
225 	class SvxShowCharSetItemAcc : public ::comphelper::OAccessibleComponentHelper,
226 								  public OAccessibleHelper_Base_2
227 	{
228 	private:
229 		SvxShowCharSetItem*	mpParent;
230 	protected:
231 		virtual ~SvxShowCharSetItemAcc();
232 
233 		// OCommonAccessibleComponent
234 		/// implements the calculation of the bounding rectangle - still waiting to be overwritten
235 		virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds(  ) throw (::com::sun::star::uno::RuntimeException);
236 	public:
237 
238 		// XInterface
239 		DECLARE_XINTERFACE( )
240 		DECLARE_XTYPEPROVIDER( )
241 
242 		SvxShowCharSetItemAcc( SvxShowCharSetItem* pParent );
243 
244 		void    ParentDestroyed();
245 
246 		// XAccessibleComponent
247 		virtual void SAL_CALL grabFocus(  ) throw (::com::sun::star::uno::RuntimeException);
248 		virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding(  ) throw (::com::sun::star::uno::RuntimeException);
249 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
250 
251 		//OAccessibleContextHelper
252 		// XAccessibleContext - still waiting to be overwritten
253 		virtual sal_Int32 SAL_CALL getAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
254 		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);
255 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent(  ) throw (::com::sun::star::uno::RuntimeException);
256 		virtual sal_Int16 SAL_CALL getAccessibleRole(  ) throw (::com::sun::star::uno::RuntimeException);
257 		virtual ::rtl::OUString SAL_CALL getAccessibleDescription(  ) throw (::com::sun::star::uno::RuntimeException);
258 		virtual ::rtl::OUString SAL_CALL getAccessibleName(  ) throw (::com::sun::star::uno::RuntimeException);
259 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) throw (::com::sun::star::uno::RuntimeException);
260 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) throw (::com::sun::star::uno::RuntimeException);
261 
262 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext(  ) throw (::com::sun::star::uno::RuntimeException) { return this; }
263 
264 		virtual sal_Int32 SAL_CALL getForeground(  ) throw (::com::sun::star::uno::RuntimeException) { return mpParent->m_pParent->getForeground(); }
265 		virtual sal_Int32 SAL_CALL getBackground(  ) throw (::com::sun::star::uno::RuntimeException) { return mpParent->m_pParent->getBackground(); }
266 
267 		inline void SAL_CALL fireEvent(
268 					const sal_Int16 _nEventId,
269 					const ::com::sun::star::uno::Any& _rOldValue,
270 					const ::com::sun::star::uno::Any& _rNewValue
271 				)
272 		{
273 			NotifyAccessibleEvent(_nEventId,_rOldValue,_rNewValue);
274 		}
275 	};
276 }
277 
278 
279