Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _VCLCANVAS_TOOLS_HXX
21 : #define _VCLCANVAS_TOOLS_HXX
22 :
23 : #include <osl/mutex.hxx>
24 :
25 : #include <vcl/svapp.hxx>
26 : #include <vcl/outdev.hxx>
27 : #include <vcl/solarmutex.hxx>
28 :
29 : #include <basegfx/polygon/b2dpolypolygon.hxx>
30 :
31 : #include <com/sun/star/uno/Reference.hxx>
32 : #include <com/sun/star/uno/Sequence.hxx>
33 :
34 : #include <canvas/vclwrapper.hxx>
35 : #include "outdevprovider.hxx"
36 :
37 :
38 : class OutputDevice;
39 : class Point;
40 : class Size;
41 :
42 : namespace basegfx
43 : {
44 : namespace matrix
45 : {
46 : class B2DHomMatrix;
47 : }
48 : }
49 :
50 : namespace com { namespace sun { namespace star { namespace awt
51 : {
52 : struct Point;
53 : struct Size;
54 : struct Rectangle;
55 : } } } }
56 :
57 : namespace com { namespace sun { namespace star { namespace drawing
58 : {
59 : struct HomogenMatrix3;
60 : } } } }
61 :
62 : namespace com { namespace sun { namespace star { namespace geometry
63 : {
64 : struct RealPoint2D;
65 : struct RealSize2D;
66 : struct RealRectangle2D;
67 : } } } }
68 :
69 : namespace com { namespace sun { namespace star { namespace rendering
70 : {
71 : struct RenderState;
72 : struct ViewState;
73 : class XBitmap;
74 : } } } }
75 :
76 :
77 : namespace vclcanvas
78 : {
79 : namespace tools
80 : {
81 : ::BitmapEx
82 : bitmapExFromXBitmap( const ::com::sun::star::uno::Reference<
83 : ::com::sun::star::rendering::XBitmap >& );
84 :
85 : /** Setup VCL font and output position
86 :
87 : @returns false, if no text output should happen
88 : */
89 : bool setupFontTransform( ::Point& o_rPoint,
90 : ::Font& io_rVCLFont,
91 : const ::com::sun::star::rendering::ViewState& viewState,
92 : const ::com::sun::star::rendering::RenderState& renderState,
93 : ::OutputDevice& rOutDev );
94 :
95 : /** Predicate, to determine whether polygon is actually an axis-aligned rectangle
96 :
97 : @return true, if the polygon is a rectangle.
98 : */
99 : bool isRectangle( const PolyPolygon& rPolyPoly );
100 :
101 :
102 : // Little helper to encapsulate locking into policy class
103 0 : class LocalGuard
104 : {
105 : public:
106 : LocalGuard() :
107 : aSolarGuard()
108 : {
109 : }
110 :
111 : /// To be compatible with CanvasBase mutex concept
112 0 : LocalGuard( const ::osl::Mutex& ) :
113 0 : aSolarGuard()
114 : {
115 0 : }
116 :
117 : private:
118 : SolarMutexGuard aSolarGuard;
119 : };
120 :
121 : class OutDevStateKeeper
122 : {
123 : public:
124 0 : explicit OutDevStateKeeper( OutputDevice& rOutDev ) :
125 : mpOutDev( &rOutDev ),
126 0 : mbMappingWasEnabled( mpOutDev->IsMapModeEnabled() ),
127 0 : mnAntiAliasing( mpOutDev->GetAntialiasing() )
128 : {
129 0 : init();
130 0 : }
131 :
132 0 : explicit OutDevStateKeeper( const OutDevProviderSharedPtr& rOutDev ) :
133 0 : mpOutDev( rOutDev.get() ? &(rOutDev->getOutDev()) : NULL ),
134 0 : mbMappingWasEnabled( mpOutDev ? mpOutDev->IsMapModeEnabled() : false ),
135 0 : mnAntiAliasing( mpOutDev ? mpOutDev->GetAntialiasing() : 0 )
136 : {
137 0 : init();
138 0 : }
139 :
140 0 : ~OutDevStateKeeper()
141 : {
142 0 : if( mpOutDev )
143 : {
144 0 : mpOutDev->EnableMapMode( mbMappingWasEnabled );
145 0 : mpOutDev->SetAntialiasing( mnAntiAliasing );
146 :
147 0 : mpOutDev->Pop();
148 : }
149 0 : }
150 :
151 : private:
152 0 : void init()
153 : {
154 0 : if( mpOutDev )
155 : {
156 0 : mpOutDev->Push();
157 0 : mpOutDev->EnableMapMode(sal_False);
158 0 : mpOutDev->SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW );
159 : }
160 0 : }
161 :
162 : OutputDevice* mpOutDev;
163 : const bool mbMappingWasEnabled;
164 : const sal_uInt16 mnAntiAliasing;
165 : };
166 :
167 : ::Point mapRealPoint2D( const ::com::sun::star::geometry::RealPoint2D& rPoint,
168 : const ::com::sun::star::rendering::ViewState& rViewState,
169 : const ::com::sun::star::rendering::RenderState& rRenderState );
170 :
171 : ::PolyPolygon mapPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly,
172 : const ::com::sun::star::rendering::ViewState& rViewState,
173 : const ::com::sun::star::rendering::RenderState& rRenderState );
174 :
175 : enum ModulationMode
176 : {
177 : MODULATE_NONE,
178 : MODULATE_WITH_DEVICECOLOR
179 : };
180 :
181 : ::BitmapEx transformBitmap( const BitmapEx& rBitmap,
182 : const ::basegfx::B2DHomMatrix& rTransform,
183 : const ::com::sun::star::uno::Sequence< double >& rDeviceColor,
184 : ModulationMode eModulationMode );
185 :
186 : }
187 : }
188 :
189 : #endif /* _VCLCANVAS_TOOLS_HXX */
190 :
191 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|