LibreOffice Module canvas (master) 1
impltools.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <osl/mutex.hxx>
23
24#include <vcl/svapp.hxx>
25#include <vcl/outdev.hxx>
26
28
29#include <com/sun/star/uno/Reference.hxx>
30
31#include "outdevprovider.hxx"
32
33
34class OutputDevice;
35class Point;
36class Size;
37
38namespace basegfx
39{
40 namespace matrix
41 {
42 class B2DHomMatrix;
43 }
44}
45
46namespace com::sun::star::awt
47{
48 struct Point;
49 struct Size;
50 struct Rectangle;
51}
52
54{
55 struct HomogenMatrix3;
56}
57
59{
60 struct RealPoint2D;
61 struct RealSize2D;
62 struct RealRectangle2D;
63 struct Matrix2D;
64}
65
67{
68 struct RenderState;
69 struct ViewState;
70 class XBitmap;
71}
72
73
74namespace vclcanvas
75{
76 namespace tools
77 {
79 bitmapExFromXBitmap( const css::uno::Reference<
80 css::rendering::XBitmap >& );
81
86 bool setupFontTransform( ::Point& o_rPoint,
87 vcl::Font& io_rVCLFont,
88 const css::rendering::ViewState& viewState,
89 const css::rendering::RenderState& renderState,
90 ::OutputDevice const & rOutDev );
91
92 void setupFontWidth(const css::geometry::Matrix2D& rFontMatrix,
93 vcl::Font& rFont,
94 OutputDevice& rOutDev);
95
100 bool isRectangle( const ::tools::PolyPolygon& rPolyPoly );
101
102
103 // Little helper to encapsulate locking into policy class
105 {
106 public:
109 {
110 }
111
113 explicit LocalGuard( const ::osl::Mutex& ) :
115 {
116 }
117
118 private:
120 };
121
123 {
124 public:
125 explicit OutDevStateKeeper( OutputDevice& rOutDev ) :
126 mpOutDev( &rOutDev ),
127 mbMappingWasEnabled( mpOutDev->IsMapModeEnabled() ),
128 mnAntiAliasing( mpOutDev->GetAntialiasing() )
129 {
130 init();
131 }
132
133 explicit OutDevStateKeeper( const OutDevProviderSharedPtr& rOutDev ) :
134 mpOutDev( rOutDev ? &(rOutDev->getOutDev()) : nullptr ),
135 mbMappingWasEnabled( mpOutDev && mpOutDev->IsMapModeEnabled() ),
136 mnAntiAliasing( mpOutDev ? mpOutDev->GetAntialiasing() : AntialiasingFlags::NONE )
137 {
138 init();
139 }
140
142 {
143 if( mpOutDev )
144 {
145 mpOutDev->EnableMapMode( mbMappingWasEnabled );
146 mpOutDev->SetAntialiasing( mnAntiAliasing );
147
148 mpOutDev->Pop();
149 }
150 }
151
152 private:
153 void init()
154 {
155 if( mpOutDev )
156 {
157 mpOutDev->Push();
158 mpOutDev->EnableMapMode(false);
159 mpOutDev->SetAntialiasing( AntialiasingFlags::Enable );
160 }
161 }
162
166 };
167
168 ::Point mapRealPoint2D( const css::geometry::RealPoint2D& rPoint,
169 const css::rendering::ViewState& rViewState,
170 const css::rendering::RenderState& rRenderState );
171
172 ::tools::PolyPolygon mapPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly,
173 const css::rendering::ViewState& rViewState,
174 const css::rendering::RenderState& rRenderState );
175
176 ::BitmapEx transformBitmap( const BitmapEx& rBitmap,
177 const ::basegfx::B2DHomMatrix& rTransform );
178
180 }
181}
182
183/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AntialiasingFlags
LocalGuard(const ::osl::Mutex &)
To be compatible with CanvasBase mutex concept.
Definition: impltools.hxx:113
SolarMutexGuard aSolarGuard
Definition: impltools.hxx:119
VclPtr< OutputDevice > mpOutDev
Definition: impltools.hxx:163
OutDevStateKeeper(OutputDevice &rOutDev)
Definition: impltools.hxx:125
OutDevStateKeeper(const OutDevProviderSharedPtr &rOutDev)
Definition: impltools.hxx:133
const AntialiasingFlags mnAntiAliasing
Definition: impltools.hxx:165
NONE
double matrix[4][4]
ViewState
void setupFontWidth(const css::geometry::Matrix2D &rFontMatrix, vcl::Font &rFont, OutputDevice &rOutDev)
Definition: impltools.cxx:138
::tools::PolyPolygon mapPolyPolygon(const ::basegfx::B2DPolyPolygon &rPoly, const rendering::ViewState &rViewState, const rendering::RenderState &rRenderState)
Definition: impltools.cxx:199
bool setupFontTransform(::Point &o_rPoint, vcl::Font &io_rVCLFont, const rendering::ViewState &rViewState, const rendering::RenderState &rRenderState, ::OutputDevice const &rOutDev)
Definition: impltools.cxx:87
void SetDefaultDeviceAntiAliasing(OutputDevice *pDevice)
Definition: impltools.cxx:248
::BitmapEx transformBitmap(const BitmapEx &rBitmap, const ::basegfx::B2DHomMatrix &rTransform)
Definition: impltools.cxx:215
bool isRectangle(const ::tools::PolyPolygon &rPolyPoly)
Predicate, to determine whether polygon is actually an axis-aligned rectangle.
Definition: impltools.cxx:165
::Point mapRealPoint2D(const geometry::RealPoint2D &rPoint, const rendering::ViewState &rViewState, const rendering::RenderState &rRenderState)
Definition: impltools.cxx:185
::BitmapEx bitmapExFromXBitmap(const uno::Reference< rendering::XBitmap > &xBitmap)
Definition: impltools.cxx:49
std::shared_ptr< OutDevProvider > OutDevProviderSharedPtr