1*2d788491SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2d788491SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2d788491SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2d788491SAndrew Rist * distributed with this work for additional information 6*2d788491SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2d788491SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2d788491SAndrew Rist * "License"); you may not use this file except in compliance 9*2d788491SAndrew Rist * with the License. You may obtain a copy of the License at 10*2d788491SAndrew Rist * 11*2d788491SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2d788491SAndrew Rist * 13*2d788491SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2d788491SAndrew Rist * software distributed under the License is distributed on an 15*2d788491SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2d788491SAndrew Rist * KIND, either express or implied. See the License for the 17*2d788491SAndrew Rist * specific language governing permissions and limitations 18*2d788491SAndrew Rist * under the License. 19*2d788491SAndrew Rist * 20*2d788491SAndrew Rist *************************************************************/ 21*2d788491SAndrew Rist 22*2d788491SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _CPPCANVAS_IMPLRENDERER_HXX 25cdf0e10cSrcweir #define _CPPCANVAS_IMPLRENDERER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <sal/types.h> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #ifndef BOOST_SHARED_PTR_HPP_INCLUDED 30cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir #include <cppcanvas/renderer.hxx> 33cdf0e10cSrcweir #include <cppcanvas/canvas.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <canvasgraphichelper.hxx> 36cdf0e10cSrcweir #include <action.hxx> 37cdf0e10cSrcweir 38cdf0e10cSrcweir #include <vector> 39cdf0e10cSrcweir 40cdf0e10cSrcweir class GDIMetaFile; 41cdf0e10cSrcweir class VirtualDevice; 42cdf0e10cSrcweir class Gradient; 43cdf0e10cSrcweir class BitmapEx; 44cdf0e10cSrcweir class MapMode; 45cdf0e10cSrcweir class Size; 46cdf0e10cSrcweir 47cdf0e10cSrcweir namespace basegfx { 48cdf0e10cSrcweir class B2DPolyPolygon; 49cdf0e10cSrcweir class B2DPolygon; 50cdf0e10cSrcweir } 51cdf0e10cSrcweir 52cdf0e10cSrcweir namespace cppcanvas 53cdf0e10cSrcweir { 54cdf0e10cSrcweir 55cdf0e10cSrcweir namespace internal 56cdf0e10cSrcweir { 57cdf0e10cSrcweir struct OutDevState; 58cdf0e10cSrcweir struct ActionFactoryParameters; 59cdf0e10cSrcweir 60cdf0e10cSrcweir // state stack of OutputDevice, to correctly handle 61cdf0e10cSrcweir // push/pop actions 62cdf0e10cSrcweir typedef ::std::vector< OutDevState > VectorOfOutDevStates; 63cdf0e10cSrcweir 64cdf0e10cSrcweir class ImplRenderer : public virtual Renderer, protected CanvasGraphicHelper 65cdf0e10cSrcweir { 66cdf0e10cSrcweir public: 67cdf0e10cSrcweir ImplRenderer( const CanvasSharedPtr& rCanvas, 68cdf0e10cSrcweir const GDIMetaFile& rMtf, 69cdf0e10cSrcweir const Parameters& rParms ); 70cdf0e10cSrcweir ImplRenderer( const CanvasSharedPtr& rCanvas, 71cdf0e10cSrcweir const BitmapEx& rBmpEx, 72cdf0e10cSrcweir const Parameters& rParms ); 73cdf0e10cSrcweir 74cdf0e10cSrcweir virtual ~ImplRenderer(); 75cdf0e10cSrcweir 76cdf0e10cSrcweir virtual bool draw() const; 77cdf0e10cSrcweir virtual bool drawSubset( sal_Int32 nStartIndex, 78cdf0e10cSrcweir sal_Int32 nEndIndex ) const; 79cdf0e10cSrcweir virtual ::basegfx::B2DRange getSubsetArea( sal_Int32 nStartIndex, 80cdf0e10cSrcweir sal_Int32 nEndIndex ) const; 81cdf0e10cSrcweir 82cdf0e10cSrcweir 83cdf0e10cSrcweir // element of the Renderer's action vector. Need to be 84cdf0e10cSrcweir // public, since some functors need it, too. 85cdf0e10cSrcweir struct MtfAction 86cdf0e10cSrcweir { MtfActioncppcanvas::internal::ImplRenderer::MtfAction87cdf0e10cSrcweir MtfAction( const ActionSharedPtr& rAction, 88cdf0e10cSrcweir sal_Int32 nOrigIndex ) : 89cdf0e10cSrcweir mpAction( rAction ), 90cdf0e10cSrcweir mnOrigIndex( nOrigIndex ) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir } 93cdf0e10cSrcweir 94cdf0e10cSrcweir ActionSharedPtr mpAction; 95cdf0e10cSrcweir sal_Int32 mnOrigIndex; 96cdf0e10cSrcweir }; 97cdf0e10cSrcweir 98cdf0e10cSrcweir // prefetched and prepared canvas actions 99cdf0e10cSrcweir // (externally not visible) 100cdf0e10cSrcweir typedef ::std::vector< MtfAction > ActionVector; 101cdf0e10cSrcweir 102cdf0e10cSrcweir 103cdf0e10cSrcweir private: 104cdf0e10cSrcweir // default: disabled copy/assignment 105cdf0e10cSrcweir ImplRenderer(const ImplRenderer&); 106cdf0e10cSrcweir ImplRenderer& operator=( const ImplRenderer& ); 107cdf0e10cSrcweir 108cdf0e10cSrcweir void updateClipping( const ::basegfx::B2DPolyPolygon& rClipPoly, 109cdf0e10cSrcweir const ActionFactoryParameters& rParms, 110cdf0e10cSrcweir bool bIntersect ); 111cdf0e10cSrcweir 112cdf0e10cSrcweir void updateClipping( const ::Rectangle& rClipRect, 113cdf0e10cSrcweir const ActionFactoryParameters& rParms, 114cdf0e10cSrcweir bool bIntersect ); 115cdf0e10cSrcweir 116cdf0e10cSrcweir ::com::sun::star::uno::Reference< 117cdf0e10cSrcweir ::com::sun::star::rendering::XCanvasFont > createFont( double& o_rFontRotation, 118cdf0e10cSrcweir const ::Font& rFont, 119cdf0e10cSrcweir const ActionFactoryParameters& rParms ) const; 120cdf0e10cSrcweir bool createActions( GDIMetaFile& rMtf, 121cdf0e10cSrcweir const ActionFactoryParameters& rParms, 122cdf0e10cSrcweir bool bSubsettableActions ); 123cdf0e10cSrcweir bool createFillAndStroke( const ::basegfx::B2DPolyPolygon& rPolyPoly, 124cdf0e10cSrcweir const ActionFactoryParameters& rParms ); 125cdf0e10cSrcweir bool createFillAndStroke( const ::basegfx::B2DPolygon& rPoly, 126cdf0e10cSrcweir const ActionFactoryParameters& rParms ); 127cdf0e10cSrcweir void skipContent( GDIMetaFile& rMtf, 128cdf0e10cSrcweir const char* pCommentString, 129cdf0e10cSrcweir sal_Int32& io_rCurrActionIndex ) const; 130cdf0e10cSrcweir 131cdf0e10cSrcweir bool isActionContained( GDIMetaFile& rMtf, 132cdf0e10cSrcweir const char* pCommentString, 133cdf0e10cSrcweir sal_uInt16 nType ) const; 134cdf0e10cSrcweir 135cdf0e10cSrcweir void createGradientAction( const ::PolyPolygon& rPoly, 136cdf0e10cSrcweir const ::Gradient& rGradient, 137cdf0e10cSrcweir const ActionFactoryParameters& rParms, 138cdf0e10cSrcweir bool bIsPolygonRectangle, 139cdf0e10cSrcweir bool bSubsettableActions ); 140cdf0e10cSrcweir 141cdf0e10cSrcweir void createTextAction( const ::Point& rStartPoint, 142cdf0e10cSrcweir const String rString, 143cdf0e10cSrcweir int nIndex, 144cdf0e10cSrcweir int nLength, 145cdf0e10cSrcweir const sal_Int32* pCharWidths, 146cdf0e10cSrcweir const ActionFactoryParameters& rParms, 147cdf0e10cSrcweir bool bSubsettable ); 148cdf0e10cSrcweir 149cdf0e10cSrcweir bool getSubsetIndices( sal_Int32& io_rStartIndex, 150cdf0e10cSrcweir sal_Int32& io_rEndIndex, 151cdf0e10cSrcweir ActionVector::const_iterator& o_rRangeBegin, 152cdf0e10cSrcweir ActionVector::const_iterator& o_rRangeEnd ) const; 153cdf0e10cSrcweir 154cdf0e10cSrcweir 155cdf0e10cSrcweir ActionVector maActions; 156cdf0e10cSrcweir }; 157cdf0e10cSrcweir 158cdf0e10cSrcweir 159cdf0e10cSrcweir /// Common parameters when creating actions 160cdf0e10cSrcweir struct ActionFactoryParameters 161cdf0e10cSrcweir { ActionFactoryParameterscppcanvas::internal::ActionFactoryParameters162cdf0e10cSrcweir ActionFactoryParameters( VectorOfOutDevStates& rStates, 163cdf0e10cSrcweir const CanvasSharedPtr& rCanvas, 164cdf0e10cSrcweir ::VirtualDevice& rVDev, 165cdf0e10cSrcweir const Renderer::Parameters& rParms, 166cdf0e10cSrcweir sal_Int32& io_rCurrActionIndex ) : 167cdf0e10cSrcweir mrStates(rStates), 168cdf0e10cSrcweir mrCanvas(rCanvas), 169cdf0e10cSrcweir mrVDev(rVDev), 170cdf0e10cSrcweir mrParms(rParms), 171cdf0e10cSrcweir mrCurrActionIndex(io_rCurrActionIndex) 172cdf0e10cSrcweir {} 173cdf0e10cSrcweir 174cdf0e10cSrcweir VectorOfOutDevStates& mrStates; 175cdf0e10cSrcweir const CanvasSharedPtr& mrCanvas; 176cdf0e10cSrcweir ::VirtualDevice& mrVDev; 177cdf0e10cSrcweir const Renderer::Parameters& mrParms; 178cdf0e10cSrcweir sal_Int32& mrCurrActionIndex; 179cdf0e10cSrcweir }; 180cdf0e10cSrcweir } 181cdf0e10cSrcweir } 182cdf0e10cSrcweir 183cdf0e10cSrcweir #endif /* _CPPCANVAS_IMPLRENDERER_HXX */ 184