xref: /aoo41x/main/sc/source/ui/inc/AccessibleText.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SC_ACCESSIBLETEXT_HXX
29 #define _SC_ACCESSIBLETEXT_HXX
30 
31 #include "textuno.hxx"
32 #include "global.hxx"
33 #include "viewdata.hxx"
34 #include <editeng/svxenum.hxx>
35 
36 #include <memory>
37 
38 class ScDocShell;
39 class ScViewForwarder;
40 class ScEditObjectViewForwarder;
41 class ScPreviewViewForwarder;
42 class ScEditViewForwarder;
43 class ScPreviewShell;
44 class EditTextObject;
45 class ScCsvViewForwarder;
46 class ScAccessibleCell;
47 
48 
49 // ============================================================================
50 
51 class ScAccessibleTextData : public SfxListener
52 {
53 public:
54 						ScAccessibleTextData() {}
55 	virtual				~ScAccessibleTextData() {}
56 
57 	virtual	ScAccessibleTextData* Clone() const = 0;
58 
59     virtual void        Notify( SfxBroadcaster& /* rBC */, const SfxHint& /* rHint */ ) {}
60 
61 	virtual SvxTextForwarder* GetTextForwarder() = 0;
62 	virtual SvxViewForwarder* GetViewForwarder() = 0;
63 	virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate ) = 0;
64 	virtual SfxBroadcaster& GetBroadcaster() const { return maBroadcaster; }
65 
66     virtual void				UpdateData() = 0;
67 	virtual void				SetDoUpdate(sal_Bool bValue) = 0;
68 	virtual sal_Bool			IsDirty() const = 0;
69 
70 private:
71 	mutable SfxBroadcaster maBroadcaster;
72 
73 	// prevent the using of this method of the base class
74 	ScSharedCellEditSource*	GetOriginalSource() { return NULL; }
75 };
76 
77 
78 // ============================================================================
79 
80 class ScAccessibleCellBaseTextData : public ScAccessibleTextData,
81                                      public ScCellTextData
82 {
83 public:
84                         ScAccessibleCellBaseTextData(ScDocShell* pDocShellP,
85                             const ScAddress& rP)
86                             : ScCellTextData(pDocShellP, rP) {}
87     virtual             ~ScAccessibleCellBaseTextData() {}
88     virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { ScCellTextData::Notify(rBC, rHint); }
89 
90     virtual void				UpdateData() { ScCellTextData::UpdateData(); }
91     virtual void				SetDoUpdate(sal_Bool bValue) { ScCellTextData::SetDoUpdate(bValue); }
92     virtual sal_Bool			IsDirty() const { return ScCellTextData::IsDirty(); }
93 };
94 
95 
96 // ============================================================================
97 
98 //	ScAccessibleCellTextData: shared data between sub objects of a accessible cell text object
99 
100 class ScAccessibleCellTextData : public ScAccessibleCellBaseTextData
101 {
102 public:
103 						ScAccessibleCellTextData(ScTabViewShell* pViewShell,
104                             const ScAddress& rP, ScSplitPos eSplitPos, ScAccessibleCell* pAccCell);
105 	virtual				~ScAccessibleCellTextData();
106 
107 	virtual	ScAccessibleTextData* Clone() const;
108 
109 	virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
110 
111 	virtual SvxTextForwarder* GetTextForwarder();
112 	virtual SvxViewForwarder* GetViewForwarder();
113 	virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate );
114 
115 	DECL_LINK( NotifyHdl, EENotify* );
116 protected:
117     virtual void            GetCellText(const ScAddress& rCellPos, String& rText);
118 private:
119 	ScViewForwarder* mpViewForwarder;
120 	ScEditViewForwarder* mpEditViewForwarder;
121 	ScTabViewShell*	mpViewShell;
122 	ScSplitPos meSplitPos;
123 	sal_Bool mbViewEditEngine;
124     ScAccessibleCell* mpAccessibleCell;
125 
126 	// prevent the using of this method of the base class
127 	ScSharedCellEditSource*	GetOriginalSource() { return NULL; }
128 
129     using ScAccessibleCellBaseTextData::GetDocShell;
130 	ScDocShell* GetDocShell(ScTabViewShell* pViewShell);
131 };
132 
133 
134 // ============================================================================
135 
136 class ScAccessibleEditObjectTextData : public ScAccessibleTextData
137 {
138 public:
139 						ScAccessibleEditObjectTextData(EditView* pEditView, Window* pWin);
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 };
163 
164 
165 // ============================================================================
166 
167 class ScAccessibleEditLineTextData : public ScAccessibleEditObjectTextData
168 {
169 public:
170                         ScAccessibleEditLineTextData(EditView* pEditView, Window* pWin);
171     virtual             ~ScAccessibleEditLineTextData();
172 
173     virtual ScAccessibleTextData* Clone() const;
174 
175     virtual SvxTextForwarder* GetTextForwarder();
176 	virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate );
177 
178     void Dispose();
179     void TextChanged();
180     void StartEdit();
181     void EndEdit();
182 private:
183     void ResetEditMode();
184 
185     sal_Bool mbEditEngineCreated;
186 };
187 
188 
189 // ============================================================================
190 
191 class ScAccessiblePreviewCellTextData : public ScAccessibleCellBaseTextData
192 {
193 public:
194 						ScAccessiblePreviewCellTextData(ScPreviewShell* pViewShell,
195 							const ScAddress& rP);
196 	virtual				~ScAccessiblePreviewCellTextData();
197 
198 	virtual	ScAccessibleTextData* Clone() const;
199 
200 	virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
201 
202 	virtual SvxTextForwarder* GetTextForwarder();
203 	virtual SvxViewForwarder* GetViewForwarder();
204 	virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; }
205 
206 //UNUSED2008-05  DECL_LINK( NotifyHdl, EENotify* );
207 private:
208 	ScPreviewViewForwarder* mpViewForwarder;
209 	ScPreviewShell*	mpViewShell;
210 
211 	// prevent the using of this method of the base class
212 	ScSharedCellEditSource*	GetOriginalSource() { return NULL; }
213 
214     using ScAccessibleCellBaseTextData::GetDocShell;
215 	ScDocShell* GetDocShell(ScPreviewShell* pViewShell);
216 };
217 
218 
219 // ============================================================================
220 
221 class ScAccessiblePreviewHeaderCellTextData : public ScAccessibleCellBaseTextData
222 {
223 public:
224 						ScAccessiblePreviewHeaderCellTextData(ScPreviewShell* pViewShell,
225 							const String& rText, const ScAddress& rP, sal_Bool bColHeader, sal_Bool bRowHeader);
226 	virtual				~ScAccessiblePreviewHeaderCellTextData();
227 
228 	virtual	ScAccessibleTextData* Clone() const;
229 
230 	virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
231 
232 	virtual SvxTextForwarder* GetTextForwarder();
233 	virtual SvxViewForwarder* GetViewForwarder();
234 	virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; }
235 
236 //UNUSED2008-05  DECL_LINK( NotifyHdl, EENotify* );
237 private:
238 	ScPreviewViewForwarder* mpViewForwarder;
239 	ScPreviewShell*	mpViewShell;
240 	String			maText;
241 	sal_Bool		mbColHeader;
242 	sal_Bool		mbRowHeader;
243 
244 	// prevent the using of this method of the base class
245 	ScSharedCellEditSource*	GetOriginalSource() { return NULL; }
246 
247     using ScAccessibleCellBaseTextData::GetDocShell;
248 	ScDocShell* GetDocShell(ScPreviewShell* pViewShell);
249 };
250 
251 
252 // ============================================================================
253 
254 class ScAccessibleHeaderTextData : public ScAccessibleTextData
255 {
256 public:
257                         ScAccessibleHeaderTextData(ScPreviewShell* pViewShell,
258                             const EditTextObject* pEditObj, sal_Bool bHeader, SvxAdjust eAdjust);
259     virtual             ~ScAccessibleHeaderTextData();
260 
261     virtual ScAccessibleTextData* Clone() const;
262 
263 	virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
264 
265 	virtual SvxTextForwarder* GetTextForwarder();
266 	virtual SvxViewForwarder* GetViewForwarder();
267 	virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; }
268 
269     virtual void				UpdateData() {  }
270     virtual void				SetDoUpdate(sal_Bool /* bValue */) {  }
271     virtual sal_Bool			IsDirty() const { return sal_False; }
272 private:
273     ScPreviewViewForwarder* mpViewForwarder;
274     ScPreviewShell*         mpViewShell;
275 	ScEditEngineDefaulter*	mpEditEngine;
276 	SvxEditEngineForwarder*	mpForwarder;
277     ScDocShell*             mpDocSh;
278     const EditTextObject*   mpEditObj;
279     sal_Bool                mbHeader;
280     sal_Bool                mbDataValid;
281     SvxAdjust               meAdjust;
282 };
283 
284 
285 // ============================================================================
286 
287 class ScAccessibleNoteTextData : public ScAccessibleTextData
288 {
289 public:
290                         ScAccessibleNoteTextData(ScPreviewShell* pViewShell,
291                             const String& sText, const ScAddress& aCellPos, sal_Bool bMarkNote);
292     virtual             ~ScAccessibleNoteTextData();
293 
294     virtual ScAccessibleTextData* Clone() const;
295 
296 	virtual void		Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
297 
298 	virtual SvxTextForwarder* GetTextForwarder();
299 	virtual SvxViewForwarder* GetViewForwarder();
300 	virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; }
301 
302     virtual void				UpdateData() {  }
303     virtual void				SetDoUpdate(sal_Bool /* bValue */) {  }
304     virtual sal_Bool			IsDirty() const { return sal_False; }
305 private:
306     ScPreviewViewForwarder* mpViewForwarder;
307     ScPreviewShell*         mpViewShell;
308 	ScEditEngineDefaulter*	mpEditEngine;
309 	SvxEditEngineForwarder*	mpForwarder;
310     ScDocShell*             mpDocSh;
311     String                  msText;
312     ScAddress               maCellPos;
313     sal_Bool                mbMarkNote;
314     sal_Bool                mbDataValid;
315 };
316 
317 
318 // ============================================================================
319 
320 class ScAccessibleCsvTextData : public ScAccessibleTextData
321 {
322 private:
323     typedef ::std::auto_ptr< SvxTextForwarder > TextForwarderPtr;
324     typedef ::std::auto_ptr< ScCsvViewForwarder > ViewForwarderPtr;
325 
326     Window*                     mpWindow;
327     EditEngine*                 mpEditEngine;
328     TextForwarderPtr            mpTextForwarder;
329     ViewForwarderPtr            mpViewForwarder;
330     String                      maCellText;
331     Rectangle                   maBoundBox;
332     Size                        maCellSize;
333 
334 public:
335     explicit                    ScAccessibleCsvTextData(
336                                     Window* pWindow,
337                                     EditEngine* pEditEngine,
338                                     const String& rCellText,
339                                     const Rectangle& rBoundBox,
340                                     const Size& rCellSize );
341     virtual                     ~ScAccessibleCsvTextData();
342 
343     virtual ScAccessibleTextData* Clone() const;
344 
345     virtual void                Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
346 
347     virtual SvxTextForwarder*   GetTextForwarder();
348     virtual SvxViewForwarder*   GetViewForwarder();
349     virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate );
350 
351     virtual void                UpdateData() {}
352     virtual void                SetDoUpdate( sal_Bool /* bValue */ ) {}
353     virtual sal_Bool            IsDirty() const { return sal_False; }
354 };
355 
356 
357 // ============================================================================
358 
359 #endif
360