/src/libreoffice/canvas/source/vcl/impltools.hxx
Line | Count | Source |
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 | | |
27 | | #include <basegfx/polygon/b2dpolypolygon.hxx> |
28 | | |
29 | | #include <com/sun/star/uno/Reference.hxx> |
30 | | |
31 | | #include "outdevprovider.hxx" |
32 | | |
33 | | |
34 | | class Point; |
35 | | |
36 | | namespace com::sun::star::geometry |
37 | | { |
38 | | struct RealPoint2D; |
39 | | struct Matrix2D; |
40 | | } |
41 | | |
42 | | namespace com::sun::star::rendering |
43 | | { |
44 | | struct RenderState; |
45 | | struct ViewState; |
46 | | class XBitmap; |
47 | | } |
48 | | |
49 | | |
50 | | namespace vclcanvastools |
51 | | { |
52 | | ::Bitmap |
53 | | bitmapFromXBitmap( const css::uno::Reference< |
54 | | css::rendering::XBitmap >& ); |
55 | | |
56 | | /** Setup VCL font and output position |
57 | | |
58 | | @returns false, if no text output should happen |
59 | | */ |
60 | | bool setupFontTransform( ::Point& o_rPoint, |
61 | | vcl::Font& io_rVCLFont, |
62 | | const css::rendering::ViewState& viewState, |
63 | | const css::rendering::RenderState& renderState, |
64 | | ::OutputDevice const & rOutDev ); |
65 | | |
66 | | void setupFontWidth(const css::geometry::Matrix2D& rFontMatrix, |
67 | | vcl::Font& rFont, |
68 | | OutputDevice& rOutDev); |
69 | | |
70 | | /** Predicate, to determine whether polygon is actually an axis-aligned rectangle |
71 | | |
72 | | @return true, if the polygon is a rectangle. |
73 | | */ |
74 | | bool isRectangle( const ::tools::PolyPolygon& rPolyPoly ); |
75 | | |
76 | | |
77 | | // Little helper to encapsulate locking into policy class |
78 | | class LocalGuard |
79 | | { |
80 | | public: |
81 | | LocalGuard() : |
82 | | aSolarGuard() |
83 | 0 | { |
84 | 0 | } |
85 | | |
86 | | /// To be compatible with CanvasBase mutex concept |
87 | | explicit LocalGuard( const ::osl::Mutex& ) : |
88 | 0 | aSolarGuard() |
89 | 0 | { |
90 | 0 | } |
91 | | |
92 | | private: |
93 | | SolarMutexGuard aSolarGuard; |
94 | | }; |
95 | | |
96 | | class OutDevStateKeeper |
97 | | { |
98 | | public: |
99 | | explicit OutDevStateKeeper( OutputDevice& rOutDev ) : |
100 | 0 | mpOutDev( &rOutDev ), |
101 | 0 | mbMappingWasEnabled( mpOutDev->IsMapModeEnabled() ), |
102 | 0 | mnAntiAliasing( mpOutDev->GetAntialiasing() ) |
103 | 0 | { |
104 | 0 | init(); |
105 | 0 | } |
106 | | |
107 | | explicit OutDevStateKeeper( const vclcanvas::OutDevProviderSharedPtr& rOutDev ) : |
108 | 0 | mpOutDev( rOutDev ? &(rOutDev->getOutDev()) : nullptr ), |
109 | 0 | mbMappingWasEnabled( mpOutDev && mpOutDev->IsMapModeEnabled() ), |
110 | 0 | mnAntiAliasing( mpOutDev ? mpOutDev->GetAntialiasing() : AntialiasingFlags::NONE ) |
111 | 0 | { |
112 | 0 | init(); |
113 | 0 | } |
114 | | |
115 | | ~OutDevStateKeeper() |
116 | 0 | { |
117 | 0 | if( mpOutDev ) |
118 | 0 | { |
119 | 0 | mpOutDev->EnableMapMode( mbMappingWasEnabled ); |
120 | 0 | mpOutDev->SetAntialiasing( mnAntiAliasing ); |
121 | |
|
122 | 0 | mpOutDev->Pop(); |
123 | 0 | } |
124 | 0 | } |
125 | | |
126 | | private: |
127 | | void init() |
128 | 0 | { |
129 | 0 | if( mpOutDev ) |
130 | 0 | { |
131 | 0 | mpOutDev->Push(); |
132 | 0 | mpOutDev->EnableMapMode(false); |
133 | 0 | mpOutDev->SetAntialiasing( AntialiasingFlags::Enable ); |
134 | 0 | } |
135 | 0 | } |
136 | | |
137 | | VclPtr<OutputDevice> mpOutDev; |
138 | | const bool mbMappingWasEnabled; |
139 | | const AntialiasingFlags mnAntiAliasing; |
140 | | }; |
141 | | |
142 | | ::Point mapRealPoint2D( const css::geometry::RealPoint2D& rPoint, |
143 | | const css::rendering::ViewState& rViewState, |
144 | | const css::rendering::RenderState& rRenderState ); |
145 | | |
146 | | ::tools::PolyPolygon mapPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly, |
147 | | const css::rendering::ViewState& rViewState, |
148 | | const css::rendering::RenderState& rRenderState ); |
149 | | |
150 | | ::Bitmap transformBitmap( const ::Bitmap& rBitmap, |
151 | | const ::basegfx::B2DHomMatrix& rTransform ); |
152 | | |
153 | | void SetDefaultDeviceAntiAliasing( OutputDevice* pDevice ); |
154 | | } |
155 | | |
156 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |