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