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 _SC_ACCESSIBLETEXT_HXX 25 #define _SC_ACCESSIBLETEXT_HXX 26 27 #include "textuno.hxx" 28 #include "global.hxx" 29 #include "viewdata.hxx" 30 #include <editeng/svxenum.hxx> 31 32 #include <memory> 33 34 class ScDocShell; 35 class ScViewForwarder; 36 class ScEditObjectViewForwarder; 37 class ScPreviewViewForwarder; 38 class ScEditViewForwarder; 39 class ScPreviewShell; 40 class EditTextObject; 41 class ScCsvViewForwarder; 42 class ScAccessibleCell; 43 44 45 // ============================================================================ 46 47 class ScAccessibleTextData : public SfxListener 48 { 49 public: 50 ScAccessibleTextData() {} 51 virtual ~ScAccessibleTextData() {} 52 53 virtual ScAccessibleTextData* Clone() const = 0; 54 55 virtual void Notify( SfxBroadcaster& /* rBC */, const SfxHint& /* rHint */ ) {} 56 57 virtual SvxTextForwarder* GetTextForwarder() = 0; 58 virtual SvxViewForwarder* GetViewForwarder() = 0; 59 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate ) = 0; 60 virtual SfxBroadcaster& GetBroadcaster() const { return maBroadcaster; } 61 62 virtual void UpdateData() = 0; 63 virtual void SetDoUpdate(sal_Bool bValue) = 0; 64 virtual sal_Bool IsDirty() const = 0; 65 66 private: 67 mutable SfxBroadcaster maBroadcaster; 68 69 // prevent the using of this method of the base class 70 ScSharedCellEditSource* GetOriginalSource() { return NULL; } 71 }; 72 73 74 // ============================================================================ 75 76 class ScAccessibleCellBaseTextData : public ScAccessibleTextData, 77 public ScCellTextData 78 { 79 public: 80 ScAccessibleCellBaseTextData(ScDocShell* pDocShellP, 81 const ScAddress& rP) 82 : ScCellTextData(pDocShellP, rP) {} 83 virtual ~ScAccessibleCellBaseTextData() {} 84 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { ScCellTextData::Notify(rBC, rHint); } 85 86 virtual void UpdateData() { ScCellTextData::UpdateData(); } 87 virtual void SetDoUpdate(sal_Bool bValue) { ScCellTextData::SetDoUpdate(bValue); } 88 virtual sal_Bool IsDirty() const { return ScCellTextData::IsDirty(); } 89 }; 90 91 92 // ============================================================================ 93 94 // ScAccessibleCellTextData: shared data between sub objects of a accessible cell text object 95 96 class ScAccessibleCellTextData : public ScAccessibleCellBaseTextData 97 { 98 public: 99 ScAccessibleCellTextData(ScTabViewShell* pViewShell, 100 const ScAddress& rP, ScSplitPos eSplitPos, ScAccessibleCell* pAccCell); 101 virtual ~ScAccessibleCellTextData(); 102 103 virtual ScAccessibleTextData* Clone() const; 104 105 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 106 107 virtual SvxTextForwarder* GetTextForwarder(); 108 virtual SvxViewForwarder* GetViewForwarder(); 109 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate ); 110 111 DECL_LINK( NotifyHdl, EENotify* ); 112 protected: 113 virtual void GetCellText(const ScAddress& rCellPos, String& rText); 114 private: 115 ScViewForwarder* mpViewForwarder; 116 ScEditViewForwarder* mpEditViewForwarder; 117 ScTabViewShell* mpViewShell; 118 ScSplitPos meSplitPos; 119 sal_Bool mbViewEditEngine; 120 ScAccessibleCell* mpAccessibleCell; 121 122 // prevent the using of this method of the base class 123 ScSharedCellEditSource* GetOriginalSource() { return NULL; } 124 125 using ScAccessibleCellBaseTextData::GetDocShell; 126 ScDocShell* GetDocShell(ScTabViewShell* pViewShell); 127 }; 128 129 130 // ============================================================================ 131 132 class ScAccessibleEditObjectTextData : public ScAccessibleTextData 133 { 134 public: 135 //IAccessibility2 Implementation 2009----- 136 // Solution: Add a para to indicate whether the object is cloned 137 //ScAccessibleEditObjectTextData(EditView* pEditView, Window* pWin); 138 ScAccessibleEditObjectTextData(EditView* pEditView, Window* pWin, sal_Bool isClone=sal_False); 139 //-----IAccessibility2 Implementation 2009 140 virtual ~ScAccessibleEditObjectTextData(); 141 142 virtual ScAccessibleTextData* Clone() const; 143 144 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 145 146 virtual SvxTextForwarder* GetTextForwarder(); 147 virtual SvxViewForwarder* GetViewForwarder(); 148 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate ); 149 150 virtual void UpdateData() { } 151 virtual void SetDoUpdate(sal_Bool /* bValue */) { } 152 virtual sal_Bool IsDirty() const { return sal_False; } 153 154 DECL_LINK( NotifyHdl, EENotify* ); 155 protected: 156 ScEditObjectViewForwarder* mpViewForwarder; 157 ScEditViewForwarder* mpEditViewForwarder; 158 EditView* mpEditView; 159 EditEngine* mpEditEngine; 160 SvxEditEngineForwarder* mpForwarder; 161 Window* mpWindow; 162 //IAccessibility2 Implementation 2009----- 163 sal_Bool mbIsCloned; 164 //-----IAccessibility2 Implementation 2009 165 }; 166 167 168 // ============================================================================ 169 170 class ScAccessibleEditLineTextData : public ScAccessibleEditObjectTextData 171 { 172 public: 173 ScAccessibleEditLineTextData(EditView* pEditView, Window* pWin); 174 virtual ~ScAccessibleEditLineTextData(); 175 176 virtual ScAccessibleTextData* Clone() const; 177 178 virtual SvxTextForwarder* GetTextForwarder(); 179 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate ); 180 181 void Dispose(); 182 void TextChanged(); 183 void StartEdit(); 184 void EndEdit(); 185 private: 186 void ResetEditMode(); 187 188 sal_Bool mbEditEngineCreated; 189 }; 190 191 192 // ============================================================================ 193 194 class ScAccessiblePreviewCellTextData : public ScAccessibleCellBaseTextData 195 { 196 public: 197 ScAccessiblePreviewCellTextData(ScPreviewShell* pViewShell, 198 const ScAddress& rP); 199 virtual ~ScAccessiblePreviewCellTextData(); 200 201 virtual ScAccessibleTextData* Clone() const; 202 203 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 204 205 virtual SvxTextForwarder* GetTextForwarder(); 206 virtual SvxViewForwarder* GetViewForwarder(); 207 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; } 208 209 //UNUSED2008-05 DECL_LINK( NotifyHdl, EENotify* ); 210 private: 211 ScPreviewViewForwarder* mpViewForwarder; 212 ScPreviewShell* mpViewShell; 213 214 // prevent the using of this method of the base class 215 ScSharedCellEditSource* GetOriginalSource() { return NULL; } 216 217 using ScAccessibleCellBaseTextData::GetDocShell; 218 ScDocShell* GetDocShell(ScPreviewShell* pViewShell); 219 }; 220 221 222 // ============================================================================ 223 224 class ScAccessiblePreviewHeaderCellTextData : public ScAccessibleCellBaseTextData 225 { 226 public: 227 ScAccessiblePreviewHeaderCellTextData(ScPreviewShell* pViewShell, 228 const String& rText, const ScAddress& rP, sal_Bool bColHeader, sal_Bool bRowHeader); 229 virtual ~ScAccessiblePreviewHeaderCellTextData(); 230 231 virtual ScAccessibleTextData* Clone() const; 232 233 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 234 235 virtual SvxTextForwarder* GetTextForwarder(); 236 virtual SvxViewForwarder* GetViewForwarder(); 237 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; } 238 239 //UNUSED2008-05 DECL_LINK( NotifyHdl, EENotify* ); 240 private: 241 ScPreviewViewForwarder* mpViewForwarder; 242 ScPreviewShell* mpViewShell; 243 String maText; 244 sal_Bool mbColHeader; 245 sal_Bool mbRowHeader; 246 247 // prevent the using of this method of the base class 248 ScSharedCellEditSource* GetOriginalSource() { return NULL; } 249 250 using ScAccessibleCellBaseTextData::GetDocShell; 251 ScDocShell* GetDocShell(ScPreviewShell* pViewShell); 252 }; 253 254 255 // ============================================================================ 256 257 class ScAccessibleHeaderTextData : public ScAccessibleTextData 258 { 259 public: 260 ScAccessibleHeaderTextData(ScPreviewShell* pViewShell, 261 const EditTextObject* pEditObj, sal_Bool bHeader, SvxAdjust eAdjust); 262 virtual ~ScAccessibleHeaderTextData(); 263 264 virtual ScAccessibleTextData* Clone() const; 265 266 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 267 268 virtual SvxTextForwarder* GetTextForwarder(); 269 virtual SvxViewForwarder* GetViewForwarder(); 270 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; } 271 272 virtual void UpdateData() { } 273 virtual void SetDoUpdate(sal_Bool /* bValue */) { } 274 virtual sal_Bool IsDirty() const { return sal_False; } 275 private: 276 ScPreviewViewForwarder* mpViewForwarder; 277 ScPreviewShell* mpViewShell; 278 ScEditEngineDefaulter* mpEditEngine; 279 SvxEditEngineForwarder* mpForwarder; 280 ScDocShell* mpDocSh; 281 const EditTextObject* mpEditObj; 282 sal_Bool mbHeader; 283 sal_Bool mbDataValid; 284 SvxAdjust meAdjust; 285 }; 286 287 288 // ============================================================================ 289 290 class ScAccessibleNoteTextData : public ScAccessibleTextData 291 { 292 public: 293 ScAccessibleNoteTextData(ScPreviewShell* pViewShell, 294 const String& sText, const ScAddress& aCellPos, sal_Bool bMarkNote); 295 virtual ~ScAccessibleNoteTextData(); 296 297 virtual ScAccessibleTextData* Clone() const; 298 299 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 300 301 virtual SvxTextForwarder* GetTextForwarder(); 302 virtual SvxViewForwarder* GetViewForwarder(); 303 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; } 304 305 virtual void UpdateData() { } 306 virtual void SetDoUpdate(sal_Bool /* bValue */) { } 307 virtual sal_Bool IsDirty() const { return sal_False; } 308 private: 309 ScPreviewViewForwarder* mpViewForwarder; 310 ScPreviewShell* mpViewShell; 311 ScEditEngineDefaulter* mpEditEngine; 312 SvxEditEngineForwarder* mpForwarder; 313 ScDocShell* mpDocSh; 314 String msText; 315 ScAddress maCellPos; 316 sal_Bool mbMarkNote; 317 sal_Bool mbDataValid; 318 }; 319 320 321 // ============================================================================ 322 323 class ScAccessibleCsvTextData : public ScAccessibleTextData 324 { 325 private: 326 typedef ::std::auto_ptr< SvxTextForwarder > TextForwarderPtr; 327 typedef ::std::auto_ptr< ScCsvViewForwarder > ViewForwarderPtr; 328 329 Window* mpWindow; 330 EditEngine* mpEditEngine; 331 TextForwarderPtr mpTextForwarder; 332 ViewForwarderPtr mpViewForwarder; 333 String maCellText; 334 Rectangle maBoundBox; 335 Size maCellSize; 336 337 public: 338 explicit ScAccessibleCsvTextData( 339 Window* pWindow, 340 EditEngine* pEditEngine, 341 const String& rCellText, 342 const Rectangle& rBoundBox, 343 const Size& rCellSize ); 344 virtual ~ScAccessibleCsvTextData(); 345 346 virtual ScAccessibleTextData* Clone() const; 347 348 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 349 350 virtual SvxTextForwarder* GetTextForwarder(); 351 virtual SvxViewForwarder* GetViewForwarder(); 352 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate ); 353 354 virtual void UpdateData() {} 355 virtual void SetDoUpdate( sal_Bool /* bValue */ ) {} 356 virtual sal_Bool IsDirty() const { return sal_False; } 357 }; 358 359 360 // ============================================================================ 361 362 #endif 363