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 #ifndef INCLUDED_SVX_SOURCE_INC_CHARMAPACC_HXX
21 #define INCLUDED_SVX_SOURCE_INC_CHARMAPACC_HXX
23 #include <osl/mutex.hxx>
24 #include <vcl/image.hxx>
25 #include <comphelper/accessibleselectionhelper.hxx>
26 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
33 typedef ::cppu::ImplHelper1
< ::com::sun::star::accessibility::XAccessible
34 > OAccessibleHelper_Base_2
;
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.
40 class SvxShowCharSetVirtualAcc
: public ::comphelper::OAccessibleComponentHelper
,
41 public OAccessibleHelper_Base_2
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
47 virtual ~SvxShowCharSetVirtualAcc();
49 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
51 virtual ::com::sun::star::awt::Rectangle
implGetBounds( ) throw (::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
53 SvxShowCharSetVirtualAcc( SvxShowCharSet
* pParent
);
57 DECLARE_XTYPEPROVIDER( )
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
;
73 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
;
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
85 // simple access methods
86 inline SvxShowCharSetAcc
* getTable() const { return m_pTable
; }
87 inline SvxShowCharSet
* getCharSetControl() const { return mpParent
; }
91 class SvxShowCharSetItemAcc
;
93 // - SvxShowCharSetItem -
95 /** Simple struct to hold some information about the single items of the table.
97 struct SvxShowCharSetItem
99 SvxShowCharSet
& mrParent
;
103 SvxShowCharSetItemAcc
* m_pItem
;
104 SvxShowCharSetAcc
* m_pParent
;
105 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> m_xAcc
;
107 SvxShowCharSetItem( SvxShowCharSet
& rParent
,SvxShowCharSetAcc
* _pParent
,sal_uInt16 _nPos
);
108 ~SvxShowCharSetItem();
110 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> GetAccessible();
111 void ClearAccessible();
116 typedef ::cppu::ImplHelper2
< ::com::sun::star::accessibility::XAccessible
,
117 ::com::sun::star::accessibility::XAccessibleTable
118 > OAccessibleHelper_Base
;
120 // - SvxShowCharSetAcc -
122 /** The table implemtentation of the vcl control.
125 class SvxShowCharSetAcc
: public ::comphelper::OAccessibleSelectionHelper
,
126 public OAccessibleHelper_Base
128 ::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> > m_aChildren
;
129 SvxShowCharSetVirtualAcc
* m_pParent
; // the virtual parent
131 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
133 SvxShowCharSetAcc( SvxShowCharSetVirtualAcc
* _pParent
);
135 DECLARE_XINTERFACE( )
136 DECLARE_XTYPEPROVIDER( )
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
;
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
;
153 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
;
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
;
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
) SAL_OVERRIDE
;
197 // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
199 implSelect( sal_Int32 nAccessibleChildIndex
, bool bSelect
)
200 throw (css::lang::IndexOutOfBoundsException
,
201 css::uno::RuntimeException
,
202 std::exception
) SAL_OVERRIDE
;
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
;
210 // - SvxShowCharSetItemAcc -
212 /** The child implementation of the table.
214 class SvxShowCharSetItemAcc
: public ::comphelper::OAccessibleComponentHelper
,
215 public OAccessibleHelper_Base_2
218 SvxShowCharSetItem
* mpParent
;
220 virtual ~SvxShowCharSetItemAcc();
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
;
228 DECLARE_XINTERFACE( )
229 DECLARE_XTYPEPROVIDER( )
231 SvxShowCharSetItemAcc( SvxShowCharSetItem
* pParent
);
233 void ParentDestroyed();
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
;
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
;
250 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; }
252 virtual sal_Int32 SAL_CALL
getForeground( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
{ return mpParent
->m_pParent
->getForeground(); }
253 virtual sal_Int32 SAL_CALL
getBackground( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
{ return mpParent
->m_pParent
->getBackground(); }
255 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
261 NotifyAccessibleEvent(_nEventId
,_rOldValue
,_rNewValue
);
267 #endif // INCLUDED_SVX_SOURCE_INC_CHARMAPACC_HXX
269 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */