update dev300-m58
[ooovba.git] / canvas / source / null / null_canvashelper.cxx
blob0a8bb53901469ee1b3527c0d08b2d13545b02277
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: null_canvashelper.cxx,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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_canvas.hxx"
34 #include <canvas/debug.hxx>
35 #include <tools/diagnose_ex.h>
37 #include <rtl/logfile.hxx>
38 #include <rtl/math.hxx>
40 #include <com/sun/star/util/Endianness.hpp>
41 #include <com/sun/star/rendering/TexturingMode.hpp>
42 #include <com/sun/star/rendering/CompositeOperation.hpp>
43 #include <com/sun/star/rendering/RepaintResult.hpp>
44 #include <com/sun/star/rendering/PathCapType.hpp>
45 #include <com/sun/star/rendering/PathJoinType.hpp>
47 #include <basegfx/matrix/b2dhommatrix.hxx>
48 #include <basegfx/point/b2dpoint.hxx>
49 #include <basegfx/tools/canvastools.hxx>
51 #include <comphelper/sequence.hxx>
52 #include <canvas/canvastools.hxx>
54 #include "null_spritecanvas.hxx"
55 #include "null_canvasfont.hxx"
56 #include "null_textlayout.hxx"
57 #include "null_canvashelper.hxx"
59 #include <algorithm>
62 using namespace ::com::sun::star;
64 namespace nullcanvas
66 CanvasHelper::CanvasHelper() :
67 mpDevice( NULL ),
68 maSize(),
69 mbHaveAlpha()
73 void CanvasHelper::disposing()
75 mpDevice = NULL;
78 void CanvasHelper::init( const ::basegfx::B2ISize& rSize,
79 SpriteCanvas& rDevice,
80 bool bHasAlpha )
82 mpDevice = &rDevice;
83 maSize = rSize;
84 mbHaveAlpha = bHasAlpha;
87 void CanvasHelper::clear()
91 void CanvasHelper::drawPoint( const rendering::XCanvas* /*pCanvas*/,
92 const geometry::RealPoint2D& /*aPoint*/,
93 const rendering::ViewState& /*viewState*/,
94 const rendering::RenderState& /*renderState*/ )
98 void CanvasHelper::drawLine( const rendering::XCanvas* /*pCanvas*/,
99 const geometry::RealPoint2D& /*aPoint1*/,
100 const geometry::RealPoint2D& /*aPoint2*/,
101 const rendering::ViewState& /*viewState*/,
102 const rendering::RenderState& /*renderState*/ )
106 void CanvasHelper::drawBezier( const rendering::XCanvas* /*pCanvas*/,
107 const geometry::RealBezierSegment2D& /*aBezierSegment*/,
108 const geometry::RealPoint2D& /*aEndPoint*/,
109 const rendering::ViewState& /*viewState*/,
110 const rendering::RenderState& /*renderState*/ )
114 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawPolyPolygon( const rendering::XCanvas* /*pCanvas*/,
115 const uno::Reference< rendering::XPolyPolygon2D >& /*xPolyPolygon*/,
116 const rendering::ViewState& /*viewState*/,
117 const rendering::RenderState& /*renderState*/ )
119 // TODO(P1): Provide caching here.
120 return uno::Reference< rendering::XCachedPrimitive >(NULL);
123 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::strokePolyPolygon( const rendering::XCanvas* /*pCanvas*/,
124 const uno::Reference< rendering::XPolyPolygon2D >& /*xPolyPolygon*/,
125 const rendering::ViewState& /*viewState*/,
126 const rendering::RenderState& /*renderState*/,
127 const rendering::StrokeAttributes& /*strokeAttributes*/ )
129 // TODO(P1): Provide caching here.
130 return uno::Reference< rendering::XCachedPrimitive >(NULL);
133 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::strokeTexturedPolyPolygon( const rendering::XCanvas* /*pCanvas*/,
134 const uno::Reference< rendering::XPolyPolygon2D >& /*xPolyPolygon*/,
135 const rendering::ViewState& /*viewState*/,
136 const rendering::RenderState& /*renderState*/,
137 const uno::Sequence< rendering::Texture >& /*textures*/,
138 const rendering::StrokeAttributes& /*strokeAttributes*/ )
140 // TODO
141 return uno::Reference< rendering::XCachedPrimitive >(NULL);
144 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::strokeTextureMappedPolyPolygon( const rendering::XCanvas* /*pCanvas*/,
145 const uno::Reference< rendering::XPolyPolygon2D >& /*xPolyPolygon*/,
146 const rendering::ViewState& /*viewState*/,
147 const rendering::RenderState& /*renderState*/,
148 const uno::Sequence< rendering::Texture >& /*textures*/,
149 const uno::Reference< geometry::XMapping2D >& /*xMapping*/,
150 const rendering::StrokeAttributes& /*strokeAttributes*/ )
152 // TODO
153 return uno::Reference< rendering::XCachedPrimitive >(NULL);
156 uno::Reference< rendering::XPolyPolygon2D > CanvasHelper::queryStrokeShapes( const rendering::XCanvas* /*pCanvas*/,
157 const uno::Reference< rendering::XPolyPolygon2D >& /*xPolyPolygon*/,
158 const rendering::ViewState& /*viewState*/,
159 const rendering::RenderState& /*renderState*/,
160 const rendering::StrokeAttributes& /*strokeAttributes*/ )
162 // TODO
163 return uno::Reference< rendering::XPolyPolygon2D >(NULL);
166 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::fillPolyPolygon( const rendering::XCanvas* /*pCanvas*/,
167 const uno::Reference< rendering::XPolyPolygon2D >& /*xPolyPolygon*/,
168 const rendering::ViewState& /*viewState*/,
169 const rendering::RenderState& /*renderState*/ )
171 // TODO(P1): Provide caching here.
172 return uno::Reference< rendering::XCachedPrimitive >(NULL);
175 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::fillTexturedPolyPolygon( const rendering::XCanvas* /*pCanvas*/,
176 const uno::Reference< rendering::XPolyPolygon2D >& /*xPolyPolygon*/,
177 const rendering::ViewState& /*viewState*/,
178 const rendering::RenderState& /*renderState*/,
179 const uno::Sequence< rendering::Texture >& /*textures*/ )
181 // TODO(P1): Provide caching here.
182 return uno::Reference< rendering::XCachedPrimitive >(NULL);
185 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::fillTextureMappedPolyPolygon( const rendering::XCanvas* /*pCanvas*/,
186 const uno::Reference< rendering::XPolyPolygon2D >& /*xPolyPolygon*/,
187 const rendering::ViewState& /*viewState*/,
188 const rendering::RenderState& /*renderState*/,
189 const uno::Sequence< rendering::Texture >& /*textures*/,
190 const uno::Reference< geometry::XMapping2D >& /*xMapping*/ )
192 // TODO
193 return uno::Reference< rendering::XCachedPrimitive >(NULL);
196 uno::Reference< rendering::XCanvasFont > CanvasHelper::createFont( const rendering::XCanvas* /*pCanvas*/,
197 const rendering::FontRequest& fontRequest,
198 const uno::Sequence< beans::PropertyValue >& extraFontProperties,
199 const geometry::Matrix2D& fontMatrix )
201 return uno::Reference< rendering::XCanvasFont >(
202 new CanvasFont(fontRequest, extraFontProperties, fontMatrix ) );
205 uno::Sequence< rendering::FontInfo > CanvasHelper::queryAvailableFonts( const rendering::XCanvas* /*pCanvas*/,
206 const rendering::FontInfo& /*aFilter*/,
207 const uno::Sequence< beans::PropertyValue >& /*aFontProperties*/ )
209 // TODO
210 return uno::Sequence< rendering::FontInfo >();
213 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawText( const rendering::XCanvas* /*pCanvas*/,
214 const rendering::StringContext& /*text*/,
215 const uno::Reference< rendering::XCanvasFont >& /*xFont*/,
216 const rendering::ViewState& /*viewState*/,
217 const rendering::RenderState& /*renderState*/,
218 sal_Int8 /*textDirection*/ )
220 return uno::Reference< rendering::XCachedPrimitive >(NULL);
223 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawTextLayout( const rendering::XCanvas* /*pCanvas*/,
224 const uno::Reference< rendering::XTextLayout >& xLayoutetText,
225 const rendering::ViewState& viewState,
226 const rendering::RenderState& renderState )
228 ENSURE_OR_THROW( xLayoutetText.is(),
229 "CanvasHelper::drawTextLayout: layout is NULL");
231 TextLayout* pTextLayout =
232 dynamic_cast< TextLayout* >( xLayoutetText.get() );
234 ENSURE_OR_THROW( pTextLayout,
235 "CanvasHelper::drawTextLayout(): TextLayout not compatible with this canvas" );
237 pTextLayout->draw( viewState,
238 renderState,
239 mpDevice );
241 return uno::Reference< rendering::XCachedPrimitive >(NULL);
244 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawBitmap( const rendering::XCanvas* /*pCanvas*/,
245 const uno::Reference< rendering::XBitmap >& /*xBitmap*/,
246 const rendering::ViewState& /*viewState*/,
247 const rendering::RenderState& /*renderState*/ )
249 // TODO(P1): Provide caching here.
250 return uno::Reference< rendering::XCachedPrimitive >(NULL);
253 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawBitmapModulated( const rendering::XCanvas* /*pCanvas*/,
254 const uno::Reference< rendering::XBitmap >& /*xBitmap*/,
255 const rendering::ViewState& /*viewState*/,
256 const rendering::RenderState& /*renderState*/ )
258 // TODO(P1): Provide caching here.
259 return uno::Reference< rendering::XCachedPrimitive >(NULL);
262 uno::Reference< rendering::XGraphicDevice > CanvasHelper::getDevice()
264 return uno::Reference< rendering::XGraphicDevice >(mpDevice);
267 void CanvasHelper::copyRect( const rendering::XCanvas* /*pCanvas*/,
268 const uno::Reference< rendering::XBitmapCanvas >& /*sourceCanvas*/,
269 const geometry::RealRectangle2D& /*sourceRect*/,
270 const rendering::ViewState& /*sourceViewState*/,
271 const rendering::RenderState& /*sourceRenderState*/,
272 const geometry::RealRectangle2D& /*destRect*/,
273 const rendering::ViewState& /*destViewState*/,
274 const rendering::RenderState& /*destRenderState*/ )
276 // TODO(F2): copyRect NYI
279 geometry::IntegerSize2D CanvasHelper::getSize()
281 if( !mpDevice )
282 geometry::IntegerSize2D(1, 1); // we're disposed
284 return ::basegfx::unotools::integerSize2DFromB2ISize( maSize );
287 uno::Reference< rendering::XBitmap > CanvasHelper::getScaledBitmap( const geometry::RealSize2D& /*newSize*/,
288 sal_Bool /*beFast*/ )
290 // TODO(F1):
291 return uno::Reference< rendering::XBitmap >();
294 uno::Sequence< sal_Int8 > CanvasHelper::getData( rendering::IntegerBitmapLayout& /*bitmapLayout*/,
295 const geometry::IntegerRectangle2D& /*rect*/ )
297 // TODO
298 return uno::Sequence< sal_Int8 >();
301 void CanvasHelper::setData( const uno::Sequence< sal_Int8 >& /*data*/,
302 const rendering::IntegerBitmapLayout& /*bitmapLayout*/,
303 const geometry::IntegerRectangle2D& /*rect*/ )
307 void CanvasHelper::setPixel( const uno::Sequence< sal_Int8 >& /*color*/,
308 const rendering::IntegerBitmapLayout& /*bitmapLayout*/,
309 const geometry::IntegerPoint2D& /*pos*/ )
313 uno::Sequence< sal_Int8 > CanvasHelper::getPixel( rendering::IntegerBitmapLayout& /*bitmapLayout*/,
314 const geometry::IntegerPoint2D& /*pos*/ )
316 return uno::Sequence< sal_Int8 >();
319 uno::Reference< rendering::XBitmapPalette > CanvasHelper::getPalette()
321 // TODO(F1): Palette bitmaps NYI
322 return uno::Reference< rendering::XBitmapPalette >();
325 rendering::IntegerBitmapLayout CanvasHelper::getMemoryLayout()
327 return ::canvas::tools::getStdMemoryLayout(getSize());
330 void CanvasHelper::flush() const
334 bool CanvasHelper::hasAlpha() const
336 return mbHaveAlpha;