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 corrent 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 whitch 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(  ) throw (::com::sun::star::uno::RuntimeException);
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         throw (::com::sun::star::uno::RuntimeException);
87     /** For drop down list boxes the text field is a not editable
88         <type>VCLXAccessibleTextField</type>, for combo boxes it is an
89         editable <type>VLCAccessibleEdit</type>.
90     */
91     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
92         getAccessibleChild (sal_Int32 i)
93         throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
94     /** The role is always <const
95         scope="com::sun::star::accessibility">AccessibleRole::COMBO_BOX</const>.
96     */
97 	sal_Int16 SAL_CALL getAccessibleRole (void)
98         throw (::com::sun::star::uno::RuntimeException);
99 
100     sal_Int32 SAL_CALL getAccessibleIndexInParent (void)
101         throw (::com::sun::star::uno::RuntimeException);
102 
103 	// XAccessibleAction
104 
105     /** There is one action for drop down boxes and none for others.
106     */
107     virtual sal_Int32 SAL_CALL getAccessibleActionCount (void)
108         throw (::com::sun::star::uno::RuntimeException);
109     /** The action for drop down boxes lets the user toggle the visibility of the
110         popup menu.
111     */
112     virtual sal_Bool SAL_CALL doAccessibleAction (sal_Int32 nIndex)
113         throw (::com::sun::star::lang::IndexOutOfBoundsException,
114             ::com::sun::star::uno::RuntimeException);
115     /** The returned string is assoicated with resource
116         <const>RID_STR_ACC_ACTION_TOGGLEPOPUP</const>.
117     */
118     virtual ::rtl::OUString SAL_CALL getAccessibleActionDescription (sal_Int32 nIndex)
119         throw (::com::sun::star::lang::IndexOutOfBoundsException,
120             ::com::sun::star::uno::RuntimeException);
121     /** No keybinding returned so far.
122     */
123 	virtual ::com::sun::star::uno::Reference<
124 		::com::sun::star::accessibility::XAccessibleKeyBinding > SAL_CALL
125 			getAccessibleActionKeyBinding( sal_Int32 nIndex )
126 				throw (::com::sun::star::lang::IndexOutOfBoundsException,
127 					   ::com::sun::star::uno::RuntimeException);
128 
129 	// XComponent
130 
131     /** This method is called from the implementation helper during an
132         XComponent::dispose() call.
133     */
134 	virtual void SAL_CALL disposing (void);
135 
136 	//=====  XAccessibleValue  ================================================
137 
138     virtual ::com::sun::star::uno::Any SAL_CALL getCurrentValue( )
139         throw (::com::sun::star::uno::RuntimeException);
140 
141     virtual sal_Bool SAL_CALL setCurrentValue(
142         const ::com::sun::star::uno::Any& aNumber )
143         throw (::com::sun::star::uno::RuntimeException);
144 
145     virtual ::com::sun::star::uno::Any SAL_CALL getMaximumValue(  )
146         throw (::com::sun::star::uno::RuntimeException);
147 
148     virtual ::com::sun::star::uno::Any SAL_CALL getMinimumValue(  )
149         throw (::com::sun::star::uno::RuntimeException);
IsDropDownBox()150 	bool IsDropDownBox() {return m_bIsDropDownBox;};
GetBoxType()151 	BoxType GetBoxType() { return m_aBoxType;};
152 protected:
153     /** Specifies whether the box is a combo box or a list box.  List boxes
154         have multi selection.
155     */
156     BoxType m_aBoxType;
157 
158     /// Specifies whether the box is a drop down box and thus has an action.
159     bool m_bIsDropDownBox;
160 
161     /// The child that represents the text field if there is one.
162     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>
163         m_xText;
164 
165     /// The child that contains the items of this box.
166     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>
167         m_xList;
168 
169     /** This flag specifies whether an object has a text field as child
170         regardless of whether that child being currently instantiated or
171         not.
172     */
173     bool m_bHasTextChild;
174 
175     /** This flag specifies whether an object has a list as child regardless
176         of whether that child being currently instantiated or not.  This
177         flag is always true in the current implementation because the list
178         child is just another wrapper arround this object and thus has the
179         same life time.
180     */
181     bool m_bHasListChild;
182 
183 	virtual ~VCLXAccessibleBox (void);
184 
185     /** Returns </true> when the object is valid.
186     */
187     virtual bool IsValid (void) const = 0;
188 
189 	virtual void ProcessWindowChildEvent (const VclWindowEvent& rVclWindowEvent);
190 	virtual void ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent);
191 
192 	virtual void	FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet );
193 
194 private:
195     /// Index in parent.  This is settable from the outside.
196 	sal_Int32 m_nIndexInParent;
197 };
198 
199 #endif
200 
201