xref: /trunk/main/accessibility/inc/accessibility/standard/vclxaccessiblebox.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef ACCESSIBILITY_STANDARD_VCLXACCESSIBLEBOX_HXX
25 #define ACCESSIBILITY_STANDARD_VCLXACCESSIBLEBOX_HXX
26 
27 #include <map>
28 #include <accessibility/standard/vclxaccessibleedit.hxx>
29 #ifndef _COM_SUN_STAR_ACCESSIBILITY_STANDARD_ACCESSIBLEROLE_HPP_
30 #include <com/sun/star/accessibility/AccessibleRole.hpp>
31 #endif
32 #include <com/sun/star/accessibility/XAccessibleKeyBinding.hpp>
33 #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLEVALUE_HPP_
34 #include <com/sun/star/accessibility/XAccessibleValue.hpp>
35 #endif
36 #ifndef _CPPUHELPER_IMPLBASE2_HXX
37 #include <cppuhelper/implbase2.hxx>
38 #endif
39 
40 
41 typedef ::cppu::ImplHelper3<
42     ::com::sun::star::accessibility::XAccessible,
43     ::com::sun::star::accessibility::XAccessibleValue,
44     ::com::sun::star::accessibility::XAccessibleAction
45     > VCLXAccessibleBox_BASE;
46 
47 
48 /** Base class for list- and combo boxes.  This class manages the box'
49     children.  The classed derived from this one have only to implement the
50     <member>IsValid</member> method and return the current implementation name.
51 */
52 class VCLXAccessibleBox
53     : public VCLXAccessibleComponent,
54       public VCLXAccessibleBox_BASE
55 {
56 public:
57     enum BoxType {COMBOBOX, LISTBOX};
58 
59     /** The constructor is initialized with the box type which may be
60         either <const>COMBOBOX</const> or <const>LISTBOX</const> and a flag
61         indicating whether the box is a drop down box.
62     */
63     VCLXAccessibleBox (VCLXWindow* pVCLXindow, BoxType aType, bool bIsDropDownBox);
64 
65     // XTypeProvider
66     DECLARE_XTYPEPROVIDER()
67 
68     // XInterface
69     DECLARE_XINTERFACE()
70 
71 
72 
73     // XAccessible
74 
75     virtual ::com::sun::star::uno::Reference<
76         ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL
77             getAccessibleContext(  );
78 
79     // XAccessibleContext
80 
81     /** Each object has one or two children: an optional text field and the
82         actual list.  The text field is not provided for non drop down list
83         boxes.
84     */
85     sal_Int32 SAL_CALL getAccessibleChildCount (void);
86     /** For drop down list boxes the text field is a not editable
87         <type>VCLXAccessibleTextField</type>, for combo boxes it is an
88         editable <type>VLCAccessibleEdit</type>.
89     */
90     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
91         getAccessibleChild (sal_Int32 i);
92     /** The role is always <const
93         scope="com::sun::star::accessibility">AccessibleRole::COMBO_BOX</const>.
94     */
95     sal_Int16 SAL_CALL getAccessibleRole (void);
96 
97     sal_Int32 SAL_CALL getAccessibleIndexInParent (void);
98 
99     // XAccessibleAction
100 
101     /** There is one action for drop down boxes and none for others.
102     */
103     virtual sal_Int32 SAL_CALL getAccessibleActionCount (void);
104     /** The action for drop down boxes lets the user toggle the visibility of the
105         popup menu.
106     */
107     virtual sal_Bool SAL_CALL doAccessibleAction (sal_Int32 nIndex);
108     /** The returned string is associated with resource
109         <const>RID_STR_ACC_ACTION_TOGGLEPOPUP</const>.
110     */
111     virtual ::rtl::OUString SAL_CALL getAccessibleActionDescription (sal_Int32 nIndex);
112     /** No keybinding returned so far.
113     */
114     virtual ::com::sun::star::uno::Reference<
115         ::com::sun::star::accessibility::XAccessibleKeyBinding > SAL_CALL
116             getAccessibleActionKeyBinding( sal_Int32 nIndex );
117 
118     // XComponent
119 
120     /** This method is called from the implementation helper during an
121         XComponent::dispose() call.
122     */
123     virtual void SAL_CALL disposing (void);
124 
125     //=====  XAccessibleValue  ================================================
126 
127     virtual ::com::sun::star::uno::Any SAL_CALL getCurrentValue( );
128 
129     virtual sal_Bool SAL_CALL setCurrentValue(
130         const ::com::sun::star::uno::Any& aNumber );
131 
132     virtual ::com::sun::star::uno::Any SAL_CALL getMaximumValue(  );
133 
134     virtual ::com::sun::star::uno::Any SAL_CALL getMinimumValue(  );
IsDropDownBox()135     bool IsDropDownBox() {return m_bIsDropDownBox;};
GetBoxType()136     BoxType GetBoxType() { return m_aBoxType;};
137 protected:
138     /** Specifies whether the box is a combo box or a list box.  List boxes
139         have multi selection.
140     */
141     BoxType m_aBoxType;
142 
143     /// Specifies whether the box is a drop down box and thus has an action.
144     bool m_bIsDropDownBox;
145 
146     /// The child that represents the text field if there is one.
147     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>
148         m_xText;
149 
150     /// The child that contains the items of this box.
151     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>
152         m_xList;
153 
154     /** This flag specifies whether an object has a text field as child
155         regardless of whether that child being currently instantiated or
156         not.
157     */
158     bool m_bHasTextChild;
159 
160     /** This flag specifies whether an object has a list as child regardless
161         of whether that child being currently instantiated or not.  This
162         flag is always true in the current implementation because the list
163         child is just another wrapper around this object and thus has the
164         same life time.
165     */
166     bool m_bHasListChild;
167 
168     virtual ~VCLXAccessibleBox (void);
169 
170     /** Returns </true> when the object is valid.
171     */
172     virtual bool IsValid (void) const = 0;
173 
174     virtual void ProcessWindowChildEvent (const VclWindowEvent& rVclWindowEvent);
175     virtual void ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent);
176 
177     virtual void    FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet );
178 
179 private:
180     /// Index in parent.  This is settable from the outside.
181     sal_Int32 m_nIndexInParent;
182 };
183 
184 #endif
185