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