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 
34 class OutputDevice;
35 class Point;
36 class Size;
37 
38 namespace basegfx
39 {
40  namespace matrix
41  {
42  class B2DHomMatrix;
43  }
44 }
45 
46 namespace 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 }
64 
66 {
67  struct RenderState;
68  struct ViewState;
69  class XBitmap;
70 }
71 
72 
73 namespace vclcanvas
74 {
75  namespace tools
76  {
78  bitmapExFromXBitmap( const css::uno::Reference<
79  css::rendering::XBitmap >& );
80 
85  bool setupFontTransform( ::Point& o_rPoint,
86  vcl::Font& io_rVCLFont,
87  const css::rendering::ViewState& viewState,
88  const css::rendering::RenderState& renderState,
89  ::OutputDevice const & rOutDev );
90 
95  bool isRectangle( const ::tools::PolyPolygon& rPolyPoly );
96 
97 
98  // Little helper to encapsulate locking into policy class
99  class LocalGuard
100  {
101  public:
103  aSolarGuard()
104  {
105  }
106 
108  explicit LocalGuard( const ::osl::Mutex& ) :
109  aSolarGuard()
110  {
111  }
112 
113  private:
115  };
116 
118  {
119  public:
120  explicit OutDevStateKeeper( OutputDevice& rOutDev ) :
121  mpOutDev( &rOutDev ),
122  mbMappingWasEnabled( mpOutDev->IsMapModeEnabled() ),
123  mnAntiAliasing( mpOutDev->GetAntialiasing() )
124  {
125  init();
126  }
127 
128  explicit OutDevStateKeeper( const OutDevProviderSharedPtr& rOutDev ) :
129  mpOutDev( rOutDev ? &(rOutDev->getOutDev()) : nullptr ),
130  mbMappingWasEnabled( mpOutDev && mpOutDev->IsMapModeEnabled() ),
131  mnAntiAliasing( mpOutDev ? mpOutDev->GetAntialiasing() : AntialiasingFlags::NONE )
132  {
133  init();
134  }
135 
137  {
138  if( mpOutDev )
139  {
142 
143  mpOutDev->Pop();
144  }
145  }
146 
147  private:
148  void init()
149  {
150  if( mpOutDev )
151  {
152  mpOutDev->Push();
153  mpOutDev->EnableMapMode(false);
154  mpOutDev->SetAntialiasing( AntialiasingFlags::Enable );
155  }
156  }
157 
161  };
162 
163  ::Point mapRealPoint2D( const css::geometry::RealPoint2D& rPoint,
164  const css::rendering::ViewState& rViewState,
165  const css::rendering::RenderState& rRenderState );
166 
167  ::tools::PolyPolygon mapPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly,
168  const css::rendering::ViewState& rViewState,
169  const css::rendering::RenderState& rRenderState );
170 
171  ::BitmapEx transformBitmap( const BitmapEx& rBitmap,
172  const ::basegfx::B2DHomMatrix& rTransform );
173 
175  }
176 }
177 
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::Point mapRealPoint2D(const geometry::RealPoint2D &rPoint, const rendering::ViewState &rViewState, const rendering::RenderState &rRenderState)
Definition: impltools.cxx:158
std::shared_ptr< OutDevProvider > OutDevProviderSharedPtr
void SetAntialiasing(AntialiasingFlags nMode)
::BitmapEx bitmapExFromXBitmap(const uno::Reference< rendering::XBitmap > &xBitmap)
Definition: impltools.cxx:49
OutDevStateKeeper(const OutDevProviderSharedPtr &rOutDev)
Definition: impltools.hxx:128
::BitmapEx transformBitmap(const BitmapEx &rBitmap, const ::basegfx::B2DHomMatrix &rTransform)
Definition: impltools.cxx:188
void EnableMapMode(bool bEnable=true)
OutDevStateKeeper(OutputDevice &rOutDev)
Definition: impltools.hxx:120
SolarMutexGuard aSolarGuard
Definition: impltools.hxx:114
NONE
VclPtr< OutputDevice > mpOutDev
Definition: impltools.hxx:158
bool setupFontTransform(::Point &o_rPoint, vcl::Font &io_rVCLFont, const rendering::ViewState &rViewState, const rendering::RenderState &rRenderState,::OutputDevice const &rOutDev)
Definition: impltools.cxx:87
::tools::PolyPolygon mapPolyPolygon(const ::basegfx::B2DPolyPolygon &rPoly, const rendering::ViewState &rViewState, const rendering::RenderState &rRenderState)
Definition: impltools.cxx:172
AntialiasingFlags
bool isRectangle(const ::tools::PolyPolygon &rPolyPoly)
Predicate, to determine whether polygon is actually an axis-aligned rectangle.
Definition: impltools.cxx:138
const AntialiasingFlags mnAntiAliasing
Definition: impltools.hxx:160
ViewState
LocalGuard(const ::osl::Mutex &)
To be compatible with CanvasBase mutex concept.
Definition: impltools.hxx:108
void Push(PushFlags nFlags=PushFlags::ALL)
void SetDefaultDeviceAntiAliasing(OutputDevice *pDevice)
Definition: impltools.cxx:221