/src/libreoffice/vcl/inc/accessibility/vclxaccessiblelist.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #include <accessibility/vclxaccessiblebox.hxx> |
23 | | |
24 | | #include <memory> |
25 | | #include <vector> |
26 | | #include <com/sun/star/accessibility/XAccessibleSelection.hpp> |
27 | | #include <cppuhelper/implbase.hxx> |
28 | | #include <vcl/accessibility/vclxaccessiblecomponent.hxx> |
29 | | #include <accessibility/IComboListBoxHelper.hxx> |
30 | | |
31 | | class IComboListBoxHelper; |
32 | | class VCLXAccessibleListItem; |
33 | | |
34 | | /** Base class for the list contained in list- and combo boxes. This class |
35 | | does not support selection because lists of combo boxes give no direct |
36 | | access to their underlying list implementation. Look into derived |
37 | | classes for selection. |
38 | | */ |
39 | | class VCLXAccessibleList final |
40 | | : public cppu::ImplInheritanceHelper<VCLXAccessibleComponent, |
41 | | css::accessibility::XAccessibleSelection> |
42 | | { |
43 | | public: |
44 | | enum BoxType {COMBOBOX, LISTBOX}; |
45 | | |
46 | | VCLXAccessibleList(vcl::Window* pWindow, BoxType aBoxType, |
47 | | const rtl::Reference<VCLXAccessibleBox>& _xParent); |
48 | | |
49 | | /** The index that is passed to this method is returned on following |
50 | | calls to getAccessibleIndexInParent. |
51 | | */ |
52 | | void SetIndexInParent (sal_Int32 nIndex); |
53 | | |
54 | | /** Process some of the events and delegate the rest to the base classes. |
55 | | */ |
56 | | virtual void ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent) override; |
57 | | virtual void FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet ) override; |
58 | | |
59 | | /** Called on reception of selection events this method checks all known |
60 | | list items for a possible change in their selection state and |
61 | | updates that accordingly. No accessibility events are sent because |
62 | | the XAccessibleSelection interface is not supported and the items |
63 | | are transient. |
64 | | @param sTextOfSelectedItem |
65 | | This string contains the text of the currently selected |
66 | | item. It is used to retrieve the index of that item. |
67 | | */ |
68 | | void UpdateSelection (std::u16string_view sTextOfSelectedItem); |
69 | | |
70 | | // XAccessibleContext |
71 | | virtual sal_Int64 SAL_CALL getAccessibleChildCount() override final; |
72 | | css::uno::Reference< css::accessibility::XAccessible> SAL_CALL |
73 | | getAccessibleChild (sal_Int64 i) override; |
74 | | virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL |
75 | | getAccessibleParent( ) override; |
76 | | |
77 | | /** The index returned as index in parent is always the one set with the |
78 | | SetIndexInParent() method. |
79 | | */ |
80 | | virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; |
81 | | virtual sal_Int16 SAL_CALL getAccessibleRole() override; |
82 | | |
83 | | // XAccessibleSelection |
84 | | virtual void SAL_CALL selectAccessibleChild( sal_Int64 nChildIndex ) override; |
85 | | virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int64 nChildIndex ) override; |
86 | | virtual void SAL_CALL clearAccessibleSelection( ) override; |
87 | | virtual void SAL_CALL selectAllAccessibleChildren( ) override; |
88 | | virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount( ) override; |
89 | | virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) override; |
90 | | virtual void SAL_CALL deselectAccessibleChild( sal_Int64 nSelectedChildIndex ) override; |
91 | | |
92 | | virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override; |
93 | | bool IsInDropDown() const; |
94 | | void HandleDropOpen(); |
95 | | void ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent, bool b_IsDropDownList); |
96 | | void UpdateSelection_Acc (std::u16string_view sTextOfSelectedItem, bool b_IsDropDownList); |
97 | | void UpdateSelection_Impl_Acc (bool b_IsDropDownList); |
98 | | |
99 | | static void NotifyListItem(css::uno::Any const & val); |
100 | 0 | IComboListBoxHelper* getListBoxHelper() { return m_pListBoxHelper.get(); } |
101 | | private: |
102 | | BoxType m_aBoxType; |
103 | | std::unique_ptr<IComboListBoxHelper> m_pListBoxHelper; |
104 | | std::vector<rtl::Reference<VCLXAccessibleListItem>> m_aAccessibleChildren; |
105 | | sal_Int32 m_nVisibleLineCount; |
106 | | /// Index in parent. This is settable from the outside. |
107 | | sal_Int32 m_nIndexInParent; |
108 | | sal_Int32 m_nLastTopEntry; |
109 | | sal_Int32 m_nLastSelectedPos; |
110 | | bool m_bDisableProcessEvent; |
111 | | bool m_bVisible; |
112 | | sal_Int32 m_nCurSelectedPos; |
113 | | |
114 | | |
115 | 0 | virtual ~VCLXAccessibleList() override = default; |
116 | | |
117 | | sal_Int64 implGetAccessibleChildCount(); |
118 | | |
119 | | /** This function is called from the implementation helper during a |
120 | | XComponent::dispose call. Free the list of items and the items themselves. |
121 | | */ |
122 | | virtual void SAL_CALL disposing() override; |
123 | | |
124 | | void disposeChildren(); |
125 | | |
126 | | /** This method adds the states |
127 | | AccessibleStateType::FOCUSABLE and possibly |
128 | | AccessibleStateType::MULTI_SELECTABLE to the state set |
129 | | of the base classes. |
130 | | */ |
131 | | virtual void FillAccessibleStateSet (sal_Int64& rStateSet) override; |
132 | | |
133 | | /** Create the specified child and insert it into the list of children. |
134 | | Sets the child's states. |
135 | | */ |
136 | | rtl::Reference<VCLXAccessibleListItem> CreateChild (sal_Int32 i); |
137 | | |
138 | | /** Call this method when the item list has been changed, i.e. items |
139 | | have been deleted or inserted. |
140 | | */ |
141 | | void HandleChangedItemList(); |
142 | | |
143 | | // VCLXAccessibleComponent |
144 | | virtual css::awt::Rectangle implGetBounds( ) override; |
145 | | |
146 | | /** We need to save the accessible parent to return it in getAccessibleParent(), |
147 | | because this method of the base class returns the wrong parent. |
148 | | */ |
149 | | rtl::Reference<VCLXAccessibleBox> m_xParent; |
150 | | |
151 | | void UpdateEntryRange_Impl(); |
152 | | void UpdateSelection_Impl(sal_Int32 nPos = 0); |
153 | | bool checkEntrySelected(sal_Int32 _nPos, |
154 | | css::uno::Any& _rNewValue, |
155 | | rtl::Reference< VCLXAccessibleListItem >& _rxNewAcc); |
156 | | void notifyVisibleStates(bool _bSetNew ); |
157 | | void UpdateVisibleLineCount(); |
158 | | }; |
159 | | |
160 | | |
161 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |