1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <osl/mutex.hxx>
21 #include <tools/string.hxx>
22 #include <vcl/image.hxx>
23 #include <comphelper/accessibleselectionhelper.hxx>
24 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
31 typedef ::cppu::ImplHelper1
< ::com::sun::star::accessibility::XAccessible
32 > OAccessibleHelper_Base_2
;
34 class SvxShowCharSetAcc
;
35 /** The class SvxShowCharSetVirtualAcc is used as a virtual class which contains the table and the scrollbar.
36 In the vcl control, the table and the scrollbar exists in one class. This is not feasible for the accessibility api.
38 class SvxShowCharSetVirtualAcc
: public ::comphelper::OAccessibleComponentHelper
,
39 public OAccessibleHelper_Base_2
41 SvxShowCharSet
* mpParent
; // the vcl control
42 SvxShowCharSetAcc
* m_pTable
; // the table, which holds the characters shown by the vcl control
43 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> m_xAcc
; // the ref to the table
45 virtual ~SvxShowCharSetVirtualAcc();
47 virtual void SAL_CALL
disposing();
49 virtual ::com::sun::star::awt::Rectangle SAL_CALL
implGetBounds( ) throw (::com::sun::star::uno::RuntimeException
);
51 SvxShowCharSetVirtualAcc( SvxShowCharSet
* pParent
);
55 DECLARE_XTYPEPROVIDER( )
57 // XAccessibleComponent
58 virtual void SAL_CALL
grabFocus( ) throw (::com::sun::star::uno::RuntimeException
);
59 virtual ::com::sun::star::uno::Any SAL_CALL
getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException
);
60 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
);
61 //OAccessibleContextHelper
62 // XAccessibleContext - still waiting to be overwritten
63 virtual sal_Int32 SAL_CALL
getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException
);
64 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
);
65 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException
);
66 virtual sal_Int16 SAL_CALL
getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException
);
67 virtual OUString SAL_CALL
getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException
);
68 virtual OUString SAL_CALL
getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException
);
69 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException
);
70 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleStateSet
> SAL_CALL
getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException
);
72 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException
) { return this; }
73 virtual sal_Int32 SAL_CALL
getForeground( ) throw (::com::sun::star::uno::RuntimeException
);
74 virtual sal_Int32 SAL_CALL
getBackground( ) throw (::com::sun::star::uno::RuntimeException
);
77 // call the fireEvent method from the table when it exists.
78 void SAL_CALL
fireEvent(
79 const sal_Int16 _nEventId
,
80 const ::com::sun::star::uno::Any
& _rOldValue
,
81 const ::com::sun::star::uno::Any
& _rNewValue
84 // simple access methods
85 inline SvxShowCharSetAcc
* getTable() const { return m_pTable
; }
86 inline SvxShowCharSet
* getCharSetControl() const { return mpParent
; }
90 class SvxShowCharSetItemAcc
;
92 // - SvxShowCharSetItem -
94 /** Simple struct to hold some information about the single items of the table.
96 struct SvxShowCharSetItem
98 SvxShowCharSet
& mrParent
;
102 SvxShowCharSetItemAcc
* m_pItem
;
103 SvxShowCharSetAcc
* m_pParent
;
104 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> m_xAcc
;
106 SvxShowCharSetItem( SvxShowCharSet
& rParent
,SvxShowCharSetAcc
* _pParent
,sal_uInt16 _nPos
);
107 ~SvxShowCharSetItem();
109 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> GetAccessible();
110 void ClearAccessible();
113 // -----------------------------------------------------------------------------
115 typedef ::cppu::ImplHelper2
< ::com::sun::star::accessibility::XAccessible
,
116 ::com::sun::star::accessibility::XAccessibleTable
117 > OAccessibleHelper_Base
;
119 // - SvxShowCharSetAcc -
121 /** The table implemtentation of the vcl control.
124 class SvxShowCharSetAcc
: public ::comphelper::OAccessibleSelectionHelper
,
125 public OAccessibleHelper_Base
127 ::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> > m_aChildren
;
128 SvxShowCharSetVirtualAcc
* m_pParent
; // the virtual parent
130 virtual void SAL_CALL
disposing();
132 SvxShowCharSetAcc( SvxShowCharSetVirtualAcc
* _pParent
);
134 DECLARE_XINTERFACE( )
135 DECLARE_XTYPEPROVIDER( )
137 // XAccessibleComponent
138 virtual void SAL_CALL
grabFocus( ) throw (::com::sun::star::uno::RuntimeException
);
139 virtual ::com::sun::star::uno::Any SAL_CALL
getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException
);
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
);
142 //OAccessibleContextHelper
143 // XAccessibleContext - still waiting to be overwritten
144 virtual sal_Int32 SAL_CALL
getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException
);
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
);
146 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException
);
147 virtual sal_Int16 SAL_CALL
getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException
);
148 virtual OUString SAL_CALL
getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException
);
149 virtual OUString SAL_CALL
getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException
);
150 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException
);
151 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleStateSet
> SAL_CALL
getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException
);
153 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException
) { return this; }
154 virtual sal_Int32 SAL_CALL
getForeground( ) throw (::com::sun::star::uno::RuntimeException
);
155 virtual sal_Int32 SAL_CALL
getBackground( ) throw (::com::sun::star::uno::RuntimeException
);
158 virtual sal_Int32 SAL_CALL
getAccessibleRowCount( ) throw (::com::sun::star::uno::RuntimeException
);
159 virtual sal_Int32 SAL_CALL
getAccessibleColumnCount( ) throw (::com::sun::star::uno::RuntimeException
);
160 virtual OUString SAL_CALL
getAccessibleRowDescription( sal_Int32 nRow
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
161 virtual OUString SAL_CALL
getAccessibleColumnDescription( sal_Int32 nColumn
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
162 virtual sal_Int32 SAL_CALL
getAccessibleRowExtentAt( sal_Int32 nRow
, sal_Int32 nColumn
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
163 virtual sal_Int32 SAL_CALL
getAccessibleColumnExtentAt( sal_Int32 nRow
, sal_Int32 nColumn
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
164 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleTable
> SAL_CALL
getAccessibleRowHeaders( ) throw (::com::sun::star::uno::RuntimeException
);
165 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleTable
> SAL_CALL
getAccessibleColumnHeaders( ) throw (::com::sun::star::uno::RuntimeException
);
166 virtual ::com::sun::star::uno::Sequence
< sal_Int32
> SAL_CALL
getSelectedAccessibleRows( ) throw (::com::sun::star::uno::RuntimeException
);
167 virtual ::com::sun::star::uno::Sequence
< sal_Int32
> SAL_CALL
getSelectedAccessibleColumns( ) throw (::com::sun::star::uno::RuntimeException
);
168 virtual sal_Bool SAL_CALL
isAccessibleRowSelected( sal_Int32 nRow
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
169 virtual sal_Bool SAL_CALL
isAccessibleColumnSelected( sal_Int32 nColumn
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
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
);
171 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleCaption( ) throw (::com::sun::star::uno::RuntimeException
);
172 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleSummary( ) throw (::com::sun::star::uno::RuntimeException
);
173 virtual sal_Bool SAL_CALL
isAccessibleSelected( sal_Int32 nRow
, sal_Int32 nColumn
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
174 virtual sal_Int32 SAL_CALL
getAccessibleIndex( sal_Int32 nRow
, sal_Int32 nColumn
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
175 virtual sal_Int32 SAL_CALL
getAccessibleRow( sal_Int32 nChildIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
176 virtual sal_Int32 SAL_CALL
getAccessibleColumn( sal_Int32 nChildIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
179 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
185 NotifyAccessibleEvent(_nEventId
,_rOldValue
,_rNewValue
);
189 virtual ~SvxShowCharSetAcc();
191 // OCommonAccessibleSelection
192 // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
194 implIsSelected( sal_Int32 nAccessibleChildIndex
)
195 throw (::com::sun::star::uno::RuntimeException
);
197 // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
199 implSelect( sal_Int32 nAccessibleChildIndex
, sal_Bool bSelect
)
200 throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
202 // OCommonAccessibleComponent
203 /// implements the calculation of the bounding rectangle - still waiting to be overwritten
204 virtual ::com::sun::star::awt::Rectangle SAL_CALL
implGetBounds( ) throw (::com::sun::star::uno::RuntimeException
);
208 // - SvxShowCharSetItemAcc -
210 /** The child implementation of the table.
212 class SvxShowCharSetItemAcc
: public ::comphelper::OAccessibleComponentHelper
,
213 public OAccessibleHelper_Base_2
216 SvxShowCharSetItem
* mpParent
;
218 virtual ~SvxShowCharSetItemAcc();
220 // OCommonAccessibleComponent
221 /// implements the calculation of the bounding rectangle - still waiting to be overwritten
222 virtual ::com::sun::star::awt::Rectangle SAL_CALL
implGetBounds( ) throw (::com::sun::star::uno::RuntimeException
);
226 DECLARE_XINTERFACE( )
227 DECLARE_XTYPEPROVIDER( )
229 SvxShowCharSetItemAcc( SvxShowCharSetItem
* pParent
);
231 void ParentDestroyed();
233 // XAccessibleComponent
234 virtual void SAL_CALL
grabFocus( ) throw (::com::sun::star::uno::RuntimeException
);
235 virtual ::com::sun::star::uno::Any SAL_CALL
getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException
);
236 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
);
238 //OAccessibleContextHelper
239 // XAccessibleContext - still waiting to be overwritten
240 virtual sal_Int32 SAL_CALL
getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException
);
241 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
);
242 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException
);
243 virtual sal_Int16 SAL_CALL
getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException
);
244 virtual OUString SAL_CALL
getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException
);
245 virtual OUString SAL_CALL
getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException
);
246 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException
);
247 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleStateSet
> SAL_CALL
getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException
);
249 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException
) { return this; }
251 virtual sal_Int32 SAL_CALL
getForeground( ) throw (::com::sun::star::uno::RuntimeException
) { return mpParent
->m_pParent
->getForeground(); }
252 virtual sal_Int32 SAL_CALL
getBackground( ) throw (::com::sun::star::uno::RuntimeException
) { return mpParent
->m_pParent
->getBackground(); }
254 inline void SAL_CALL
fireEvent(
255 const sal_Int16 _nEventId
,
256 const ::com::sun::star::uno::Any
& _rOldValue
,
257 const ::com::sun::star::uno::Any
& _rNewValue
260 NotifyAccessibleEvent(_nEventId
,_rOldValue
,_rNewValue
);
266 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */