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_ACCESSIBILITY_INC_STANDARD_VCLXACCESSIBLELIST_HXX
21 #define INCLUDED_ACCESSIBILITY_INC_STANDARD_VCLXACCESSIBLELIST_HXX
26 #include <standard/vclxaccessibleedit.hxx>
27 #include <com/sun/star/accessibility/AccessibleRole.hpp>
28 #include <com/sun/star/accessibility/XAccessibleAction.hpp>
29 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
30 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
31 #include <cppuhelper/implbase2.hxx>
33 typedef ::cppu::ImplHelper2
<
34 css::accessibility::XAccessible
,
35 css::accessibility::XAccessibleSelection
36 > VCLXAccessibleList_BASE
;
38 typedef std::vector
< css::uno::WeakReference
< css::accessibility::XAccessible
> >
41 namespace accessibility
43 class IComboListBoxHelper
;
47 /** Base class for the list contained in list- and combo boxes. This class
48 does not support selection because lists of combo boxes give no direct
49 access to their underlying list implementation. Look into derived
50 classes for selection.
52 class VCLXAccessibleList final
53 : public VCLXAccessibleComponent
,
54 public VCLXAccessibleList_BASE
57 enum BoxType
{COMBOBOX
, LISTBOX
};
59 VCLXAccessibleList (VCLXWindow
* pVCLXindow
, BoxType aBoxType
,
60 const css::uno::Reference
<
61 css::accessibility::XAccessible
>& _xParent
);
63 /** The index that is passed to this method is returned on following
64 calls to getAccessibleIndexInParent.
66 void SetIndexInParent (sal_Int32 nIndex
);
68 /** Process some of the events and delegate the rest to the base classes.
70 virtual void ProcessWindowEvent (const VclWindowEvent
& rVclWindowEvent
) override
;
71 virtual void FillAccessibleRelationSet( utl::AccessibleRelationSetHelper
& rRelationSet
) override
;
73 /** Called on reception of selection events this method checks all known
74 list items for a possible change in their selection state and
75 updates that accordingly. No accessibility events are send because
76 the XAccessibleSelection interface is not supported and the items
78 @param sTextOfSelectedItem
79 This string contains the text of the currently selected
80 item. It is used to retrieve the index of that item.
82 void UpdateSelection (const OUString
& sTextOfSelectedItem
);
88 DECLARE_XTYPEPROVIDER()
91 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
> SAL_CALL
92 getAccessibleContext() override
;
95 virtual sal_Int32 SAL_CALL
getAccessibleChildCount() override final
;
96 css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
97 getAccessibleChild (sal_Int32 i
) override
;
98 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
99 getAccessibleParent( ) override
;
101 /** The index returned as index in parent is always the one set with the
102 SetIndexInParent() method.
104 virtual sal_Int32 SAL_CALL
getAccessibleIndexInParent() override
;
105 virtual sal_Int16 SAL_CALL
getAccessibleRole() override
;
108 virtual OUString SAL_CALL
getImplementationName() override
;
109 // Return list specific services.
110 virtual css::uno::Sequence
< OUString
> SAL_CALL
111 getSupportedServiceNames() override
;
113 // XAccessibleSelection
114 virtual void SAL_CALL
selectAccessibleChild( sal_Int32 nChildIndex
) override
;
115 virtual sal_Bool SAL_CALL
isAccessibleChildSelected( sal_Int32 nChildIndex
) override
;
116 virtual void SAL_CALL
clearAccessibleSelection( ) override
;
117 virtual void SAL_CALL
selectAllAccessibleChildren( ) override
;
118 virtual sal_Int32 SAL_CALL
getSelectedAccessibleChildCount( ) override
;
119 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
) override
;
120 virtual void SAL_CALL
deselectAccessibleChild( sal_Int32 nSelectedChildIndex
) override
;
122 virtual css::awt::Point SAL_CALL
getLocationOnScreen( ) override
;
124 void HandleDropOpen();
125 void ProcessWindowEvent (const VclWindowEvent
& rVclWindowEvent
, bool b_IsDropDownList
);
126 void UpdateSelection_Acc (const ::rtl::OUString
& sTextOfSelectedItem
, bool b_IsDropDownList
);
127 void UpdateSelection_Impl_Acc (bool b_IsDropDownList
);
129 static void NotifyListItem(css::uno::Any
const & val
);
130 ::accessibility::IComboListBoxHelper
* getListBoxHelper() { return m_pListBoxHelper
.get(); }
133 std::unique_ptr
<::accessibility::IComboListBoxHelper
> m_pListBoxHelper
;
134 ListItems m_aAccessibleChildren
;
135 sal_Int32 m_nVisibleLineCount
;
136 /// Index in parent. This is settable from the outside.
137 sal_Int32 m_nIndexInParent
;
138 sal_Int32 m_nLastTopEntry
;
139 sal_Int32 m_nLastSelectedPos
;
140 bool m_bDisableProcessEvent
;
142 sal_Int32 m_nCurSelectedPos
;
145 virtual ~VCLXAccessibleList() override
= default;
147 sal_Int32
implGetAccessibleChildCount();
149 /** This function is called from the implementation helper during a
150 XComponent::dispose call. Free the list of items and the items themselves.
152 virtual void SAL_CALL
disposing() override
;
154 /** This method adds the states
155 AccessibleStateType::FOCUSABLE and possibly
156 AccessibleStateType::MULTI_SELECTABLE to the state set
159 virtual void FillAccessibleStateSet (utl::AccessibleStateSetHelper
& rStateSet
) override
;
161 /** Create the specified child and insert it into the list of children.
162 Sets the child's states.
164 css::uno::Reference
< css::accessibility::XAccessible
>
165 CreateChild (sal_Int32 i
);
167 /** Call this method when the item list has been changed, i.e. items
168 have been deleted or inserted.
170 void HandleChangedItemList();
172 // VCLXAccessibleComponent
173 virtual css::awt::Rectangle
implGetBounds( ) override
;
175 /** We need to save the accessible parent to return it in getAccessibleParent(),
176 because this method of the base class returns the wrong parent.
178 css::uno::Reference
< css::accessibility::XAccessible
> m_xParent
;
180 void UpdateEntryRange_Impl();
181 void UpdateSelection_Impl(sal_Int32 nPos
= 0);
182 bool checkEntrySelected(sal_Int32 _nPos
,
183 css::uno::Any
& _rNewValue
,
184 css::uno::Reference
< css::accessibility::XAccessible
>& _rxNewAcc
);
185 void notifyVisibleStates(bool _bSetNew
);
186 void UpdateVisibleLineCount();
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */