1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: charmapacc.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <vos/mutex.hxx>
32 #include <tools/list.hxx>
33 #include <tools/color.hxx>
34 #include <tools/string.hxx>
36 #include <vcl/image.hxx>
39 #include <comphelper/accessibleselectionhelper.hxx>
40 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
47 typedef ::cppu::ImplHelper1
< ::com::sun::star::accessibility::XAccessible
48 > OAccessibleHelper_Base_2
;
50 class SvxShowCharSetAcc
;
51 /** The class SvxShowCharSetVirtualAcc is used as a virtual class which contains the table and the scrollbar.
52 In the vcl control, the table and the scrollbar exists in one class. This is not feasible for the accessibility api.
54 class SvxShowCharSetVirtualAcc
: public ::comphelper::OAccessibleComponentHelper
,
55 public OAccessibleHelper_Base_2
57 SvxShowCharSet
* mpParent
; // the vcl control
58 SvxShowCharSetAcc
* m_pTable
; // the table, which holds the characters shown by the vcl control
59 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> m_xAcc
; // the ref to the table
61 virtual ~SvxShowCharSetVirtualAcc();
63 virtual void SAL_CALL
disposing();
65 virtual ::com::sun::star::awt::Rectangle SAL_CALL
implGetBounds( ) throw (::com::sun::star::uno::RuntimeException
);
67 SvxShowCharSetVirtualAcc( SvxShowCharSet
* pParent
);
71 DECLARE_XTYPEPROVIDER( )
73 // XAccessibleComponent
74 virtual void SAL_CALL
grabFocus( ) throw (::com::sun::star::uno::RuntimeException
);
75 virtual ::com::sun::star::uno::Any SAL_CALL
getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException
);
76 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
);
77 //OAccessibleContextHelper
78 // XAccessibleContext - still waiting to be overwritten
79 virtual sal_Int32 SAL_CALL
getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException
);
80 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
);
81 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException
);
82 virtual sal_Int16 SAL_CALL
getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException
);
83 virtual ::rtl::OUString SAL_CALL
getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException
);
84 virtual ::rtl::OUString SAL_CALL
getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException
);
85 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException
);
86 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleStateSet
> SAL_CALL
getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException
);
88 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException
) { return this; }
89 virtual sal_Int32 SAL_CALL
getForeground( ) throw (::com::sun::star::uno::RuntimeException
);
90 virtual sal_Int32 SAL_CALL
getBackground( ) throw (::com::sun::star::uno::RuntimeException
);
93 // call the fireEvent method from the table when it exists.
94 void SAL_CALL
fireEvent(
95 const sal_Int16 _nEventId
,
96 const ::com::sun::star::uno::Any
& _rOldValue
,
97 const ::com::sun::star::uno::Any
& _rNewValue
100 // simple access methods
101 inline SvxShowCharSetAcc
* getTable() const { return m_pTable
; }
102 inline SvxShowCharSet
* getCharSetControl() const { return mpParent
; }
106 class SvxShowCharSetItemAcc
;
108 // - SvxShowCharSetItem -
110 /** Simple struct to hold some information about the single items of the table.
112 struct SvxShowCharSetItem
114 SvxShowCharSet
& mrParent
;
118 SvxShowCharSetItemAcc
* m_pItem
;
119 SvxShowCharSetAcc
* m_pParent
;
120 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> m_xAcc
;
122 SvxShowCharSetItem( SvxShowCharSet
& rParent
,SvxShowCharSetAcc
* _pParent
,USHORT _nPos
);
123 ~SvxShowCharSetItem();
125 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> GetAccessible();
126 void ClearAccessible();
129 // -----------------------------------------------------------------------------
131 typedef ::cppu::ImplHelper2
< ::com::sun::star::accessibility::XAccessible
,
132 ::com::sun::star::accessibility::XAccessibleTable
133 > OAccessibleHelper_Base
;
135 // - SvxShowCharSetAcc -
137 /** The table implemtentation of the vcl control.
140 class SvxShowCharSetAcc
: public ::comphelper::OAccessibleSelectionHelper
,
141 public OAccessibleHelper_Base
143 ::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> > m_aChildren
;
144 SvxShowCharSetVirtualAcc
* m_pParent
; // the virtual parent
146 virtual void SAL_CALL
disposing();
148 SvxShowCharSetAcc( SvxShowCharSetVirtualAcc
* _pParent
);
150 DECLARE_XINTERFACE( )
151 DECLARE_XTYPEPROVIDER( )
153 // XAccessibleComponent
154 virtual void SAL_CALL
grabFocus( ) throw (::com::sun::star::uno::RuntimeException
);
155 virtual ::com::sun::star::uno::Any SAL_CALL
getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException
);
156 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
);
158 //OAccessibleContextHelper
159 // XAccessibleContext - still waiting to be overwritten
160 virtual sal_Int32 SAL_CALL
getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException
);
161 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
);
162 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException
);
163 virtual sal_Int16 SAL_CALL
getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException
);
164 virtual ::rtl::OUString SAL_CALL
getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException
);
165 virtual ::rtl::OUString SAL_CALL
getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException
);
166 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException
);
167 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleStateSet
> SAL_CALL
getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException
);
169 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException
) { return this; }
170 virtual sal_Int32 SAL_CALL
getForeground( ) throw (::com::sun::star::uno::RuntimeException
);
171 virtual sal_Int32 SAL_CALL
getBackground( ) throw (::com::sun::star::uno::RuntimeException
);
174 virtual sal_Int32 SAL_CALL
getAccessibleRowCount( ) throw (::com::sun::star::uno::RuntimeException
);
175 virtual sal_Int32 SAL_CALL
getAccessibleColumnCount( ) throw (::com::sun::star::uno::RuntimeException
);
176 virtual ::rtl::OUString SAL_CALL
getAccessibleRowDescription( sal_Int32 nRow
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
177 virtual ::rtl::OUString SAL_CALL
getAccessibleColumnDescription( sal_Int32 nColumn
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
178 virtual sal_Int32 SAL_CALL
getAccessibleRowExtentAt( sal_Int32 nRow
, sal_Int32 nColumn
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
179 virtual sal_Int32 SAL_CALL
getAccessibleColumnExtentAt( 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::XAccessibleTable
> SAL_CALL
getAccessibleRowHeaders( ) throw (::com::sun::star::uno::RuntimeException
);
181 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleTable
> SAL_CALL
getAccessibleColumnHeaders( ) throw (::com::sun::star::uno::RuntimeException
);
182 virtual ::com::sun::star::uno::Sequence
< sal_Int32
> SAL_CALL
getSelectedAccessibleRows( ) throw (::com::sun::star::uno::RuntimeException
);
183 virtual ::com::sun::star::uno::Sequence
< sal_Int32
> SAL_CALL
getSelectedAccessibleColumns( ) throw (::com::sun::star::uno::RuntimeException
);
184 virtual sal_Bool SAL_CALL
isAccessibleRowSelected( sal_Int32 nRow
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
185 virtual sal_Bool SAL_CALL
isAccessibleColumnSelected( sal_Int32 nColumn
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
186 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
);
187 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleCaption( ) throw (::com::sun::star::uno::RuntimeException
);
188 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleSummary( ) throw (::com::sun::star::uno::RuntimeException
);
189 virtual sal_Bool SAL_CALL
isAccessibleSelected( sal_Int32 nRow
, sal_Int32 nColumn
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
190 virtual sal_Int32 SAL_CALL
getAccessibleIndex( sal_Int32 nRow
, sal_Int32 nColumn
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
191 virtual sal_Int32 SAL_CALL
getAccessibleRow( sal_Int32 nChildIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
192 virtual sal_Int32 SAL_CALL
getAccessibleColumn( sal_Int32 nChildIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
195 inline void SAL_CALL
fireEvent(
196 const sal_Int16 _nEventId
,
197 const ::com::sun::star::uno::Any
& _rOldValue
,
198 const ::com::sun::star::uno::Any
& _rNewValue
201 NotifyAccessibleEvent(_nEventId
,_rOldValue
,_rNewValue
);
205 virtual ~SvxShowCharSetAcc();
207 // OCommonAccessibleSelection
208 // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
210 implIsSelected( sal_Int32 nAccessibleChildIndex
)
211 throw (::com::sun::star::uno::RuntimeException
);
213 // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
215 implSelect( sal_Int32 nAccessibleChildIndex
, sal_Bool bSelect
)
216 throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
218 // OCommonAccessibleComponent
219 /// implements the calculation of the bounding rectangle - still waiting to be overwritten
220 virtual ::com::sun::star::awt::Rectangle SAL_CALL
implGetBounds( ) throw (::com::sun::star::uno::RuntimeException
);
224 // - SvxShowCharSetItemAcc -
226 /** The child implementation of the table.
228 class SvxShowCharSetItemAcc
: public ::comphelper::OAccessibleComponentHelper
,
229 public OAccessibleHelper_Base_2
232 SvxShowCharSetItem
* mpParent
;
234 virtual ~SvxShowCharSetItemAcc();
236 // OCommonAccessibleComponent
237 /// implements the calculation of the bounding rectangle - still waiting to be overwritten
238 virtual ::com::sun::star::awt::Rectangle SAL_CALL
implGetBounds( ) throw (::com::sun::star::uno::RuntimeException
);
242 DECLARE_XINTERFACE( )
243 DECLARE_XTYPEPROVIDER( )
245 SvxShowCharSetItemAcc( SvxShowCharSetItem
* pParent
);
247 void ParentDestroyed();
249 // XAccessibleComponent
250 virtual void SAL_CALL
grabFocus( ) throw (::com::sun::star::uno::RuntimeException
);
251 virtual ::com::sun::star::uno::Any SAL_CALL
getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException
);
252 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
);
254 //OAccessibleContextHelper
255 // XAccessibleContext - still waiting to be overwritten
256 virtual sal_Int32 SAL_CALL
getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException
);
257 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
);
258 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException
);
259 virtual sal_Int16 SAL_CALL
getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException
);
260 virtual ::rtl::OUString SAL_CALL
getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException
);
261 virtual ::rtl::OUString SAL_CALL
getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException
);
262 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException
);
263 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleStateSet
> SAL_CALL
getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException
);
265 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException
) { return this; }
267 virtual sal_Int32 SAL_CALL
getForeground( ) throw (::com::sun::star::uno::RuntimeException
) { return mpParent
->m_pParent
->getForeground(); }
268 virtual sal_Int32 SAL_CALL
getBackground( ) throw (::com::sun::star::uno::RuntimeException
) { return mpParent
->m_pParent
->getBackground(); }
270 inline void SAL_CALL
fireEvent(
271 const sal_Int16 _nEventId
,
272 const ::com::sun::star::uno::Any
& _rOldValue
,
273 const ::com::sun::star::uno::Any
& _rNewValue
276 NotifyAccessibleEvent(_nEventId
,_rOldValue
,_rNewValue
);