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 #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 
29 
30 #include <com/sun/star/uno/Reference.hxx>
31 
32 #include "outdevprovider.hxx"
33 
34 
35 class OutputDevice;
36 class Point;
37 class Size;
38 
39 namespace basegfx
40 {
41  namespace matrix
42  {
43  class B2DHomMatrix;
44  }
45 }
46 
47 namespace com { namespace sun { namespace star { namespace awt
48 {
49  struct Point;
50  struct Size;
51  struct Rectangle;
52 } } } }
53 
54 namespace com { namespace sun { namespace star { namespace drawing
55 {
56  struct HomogenMatrix3;
57 } } } }
58 
59 namespace com { namespace sun { namespace star { namespace geometry
60 {
61  struct RealPoint2D;
62  struct RealSize2D;
63  struct RealRectangle2D;
64 } } } }
65 
66 namespace com { namespace sun { namespace star { namespace rendering
67 {
68  struct RenderState;
69  struct ViewState;
70  class XBitmap;
71 } } } }
72 
73 
74 namespace 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 
96  bool isRectangle( const ::tools::PolyPolygon& rPolyPoly );
97 
98 
99  // Little helper to encapsulate locking into policy class
101  {
102  public:
104  aSolarGuard()
105  {
106  }
107 
109  explicit LocalGuard( const ::osl::Mutex& ) :
110  aSolarGuard()
111  {
112  }
113 
114  private:
116  };
117 
119  {
120  public:
121  explicit OutDevStateKeeper( OutputDevice& rOutDev ) :
122  mpOutDev( &rOutDev ),
123  mbMappingWasEnabled( mpOutDev->IsMapModeEnabled() ),
124  mnAntiAliasing( mpOutDev->GetAntialiasing() )
125  {
126  init();
127  }
128 
129  explicit OutDevStateKeeper( const OutDevProviderSharedPtr& rOutDev ) :
130  mpOutDev( rOutDev.get() ? &(rOutDev->getOutDev()) : nullptr ),
131  mbMappingWasEnabled( mpOutDev && mpOutDev->IsMapModeEnabled() ),
132  mnAntiAliasing( mpOutDev ? mpOutDev->GetAntialiasing() : AntialiasingFlags::NONE )
133  {
134  init();
135  }
136 
138  {
139  if( mpOutDev )
140  {
143 
144  mpOutDev->Pop();
145  }
146  }
147 
148  private:
149  void init()
150  {
151  if( mpOutDev )
152  {
153  mpOutDev->Push();
154  mpOutDev->EnableMapMode(false);
155  mpOutDev->SetAntialiasing( AntialiasingFlags::EnableB2dDraw );
156  }
157  }
158 
162  };
163 
164  ::Point mapRealPoint2D( const css::geometry::RealPoint2D& rPoint,
165  const css::rendering::ViewState& rViewState,
166  const css::rendering::RenderState& rRenderState );
167 
168  ::tools::PolyPolygon mapPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly,
169  const css::rendering::ViewState& rViewState,
170  const css::rendering::RenderState& rRenderState );
171 
172  ::BitmapEx transformBitmap( const BitmapEx& rBitmap,
173  const ::basegfx::B2DHomMatrix& rTransform );
174 
175  }
176 }
177 
178 #endif // INCLUDED_CANVAS_SOURCE_VCL_IMPLTOOLS_HXX
179 
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
::Point mapRealPoint2D(const geometry::RealPoint2D &rPoint, const rendering::ViewState &rViewState, const rendering::RenderState &rRenderState)
Definition: impltools.cxx:159
std::shared_ptr< OutDevProvider > OutDevProviderSharedPtr
void SetAntialiasing(AntialiasingFlags nMode)
::BitmapEx bitmapExFromXBitmap(const uno::Reference< rendering::XBitmap > &xBitmap)
Definition: impltools.cxx:50
OutDevStateKeeper(const OutDevProviderSharedPtr &rOutDev)
Definition: impltools.hxx:129
::BitmapEx transformBitmap(const BitmapEx &rBitmap, const ::basegfx::B2DHomMatrix &rTransform)
Definition: impltools.cxx:189
void EnableMapMode(bool bEnable=true)
OutDevStateKeeper(OutputDevice &rOutDev)
Definition: impltools.hxx:121
SolarMutexGuard aSolarGuard
Definition: impltools.hxx:115
VclPtr< OutputDevice > mpOutDev
Definition: impltools.hxx:159
bool setupFontTransform(::Point &o_rPoint, vcl::Font &io_rVCLFont, const rendering::ViewState &rViewState, const rendering::RenderState &rRenderState,::OutputDevice const &rOutDev)
Definition: impltools.cxx:88
NONE
::tools::PolyPolygon mapPolyPolygon(const ::basegfx::B2DPolyPolygon &rPoly, const rendering::ViewState &rViewState, const rendering::RenderState &rRenderState)
Definition: impltools.cxx:173
AntialiasingFlags
bool isRectangle(const ::tools::PolyPolygon &rPolyPoly)
Predicate, to determine whether polygon is actually an axis-aligned rectangle.
Definition: impltools.cxx:139
const AntialiasingFlags mnAntiAliasing
Definition: impltools.hxx:161
ViewState
LocalGuard(const ::osl::Mutex &)
To be compatible with CanvasBase mutex concept.
Definition: impltools.hxx:109
void Push(PushFlags nFlags=PushFlags::ALL)