1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 #ifndef _DXCANVAS_BITMAPCANVASHELPER_HXX_ 29 #define _DXCANVAS_BITMAPCANVASHELPER_HXX_ 30 31 #include <com/sun/star/rendering/XCanvas.hpp> 32 33 #include <basegfx/vector/b2isize.hxx> 34 #include <basegfx/vector/b2dsize.hxx> 35 36 #include "dx_graphicsprovider.hxx" 37 #include "dx_ibitmap.hxx" 38 #include "dx_gdiplususer.hxx" 39 #include "dx_impltools.hxx" 40 #include "dx_canvashelper.hxx" 41 42 #include <boost/utility.hpp> 43 44 45 namespace dxcanvas 46 { 47 /** Helper class for basic canvas functionality. Also offers 48 optional backbuffer painting, when providing it with a second 49 HDC to render into. 50 */ 51 class BitmapCanvasHelper : public CanvasHelper 52 { 53 public: 54 BitmapCanvasHelper(); 55 56 /// Release all references 57 void disposing(); 58 59 /** Set the target for rendering operations 60 61 @param rTarget 62 Render target 63 */ 64 void setTarget( const IBitmapSharedPtr& rTarget ); 65 66 /** Set the target for rendering operations 67 68 @param rTarget 69 Render target 70 71 @param rOutputOffset 72 Output offset in pixel 73 */ 74 void setTarget( const IBitmapSharedPtr& rTarget, 75 const ::basegfx::B2ISize& rOutputOffset ); 76 77 78 // CanvasHelper functionality is implementation-inherited. yuck. 79 // ============================================================= 80 void clear(); 81 82 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > 83 drawTextLayout( const ::com::sun::star::rendering::XCanvas* pCanvas, 84 const ::com::sun::star::uno::Reference< 85 ::com::sun::star::rendering::XTextLayout >& layoutetText, 86 const ::com::sun::star::rendering::ViewState& viewState, 87 const ::com::sun::star::rendering::RenderState& renderState ); 88 89 // BitmapCanvasHelper functionality 90 // ================================ 91 92 void copyRect( const ::com::sun::star::rendering::XCanvas* pCanvas, 93 const ::com::sun::star::uno::Reference< 94 ::com::sun::star::rendering::XBitmapCanvas >& sourceCanvas, 95 const ::com::sun::star::geometry::RealRectangle2D& sourceRect, 96 const ::com::sun::star::rendering::ViewState& sourceViewState, 97 const ::com::sun::star::rendering::RenderState& sourceRenderState, 98 const ::com::sun::star::geometry::RealRectangle2D& destRect, 99 const ::com::sun::star::rendering::ViewState& destViewState, 100 const ::com::sun::star::rendering::RenderState& destRenderState ); 101 102 ::com::sun::star::geometry::IntegerSize2D getSize(); 103 104 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > 105 getScaledBitmap( const ::com::sun::star::geometry::RealSize2D& newSize, 106 sal_Bool beFast ); 107 108 ::com::sun::star::uno::Sequence< sal_Int8 > 109 getData( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 110 const ::com::sun::star::geometry::IntegerRectangle2D& rect ); 111 112 void setData( const ::com::sun::star::uno::Sequence< sal_Int8 >& data, 113 const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 114 const ::com::sun::star::geometry::IntegerRectangle2D& rect ); 115 116 void setPixel( const ::com::sun::star::uno::Sequence< sal_Int8 >& color, 117 const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 118 const ::com::sun::star::geometry::IntegerPoint2D& pos ); 119 120 ::com::sun::star::uno::Sequence< sal_Int8 > 121 getPixel( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 122 const ::com::sun::star::geometry::IntegerPoint2D& pos ); 123 124 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapPalette > getPalette(); 125 126 ::com::sun::star::rendering::IntegerBitmapLayout getMemoryLayout(); 127 128 bool hasAlpha() const; 129 130 protected: 131 /// Render target 132 IBitmapSharedPtr mpTarget; 133 }; 134 } 135 136 #endif /* _DXCANVAS_BITMAPCANVASHELPER_HXX_ */ 137