xref: /AOO41X/main/cppcanvas/source/inc/implrenderer.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _CPPCANVAS_IMPLRENDERER_HXX
29*cdf0e10cSrcweir #define _CPPCANVAS_IMPLRENDERER_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <sal/types.h>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
34*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
35*cdf0e10cSrcweir #endif
36*cdf0e10cSrcweir #include <cppcanvas/renderer.hxx>
37*cdf0e10cSrcweir #include <cppcanvas/canvas.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <canvasgraphichelper.hxx>
40*cdf0e10cSrcweir #include <action.hxx>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #include <vector>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir class GDIMetaFile;
45*cdf0e10cSrcweir class VirtualDevice;
46*cdf0e10cSrcweir class Gradient;
47*cdf0e10cSrcweir class BitmapEx;
48*cdf0e10cSrcweir class MapMode;
49*cdf0e10cSrcweir class Size;
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir namespace basegfx {
52*cdf0e10cSrcweir     class B2DPolyPolygon;
53*cdf0e10cSrcweir     class B2DPolygon;
54*cdf0e10cSrcweir }
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir namespace cppcanvas
57*cdf0e10cSrcweir {
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir     namespace internal
60*cdf0e10cSrcweir     {
61*cdf0e10cSrcweir         struct OutDevState;
62*cdf0e10cSrcweir         struct ActionFactoryParameters;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir         // state stack of OutputDevice, to correctly handle
65*cdf0e10cSrcweir         // push/pop actions
66*cdf0e10cSrcweir         typedef ::std::vector< OutDevState >	VectorOfOutDevStates;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir         class ImplRenderer : public virtual Renderer, protected CanvasGraphicHelper
69*cdf0e10cSrcweir         {
70*cdf0e10cSrcweir         public:
71*cdf0e10cSrcweir             ImplRenderer( const CanvasSharedPtr&	rCanvas,
72*cdf0e10cSrcweir                           const GDIMetaFile&		rMtf,
73*cdf0e10cSrcweir                           const Parameters& 		rParms );
74*cdf0e10cSrcweir             ImplRenderer( const CanvasSharedPtr&	rCanvas,
75*cdf0e10cSrcweir                           const BitmapEx&			rBmpEx,
76*cdf0e10cSrcweir                           const Parameters& 		rParms );
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir             virtual ~ImplRenderer();
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir             virtual bool 				draw() const;
81*cdf0e10cSrcweir             virtual bool 				drawSubset( sal_Int32	nStartIndex,
82*cdf0e10cSrcweir                                                     sal_Int32	nEndIndex ) const;
83*cdf0e10cSrcweir             virtual ::basegfx::B2DRange getSubsetArea( sal_Int32	nStartIndex,
84*cdf0e10cSrcweir                                                        sal_Int32	nEndIndex ) const;
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir             // element of the Renderer's action vector. Need to be
88*cdf0e10cSrcweir             // public, since some functors need it, too.
89*cdf0e10cSrcweir             struct MtfAction
90*cdf0e10cSrcweir             {
91*cdf0e10cSrcweir                 MtfAction( const ActionSharedPtr& 	rAction,
92*cdf0e10cSrcweir                            sal_Int32				nOrigIndex ) :
93*cdf0e10cSrcweir                     mpAction( rAction ),
94*cdf0e10cSrcweir                     mnOrigIndex( nOrigIndex )
95*cdf0e10cSrcweir                 {
96*cdf0e10cSrcweir                 }
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir                 ActionSharedPtr mpAction;
99*cdf0e10cSrcweir                 sal_Int32		mnOrigIndex;
100*cdf0e10cSrcweir             };
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir             // prefetched and prepared canvas actions
103*cdf0e10cSrcweir             // (externally not visible)
104*cdf0e10cSrcweir             typedef ::std::vector< MtfAction > 		ActionVector;
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir         private:
108*cdf0e10cSrcweir             // default: disabled copy/assignment
109*cdf0e10cSrcweir             ImplRenderer(const ImplRenderer&);
110*cdf0e10cSrcweir             ImplRenderer& operator=( const ImplRenderer& );
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir             void updateClipping( const ::basegfx::B2DPolyPolygon&   rClipPoly,
113*cdf0e10cSrcweir                                  const ActionFactoryParameters&     rParms,
114*cdf0e10cSrcweir                                  bool                               bIntersect );
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir             void updateClipping( const ::Rectangle&                 rClipRect,
117*cdf0e10cSrcweir                                  const ActionFactoryParameters&     rParms,
118*cdf0e10cSrcweir                                  bool                               bIntersect );
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir             ::com::sun::star::uno::Reference<
121*cdf0e10cSrcweir                 ::com::sun::star::rendering::XCanvasFont > createFont( double&                         o_rFontRotation,
122*cdf0e10cSrcweir                                                                        const ::Font&                   rFont,
123*cdf0e10cSrcweir                                                                        const ActionFactoryParameters&  rParms ) const;
124*cdf0e10cSrcweir             bool createActions( GDIMetaFile&                    rMtf,
125*cdf0e10cSrcweir                                 const ActionFactoryParameters&  rParms,
126*cdf0e10cSrcweir                                 bool                            bSubsettableActions );
127*cdf0e10cSrcweir             bool createFillAndStroke( const ::basegfx::B2DPolyPolygon& rPolyPoly,
128*cdf0e10cSrcweir                                       const ActionFactoryParameters&   rParms );
129*cdf0e10cSrcweir             bool createFillAndStroke( const ::basegfx::B2DPolygon&   rPoly,
130*cdf0e10cSrcweir                                       const ActionFactoryParameters& rParms );
131*cdf0e10cSrcweir             void skipContent( GDIMetaFile& rMtf,
132*cdf0e10cSrcweir                               const char*  pCommentString,
133*cdf0e10cSrcweir                               sal_Int32&   io_rCurrActionIndex ) const;
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir             bool isActionContained( GDIMetaFile& rMtf,
136*cdf0e10cSrcweir                                     const char*  pCommentString,
137*cdf0e10cSrcweir                                     sal_uInt16       nType ) const;
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir             void createGradientAction( const ::PolyPolygon&           rPoly,
140*cdf0e10cSrcweir                                        const ::Gradient&              rGradient,
141*cdf0e10cSrcweir                                        const ActionFactoryParameters& rParms,
142*cdf0e10cSrcweir                                        bool                           bIsPolygonRectangle,
143*cdf0e10cSrcweir                                        bool                           bSubsettableActions );
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir             void createTextAction( const ::Point&                 rStartPoint,
146*cdf0e10cSrcweir                                    const String                   rString,
147*cdf0e10cSrcweir                                    int                            nIndex,
148*cdf0e10cSrcweir                                    int                            nLength,
149*cdf0e10cSrcweir                                    const sal_Int32*               pCharWidths,
150*cdf0e10cSrcweir                                    const ActionFactoryParameters& rParms,
151*cdf0e10cSrcweir                                    bool                           bSubsettable );
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir             bool getSubsetIndices( sal_Int32&                    io_rStartIndex,
154*cdf0e10cSrcweir                                    sal_Int32&                    io_rEndIndex,
155*cdf0e10cSrcweir                                    ActionVector::const_iterator& o_rRangeBegin,
156*cdf0e10cSrcweir                                    ActionVector::const_iterator& o_rRangeEnd ) const;
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir             ActionVector maActions;
160*cdf0e10cSrcweir         };
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir         /// Common parameters when creating actions
164*cdf0e10cSrcweir         struct ActionFactoryParameters
165*cdf0e10cSrcweir         {
166*cdf0e10cSrcweir             ActionFactoryParameters( VectorOfOutDevStates&       rStates,
167*cdf0e10cSrcweir                                      const CanvasSharedPtr&      rCanvas,
168*cdf0e10cSrcweir                                      ::VirtualDevice&            rVDev,
169*cdf0e10cSrcweir                                      const Renderer::Parameters& rParms,
170*cdf0e10cSrcweir                                      sal_Int32&                  io_rCurrActionIndex ) :
171*cdf0e10cSrcweir                 mrStates(rStates),
172*cdf0e10cSrcweir                 mrCanvas(rCanvas),
173*cdf0e10cSrcweir                 mrVDev(rVDev),
174*cdf0e10cSrcweir                 mrParms(rParms),
175*cdf0e10cSrcweir                 mrCurrActionIndex(io_rCurrActionIndex)
176*cdf0e10cSrcweir             {}
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir             VectorOfOutDevStates&       mrStates;
179*cdf0e10cSrcweir             const CanvasSharedPtr&      mrCanvas;
180*cdf0e10cSrcweir             ::VirtualDevice&            mrVDev;
181*cdf0e10cSrcweir             const Renderer::Parameters& mrParms;
182*cdf0e10cSrcweir             sal_Int32&                  mrCurrActionIndex;
183*cdf0e10cSrcweir         };
184*cdf0e10cSrcweir     }
185*cdf0e10cSrcweir }
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir #endif /* _CPPCANVAS_IMPLRENDERER_HXX */
188