Bump version to 4.3-4
[LibreOffice.git] / sc / inc / textuno.hxx
blob9de49885a45b7a73cabcd028cd422535d549aca1
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_INC_TEXTUNO_HXX
21 #define INCLUDED_SC_INC_TEXTUNO_HXX
23 #include "global.hxx"
24 #include "address.hxx"
25 #include <editeng/unotext.hxx>
26 #include <svl/brdcst.hxx>
27 #include <svl/lstner.hxx>
28 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
29 #include <com/sun/star/sheet/XHeaderFooterContent.hpp>
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <com/sun/star/lang/XUnoTunnel.hpp>
32 #include <cppuhelper/implbase3.hxx>
33 #include <cppuhelper/implbase5.hxx>
35 #include <rtl/ref.hxx>
36 #include "scdllapi.h"
38 #include <boost/noncopyable.hpp>
40 class EditEngine;
41 class EditTextObject;
42 class SvxEditEngineForwarder;
43 class ScDocShell;
44 class ScAddress;
45 class ScCellObj;
46 class ScSimpleEditSource;
47 class ScCellEditSource;
48 class ScEditEngineDefaulter;
49 class ScFieldEditEngine;
50 class ScHeaderFooterTextObj;
52 struct ScHeaderFieldData;
55 #define SC_HDFT_LEFT 0
56 #define SC_HDFT_CENTER 1
57 #define SC_HDFT_RIGHT 2
60 // ScHeaderFooterContentObj is a dumb container which must be re-written into
61 // the page template using setPropertyValue
63 class ScHeaderFooterContentObj : public cppu::WeakImplHelper3<
64 com::sun::star::sheet::XHeaderFooterContent,
65 com::sun::star::lang::XUnoTunnel,
66 com::sun::star::lang::XServiceInfo >
68 private:
69 rtl::Reference<ScHeaderFooterTextObj> mxLeftText;
70 rtl::Reference<ScHeaderFooterTextObj> mxCenterText;
71 rtl::Reference<ScHeaderFooterTextObj> mxRightText;
73 ScHeaderFooterContentObj(); // disabled
75 public:
76 ScHeaderFooterContentObj( const EditTextObject* pLeft,
77 const EditTextObject* pCenter,
78 const EditTextObject* pRight );
79 virtual ~ScHeaderFooterContentObj();
81 // for ScPageHFItem (using getImplementation)
82 const EditTextObject* GetLeftEditObject() const;
83 const EditTextObject* GetCenterEditObject() const;
84 const EditTextObject* GetRightEditObject() const;
86 // XHeaderFooterContent
87 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
88 getLeftText() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
89 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
90 getCenterText() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
91 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
92 getRightText() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
94 // XUnoTunnel
95 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
96 sal_Int8 >& aIdentifier )
97 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
100 static ScHeaderFooterContentObj* getImplementation( const com::sun::star::uno::Reference<
101 com::sun::star::sheet::XHeaderFooterContent> xObj );
103 // XServiceInfo
104 virtual OUString SAL_CALL getImplementationName()
105 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
106 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
107 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
108 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
109 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
113 // ScHeaderFooterTextData: shared data between sub objects of a ScHeaderFooterTextObj
115 class ScHeaderFooterTextData : boost::noncopyable
117 private:
118 EditTextObject* mpTextObj;
119 ScHeaderFooterContentObj& rContentObj;
120 sal_uInt16 nPart;
121 ScEditEngineDefaulter* pEditEngine;
122 SvxEditEngineForwarder* pForwarder;
123 bool bDataValid;
125 public:
126 ScHeaderFooterTextData(
127 ScHeaderFooterContentObj& rContent, sal_uInt16 nP, const EditTextObject* pTextObj);
128 ~ScHeaderFooterTextData();
130 // helper functions
131 SvxTextForwarder* GetTextForwarder();
132 void UpdateData();
133 void UpdateData(EditEngine& rEditEngine);
134 ScEditEngineDefaulter* GetEditEngine() { GetTextForwarder(); return pEditEngine; }
136 sal_uInt16 GetPart() const { return nPart; }
137 ScHeaderFooterContentObj& GetContentObj() const { return rContentObj; }
139 const EditTextObject* GetTextObject() const;
143 * Each of these instances represent, the left, center or right part of the
144 * header of footer of a page.
146 * ScHeaderFooterTextObj changes the text in a ScHeaderFooterContentObj.
148 class ScHeaderFooterTextObj : public cppu::WeakImplHelper5<
149 com::sun::star::text::XText,
150 com::sun::star::text::XTextRangeMover,
151 com::sun::star::container::XEnumerationAccess,
152 com::sun::star::text::XTextFieldsSupplier,
153 com::sun::star::lang::XServiceInfo >
155 private:
156 ScHeaderFooterTextData aTextData;
157 rtl::Reference<SvxUnoText> mxUnoText;
159 void CreateUnoText_Impl();
161 public:
162 ScHeaderFooterTextObj(
163 ScHeaderFooterContentObj& rContent, sal_uInt16 nP, const EditTextObject* pTextObj);
164 virtual ~ScHeaderFooterTextObj();
166 const EditTextObject* GetTextObject() const;
167 const SvxUnoText& GetUnoText();
169 static void FillDummyFieldData( ScHeaderFieldData& rData );
171 // XText
172 virtual void SAL_CALL insertTextContent( const ::com::sun::star::uno::Reference<
173 ::com::sun::star::text::XTextRange >& xRange,
174 const ::com::sun::star::uno::Reference<
175 ::com::sun::star::text::XTextContent >& xContent,
176 sal_Bool bAbsorb )
177 throw(::com::sun::star::lang::IllegalArgumentException,
178 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
179 virtual void SAL_CALL removeTextContent( const ::com::sun::star::uno::Reference<
180 ::com::sun::star::text::XTextContent >& xContent )
181 throw(::com::sun::star::container::NoSuchElementException,
182 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
184 // XSimpleText
185 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL
186 createTextCursor() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
187 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL
188 createTextCursorByRange( const ::com::sun::star::uno::Reference<
189 ::com::sun::star::text::XTextRange >& aTextPosition )
190 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
191 virtual void SAL_CALL insertString( const ::com::sun::star::uno::Reference<
192 ::com::sun::star::text::XTextRange >& xRange,
193 const OUString& aString, sal_Bool bAbsorb )
194 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
195 virtual void SAL_CALL insertControlCharacter( const ::com::sun::star::uno::Reference<
196 ::com::sun::star::text::XTextRange >& xRange,
197 sal_Int16 nControlCharacter, sal_Bool bAbsorb )
198 throw(::com::sun::star::lang::IllegalArgumentException,
199 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
201 // XTextRange
202 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
203 getText() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
204 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
205 getStart() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
206 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
207 getEnd() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
208 virtual OUString SAL_CALL getString() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
209 virtual void SAL_CALL setString( const OUString& aString )
210 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
212 // XTextRangeMover
213 virtual void SAL_CALL moveTextRange( const ::com::sun::star::uno::Reference<
214 ::com::sun::star::text::XTextRange >& xRange,
215 sal_Int16 nParagraphs )
216 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
218 // XEnumerationAccess
219 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
220 createEnumeration() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
222 // XElementAccess
223 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
224 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
225 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
227 // XTextFieldsSupplier
228 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerationAccess > SAL_CALL
229 getTextFields() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
230 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
231 getTextFieldMasters() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
233 // XServiceInfo
234 virtual OUString SAL_CALL getImplementationName()
235 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
236 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
237 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
238 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
239 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
243 // derived cursor objects for getImplementation and getText/getStart/getEnd
245 //! uno3: SvxUnoTextCursor is not derived from XUnoTunnel, but should be (?)
247 class ScCellTextCursor : public SvxUnoTextCursor
249 ScCellObj& rTextObj;
251 public:
252 ScCellTextCursor(const ScCellTextCursor& rOther);
253 ScCellTextCursor(ScCellObj& rText);
254 virtual ~ScCellTextCursor() throw();
256 ScCellObj& GetCellObj() const { return rTextObj; }
258 // SvxUnoTextCursor methods reimplemented here:
259 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
260 getText() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
261 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
262 getStart() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
263 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
264 getEnd() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
266 // XUnoTunnel
267 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
268 sal_Int8 >& aIdentifier )
269 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
271 static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
272 static ScCellTextCursor* getImplementation( const com::sun::star::uno::Reference<
273 com::sun::star::uno::XInterface> xObj );
276 class ScHeaderFooterTextCursor : public SvxUnoTextCursor
278 private:
279 ScHeaderFooterTextObj& rTextObj;
281 public:
282 ScHeaderFooterTextCursor(const ScHeaderFooterTextCursor& rOther);
283 ScHeaderFooterTextCursor(ScHeaderFooterTextObj& rText);
284 virtual ~ScHeaderFooterTextCursor() throw();
286 // SvxUnoTextCursor methods reimplemented here:
287 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
288 getText() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
289 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
290 getStart() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
291 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
292 getEnd() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
294 // XUnoTunnel
295 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
296 sal_Int8 >& aIdentifier )
297 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
299 static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
300 static ScHeaderFooterTextCursor* getImplementation( const com::sun::star::uno::Reference<
301 com::sun::star::uno::XInterface> xObj );
304 class ScDrawTextCursor : public SvxUnoTextCursor
306 private:
307 com::sun::star::uno::Reference< com::sun::star::text::XText > xParentText;
309 public:
310 ScDrawTextCursor(const ScDrawTextCursor& rOther);
311 ScDrawTextCursor( const com::sun::star::uno::Reference<
312 com::sun::star::text::XText >& xParent,
313 const SvxUnoTextBase& rText );
314 virtual ~ScDrawTextCursor() throw();
316 // SvxUnoTextCursor methods reimplemented here:
317 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
318 getText() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
319 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
320 getStart() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
321 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
322 getEnd() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
324 // XUnoTunnel
325 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
326 sal_Int8 >& aIdentifier )
327 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
329 static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
330 static ScDrawTextCursor* getImplementation( const com::sun::star::uno::Reference<
331 com::sun::star::uno::XInterface> xObj );
335 // ScAnnotationTextCursor isn't needed anymore - SvxUnoTextCursor is used instead
338 // ScEditEngineTextObj for formatted cell content that is not inserted in a cell or header/footer
339 // (used for XML export of change tracking contents)
341 class ScSimpleEditSourceHelper
343 ScEditEngineDefaulter* pEditEngine;
344 SvxEditEngineForwarder* pForwarder;
345 ScSimpleEditSource* pOriginalSource;
347 public:
348 ScSimpleEditSourceHelper();
349 ~ScSimpleEditSourceHelper();
351 ScSimpleEditSource* GetOriginalSource() const { return pOriginalSource; }
352 ScEditEngineDefaulter* GetEditEngine() const { return pEditEngine; }
355 class ScEditEngineTextObj : public ScSimpleEditSourceHelper, public SvxUnoText
357 public:
358 ScEditEngineTextObj();
359 virtual ~ScEditEngineTextObj() throw();
361 void SetText( const EditTextObject& rTextObject );
362 EditTextObject* CreateTextObject();
366 // ScCellTextData: shared data between sub objects of a cell text object
368 class ScCellTextData : public SfxListener
370 protected:
371 ScDocShell* pDocShell;
372 ScAddress aCellPos;
373 ScFieldEditEngine* pEditEngine;
374 SvxEditEngineForwarder* pForwarder;
375 ScCellEditSource* pOriginalSource;
376 bool bDataValid;
377 bool bInUpdate;
378 bool bDirty;
379 bool bDoUpdate;
381 protected:
382 virtual void GetCellText(const ScAddress& rCellPos, OUString& rText);
384 public:
385 ScCellTextData(ScDocShell* pDocSh, const ScAddress& rP);
386 virtual ~ScCellTextData();
388 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
390 // helper functions for ScSharedCellEditSource:
391 virtual SvxTextForwarder* GetTextForwarder();
392 void UpdateData();
393 ScFieldEditEngine* GetEditEngine() { GetTextForwarder(); return pEditEngine; }
395 ScCellEditSource* GetOriginalSource(); // used as argument for SvxUnoText ctor
397 // used for ScCellEditSource:
398 ScDocShell* GetDocShell() const { return pDocShell; }
399 const ScAddress& GetCellPos() const { return aCellPos; }
401 void SetDirty(bool bValue) { bDirty = bValue; }
402 bool IsDirty() const { return bDirty; }
403 void SetDoUpdate(bool bValue) { bDoUpdate = bValue; }
406 class ScCellTextObj : public ScCellTextData, public SvxUnoText
408 public:
409 ScCellTextObj(ScDocShell* pDocSh, const ScAddress& rP);
410 virtual ~ScCellTextObj() throw();
414 #endif
416 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */