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_features.h>
21 #include <config_feature_desktop.h>
23 #include <toolkit/awt/vclxwindows.hxx>
24 #include <toolkit/helper/accessiblefactory.hxx>
25 #include <vcl/accessiblefactory.hxx>
26 #include <standard/svtaccessiblenumericfield.hxx>
27 #include <standard/vclxaccessiblebutton.hxx>
28 #include <standard/vclxaccessiblecheckbox.hxx>
29 #include <standard/vclxaccessibledropdowncombobox.hxx>
30 #include <standard/vclxaccessiblecombobox.hxx>
31 #include <standard/vclxaccessibledropdownlistbox.hxx>
32 #include <standard/vclxaccessibleedit.hxx>
33 #include <standard/vclxaccessiblefixedhyperlink.hxx>
34 #include <standard/vclxaccessiblefixedtext.hxx>
35 #include <standard/vclxaccessibleheaderbar.hxx>
36 #include <standard/vclxaccessiblelistbox.hxx>
37 #include <standard/vclxaccessibleradiobutton.hxx>
38 #include <standard/vclxaccessiblescrollbar.hxx>
39 #include <standard/vclxaccessibletoolbox.hxx>
40 #include <toolkit/awt/vclxaccessiblecomponent.hxx>
41 #include <standard/vclxaccessiblestatusbar.hxx>
42 #include <standard/vclxaccessibletabcontrol.hxx>
43 #include <standard/vclxaccessibletabpagewindow.hxx>
44 #include <standard/vclxaccessiblemenubar.hxx>
45 #include <standard/vclxaccessiblepopupmenu.hxx>
46 #include <extended/accessibletablistbox.hxx>
47 #include <extended/AccessibleBrowseBox.hxx>
48 #include <extended/accessibleiconchoicectrl.hxx>
49 #include <extended/AccessibleIconView.hxx>
50 #include <extended/accessibletabbar.hxx>
51 #include <extended/accessiblelistbox.hxx>
52 #include <extended/AccessibleBrowseBoxHeaderBar.hxx>
53 #include <extended/textwindowaccessibility.hxx>
54 #include <extended/AccessibleBrowseBoxTableCell.hxx>
55 #include <extended/AccessibleBrowseBoxHeaderCell.hxx>
56 #include <extended/AccessibleBrowseBoxCheckBoxCell.hxx>
57 #include <extended/accessibleeditbrowseboxcell.hxx>
58 #include <com/sun/star/accessibility/AccessibleRole.hpp>
59 #include <vcl/toolkit/lstbox.hxx>
60 #include <vcl/toolkit/combobox.hxx>
61 #include <extended/AccessibleGridControl.hxx>
62 #include <vcl/accessibletable.hxx>
64 #include <floatingwindowaccessible.hxx>
66 using namespace ::accessibility
;
67 using namespace ::com::sun::star::uno
;
68 using namespace ::com::sun::star::awt
;
69 using namespace ::com::sun::star::accessibility
;
70 using namespace ::vcl
;
71 using namespace ::vcl::table
;
75 bool hasFloatingChild(vcl::Window
*pWindow
)
77 vcl::Window
* pChild
= pWindow
->GetAccessibleChildWindow(0);
78 return pChild
&& pChild
->GetType() == WindowType::FLOATINGWINDOW
;
82 class AccessibleFactory
:public ::toolkit::IAccessibleFactory
83 ,public ::vcl::IAccessibleFactory
88 // ::toolkit::IAccessibleFactory
89 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
90 createAccessibleContext( VCLXButton
* _pXWindow
) override
;
91 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
92 createAccessibleContext( VCLXCheckBox
* _pXWindow
) override
;
93 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
94 createAccessibleContext( VCLXRadioButton
* _pXWindow
) override
;
95 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
96 createAccessibleContext( VCLXListBox
* _pXWindow
) override
;
97 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
98 createAccessibleContext( VCLXFixedText
* _pXWindow
) override
;
99 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
100 createAccessibleContext( VCLXFixedHyperlink
* _pXWindow
) override
;
101 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
102 createAccessibleContext( VCLXScrollBar
* _pXWindow
) override
;
103 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
104 createAccessibleContext( VCLXEdit
* _pXWindow
) override
;
105 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
106 createAccessibleContext( VCLXMultiLineEdit
* _pXWindow
) override
;
107 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
108 createAccessibleContext( VCLXComboBox
* _pXWindow
) override
;
109 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
110 createAccessibleContext( VCLXToolBox
* _pXWindow
) override
;
111 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
112 createAccessibleContext( VCLXHeaderBar
* _pXWindow
) override
;
113 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
114 createAccessibleContext( SVTXNumericField
* _pXWindow
) override
;
115 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
116 createAccessibleContext( VCLXWindow
* _pXWindow
) override
;
117 virtual css::uno::Reference
< css::accessibility::XAccessible
>
118 createAccessible( Menu
* _pMenu
, bool _bIsMenuBar
) override
;
120 // ::vcl::IAccessibleFactory
121 virtual vcl::IAccessibleTabListBox
*
122 createAccessibleTabListBox(
123 const css::uno::Reference
< css::accessibility::XAccessible
>& rxParent
,
124 SvHeaderTabListBox
& rBox
127 virtual rtl::Reference
<vcl::IAccessibleBrowseBox
>
128 createAccessibleBrowseBox(
129 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxParent
,
130 vcl::IAccessibleTableProvider
& _rBrowseBox
133 virtual rtl::Reference
<IAccessibleTableControl
>
134 createAccessibleTableControl(
135 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxParent
,
136 IAccessibleTable
& _rTable
139 virtual css::uno::Reference
< css::accessibility::XAccessible
>
140 createAccessibleIconChoiceCtrl(
141 SvtIconChoiceCtrl
& _rIconCtrl
,
142 const css::uno::Reference
< css::accessibility::XAccessible
>& _xParent
145 virtual css::uno::Reference
< css::accessibility::XAccessible
>
146 createAccessibleTabBar(
150 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
151 createAccessibleTextWindowContext(
152 VCLXWindow
* pVclXWindow
, TextEngine
& rEngine
, TextView
& rView
155 virtual css::uno::Reference
< css::accessibility::XAccessible
>
156 createAccessibleTreeListBox(
157 SvTreeListBox
& _rListBox
,
158 const css::uno::Reference
< css::accessibility::XAccessible
>& _xParent
161 virtual css::uno::Reference
< css::accessibility::XAccessible
>
162 createAccessibleIconView(
163 SvTreeListBox
& _rListBox
,
164 const css::uno::Reference
< css::accessibility::XAccessible
>& _xParent
167 virtual css::uno::Reference
< css::accessibility::XAccessible
>
168 createAccessibleBrowseBoxHeaderBar(
169 const css::uno::Reference
< css::accessibility::XAccessible
>& rxParent
,
170 vcl::IAccessibleTableProvider
& _rOwningTable
,
171 AccessibleBrowseBoxObjType _eObjType
174 virtual css::uno::Reference
< css::accessibility::XAccessible
>
175 createAccessibleBrowseBoxTableCell(
176 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxParent
,
177 vcl::IAccessibleTableProvider
& _rBrowseBox
,
178 const css::uno::Reference
< css::awt::XWindow
>& _xFocusWindow
,
184 virtual css::uno::Reference
< css::accessibility::XAccessible
>
185 createAccessibleBrowseBoxHeaderCell(
186 sal_Int32 _nColumnRowId
,
187 const css::uno::Reference
< css::accessibility::XAccessible
>& rxParent
,
188 vcl::IAccessibleTableProvider
& _rBrowseBox
,
189 const css::uno::Reference
< css::awt::XWindow
>& _xFocusWindow
,
190 AccessibleBrowseBoxObjType _eObjType
193 virtual css::uno::Reference
< css::accessibility::XAccessible
>
194 createAccessibleCheckBoxCell(
195 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxParent
,
196 vcl::IAccessibleTableProvider
& _rBrowseBox
,
197 const css::uno::Reference
< css::awt::XWindow
>& _xFocusWindow
,
200 const TriState
& _eState
,
204 virtual css::uno::Reference
< css::accessibility::XAccessible
>
205 createEditBrowseBoxTableCellAccess(
206 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxParent
,
207 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxControlAccessible
,
208 const css::uno::Reference
< css::awt::XWindow
>& _rxFocusWindow
,
209 vcl::IAccessibleTableProvider
& _rBrowseBox
,
215 virtual ~AccessibleFactory() override
;
218 AccessibleFactory::AccessibleFactory()
222 AccessibleFactory::~AccessibleFactory()
226 Reference
< XAccessible
> AccessibleFactory::createAccessible( Menu
* _pMenu
, bool _bIsMenuBar
)
228 rtl::Reference
<OAccessibleMenuBaseComponent
> pAccessible
;
230 pAccessible
= new VCLXAccessibleMenuBar( _pMenu
);
232 pAccessible
= new VCLXAccessiblePopupMenu( _pMenu
);
233 pAccessible
->SetStates();
237 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXButton
* _pXWindow
)
239 return new VCLXAccessibleButton( _pXWindow
);
242 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXCheckBox
* _pXWindow
)
244 return new VCLXAccessibleCheckBox( _pXWindow
);
247 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXRadioButton
* _pXWindow
)
249 return new VCLXAccessibleRadioButton( _pXWindow
);
252 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXListBox
* _pXWindow
)
254 bool bIsDropDownBox
= false;
255 VclPtr
< ListBox
> pBox
= _pXWindow
->GetAs
< ListBox
>();
257 bIsDropDownBox
= ( ( pBox
->GetStyle() & WB_DROPDOWN
) == WB_DROPDOWN
);
259 if ( bIsDropDownBox
)
260 return new VCLXAccessibleDropDownListBox( _pXWindow
);
262 return new VCLXAccessibleListBox( _pXWindow
);
265 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXFixedText
* _pXWindow
)
267 return new VCLXAccessibleFixedText( _pXWindow
);
270 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXFixedHyperlink
* _pXWindow
)
272 return new VCLXAccessibleFixedHyperlink( _pXWindow
);
275 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXScrollBar
* _pXWindow
)
277 return new VCLXAccessibleScrollBar( _pXWindow
);
280 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXEdit
* _pXWindow
)
282 return new VCLXAccessibleEdit( _pXWindow
);
285 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXMultiLineEdit
* _pXWindow
)
287 return new VCLXAccessibleEdit( _pXWindow
);
290 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXComboBox
* _pXWindow
)
292 bool bIsDropDownBox
= false;
293 VclPtr
< ComboBox
> pBox
= _pXWindow
->GetAs
< ComboBox
>();
295 bIsDropDownBox
= ( ( pBox
->GetStyle() & WB_DROPDOWN
) == WB_DROPDOWN
);
297 if ( bIsDropDownBox
)
298 return new VCLXAccessibleDropDownComboBox( _pXWindow
);
300 return new VCLXAccessibleComboBox( _pXWindow
);
303 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXWindow
* _pXWindow
)
305 Reference
< XAccessibleContext
> xContext
;
307 VclPtr
<vcl::Window
> pWindow
= _pXWindow
->GetWindow();
310 WindowType nType
= pWindow
->GetType();
312 if ( nType
== WindowType::MENUBARWINDOW
|| pWindow
->IsMenuFloatingWindow() || pWindow
->IsToolbarFloatingWindow() )
314 Reference
< XAccessible
> xAcc( pWindow
->GetAccessible() );
317 Reference
< XAccessibleContext
> xCont( xAcc
->getAccessibleContext() );
318 if ( pWindow
->GetType() == WindowType::MENUBARWINDOW
||
319 ( xCont
.is() && xCont
->getAccessibleRole() == AccessibleRole::POPUP_MENU
) )
326 else if ( nType
== WindowType::STATUSBAR
)
328 xContext
= new VCLXAccessibleStatusBar(_pXWindow
);
331 else if ( nType
== WindowType::TABCONTROL
)
333 xContext
= new VCLXAccessibleTabControl(_pXWindow
);
336 else if ( nType
== WindowType::TABPAGE
&& pWindow
->GetAccessibleParentWindow() && pWindow
->GetAccessibleParentWindow()->GetType() == WindowType::TABCONTROL
)
338 xContext
= new VCLXAccessibleTabPageWindow( _pXWindow
);
341 else if ( nType
== WindowType::FLOATINGWINDOW
)
343 xContext
= new FloatingWindowAccessible( _pXWindow
);
346 else if ( nType
== WindowType::BORDERWINDOW
&& hasFloatingChild( pWindow
) )
348 xContext
= new FloatingWindowAccessible( _pXWindow
);
351 else if ( ( nType
== WindowType::HELPTEXTWINDOW
) || ( nType
== WindowType::FIXEDLINE
) )
353 xContext
= new VCLXAccessibleFixedText(_pXWindow
);
357 xContext
= new VCLXAccessibleComponent(_pXWindow
);
363 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXToolBox
* _pXWindow
)
365 return new VCLXAccessibleToolBox( _pXWindow
);
368 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXHeaderBar
* _pXWindow
)
370 return new VCLXAccessibleHeaderBar(_pXWindow
);
373 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( SVTXNumericField
* _pXWindow
)
375 return new SVTXAccessibleNumericField( _pXWindow
);
378 vcl::IAccessibleTabListBox
* AccessibleFactory::createAccessibleTabListBox(
379 const Reference
< XAccessible
>& rxParent
, SvHeaderTabListBox
& rBox
) const
381 return new AccessibleTabListBox( rxParent
, rBox
);
384 rtl::Reference
<vcl::IAccessibleBrowseBox
> AccessibleFactory::createAccessibleBrowseBox(
385 const Reference
< XAccessible
>& _rxParent
, vcl::IAccessibleTableProvider
& _rBrowseBox
) const
387 return new AccessibleBrowseBoxAccess( _rxParent
, _rBrowseBox
);
390 rtl::Reference
<IAccessibleTableControl
> AccessibleFactory::createAccessibleTableControl(
391 const Reference
< XAccessible
>& _rxParent
, IAccessibleTable
& _rTable
) const
393 return new AccessibleGridControlAccess( _rxParent
, _rTable
);
396 Reference
< XAccessible
> AccessibleFactory::createAccessibleIconChoiceCtrl(
397 SvtIconChoiceCtrl
& _rIconCtrl
, const Reference
< XAccessible
>& _xParent
) const
399 return new AccessibleIconChoiceCtrl( _rIconCtrl
, _xParent
);
402 Reference
< XAccessible
> AccessibleFactory::createAccessibleTabBar( TabBar
& _rTabBar
) const
404 #if HAVE_FEATURE_SCRIPTING
405 return new AccessibleTabBar( &_rTabBar
);
412 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleTextWindowContext(
413 VCLXWindow
* pVclXWindow
, TextEngine
& rEngine
, TextView
& rView
) const
415 return new Document( pVclXWindow
, rEngine
, rView
);
418 Reference
< XAccessible
> AccessibleFactory::createAccessibleTreeListBox(
419 SvTreeListBox
& _rListBox
, const Reference
< XAccessible
>& _xParent
) const
421 return new AccessibleListBox( _rListBox
, _xParent
);
424 Reference
< XAccessible
> AccessibleFactory::createAccessibleIconView(
425 SvTreeListBox
& _rListBox
, const Reference
< XAccessible
>& _xParent
) const
427 return new AccessibleIconView( _rListBox
, _xParent
);
430 Reference
< XAccessible
> AccessibleFactory::createAccessibleBrowseBoxHeaderBar(
431 const Reference
< XAccessible
>& rxParent
, vcl::IAccessibleTableProvider
& _rOwningTable
,
432 AccessibleBrowseBoxObjType _eObjType
) const
434 return new AccessibleBrowseBoxHeaderBar( rxParent
, _rOwningTable
, _eObjType
);
437 Reference
< XAccessible
> AccessibleFactory::createAccessibleBrowseBoxTableCell(
438 const Reference
< XAccessible
>& _rxParent
, vcl::IAccessibleTableProvider
& _rBrowseBox
,
439 const Reference
< XWindow
>& _xFocusWindow
, sal_Int32 _nRowId
, sal_uInt16 _nColId
, sal_Int32 _nOffset
) const
441 return new AccessibleBrowseBoxTableCell( _rxParent
, _rBrowseBox
, _xFocusWindow
,
442 _nRowId
, _nColId
, _nOffset
);
445 Reference
< XAccessible
> AccessibleFactory::createAccessibleBrowseBoxHeaderCell(
446 sal_Int32 _nColumnRowId
, const Reference
< XAccessible
>& rxParent
, vcl::IAccessibleTableProvider
& _rBrowseBox
,
447 const Reference
< XWindow
>& _xFocusWindow
, AccessibleBrowseBoxObjType _eObjType
) const
449 return new AccessibleBrowseBoxHeaderCell( _nColumnRowId
, rxParent
, _rBrowseBox
,
450 _xFocusWindow
, _eObjType
);
453 Reference
< XAccessible
> AccessibleFactory::createAccessibleCheckBoxCell(
454 const Reference
< XAccessible
>& _rxParent
, vcl::IAccessibleTableProvider
& _rBrowseBox
,
455 const Reference
< XWindow
>& _xFocusWindow
, sal_Int32 _nRowPos
, sal_uInt16 _nColPos
,
456 const TriState
& _eState
, bool _bIsTriState
) const
458 return new AccessibleCheckBoxCell( _rxParent
, _rBrowseBox
, _xFocusWindow
,
459 _nRowPos
, _nColPos
, _eState
, _bIsTriState
);
462 Reference
< XAccessible
> AccessibleFactory::createEditBrowseBoxTableCellAccess(
463 const Reference
< XAccessible
>& _rxParent
, const Reference
< XAccessible
>& _rxControlAccessible
,
464 const Reference
< XWindow
>& _rxFocusWindow
, vcl::IAccessibleTableProvider
& _rBrowseBox
,
465 sal_Int32 _nRowPos
, sal_uInt16 _nColPos
) const
467 return new EditBrowseBoxTableCellAccess( _rxParent
, _rxControlAccessible
,
468 _rxFocusWindow
, _rBrowseBox
, _nRowPos
, _nColPos
);
471 } // anonymous namespace
473 #if HAVE_FEATURE_DESKTOP
474 /* this is the entry point to retrieve a factory for the toolkit-level Accessible/Contexts supplied
477 This function implements the factory function needed in toolkit
478 (of type GetStandardAccComponentFactory).
482 SAL_DLLPUBLIC_EXPORT
void* getStandardAccessibleFactory()
484 ::toolkit::IAccessibleFactory
* pFactory
= new AccessibleFactory
;
490 /** this is the entry point to retrieve a factory for the svtools-level Accessible/Contexts supplied
493 This function implements the factory function needed in svtools
494 (of type GetSvtAccessibilityComponentFactory).
498 SAL_DLLPUBLIC_EXPORT
void* getSvtAccessibilityComponentFactory()
500 ::vcl::IAccessibleFactory
* pFactory
= new AccessibleFactory
;
505 #endif // HAVE_FEATURE_DESKTOP
507 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */