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 INCLUDED_CANVAS_SOURCE_VCL_IMPLTOOLS_HXX
21 : #define INCLUDED_CANVAS_SOURCE_VCL_IMPLTOOLS_HXX
22 :
23 : #include <osl/mutex.hxx>
24 :
25 : #include <vcl/svapp.hxx>
26 : #include <vcl/outdev.hxx>
27 :
28 : #include <basegfx/polygon/b2dpolypolygon.hxx>
29 :
30 : #include <com/sun/star/uno/Reference.hxx>
31 : #include <com/sun/star/uno/Sequence.hxx>
32 :
33 : #include <canvas/vclwrapper.hxx>
34 : #include "outdevprovider.hxx"
35 :
36 :
37 : class OutputDevice;
38 : class Point;
39 : class Size;
40 :
41 : namespace basegfx
42 : {
43 : namespace matrix
44 : {
45 : class B2DHomMatrix;
46 : }
47 : }
48 :
49 : namespace com { namespace sun { namespace star { namespace awt
50 : {
51 : struct Point;
52 : struct Size;
53 : struct Rectangle;
54 : } } } }
55 :
56 : namespace com { namespace sun { namespace star { namespace drawing
57 : {
58 : struct HomogenMatrix3;
59 : } } } }
60 :
61 : namespace com { namespace sun { namespace star { namespace geometry
62 : {
63 : struct RealPoint2D;
64 : struct RealSize2D;
65 : struct RealRectangle2D;
66 : } } } }
67 :
68 : namespace com { namespace sun { namespace star { namespace rendering
69 : {
70 : struct RenderState;
71 : struct ViewState;
72 : class XBitmap;
73 : } } } }
74 :
75 :
76 : namespace vclcanvas
77 : {
78 : namespace tools
79 : {
80 : ::BitmapEx
81 : bitmapExFromXBitmap( const ::com::sun::star::uno::Reference<
82 : ::com::sun::star::rendering::XBitmap >& );
83 :
84 : /** Setup VCL font and output position
85 :
86 : @returns false, if no text output should happen
87 : */
88 : bool setupFontTransform( ::Point& o_rPoint,
89 : ::Font& io_rVCLFont,
90 : const ::com::sun::star::rendering::ViewState& viewState,
91 : const ::com::sun::star::rendering::RenderState& renderState,
92 : ::OutputDevice& rOutDev );
93 :
94 : /** Predicate, to determine whether polygon is actually an axis-aligned rectangle
95 :
96 : @return true, if the polygon is a rectangle.
97 : */
98 : bool isRectangle( const PolyPolygon& rPolyPoly );
99 :
100 :
101 : // Little helper to encapsulate locking into policy class
102 0 : class LocalGuard
103 : {
104 : public:
105 : LocalGuard() :
106 : aSolarGuard()
107 : {
108 : }
109 :
110 : /// To be compatible with CanvasBase mutex concept
111 0 : LocalGuard( const ::osl::Mutex& ) :
112 0 : aSolarGuard()
113 : {
114 0 : }
115 :
116 : private:
117 : SolarMutexGuard aSolarGuard;
118 : };
119 :
120 : class OutDevStateKeeper
121 : {
122 : public:
123 0 : explicit OutDevStateKeeper( OutputDevice& rOutDev ) :
124 : mpOutDev( &rOutDev ),
125 0 : mbMappingWasEnabled( mpOutDev->IsMapModeEnabled() ),
126 0 : mnAntiAliasing( mpOutDev->GetAntialiasing() )
127 : {
128 0 : init();
129 0 : }
130 :
131 0 : explicit OutDevStateKeeper( const OutDevProviderSharedPtr& rOutDev ) :
132 0 : mpOutDev( rOutDev.get() ? &(rOutDev->getOutDev()) : NULL ),
133 0 : mbMappingWasEnabled( mpOutDev ? mpOutDev->IsMapModeEnabled() : false ),
134 0 : mnAntiAliasing( mpOutDev ? mpOutDev->GetAntialiasing() : 0 )
135 : {
136 0 : init();
137 0 : }
138 :
139 0 : ~OutDevStateKeeper()
140 : {
141 0 : if( mpOutDev )
142 : {
143 0 : mpOutDev->EnableMapMode( mbMappingWasEnabled );
144 0 : mpOutDev->SetAntialiasing( mnAntiAliasing );
145 :
146 0 : mpOutDev->Pop();
147 : }
148 0 : }
149 :
150 : private:
151 0 : void init()
152 : {
153 0 : if( mpOutDev )
154 : {
155 0 : mpOutDev->Push();
156 0 : mpOutDev->EnableMapMode(false);
157 0 : mpOutDev->SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW );
158 : }
159 0 : }
160 :
161 : OutputDevice* mpOutDev;
162 : const bool mbMappingWasEnabled;
163 : const sal_uInt16 mnAntiAliasing;
164 : };
165 :
166 : ::Point mapRealPoint2D( const ::com::sun::star::geometry::RealPoint2D& rPoint,
167 : const ::com::sun::star::rendering::ViewState& rViewState,
168 : const ::com::sun::star::rendering::RenderState& rRenderState );
169 :
170 : ::PolyPolygon mapPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly,
171 : const ::com::sun::star::rendering::ViewState& rViewState,
172 : const ::com::sun::star::rendering::RenderState& rRenderState );
173 :
174 : enum ModulationMode
175 : {
176 : MODULATE_NONE,
177 : MODULATE_WITH_DEVICECOLOR
178 : };
179 :
180 : ::BitmapEx transformBitmap( const BitmapEx& rBitmap,
181 : const ::basegfx::B2DHomMatrix& rTransform,
182 : const ::com::sun::star::uno::Sequence< double >& rDeviceColor,
183 : ModulationMode eModulationMode );
184 :
185 : }
186 : }
187 :
188 : #endif // INCLUDED_CANVAS_SOURCE_VCL_IMPLTOOLS_HXX
189 :
190 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|