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 #include <vos/mutex.hxx> 25 #include <tools/list.hxx> 26 #include <tools/color.hxx> 27 #include <tools/string.hxx> 28 #ifndef _IMAGE_HXX 29 #include <vcl/image.hxx> 30 #endif 31 #include <rtl/uuid.h> 32 #include <comphelper/accessibleselectionhelper.hxx> 33 #include <com/sun/star/accessibility/XAccessibleTable.hpp> 34 35 #include <vector> 36 class SvxShowCharSet; 37 38 namespace svx 39 { 40 typedef ::cppu::ImplHelper1 < ::com::sun::star::accessibility::XAccessible 41 > OAccessibleHelper_Base_2; 42 43 class SvxShowCharSetAcc; 44 /** The class SvxShowCharSetVirtualAcc is used as a virtual class which contains the table and the scrollbar. 45 In the vcl control, the table and the scrollbar exists in one class. This is not feasible for the accessibility api. 46 */ 47 class SvxShowCharSetVirtualAcc : public ::comphelper::OAccessibleComponentHelper, 48 public OAccessibleHelper_Base_2 49 { 50 SvxShowCharSet* mpParent; // the vcl control 51 SvxShowCharSetAcc* m_pTable; // the table, which holds the characters shown by the vcl control 52 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xAcc; // the ref to the table 53 protected: 54 virtual ~SvxShowCharSetVirtualAcc(); 55 56 virtual void SAL_CALL disposing(); 57 58 virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds( ); 59 public: 60 SvxShowCharSetVirtualAcc( SvxShowCharSet* pParent ); 61 62 // XInterface 63 DECLARE_XINTERFACE( ) 64 DECLARE_XTYPEPROVIDER( ) 65 66 // XAccessibleComponent 67 virtual void SAL_CALL grabFocus( ); 68 virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding( ); 69 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ); 70 //OAccessibleContextHelper 71 // XAccessibleContext - still waiting to be overwritten 72 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ); 73 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ); 74 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ); 75 virtual sal_Int16 SAL_CALL getAccessibleRole( ); 76 virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ); 77 virtual ::rtl::OUString SAL_CALL getAccessibleName( ); 78 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ); 79 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ); 80 getAccessibleContext()81 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) { return this; } 82 virtual sal_Int32 SAL_CALL getForeground( ); 83 virtual sal_Int32 SAL_CALL getBackground( ); 84 85 86 // call the fireEvent method from the table when it exists. 87 void SAL_CALL fireEvent( 88 const sal_Int16 _nEventId, 89 const ::com::sun::star::uno::Any& _rOldValue, 90 const ::com::sun::star::uno::Any& _rNewValue 91 ); 92 93 // simple access methods getTable() const94 inline SvxShowCharSetAcc* getTable() const { return m_pTable; } getCharSetControl() const95 inline SvxShowCharSet* getCharSetControl() const { return mpParent; } 96 }; 97 98 99 class SvxShowCharSetItemAcc; 100 // ---------------- 101 // - SvxShowCharSetItem - 102 // ---------------- 103 /** Simple struct to hold some information about the single items of the table. 104 */ 105 struct SvxShowCharSetItem 106 { 107 SvxShowCharSet& mrParent; 108 sal_uInt16 mnId; 109 XubString maText; 110 Rectangle maRect; 111 SvxShowCharSetItemAcc* m_pItem; 112 SvxShowCharSetAcc* m_pParent; 113 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xAcc; 114 115 SvxShowCharSetItem( SvxShowCharSet& rParent,SvxShowCharSetAcc* _pParent,sal_uInt16 _nPos ); 116 ~SvxShowCharSetItem(); 117 118 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetAccessible(); 119 void ClearAccessible(); 120 }; 121 122 // ----------------------------------------------------------------------------- 123 124 typedef ::cppu::ImplHelper2 < ::com::sun::star::accessibility::XAccessible, 125 ::com::sun::star::accessibility::XAccessibleTable 126 > OAccessibleHelper_Base; 127 // --------------- 128 // - SvxShowCharSetAcc - 129 // --------------- 130 /** The table implemtentation of the vcl control. 131 */ 132 133 class SvxShowCharSetAcc : public ::comphelper::OAccessibleSelectionHelper, 134 public OAccessibleHelper_Base 135 { 136 ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > > m_aChildren; 137 SvxShowCharSetVirtualAcc* m_pParent; // the virtual parent 138 protected: 139 virtual void SAL_CALL disposing(); 140 public: 141 SvxShowCharSetAcc( SvxShowCharSetVirtualAcc* _pParent ); 142 143 DECLARE_XINTERFACE( ) 144 DECLARE_XTYPEPROVIDER( ) 145 146 // XAccessibleComponent 147 virtual void SAL_CALL grabFocus( ); 148 virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding( ); 149 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ); 150 151 //OAccessibleContextHelper 152 // XAccessibleContext - still waiting to be overwritten 153 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ); 154 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ); 155 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ); 156 virtual sal_Int16 SAL_CALL getAccessibleRole( ); 157 virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ); 158 virtual ::rtl::OUString SAL_CALL getAccessibleName( ); 159 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ); 160 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ); 161 getAccessibleContext()162 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) { return this; } 163 virtual sal_Int32 SAL_CALL getForeground( ); 164 virtual sal_Int32 SAL_CALL getBackground( ); 165 166 // XAccessibleTable 167 virtual sal_Int32 SAL_CALL getAccessibleRowCount( ); 168 virtual sal_Int32 SAL_CALL getAccessibleColumnCount( ); 169 virtual ::rtl::OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow ); 170 virtual ::rtl::OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn ); 171 virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ); 172 virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ); 173 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders( ); 174 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders( ); 175 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows( ); 176 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns( ); 177 virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ); 178 virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ); 179 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ); 180 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleCaption( ); 181 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleSummary( ); 182 virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ); 183 virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ); 184 virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ); 185 virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ); 186 187 fireEvent(const sal_Int16 _nEventId,const::com::sun::star::uno::Any & _rOldValue,const::com::sun::star::uno::Any & _rNewValue)188 inline void SAL_CALL fireEvent( 189 const sal_Int16 _nEventId, 190 const ::com::sun::star::uno::Any& _rOldValue, 191 const ::com::sun::star::uno::Any& _rNewValue 192 ) 193 { 194 NotifyAccessibleEvent(_nEventId,_rOldValue,_rNewValue); 195 } 196 protected: 197 198 virtual ~SvxShowCharSetAcc(); 199 200 // OCommonAccessibleSelection 201 // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) 202 virtual sal_Bool 203 implIsSelected( sal_Int32 nAccessibleChildIndex ); 204 205 // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) 206 virtual void 207 implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect ); 208 209 // OCommonAccessibleComponent 210 /// implements the calculation of the bounding rectangle - still waiting to be overwritten 211 virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds( ); 212 }; 213 214 // ---------------- 215 // - SvxShowCharSetItemAcc - 216 // ---------------- 217 /** The child implementation of the table. 218 */ 219 class SvxShowCharSetItemAcc : public ::comphelper::OAccessibleComponentHelper, 220 public OAccessibleHelper_Base_2 221 { 222 private: 223 SvxShowCharSetItem* mpParent; 224 protected: 225 virtual ~SvxShowCharSetItemAcc(); 226 227 // OCommonAccessibleComponent 228 /// implements the calculation of the bounding rectangle - still waiting to be overwritten 229 virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds( ); 230 public: 231 232 // XInterface 233 DECLARE_XINTERFACE( ) 234 DECLARE_XTYPEPROVIDER( ) 235 236 SvxShowCharSetItemAcc( SvxShowCharSetItem* pParent ); 237 238 void ParentDestroyed(); 239 240 // XAccessibleComponent 241 virtual void SAL_CALL grabFocus( ); 242 virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding( ); 243 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ); 244 245 //OAccessibleContextHelper 246 // XAccessibleContext - still waiting to be overwritten 247 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ); 248 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ); 249 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ); 250 virtual sal_Int16 SAL_CALL getAccessibleRole( ); 251 virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ); 252 virtual ::rtl::OUString SAL_CALL getAccessibleName( ); 253 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ); 254 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ); 255 getAccessibleContext()256 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) { return this; } 257 getForeground()258 virtual sal_Int32 SAL_CALL getForeground( ) { return mpParent->m_pParent->getForeground(); } getBackground()259 virtual sal_Int32 SAL_CALL getBackground( ) { return mpParent->m_pParent->getBackground(); } 260 fireEvent(const sal_Int16 _nEventId,const::com::sun::star::uno::Any & _rOldValue,const::com::sun::star::uno::Any & _rNewValue)261 inline void SAL_CALL fireEvent( 262 const sal_Int16 _nEventId, 263 const ::com::sun::star::uno::Any& _rOldValue, 264 const ::com::sun::star::uno::Any& _rNewValue 265 ) 266 { 267 NotifyAccessibleEvent(_nEventId,_rOldValue,_rNewValue); 268 } 269 }; 270 } 271