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_VCLXACCESSIBLELIST_HXX 25 #define ACCESSIBILITY_STANDARD_VCLXACCESSIBLELIST_HXX 26 27 #include <vector> 28 #include <functional> 29 #include "accessibility/standard/vclxaccessiblelistitem.hxx" 30 #include <accessibility/standard/vclxaccessibleedit.hxx> 31 #ifndef _COM_SUN_STAR_ACCESSIBILITY_STANDARD_ACCESSIBLEROLE_HPP_ 32 #include <com/sun/star/accessibility/AccessibleRole.hpp> 33 #endif 34 #include <com/sun/star/accessibility/XAccessibleAction.hpp> 35 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> 36 #include <com/sun/star/accessibility/XAccessibleSelection.hpp> 37 #ifndef _CPPUHELPER_IMPLBASE2_HXX 38 #include <cppuhelper/implbase2.hxx> 39 #endif 40 41 typedef ::cppu::ImplHelper2< 42 ::com::sun::star::accessibility::XAccessible, 43 ::com::sun::star::accessibility::XAccessibleSelection 44 > VCLXAccessibleList_BASE; 45 46 typedef std::vector< ::com::sun::star::uno::WeakReference< ::com::sun::star::accessibility::XAccessible > > 47 ListItems; 48 49 namespace accessibility 50 { 51 class IComboListBoxHelper; 52 } 53 54 55 /** Base class for the list contained in list- and combo boxes. This class 56 does not support selection because lists of combo boxes give no direct 57 access to their underlying list implementation. Look into derived 58 classes for selection. 59 */ 60 class VCLXAccessibleList 61 : public VCLXAccessibleComponent, 62 public VCLXAccessibleList_BASE 63 { 64 public: 65 enum BoxType {COMBOBOX, LISTBOX}; 66 67 VCLXAccessibleList (VCLXWindow* pVCLXindow, BoxType aBoxType, 68 const ::com::sun::star::uno::Reference< 69 ::com::sun::star::accessibility::XAccessible >& _xParent); 70 71 /** The index that is passed to this method is returned on following 72 calls to <member>getAccessibleIndexInParent</member>. 73 */ 74 void SetIndexInParent (sal_Int32 nIndex); 75 76 /** Process some of the events and delegate the rest to the base classes. 77 */ 78 virtual void ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent); 79 virtual void FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet ); 80 81 /** Called on reception of selection events this method checks all known 82 list items for a possible change in their selection state and 83 updates that accordingly. No accessibility events are send because 84 the XAccessibleSelection interface is not supported and the items 85 are transient. 86 @param sTextOfSelectedItem 87 This string contains the text of the the currently selected 88 item. It is used to retrieve the index of that item. 89 */ 90 void UpdateSelection (::rtl::OUString sTextOfSelectedItem); 91 92 // XInterface 93 DECLARE_XINTERFACE() 94 95 // XTypeProvider 96 DECLARE_XTYPEPROVIDER() 97 98 // XAccessible 99 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL 100 getAccessibleContext (void) 101 throw (::com::sun::star::uno::RuntimeException); 102 103 // XAccessibleContext 104 virtual sal_Int32 SAL_CALL getAccessibleChildCount (void) 105 throw (::com::sun::star::uno::RuntimeException); 106 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL 107 getAccessibleChild (sal_Int32 i) 108 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 109 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL 110 getAccessibleParent( ) 111 throw (::com::sun::star::uno::RuntimeException); 112 113 /** The index returned as index in parent is always the one set with the 114 <member>SetIndexInParent()</member> method. 115 */ 116 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent (void) 117 throw (::com::sun::star::uno::RuntimeException); 118 virtual sal_Int16 SAL_CALL getAccessibleRole (void) 119 throw (::com::sun::star::uno::RuntimeException); 120 121 // XAccessibleComponent 122 virtual sal_Bool SAL_CALL contains (const ::com::sun::star::awt::Point& aPoint) 123 throw (::com::sun::star::uno::RuntimeException); 124 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL 125 getAccessibleAt (const ::com::sun::star::awt::Point& aPoint) 126 throw (::com::sun::star::uno::RuntimeException); 127 128 129 // XServiceInfo 130 virtual ::rtl::OUString SAL_CALL getImplementationName (void) 131 throw (::com::sun::star::uno::RuntimeException); 132 // Return list specific services. 133 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 134 getSupportedServiceNames (void) 135 throw (::com::sun::star::uno::RuntimeException); 136 137 // XAccessibleSelection 138 virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 139 virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 140 virtual void SAL_CALL clearAccessibleSelection( ) throw (::com::sun::star::uno::RuntimeException); 141 virtual void SAL_CALL selectAllAccessibleChildren( ) throw (::com::sun::star::uno::RuntimeException); 142 virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); 143 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 144 virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 145 146 virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException); 147 sal_Bool IsInDropDown(); 148 void HandleDropOpen(); 149 virtual void ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent, bool b_IsDropDownList); 150 void UpdateSelection_Acc (::rtl::OUString sTextOfSelectedItem, bool b_IsDropDownList); 151 void UpdateSelection_Impl_Acc (bool b_IsDropDownList); 152 153 void UpdateFocus_Impl_Acc ( sal_uInt16 nPos, bool b_IsDropDownList) ; 154 void NotifyListItem(::com::sun::star::uno::Any& val); 155 protected: 156 BoxType m_aBoxType; 157 ::accessibility::IComboListBoxHelper* m_pListBoxHelper; 158 ListItems m_aAccessibleChildren; 159 sal_Int32 m_nVisibleLineCount; 160 /// Index in parent. This is settable from the outside. 161 sal_Int32 m_nIndexInParent; 162 sal_Int32 m_nLastTopEntry; 163 sal_uInt16 m_nLastSelectedPos; 164 bool m_bDisableProcessEvent; 165 bool m_bVisible; 166 sal_uInt16 m_nCurSelectedPos; 167 168 169 /// The currently selected item. 170 ::com::sun::star::uno::WeakReference< ::com::sun::star::accessibility::XAccessible> 171 m_xSelectedItem; 172 173 virtual ~VCLXAccessibleList (void); 174 175 /** This function is called from the implementation helper during a 176 XComponent::dispose call. Free the list of items and the items themselves. 177 */ 178 virtual void SAL_CALL disposing (void); 179 180 /** This method adds the states 181 <const>AccessibleStateType::FOCUSABLE</const> and possibly 182 <const>AccessibleStateType::MULTI_SELECTABLE</const> to the state set 183 of the base classes. 184 */ 185 virtual void FillAccessibleStateSet (utl::AccessibleStateSetHelper& rStateSet); 186 187 /** Create the specified child and insert it into the list of children. 188 Sets the child's states. 189 */ 190 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 191 CreateChild (sal_Int32 i); 192 193 /** Call this method when the item list has been changed, i.e. items 194 have been deleted or inserted. 195 @param bItemInserted 196 Indicate whether items have been inserted (<TRUE/>) or removed 197 (<FALSE/>). 198 @param nIndex 199 Index of the new or removed item. A value of -1 indicates that 200 the whole list has been cleared. 201 */ 202 virtual void HandleChangedItemList (bool bItemInserted, sal_Int32 nIndex); 203 204 // VCLXAccessibleComponent 205 virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds( ) throw (::com::sun::star::uno::RuntimeException); 206 207 private: 208 /** We need to save the accessible parent to return it in <type>getAccessibleParent()</type>, 209 because this method of the base class returns the wrong parent. 210 */ 211 ::com::sun::star::uno::Reference< 212 ::com::sun::star::accessibility::XAccessible > m_xParent; 213 214 215 /** dispose all items aand clears the container 216 */ 217 void clearItems(); 218 219 void adjustEntriesIndexInParent(ListItems::iterator& _aBegin,::std::mem_fun_t<bool,VCLXAccessibleListItem>& _rMemFun); 220 void UpdateEntryRange_Impl (void); 221 protected: 222 void UpdateSelection_Impl (sal_uInt16 nPos = 0); 223 sal_Bool checkEntrySelected(sal_uInt16 _nPos, 224 ::com::sun::star::uno::Any& _rNewValue, 225 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxNewAcc); 226 private: 227 void notifyVisibleStates(sal_Bool _bSetNew ); 228 void UpdateVisibleLineCount(); 229 }; 230 231 #endif 232 233