LibreOffice Module sc (master) 1
textuno.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include "address.hxx"
23#include <editeng/unotext.hxx>
24#include <svl/lstner.hxx>
25#include <com/sun/star/text/XTextFieldsSupplier.hpp>
26#include <com/sun/star/sheet/XHeaderFooterContent.hpp>
27#include <com/sun/star/lang/XServiceInfo.hpp>
31
32#include <rtl/ref.hxx>
33
34#include <memory>
35
36class EditEngine;
37class EditTextObject;
39class ScDocShell;
40class ScCellObj;
46
48
50
51// ScHeaderFooterContentObj is a dumb container which must be re-written into
52// the page template using setPropertyValue
53
54class ScHeaderFooterContentObj final : public cppu::WeakImplHelper<
55 css::sheet::XHeaderFooterContent,
56 css::lang::XServiceInfo >
57{
58private:
62
63public:
65 virtual ~ScHeaderFooterContentObj() override;
66
67 // for ScPageHFItem (using getImplementation)
68 const EditTextObject* GetLeftEditObject() const;
71
72 void Init( const EditTextObject* pLeft,
73 const EditTextObject* pCenter,
74 const EditTextObject* pRight);
75
76 // XHeaderFooterContent
77 virtual css::uno::Reference< css::text::XText > SAL_CALL
78 getLeftText() override;
79 virtual css::uno::Reference< css::text::XText > SAL_CALL
80 getCenterText() override;
81 virtual css::uno::Reference< css::text::XText > SAL_CALL
82 getRightText() override;
83
84 static rtl::Reference<ScHeaderFooterContentObj> getImplementation(const css::uno::Reference<css::sheet::XHeaderFooterContent>& rObj);
85
86 // XServiceInfo
87 virtual OUString SAL_CALL getImplementationName() override;
88 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
89 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
90
91};
92
93// ScHeaderFooterTextData: shared data between sub objects of a ScHeaderFooterTextObj
94
96{
97private:
98 std::unique_ptr<EditTextObject> mpTextObj;
99 css::uno::WeakReference<css::sheet::XHeaderFooterContent> xContentObj;
101 std::unique_ptr<ScEditEngineDefaulter> pEditEngine;
102 std::unique_ptr<SvxEditEngineForwarder> pForwarder;
104
105public:
109 css::uno::WeakReference<css::sheet::XHeaderFooterContent> xContent, ScHeaderFooterPart nP, const EditTextObject* pTextObj);
111
112 // helper functions
114 void UpdateData();
115 void UpdateData(EditEngine& rEditEngine);
117
118 ScHeaderFooterPart GetPart() const { return nPart; }
119 css::uno::Reference<css::sheet::XHeaderFooterContent> GetContentObj() const { return xContentObj; }
120
121 const EditTextObject* GetTextObject() const { return mpTextObj.get(); }
122};
123
130class ScHeaderFooterTextObj final : public cppu::WeakImplHelper<
131 css::text::XText,
132 css::text::XTextRangeMover,
133 css::container::XEnumerationAccess,
134 css::text::XTextFieldsSupplier,
135 css::lang::XServiceInfo >
136{
137private:
140
141 void CreateUnoText_Impl();
142
143public:
145 const css::uno::WeakReference<css::sheet::XHeaderFooterContent>& xContent, ScHeaderFooterPart nP, const EditTextObject* pTextObj);
146 virtual ~ScHeaderFooterTextObj() override;
147
148 const EditTextObject* GetTextObject() const;
149 const SvxUnoText& GetUnoText();
150
151 static void FillDummyFieldData( ScHeaderFieldData& rData );
152
153 // XText
154 virtual void SAL_CALL insertTextContent( const css::uno::Reference< css::text::XTextRange >& xRange,
155 const css::uno::Reference< css::text::XTextContent >& xContent,
156 sal_Bool bAbsorb ) override;
157 virtual void SAL_CALL removeTextContent( const css::uno::Reference< css::text::XTextContent >& xContent ) override;
158
159 // XSimpleText
160 virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL
161 createTextCursor() override;
162 virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL
163 createTextCursorByRange( const css::uno::Reference< css::text::XTextRange >& aTextPosition ) override;
164 virtual void SAL_CALL insertString( const css::uno::Reference< css::text::XTextRange >& xRange,
165 const OUString& aString, sal_Bool bAbsorb ) override;
166 virtual void SAL_CALL insertControlCharacter( const css::uno::Reference< css::text::XTextRange >& xRange,
167 sal_Int16 nControlCharacter, sal_Bool bAbsorb ) override;
168
169 // XTextRange
170 virtual css::uno::Reference< css::text::XText > SAL_CALL
171 getText() override;
172 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
173 getStart() override;
174 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
175 getEnd() override;
176 virtual OUString SAL_CALL getString() override;
177 virtual void SAL_CALL setString( const OUString& aString ) override;
178
179 // XTextRangeMover
180 virtual void SAL_CALL moveTextRange( const css::uno::Reference< css::text::XTextRange >& xRange,
181 sal_Int16 nParagraphs ) override;
182
183 // XEnumerationAccess
184 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
185 createEnumeration() override;
186
187 // XElementAccess
188 virtual css::uno::Type SAL_CALL getElementType() override;
189 virtual sal_Bool SAL_CALL hasElements() override;
190
191 // XTextFieldsSupplier
192 virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL
193 getTextFields() override;
194 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL
195 getTextFieldMasters() override;
196
197 // XServiceInfo
198 virtual OUString SAL_CALL getImplementationName() override;
199 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
200 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
201
202};
203
204// derived cursor objects for getImplementation and getText/getStart/getEnd
205
207
209{
211
212public:
214 virtual ~ScCellTextCursor() noexcept override;
215
218 ScCellTextCursor & operator =(ScCellTextCursor const &) = delete; // due to SvxUnoTextCursor
219 ScCellTextCursor & operator =(ScCellTextCursor &&) = delete; // due to SvxUnoTextCursor
220
221 ScCellObj& GetCellObj() const { return *mxTextObj; }
222
223 // SvxUnoTextCursor methods reimplemented here:
224 virtual css::uno::Reference< css::text::XText > SAL_CALL
225 getText() override;
226 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
227 getStart() override;
228 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
229 getEnd() override;
230
231 // XUnoTunnel
233};
234
236{
237private:
239
240public:
242 virtual ~ScHeaderFooterTextCursor() noexcept override;
243
246 ScHeaderFooterTextCursor & operator =(ScHeaderFooterTextCursor const &) = delete; // due to SvxUnoTextCursor
247 ScHeaderFooterTextCursor & operator =(ScHeaderFooterTextCursor &&) = delete; // due to SvxUnoTextCursor
248
249 // SvxUnoTextCursor methods reimplemented here:
250 virtual css::uno::Reference< css::text::XText > SAL_CALL
251 getText() override;
252 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
253 getStart() override;
254 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
255 getEnd() override;
256
257 // XUnoTunnel
258 UNO3_GETIMPLEMENTATION_DECL(ScHeaderFooterTextCursor)
259};
260
262{
263private:
264 css::uno::Reference< css::text::XText > xParentText;
265
266public:
267 ScDrawTextCursor( css::uno::Reference< css::text::XText > xParent,
268 const SvxUnoTextBase& rText );
269 virtual ~ScDrawTextCursor() noexcept override;
270
273 ScDrawTextCursor & operator =(ScDrawTextCursor const &) = delete; // due to SvxUnoTextCursor
274 ScDrawTextCursor & operator =(ScDrawTextCursor &&) = delete; // due to SvxUnoTextCursor
275
276 // SvxUnoTextCursor methods reimplemented here:
277 virtual css::uno::Reference< css::text::XText > SAL_CALL
278 getText() override;
279 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
280 getStart() override;
281 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
282 getEnd() override;
283
284 // XUnoTunnel
285 UNO3_GETIMPLEMENTATION_DECL(ScDrawTextCursor)
286};
287
288// ScAnnotationTextCursor isn't needed anymore - SvxUnoTextCursor is used instead
289
290// ScEditEngineTextObj for formatted cell content that is not inserted in a cell or header/footer
291// (used for XML export of change tracking contents)
292
294{
295 std::unique_ptr<ScEditEngineDefaulter> pEditEngine;
296 std::unique_ptr<SvxEditEngineForwarder> pForwarder;
297 std::unique_ptr<ScSimpleEditSource> pOriginalSource;
298
299public:
302
303 ScSimpleEditSource* GetOriginalSource() const { return pOriginalSource.get(); }
304 ScEditEngineDefaulter* GetEditEngine() const { return pEditEngine.get(); }
305};
306
308{
309public:
311 virtual ~ScEditEngineTextObj() noexcept override;
312
313 void SetText( const EditTextObject& rTextObject );
314 std::unique_ptr<EditTextObject> CreateTextObject();
315};
316
317// ScCellTextData: shared data between sub objects of a cell text object
318
320{
321protected:
324 std::unique_ptr<ScFieldEditEngine> pEditEngine;
325 std::unique_ptr<SvxEditEngineForwarder> pForwarder;
326 std::unique_ptr<ScCellEditSource> pOriginalSource;
329 bool bDirty;
331
332public:
333 ScCellTextData(ScDocShell* pDocSh, const ScAddress& rP);
334 virtual ~ScCellTextData() override;
335
336 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
337
338 // helper functions for ScSharedCellEditSource:
339 virtual SvxTextForwarder* GetTextForwarder();
340 void UpdateData();
341 ScFieldEditEngine* GetEditEngine() { GetTextForwarder(); return pEditEngine.get(); }
342
343 ScCellEditSource* GetOriginalSource(); // used as argument for SvxUnoText ctor
344
345 // used for ScCellEditSource:
346 ScDocShell* GetDocShell() const { return pDocShell; }
347 const ScAddress& GetCellPos() const { return aCellPos; }
348
349 bool IsDirty() const { return bDirty; }
350 void SetDoUpdate(bool bValue) { bDoUpdate = bValue; }
351};
352
353class ScCellTextObj final : public ScCellTextData, public SvxUnoText
354{
355public:
356 ScCellTextObj(ScDocShell* pDocSh, const ScAddress& rP);
357 virtual ~ScCellTextObj() COVERITY_NOEXCEPT_FALSE override;
358};
359
360/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Data (incl.
Definition: editsrc.hxx:74
really derive cell from range?
Definition: cellsuno.hxx:640
uno3: SvxUnoTextCursor is not derived from XUnoTunnel, but should be (?)
Definition: textuno.hxx:209
rtl::Reference< ScCellObj > mxTextObj
Definition: textuno.hxx:210
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: textuno.cxx:553
ScCellObj & GetCellObj() const
Definition: textuno.hxx:221
ScCellTextCursor(ScCellObj &rText)
Definition: textuno.cxx:520
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: textuno.cxx:532
virtual ~ScCellTextCursor() noexcept override
Definition: textuno.cxx:526
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: textuno.cxx:537
ScDocShell * pDocShell
Definition: textuno.hxx:322
std::unique_ptr< ScCellEditSource > pOriginalSource
Definition: textuno.hxx:326
std::unique_ptr< ScFieldEditEngine > pEditEngine
Definition: textuno.hxx:324
ScDocShell * GetDocShell() const
Definition: textuno.hxx:346
std::unique_ptr< SvxEditEngineForwarder > pForwarder
Definition: textuno.hxx:325
bool IsDirty() const
Definition: textuno.hxx:349
const ScAddress & GetCellPos() const
Definition: textuno.hxx:347
ScAddress aCellPos
Definition: textuno.hxx:323
ScFieldEditEngine * GetEditEngine()
Definition: textuno.hxx:341
void SetDoUpdate(bool bValue)
Definition: textuno.hxx:350
ScDrawTextCursor(css::uno::Reference< css::text::XText > xParent, const SvxUnoTextBase &rText)
css::uno::Reference< css::text::XText > xParentText
Definition: textuno.hxx:264
rtl::Reference< ScHeaderFooterTextObj > mxRightText
Definition: textuno.hxx:61
virtual css::uno::Reference< css::text::XText > SAL_CALL getLeftText() override
Definition: textuno.cxx:109
virtual css::uno::Reference< css::text::XText > SAL_CALL getCenterText() override
Definition: textuno.cxx:116
static rtl::Reference< ScHeaderFooterContentObj > getImplementation(const css::uno::Reference< css::sheet::XHeaderFooterContent > &rObj)
Definition: textuno.cxx:130
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual OUString SAL_CALL getImplementationName() override
const EditTextObject * GetLeftEditObject() const
Definition: textuno.cxx:92
virtual ~ScHeaderFooterContentObj() override
Definition: textuno.cxx:90
rtl::Reference< ScHeaderFooterTextObj > mxCenterText
Definition: textuno.hxx:60
void Init(const EditTextObject *pLeft, const EditTextObject *pCenter, const EditTextObject *pRight)
Definition: textuno.cxx:136
const EditTextObject * GetCenterEditObject() const
Definition: textuno.cxx:97
virtual css::uno::Reference< css::text::XText > SAL_CALL getRightText() override
Definition: textuno.cxx:123
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
const EditTextObject * GetRightEditObject() const
Definition: textuno.cxx:102
rtl::Reference< ScHeaderFooterTextObj > mxLeftText
Definition: textuno.hxx:59
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: textuno.cxx:588
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: textuno.cxx:582
ScHeaderFooterTextCursor(rtl::Reference< ScHeaderFooterTextObj > const &rText)
Definition: textuno.cxx:573
virtual ~ScHeaderFooterTextCursor() noexcept override
Definition: textuno.cxx:578
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: textuno.cxx:604
rtl::Reference< ScHeaderFooterTextObj > rTextObj
Definition: textuno.hxx:238
ScHeaderFooterTextData(const ScHeaderFooterTextData &)=delete
css::uno::WeakReference< css::sheet::XHeaderFooterContent > xContentObj
Definition: textuno.hxx:99
ScHeaderFooterTextData(css::uno::WeakReference< css::sheet::XHeaderFooterContent > xContent, ScHeaderFooterPart nP, const EditTextObject *pTextObj)
ScHeaderFooterPart GetPart() const
Definition: textuno.hxx:118
std::unique_ptr< EditTextObject > mpTextObj
Definition: textuno.hxx:98
const EditTextObject * GetTextObject() const
Definition: textuno.hxx:121
std::unique_ptr< SvxEditEngineForwarder > pForwarder
Definition: textuno.hxx:102
std::unique_ptr< ScEditEngineDefaulter > pEditEngine
Definition: textuno.hxx:101
css::uno::Reference< css::sheet::XHeaderFooterContent > GetContentObj() const
Definition: textuno.hxx:119
const ScHeaderFooterTextData & operator=(const ScHeaderFooterTextData &)=delete
SvxTextForwarder * GetTextForwarder()
Definition: textuno.cxx:163
ScHeaderFooterPart nPart
Definition: textuno.hxx:100
ScEditEngineDefaulter * GetEditEngine()
Definition: textuno.hxx:116
Each of these instances represent, the left, center or right part of the header of footer of a page.
Definition: textuno.hxx:136
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > &aTextPosition) override
Definition: textuno.cxx:259
virtual void SAL_CALL removeTextContent(const css::uno::Reference< css::text::XTextContent > &xContent) override
Definition: textuno.cxx:422
virtual void SAL_CALL moveTextRange(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Int16 nParagraphs) override
Definition: textuno.cxx:482
virtual void SAL_CALL setString(const OUString &aString) override
Definition: textuno.cxx:324
const EditTextObject * GetTextObject() const
Definition: textuno.cxx:239
virtual void SAL_CALL insertTextContent(const css::uno::Reference< css::text::XTextRange > &xRange, const css::uno::Reference< css::text::XTextContent > &xContent, sal_Bool bAbsorb) override
Definition: textuno.cxx:353
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override
Definition: textuno.cxx:253
virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL getTextFields() override
Definition: textuno.cxx:467
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTextFieldMasters() override
Definition: textuno.cxx:474
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: textuno.cxx:441
static void FillDummyFieldData(ScHeaderFieldData &rData)
Definition: textuno.cxx:269
const SvxUnoText & GetUnoText()
Definition: textuno.cxx:244
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ~ScHeaderFooterTextObj() override
Definition: textuno.cxx:237
virtual void SAL_CALL insertString(const css::uno::Reference< css::text::XTextRange > &xRange, const OUString &aString, sal_Bool bAbsorb) override
Definition: textuno.cxx:334
virtual css::uno::Type SAL_CALL getElementType() override
Definition: textuno.cxx:504
rtl::Reference< SvxUnoText > mxUnoText
Definition: textuno.hxx:139
virtual OUString SAL_CALL getString() override
Definition: textuno.cxx:280
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: textuno.cxx:494
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: textuno.cxx:449
virtual void SAL_CALL insertControlCharacter(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb) override
Definition: textuno.cxx:343
ScHeaderFooterTextObj(const css::uno::WeakReference< css::sheet::XHeaderFooterContent > &xContent, ScHeaderFooterPart nP, const EditTextObject *pTextObj)
Definition: textuno.cxx:219
virtual sal_Bool SAL_CALL hasElements() override
Definition: textuno.cxx:512
ScHeaderFooterTextData aTextData
Definition: textuno.hxx:138
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: textuno.cxx:457
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
ScSimpleEditSource * GetOriginalSource() const
Definition: textuno.hxx:303
std::unique_ptr< SvxEditEngineForwarder > pForwarder
Definition: textuno.hxx:296
ScEditEngineDefaulter * GetEditEngine() const
Definition: textuno.hxx:304
std::unique_ptr< ScSimpleEditSource > pOriginalSource
Definition: textuno.hxx:297
std::unique_ptr< ScEditEngineDefaulter > pEditEngine
Definition: textuno.hxx:295
virtual void SetText(const OUString &rStr) override
void Notify(ScModelObj &rModelObj, const ScRangeList &rChangeRanges, const OUString &rType=OUString("cell-change"), const css::uno::Sequence< css::beans::PropertyValue > &rProperties=css::uno::Sequence< css::beans::PropertyValue >())
Definition: docsh.hxx:498
const sal_uInt32 LEFT
const sal_uInt32 RIGHT
#define UNO3_GETIMPLEMENTATION_DECL(classname)
ScHeaderFooterPart
Definition: textuno.hxx:49
unsigned char sal_Bool