Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / offapi / com / sun / star / rendering / XCanvas.idl
blob28e2a8fe232efa4f39fbe9ae497fe73a8b2ece8d
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 .
19 #ifndef __com_sun_star_rendering_XCanvas_idl__
20 #define __com_sun_star_rendering_XCanvas_idl__
22 #include <com/sun/star/uno/XInterface.idl>
23 #include <com/sun/star/lang/IllegalArgumentException.idl>
24 #include <com/sun/star/geometry/RealPoint2D.idl>
25 #include <com/sun/star/geometry/RealBezierSegment2D.idl>
26 #include <com/sun/star/geometry/RealRectangle2D.idl>
27 #include <com/sun/star/geometry/Matrix2D.idl>
28 #include <com/sun/star/rendering/ViewState.idl>
29 #include <com/sun/star/rendering/RenderState.idl>
30 #include <com/sun/star/rendering/FontRequest.idl>
31 #include <com/sun/star/rendering/FontInfo.idl>
32 #include <com/sun/star/rendering/Texture.idl>
33 #include <com/sun/star/rendering/StringContext.idl>
34 #include <com/sun/star/rendering/StrokeAttributes.idl>
35 #include <com/sun/star/rendering/VolatileContentDestroyedException.idl>
36 #include <com/sun/star/beans/PropertyValue.idl>
39 module com { module sun { module star { module geometry {
40 interface XMapping2D;
41 }; }; }; };
43 module com { module sun { module star { module rendering {
45 interface XCanvasFont;
46 interface XPolyPolygon2D;
47 interface XCachedPrimitive;
48 interface XBitmap;
49 interface XGraphicDevice;
50 interface XTextLayout;
52 /** Central interface for rendering.<p>
54 This is the central interface for graphical output production, and
55 the place where all draw methods are located.<p>
57 Some notes are in order to explain the concepts used here. The
58 XCanvas interface is free of client-modifiable state,
59 i.e. it can be used safely and without external synchronization in
60 a multi-threaded environment. On the other hand, this implies that
61 for nearly every canvas operation, external state is
62 required. This is provided by ViewState and
63 RenderState in a unified fashion, supplemented by a
64 few extra state parameters for some methods (e.g. textured
65 polygons or text rendering).<p>
67 When used careless, this scheme can be inefficient to some extend,
68 because internally, view, render and other states have to be
69 combined before rendering. This is especially expensive for
70 complex clip polygons, i.e. when both ViewState and
71 RenderState have a complex clip polygon set, which
72 have to be intersected before rendering. It is therefore
73 recommended to combine ViewState and
74 RenderState already at the client side, when objects
75 are organized in a hierarchical way: the classic example are
76 grouped draw shapes, whose parent group object imposes a
77 common clipping and a common transformation on its siblings. The
78 group object would therefore merge the ViewState and
79 the RenderState it is called with into a new
80 ViewState, and call its siblings with a
81 RenderState containing only the local offset (and no
82 extra clipping).<p>
84 Further on, this stateless nature provides easy ways for
85 caching. Every non-trivial operation on XCanvas can
86 return a cache object, which, when called to redraw, renders the
87 primitive usually much more quickly than the original method. Note
88 that such caching is a lot more complicated, should the actual
89 rendering a method yields depend on internal state (which is the
90 case e.g. for the
91 ::com::sun::star::awt::XGraphics
92 interface). Please note, though, that deciding whether to return
93 an XCachedPrimitive is completely up to the
94 implementation - don't rely on the methods returning something
95 (this is because there might be cases when returning such a cache
96 object will actually be a pessimization, since it involves memory
97 allocation and comparisons).<p>
99 Things that need more than a small, fixed amount of data are
100 encapsulated in own interfaces, e.g. polygons and bitmaps. You
101 can, in principle, roll your own implementations of these
102 interfaces, wrap it around your internal representation of
103 polygons and bitmaps, and render them. It might just not be overly
104 fast, because the XCanvas would need to convert for
105 each render call. It is therefore recommended to create such
106 objects via the XGraphicDevice factory (to be
107 retrieved from every canvas object via the
108 getDevice() call) - they will then internally
109 optimize to the underlying graphics subsystem.<p>
111 @since OOo 2.0
113 interface XCanvas : ::com::sun::star::uno::XInterface
115 /** Clear the whole canvas area.<p>
117 This method clears the whole canvas area to the device default
118 color (e.g. white for a printer, transparent for an
119 XCustomSprite).
121 void clear();
123 /** Draw a point in device resolution on the device.
125 @param aPoint
126 The point to draw.
128 @param aViewState
129 The view state to be used when drawing this point.
131 @param aRenderState
132 The render state to be used when drawing this point.
134 @throws com::sun::star::lang::IllegalArgumentException
135 if one of the view and render state parameters are outside the
136 specified range.
138 void drawPoint( [in] ::com::sun::star::geometry::RealPoint2D aPoint, [in] ViewState aViewState, [in] RenderState aRenderState )
139 raises (com::sun::star::lang::IllegalArgumentException);
142 /** Draw a line in device resolution width (i.e. one device pixel
143 wide).
145 @param aStartPoint
146 The start point of the line to draw.
148 @param aEndPoint
149 The end point of the line to draw.
151 @param aViewState
152 The view state to be used when drawing this line.
154 @param aRenderState
155 The render state to be used when drawing this line.
157 @throws com::sun::star::lang::IllegalArgumentException
158 if one of the view and render state parameters are outside the
159 specified range.
161 void drawLine( [in] ::com::sun::star::geometry::RealPoint2D aStartPoint, [in] ::com::sun::star::geometry::RealPoint2D aEndPoint, [in] ViewState aViewState, [in] RenderState aRenderState )
162 raises (com::sun::star::lang::IllegalArgumentException);
165 /** Draw a cubic Bezier curve in device resolution width (i.e. one
166 device pixel wide).
168 @param aBezierSegment
169 The start and the two control points of the Bezier curve.
171 @param aEndPoint
172 The end point of the Bezier curve.
174 @param aViewState
175 The view state to be used when drawing this curve.
177 @param aRenderState
178 The render state to be used when drawing this curve.
180 @throws com::sun::star::lang::IllegalArgumentException
181 if one of the view and render state parameters are outside the
182 specified range.
184 void drawBezier( [in] ::com::sun::star::geometry::RealBezierSegment2D aBezierSegment, [in] ::com::sun::star::geometry::RealPoint2D aEndPoint, [in] ViewState aViewState, [in] RenderState aRenderState )
185 raises (com::sun::star::lang::IllegalArgumentException);
188 /** Draw a poly-polygon in device resolution line width (i.e. the
189 lines are one device pixel wide).
191 @param xPolyPolygon
192 The poly-polygon to draw.
194 @param aViewState
195 The view state to be used when drawing this polygon.
197 @param aRenderState
198 The render state to be used when drawing this polygon.
200 @return a handle to the cached rendering output.
202 @throws com::sun::star::lang::IllegalArgumentException
203 if one of the view and render state parameters are outside the
204 specified range.
206 XCachedPrimitive drawPolyPolygon( [in] XPolyPolygon2D xPolyPolygon, [in] ViewState aViewState, [in] RenderState aRenderState )
207 raises (com::sun::star::lang::IllegalArgumentException);
210 /** Stroke each polygon of the provided poly-polygon with the
211 specified stroke attributes.<p>
213 This method considers the stroking of all polygons as an
214 atomic operation in relation to the RenderState's
215 CompositeOperationy operation. That means,
216 overlapping strokes from distinct polygons will look exactly
217 as overlapping segments of the same polygon, even with
218 transparency.<p>
220 @param xPolyPolygon
221 The poly-polygon to render.
223 @param aViewState
224 The view state to be used when stroking this polygon.
226 @param aRenderState
227 The render state to be used when stroking this polygon.
229 @param aStrokeAttributes
230 Further attributes used to parameterize the stroking.
232 @return a handle to the cached rendering output.
234 @throws com::sun::star::lang::IllegalArgumentException
235 if one of the view and render state parameters are outside the
236 specified range.
238 XCachedPrimitive strokePolyPolygon( [in] XPolyPolygon2D xPolyPolygon, [in] ViewState aViewState, [in] RenderState aRenderState, [in] StrokeAttributes aStrokeAttributes )
239 raises (com::sun::star::lang::IllegalArgumentException);
242 /** Stroke each polygon of the provided poly-polygon with the
243 specified stroke attributes, fill the stroked outline
244 with the specified texture graphics.<p>
246 This method considers the stroking of all polygons as an
247 atomic operation in relation to the RenderState's
248 CompositeOp operation. That means, overlapping
249 strokes from distinct polygons will look exactly as
250 overlapping segments of the same polygon, even with
251 transparency.<p>
253 @param xPolyPolygon
254 The poly-polygon to render.
256 @param aViewState
257 The view state to be used when strokes this polygon.
259 @param aRenderState
260 The render state to be used when stroking this polygon.
262 @param aTextures
263 A sequence of texture definitions, with which to fill the
264 stroked area.
266 @param aStrokeAttributes
267 Further attributes used to parameterize the stroking.
269 @return a handle to the cached rendering output.
271 @throws com::sun::star::lang::IllegalArgumentException
272 if one of the view and render state parameters are outside the
273 specified range.
275 @throws VolatileContentDestroyedException
276 if a texture bitmap was volatile, and the content was
277 destroyed before the rendering could take place.
279 XCachedPrimitive strokeTexturedPolyPolygon( [in] XPolyPolygon2D xPolyPolygon, [in] ViewState aViewState, [in] RenderState aRenderState, [in] sequence<Texture> aTextures, [in] StrokeAttributes aStrokeAttributes )
280 raises (com::sun::star::lang::IllegalArgumentException,
281 VolatileContentDestroyedException);
284 /** Stroke each polygon of the provided poly-polygon with the
285 specified stroke attributes, fill the stroked outline
286 with the specified texture graphics, map the texture to the
287 outline via the specified texture mapping.<p>
289 This method considers the stroking of all polygons as an
290 atomic operation in relation to the RenderState's
291 CompositeOp operation. That means, overlapping
292 strokes from distinct polygons will look exactly as
293 overlapping segments of the same polygon, even with
294 transparency.
296 @param xPolyPolygon
297 The poly-polygon to render.
299 @param aViewState
300 The view state to be used when stroking this polygon.
302 @param aRenderState
303 The render state to be used when stroking this polygon.
305 @param aTextures
306 A sequence of texture definitions, with which to fill the
307 stroked area.
309 @param xMapping
310 A bilinear mapping function which defines the warping of the
311 textures on the output area.
313 @param aStrokeAttributes
314 Further attributes used to parameterize the stroking.
316 @return a handle to the cached rendering output.
318 @throws com::sun::star::lang::IllegalArgumentException
319 if one of the view and render state parameters are outside the
320 specified range.
322 @throws VolatileContentDestroyedException
323 if a texture bitmap was volatile, and the content was
324 destroyed before the rendering could take place.
326 XCachedPrimitive strokeTextureMappedPolyPolygon( [in] XPolyPolygon2D xPolyPolygon, [in] ViewState aViewState, [in] RenderState aRenderState, [in] sequence<Texture> aTextures, [in] ::com::sun::star::geometry::XMapping2D xMapping, [in] StrokeAttributes aStrokeAttributes )
327 raises (com::sun::star::lang::IllegalArgumentException,
328 VolatileContentDestroyedException);
331 // [TODO: Method misplaced at this interface?]
333 /** Query the polygonal representation of the stroke outlines, as
334 it would be generated by the strokePolyPolygon methods.<p>
336 This method can be used to e.g. set a clipping which covers the same
337 area as a stroke.<p>
339 @param xPolyPolygon
340 The poly-polygon to render.
342 @param aViewState
343 The view state to be used when generating the outline.
345 @param aRenderState
346 The render state to be used when generating the outline.
348 @param aStrokeAttributes
349 Further attributes used to parameterize the stroking.
351 @return a poly-polygon describing the outline of the stroked
352 area.
354 @throws com::sun::star::lang::IllegalArgumentException
355 if one of the view and render state parameters are outside the
356 specified range.
358 XPolyPolygon2D queryStrokeShapes( [in] XPolyPolygon2D xPolyPolygon, [in] ViewState aViewState, [in] RenderState aRenderState, [in] StrokeAttributes aStrokeAttributes )
359 raises (com::sun::star::lang::IllegalArgumentException);
362 /** Fill the given poly-polygon.<p>
364 This method fills the given poly-polygon according to the
365 RenderState's color and the poly-polygon's fill
366 rule.<p>
368 @param xPolyPolygon
369 The poly-polygon to render.
371 @param aViewState
372 The view state to be used when filling this polygon.
374 @param aRenderState
375 The render state to be used when filling this polygon.
377 @return a handle to the cached rendering output.
379 @throws com::sun::star::lang::IllegalArgumentException
380 if one of the view and render state parameters are outside the
381 specified range.
383 XCachedPrimitive fillPolyPolygon( [in] XPolyPolygon2D xPolyPolygon, [in] ViewState aViewState, [in] RenderState aRenderState )
384 raises (com::sun::star::lang::IllegalArgumentException);
387 /** Fill the given poly-polygon with a texture.<p>
389 This method fills the given poly-polygon according to the
390 RenderState's color, the given textures and
391 poly-polygon's fill rule.<p>
393 @param xPolyPolygon
394 The poly-polygon to render.
396 @param aViewState
397 The view state to be used when filling this polygon.
399 @param aRenderState
400 The render state to be used when filling this polygon.
402 @param xTextures
403 A sequence of texture definitions, with which to fill the
404 polygonal area.
406 @return a handle to the cached rendering output.
408 @throws com::sun::star::lang::IllegalArgumentException
409 if one of the view and render state parameters are outside the
410 specified range.
412 @throws VolatileContentDestroyedException
413 if a texture bitmap was volatile, and the content was
414 destroyed before the rendering could take place.
416 XCachedPrimitive fillTexturedPolyPolygon( [in] XPolyPolygon2D xPolyPolygon, [in] ViewState aViewState, [in] RenderState aRenderState, [in] sequence<Texture> xTextures )
417 raises (com::sun::star::lang::IllegalArgumentException,
418 VolatileContentDestroyedException);
421 /** Fill the given poly-polygon with a mapped texture.<p>
423 This method fills the given poly-polygon according to the
424 RenderState's color, the given textures and
425 poly-polygon's fill rule. The texture is mapped to the
426 poly-polygon's interior via the given texture mapping.<p>
428 @param xPolyPolygon
429 The poly-polygon to render.
431 @param aViewState
432 The view state to be used when filling this polygon.
434 @param aRenderState
435 The render state to be used when filling this polygon.
437 @param xTextures
438 A sequence of texture definitions, with which to fill the
439 polygonal area.
441 @param xMapping
442 A bilinear mapping function which defines the warping of the
443 textures on the output area.
445 @return a handle to the cached rendering output.
447 @throws com::sun::star::lang::IllegalArgumentException
448 if one of the view and render state parameters are outside the
449 specified range.
451 @throws VolatileContentDestroyedException
452 if a texture bitmap was volatile, and the content was
453 destroyed before the rendering could take place.
455 XCachedPrimitive fillTextureMappedPolyPolygon( [in] XPolyPolygon2D xPolyPolygon, [in] ViewState aViewState, [in] RenderState aRenderState, [in] sequence<Texture> xTextures, [in] ::com::sun::star::geometry::XMapping2D xMapping )
456 raises (com::sun::star::lang::IllegalArgumentException,
457 VolatileContentDestroyedException);
460 /** Create a suitable font for the specified font description.
462 @param aFontRequest
464 @param aExtraFontProperties
465 Additional font properties to be applied when selecting this
466 font. Normally, you should not need this parameter. Currently,
467 the following properties are recognized:
469 - Kerning: a double between 0 and 1, where
470 0 completely disables kerning. Whether kerning is on or
471 off by default is font-dependent.
473 - IsEmphasisMarks: a boolean, where `TRUE`
474 enables automatic placements of emphasis marks, e.g. for
475 Hebrew. The default value, if this property is not
476 specified, is `FALSE`.
478 - ExpandedSpacing: a double value which is added
479 between all cell distances for this font. The default value for
480 this property is zero. Use negative values for condensed output,
481 and positive values for expanded output.
483 - OptionalLayoutFeatures: a sequence of
484 ::com::sun::star::beans::PropertyValue listing
485 font-specific optional layout features, like glyph
486 variants.
488 @param aFontMatrix
489 Font-specific transformation matrix, which affects both the
490 glyphs as well as the advancement.
492 @returns the requested font, or an invalid reference, if the
493 request failed.
495 @throws com::sun::star::lang::IllegalArgumentException
496 if one of the parameters is not within the allowed range.
498 XCanvasFont createFont( [in] FontRequest aFontRequest, [in] sequence< ::com::sun::star::beans::PropertyValue > aExtraFontProperties, [in] ::com::sun::star::geometry::Matrix2D aFontMatrix )
499 raises (com::sun::star::lang::IllegalArgumentException);
502 /** Query font information, specific to this canvas.<p>
504 @param aFilter
505 Filter parameter to reduce the list of returned fonts. Every
506 member of FontInfo that is not the empty string
507 or the "don't care" value restricts the list of returned fonts
508 to contain only those that have the specified attribute.
510 @param aFontProperties
511 This interface can provide additional font properties to
512 filter the list of available fonts against.
514 @returns the list of fonts matching the filter set.
516 @throws com::sun::star::lang::IllegalArgumentException
517 if one of the font properties are invalid or not recognized,
518 or if one of the FontInfo members is not within
519 the permitted range.
521 sequence< FontInfo > queryAvailableFonts( [in] FontInfo aFilter, [in] sequence< ::com::sun::star::beans::PropertyValue > aFontProperties )
522 raises (com::sun::star::lang::IllegalArgumentException);
525 /** Draw the text given by the substring of the specified string
526 with the given font.<p>
528 The local origin of this output operation is either the left
529 end of the text baseline, for textDirection equal
530 LEFT_TO_RIGHT, or the right end of the baseline, for
531 textDirection equal to RIGHT_TO_LEFT, respectively.<p>
533 @param aText
534 The text to output.
536 @param xFont
537 The font retrieved from this canvas to be used when drawing
538 the text.
540 @param aViewState
541 The view state to be used when drawing this text.
543 @param aRenderState
544 The render state to be used when drawing this text.
546 @param nTextDirection
547 A value from the TextDirection collection,
548 denoting the main writing direction for this string. The main
549 writing direction determines the origin of the text output,
550 i.e. the left edge for left-to-right and the right edge for
551 right-to-left text.
553 @return a handle to the cached rendering output.
555 @throws com::sun::star::lang::IllegalArgumentException
556 if one of the view and render state parameters are outside the
557 specified range.
559 XCachedPrimitive drawText( [in] StringContext aText, [in] XCanvasFont xFont, [in] ViewState aViewState, [in] RenderState aRenderState, [in] byte nTextDirection )
560 raises (com::sun::star::lang::IllegalArgumentException);
563 /** Draw the formatted text given by the text layout.<p>
565 The glyphs as represented by the text layout are always output
566 with the reference position being the leftmost edge of the
567 layout object's baseline. If the layout contains more than one
568 baseline, the baseline of the first strong character in
569 logical order is used here (strong in this context means that
570 the character can be unambiguously assigned to a Unicode
571 script).<p>
573 @param xLayoutetText
574 An interface to the readily layouted text, obtained from a
575 XCanvasFont created at this canvas. The text
576 layout already carries intrinsic font information.
578 @param aViewState
579 The view state to be used when drawing this text.
581 @param aRenderState
582 The render state to be used when drawing this text.
584 @return a handle to the cached rendering output.
586 @throws com::sun::star::lang::IllegalArgumentException
587 if one of the view and render state parameters are outside the
588 specified range.
590 XCachedPrimitive drawTextLayout( [in] XTextLayout xLayoutetText, [in] ViewState aViewState, [in] RenderState aRenderState )
591 raises (com::sun::star::lang::IllegalArgumentException);
594 /** Render the given bitmap.<p>
596 This method renders the bitmap, at a position and shape as
597 specified by the combined view and render transformations. For
598 fast render speed, the bitmap should be created by the
599 corresponding XGraphicDevice's
600 XGraphicDevice::createCompatibleBitmap()
601 method.<p>
603 @param xBitmap
604 The bitmap to render.
606 @param aViewState
607 The view state to be used when drawing this text.
609 @param aRenderState
610 The render state to be used when drawing this text.
612 @return a handle to the cached rendering output.
614 @throws com::sun::star::lang::IllegalArgumentException
615 if one of the view and render state parameters are outside the
616 specified range.
618 @throws VolatileContentDestroyedException
619 if a texture bitmap was volatile, and the content was
620 destroyed before the rendering could take place.
622 XCachedPrimitive drawBitmap( [in] XBitmap xBitmap, [in] ViewState aViewState, [in] RenderState aRenderState )
623 raises (com::sun::star::lang::IllegalArgumentException,
624 VolatileContentDestroyedException);
626 /** Render the given bitmap, with a global color modulation.<p>
628 This method renders the bitmap, at a position and shape as
629 specified by the combined view and render transformations. For
630 fast render speed, the bitmap should be created by the
631 corresponding XGraphicDevice's
632 XGraphicDevice::createCompatibleBitmap()
633 method. The bitmap's color channel values are multiplied with
634 the device color values as specified in the render state.<p>
636 @param xBitmap
637 The bitmap to render.
639 @param aViewState
640 The view state to be used when drawing this text.
642 @param aRenderState
643 The render state to be used when drawing this text. The device
644 color entry in the render state is multiplied with every pixel
645 color value, and only the result is rendered into the
646 canvas. If, for example, the bitmap should be rendered with
647 increased global transparency, set all device color channels
648 to 1.0, except for the alpha channel, which should be set to
649 the desired transparency.
651 @return a handle to the cached rendering output.
653 @throws com::sun::star::lang::IllegalArgumentException
654 if one of the view and render state parameters are outside the
655 specified range.
657 @throws VolatileContentDestroyedException
658 if a texture bitmap was volatile, and the content was
659 destroyed before the rendering could take place.
661 XCachedPrimitive drawBitmapModulated( [in] XBitmap xBitmap, [in] ViewState aViewState, [in] RenderState aRenderState )
662 raises (com::sun::star::lang::IllegalArgumentException,
663 VolatileContentDestroyedException);
666 /** Request the associated graphic device for this canvas.<p>
668 A graphic device provides methods specific to the underlying
669 output device capabilities, which are common for all canvases
670 rendering to such a device. This includes device resolution,
671 color space, or bitmap formats.
673 @return the associated XGraphicDevice.
675 XGraphicDevice getDevice();
678 }; }; }; };
680 #endif
682 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */