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 <config_feature_desktop.h>
22 #include <toolkit/awt/vclxwindows.hxx>
23 #include <toolkit/helper/accessiblefactory.hxx>
24 #include <vcl/accessiblefactory.hxx>
25 #include <standard/svtaccessiblenumericfield.hxx>
26 #include <standard/vclxaccessiblebutton.hxx>
27 #include <standard/vclxaccessiblecheckbox.hxx>
28 #include <standard/vclxaccessibledropdowncombobox.hxx>
29 #include <standard/vclxaccessiblecombobox.hxx>
30 #include <standard/vclxaccessibledropdownlistbox.hxx>
31 #include <standard/vclxaccessibleedit.hxx>
32 #include <standard/vclxaccessiblefixedhyperlink.hxx>
33 #include <standard/vclxaccessiblefixedtext.hxx>
34 #include <standard/vclxaccessibleheaderbar.hxx>
35 #include <standard/vclxaccessiblelistbox.hxx>
36 #include <standard/vclxaccessibleradiobutton.hxx>
37 #include <standard/vclxaccessiblescrollbar.hxx>
38 #include <standard/vclxaccessibletoolbox.hxx>
39 #include <toolkit/awt/vclxaccessiblecomponent.hxx>
40 #include <standard/vclxaccessiblestatusbar.hxx>
41 #include <standard/vclxaccessibletabcontrol.hxx>
42 #include <standard/vclxaccessibletabpagewindow.hxx>
43 #include <standard/vclxaccessiblemenubar.hxx>
44 #include <standard/vclxaccessiblepopupmenu.hxx>
45 #include <extended/accessibletablistbox.hxx>
46 #include <extended/AccessibleBrowseBox.hxx>
47 #include <extended/accessibleiconchoicectrl.hxx>
48 #include <extended/AccessibleIconView.hxx>
49 #include <extended/accessibletabbar.hxx>
50 #include <extended/accessiblelistbox.hxx>
51 #include <extended/AccessibleBrowseBoxHeaderBar.hxx>
52 #include <extended/textwindowaccessibility.hxx>
53 #include <extended/AccessibleBrowseBoxTableCell.hxx>
54 #include <extended/AccessibleBrowseBoxHeaderCell.hxx>
55 #include <extended/AccessibleBrowseBoxCheckBoxCell.hxx>
56 #include <extended/accessibleeditbrowseboxcell.hxx>
57 #include <com/sun/star/accessibility/AccessibleRole.hpp>
58 #include <vcl/toolkit/lstbox.hxx>
59 #include <vcl/toolkit/combobox.hxx>
60 #include <extended/AccessibleGridControl.hxx>
61 #include <vcl/accessibletable.hxx>
63 #include <floatingwindowaccessible.hxx>
65 using namespace ::accessibility
;
66 using namespace ::com::sun::star::uno
;
67 using namespace ::com::sun::star::awt
;
68 using namespace ::com::sun::star::accessibility
;
69 using namespace ::vcl
;
70 using namespace ::vcl::table
;
74 bool hasFloatingChild(vcl::Window
*pWindow
)
76 vcl::Window
* pChild
= pWindow
->GetAccessibleChildWindow(0);
77 return pChild
&& pChild
->GetType() == WindowType::FLOATINGWINDOW
;
81 class AccessibleFactory
:public ::toolkit::IAccessibleFactory
82 ,public ::vcl::IAccessibleFactory
87 // ::toolkit::IAccessibleFactory
88 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
89 createAccessibleContext( VCLXButton
* _pXWindow
) override
;
90 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
91 createAccessibleContext( VCLXCheckBox
* _pXWindow
) override
;
92 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
93 createAccessibleContext( VCLXRadioButton
* _pXWindow
) override
;
94 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
95 createAccessibleContext( VCLXListBox
* _pXWindow
) override
;
96 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
97 createAccessibleContext( VCLXFixedText
* _pXWindow
) override
;
98 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
99 createAccessibleContext( VCLXFixedHyperlink
* _pXWindow
) override
;
100 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
101 createAccessibleContext( VCLXScrollBar
* _pXWindow
) override
;
102 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
103 createAccessibleContext( VCLXEdit
* _pXWindow
) override
;
104 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
105 createAccessibleContext( VCLXComboBox
* _pXWindow
) override
;
106 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
107 createAccessibleContext( VCLXToolBox
* _pXWindow
) override
;
108 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
109 createAccessibleContext( VCLXHeaderBar
* _pXWindow
) override
;
110 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
111 createAccessibleContext( SVTXNumericField
* _pXWindow
) override
;
112 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
113 createAccessibleContext( VCLXWindow
* _pXWindow
) override
;
114 virtual css::uno::Reference
< css::accessibility::XAccessible
>
115 createAccessible( Menu
* _pMenu
, bool _bIsMenuBar
) override
;
117 // ::vcl::IAccessibleFactory
118 virtual vcl::IAccessibleTabListBox
*
119 createAccessibleTabListBox(
120 const css::uno::Reference
< css::accessibility::XAccessible
>& rxParent
,
121 SvHeaderTabListBox
& rBox
124 virtual vcl::IAccessibleBrowseBox
*
125 createAccessibleBrowseBox(
126 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxParent
,
127 vcl::IAccessibleTableProvider
& _rBrowseBox
130 virtual IAccessibleTableControl
*
131 createAccessibleTableControl(
132 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxParent
,
133 IAccessibleTable
& _rTable
136 virtual css::uno::Reference
< css::accessibility::XAccessible
>
137 createAccessibleIconChoiceCtrl(
138 SvtIconChoiceCtrl
& _rIconCtrl
,
139 const css::uno::Reference
< css::accessibility::XAccessible
>& _xParent
142 virtual css::uno::Reference
< css::accessibility::XAccessible
>
143 createAccessibleTabBar(
147 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
148 createAccessibleTextWindowContext(
149 VCLXWindow
* pVclXWindow
, TextEngine
& rEngine
, TextView
& rView
152 virtual css::uno::Reference
< css::accessibility::XAccessible
>
153 createAccessibleTreeListBox(
154 SvTreeListBox
& _rListBox
,
155 const css::uno::Reference
< css::accessibility::XAccessible
>& _xParent
158 virtual css::uno::Reference
< css::accessibility::XAccessible
>
159 createAccessibleIconView(
160 SvTreeListBox
& _rListBox
,
161 const css::uno::Reference
< css::accessibility::XAccessible
>& _xParent
164 virtual css::uno::Reference
< css::accessibility::XAccessible
>
165 createAccessibleBrowseBoxHeaderBar(
166 const css::uno::Reference
< css::accessibility::XAccessible
>& rxParent
,
167 vcl::IAccessibleTableProvider
& _rOwningTable
,
168 AccessibleBrowseBoxObjType _eObjType
171 virtual css::uno::Reference
< css::accessibility::XAccessible
>
172 createAccessibleBrowseBoxTableCell(
173 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxParent
,
174 vcl::IAccessibleTableProvider
& _rBrowseBox
,
175 const css::uno::Reference
< css::awt::XWindow
>& _xFocusWindow
,
181 virtual css::uno::Reference
< css::accessibility::XAccessible
>
182 createAccessibleBrowseBoxHeaderCell(
183 sal_Int32 _nColumnRowId
,
184 const css::uno::Reference
< css::accessibility::XAccessible
>& rxParent
,
185 vcl::IAccessibleTableProvider
& _rBrowseBox
,
186 const css::uno::Reference
< css::awt::XWindow
>& _xFocusWindow
,
187 AccessibleBrowseBoxObjType _eObjType
190 virtual css::uno::Reference
< css::accessibility::XAccessible
>
191 createAccessibleCheckBoxCell(
192 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxParent
,
193 vcl::IAccessibleTableProvider
& _rBrowseBox
,
194 const css::uno::Reference
< css::awt::XWindow
>& _xFocusWindow
,
197 const TriState
& _eState
,
201 virtual css::uno::Reference
< css::accessibility::XAccessible
>
202 createEditBrowseBoxTableCellAccess(
203 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxParent
,
204 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxControlAccessible
,
205 const css::uno::Reference
< css::awt::XWindow
>& _rxFocusWindow
,
206 vcl::IAccessibleTableProvider
& _rBrowseBox
,
212 virtual ~AccessibleFactory() override
;
215 AccessibleFactory::AccessibleFactory()
219 AccessibleFactory::~AccessibleFactory()
223 Reference
< XAccessible
> AccessibleFactory::createAccessible( Menu
* _pMenu
, bool _bIsMenuBar
)
225 rtl::Reference
<OAccessibleMenuBaseComponent
> pAccessible
;
227 pAccessible
= new VCLXAccessibleMenuBar( _pMenu
);
229 pAccessible
= new VCLXAccessiblePopupMenu( _pMenu
);
230 pAccessible
->SetStates();
234 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXButton
* _pXWindow
)
236 return new VCLXAccessibleButton( _pXWindow
);
239 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXCheckBox
* _pXWindow
)
241 return new VCLXAccessibleCheckBox( _pXWindow
);
244 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXRadioButton
* _pXWindow
)
246 return new VCLXAccessibleRadioButton( _pXWindow
);
249 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXListBox
* _pXWindow
)
251 bool bIsDropDownBox
= false;
252 VclPtr
< ListBox
> pBox
= _pXWindow
->GetAs
< ListBox
>();
254 bIsDropDownBox
= ( ( pBox
->GetStyle() & WB_DROPDOWN
) == WB_DROPDOWN
);
256 if ( bIsDropDownBox
)
257 return new VCLXAccessibleDropDownListBox( _pXWindow
);
259 return new VCLXAccessibleListBox( _pXWindow
);
262 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXFixedText
* _pXWindow
)
264 return new VCLXAccessibleFixedText( _pXWindow
);
267 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXFixedHyperlink
* _pXWindow
)
269 return new VCLXAccessibleFixedHyperlink( _pXWindow
);
272 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXScrollBar
* _pXWindow
)
274 return new VCLXAccessibleScrollBar( _pXWindow
);
277 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXEdit
* _pXWindow
)
279 return new VCLXAccessibleEdit( _pXWindow
);
282 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXComboBox
* _pXWindow
)
284 bool bIsDropDownBox
= false;
285 VclPtr
< ComboBox
> pBox
= _pXWindow
->GetAs
< ComboBox
>();
287 bIsDropDownBox
= ( ( pBox
->GetStyle() & WB_DROPDOWN
) == WB_DROPDOWN
);
289 if ( bIsDropDownBox
)
290 return new VCLXAccessibleDropDownComboBox( _pXWindow
);
292 return new VCLXAccessibleComboBox( _pXWindow
);
295 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXWindow
* _pXWindow
)
297 Reference
< XAccessibleContext
> xContext
;
299 VclPtr
<vcl::Window
> pWindow
= _pXWindow
->GetWindow();
302 WindowType nType
= pWindow
->GetType();
304 if ( nType
== WindowType::MENUBARWINDOW
|| pWindow
->IsMenuFloatingWindow() || pWindow
->IsToolbarFloatingWindow() )
306 Reference
< XAccessible
> xAcc( pWindow
->GetAccessible() );
309 Reference
< XAccessibleContext
> xCont( xAcc
->getAccessibleContext() );
310 if ( pWindow
->GetType() == WindowType::MENUBARWINDOW
||
311 ( xCont
.is() && xCont
->getAccessibleRole() == AccessibleRole::POPUP_MENU
) )
318 else if ( nType
== WindowType::STATUSBAR
)
320 xContext
= new VCLXAccessibleStatusBar(_pXWindow
);
323 else if ( nType
== WindowType::TABCONTROL
)
325 xContext
= new VCLXAccessibleTabControl(_pXWindow
);
328 else if ( nType
== WindowType::TABPAGE
&& pWindow
->GetAccessibleParentWindow() && pWindow
->GetAccessibleParentWindow()->GetType() == WindowType::TABCONTROL
)
330 xContext
= new VCLXAccessibleTabPageWindow( _pXWindow
);
333 else if ( nType
== WindowType::FLOATINGWINDOW
)
335 xContext
= new FloatingWindowAccessible( _pXWindow
);
338 else if ( nType
== WindowType::BORDERWINDOW
&& hasFloatingChild( pWindow
) )
340 xContext
= new FloatingWindowAccessible( _pXWindow
);
343 else if ( ( nType
== WindowType::HELPTEXTWINDOW
) || ( nType
== WindowType::FIXEDLINE
) )
345 xContext
= new VCLXAccessibleFixedText(_pXWindow
);
349 xContext
= new VCLXAccessibleComponent(_pXWindow
);
355 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXToolBox
* _pXWindow
)
357 return new VCLXAccessibleToolBox( _pXWindow
);
360 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXHeaderBar
* _pXWindow
)
362 return new VCLXAccessibleHeaderBar(_pXWindow
);
365 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( SVTXNumericField
* _pXWindow
)
367 return new SVTXAccessibleNumericField( _pXWindow
);
370 vcl::IAccessibleTabListBox
* AccessibleFactory::createAccessibleTabListBox(
371 const Reference
< XAccessible
>& rxParent
, SvHeaderTabListBox
& rBox
) const
373 return new AccessibleTabListBox( rxParent
, rBox
);
376 vcl::IAccessibleBrowseBox
* AccessibleFactory::createAccessibleBrowseBox(
377 const Reference
< XAccessible
>& _rxParent
, vcl::IAccessibleTableProvider
& _rBrowseBox
) const
379 return new AccessibleBrowseBoxAccess( _rxParent
, _rBrowseBox
);
382 IAccessibleTableControl
* AccessibleFactory::createAccessibleTableControl(
383 const Reference
< XAccessible
>& _rxParent
, IAccessibleTable
& _rTable
) const
385 return new AccessibleGridControlAccess( _rxParent
, _rTable
);
388 Reference
< XAccessible
> AccessibleFactory::createAccessibleIconChoiceCtrl(
389 SvtIconChoiceCtrl
& _rIconCtrl
, const Reference
< XAccessible
>& _xParent
) const
391 return new AccessibleIconChoiceCtrl( _rIconCtrl
, _xParent
);
394 Reference
< XAccessible
> AccessibleFactory::createAccessibleTabBar( TabBar
& _rTabBar
) const
396 return new AccessibleTabBar( &_rTabBar
);
399 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleTextWindowContext(
400 VCLXWindow
* pVclXWindow
, TextEngine
& rEngine
, TextView
& rView
) const
402 return new Document( pVclXWindow
, rEngine
, rView
);
405 Reference
< XAccessible
> AccessibleFactory::createAccessibleTreeListBox(
406 SvTreeListBox
& _rListBox
, const Reference
< XAccessible
>& _xParent
) const
408 return new AccessibleListBox( _rListBox
, _xParent
);
411 Reference
< XAccessible
> AccessibleFactory::createAccessibleIconView(
412 SvTreeListBox
& _rListBox
, const Reference
< XAccessible
>& _xParent
) const
414 return new AccessibleIconView( _rListBox
, _xParent
);
417 Reference
< XAccessible
> AccessibleFactory::createAccessibleBrowseBoxHeaderBar(
418 const Reference
< XAccessible
>& rxParent
, vcl::IAccessibleTableProvider
& _rOwningTable
,
419 AccessibleBrowseBoxObjType _eObjType
) const
421 return new AccessibleBrowseBoxHeaderBar( rxParent
, _rOwningTable
, _eObjType
);
424 Reference
< XAccessible
> AccessibleFactory::createAccessibleBrowseBoxTableCell(
425 const Reference
< XAccessible
>& _rxParent
, vcl::IAccessibleTableProvider
& _rBrowseBox
,
426 const Reference
< XWindow
>& _xFocusWindow
, sal_Int32 _nRowId
, sal_uInt16 _nColId
, sal_Int32 _nOffset
) const
428 return new AccessibleBrowseBoxTableCell( _rxParent
, _rBrowseBox
, _xFocusWindow
,
429 _nRowId
, _nColId
, _nOffset
);
432 Reference
< XAccessible
> AccessibleFactory::createAccessibleBrowseBoxHeaderCell(
433 sal_Int32 _nColumnRowId
, const Reference
< XAccessible
>& rxParent
, vcl::IAccessibleTableProvider
& _rBrowseBox
,
434 const Reference
< XWindow
>& _xFocusWindow
, AccessibleBrowseBoxObjType _eObjType
) const
436 return new AccessibleBrowseBoxHeaderCell( _nColumnRowId
, rxParent
, _rBrowseBox
,
437 _xFocusWindow
, _eObjType
);
440 Reference
< XAccessible
> AccessibleFactory::createAccessibleCheckBoxCell(
441 const Reference
< XAccessible
>& _rxParent
, vcl::IAccessibleTableProvider
& _rBrowseBox
,
442 const Reference
< XWindow
>& _xFocusWindow
, sal_Int32 _nRowPos
, sal_uInt16 _nColPos
,
443 const TriState
& _eState
, bool _bIsTriState
) const
445 return new AccessibleCheckBoxCell( _rxParent
, _rBrowseBox
, _xFocusWindow
,
446 _nRowPos
, _nColPos
, _eState
, _bIsTriState
);
449 Reference
< XAccessible
> AccessibleFactory::createEditBrowseBoxTableCellAccess(
450 const Reference
< XAccessible
>& _rxParent
, const Reference
< XAccessible
>& _rxControlAccessible
,
451 const Reference
< XWindow
>& _rxFocusWindow
, vcl::IAccessibleTableProvider
& _rBrowseBox
,
452 sal_Int32 _nRowPos
, sal_uInt16 _nColPos
) const
454 return new EditBrowseBoxTableCellAccess( _rxParent
, _rxControlAccessible
,
455 _rxFocusWindow
, _rBrowseBox
, _nRowPos
, _nColPos
);
458 } // anonymous namespace
460 #if HAVE_FEATURE_DESKTOP
461 /* this is the entry point to retrieve a factory for the toolkit-level Accessible/Contexts supplied
464 This function implements the factory function needed in toolkit
465 (of type GetStandardAccComponentFactory).
469 SAL_DLLPUBLIC_EXPORT
void* getStandardAccessibleFactory()
471 ::toolkit::IAccessibleFactory
* pFactory
= new AccessibleFactory
;
477 /** this is the entry point to retrieve a factory for the svtools-level Accessible/Contexts supplied
480 This function implements the factory function needed in svtools
481 (of type GetSvtAccessibilityComponentFactory).
485 SAL_DLLPUBLIC_EXPORT
void* getSvtAccessibilityComponentFactory()
487 ::vcl::IAccessibleFactory
* pFactory
= new AccessibleFactory
;
492 #endif // HAVE_FEATURE_DESKTOP
494 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */