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