Branch libreoffice-5-0-4
[LibreOffice.git] / canvas / source / vcl / impltools.hxx
blob9d5e0b23b675e6e09e5a650ff69e196b37c2a3b8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_CANVAS_SOURCE_VCL_IMPLTOOLS_HXX
21 #define INCLUDED_CANVAS_SOURCE_VCL_IMPLTOOLS_HXX
23 #include <osl/mutex.hxx>
25 #include <vcl/svapp.hxx>
26 #include <vcl/outdev.hxx>
28 #include <basegfx/polygon/b2dpolypolygon.hxx>
30 #include <com/sun/star/uno/Reference.hxx>
31 #include <com/sun/star/uno/Sequence.hxx>
33 #include <canvas/vclwrapper.hxx>
34 #include "outdevprovider.hxx"
37 class OutputDevice;
38 class Point;
39 class Size;
41 namespace basegfx
43 namespace matrix
45 class B2DHomMatrix;
49 namespace com { namespace sun { namespace star { namespace awt
51 struct Point;
52 struct Size;
53 struct Rectangle;
54 } } } }
56 namespace com { namespace sun { namespace star { namespace drawing
58 struct HomogenMatrix3;
59 } } } }
61 namespace com { namespace sun { namespace star { namespace geometry
63 struct RealPoint2D;
64 struct RealSize2D;
65 struct RealRectangle2D;
66 } } } }
68 namespace com { namespace sun { namespace star { namespace rendering
70 struct RenderState;
71 struct ViewState;
72 class XBitmap;
73 } } } }
76 namespace vclcanvas
78 namespace tools
80 ::BitmapEx
81 bitmapExFromXBitmap( const ::com::sun::star::uno::Reference<
82 ::com::sun::star::rendering::XBitmap >& );
84 /** Setup VCL font and output position
86 @returns false, if no text output should happen
88 bool setupFontTransform( ::Point& o_rPoint,
89 vcl::Font& io_rVCLFont,
90 const ::com::sun::star::rendering::ViewState& viewState,
91 const ::com::sun::star::rendering::RenderState& renderState,
92 ::OutputDevice& rOutDev );
94 /** Predicate, to determine whether polygon is actually an axis-aligned rectangle
96 @return true, if the polygon is a rectangle.
98 bool isRectangle( const ::tools::PolyPolygon& rPolyPoly );
101 // Little helper to encapsulate locking into policy class
102 class LocalGuard
104 public:
105 LocalGuard() :
106 aSolarGuard()
110 /// To be compatible with CanvasBase mutex concept
111 LocalGuard( const ::osl::Mutex& ) :
112 aSolarGuard()
116 private:
117 SolarMutexGuard aSolarGuard;
120 class OutDevStateKeeper
122 public:
123 explicit OutDevStateKeeper( OutputDevice& rOutDev ) :
124 mpOutDev( &rOutDev ),
125 mbMappingWasEnabled( mpOutDev->IsMapModeEnabled() ),
126 mnAntiAliasing( mpOutDev->GetAntialiasing() )
128 init();
131 explicit OutDevStateKeeper( const OutDevProviderSharedPtr& rOutDev ) :
132 mpOutDev( rOutDev.get() ? &(rOutDev->getOutDev()) : NULL ),
133 mbMappingWasEnabled( mpOutDev && mpOutDev->IsMapModeEnabled() ),
134 mnAntiAliasing( mpOutDev ? mpOutDev->GetAntialiasing() : AntialiasingFlags::NONE )
136 init();
139 ~OutDevStateKeeper()
141 if( mpOutDev )
143 mpOutDev->EnableMapMode( mbMappingWasEnabled );
144 mpOutDev->SetAntialiasing( mnAntiAliasing );
146 mpOutDev->Pop();
150 private:
151 void init()
153 if( mpOutDev )
155 mpOutDev->Push();
156 mpOutDev->EnableMapMode(false);
157 mpOutDev->SetAntialiasing( AntialiasingFlags::EnableB2dDraw );
161 VclPtr<OutputDevice> mpOutDev;
162 const bool mbMappingWasEnabled;
163 const AntialiasingFlags mnAntiAliasing;
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 );
170 ::tools::PolyPolygon mapPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly,
171 const ::com::sun::star::rendering::ViewState& rViewState,
172 const ::com::sun::star::rendering::RenderState& rRenderState );
174 enum ModulationMode
176 MODULATE_NONE,
177 MODULATE_WITH_DEVICECOLOR
180 ::BitmapEx transformBitmap( const BitmapEx& rBitmap,
181 const ::basegfx::B2DHomMatrix& rTransform,
182 const ::com::sun::star::uno::Sequence< double >& rDeviceColor,
183 ModulationMode eModulationMode );
188 #endif // INCLUDED_CANVAS_SOURCE_VCL_IMPLTOOLS_HXX
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */