CWS-TOOLING: integrate CWS os146
[LibreOffice.git] / canvas / source / null / null_canvashelper.cxx
blob21e2c74f6b9513e6decfd6c1dd3546934cd8c411
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 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_canvas.hxx"
31 #include <canvas/debug.hxx>
32 #include <tools/diagnose_ex.h>
34 #include <rtl/logfile.hxx>
35 #include <rtl/math.hxx>
37 #include <com/sun/star/util/Endianness.hpp>
38 #include <com/sun/star/rendering/TexturingMode.hpp>
39 #include <com/sun/star/rendering/CompositeOperation.hpp>
40 #include <com/sun/star/rendering/RepaintResult.hpp>
41 #include <com/sun/star/rendering/PathCapType.hpp>
42 #include <com/sun/star/rendering/PathJoinType.hpp>
44 #include <basegfx/matrix/b2dhommatrix.hxx>
45 #include <basegfx/point/b2dpoint.hxx>
46 #include <basegfx/tools/canvastools.hxx>
48 #include <comphelper/sequence.hxx>
49 #include <canvas/canvastools.hxx>
51 #include "null_spritecanvas.hxx"
52 #include "null_canvasfont.hxx"
53 #include "null_textlayout.hxx"
54 #include "null_canvashelper.hxx"
56 #include <algorithm>
59 using namespace ::com::sun::star;
61 namespace nullcanvas
63 CanvasHelper::CanvasHelper() :
64 mpDevice( NULL ),
65 maSize(),
66 mbHaveAlpha()
70 void CanvasHelper::disposing()
72 mpDevice = NULL;
75 void CanvasHelper::init( const ::basegfx::B2ISize& rSize,
76 SpriteCanvas& rDevice,
77 bool bHasAlpha )
79 mpDevice = &rDevice;
80 maSize = rSize;
81 mbHaveAlpha = bHasAlpha;
84 void CanvasHelper::clear()
88 void CanvasHelper::drawPoint( const rendering::XCanvas* /*pCanvas*/,
89 const geometry::RealPoint2D& /*aPoint*/,
90 const rendering::ViewState& /*viewState*/,
91 const rendering::RenderState& /*renderState*/ )
95 void CanvasHelper::drawLine( const rendering::XCanvas* /*pCanvas*/,
96 const geometry::RealPoint2D& /*aPoint1*/,
97 const geometry::RealPoint2D& /*aPoint2*/,
98 const rendering::ViewState& /*viewState*/,
99 const rendering::RenderState& /*renderState*/ )
103 void CanvasHelper::drawBezier( const rendering::XCanvas* /*pCanvas*/,
104 const geometry::RealBezierSegment2D& /*aBezierSegment*/,
105 const geometry::RealPoint2D& /*aEndPoint*/,
106 const rendering::ViewState& /*viewState*/,
107 const rendering::RenderState& /*renderState*/ )
111 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawPolyPolygon( const rendering::XCanvas* /*pCanvas*/,
112 const uno::Reference< rendering::XPolyPolygon2D >& /*xPolyPolygon*/,
113 const rendering::ViewState& /*viewState*/,
114 const rendering::RenderState& /*renderState*/ )
116 // TODO(P1): Provide caching here.
117 return uno::Reference< rendering::XCachedPrimitive >(NULL);
120 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::strokePolyPolygon( const rendering::XCanvas* /*pCanvas*/,
121 const uno::Reference< rendering::XPolyPolygon2D >& /*xPolyPolygon*/,
122 const rendering::ViewState& /*viewState*/,
123 const rendering::RenderState& /*renderState*/,
124 const rendering::StrokeAttributes& /*strokeAttributes*/ )
126 // TODO(P1): Provide caching here.
127 return uno::Reference< rendering::XCachedPrimitive >(NULL);
130 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::strokeTexturedPolyPolygon( const rendering::XCanvas* /*pCanvas*/,
131 const uno::Reference< rendering::XPolyPolygon2D >& /*xPolyPolygon*/,
132 const rendering::ViewState& /*viewState*/,
133 const rendering::RenderState& /*renderState*/,
134 const uno::Sequence< rendering::Texture >& /*textures*/,
135 const rendering::StrokeAttributes& /*strokeAttributes*/ )
137 // TODO
138 return uno::Reference< rendering::XCachedPrimitive >(NULL);
141 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::strokeTextureMappedPolyPolygon( const rendering::XCanvas* /*pCanvas*/,
142 const uno::Reference< rendering::XPolyPolygon2D >& /*xPolyPolygon*/,
143 const rendering::ViewState& /*viewState*/,
144 const rendering::RenderState& /*renderState*/,
145 const uno::Sequence< rendering::Texture >& /*textures*/,
146 const uno::Reference< geometry::XMapping2D >& /*xMapping*/,
147 const rendering::StrokeAttributes& /*strokeAttributes*/ )
149 // TODO
150 return uno::Reference< rendering::XCachedPrimitive >(NULL);
153 uno::Reference< rendering::XPolyPolygon2D > CanvasHelper::queryStrokeShapes( const rendering::XCanvas* /*pCanvas*/,
154 const uno::Reference< rendering::XPolyPolygon2D >& /*xPolyPolygon*/,
155 const rendering::ViewState& /*viewState*/,
156 const rendering::RenderState& /*renderState*/,
157 const rendering::StrokeAttributes& /*strokeAttributes*/ )
159 // TODO
160 return uno::Reference< rendering::XPolyPolygon2D >(NULL);
163 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::fillPolyPolygon( const rendering::XCanvas* /*pCanvas*/,
164 const uno::Reference< rendering::XPolyPolygon2D >& /*xPolyPolygon*/,
165 const rendering::ViewState& /*viewState*/,
166 const rendering::RenderState& /*renderState*/ )
168 // TODO(P1): Provide caching here.
169 return uno::Reference< rendering::XCachedPrimitive >(NULL);
172 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::fillTexturedPolyPolygon( const rendering::XCanvas* /*pCanvas*/,
173 const uno::Reference< rendering::XPolyPolygon2D >& /*xPolyPolygon*/,
174 const rendering::ViewState& /*viewState*/,
175 const rendering::RenderState& /*renderState*/,
176 const uno::Sequence< rendering::Texture >& /*textures*/ )
178 // TODO(P1): Provide caching here.
179 return uno::Reference< rendering::XCachedPrimitive >(NULL);
182 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::fillTextureMappedPolyPolygon( const rendering::XCanvas* /*pCanvas*/,
183 const uno::Reference< rendering::XPolyPolygon2D >& /*xPolyPolygon*/,
184 const rendering::ViewState& /*viewState*/,
185 const rendering::RenderState& /*renderState*/,
186 const uno::Sequence< rendering::Texture >& /*textures*/,
187 const uno::Reference< geometry::XMapping2D >& /*xMapping*/ )
189 // TODO
190 return uno::Reference< rendering::XCachedPrimitive >(NULL);
193 uno::Reference< rendering::XCanvasFont > CanvasHelper::createFont( const rendering::XCanvas* /*pCanvas*/,
194 const rendering::FontRequest& fontRequest,
195 const uno::Sequence< beans::PropertyValue >& extraFontProperties,
196 const geometry::Matrix2D& fontMatrix )
198 return uno::Reference< rendering::XCanvasFont >(
199 new CanvasFont(fontRequest, extraFontProperties, fontMatrix ) );
202 uno::Sequence< rendering::FontInfo > CanvasHelper::queryAvailableFonts( const rendering::XCanvas* /*pCanvas*/,
203 const rendering::FontInfo& /*aFilter*/,
204 const uno::Sequence< beans::PropertyValue >& /*aFontProperties*/ )
206 // TODO
207 return uno::Sequence< rendering::FontInfo >();
210 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawText( const rendering::XCanvas* /*pCanvas*/,
211 const rendering::StringContext& /*text*/,
212 const uno::Reference< rendering::XCanvasFont >& /*xFont*/,
213 const rendering::ViewState& /*viewState*/,
214 const rendering::RenderState& /*renderState*/,
215 sal_Int8 /*textDirection*/ )
217 return uno::Reference< rendering::XCachedPrimitive >(NULL);
220 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawTextLayout( const rendering::XCanvas* /*pCanvas*/,
221 const uno::Reference< rendering::XTextLayout >& xLayoutetText,
222 const rendering::ViewState& viewState,
223 const rendering::RenderState& renderState )
225 ENSURE_OR_THROW( xLayoutetText.is(),
226 "CanvasHelper::drawTextLayout: layout is NULL");
228 TextLayout* pTextLayout =
229 dynamic_cast< TextLayout* >( xLayoutetText.get() );
231 ENSURE_OR_THROW( pTextLayout,
232 "CanvasHelper::drawTextLayout(): TextLayout not compatible with this canvas" );
234 pTextLayout->draw( viewState,
235 renderState,
236 mpDevice );
238 return uno::Reference< rendering::XCachedPrimitive >(NULL);
241 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawBitmap( const rendering::XCanvas* /*pCanvas*/,
242 const uno::Reference< rendering::XBitmap >& /*xBitmap*/,
243 const rendering::ViewState& /*viewState*/,
244 const rendering::RenderState& /*renderState*/ )
246 // TODO(P1): Provide caching here.
247 return uno::Reference< rendering::XCachedPrimitive >(NULL);
250 uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawBitmapModulated( const rendering::XCanvas* /*pCanvas*/,
251 const uno::Reference< rendering::XBitmap >& /*xBitmap*/,
252 const rendering::ViewState& /*viewState*/,
253 const rendering::RenderState& /*renderState*/ )
255 // TODO(P1): Provide caching here.
256 return uno::Reference< rendering::XCachedPrimitive >(NULL);
259 uno::Reference< rendering::XGraphicDevice > CanvasHelper::getDevice()
261 return uno::Reference< rendering::XGraphicDevice >(mpDevice);
264 void CanvasHelper::copyRect( const rendering::XCanvas* /*pCanvas*/,
265 const uno::Reference< rendering::XBitmapCanvas >& /*sourceCanvas*/,
266 const geometry::RealRectangle2D& /*sourceRect*/,
267 const rendering::ViewState& /*sourceViewState*/,
268 const rendering::RenderState& /*sourceRenderState*/,
269 const geometry::RealRectangle2D& /*destRect*/,
270 const rendering::ViewState& /*destViewState*/,
271 const rendering::RenderState& /*destRenderState*/ )
273 // TODO(F2): copyRect NYI
276 geometry::IntegerSize2D CanvasHelper::getSize()
278 if( !mpDevice )
279 geometry::IntegerSize2D(1, 1); // we're disposed
281 return ::basegfx::unotools::integerSize2DFromB2ISize( maSize );
284 uno::Reference< rendering::XBitmap > CanvasHelper::getScaledBitmap( const geometry::RealSize2D& /*newSize*/,
285 sal_Bool /*beFast*/ )
287 // TODO(F1):
288 return uno::Reference< rendering::XBitmap >();
291 uno::Sequence< sal_Int8 > CanvasHelper::getData( rendering::IntegerBitmapLayout& /*bitmapLayout*/,
292 const geometry::IntegerRectangle2D& /*rect*/ )
294 // TODO
295 return uno::Sequence< sal_Int8 >();
298 void CanvasHelper::setData( const uno::Sequence< sal_Int8 >& /*data*/,
299 const rendering::IntegerBitmapLayout& /*bitmapLayout*/,
300 const geometry::IntegerRectangle2D& /*rect*/ )
304 void CanvasHelper::setPixel( const uno::Sequence< sal_Int8 >& /*color*/,
305 const rendering::IntegerBitmapLayout& /*bitmapLayout*/,
306 const geometry::IntegerPoint2D& /*pos*/ )
310 uno::Sequence< sal_Int8 > CanvasHelper::getPixel( rendering::IntegerBitmapLayout& /*bitmapLayout*/,
311 const geometry::IntegerPoint2D& /*pos*/ )
313 return uno::Sequence< sal_Int8 >();
316 uno::Reference< rendering::XBitmapPalette > CanvasHelper::getPalette()
318 // TODO(F1): Palette bitmaps NYI
319 return uno::Reference< rendering::XBitmapPalette >();
322 rendering::IntegerBitmapLayout CanvasHelper::getMemoryLayout()
324 return ::canvas::tools::getStdMemoryLayout(getSize());
327 void CanvasHelper::flush() const
331 bool CanvasHelper::hasAlpha() const
333 return mbHaveAlpha;