merge the formfield patch from ooo-build
[ooovba.git] / canvas / source / vcl / impltools.hxx
blob593171898d8be78fcb1abee4a9b474cb4177db92
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: impltools.hxx,v $
10 * $Revision: 1.8 $
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 #ifndef _VCLCANVAS_TOOLS_HXX
32 #define _VCLCANVAS_TOOLS_HXX
34 #include <osl/mutex.hxx>
35 #include <vos/mutex.hxx>
37 #include <vcl/svapp.hxx>
38 #include <vcl/outdev.hxx>
40 #include <basegfx/polygon/b2dpolypolygon.hxx>
42 #include <com/sun/star/uno/Reference.hxx>
43 #include <com/sun/star/uno/Sequence.hxx>
45 #include <canvas/vclwrapper.hxx>
46 #include "outdevprovider.hxx"
49 class OutputDevice;
50 class Point;
51 class Size;
53 namespace basegfx
55 namespace matrix
57 class B2DHomMatrix;
59 namespace vector
61 class B2DVector;
63 namespace point
65 class B2DPoint;
69 namespace com { namespace sun { namespace star { namespace awt
71 struct Point;
72 struct Size;
73 struct Rectangle;
74 } } } }
76 namespace com { namespace sun { namespace star { namespace drawing
78 struct HomogenMatrix3;
79 } } } }
81 namespace com { namespace sun { namespace star { namespace geometry
83 struct RealPoint2D;
84 struct RealSize2D;
85 struct RealRectangle2D;
86 } } } }
88 namespace com { namespace sun { namespace star { namespace rendering
90 struct RenderState;
91 struct ViewState;
92 class XCanvas;
93 class XBitmap;
94 class XPolyPolygon2D;
95 } } } }
98 namespace vclcanvas
100 namespace tools
102 ::BitmapEx
103 bitmapExFromXBitmap( const ::com::sun::star::uno::Reference<
104 ::com::sun::star::rendering::XBitmap >& );
106 /** Setup VCL font and output position
108 @returns false, if no text output should happen
110 bool setupFontTransform( ::Point& o_rPoint,
111 ::Font& io_rVCLFont,
112 const ::com::sun::star::rendering::ViewState& viewState,
113 const ::com::sun::star::rendering::RenderState& renderState,
114 ::OutputDevice& rOutDev );
116 /** Predicate, to determine whether polygon is actually an axis-aligned rectangle
118 @return true, if the polygon is a rectangle.
120 bool isRectangle( const PolyPolygon& rPolyPoly );
123 // Little helper to encapsulate locking into policy class
124 class LocalGuard
126 public:
127 LocalGuard() :
128 aGuard( Application::GetSolarMutex() )
132 /// To be compatible with CanvasBase mutex concept
133 LocalGuard( const ::osl::Mutex& ) :
134 aGuard( Application::GetSolarMutex() )
138 private:
139 ::vos::OGuard aGuard;
142 class OutDevStateKeeper
144 public:
145 explicit OutDevStateKeeper( OutputDevice& rOutDev ) :
146 mpOutDev( &rOutDev ),
147 mbMappingWasEnabled( mpOutDev->IsMapModeEnabled() )
149 init();
152 explicit OutDevStateKeeper( const OutDevProviderSharedPtr& rOutDev ) :
153 mpOutDev( rOutDev.get() ? &(rOutDev->getOutDev()) : NULL ),
154 mbMappingWasEnabled( mpOutDev ? mpOutDev->IsMapModeEnabled() : false )
156 init();
159 ~OutDevStateKeeper()
161 if( mpOutDev )
163 mpOutDev->EnableMapMode( mbMappingWasEnabled );
164 mpOutDev->Pop();
168 private:
169 void init()
171 if( mpOutDev )
173 mpOutDev->Push();
174 mpOutDev->EnableMapMode(FALSE);
178 OutputDevice* mpOutDev;
179 const bool mbMappingWasEnabled;
182 ::Point mapRealPoint2D( const ::com::sun::star::geometry::RealPoint2D& rPoint,
183 const ::com::sun::star::rendering::ViewState& rViewState,
184 const ::com::sun::star::rendering::RenderState& rRenderState );
186 ::PolyPolygon mapPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly,
187 const ::com::sun::star::rendering::ViewState& rViewState,
188 const ::com::sun::star::rendering::RenderState& rRenderState );
190 enum ModulationMode
192 MODULATE_NONE,
193 MODULATE_WITH_DEVICECOLOR
196 ::BitmapEx transformBitmap( const BitmapEx& rBitmap,
197 const ::basegfx::B2DHomMatrix& rTransform,
198 const ::com::sun::star::uno::Sequence< double >& rDeviceColor,
199 ModulationMode eModulationMode );
204 #endif /* _VCLCANVAS_TOOLS_HXX */