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