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>
28#include <com/sun/star/lang/XUnoTunnel.hpp>
32
33#include <rtl/ref.hxx>
34
35#include <memory>
36
37class EditEngine;
38class EditTextObject;
40class ScDocShell;
41class ScCellObj;
47
49
51
52// ScHeaderFooterContentObj is a dumb container which must be re-written into
53// the page template using setPropertyValue
54
55class ScHeaderFooterContentObj final : public cppu::WeakImplHelper<
56 css::sheet::XHeaderFooterContent,
57 css::lang::XUnoTunnel,
58 css::lang::XServiceInfo >
59{
60private:
64
65public:
67 virtual ~ScHeaderFooterContentObj() override;
68
69 // for ScPageHFItem (using getImplementation)
70 const EditTextObject* GetLeftEditObject() const;
73
74 void Init( const EditTextObject* pLeft,
75 const EditTextObject* pCenter,
76 const EditTextObject* pRight);
77
78 // XHeaderFooterContent
79 virtual css::uno::Reference< css::text::XText > SAL_CALL
80 getLeftText() override;
81 virtual css::uno::Reference< css::text::XText > SAL_CALL
82 getCenterText() override;
83 virtual css::uno::Reference< css::text::XText > SAL_CALL
84 getRightText() override;
85
86 // XUnoTunnel
87 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence<
88 sal_Int8 >& aIdentifier ) override;
89
90 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
91 static rtl::Reference<ScHeaderFooterContentObj> getImplementation(const css::uno::Reference<css::sheet::XHeaderFooterContent>& rObj);
92
93 // XServiceInfo
94 virtual OUString SAL_CALL getImplementationName() override;
95 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
96 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
97
98};
99
100// ScHeaderFooterTextData: shared data between sub objects of a ScHeaderFooterTextObj
101
103{
104private:
105 std::unique_ptr<EditTextObject> mpTextObj;
106 css::uno::WeakReference<css::sheet::XHeaderFooterContent> xContentObj;
108 std::unique_ptr<ScEditEngineDefaulter> pEditEngine;
109 std::unique_ptr<SvxEditEngineForwarder> pForwarder;
111
112public:
116 css::uno::WeakReference<css::sheet::XHeaderFooterContent> xContent, ScHeaderFooterPart nP, const EditTextObject* pTextObj);
118
119 // helper functions
121 void UpdateData();
122 void UpdateData(EditEngine& rEditEngine);
124
125 ScHeaderFooterPart GetPart() const { return nPart; }
126 css::uno::Reference<css::sheet::XHeaderFooterContent> GetContentObj() const { return xContentObj; }
127
128 const EditTextObject* GetTextObject() const { return mpTextObj.get(); }
129};
130
137class ScHeaderFooterTextObj final : public cppu::WeakImplHelper<
138 css::text::XText,
139 css::text::XTextRangeMover,
140 css::container::XEnumerationAccess,
141 css::text::XTextFieldsSupplier,
142 css::lang::XServiceInfo >
143{
144private:
147
148 void CreateUnoText_Impl();
149
150public:
152 const css::uno::WeakReference<css::sheet::XHeaderFooterContent>& xContent, ScHeaderFooterPart nP, const EditTextObject* pTextObj);
153 virtual ~ScHeaderFooterTextObj() override;
154
155 const EditTextObject* GetTextObject() const;
156 const SvxUnoText& GetUnoText();
157
158 static void FillDummyFieldData( ScHeaderFieldData& rData );
159
160 // XText
161 virtual void SAL_CALL insertTextContent( const css::uno::Reference< css::text::XTextRange >& xRange,
162 const css::uno::Reference< css::text::XTextContent >& xContent,
163 sal_Bool bAbsorb ) override;
164 virtual void SAL_CALL removeTextContent( const css::uno::Reference< css::text::XTextContent >& xContent ) override;
165
166 // XSimpleText
167 virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL
168 createTextCursor() override;
169 virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL
170 createTextCursorByRange( const css::uno::Reference< css::text::XTextRange >& aTextPosition ) override;
171 virtual void SAL_CALL insertString( const css::uno::Reference< css::text::XTextRange >& xRange,
172 const OUString& aString, sal_Bool bAbsorb ) override;
173 virtual void SAL_CALL insertControlCharacter( const css::uno::Reference< css::text::XTextRange >& xRange,
174 sal_Int16 nControlCharacter, sal_Bool bAbsorb ) override;
175
176 // XTextRange
177 virtual css::uno::Reference< css::text::XText > SAL_CALL
178 getText() override;
179 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
180 getStart() override;
181 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
182 getEnd() override;
183 virtual OUString SAL_CALL getString() override;
184 virtual void SAL_CALL setString( const OUString& aString ) override;
185
186 // XTextRangeMover
187 virtual void SAL_CALL moveTextRange( const css::uno::Reference< css::text::XTextRange >& xRange,
188 sal_Int16 nParagraphs ) override;
189
190 // XEnumerationAccess
191 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
192 createEnumeration() override;
193
194 // XElementAccess
195 virtual css::uno::Type SAL_CALL getElementType() override;
196 virtual sal_Bool SAL_CALL hasElements() override;
197
198 // XTextFieldsSupplier
199 virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL
200 getTextFields() override;
201 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL
202 getTextFieldMasters() override;
203
204 // XServiceInfo
205 virtual OUString SAL_CALL getImplementationName() override;
206 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
207 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
208
209};
210
211// derived cursor objects for getImplementation and getText/getStart/getEnd
212
214
216{
218
219public:
221 virtual ~ScCellTextCursor() noexcept override;
222
225 ScCellTextCursor & operator =(ScCellTextCursor const &) = delete; // due to SvxUnoTextCursor
226 ScCellTextCursor & operator =(ScCellTextCursor &&) = delete; // due to SvxUnoTextCursor
227
228 ScCellObj& GetCellObj() const { return *mxTextObj; }
229
230 // SvxUnoTextCursor methods reimplemented here:
231 virtual css::uno::Reference< css::text::XText > SAL_CALL
232 getText() override;
233 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
234 getStart() override;
235 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
236 getEnd() override;
237
238 // XUnoTunnel
240};
241
243{
244private:
246
247public:
249 virtual ~ScHeaderFooterTextCursor() noexcept override;
250
253 ScHeaderFooterTextCursor & operator =(ScHeaderFooterTextCursor const &) = delete; // due to SvxUnoTextCursor
254 ScHeaderFooterTextCursor & operator =(ScHeaderFooterTextCursor &&) = delete; // due to SvxUnoTextCursor
255
256 // SvxUnoTextCursor methods reimplemented here:
257 virtual css::uno::Reference< css::text::XText > SAL_CALL
258 getText() override;
259 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
260 getStart() override;
261 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
262 getEnd() override;
263
264 // XUnoTunnel
265 UNO3_GETIMPLEMENTATION_DECL(ScHeaderFooterTextCursor)
266};
267
269{
270private:
271 css::uno::Reference< css::text::XText > xParentText;
272
273public:
274 ScDrawTextCursor( css::uno::Reference< css::text::XText > xParent,
275 const SvxUnoTextBase& rText );
276 virtual ~ScDrawTextCursor() noexcept override;
277
280 ScDrawTextCursor & operator =(ScDrawTextCursor const &) = delete; // due to SvxUnoTextCursor
281 ScDrawTextCursor & operator =(ScDrawTextCursor &&) = delete; // due to SvxUnoTextCursor
282
283 // SvxUnoTextCursor methods reimplemented here:
284 virtual css::uno::Reference< css::text::XText > SAL_CALL
285 getText() override;
286 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
287 getStart() override;
288 virtual css::uno::Reference< css::text::XTextRange > SAL_CALL
289 getEnd() override;
290
291 // XUnoTunnel
292 UNO3_GETIMPLEMENTATION_DECL(ScDrawTextCursor)
293};
294
295// ScAnnotationTextCursor isn't needed anymore - SvxUnoTextCursor is used instead
296
297// ScEditEngineTextObj for formatted cell content that is not inserted in a cell or header/footer
298// (used for XML export of change tracking contents)
299
301{
302 std::unique_ptr<ScEditEngineDefaulter> pEditEngine;
303 std::unique_ptr<SvxEditEngineForwarder> pForwarder;
304 std::unique_ptr<ScSimpleEditSource> pOriginalSource;
305
306public:
309
310 ScSimpleEditSource* GetOriginalSource() const { return pOriginalSource.get(); }
311 ScEditEngineDefaulter* GetEditEngine() const { return pEditEngine.get(); }
312};
313
315{
316public:
318 virtual ~ScEditEngineTextObj() noexcept override;
319
320 void SetText( const EditTextObject& rTextObject );
321 std::unique_ptr<EditTextObject> CreateTextObject();
322};
323
324// ScCellTextData: shared data between sub objects of a cell text object
325
327{
328protected:
331 std::unique_ptr<ScFieldEditEngine> pEditEngine;
332 std::unique_ptr<SvxEditEngineForwarder> pForwarder;
333 std::unique_ptr<ScCellEditSource> pOriginalSource;
336 bool bDirty;
338
339public:
340 ScCellTextData(ScDocShell* pDocSh, const ScAddress& rP);
341 virtual ~ScCellTextData() override;
342
343 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
344
345 // helper functions for ScSharedCellEditSource:
346 virtual SvxTextForwarder* GetTextForwarder();
347 void UpdateData();
348 ScFieldEditEngine* GetEditEngine() { GetTextForwarder(); return pEditEngine.get(); }
349
350 ScCellEditSource* GetOriginalSource(); // used as argument for SvxUnoText ctor
351
352 // used for ScCellEditSource:
353 ScDocShell* GetDocShell() const { return pDocShell; }
354 const ScAddress& GetCellPos() const { return aCellPos; }
355
356 bool IsDirty() const { return bDirty; }
357 void SetDoUpdate(bool bValue) { bDoUpdate = bValue; }
358};
359
360class ScCellTextObj final : public ScCellTextData, public SvxUnoText
361{
362public:
363 ScCellTextObj(ScDocShell* pDocSh, const ScAddress& rP);
364 virtual ~ScCellTextObj() COVERITY_NOEXCEPT_FALSE override;
365};
366
367/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Data (incl.
Definition: editsrc.hxx:74
really derive cell from range?
Definition: cellsuno.hxx:645
uno3: SvxUnoTextCursor is not derived from XUnoTunnel, but should be (?)
Definition: textuno.hxx:216
rtl::Reference< ScCellObj > mxTextObj
Definition: textuno.hxx:217
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: textuno.cxx:567
ScCellObj & GetCellObj() const
Definition: textuno.hxx:228
ScCellTextCursor(ScCellObj &rText)
Definition: textuno.cxx:534
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: textuno.cxx:546
virtual ~ScCellTextCursor() noexcept override
Definition: textuno.cxx:540
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: textuno.cxx:551
ScDocShell * pDocShell
Definition: textuno.hxx:329
std::unique_ptr< ScCellEditSource > pOriginalSource
Definition: textuno.hxx:333
std::unique_ptr< ScFieldEditEngine > pEditEngine
Definition: textuno.hxx:331
ScDocShell * GetDocShell() const
Definition: textuno.hxx:353
std::unique_ptr< SvxEditEngineForwarder > pForwarder
Definition: textuno.hxx:332
bool IsDirty() const
Definition: textuno.hxx:356
const ScAddress & GetCellPos() const
Definition: textuno.hxx:354
ScAddress aCellPos
Definition: textuno.hxx:330
ScFieldEditEngine * GetEditEngine()
Definition: textuno.hxx:348
void SetDoUpdate(bool bValue)
Definition: textuno.hxx:357
ScDrawTextCursor(css::uno::Reference< css::text::XText > xParent, const SvxUnoTextBase &rText)
css::uno::Reference< css::text::XText > xParentText
Definition: textuno.hxx:271
rtl::Reference< ScHeaderFooterTextObj > mxRightText
Definition: textuno.hxx:63
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
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: textuno.cxx:132
static rtl::Reference< ScHeaderFooterContentObj > getImplementation(const css::uno::Reference< css::sheet::XHeaderFooterContent > &rObj)
Definition: textuno.cxx:144
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: textuno.cxx:138
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:62
void Init(const EditTextObject *pLeft, const EditTextObject *pCenter, const EditTextObject *pRight)
Definition: textuno.cxx:150
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:61
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: textuno.cxx:602
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: textuno.cxx:596
ScHeaderFooterTextCursor(rtl::Reference< ScHeaderFooterTextObj > const &rText)
Definition: textuno.cxx:587
virtual ~ScHeaderFooterTextCursor() noexcept override
Definition: textuno.cxx:592
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: textuno.cxx:618
rtl::Reference< ScHeaderFooterTextObj > rTextObj
Definition: textuno.hxx:245
ScHeaderFooterTextData(const ScHeaderFooterTextData &)=delete
css::uno::WeakReference< css::sheet::XHeaderFooterContent > xContentObj
Definition: textuno.hxx:106
ScHeaderFooterTextData(css::uno::WeakReference< css::sheet::XHeaderFooterContent > xContent, ScHeaderFooterPart nP, const EditTextObject *pTextObj)
ScHeaderFooterPart GetPart() const
Definition: textuno.hxx:125
std::unique_ptr< EditTextObject > mpTextObj
Definition: textuno.hxx:105
const EditTextObject * GetTextObject() const
Definition: textuno.hxx:128
std::unique_ptr< SvxEditEngineForwarder > pForwarder
Definition: textuno.hxx:109
std::unique_ptr< ScEditEngineDefaulter > pEditEngine
Definition: textuno.hxx:108
css::uno::Reference< css::sheet::XHeaderFooterContent > GetContentObj() const
Definition: textuno.hxx:126
const ScHeaderFooterTextData & operator=(const ScHeaderFooterTextData &)=delete
SvxTextForwarder * GetTextForwarder()
Definition: textuno.cxx:177
ScHeaderFooterPart nPart
Definition: textuno.hxx:107
ScEditEngineDefaulter * GetEditEngine()
Definition: textuno.hxx:123
Each of these instances represent, the left, center or right part of the header of footer of a page.
Definition: textuno.hxx:143
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > &aTextPosition) override
Definition: textuno.cxx:273
virtual void SAL_CALL removeTextContent(const css::uno::Reference< css::text::XTextContent > &xContent) override
Definition: textuno.cxx:436
virtual void SAL_CALL moveTextRange(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Int16 nParagraphs) override
Definition: textuno.cxx:496
virtual void SAL_CALL setString(const OUString &aString) override
Definition: textuno.cxx:338
const EditTextObject * GetTextObject() const
Definition: textuno.cxx:253
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:367
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override
Definition: textuno.cxx:267
virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL getTextFields() override
Definition: textuno.cxx:481
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTextFieldMasters() override
Definition: textuno.cxx:488
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: textuno.cxx:455
static void FillDummyFieldData(ScHeaderFieldData &rData)
Definition: textuno.cxx:283
const SvxUnoText & GetUnoText()
Definition: textuno.cxx:258
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ~ScHeaderFooterTextObj() override
Definition: textuno.cxx:251
virtual void SAL_CALL insertString(const css::uno::Reference< css::text::XTextRange > &xRange, const OUString &aString, sal_Bool bAbsorb) override
Definition: textuno.cxx:348
virtual css::uno::Type SAL_CALL getElementType() override
Definition: textuno.cxx:518
rtl::Reference< SvxUnoText > mxUnoText
Definition: textuno.hxx:146
virtual OUString SAL_CALL getString() override
Definition: textuno.cxx:294
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: textuno.cxx:508
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: textuno.cxx:463
virtual void SAL_CALL insertControlCharacter(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb) override
Definition: textuno.cxx:357
ScHeaderFooterTextObj(const css::uno::WeakReference< css::sheet::XHeaderFooterContent > &xContent, ScHeaderFooterPart nP, const EditTextObject *pTextObj)
Definition: textuno.cxx:233
virtual sal_Bool SAL_CALL hasElements() override
Definition: textuno.cxx:526
ScHeaderFooterTextData aTextData
Definition: textuno.hxx:145
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: textuno.cxx:471
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
ScSimpleEditSource * GetOriginalSource() const
Definition: textuno.hxx:310
std::unique_ptr< SvxEditEngineForwarder > pForwarder
Definition: textuno.hxx:303
ScEditEngineDefaulter * GetEditEngine() const
Definition: textuno.hxx:311
std::unique_ptr< ScSimpleEditSource > pOriginalSource
Definition: textuno.hxx:304
std::unique_ptr< ScEditEngineDefaulter > pEditEngine
Definition: textuno.hxx:302
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:483
const sal_uInt32 LEFT
const sal_uInt32 RIGHT
#define UNO3_GETIMPLEMENTATION_DECL(classname)
ScHeaderFooterPart
Definition: textuno.hxx:50
unsigned char sal_Bool
signed char sal_Int8