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( VCLXComboBox
* _pXWindow
) override
;
107 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
108 createAccessibleContext( VCLXToolBox
* _pXWindow
) override
;
109 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
110 createAccessibleContext( VCLXHeaderBar
* _pXWindow
) override
;
111 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
112 createAccessibleContext( SVTXNumericField
* _pXWindow
) override
;
113 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
114 createAccessibleContext( VCLXWindow
* _pXWindow
) override
;
115 virtual css::uno::Reference
< css::accessibility::XAccessible
>
116 createAccessible( Menu
* _pMenu
, bool _bIsMenuBar
) override
;
118 // ::vcl::IAccessibleFactory
119 virtual vcl::IAccessibleTabListBox
*
120 createAccessibleTabListBox(
121 const css::uno::Reference
< css::accessibility::XAccessible
>& rxParent
,
122 SvHeaderTabListBox
& rBox
125 virtual vcl::IAccessibleBrowseBox
*
126 createAccessibleBrowseBox(
127 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxParent
,
128 vcl::IAccessibleTableProvider
& _rBrowseBox
131 virtual IAccessibleTableControl
*
132 createAccessibleTableControl(
133 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxParent
,
134 IAccessibleTable
& _rTable
137 virtual css::uno::Reference
< css::accessibility::XAccessible
>
138 createAccessibleIconChoiceCtrl(
139 SvtIconChoiceCtrl
& _rIconCtrl
,
140 const css::uno::Reference
< css::accessibility::XAccessible
>& _xParent
143 virtual css::uno::Reference
< css::accessibility::XAccessible
>
144 createAccessibleTabBar(
148 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
149 createAccessibleTextWindowContext(
150 VCLXWindow
* pVclXWindow
, TextEngine
& rEngine
, TextView
& rView
153 virtual css::uno::Reference
< css::accessibility::XAccessible
>
154 createAccessibleTreeListBox(
155 SvTreeListBox
& _rListBox
,
156 const css::uno::Reference
< css::accessibility::XAccessible
>& _xParent
159 virtual css::uno::Reference
< css::accessibility::XAccessible
>
160 createAccessibleIconView(
161 SvTreeListBox
& _rListBox
,
162 const css::uno::Reference
< css::accessibility::XAccessible
>& _xParent
165 virtual css::uno::Reference
< css::accessibility::XAccessible
>
166 createAccessibleBrowseBoxHeaderBar(
167 const css::uno::Reference
< css::accessibility::XAccessible
>& rxParent
,
168 vcl::IAccessibleTableProvider
& _rOwningTable
,
169 AccessibleBrowseBoxObjType _eObjType
172 virtual css::uno::Reference
< css::accessibility::XAccessible
>
173 createAccessibleBrowseBoxTableCell(
174 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxParent
,
175 vcl::IAccessibleTableProvider
& _rBrowseBox
,
176 const css::uno::Reference
< css::awt::XWindow
>& _xFocusWindow
,
182 virtual css::uno::Reference
< css::accessibility::XAccessible
>
183 createAccessibleBrowseBoxHeaderCell(
184 sal_Int32 _nColumnRowId
,
185 const css::uno::Reference
< css::accessibility::XAccessible
>& rxParent
,
186 vcl::IAccessibleTableProvider
& _rBrowseBox
,
187 const css::uno::Reference
< css::awt::XWindow
>& _xFocusWindow
,
188 AccessibleBrowseBoxObjType _eObjType
191 virtual css::uno::Reference
< css::accessibility::XAccessible
>
192 createAccessibleCheckBoxCell(
193 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxParent
,
194 vcl::IAccessibleTableProvider
& _rBrowseBox
,
195 const css::uno::Reference
< css::awt::XWindow
>& _xFocusWindow
,
198 const TriState
& _eState
,
202 virtual css::uno::Reference
< css::accessibility::XAccessible
>
203 createEditBrowseBoxTableCellAccess(
204 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxParent
,
205 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxControlAccessible
,
206 const css::uno::Reference
< css::awt::XWindow
>& _rxFocusWindow
,
207 vcl::IAccessibleTableProvider
& _rBrowseBox
,
213 virtual ~AccessibleFactory() override
;
216 AccessibleFactory::AccessibleFactory()
220 AccessibleFactory::~AccessibleFactory()
224 Reference
< XAccessible
> AccessibleFactory::createAccessible( Menu
* _pMenu
, bool _bIsMenuBar
)
226 rtl::Reference
<OAccessibleMenuBaseComponent
> pAccessible
;
228 pAccessible
= new VCLXAccessibleMenuBar( _pMenu
);
230 pAccessible
= new VCLXAccessiblePopupMenu( _pMenu
);
231 pAccessible
->SetStates();
235 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXButton
* _pXWindow
)
237 return new VCLXAccessibleButton( _pXWindow
);
240 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXCheckBox
* _pXWindow
)
242 return new VCLXAccessibleCheckBox( _pXWindow
);
245 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXRadioButton
* _pXWindow
)
247 return new VCLXAccessibleRadioButton( _pXWindow
);
250 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXListBox
* _pXWindow
)
252 bool bIsDropDownBox
= false;
253 VclPtr
< ListBox
> pBox
= _pXWindow
->GetAs
< ListBox
>();
255 bIsDropDownBox
= ( ( pBox
->GetStyle() & WB_DROPDOWN
) == WB_DROPDOWN
);
257 if ( bIsDropDownBox
)
258 return new VCLXAccessibleDropDownListBox( _pXWindow
);
260 return new VCLXAccessibleListBox( _pXWindow
);
263 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXFixedText
* _pXWindow
)
265 return new VCLXAccessibleFixedText( _pXWindow
);
268 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXFixedHyperlink
* _pXWindow
)
270 return new VCLXAccessibleFixedHyperlink( _pXWindow
);
273 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXScrollBar
* _pXWindow
)
275 return new VCLXAccessibleScrollBar( _pXWindow
);
278 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXEdit
* _pXWindow
)
280 return new VCLXAccessibleEdit( _pXWindow
);
283 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXComboBox
* _pXWindow
)
285 bool bIsDropDownBox
= false;
286 VclPtr
< ComboBox
> pBox
= _pXWindow
->GetAs
< ComboBox
>();
288 bIsDropDownBox
= ( ( pBox
->GetStyle() & WB_DROPDOWN
) == WB_DROPDOWN
);
290 if ( bIsDropDownBox
)
291 return new VCLXAccessibleDropDownComboBox( _pXWindow
);
293 return new VCLXAccessibleComboBox( _pXWindow
);
296 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXWindow
* _pXWindow
)
298 Reference
< XAccessibleContext
> xContext
;
300 VclPtr
<vcl::Window
> pWindow
= _pXWindow
->GetWindow();
303 WindowType nType
= pWindow
->GetType();
305 if ( nType
== WindowType::MENUBARWINDOW
|| pWindow
->IsMenuFloatingWindow() || pWindow
->IsToolbarFloatingWindow() )
307 Reference
< XAccessible
> xAcc( pWindow
->GetAccessible() );
310 Reference
< XAccessibleContext
> xCont( xAcc
->getAccessibleContext() );
311 if ( pWindow
->GetType() == WindowType::MENUBARWINDOW
||
312 ( xCont
.is() && xCont
->getAccessibleRole() == AccessibleRole::POPUP_MENU
) )
319 else if ( nType
== WindowType::STATUSBAR
)
321 xContext
= new VCLXAccessibleStatusBar(_pXWindow
);
324 else if ( nType
== WindowType::TABCONTROL
)
326 xContext
= new VCLXAccessibleTabControl(_pXWindow
);
329 else if ( nType
== WindowType::TABPAGE
&& pWindow
->GetAccessibleParentWindow() && pWindow
->GetAccessibleParentWindow()->GetType() == WindowType::TABCONTROL
)
331 xContext
= new VCLXAccessibleTabPageWindow( _pXWindow
);
334 else if ( nType
== WindowType::FLOATINGWINDOW
)
336 xContext
= new FloatingWindowAccessible( _pXWindow
);
339 else if ( nType
== WindowType::BORDERWINDOW
&& hasFloatingChild( pWindow
) )
341 xContext
= new FloatingWindowAccessible( _pXWindow
);
344 else if ( ( nType
== WindowType::HELPTEXTWINDOW
) || ( nType
== WindowType::FIXEDLINE
) )
346 xContext
= new VCLXAccessibleFixedText(_pXWindow
);
350 xContext
= new VCLXAccessibleComponent(_pXWindow
);
356 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXToolBox
* _pXWindow
)
358 return new VCLXAccessibleToolBox( _pXWindow
);
361 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( VCLXHeaderBar
* _pXWindow
)
363 return new VCLXAccessibleHeaderBar(_pXWindow
);
366 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleContext( SVTXNumericField
* _pXWindow
)
368 return new SVTXAccessibleNumericField( _pXWindow
);
371 vcl::IAccessibleTabListBox
* AccessibleFactory::createAccessibleTabListBox(
372 const Reference
< XAccessible
>& rxParent
, SvHeaderTabListBox
& rBox
) const
374 return new AccessibleTabListBox( rxParent
, rBox
);
377 vcl::IAccessibleBrowseBox
* AccessibleFactory::createAccessibleBrowseBox(
378 const Reference
< XAccessible
>& _rxParent
, vcl::IAccessibleTableProvider
& _rBrowseBox
) const
380 return new AccessibleBrowseBoxAccess( _rxParent
, _rBrowseBox
);
383 IAccessibleTableControl
* AccessibleFactory::createAccessibleTableControl(
384 const Reference
< XAccessible
>& _rxParent
, IAccessibleTable
& _rTable
) const
386 return new AccessibleGridControlAccess( _rxParent
, _rTable
);
389 Reference
< XAccessible
> AccessibleFactory::createAccessibleIconChoiceCtrl(
390 SvtIconChoiceCtrl
& _rIconCtrl
, const Reference
< XAccessible
>& _xParent
) const
392 return new AccessibleIconChoiceCtrl( _rIconCtrl
, _xParent
);
395 Reference
< XAccessible
> AccessibleFactory::createAccessibleTabBar( TabBar
& _rTabBar
) const
397 #if HAVE_FEATURE_SCRIPTING
398 return new AccessibleTabBar( &_rTabBar
);
405 Reference
< XAccessibleContext
> AccessibleFactory::createAccessibleTextWindowContext(
406 VCLXWindow
* pVclXWindow
, TextEngine
& rEngine
, TextView
& rView
) const
408 return new Document( pVclXWindow
, rEngine
, rView
);
411 Reference
< XAccessible
> AccessibleFactory::createAccessibleTreeListBox(
412 SvTreeListBox
& _rListBox
, const Reference
< XAccessible
>& _xParent
) const
414 return new AccessibleListBox( _rListBox
, _xParent
);
417 Reference
< XAccessible
> AccessibleFactory::createAccessibleIconView(
418 SvTreeListBox
& _rListBox
, const Reference
< XAccessible
>& _xParent
) const
420 return new AccessibleIconView( _rListBox
, _xParent
);
423 Reference
< XAccessible
> AccessibleFactory::createAccessibleBrowseBoxHeaderBar(
424 const Reference
< XAccessible
>& rxParent
, vcl::IAccessibleTableProvider
& _rOwningTable
,
425 AccessibleBrowseBoxObjType _eObjType
) const
427 return new AccessibleBrowseBoxHeaderBar( rxParent
, _rOwningTable
, _eObjType
);
430 Reference
< XAccessible
> AccessibleFactory::createAccessibleBrowseBoxTableCell(
431 const Reference
< XAccessible
>& _rxParent
, vcl::IAccessibleTableProvider
& _rBrowseBox
,
432 const Reference
< XWindow
>& _xFocusWindow
, sal_Int32 _nRowId
, sal_uInt16 _nColId
, sal_Int32 _nOffset
) const
434 return new AccessibleBrowseBoxTableCell( _rxParent
, _rBrowseBox
, _xFocusWindow
,
435 _nRowId
, _nColId
, _nOffset
);
438 Reference
< XAccessible
> AccessibleFactory::createAccessibleBrowseBoxHeaderCell(
439 sal_Int32 _nColumnRowId
, const Reference
< XAccessible
>& rxParent
, vcl::IAccessibleTableProvider
& _rBrowseBox
,
440 const Reference
< XWindow
>& _xFocusWindow
, AccessibleBrowseBoxObjType _eObjType
) const
442 return new AccessibleBrowseBoxHeaderCell( _nColumnRowId
, rxParent
, _rBrowseBox
,
443 _xFocusWindow
, _eObjType
);
446 Reference
< XAccessible
> AccessibleFactory::createAccessibleCheckBoxCell(
447 const Reference
< XAccessible
>& _rxParent
, vcl::IAccessibleTableProvider
& _rBrowseBox
,
448 const Reference
< XWindow
>& _xFocusWindow
, sal_Int32 _nRowPos
, sal_uInt16 _nColPos
,
449 const TriState
& _eState
, bool _bIsTriState
) const
451 return new AccessibleCheckBoxCell( _rxParent
, _rBrowseBox
, _xFocusWindow
,
452 _nRowPos
, _nColPos
, _eState
, _bIsTriState
);
455 Reference
< XAccessible
> AccessibleFactory::createEditBrowseBoxTableCellAccess(
456 const Reference
< XAccessible
>& _rxParent
, const Reference
< XAccessible
>& _rxControlAccessible
,
457 const Reference
< XWindow
>& _rxFocusWindow
, vcl::IAccessibleTableProvider
& _rBrowseBox
,
458 sal_Int32 _nRowPos
, sal_uInt16 _nColPos
) const
460 return new EditBrowseBoxTableCellAccess( _rxParent
, _rxControlAccessible
,
461 _rxFocusWindow
, _rBrowseBox
, _nRowPos
, _nColPos
);
464 } // anonymous namespace
466 #if HAVE_FEATURE_DESKTOP
467 /* this is the entry point to retrieve a factory for the toolkit-level Accessible/Contexts supplied
470 This function implements the factory function needed in toolkit
471 (of type GetStandardAccComponentFactory).
475 SAL_DLLPUBLIC_EXPORT
void* getStandardAccessibleFactory()
477 ::toolkit::IAccessibleFactory
* pFactory
= new AccessibleFactory
;
483 /** this is the entry point to retrieve a factory for the svtools-level Accessible/Contexts supplied
486 This function implements the factory function needed in svtools
487 (of type GetSvtAccessibilityComponentFactory).
491 SAL_DLLPUBLIC_EXPORT
void* getSvtAccessibilityComponentFactory()
493 ::vcl::IAccessibleFactory
* pFactory
= new AccessibleFactory
;
498 #endif // HAVE_FEATURE_DESKTOP
500 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */