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 80 /** Called on reception of selection events this method checks all known 81 list items for a possible change in their selection state and 82 updates that accordingly. No accessibility events are send because 83 the XAccessibleSelection interface is not supported and the items 84 are transient. 85 @param sTextOfSelectedItem 86 This string contains the text of the the currently selected 87 item. It is used to retrieve the index of that item. 88 */ 89 void UpdateSelection (::rtl::OUString sTextOfSelectedItem); 90 91 // XInterface 92 DECLARE_XINTERFACE() 93 94 // XTypeProvider 95 DECLARE_XTYPEPROVIDER() 96 97 // XAccessible 98 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL 99 getAccessibleContext (void) 100 throw (::com::sun::star::uno::RuntimeException); 101 102 // XAccessibleContext 103 virtual sal_Int32 SAL_CALL getAccessibleChildCount (void) 104 throw (::com::sun::star::uno::RuntimeException); 105 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL 106 getAccessibleChild (sal_Int32 i) 107 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 108 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL 109 getAccessibleParent( ) 110 throw (::com::sun::star::uno::RuntimeException); 111 112 /** The index returned as index in parent is always the one set with the 113 <member>SetIndexInParent()</member> method. 114 */ 115 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent (void) 116 throw (::com::sun::star::uno::RuntimeException); 117 virtual sal_Int16 SAL_CALL getAccessibleRole (void) 118 throw (::com::sun::star::uno::RuntimeException); 119 120 // XAccessibleComponent 121 virtual sal_Bool SAL_CALL contains (const ::com::sun::star::awt::Point& aPoint) 122 throw (::com::sun::star::uno::RuntimeException); 123 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL 124 getAccessibleAt (const ::com::sun::star::awt::Point& aPoint) 125 throw (::com::sun::star::uno::RuntimeException); 126 127 128 // XServiceInfo 129 virtual ::rtl::OUString SAL_CALL getImplementationName (void) 130 throw (::com::sun::star::uno::RuntimeException); 131 // Return list specific services. 132 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 133 getSupportedServiceNames (void) 134 throw (::com::sun::star::uno::RuntimeException); 135 136 // XAccessibleSelection 137 virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 138 virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 139 virtual void SAL_CALL clearAccessibleSelection( ) throw (::com::sun::star::uno::RuntimeException); 140 virtual void SAL_CALL selectAllAccessibleChildren( ) throw (::com::sun::star::uno::RuntimeException); 141 virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); 142 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); 143 virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 144 145 virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException); 146 147 protected: 148 BoxType m_aBoxType; 149 ::accessibility::IComboListBoxHelper* m_pListBoxHelper; 150 ListItems m_aAccessibleChildren; 151 sal_Int32 m_nVisibleLineCount; 152 /// Index in parent. This is settable from the outside. 153 sal_Int32 m_nIndexInParent; 154 sal_Int32 m_nLastTopEntry; 155 sal_uInt16 m_nLastSelectedPos; 156 bool m_bDisableProcessEvent; 157 bool m_bVisible; 158 159 160 161 /// The currently selected item. 162 ::com::sun::star::uno::WeakReference< ::com::sun::star::accessibility::XAccessible> 163 m_xSelectedItem; 164 165 virtual ~VCLXAccessibleList (void); 166 167 /** This function is called from the implementation helper during a 168 XComponent::dispose call. Free the list of items and the items themselves. 169 */ 170 virtual void SAL_CALL disposing (void); 171 172 /** This method adds the states 173 <const>AccessibleStateType::FOCUSABLE</const> and possibly 174 <const>AccessibleStateType::MULTI_SELECTABLE</const> to the state set 175 of the base classes. 176 */ 177 virtual void FillAccessibleStateSet (utl::AccessibleStateSetHelper& rStateSet); 178 179 /** Create the specified child and insert it into the list of children. 180 Sets the child's states. 181 */ 182 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 183 CreateChild (sal_Int32 i); 184 185 /** Call this method when the item list has been changed, i.e. items 186 have been deleted or inserted. 187 @param bItemInserted 188 Indicate whether items have been inserted (<TRUE/>) or removed 189 (<FALSE/>). 190 @param nIndex 191 Index of the new or removed item. A value of -1 indicates that 192 the whole list has been cleared. 193 */ 194 virtual void HandleChangedItemList (bool bItemInserted, sal_Int32 nIndex); 195 196 // VCLXAccessibleComponent 197 virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds( ) throw (::com::sun::star::uno::RuntimeException); 198 199 private: 200 /** We need to save the accessible parent to return it in <type>getAccessibleParent()</type>, 201 because this method of the base class returns the wrong parent. 202 */ 203 ::com::sun::star::uno::Reference< 204 ::com::sun::star::accessibility::XAccessible > m_xParent; 205 206 207 /** dispose all items aand clears the container 208 */ 209 void clearItems(); 210 211 void adjustEntriesIndexInParent(ListItems::iterator& _aBegin,::std::mem_fun_t<bool,VCLXAccessibleListItem>& _rMemFun); 212 void UpdateEntryRange_Impl (void); 213 protected: 214 void UpdateSelection_Impl (sal_uInt16 nPos = 0); 215 sal_Bool checkEntrySelected(sal_uInt16 _nPos, 216 ::com::sun::star::uno::Any& _rNewValue, 217 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxNewAcc); 218 private: 219 void notifyVisibleStates(sal_Bool _bSetNew ); 220 void UpdateVisibleLineCount(); 221 }; 222 223 #endif 224 225