Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / inc / AccessibleText.hxx
blobe98d1336ead7b72ec00d66f93a426650126cec64
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _SC_ACCESSIBLETEXT_HXX
21 #define _SC_ACCESSIBLETEXT_HXX
23 #include "textuno.hxx"
24 #include "global.hxx"
25 #include "viewdata.hxx"
26 #include <editeng/svxenum.hxx>
28 #include <memory>
30 class ScDocShell;
31 class ScViewForwarder;
32 class ScEditObjectViewForwarder;
33 class ScPreviewViewForwarder;
34 class ScEditViewForwarder;
35 class ScPreviewShell;
36 class EditTextObject;
37 class ScCsvViewForwarder;
38 class ScAccessibleCell;
41 // ============================================================================
43 class ScAccessibleTextData : public SfxListener
45 public:
46 ScAccessibleTextData() {}
47 virtual ~ScAccessibleTextData() {}
49 virtual ScAccessibleTextData* Clone() const = 0;
51 virtual void Notify( SfxBroadcaster& /* rBC */, const SfxHint& /* rHint */ ) {}
53 virtual SvxTextForwarder* GetTextForwarder() = 0;
54 virtual SvxViewForwarder* GetViewForwarder() = 0;
55 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate ) = 0;
56 virtual SfxBroadcaster& GetBroadcaster() const { return maBroadcaster; }
58 virtual void UpdateData() = 0;
59 virtual void SetDoUpdate(sal_Bool bValue) = 0;
60 virtual sal_Bool IsDirty() const = 0;
62 private:
63 mutable SfxBroadcaster maBroadcaster;
65 // prevent the using of this method of the base class
66 ScCellEditSource* GetOriginalSource() { return NULL; }
70 // ============================================================================
72 class ScAccessibleCellBaseTextData : public ScAccessibleTextData,
73 public ScCellTextData
75 public:
76 ScAccessibleCellBaseTextData(ScDocShell* pDocShellP,
77 const ScAddress& rP)
78 : ScCellTextData(pDocShellP, rP) {}
79 virtual ~ScAccessibleCellBaseTextData() {}
80 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { ScCellTextData::Notify(rBC, rHint); }
82 virtual void UpdateData() { ScCellTextData::UpdateData(); }
83 virtual void SetDoUpdate(sal_Bool bValue) { ScCellTextData::SetDoUpdate(bValue); }
84 virtual sal_Bool IsDirty() const { return ScCellTextData::IsDirty(); }
88 // ============================================================================
90 // ScAccessibleCellTextData: shared data between sub objects of a accessible cell text object
92 class ScAccessibleCellTextData : public ScAccessibleCellBaseTextData
94 public:
95 ScAccessibleCellTextData(ScTabViewShell* pViewShell,
96 const ScAddress& rP, ScSplitPos eSplitPos, ScAccessibleCell* pAccCell);
97 virtual ~ScAccessibleCellTextData();
99 virtual ScAccessibleTextData* Clone() const;
101 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
103 virtual SvxTextForwarder* GetTextForwarder();
104 virtual SvxViewForwarder* GetViewForwarder();
105 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate );
107 DECL_LINK( NotifyHdl, EENotify* );
108 protected:
109 virtual void GetCellText(const ScAddress& rCellPos, OUString& rText);
110 private:
111 ScViewForwarder* mpViewForwarder;
112 ScEditViewForwarder* mpEditViewForwarder;
113 ScTabViewShell* mpViewShell;
114 ScSplitPos meSplitPos;
115 ScAccessibleCell* mpAccessibleCell;
117 // prevent the using of this method of the base class
118 ScCellEditSource* GetOriginalSource() { return NULL; }
120 using ScAccessibleCellBaseTextData::GetDocShell;
121 ScDocShell* GetDocShell(ScTabViewShell* pViewShell);
125 // ============================================================================
127 class ScAccessibleEditObjectTextData : public ScAccessibleTextData
129 public:
130 ScAccessibleEditObjectTextData(EditView* pEditView, Window* pWin);
131 virtual ~ScAccessibleEditObjectTextData();
133 virtual ScAccessibleTextData* Clone() const;
135 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
137 virtual SvxTextForwarder* GetTextForwarder();
138 virtual SvxViewForwarder* GetViewForwarder();
139 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate );
141 virtual void UpdateData() { }
142 virtual void SetDoUpdate(sal_Bool /* bValue */) { }
143 virtual sal_Bool IsDirty() const { return false; }
145 DECL_LINK( NotifyHdl, EENotify* );
146 protected:
147 ScEditObjectViewForwarder* mpViewForwarder;
148 ScEditViewForwarder* mpEditViewForwarder;
149 EditView* mpEditView;
150 EditEngine* mpEditEngine;
151 SvxEditEngineForwarder* mpForwarder;
152 Window* mpWindow;
156 // ============================================================================
158 class ScAccessibleEditLineTextData : public ScAccessibleEditObjectTextData
160 public:
161 ScAccessibleEditLineTextData(EditView* pEditView, Window* pWin);
162 virtual ~ScAccessibleEditLineTextData();
164 virtual ScAccessibleTextData* Clone() const;
166 virtual SvxTextForwarder* GetTextForwarder();
167 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate );
169 void Dispose();
170 void TextChanged();
171 void StartEdit();
172 void EndEdit();
173 private:
174 void ResetEditMode();
176 sal_Bool mbEditEngineCreated;
180 // ============================================================================
182 class ScAccessiblePreviewCellTextData : public ScAccessibleCellBaseTextData
184 public:
185 ScAccessiblePreviewCellTextData(ScPreviewShell* pViewShell,
186 const ScAddress& rP);
187 virtual ~ScAccessiblePreviewCellTextData();
189 virtual ScAccessibleTextData* Clone() const;
191 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
193 virtual SvxTextForwarder* GetTextForwarder();
194 virtual SvxViewForwarder* GetViewForwarder();
195 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; }
197 private:
198 ScPreviewViewForwarder* mpViewForwarder;
199 ScPreviewShell* mpViewShell;
201 // prevent the using of this method of the base class
202 ScCellEditSource* GetOriginalSource() { return NULL; }
204 using ScAccessibleCellBaseTextData::GetDocShell;
205 ScDocShell* GetDocShell(ScPreviewShell* pViewShell);
209 // ============================================================================
211 class ScAccessiblePreviewHeaderCellTextData : public ScAccessibleCellBaseTextData
213 public:
214 ScAccessiblePreviewHeaderCellTextData(ScPreviewShell* pViewShell,
215 const OUString& rText, const ScAddress& rP, sal_Bool bColHeader, sal_Bool bRowHeader);
216 virtual ~ScAccessiblePreviewHeaderCellTextData();
218 virtual ScAccessibleTextData* Clone() const;
220 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
222 virtual SvxTextForwarder* GetTextForwarder();
223 virtual SvxViewForwarder* GetViewForwarder();
224 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; }
226 private:
227 ScPreviewViewForwarder* mpViewForwarder;
228 ScPreviewShell* mpViewShell;
229 OUString maText;
230 sal_Bool mbColHeader;
231 sal_Bool mbRowHeader;
233 // prevent the using of this method of the base class
234 ScCellEditSource* GetOriginalSource() { return NULL; }
236 using ScAccessibleCellBaseTextData::GetDocShell;
237 ScDocShell* GetDocShell(ScPreviewShell* pViewShell);
241 // ============================================================================
243 class ScAccessibleHeaderTextData : public ScAccessibleTextData
245 public:
246 ScAccessibleHeaderTextData(ScPreviewShell* pViewShell,
247 const EditTextObject* pEditObj, sal_Bool bHeader, SvxAdjust eAdjust);
248 virtual ~ScAccessibleHeaderTextData();
250 virtual ScAccessibleTextData* Clone() const;
252 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
254 virtual SvxTextForwarder* GetTextForwarder();
255 virtual SvxViewForwarder* GetViewForwarder();
256 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; }
258 virtual void UpdateData() { }
259 virtual void SetDoUpdate(sal_Bool /* bValue */) { }
260 virtual sal_Bool IsDirty() const { return false; }
261 private:
262 ScPreviewViewForwarder* mpViewForwarder;
263 ScPreviewShell* mpViewShell;
264 ScEditEngineDefaulter* mpEditEngine;
265 SvxEditEngineForwarder* mpForwarder;
266 ScDocShell* mpDocSh;
267 const EditTextObject* mpEditObj;
268 sal_Bool mbHeader;
269 sal_Bool mbDataValid;
270 SvxAdjust meAdjust;
274 // ============================================================================
276 class ScAccessibleNoteTextData : public ScAccessibleTextData
278 public:
279 ScAccessibleNoteTextData(ScPreviewShell* pViewShell,
280 const OUString& sText, const ScAddress& aCellPos, sal_Bool bMarkNote);
281 virtual ~ScAccessibleNoteTextData();
283 virtual ScAccessibleTextData* Clone() const;
285 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
287 virtual SvxTextForwarder* GetTextForwarder();
288 virtual SvxViewForwarder* GetViewForwarder();
289 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; }
291 virtual void UpdateData() { }
292 virtual void SetDoUpdate(sal_Bool /* bValue */) { }
293 virtual sal_Bool IsDirty() const { return false; }
294 private:
295 ScPreviewViewForwarder* mpViewForwarder;
296 ScPreviewShell* mpViewShell;
297 ScEditEngineDefaulter* mpEditEngine;
298 SvxEditEngineForwarder* mpForwarder;
299 ScDocShell* mpDocSh;
300 OUString msText;
301 ScAddress maCellPos;
302 sal_Bool mbMarkNote;
303 sal_Bool mbDataValid;
307 // ============================================================================
309 class ScAccessibleCsvTextData : public ScAccessibleTextData
311 private:
312 typedef ::std::auto_ptr< SvxTextForwarder > TextForwarderPtr;
313 typedef ::std::auto_ptr< ScCsvViewForwarder > ViewForwarderPtr;
315 Window* mpWindow;
316 EditEngine* mpEditEngine;
317 TextForwarderPtr mpTextForwarder;
318 ViewForwarderPtr mpViewForwarder;
319 OUString maCellText;
320 Rectangle maBoundBox;
321 Size maCellSize;
323 public:
324 explicit ScAccessibleCsvTextData(
325 Window* pWindow,
326 EditEngine* pEditEngine,
327 const OUString& rCellText,
328 const Rectangle& rBoundBox,
329 const Size& rCellSize );
330 virtual ~ScAccessibleCsvTextData();
332 virtual ScAccessibleTextData* Clone() const;
334 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
336 virtual SvxTextForwarder* GetTextForwarder();
337 virtual SvxViewForwarder* GetViewForwarder();
338 virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate );
340 virtual void UpdateData() {}
341 virtual void SetDoUpdate( sal_Bool /* bValue */ ) {}
342 virtual sal_Bool IsDirty() const { return false; }
346 // ============================================================================
348 #endif
350 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */