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 25 #ifndef _SC_ACCESSIBLESPREADSHEET_HXX 26 #define _SC_ACCESSIBLESPREADSHEET_HXX 27 28 #include "AccessibleTableBase.hxx" 29 #include "viewdata.hxx" 30 31 #include <vector> 32 33 #include "rangelst.hxx" 34 #include <map> 35 class ScMyAddress : public ScAddress 36 { 37 public: ScMyAddress()38 ScMyAddress() : ScAddress() {} ScMyAddress(SCCOL nColP,SCROW nRowP,SCTAB nTabP)39 ScMyAddress(SCCOL nColP, SCROW nRowP, SCTAB nTabP) : ScAddress(nColP, nRowP, nTabP) {} ScMyAddress(const ScAddress & rAddress)40 ScMyAddress(const ScAddress& rAddress) : ScAddress(rAddress) {} 41 operator <(const ScMyAddress & rAddress) const42 sal_Bool operator< ( const ScMyAddress& rAddress ) const 43 { 44 if( Row() != rAddress.Row() ) 45 return (Row() < rAddress.Row()); 46 else 47 return (Col() < rAddress.Col()); 48 } 49 }; 50 51 class ScTabViewShell; 52 class ScAccessibleDocument; 53 class ScAccessibleCell; 54 55 /** @descr 56 This base class provides an implementation of the 57 <code>AccessibleTable</code> service. 58 */ 59 class ScAccessibleSpreadsheet 60 : public ScAccessibleTableBase 61 { 62 public: 63 //===== internal ======================================================== 64 ScAccessibleSpreadsheet( 65 ScAccessibleDocument* pAccDoc, 66 ScTabViewShell* pViewShell, 67 SCTAB nTab, 68 ScSplitPos eSplitPos); 69 protected: 70 ScAccessibleSpreadsheet( 71 ScAccessibleSpreadsheet& rParent, 72 const ScRange& rRange ); 73 74 virtual ~ScAccessibleSpreadsheet(); 75 76 void ConstructScAccessibleSpreadsheet( 77 ScAccessibleDocument* pAccDoc, 78 ScTabViewShell* pViewShell, 79 SCTAB nTab, 80 ScSplitPos eSplitPos); 81 82 using ScAccessibleTableBase::IsDefunc; 83 84 public: 85 using ScAccessibleTableBase::addEventListener; 86 using ScAccessibleTableBase::disposing; 87 88 virtual void SAL_CALL disposing(); 89 90 void CompleteSelectionChanged(sal_Bool bNewState); 91 92 virtual void LostFocus(); 93 94 virtual void GotFocus(); 95 96 void BoundingBoxChanged(); 97 98 void VisAreaChanged(); 99 100 ///===== SfxListener ===================================================== 101 102 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 103 104 ///===== XAccessibleTable ================================================ 105 106 /// Returns the row headers as an AccessibleTable. 107 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL 108 getAccessibleRowHeaders( ); 109 110 /// Returns the column headers as an AccessibleTable. 111 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL 112 getAccessibleColumnHeaders( ); 113 114 /// Returns the selected rows in a table. 115 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL 116 getSelectedAccessibleRows( ); 117 118 /// Returns the selected columns in a table. 119 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL 120 getSelectedAccessibleColumns( ); 121 122 /// Returns a boolean value indicating whether the specified row is selected. 123 virtual sal_Bool SAL_CALL 124 isAccessibleRowSelected( sal_Int32 nRow ); 125 126 /// Returns a boolean value indicating whether the specified column is selected. 127 virtual sal_Bool SAL_CALL 128 isAccessibleColumnSelected( sal_Int32 nColumn ); 129 130 /// Returns the Accessible at a specified row and column in the table. 131 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL 132 getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ); 133 134 ScAccessibleCell* GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn); 135 136 /// Returns a boolean value indicating whether the accessible at a specified row and column is selected. 137 virtual sal_Bool SAL_CALL 138 isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ); 139 140 ///===== XAccessibleComponent ============================================ 141 142 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 143 SAL_CALL getAccessibleAtPoint( 144 const ::com::sun::star::awt::Point& rPoint ); 145 146 virtual void SAL_CALL grabFocus( ); 147 148 virtual sal_Int32 SAL_CALL getForeground( ); 149 150 virtual sal_Int32 SAL_CALL getBackground( ); 151 152 ///===== XAccessibleContext ============================================== 153 154 /// Return NULL to indicate that an empty relation set. 155 virtual ::com::sun::star::uno::Reference< 156 ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL 157 getAccessibleRelationSet(void); 158 159 /// Return the set of current states. 160 virtual ::com::sun::star::uno::Reference< 161 ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL 162 getAccessibleStateSet(void); 163 164 ///===== XAccessibleSelection =========================================== 165 166 virtual void SAL_CALL 167 selectAccessibleChild( sal_Int32 nChildIndex ); 168 169 virtual void SAL_CALL 170 clearAccessibleSelection( ); 171 172 virtual void SAL_CALL 173 selectAllAccessibleChildren( ); 174 175 virtual sal_Int32 SAL_CALL 176 getSelectedAccessibleChildCount( ); 177 178 virtual ::com::sun::star::uno::Reference< 179 ::com::sun::star::accessibility::XAccessible > SAL_CALL 180 getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ); 181 182 virtual void SAL_CALL 183 deselectAccessibleChild( sal_Int32 nChildIndex ); 184 185 ///===== XServiceInfo ==================================================== 186 187 /** Returns an identifier for the implementation of this object. 188 */ 189 virtual ::rtl::OUString SAL_CALL 190 getImplementationName(void); 191 192 /** Returns a list of all supported services. 193 */ 194 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL 195 getSupportedServiceNames(void); 196 197 ///===== XTypeProvider =================================================== 198 199 /** Returns a implementation id. 200 */ 201 virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL 202 getImplementationId(void); 203 204 ///===== XAccessibleEventBroadcaster ===================================== 205 206 /** Add listener that is informed of future changes of name, 207 description and so on events. 208 */ 209 virtual void SAL_CALL 210 addEventListener( 211 const ::com::sun::star::uno::Reference< 212 ::com::sun::star::accessibility::XAccessibleEventListener>& xListener); 213 //===== XAccessibleTableSelection ============================================ 214 virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) ; 215 virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) ; 216 virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) ; 217 virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) ; 218 219 protected: 220 /// Return the object's current bounding box relative to the desktop. 221 virtual Rectangle GetBoundingBoxOnScreen(void) const; 222 223 /// Return the object's current bounding box relative to the parent object. 224 virtual Rectangle GetBoundingBox(void) const; 225 private: 226 ScTabViewShell* mpViewShell; 227 ScRangeList* mpMarkedRanges; 228 std::vector<ScMyAddress>* mpSortedMarkedCells; 229 ScAccessibleDocument* mpAccDoc; 230 ScAccessibleCell* mpAccCell; 231 Rectangle maVisCells; 232 ScSplitPos meSplitPos; 233 ScAddress maActiveCell; 234 SCTAB mnTab; 235 sal_Bool mbIsSpreadsheet; 236 sal_Bool mbHasSelection; 237 sal_Bool mbDelIns; 238 sal_Bool mbIsFocusSend; 239 240 sal_Bool IsDefunc( 241 const com::sun::star::uno::Reference< 242 ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates); 243 sal_Bool IsEditable( 244 const com::sun::star::uno::Reference< 245 ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates); 246 sal_Bool IsFocused(); 247 sal_Bool IsCompleteSheetSelected(); 248 249 void SelectCell(sal_Int32 nRow, sal_Int32 nCol, sal_Bool bDeselect); 250 void CreateSortedMarkedCells(); 251 void AddMarkedRange(const ScRange& rRange); 252 253 ScDocument* GetDocument(ScTabViewShell* pViewShell); 254 Rectangle GetVisArea(ScTabViewShell* pViewShell, ScSplitPos eSplitPos); 255 Rectangle GetVisCells(const Rectangle& rVisArea); 256 //void CreateSortedMarkedCells(); 257 //void AddMarkedRange(const ScRange& rRange); 258 typedef std::vector<ScMyAddress> VEC_MYADDR; 259 260 typedef std::map<ScMyAddress,com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > > 261 MAP_ADDR_XACC; 262 MAP_ADDR_XACC m_mapSelectionSend; 263 void RemoveSelection(ScMarkData &refScMarkData); 264 sal_Bool IsSameMarkCell(); 265 void CommitFocusCell(const ScAddress &aNewCell); 266 public: 267 void FireFirstCellFocus(); 268 private: 269 sal_Bool m_bFormulaMode; 270 sal_Bool m_bFormulaLastMode; 271 ScAddress m_aFormulaActiveCell; 272 MAP_ADDR_XACC m_mapFormulaSelectionSend; 273 VEC_MYADDR m_vecFormulaLastMyAddr; 274 ScAccessibleCell* m_pAccFormulaCell; 275 sal_uInt16 m_nMinX; 276 sal_uInt16 m_nMaxX; 277 sal_Int32 m_nMinY; 278 sal_Int32 m_nMaxY; GetRowAll() const279 sal_Int32 GetRowAll() const { return m_nMaxY - m_nMinY + 1 ; } GetColAll() const280 sal_uInt16 GetColAll() const { return m_nMaxX - m_nMinX + 1; } 281 void NotifyRefMode(); 282 void RemoveFormulaSelection(sal_Bool bRemoveAll =sal_False); 283 sal_Bool CheckChildIndex(sal_Int32)const ; 284 ScAddress GetChildIndexAddress(sal_Int32) const; 285 sal_Int32 GetAccessibleIndexFormula( sal_Int32 nRow, sal_Int32 nColumn ); 286 sal_Bool GetFormulaCurrentFocusCell(ScAddress &addr); 287 public: 288 sal_Bool IsScAddrFormulaSel (const ScAddress &addr) const ; 289 sal_Bool IsFormulaMode() ; 290 ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > GetActiveCell(); 291 ScRange m_aLastWithInMarkRange; 292 String m_strCurCellValue; 293 ScRangeList m_LastMarkedRanges; 294 typedef std::vector<ScRange*> VEC_RANGE; 295 VEC_RANGE m_vecTempRange; 296 typedef std::pair<sal_uInt16,sal_uInt16> PAIR_COL; 297 typedef std::vector<PAIR_COL> VEC_COL; 298 VEC_COL m_vecTempCol; 299 ScMyAddress CalcScAddressFromRangeList(ScRangeList *pMarkedRanges,sal_Int32 nSelectedChildIndex); 300 sal_Bool CalcScRangeDifferenceMax(ScRange *pSrc,ScRange *pDest,int nMax,VEC_MYADDR &vecRet,int &nSize); 301 sal_Bool CalcScRangeListDifferenceMax(ScRangeList *pSrc,ScRangeList *pDest,int nMax,VEC_MYADDR &vecRet); 302 String m_strOldTabName; 303 }; 304 305 306 #endif 307