1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 #ifndef __com_sun_star_rendering_XTextLayout_idl__
28 #define __com_sun_star_rendering_XTextLayout_idl__
30 #ifndef __com_sun_star_uno_XInterface_idl__
31 #include
<com
/sun
/star
/uno
/XInterface.idl
>
33 #ifndef __com_sun_star_lang_IllegalArgumentException_idl__
34 #include
<com
/sun
/star
/lang
/IllegalArgumentException.idl
>
36 #ifndef __com_sun_star_lang_IndexOutOfBoundsException_idl__
37 #include
<com
/sun
/star
/lang
/IndexOutOfBoundsException.idl
>
39 #ifndef __com_sun_star_geometry_RealPoint2D_idl__
40 #include
<com
/sun
/star
/geometry
/RealPoint2D.idl
>
42 #ifndef __com_sun_star_geometry_RealBezierSegment2D_idl__
43 #include
<com
/sun
/star
/geometry
/RealBezierSegment2D.idl
>
45 #ifndef __com_sun_star_geometry_RealRectangle2D_idl__
46 #include
<com
/sun
/star
/geometry
/RealRectangle2D.idl
>
48 #ifndef __com_sun_star_rendering_ViewState_idl__
49 #include
<com
/sun
/star
/rendering
/ViewState.idl
>
51 #ifndef __com_sun_star_rendering_RenderState_idl__
52 #include
<com
/sun
/star
/rendering
/RenderState.idl
>
54 #ifndef __com_sun_star_rendering_StringContext_idl__
55 #include
<com
/sun
/star
/rendering
/StringContext.idl
>
57 #ifndef __com_sun_star_rendering_TextHit_idl__
58 #include
<com
/sun
/star
/rendering
/TextHit.idl
>
60 #ifndef __com_sun_star_rendering_Caret_idl__
61 #include
<com
/sun
/star
/rendering
/Caret.idl
>
65 module com
{ module sun
{ module star
{ module rendering
{
68 interface XCanvasFont
;
69 interface XPolyPolygon2D
;
71 /** This is the central interface for text layouting.<p>
73 This is the central interface for text-related tasks more
74 complicated than simple string rendering. Note that all query
75 methods are subject to the current layout state of this
76 object. That is, calls to <member>XTextLayout::justify()</member>
77 or <member>XTextLayout::applyLogicalAdvancements()</member> are
78 likely to change subsequent output of those query methods.<p>
80 Similar to <type>XCanvasFont</type>, all measurements and
81 coordinates accepted and returned by this interface are relative
82 to the font's local coordinate system (which only equals device
83 coordinate space, if the combined render transformation used
84 during text output is the identity transformation). Conversely, if
85 the combined transformation used during text output is
86 <em>not</em> the identity transformation, all measurements
87 returned by this interface should be subjected to that
88 transformation, to yield values in device coordinate space.
89 Depending on the underlying font technology, actual device output
90 might be off by up to one device pixel from the transformed
95 interface XTextLayout
: ::com
::sun
::star
::uno
::XInterface
97 /** Extract the polygonal shapes of the layouted text.<p>
99 Each glyph is represented by a separate
100 <type>XPolyPolygon2D</type> in the returned sequence.<p>
102 @returns a sequence of <type>XPolyPolygon2D</type> in font
103 coordinate space, one for every glyph.
105 sequence
<XPolyPolygon2D
> queryTextShapes
();
107 //-------------------------------------------------------------------------
109 /** Query the ink bounding boxes for every glyph in the layouted
112 Ink, or tight bounding boxes in this case means that for
113 e.g. an 'a', the bounding box for the
114 <type>XPolyPolygon2D</type> describing the glyph 'a' is
115 returned, not the logical dimensions of the character in the
118 @returns a sequence of rectangles in font coordinate space,
119 specifying the bounds, one for every glyph.
121 @see <member>XTextLayout::queryMeasures()</member>
123 sequence
<::com
::sun
::star
::geometry
::RealRectangle2D
> queryInkMeasures
();
125 //-------------------------------------------------------------------------
127 /** Query the logical bounding boxes of every character in the
128 given text string.<p>
130 Logical bounding boxes means the space that the font allocates
131 for the given character, which, e.g. for a '.', might be
132 significantly broader than the bounds returned via
133 <member>XTextLayout::queryInkMeasures()</member>.
135 @returns a sequence of rectangles specifying the bounds in
136 font coordinate space, one for every glyph.
138 @see <member>XTextLayout::queryInkMeasures()</member>
140 sequence
<::com
::sun
::star
::geometry
::RealRectangle2D
> queryMeasures
();
142 //-------------------------------------------------------------------------
144 /** Query the advancements for every character in the input string.<p>
146 This method returns a sequence of advancements, one for each
147 character in the input string (<em>not</em> for every
148 glyph. There might be multiple glyphs per input character, or
149 multiple input characters per glyph). Adding up all
150 advancements yields the total advancement of this layout. To
151 manipulate the layout of a string on the level of characters,
152 this method can be used to query for the layout's default
153 advancements, which can subsequently be changed and applied to
155 <member>XTextLayout::applyLogicalAdvancements()</member>.<p>
157 @returns a sequence of <type>double</type> specifying the
158 advancements per character in font coordinate space.
160 @see <member>XTextLayout::applyLogicalAdvancements()</member>
162 sequence
<double> queryLogicalAdvancements
();
164 //-------------------------------------------------------------------------
166 /** Apply explicit advancements for every character in the layout
169 This method applies the specified advancements to every
170 logical character in the input string (<em>not</em> for every
171 glyph. There might be multiple glyphs per input character, or
172 multiple input characters per glyph). This is useful to
173 explicitely manipulate the exact output positions of
174 characters, e.g. relative to a reference output device.<p>
177 A sequence of character advancements, in font coordinate
180 @see <member>XTextLayout::queryLogicalAdvancements()</member>
182 @throws <type>com::sun::star::lang::IllegalArgumentException</type>
183 if the size of aAdvancements does not match the number of
184 characters in the text.
186 void applyLogicalAdvancements
( [in] sequence
< double > aAdvancements
)
187 raises
(com
::sun
::star
::lang
::IllegalArgumentException
);
189 //-------------------------------------------------------------------------
191 /** Query the overall bounding box of the text.<p>
193 This method is similar to
194 <member>XTextLayout::queryTextMeasures</member>, only that the
195 overall bounds are returned by this method.<p>
197 @return the overall bounding box for the given layout, in font
200 ::com
::sun
::star
::geometry
::RealRectangle2D queryTextBounds
();
202 //-------------------------------------------------------------------------
204 /** Justify the text to the given size.<p>
206 This method is the core of the <type>XTextLayout</type>
207 interface, because it layouts the text in a typographically
208 correct way into the available space.<p>
211 The requested size of the text after justification (either
212 width or height, depending on the writing mode). This
213 parameter is interpreted in font coordinate space.
215 @return the actual size of the text after the justification in
216 the font coordinate space. Depending on the font and the
217 script type, this might be somewhat different from the size
218 requested. If the requested size was smaller than the
219 justification algorithm could compress the text, this value
220 might even be significantly larger than nSize.
222 @throws <type>com::sun::star::lang::IllegalArgumentException</type>
223 if nSize is 0 or negative.
225 double justify
( [in] double nSize
)
226 raises
(com
::sun
::star
::lang
::IllegalArgumentException
);
228 //-------------------------------------------------------------------------
230 /** Justify a number of text layouts to the given size.<p>
232 This method can be used to combine the layout of a text line
233 into a single justification run. This is e.g. useful if the
234 line consists of several text portions (e.g. because of
235 different fonts or colors), but it is desirable to spread the
236 available space more globally across the different layout
237 objects. If, for example, one layout object contains
238 significantly more whitespace or Kashidas than the rest, this
239 method can assign proportionally more space to this layout
243 A sequence of layouts following this one in logical text
247 The requested size of the text for <em>all</em>
248 <type>XTextLayout</type>s after justification in font
249 coordinate space (either width or height, depending on the
252 @return the actual size of the text after the justification,
253 in font coordinate space. Depending on the font and the
254 script type, this might be somewhat different from the size
255 requested. If the requested size was smaller than the
256 justification algorithm could compress the text, this value
257 might even be significantly larger than nSize.
259 @throws <type>com::sun::star::lang::IllegalArgumentException</type>
260 if one of the parameters are not in the valid range.
262 double combinedJustify
( [in] sequence
< XTextLayout
> aNextLayouts
, [in] double nSize
)
263 raises
(com
::sun
::star
::lang
::IllegalArgumentException
);
265 //-------------------------------------------------------------------------
267 /** This method determines the hit position in the text.<p>
269 This method determines the index of the character hit at the
270 specified position (in font coordinate space).<p>
273 The position in font coordinate space to determine the
274 underlying character index for.
277 TextHit getTextHit
( [in] ::com
::sun
::star
::geometry
::RealPoint2D aHitPoint
);
279 //-------------------------------------------------------------------------
281 /** This method converts an insertion index to a caret.<p>
283 This method generates caret information for a given insertion
284 point in the layout text.<p>
286 @param nInsertionIndex
287 The insertion index, as e.g. returned by
288 <member>XTextLayout::getTextHit()</member>. This value must be
289 in the range 0 up to the number of characters in the string.
291 @param bExcludeLigatures
292 Set this to <TRUE/>, to skip the positions inside ligatures as
293 valid caret placements. That means, on cannot e.g. set the
294 caret between the 'f' and the 'i' in a 'fi' ligature.
296 @returns the generated Caret structure.
298 @throws <type>com::sun::star::lang::IndexOutOfBoundsException</type>
299 if nInsertionIndex is outside the permissible range.
301 Caret getCaret
( [in] long nInsertionIndex
,
302 [in] boolean bExcludeLigatures
)
303 raises
(com
::sun
::star
::lang
::IndexOutOfBoundsException
);
305 //-------------------------------------------------------------------------
307 /** This method calculates a new insertion index.<p>
309 This method calculates a new insertion index, given a start
310 index and the number of characters to skip. This is most
311 useful for caret traveling.<p>
314 The insertion index to start from.
316 @param nCaretAdvancement
317 For values greater than 0, the caret is visually moved to the
318 right. For values smaller than 0, the caret is visually moved
321 @returns the new insertion index.
323 @throws <type>com::sun::star::lang::IndexOutOfBoundsException</type>
324 if nStartIndex or nCaretAdvancement is outside the permissible
327 long getNextInsertionIndex
( [in] long nStartIndex
,
328 [in] long nCaretAdvancement
,
329 [in] boolean bExcludeLigatures
)
330 raises
(com
::sun
::star
::lang
::IndexOutOfBoundsException
);
332 //-------------------------------------------------------------------------
334 /** This method generates a highlight polygon.<p>
336 This method generates a highlighting polygon from two
337 insertion indices. This polygon will be visually continuous,
338 i.e. will not have non-highlighted text in between.<p>
341 Start of the selection range.
344 End of the selection range.
346 @return the highlight polygon in the font coordinate space.
348 @throws <type>com::sun::star::lang::IndexOutOfBoundsException</type>
349 if nStartIndex or nEndIndex are outside the permissible
352 XPolyPolygon2D queryVisualHighlighting
( [in] long nStartIndex
,
353 [in] long nEndIndex
)
354 raises
(com
::sun
::star
::lang
::IndexOutOfBoundsException
);
356 //-------------------------------------------------------------------------
358 /** This method generates a highlight polygon.<p>
360 This method generates a highlighting polygon from two
361 insertion indices. This polygon will not always be visually
362 continuous, if e.g. the text direction changes in the middle
363 of the selection, the might be parts visually between start
364 and end position that are not selected.<p>
367 Start of the selection range.
370 End of the selection range.
372 @return the highlight polygon in the font coordinate space.
374 @throws <type>com::sun::star::lang::IndexOutOfBoundsException</type>
375 if nStartIndex or nEndIndex are outside the permissible
378 XPolyPolygon2D queryLogicalHighlighting
( [in] long nStartIndex
,
379 [in] long nEndIndex
)
380 raises
(com
::sun
::star
::lang
::IndexOutOfBoundsException
);
382 //-------------------------------------------------------------------------
384 /** This method yields the baseline offset.<p>
386 This method returns the baseline offset for this layout
387 object, either measured from the top or the left edge,
388 depending on the writing direction (horizontally or
389 vertically). Since rendering this layout via
390 <member>XCanvas::drawTextLayout()</member> outputs relative to
391 the layout object's baseline, this method can be used to
392 e.g. output relative to the left, top edge.<p>
394 @returns the distance of the main baseline from the top or the
395 left edge of this object, depending on the writing direction.
397 double getBaselineOffset
();
399 //-------------------------------------------------------------------------
401 /** This method returns the main writing direction.<p>
403 This method returns the main writing direction of this layout,
404 i.e. either LEFT_TO_RIGHT or RIGHT_TO_LEFT.<p>
406 @returns the main text direction of this layout.
408 byte getMainTextDirection
();
410 //-------------------------------------------------------------------------
412 /** Request the associated font for this layout..
414 @returns the associated font for this layout.
416 XCanvasFont getFont
();
418 //-------------------------------------------------------------------------
420 /** Request the text this layout contains.
422 @returns the text this layout contains.
424 StringContext getText
();
426 //-------------------------------------------------------------------------