Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / source / ui / inc / AccessibleText.hxx
blob0bea5fae11456fbf7ec28cdffcb2c8ca4bb126ab
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 INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLETEXT_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLETEXT_HXX
23 #include "textuno.hxx"
24 #include "global.hxx"
25 #include "viewdata.hxx"
26 #include <editeng/svxenum.hxx>
27 #include <svl/SfxBroadcaster.hxx>
29 #include <memory>
31 class ScDocShell;
32 class ScViewForwarder;
33 class ScEditObjectViewForwarder;
34 class ScPreviewViewForwarder;
35 class ScEditViewForwarder;
36 class ScPreviewShell;
37 class EditTextObject;
38 class ScCsvViewForwarder;
39 class ScAccessibleCell;
41 class ScAccessibleTextData : public SfxListener
43 public:
44 ScAccessibleTextData() {}
45 virtual ~ScAccessibleTextData() {}
47 virtual ScAccessibleTextData* Clone() const = 0;
49 virtual void Notify( SfxBroadcaster& /* rBC */, const SfxHint& /* rHint */ ) override {}
51 virtual SvxTextForwarder* GetTextForwarder() = 0;
52 virtual SvxViewForwarder* GetViewForwarder() = 0;
53 virtual SvxEditViewForwarder* GetEditViewForwarder( bool bCreate ) = 0;
54 SfxBroadcaster& GetBroadcaster() const { return maBroadcaster; }
56 virtual void UpdateData() = 0;
57 DECL_LINK_TYPED( NotifyHdl, EENotify&, void );
59 private:
60 mutable SfxBroadcaster maBroadcaster;
64 class ScAccessibleCellBaseTextData : public ScAccessibleTextData,
65 public ScCellTextData
67 public:
68 ScAccessibleCellBaseTextData(ScDocShell* pDocShellP,
69 const ScAddress& rP)
70 : ScCellTextData(pDocShellP, rP) {}
71 virtual ~ScAccessibleCellBaseTextData() {}
72 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override { ScCellTextData::Notify(rBC, rHint); }
74 virtual void UpdateData() override { ScCellTextData::UpdateData(); }
77 // ScAccessibleCellTextData: shared data between sub objects of a accessible cell text object
79 class ScAccessibleCellTextData : public ScAccessibleCellBaseTextData
81 public:
82 ScAccessibleCellTextData(ScTabViewShell* pViewShell,
83 const ScAddress& rP, ScSplitPos eSplitPos, ScAccessibleCell* pAccCell);
84 virtual ~ScAccessibleCellTextData();
86 virtual ScAccessibleTextData* Clone() const override;
88 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
90 virtual SvxTextForwarder* GetTextForwarder() override;
91 virtual SvxViewForwarder* GetViewForwarder() override;
92 virtual SvxEditViewForwarder* GetEditViewForwarder( bool bCreate ) override;
94 private:
95 ScViewForwarder* mpViewForwarder;
96 ScEditViewForwarder* mpEditViewForwarder;
97 ScTabViewShell* mpViewShell;
98 ScSplitPos meSplitPos;
99 ScAccessibleCell* mpAccessibleCell;
101 using ScAccessibleCellBaseTextData::GetDocShell;
102 static ScDocShell* GetDocShell(ScTabViewShell* pViewShell);
105 class ScAccessibleEditObjectTextData : public ScAccessibleTextData
107 public:
108 // Add a para to indicate whether the object is cloned
109 ScAccessibleEditObjectTextData(EditView* pEditView, vcl::Window* pWin, bool isClone = false);
110 virtual ~ScAccessibleEditObjectTextData();
112 virtual ScAccessibleTextData* Clone() const override;
114 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
116 virtual SvxTextForwarder* GetTextForwarder() override;
117 virtual SvxViewForwarder* GetViewForwarder() override;
118 virtual SvxEditViewForwarder* GetEditViewForwarder( bool bCreate ) override;
120 virtual void UpdateData() override { }
122 DECL_LINK_TYPED( NotifyHdl, EENotify&, void );
123 protected:
124 ScEditObjectViewForwarder* mpViewForwarder;
125 ScEditViewForwarder* mpEditViewForwarder;
126 EditView* mpEditView;
127 EditEngine* mpEditEngine;
128 SvxEditEngineForwarder* mpForwarder;
129 VclPtr<vcl::Window> mpWindow;
130 bool mbIsCloned;
133 class ScAccessibleEditLineTextData : public ScAccessibleEditObjectTextData
135 public:
136 ScAccessibleEditLineTextData(EditView* pEditView, vcl::Window* pWin);
137 virtual ~ScAccessibleEditLineTextData();
139 virtual ScAccessibleTextData* Clone() const override;
141 virtual SvxTextForwarder* GetTextForwarder() override;
142 virtual SvxEditViewForwarder* GetEditViewForwarder( bool bCreate ) override;
144 void Dispose();
145 void TextChanged();
146 void StartEdit();
147 void EndEdit();
148 private:
149 void ResetEditMode();
151 bool mbEditEngineCreated;
154 class ScAccessiblePreviewCellTextData : public ScAccessibleCellBaseTextData
156 public:
157 ScAccessiblePreviewCellTextData(ScPreviewShell* pViewShell,
158 const ScAddress& rP);
159 virtual ~ScAccessiblePreviewCellTextData();
161 virtual ScAccessibleTextData* Clone() const override;
163 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
165 virtual SvxTextForwarder* GetTextForwarder() override;
166 virtual SvxViewForwarder* GetViewForwarder() override;
167 virtual SvxEditViewForwarder* GetEditViewForwarder( bool /* bCreate */ ) override { return nullptr; }
169 private:
170 ScPreviewViewForwarder* mpViewForwarder;
171 ScPreviewShell* mpViewShell;
173 using ScAccessibleCellBaseTextData::GetDocShell;
174 static ScDocShell* GetDocShell(ScPreviewShell* pViewShell);
177 class ScAccessiblePreviewHeaderCellTextData : public ScAccessibleCellBaseTextData
179 public:
180 ScAccessiblePreviewHeaderCellTextData(ScPreviewShell* pViewShell,
181 const OUString& rText, const ScAddress& rP, bool bColHeader, bool bRowHeader);
182 virtual ~ScAccessiblePreviewHeaderCellTextData();
184 virtual ScAccessibleTextData* Clone() const override;
186 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
188 virtual SvxTextForwarder* GetTextForwarder() override;
189 virtual SvxViewForwarder* GetViewForwarder() override;
190 virtual SvxEditViewForwarder* GetEditViewForwarder( bool /* bCreate */ ) override { return nullptr; }
192 private:
193 ScPreviewViewForwarder* mpViewForwarder;
194 ScPreviewShell* mpViewShell;
195 OUString maText;
196 bool mbColHeader;
197 bool mbRowHeader;
199 using ScAccessibleCellBaseTextData::GetDocShell;
200 static ScDocShell* GetDocShell(ScPreviewShell* pViewShell);
203 class ScAccessibleHeaderTextData : public ScAccessibleTextData
205 public:
206 ScAccessibleHeaderTextData(ScPreviewShell* pViewShell,
207 const EditTextObject* pEditObj, bool bHeader, SvxAdjust eAdjust);
208 virtual ~ScAccessibleHeaderTextData();
210 virtual ScAccessibleTextData* Clone() const override;
212 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
214 virtual SvxTextForwarder* GetTextForwarder() override;
215 virtual SvxViewForwarder* GetViewForwarder() override;
216 virtual SvxEditViewForwarder* GetEditViewForwarder( bool /* bCreate */ ) override { return nullptr; }
218 virtual void UpdateData() override { }
219 private:
220 ScPreviewViewForwarder* mpViewForwarder;
221 ScPreviewShell* mpViewShell;
222 ScEditEngineDefaulter* mpEditEngine;
223 SvxEditEngineForwarder* mpForwarder;
224 ScDocShell* mpDocSh;
225 const EditTextObject* mpEditObj;
226 bool mbHeader;
227 bool mbDataValid;
228 SvxAdjust meAdjust;
231 class ScAccessibleNoteTextData : public ScAccessibleTextData
233 public:
234 ScAccessibleNoteTextData(ScPreviewShell* pViewShell,
235 const OUString& sText, const ScAddress& aCellPos, bool bMarkNote);
236 virtual ~ScAccessibleNoteTextData();
238 virtual ScAccessibleTextData* Clone() const override;
240 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
242 virtual SvxTextForwarder* GetTextForwarder() override;
243 virtual SvxViewForwarder* GetViewForwarder() override;
244 virtual SvxEditViewForwarder* GetEditViewForwarder( bool /* bCreate */ ) override { return nullptr; }
246 virtual void UpdateData() override { }
247 private:
248 ScPreviewViewForwarder* mpViewForwarder;
249 ScPreviewShell* mpViewShell;
250 ScEditEngineDefaulter* mpEditEngine;
251 SvxEditEngineForwarder* mpForwarder;
252 ScDocShell* mpDocSh;
253 OUString msText;
254 ScAddress maCellPos;
255 bool mbMarkNote;
256 bool mbDataValid;
259 class ScAccessibleCsvTextData : public ScAccessibleTextData
261 private:
262 typedef ::std::unique_ptr< SvxTextForwarder > TextForwarderPtr;
263 typedef ::std::unique_ptr< ScCsvViewForwarder > ViewForwarderPtr;
265 VclPtr<vcl::Window> mpWindow;
266 EditEngine* mpEditEngine;
267 TextForwarderPtr mpTextForwarder;
268 ViewForwarderPtr mpViewForwarder;
269 OUString maCellText;
270 Rectangle maBoundBox;
271 Size maCellSize;
273 public:
274 explicit ScAccessibleCsvTextData(
275 vcl::Window* pWindow,
276 EditEngine* pEditEngine,
277 const OUString& rCellText,
278 const Rectangle& rBoundBox,
279 const Size& rCellSize );
280 virtual ~ScAccessibleCsvTextData();
282 virtual ScAccessibleTextData* Clone() const override;
284 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
286 virtual SvxTextForwarder* GetTextForwarder() override;
287 virtual SvxViewForwarder* GetViewForwarder() override;
288 virtual SvxEditViewForwarder* GetEditViewForwarder( bool bCreate ) override;
290 virtual void UpdateData() override {}
293 #endif
295 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */