Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_sc / textuno.hxx
blob2e4b5617536f2bdd5e02a4f08edb3a610e0b069a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: textuno.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_TEXTSUNO_HXX
32 #define SC_TEXTSUNO_HXX
34 #ifndef SC_SCGLOB_HXX
35 #include "global.hxx" // ScRange, ScAddress
36 #endif
38 #ifndef _SVX_UNOTEXT_HXX
39 #include <bf_svx/unotext.hxx>
40 #endif
42 #ifndef _SFXBRDCST_HXX
43 #include <bf_svtools/brdcst.hxx>
44 #endif
45 #ifndef _SFXLSTNER_HXX
46 #include <bf_svtools/lstner.hxx>
47 #endif
49 #ifndef _COM_SUN_STAR_TEXT_XTEXTFIELDSSUPPLIER_HPP_
50 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
51 #endif
52 #ifndef _COM_SUN_STAR_SHEET_XHEADERFOOTERCONTENT_HPP_
53 #include <com/sun/star/sheet/XHeaderFooterContent.hpp>
54 #endif
55 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
56 #include <com/sun/star/lang/XServiceInfo.hpp>
57 #endif
58 #ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
59 #include <com/sun/star/lang/XUnoTunnel.hpp>
60 #endif
62 #ifndef _CPPUHELPER_IMPLBASE3_HXX_
63 #include <cppuhelper/implbase3.hxx>
64 #endif
65 #ifndef _CPPUHELPER_IMPLBASE5_HXX_
66 #include <cppuhelper/implbase5.hxx>
67 #endif
68 namespace binfilter {
71 class EditEngine;
72 class EditTextObject;
73 class SvxEditEngineForwarder;
74 class ScDocShell;
75 class ScAddress;
76 class ScCellObj;
77 class ScSimpleEditSource;
78 class ScSharedCellEditSource;
79 class ScEditEngineDefaulter;
80 class ScFieldEditEngine;
82 struct ScHeaderFieldData;
85 #define SC_HDFT_LEFT 0
86 #define SC_HDFT_CENTER 1
87 #define SC_HDFT_RIGHT 2
90 // ScHeaderFooterContentObj ist ein dummer Container, der per setPropertyValue
91 // wieder in die Seitenvorlage geschrieben werden muss
93 class ScHeaderFooterContentObj : public cppu::WeakImplHelper3<
94 ::com::sun::star::sheet::XHeaderFooterContent,
95 ::com::sun::star::lang::XUnoTunnel,
96 ::com::sun::star::lang::XServiceInfo >
98 private:
99 EditTextObject* pLeftText;
100 EditTextObject* pCenterText;
101 EditTextObject* pRightText;
102 SfxBroadcaster aBC;
104 public:
105 ScHeaderFooterContentObj( const EditTextObject* pLeft,
106 const EditTextObject* pCenter,
107 const EditTextObject* pRight );
108 virtual ~ScHeaderFooterContentObj();
110 // fuer ScPageHFItem (per getImplementation)
111 const EditTextObject* GetLeftEditObject() const { return pLeftText; }
112 const EditTextObject* GetCenterEditObject() const { return pCenterText; }
113 const EditTextObject* GetRightEditObject() const { return pRightText; }
115 void AddListener( SfxListener& rListener );
116 void RemoveListener( SfxListener& rListener );
118 void UpdateText( USHORT nPart, EditEngine& rSource );
120 // XHeaderFooterContent
121 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
122 getLeftText() throw(::com::sun::star::uno::RuntimeException);
123 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
124 getCenterText() throw(::com::sun::star::uno::RuntimeException);
125 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
126 getRightText() throw(::com::sun::star::uno::RuntimeException);
128 // XUnoTunnel
129 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
130 sal_Int8 >& aIdentifier )
131 throw(::com::sun::star::uno::RuntimeException);
133 static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
134 static ScHeaderFooterContentObj* getImplementation( const ::com::sun::star::uno::Reference<
135 ::com::sun::star::sheet::XHeaderFooterContent> xObj );
137 // XServiceInfo
138 virtual ::rtl::OUString SAL_CALL getImplementationName()
139 throw(::com::sun::star::uno::RuntimeException);
140 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
141 throw(::com::sun::star::uno::RuntimeException);
142 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
143 throw(::com::sun::star::uno::RuntimeException);
147 // ScHeaderFooterTextData: shared data between sub objects of a ScHeaderFooterTextObj
149 class ScHeaderFooterTextData : public SfxListener
151 private:
152 ScHeaderFooterContentObj& rContentObj;
153 USHORT nPart;
154 ScEditEngineDefaulter* pEditEngine;
155 SvxEditEngineForwarder* pForwarder;
156 BOOL bDataValid;
157 BOOL bInUpdate;
159 public:
160 ScHeaderFooterTextData( ScHeaderFooterContentObj& rContent,
161 USHORT nP );
162 ~ScHeaderFooterTextData();
164 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
166 // helper functions
167 SvxTextForwarder* GetTextForwarder();
168 void UpdateData();
169 ScEditEngineDefaulter* GetEditEngine() { GetTextForwarder(); return pEditEngine; }
171 USHORT GetPart() const { return nPart; }
172 ScHeaderFooterContentObj& GetContentObj() const { return rContentObj; }
175 // ScHeaderFooterTextObj veraendert den Text in einem ScHeaderFooterContentObj
177 class ScHeaderFooterTextObj : public cppu::WeakImplHelper5<
178 ::com::sun::star::text::XText,
179 ::com::sun::star::text::XTextRangeMover,
180 ::com::sun::star::container::XEnumerationAccess,
181 ::com::sun::star::text::XTextFieldsSupplier,
182 ::com::sun::star::lang::XServiceInfo >
184 private:
185 ScHeaderFooterTextData aTextData;
186 SvxUnoText* pUnoText;
188 void CreateUnoText_Impl();
190 public:
191 ScHeaderFooterTextObj( ScHeaderFooterContentObj& rContent,
192 USHORT nP );
193 virtual ~ScHeaderFooterTextObj();
195 const SvxUnoText& GetUnoText();
197 static void FillDummyFieldData( ScHeaderFieldData& rData );
199 // XText
200 virtual void SAL_CALL insertTextContent( const ::com::sun::star::uno::Reference<
201 ::com::sun::star::text::XTextRange >& xRange,
202 const ::com::sun::star::uno::Reference<
203 ::com::sun::star::text::XTextContent >& xContent,
204 sal_Bool bAbsorb )
205 throw(::com::sun::star::lang::IllegalArgumentException,
206 ::com::sun::star::uno::RuntimeException);
207 virtual void SAL_CALL removeTextContent( const ::com::sun::star::uno::Reference<
208 ::com::sun::star::text::XTextContent >& xContent )
209 throw(::com::sun::star::container::NoSuchElementException,
210 ::com::sun::star::uno::RuntimeException);
212 // XSimpleText
213 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL
214 createTextCursor() throw(::com::sun::star::uno::RuntimeException);
215 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL
216 createTextCursorByRange( const ::com::sun::star::uno::Reference<
217 ::com::sun::star::text::XTextRange >& aTextPosition )
218 throw(::com::sun::star::uno::RuntimeException);
219 virtual void SAL_CALL insertString( const ::com::sun::star::uno::Reference<
220 ::com::sun::star::text::XTextRange >& xRange,
221 const ::rtl::OUString& aString, sal_Bool bAbsorb )
222 throw(::com::sun::star::uno::RuntimeException);
223 virtual void SAL_CALL insertControlCharacter( const ::com::sun::star::uno::Reference<
224 ::com::sun::star::text::XTextRange >& xRange,
225 sal_Int16 nControlCharacter, sal_Bool bAbsorb )
226 throw(::com::sun::star::lang::IllegalArgumentException,
227 ::com::sun::star::uno::RuntimeException);
229 // XTextRange
230 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
231 getText() throw(::com::sun::star::uno::RuntimeException);
232 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
233 getStart() throw(::com::sun::star::uno::RuntimeException);
234 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
235 getEnd() throw(::com::sun::star::uno::RuntimeException);
236 virtual ::rtl::OUString SAL_CALL getString() throw(::com::sun::star::uno::RuntimeException);
237 virtual void SAL_CALL setString( const ::rtl::OUString& aString )
238 throw(::com::sun::star::uno::RuntimeException);
240 // XTextRangeMover
241 virtual void SAL_CALL moveTextRange( const ::com::sun::star::uno::Reference<
242 ::com::sun::star::text::XTextRange >& xRange,
243 sal_Int16 nParagraphs )
244 throw(::com::sun::star::uno::RuntimeException);
246 // XEnumerationAccess
247 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
248 createEnumeration() throw(::com::sun::star::uno::RuntimeException);
250 // XElementAccess
251 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
252 throw(::com::sun::star::uno::RuntimeException);
253 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
255 // XTextFieldsSupplier
256 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerationAccess > SAL_CALL
257 getTextFields() throw(::com::sun::star::uno::RuntimeException);
258 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL
259 getTextFieldMasters() throw(::com::sun::star::uno::RuntimeException);
261 // XServiceInfo
262 virtual ::rtl::OUString SAL_CALL getImplementationName()
263 throw(::com::sun::star::uno::RuntimeException);
264 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
265 throw(::com::sun::star::uno::RuntimeException);
266 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
267 throw(::com::sun::star::uno::RuntimeException);
271 // derived cursor objects for getImplementation and getText/getStart/getEnd
273 //! uno3: SvxUnoTextCursor is not derived from XUnoTunnel, but should be (?)
275 class ScCellTextCursor : public SvxUnoTextCursor
277 ScCellObj& rTextObj;
279 public:
280 ScCellTextCursor(const ScCellTextCursor& rOther);
281 ScCellTextCursor(ScCellObj& rText);
282 virtual ~ScCellTextCursor() throw();
284 // SvxUnoTextCursor methods reimplemented here:
285 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
286 getText() throw(::com::sun::star::uno::RuntimeException);
287 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
288 getStart() throw(::com::sun::star::uno::RuntimeException);
289 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
290 getEnd() throw(::com::sun::star::uno::RuntimeException);
292 // XUnoTunnel
293 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
294 sal_Int8 >& aIdentifier )
295 throw(::com::sun::star::uno::RuntimeException);
297 static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
298 static ScCellTextCursor* getImplementation( const ::com::sun::star::uno::Reference<
299 ::com::sun::star::uno::XInterface> xObj );
302 class ScHeaderFooterTextCursor : public SvxUnoTextCursor
304 private:
305 ScHeaderFooterTextObj& rTextObj;
307 public:
308 ScHeaderFooterTextCursor(const ScHeaderFooterTextCursor& rOther);
309 ScHeaderFooterTextCursor(ScHeaderFooterTextObj& rText);
310 virtual ~ScHeaderFooterTextCursor() throw();
312 // SvxUnoTextCursor methods reimplemented here:
313 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
314 getText() throw(::com::sun::star::uno::RuntimeException);
315 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
316 getStart() throw(::com::sun::star::uno::RuntimeException);
317 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
318 getEnd() throw(::com::sun::star::uno::RuntimeException);
320 // XUnoTunnel
321 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
322 sal_Int8 >& aIdentifier )
323 throw(::com::sun::star::uno::RuntimeException);
325 static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
326 static ScHeaderFooterTextCursor* getImplementation( const ::com::sun::star::uno::Reference<
327 ::com::sun::star::uno::XInterface> xObj );
330 class ScDrawTextCursor : public SvxUnoTextCursor
332 private:
333 ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText;
335 public:
336 ScDrawTextCursor(const ScDrawTextCursor& rOther);
337 ScDrawTextCursor( const ::com::sun::star::uno::Reference<
338 ::com::sun::star::text::XText >& xParent,
339 const SvxUnoTextBase& rText );
340 virtual ~ScDrawTextCursor() throw();
342 // SvxUnoTextCursor methods reimplemented here:
343 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
344 getText() throw(::com::sun::star::uno::RuntimeException);
345 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
346 getStart() throw(::com::sun::star::uno::RuntimeException);
347 virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
348 getEnd() throw(::com::sun::star::uno::RuntimeException);
352 // ScAnnotationTextCursor isn't needed anymore - SvxUnoTextCursor is used instead
355 // ScEditEngineTextObj for formatted cell content that is not inserted in a cell or header/footer
356 // (used for XML export of change tracking contents)
358 class ScSimpleEditSourceHelper
360 ScEditEngineDefaulter* pEditEngine;
361 SvxEditEngineForwarder* pForwarder;
362 ScSimpleEditSource* pOriginalSource;
364 public:
365 ScSimpleEditSourceHelper();
366 ~ScSimpleEditSourceHelper();
368 ScSimpleEditSource* GetOriginalSource() const { return pOriginalSource; }
369 ScEditEngineDefaulter* GetEditEngine() const { return pEditEngine; }
372 class ScEditEngineTextObj : public ScSimpleEditSourceHelper, public SvxUnoText
374 public:
375 ScEditEngineTextObj();
376 virtual ~ScEditEngineTextObj() throw();
378 void SetText( const EditTextObject& rTextObject );
379 EditTextObject* CreateTextObject();
383 // ScCellTextData: shared data between sub objects of a cell text object
385 class ScCellTextData : public SfxListener
387 protected:
388 ScDocShell* pDocShell;
389 ScAddress aCellPos;
390 ScFieldEditEngine* pEditEngine;
391 SvxEditEngineForwarder* pForwarder;
392 ScSharedCellEditSource* pOriginalSource;
393 BOOL bDataValid;
394 BOOL bInUpdate;
395 BOOL bDirty;
396 BOOL bDoUpdate;
398 protected:
399 virtual void GetCellText(const ScAddress& rCellPos, String& rText);
401 public:
402 ScCellTextData(ScDocShell* pDocSh, const ScAddress& rP);
403 virtual ~ScCellTextData();
405 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
407 // helper functions for ScSharedCellEditSource:
408 virtual SvxTextForwarder* GetTextForwarder();
409 void UpdateData();
410 ScFieldEditEngine* GetEditEngine() { GetTextForwarder(); return pEditEngine; }
412 ScSharedCellEditSource* GetOriginalSource(); // used as argument for SvxUnoText ctor
414 // used for ScCellEditSource:
415 ScDocShell* GetDocShell() const { return pDocShell; }
416 const ScAddress& GetCellPos() const { return aCellPos; }
418 void SetDirty(BOOL bValue) { bDirty = bValue; }
419 BOOL IsDirty() const { return bDirty; }
420 void SetDoUpdate(BOOL bValue) { bDoUpdate = bValue; }
423 class ScCellTextObj : public ScCellTextData, public SvxUnoText
425 public:
426 ScCellTextObj(ScDocShell* pDocSh, const ScAddress& rP);
427 virtual ~ScCellTextObj() throw();
431 } //namespace binfilter
432 #endif