xref: /trunk/main/sc/source/ui/inc/AccessibleText.hxx (revision 4d7c9de0)
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:
ScAccessibleTextData()50 						ScAccessibleTextData() {}
~ScAccessibleTextData()51 	virtual				~ScAccessibleTextData() {}
52 
53 	virtual	ScAccessibleTextData* Clone() const = 0;
54 
Notify(SfxBroadcaster &,const SfxHint &)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;
GetBroadcaster() const60 	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
GetOriginalSource()70 	ScSharedCellEditSource*	GetOriginalSource() { return NULL; }
71 };
72 
73 
74 // ============================================================================
75 
76 class ScAccessibleCellBaseTextData : public ScAccessibleTextData,
77                                      public ScCellTextData
78 {
79 public:
ScAccessibleCellBaseTextData(ScDocShell * pDocShellP,const ScAddress & rP)80                         ScAccessibleCellBaseTextData(ScDocShell* pDocShellP,
81                             const ScAddress& rP)
82                             : ScCellTextData(pDocShellP, rP) {}
~ScAccessibleCellBaseTextData()83     virtual             ~ScAccessibleCellBaseTextData() {}
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)84     virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { ScCellTextData::Notify(rBC, rHint); }
85 
UpdateData()86     virtual void				UpdateData() { ScCellTextData::UpdateData(); }
SetDoUpdate(sal_Bool bValue)87     virtual void				SetDoUpdate(sal_Bool bValue) { ScCellTextData::SetDoUpdate(bValue); }
IsDirty() const88     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
GetOriginalSource()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 	// Solution: Add a para to indicate whether the object is cloned
136 						//ScAccessibleEditObjectTextData(EditView* pEditView, Window* pWin);
137 						ScAccessibleEditObjectTextData(EditView* pEditView, Window* pWin, sal_Bool isClone=sal_False);
138 	virtual				~ScAccessibleEditObjectTextData();
139 
140 	virtual	ScAccessibleTextData* Clone() const;
141 
142 	virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
143 
144 	virtual SvxTextForwarder* GetTextForwarder();
145 	virtual SvxViewForwarder* GetViewForwarder();
146 	virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate );
147 
UpdateData()148     virtual void				UpdateData() {  }
SetDoUpdate(sal_Bool)149     virtual void				SetDoUpdate(sal_Bool /* bValue */) {  }
IsDirty() const150     virtual sal_Bool			IsDirty() const { return sal_False; }
151 
152     DECL_LINK( NotifyHdl, EENotify* );
153 protected:
154 	ScEditObjectViewForwarder* mpViewForwarder;
155 	ScEditViewForwarder* mpEditViewForwarder;
156     EditView* mpEditView;
157     EditEngine* mpEditEngine;
158     SvxEditEngineForwarder*	mpForwarder;
159     Window* mpWindow;
160     sal_Bool mbIsCloned;
161 };
162 
163 
164 // ============================================================================
165 
166 class ScAccessibleEditLineTextData : public ScAccessibleEditObjectTextData
167 {
168 public:
169                         ScAccessibleEditLineTextData(EditView* pEditView, Window* pWin);
170     virtual             ~ScAccessibleEditLineTextData();
171 
172     virtual ScAccessibleTextData* Clone() const;
173 
174     virtual SvxTextForwarder* GetTextForwarder();
175 	virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate );
176 
177     void Dispose();
178     void TextChanged();
179     void StartEdit();
180     void EndEdit();
181 private:
182     void ResetEditMode();
183 
184     sal_Bool mbEditEngineCreated;
185 };
186 
187 
188 // ============================================================================
189 
190 class ScAccessiblePreviewCellTextData : public ScAccessibleCellBaseTextData
191 {
192 public:
193 						ScAccessiblePreviewCellTextData(ScPreviewShell* pViewShell,
194 							const ScAddress& rP);
195 	virtual				~ScAccessiblePreviewCellTextData();
196 
197 	virtual	ScAccessibleTextData* Clone() const;
198 
199 	virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
200 
201 	virtual SvxTextForwarder* GetTextForwarder();
202 	virtual SvxViewForwarder* GetViewForwarder();
GetEditViewForwarder(sal_Bool)203 	virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; }
204 
205 //UNUSED2008-05  DECL_LINK( NotifyHdl, EENotify* );
206 private:
207 	ScPreviewViewForwarder* mpViewForwarder;
208 	ScPreviewShell*	mpViewShell;
209 
210 	// prevent the using of this method of the base class
GetOriginalSource()211 	ScSharedCellEditSource*	GetOriginalSource() { return NULL; }
212 
213     using ScAccessibleCellBaseTextData::GetDocShell;
214 	ScDocShell* GetDocShell(ScPreviewShell* pViewShell);
215 };
216 
217 
218 // ============================================================================
219 
220 class ScAccessiblePreviewHeaderCellTextData : public ScAccessibleCellBaseTextData
221 {
222 public:
223 						ScAccessiblePreviewHeaderCellTextData(ScPreviewShell* pViewShell,
224 							const String& rText, const ScAddress& rP, sal_Bool bColHeader, sal_Bool bRowHeader);
225 	virtual				~ScAccessiblePreviewHeaderCellTextData();
226 
227 	virtual	ScAccessibleTextData* Clone() const;
228 
229 	virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
230 
231 	virtual SvxTextForwarder* GetTextForwarder();
232 	virtual SvxViewForwarder* GetViewForwarder();
GetEditViewForwarder(sal_Bool)233 	virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; }
234 
235 //UNUSED2008-05  DECL_LINK( NotifyHdl, EENotify* );
236 private:
237 	ScPreviewViewForwarder* mpViewForwarder;
238 	ScPreviewShell*	mpViewShell;
239 	String			maText;
240 	sal_Bool		mbColHeader;
241 	sal_Bool		mbRowHeader;
242 
243 	// prevent the using of this method of the base class
GetOriginalSource()244 	ScSharedCellEditSource*	GetOriginalSource() { return NULL; }
245 
246     using ScAccessibleCellBaseTextData::GetDocShell;
247 	ScDocShell* GetDocShell(ScPreviewShell* pViewShell);
248 };
249 
250 
251 // ============================================================================
252 
253 class ScAccessibleHeaderTextData : public ScAccessibleTextData
254 {
255 public:
256                         ScAccessibleHeaderTextData(ScPreviewShell* pViewShell,
257                             const EditTextObject* pEditObj, sal_Bool bHeader, SvxAdjust eAdjust);
258     virtual             ~ScAccessibleHeaderTextData();
259 
260     virtual ScAccessibleTextData* Clone() const;
261 
262 	virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
263 
264 	virtual SvxTextForwarder* GetTextForwarder();
265 	virtual SvxViewForwarder* GetViewForwarder();
GetEditViewForwarder(sal_Bool)266 	virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; }
267 
UpdateData()268     virtual void				UpdateData() {  }
SetDoUpdate(sal_Bool)269     virtual void				SetDoUpdate(sal_Bool /* bValue */) {  }
IsDirty() const270     virtual sal_Bool			IsDirty() const { return sal_False; }
271 private:
272     ScPreviewViewForwarder* mpViewForwarder;
273     ScPreviewShell*         mpViewShell;
274 	ScEditEngineDefaulter*	mpEditEngine;
275 	SvxEditEngineForwarder*	mpForwarder;
276     ScDocShell*             mpDocSh;
277     const EditTextObject*   mpEditObj;
278     sal_Bool                mbHeader;
279     sal_Bool                mbDataValid;
280     SvxAdjust               meAdjust;
281 };
282 
283 
284 // ============================================================================
285 
286 class ScAccessibleNoteTextData : public ScAccessibleTextData
287 {
288 public:
289                         ScAccessibleNoteTextData(ScPreviewShell* pViewShell,
290                             const String& sText, const ScAddress& aCellPos, sal_Bool bMarkNote);
291     virtual             ~ScAccessibleNoteTextData();
292 
293     virtual ScAccessibleTextData* Clone() const;
294 
295 	virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
296 
297 	virtual SvxTextForwarder* GetTextForwarder();
298 	virtual SvxViewForwarder* GetViewForwarder();
GetEditViewForwarder(sal_Bool)299 	virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; }
300 
UpdateData()301     virtual void				UpdateData() {  }
SetDoUpdate(sal_Bool)302     virtual void				SetDoUpdate(sal_Bool /* bValue */) {  }
IsDirty() const303     virtual sal_Bool			IsDirty() const { return sal_False; }
304 private:
305     ScPreviewViewForwarder* mpViewForwarder;
306     ScPreviewShell*         mpViewShell;
307 	ScEditEngineDefaulter*	mpEditEngine;
308 	SvxEditEngineForwarder*	mpForwarder;
309     ScDocShell*             mpDocSh;
310     String                  msText;
311     ScAddress               maCellPos;
312     sal_Bool                mbMarkNote;
313     sal_Bool                mbDataValid;
314 };
315 
316 
317 // ============================================================================
318 
319 class ScAccessibleCsvTextData : public ScAccessibleTextData
320 {
321 private:
322     typedef ::std::auto_ptr< SvxTextForwarder > TextForwarderPtr;
323     typedef ::std::auto_ptr< ScCsvViewForwarder > ViewForwarderPtr;
324 
325     Window*                     mpWindow;
326     EditEngine*                 mpEditEngine;
327     TextForwarderPtr            mpTextForwarder;
328     ViewForwarderPtr            mpViewForwarder;
329     String                      maCellText;
330     Rectangle                   maBoundBox;
331     Size                        maCellSize;
332 
333 public:
334     explicit                    ScAccessibleCsvTextData(
335                                     Window* pWindow,
336                                     EditEngine* pEditEngine,
337                                     const String& rCellText,
338                                     const Rectangle& rBoundBox,
339                                     const Size& rCellSize );
340     virtual                     ~ScAccessibleCsvTextData();
341 
342     virtual ScAccessibleTextData* Clone() const;
343 
344     virtual void                Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
345 
346     virtual SvxTextForwarder*   GetTextForwarder();
347     virtual SvxViewForwarder*   GetViewForwarder();
348     virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate );
349 
UpdateData()350     virtual void                UpdateData() {}
SetDoUpdate(sal_Bool)351     virtual void                SetDoUpdate( sal_Bool /* bValue */ ) {}
IsDirty() const352     virtual sal_Bool            IsDirty() const { return sal_False; }
353 };
354 
355 
356 // ============================================================================
357 
358 #endif
359