1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoedsrc.hxx,v $
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 _SVX_UNOEDSRC_HXX
32 #define _SVX_UNOEDSRC_HXX
35 #include <tools/solar.h>
37 #ifndef INCLUDED_I18NPOOL_LANG_H
38 #include <i18npool/lang.h>
40 #ifndef _SV_MAPMOD_HXX
41 #include <vcl/mapmod.hxx>
44 #ifndef _SFXITEMPOOL_HXX //autogen
45 #include <bf_svtools/itempool.hxx>
58 class SvxTextForwarder
;
59 class SvxViewForwarder
;
60 class SvxEditViewForwarder
;
62 class EECharAttribArray
;
64 /** Wrapper class for unified EditEngine/Outliner access
66 This class wraps a textual object, which might or might not
67 contain an EditEngine/Outliner. Is used e.g. for filling an
68 EditEngine with the content of a cell, note page or page template.
73 virtual ~SvxEditSource();
75 /// Returns a new reference to the same object. This is a shallow copy
76 virtual SvxEditSource
* Clone() const = 0;
78 /** Query the text forwarder
80 @return the text forwarder, or NULL if the underlying object is dead
82 virtual SvxTextForwarder
* GetTextForwarder() = 0;
84 /** Query the view forwarder
86 @return the view forwarder, or NULL if the underlying object
87 is dead, or if no view is available
89 @derive default implementation provided, overriding is optional
91 virtual SvxViewForwarder
* GetViewForwarder();
93 /** Query the edit view forwarder
96 Determines whether an EditView should be created, if there is
97 none active. If set to sal_True, and the underlying object is
98 not in EditMode, the text forwarder changes and the object is
101 @return the edit view forwarder, or NULL if the underlying
102 object is dead, or if no view is available (if bCreate is
103 sal_False, NULL is also returned if the object is not in
106 @derive default implementation provided, overriding is optional
108 @attention If this method is called with bCreate equal to
109 sal_True, all previously returned text forwarder can become
112 virtual SvxEditViewForwarder
* GetEditViewForwarder( sal_Bool bCreate
= sal_False
);
114 /// Write back data to model
115 virtual void UpdateData() = 0;
117 /** Returns broadcaster the underlying edit engine's events are sent from
119 @derive default implementation provided, overriding is optional
121 virtual SfxBroadcaster
& GetBroadcaster() const;
125 /** Contains an EditEngine or an Outliner and unifies access to them.
127 The EditEngine-UNO objects use this class only. To reflect changes
128 not only in the EditEngine, but also in the model data, call
129 SvxEditSource::UpdateData(). This copies back the data to the model's
130 EditTextObject/OutlinerParaObject.
132 class SvxTextForwarder
135 virtual ~SvxTextForwarder();
137 virtual USHORT
GetParagraphCount() const = 0;
138 virtual USHORT
GetTextLen( USHORT nParagraph
) const = 0;
139 virtual String
GetText( const ESelection
& rSel
) const = 0;
140 virtual SfxItemSet
GetAttribs( const ESelection
& rSel
, BOOL bOnlyHardAttrib
= 0 ) const = 0;
141 virtual SfxItemSet
GetParaAttribs( USHORT nPara
) const = 0;
142 virtual void SetParaAttribs( USHORT nPara
, const SfxItemSet
& rSet
) = 0;
143 virtual void GetPortions( USHORT nPara
, SvUShorts
& rList
) const = 0;
145 virtual USHORT
GetItemState( const ESelection
& rSel
, USHORT nWhich
) const = 0;
146 virtual USHORT
GetItemState( USHORT nPara
, USHORT nWhich
) const = 0;
148 virtual void QuickInsertText( const String
& rText
, const ESelection
& rSel
) = 0;
149 virtual void QuickInsertField( const SvxFieldItem
& rFld
, const ESelection
& rSel
) = 0;
150 virtual void QuickSetAttribs( const SfxItemSet
& rSet
, const ESelection
& rSel
) = 0;
151 virtual void QuickInsertLineBreak( const ESelection
& rSel
) = 0;
153 virtual XubString
CalcFieldValue( const SvxFieldItem
& rField
, USHORT nPara
, USHORT nPos
, Color
*& rpTxtColor
, Color
*& rpFldColor
) = 0;
155 virtual SfxItemPool
* GetPool() const = 0;
157 /** Query state of forwarder
159 @return sal_False, if no longer valid
161 virtual BOOL
IsValid() const = 0;
163 /** Query language of character at given position on the underlying edit engine
165 @param nPara[0 .. n-1]
166 Index of paragraph to query language in
168 @param nIndex[0 .. m-1]
169 Index of character to query language of
171 virtual LanguageType
GetLanguage( USHORT nPara
, USHORT nIndex
) const = 0;
173 /** Query number of fields in the underlying edit engine
175 @param nPara[0 .. n-1]
176 Index of paragraph to query field number in
178 virtual USHORT
GetFieldCount( USHORT nPara
) const = 0;
180 /** Query information for given field number in the underlying edit engine
182 @param nPara[0 .. n-1]
183 Index of paragraph to query field info in
185 @param nField[0 .. m-1]
186 Index of field to query information of
188 virtual EFieldInfo
GetFieldInfo( USHORT nPara
, USHORT nField
) const = 0;
190 /** Query information regarding bullets for given paragraph on the underlying edit engine
192 @param nPara[0 .. n-1]
193 Index of paragraph to query bullet info on
195 virtual EBulletInfo
GetBulletInfo( USHORT nPara
) const = 0;
197 /** Query the bounding rectangle of the given character
200 Index of paragraph to query the bounds in. <p>The virtual
201 character after the last character of the represented text,
202 i.e. the one at position n is a special case. Because it does
203 not represent an existing character its bounding box is
204 defined in relation to preceding characters. It should be
205 rougly equivalent to the bounding box of some character when
206 inserted at the end of the text. Its height typically being
207 the maximal height of all the characters in the text or the
208 height of the preceding character, its width being at least
209 one pixel so that the bounding box is not degenerate.<br>
211 @param nIndex[0 .. m-1]
212 Index of character to query the bounds of
214 @return rectangle in logical coordinates, relative to upper
215 left corner of text. The coordinates returned here are to be
216 interpreted in the map mode given by GetMapMode().
218 virtual Rectangle
GetCharBounds( USHORT nPara
, USHORT nIndex
) const = 0;
220 /** Query the bounding rectangle of the given paragraph
222 @param nPara[0 .. n-1]
223 Index of paragraph to query the bounds of
225 @return rectangle in logical coordinates, relative to upper
226 left corner of text. The coordinates returned here are to be
227 interpreted in the map mode given by GetMapMode().
229 virtual Rectangle
GetParaBounds( USHORT nPara
) const = 0;
231 /** Query the map mode of the underlying EditEngine/Outliner
233 @return the map mode used on the EditEngine/Outliner. The
234 values returned by GetParaBounds() and GetCharBounds() are to
235 be interpreted in this map mode, the point given to
236 GetIndexAtPoint() is interpreted in this map mode.
238 virtual MapMode
GetMapMode() const = 0;
240 /** Query the reference output device of the underlying EditEngine/Outliner
242 @return the OutputDevice used from the EditEngine/Outliner to
243 format the text. It should be used when performing e.g. font
244 calculations, since this is usually a printer with fonts and
245 resolution different from the screen.
247 virtual OutputDevice
* GetRefDevice() const = 0;
249 /** Query paragraph and character index of the character at the
250 given point. Returns sal_True on success, sal_False otherwise
253 Point to query text position of. Is interpreted in logical
254 coordinates, relativ to the upper left corner of the text, and
255 in the map mode given by GetMapMode()
257 @param rPara[0 .. n-1]
258 Index of paragraph the point is within
260 @param rIndex[0 .. m-1]
261 Index of character the point is over
263 @return sal_True, if the point is over any text and both rPara and rIndex are valid
266 virtual sal_Bool
GetIndexAtPoint( const Point
& rPoint
, USHORT
& rPara
, USHORT
& rIndex
) const = 0;
268 /** Get the start and the end index of the word at the given index
270 An index value on a word leads from the first character of
271 that word up to and including the last space before the next
272 word. The index values returned do not contain any leading or
273 trailing white-space. If the input indices are invalid,
274 sal_False is returned.
276 @param nPara[0 .. n-1]
277 Index of paragraph to start the search in
279 @param nIndex[0 .. m-1]
280 Index of character to query the search on
283 Start index (in the same paragraph)
286 End index (in the same paragraph), this point to the last
287 character still contained in the query
289 @return sal_True, if the result is non-empty
291 virtual sal_Bool
GetWordIndices( USHORT nPara
, USHORT nIndex
, USHORT
& rStart
, USHORT
& rEnd
) const = 0;
293 /** Query range of similar attributes
295 Please note that the range returned is half-open: [nStartIndex,nEndIndex)
298 Herein, the start index of the range of similar attributes is returned
301 Herein, the end index (exclusive) of the range of similar attributes is returned
304 The character index from which the range of similar attributed characters is requested
306 @return sal_True, if the range has been successfully determined
308 virtual sal_Bool
GetAttributeRun( USHORT
& nStartIndex
, USHORT
& nEndIndex
, USHORT nPara
, USHORT nIndex
) const = 0;
310 /** Query number of lines in the formatted paragraph
312 @param nPara[0 .. n-1]
313 Index of paragraph to query number of lines in
315 @return number of lines in given paragraph
318 virtual USHORT
GetLineCount( USHORT nPara
) const = 0;
320 /** Query line length
322 @param nPara[0 .. n-1]
323 Index of paragraph to query line length in
325 @param nLine[0 .. m-1]
326 Index of line in paragraph to query line length of
329 virtual USHORT
GetLineLen( USHORT nPara
, USHORT nLine
) const = 0;
331 /** Delete given text range and reformat text
334 The text range to be deleted
336 @return sal_True if text has been successfully deleted
338 virtual sal_Bool
Delete( const ESelection
& rSelection
) = 0;
340 /** Insert/Replace given text in given range and reformat text
343 Text to insert/replace
346 Selection where text should be replaced. The empty selection inserts
348 @return sal_True if text has been successfully inserted
350 virtual sal_Bool
InsertText( const String
& rText
, const ESelection
& rSel
) = 0;
352 /** Updates the formatting
354 @see EditEngine::QuickFormatDoc() for details
356 @return sal_True if text have been successfully reformatted
358 virtual sal_Bool
QuickFormatDoc( BOOL bFull
=FALSE
) = 0;
360 /** Get the outline depth of given paragraph
363 Index of the paragraph to query the depth of
365 @return the outline level of the given paragraph. The range is
366 [0,n), where n is the maximal outline level.
368 virtual USHORT
GetDepth( USHORT nPara
) const = 0;
370 /** Set the outline depth of given paragraph
373 Index of the paragraph to set the depth of
376 The depth to set on the given paragraph. The range is
377 [0,n), where n is the maximal outline level.
379 @return TRUE, if depth could be successfully set. Reasons for
380 failure are e.g. the text does not support outline level
381 (EditEngine), or the depth range is exceeded.
383 virtual sal_Bool
SetDepth( USHORT nPara
, USHORT nNewDepth
) = 0;
387 /** Encapsulates the document view for the purpose of unified
388 EditEngine/Outliner access.
390 This one has to be different from the SvxEditViewForwarder, since
391 the latter is only valid in edit mode.
393 class SvxViewForwarder
396 virtual ~SvxViewForwarder();
398 /** Query state of forwarder
400 @return sal_False, if no longer valid
402 virtual BOOL
IsValid() const = 0;
404 /** Query visible area of the view containing the text
406 @return the visible rectangle of the text, i.e. the part of
407 the EditEngine or Outliner that is currently on screen. The
408 values are already in screen coordinates (pixel), and have to
409 be relative to the EditEngine/Outliner's upper left corner.
411 virtual Rectangle
GetVisArea() const = 0;
413 /** Convert from logical, EditEngine-relative coordinates to screen coordinates
416 Point in logical, EditEngine-relative coordinates.
419 The map mode to interpret the coordinates in.
421 @return the point in screen coordinates
423 virtual Point
LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const = 0;
425 /** Convert from screen to logical, EditEngine-relative coordinates
428 Point in screen coordinates
431 The map mode to interpret the coordinates in.
433 @return the point in logical coordinates.
435 virtual Point
PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const = 0;
439 /** Encapsulates EditView and OutlinerView for the purpose of unified
440 EditEngine/Outliner access
442 class SvxEditViewForwarder
: public SvxViewForwarder
446 /** Query current selection.
449 Contains the current selection after method call
451 @return sal_False, if there is no view or no selection (the empty selection _is_ a selection)
454 virtual sal_Bool
GetSelection( ESelection
& rSelection
) const = 0;
456 /** Set selection in view.
461 @return sal_False, if there is no view or selection is invalid
463 virtual sal_Bool
SetSelection( const ESelection
& rSelection
) = 0;
465 /** Copy current selection to clipboard.
467 @return sal_False if no selection or no view (the empty selection _is_ a selection)
469 virtual sal_Bool
Copy() = 0;
471 /** Cut current selection to clipboard.
473 @eturn sal_False if no selection or no view (the empty selection _is_ a selection)
475 virtual sal_Bool
Cut() = 0;
477 /** Paste clipboard into current selection.
479 @return sal_False if no view or no selection (the empty selection _is_ a selection)
481 virtual sal_Bool
Paste() = 0;
485 }//end of namespace binfilter