Coverage Report

Created: 2026-04-09 11:41

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