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 _SVX_ACCESSIBILITY_ACCESSIBLE_TABLE_SHAPE_HXX 25 #define _SVX_ACCESSIBILITY_ACCESSIBLE_TABLE_SHAPE_HXX 26 27 #include <com/sun/star/table/XTable.hpp> 28 #include <com/sun/star/accessibility/XAccessibleTable.hpp> 29 #include <com/sun/star/accessibility/XAccessibleSelection.hpp> 30 #include <com/sun/star/util/XModifyListener.hpp> 31 32 #include <rtl/ref.hxx> 33 34 #include <cppuhelper/implbase2.hxx> 35 36 #include <svx/AccessibleShape.hxx> 37 //IAccessibility2 Implementation 2009----- 38 #include <com/sun/star/view/XSelectionChangeListener.hpp> 39 // SD table ACC----, added by Steve Yin 40 #include <com/sun/star/accessibility/XAccessibleTableSelection.hpp> 41 #include <cppuhelper/compbase5.hxx> 42 // ----SD table ACC 43 //-----IAccessibility2 Implementation 2009 44 45 #include <boost/noncopyable.hpp> 46 47 namespace sdr { namespace table { 48 class SvxTableController; 49 } } 50 51 namespace accessibility 52 { 53 class AccessibleTableShapeImpl; 54 //IAccessibility2 Implementation 2009 55 class AccessibleCell; 56 57 //IAccessibility2 Implementation 2009----- 58 /*typedef ::cppu::ImplInheritanceHelper2< AccessibleShape, 59 ::com::sun::star::accessibility::XAccessibleSelection, 60 ::com::sun::star::accessibility::XAccessibleTable 61 > AccessibleTableShape_Base;*/ 62 typedef ::cppu::ImplInheritanceHelper2< AccessibleShape, 63 ::com::sun::star::accessibility::XAccessibleTable, 64 ::com::sun::star::view::XSelectionChangeListener 65 > AccessibleTableShape_Base; 66 //-----IAccessibility2 Implementation 2009 67 /** @descr 68 */ 69 class AccessibleTableShape : boost::noncopyable, public AccessibleTableShape_Base, public ::com::sun::star::accessibility::XAccessibleTableSelection 70 { 71 public: 72 AccessibleTableShape( const AccessibleShapeInfo& rShapeInfo, const AccessibleShapeTreeInfo& rShapeTreeInfo ); 73 virtual ~AccessibleTableShape( ); 74 75 virtual void Init (void); 76 77 // XInterface 78 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); 79 virtual void SAL_CALL acquire( ) throw (); 80 virtual void SAL_CALL release( ) throw (); 81 82 // XAccessible 83 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL getAccessibleContext( ) throw(::com::sun::star::uno::RuntimeException); 84 85 // XAccessibleContext 86 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw(::com::sun::star::uno::RuntimeException); 87 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 88 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException); 89 virtual sal_Int16 SAL_CALL getAccessibleRole (void) throw (::com::sun::star::uno::RuntimeException); 90 91 // XAccessibleTable 92 virtual sal_Int32 SAL_CALL getAccessibleRowCount() throw (::com::sun::star::uno::RuntimeException); 93 virtual sal_Int32 SAL_CALL getAccessibleColumnCount( ) throw (::com::sun::star::uno::RuntimeException); 94 virtual ::rtl::OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 95 virtual ::rtl::OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 96 virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 97 virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 98 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders( ) throw (::com::sun::star::uno::RuntimeException); 99 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders( ) throw (::com::sun::star::uno::RuntimeException); 100 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows( ) throw (::com::sun::star::uno::RuntimeException); 101 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns( ) throw (::com::sun::star::uno::RuntimeException); 102 virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 103 virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 104 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 105 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleCaption( ) throw (::com::sun::star::uno::RuntimeException); 106 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleSummary( ) throw (::com::sun::star::uno::RuntimeException); 107 virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 108 virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 109 virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 110 virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 111 112 // XAccessibleSelection 113 virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw ( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 114 virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw ( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 115 virtual void SAL_CALL clearAccessibleSelection( ) throw ( ::com::sun::star::uno::RuntimeException ); 116 virtual void SAL_CALL selectAllAccessibleChildren( ) throw ( ::com::sun::star::uno::RuntimeException ); 117 virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) throw ( ::com::sun::star::uno::RuntimeException ); 118 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); 119 virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nChildIndex ) throw ( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 120 // SD table ACC----, added by Steve Yin 121 //===== XAccessibleTableSelection ============================================ 122 virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) 123 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; 124 virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) 125 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; 126 virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) 127 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; 128 virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) 129 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; 130 // ----SD table ACC 131 132 // XServiceInfo 133 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); 134 135 // XComponent 136 virtual void SAL_CALL disposing( ); 137 138 // XSelectionChangeListener 139 virtual void SAL_CALL 140 disposing (const ::com::sun::star::lang::EventObject& Source) 141 throw (::com::sun::star::uno::RuntimeException); 142 virtual void SAL_CALL 143 selectionChanged (const ::com::sun::star::lang::EventObject& rEvent) 144 throw (::com::sun::star::uno::RuntimeException); 145 sal_Int32 mnPreviousSelectionCount; 146 using AccessibleShape::disposing; 147 // SD table ACC----, added by Steve Yin 148 friend class AccessibleTableHeaderShape; 149 // Sym2_6134 150 void getColumnAndRow( sal_Int32 nChildIndex, sal_Int32& rnColumn, sal_Int32& rnRow ) throw (::com::sun::star::lang::IndexOutOfBoundsException ); 151 //Sym2_6108, overwrite the SetState & ResetState to do special operation for table cell's internal text 152 virtual sal_Bool SetState (sal_Int16 aState); 153 virtual sal_Bool ResetState (sal_Int16 aState); 154 // The following two methods are used to set state directly on table object, instread of the internal cell or paragraph. 155 sal_Bool SetStateDirectly (sal_Int16 aState); 156 sal_Bool ResetStateDirectly (sal_Int16 aState); 157 // Get the currently active cell which is text editing 158 AccessibleCell* GetActiveAccessibleCell(); 159 // ----SD table ACC 160 161 protected: 162 virtual ::rtl::OUString CreateAccessibleBaseName(void) throw (::com::sun::star::uno::RuntimeException); 163 164 sdr::table::SvxTableController* getTableController(); 165 166 void checkCellPosition( sal_Int32 nCol, sal_Int32 nRow ) throw ( ::com::sun::star::lang::IndexOutOfBoundsException ); 167 // Sym2_6134, move to public 168 //void getColumnAndRow( sal_Int32 nChildIndex, sal_Int32& rnColumn, sal_Int32& rnRow ) throw (::com::sun::star::lang::IndexOutOfBoundsException ); 169 170 private: 171 rtl::Reference< AccessibleTableShapeImpl > mxImpl; 172 // SD table ACC----, added by Steve Yin 173 sal_Int32 GetIndexOfSelectedChild( sal_Int32 nSelectedChildIndex ) const; 174 // ----SD table ACC 175 }; 176 177 // SD table ACC----, added by Steve Yin 178 typedef ::cppu::WeakImplHelper5< 179 ::com::sun::star::accessibility::XAccessible, 180 ::com::sun::star::accessibility::XAccessibleComponent, 181 ::com::sun::star::accessibility::XAccessibleContext, 182 ::com::sun::star::accessibility::XAccessibleTable, 183 ::com::sun::star::accessibility::XAccessibleTableSelection > 184 AccessibleTableHeaderShape_BASE; 185 186 class AccessibleTableHeaderShape : boost::noncopyable, 187 public MutexOwner, 188 public AccessibleTableHeaderShape_BASE 189 { 190 public: 191 // bRow, sal_True means rowheader, sal_False means columnheader 192 AccessibleTableHeaderShape( AccessibleTableShape* pTable, sal_Bool bRow ); 193 virtual ~AccessibleTableHeaderShape(); 194 195 // XAccessible 196 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL getAccessibleContext( ) throw(::com::sun::star::uno::RuntimeException); 197 198 // XAccessibleContext 199 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); 200 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 201 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException); 202 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException); 203 virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException); 204 virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException); 205 virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException); 206 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException); 207 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException); 208 virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException); 209 210 //XAccessibleComponent 211 virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); 212 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); 213 virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( ) throw (::com::sun::star::uno::RuntimeException); 214 virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException); 215 virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException); 216 virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException); 217 virtual sal_Int32 SAL_CALL getForeground( ) throw (::com::sun::star::uno::RuntimeException); 218 virtual sal_Int32 SAL_CALL getBackground( ) throw (::com::sun::star::uno::RuntimeException); 219 virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException); 220 221 // XAccessibleTable 222 virtual sal_Int32 SAL_CALL getAccessibleRowCount() throw (::com::sun::star::uno::RuntimeException); 223 virtual sal_Int32 SAL_CALL getAccessibleColumnCount( ) throw (::com::sun::star::uno::RuntimeException); 224 virtual ::rtl::OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 225 virtual ::rtl::OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 226 virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 227 virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 228 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders( ) throw (::com::sun::star::uno::RuntimeException); 229 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders( ) throw (::com::sun::star::uno::RuntimeException); 230 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows( ) throw (::com::sun::star::uno::RuntimeException); 231 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns( ) throw (::com::sun::star::uno::RuntimeException); 232 virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 233 virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 234 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 235 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleCaption( ) throw (::com::sun::star::uno::RuntimeException); 236 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleSummary( ) throw (::com::sun::star::uno::RuntimeException); 237 virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 238 virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 239 virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 240 virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 241 242 //===== XAccessibleTableSelection ============================================ 243 virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) 244 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; 245 virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) 246 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; 247 virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) 248 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; 249 virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) 250 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; 251 private: 252 SVX_DLLPRIVATE explicit AccessibleTableHeaderShape( const ::com::sun::star::uno::Reference< 253 ::com::sun::star::accessibility::XAccessible>& rxParent ); 254 sal_Bool mbRow; 255 rtl::Reference< AccessibleTableShape > mpTable; 256 }; 257 // ----SD table ACC 258 259 } // end of namespace accessibility 260 261 #endif 262