Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/GraphicAttributes.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 <tools/degree.hxx>
23
#include <vcl/dllapi.h>
24
#include <vcl/bitmap.hxx>
25
26
// Represents css::drawing::ColorMode
27
enum class GraphicDrawMode
28
{
29
    Standard = 0,
30
    Greys = 1,
31
    Mono = 2,
32
    Watermark = 3
33
};
34
35
class VCL_DLLPUBLIC GraphicAttr
36
{
37
private:
38
    double mfGamma;
39
    tools::Long mnLeftCrop;
40
    tools::Long mnTopCrop;
41
    tools::Long mnRightCrop;
42
    tools::Long mnBottomCrop;
43
    BmpMirrorFlags mnMirrFlags;
44
    GraphicDrawMode meDrawMode;
45
    Degree10 mnRotate10;
46
    short mnContPercent;
47
    short mnLumPercent;
48
    short mnRPercent;
49
    short mnGPercent;
50
    short mnBPercent;
51
    sal_uInt8 mcAlpha;
52
    bool mbInvert;
53
54
public:
55
    GraphicAttr()
56
320k
        : mfGamma(1.0)
57
320k
        , mnLeftCrop(0)
58
320k
        , mnTopCrop(0)
59
320k
        , mnRightCrop(0)
60
320k
        , mnBottomCrop(0)
61
320k
        , mnMirrFlags(BmpMirrorFlags::NONE)
62
320k
        , meDrawMode(GraphicDrawMode::Standard)
63
320k
        , mnRotate10(0)
64
320k
        , mnContPercent(0)
65
320k
        , mnLumPercent(0)
66
320k
        , mnRPercent(0)
67
320k
        , mnGPercent(0)
68
320k
        , mnBPercent(0)
69
320k
        , mcAlpha(255)
70
320k
        , mbInvert(false)
71
320k
    {
72
320k
    }
73
74
    bool operator==(const GraphicAttr& rAttr) const
75
47.3k
    {
76
47.3k
        return mfGamma == rAttr.mfGamma && mnMirrFlags == rAttr.mnMirrFlags
77
47.3k
               && mnLeftCrop == rAttr.mnLeftCrop && mnTopCrop == rAttr.mnTopCrop
78
47.3k
               && mnRightCrop == rAttr.mnRightCrop && mnBottomCrop == rAttr.mnBottomCrop
79
47.3k
               && mnRotate10 == rAttr.mnRotate10 && mnContPercent == rAttr.mnContPercent
80
47.3k
               && mnLumPercent == rAttr.mnLumPercent && mnRPercent == rAttr.mnRPercent
81
47.3k
               && mnGPercent == rAttr.mnGPercent && mnBPercent == rAttr.mnBPercent
82
47.3k
               && mbInvert == rAttr.mbInvert && mcAlpha == rAttr.mcAlpha
83
47.3k
               && meDrawMode == rAttr.meDrawMode;
84
47.3k
    }
85
86
0
    bool operator!=(const GraphicAttr& rAttr) const { return !(*this == rAttr); }
87
88
514
    void SetDrawMode(GraphicDrawMode eDrawMode) { meDrawMode = eDrawMode; }
89
548
    GraphicDrawMode GetDrawMode() const { return meDrawMode; }
90
91
978
    void SetMirrorFlags(BmpMirrorFlags nMirrFlags) { mnMirrFlags = nMirrFlags; }
92
860
    BmpMirrorFlags GetMirrorFlags() const { return mnMirrFlags; }
93
94
    void SetCrop(tools::Long nLeft_100TH_MM, tools::Long nTop_100TH_MM, tools::Long nRight_100TH_MM,
95
                 tools::Long nBottom_100TH_MM)
96
1.06k
    {
97
1.06k
        mnLeftCrop = nLeft_100TH_MM;
98
1.06k
        mnTopCrop = nTop_100TH_MM;
99
1.06k
        mnRightCrop = nRight_100TH_MM;
100
1.06k
        mnBottomCrop = nBottom_100TH_MM;
101
1.06k
    }
102
12
    tools::Long GetLeftCrop() const { return mnLeftCrop; }
103
12
    tools::Long GetTopCrop() const { return mnTopCrop; }
104
12
    tools::Long GetRightCrop() const { return mnRightCrop; }
105
12
    tools::Long GetBottomCrop() const { return mnBottomCrop; }
106
107
1.06k
    void SetRotation(Degree10 nRotate10) { mnRotate10 = nRotate10; }
108
0
    Degree10 GetRotation() const { return mnRotate10; }
109
110
514
    void SetLuminance(short nLuminancePercent) { mnLumPercent = nLuminancePercent; }
111
0
    short GetLuminance() const { return mnLumPercent; }
112
113
514
    void SetContrast(short nContrastPercent) { mnContPercent = nContrastPercent; }
114
0
    short GetContrast() const { return mnContPercent; }
115
116
514
    void SetChannelR(short nChannelRPercent) { mnRPercent = nChannelRPercent; }
117
0
    short GetChannelR() const { return mnRPercent; }
118
119
514
    void SetChannelG(short nChannelGPercent) { mnGPercent = nChannelGPercent; }
120
0
    short GetChannelG() const { return mnGPercent; }
121
122
514
    void SetChannelB(short nChannelBPercent) { mnBPercent = nChannelBPercent; }
123
0
    short GetChannelB() const { return mnBPercent; }
124
125
514
    void SetGamma(double fGamma) { mfGamma = fGamma; }
126
0
    double GetGamma() const { return mfGamma; }
127
128
514
    void SetInvert(bool bInvert) { mbInvert = bInvert; }
129
0
    bool IsInvert() const { return mbInvert; }
130
131
1.11k
    void SetAlpha(sal_uInt8 cAlpha) { mcAlpha = cAlpha; }
132
1.33k
    sal_uInt8 GetAlpha() const { return mcAlpha; }
133
134
73
    bool IsSpecialDrawMode() const { return (meDrawMode != GraphicDrawMode::Standard); }
135
548
    bool IsMirrored() const { return mnMirrFlags != BmpMirrorFlags::NONE; }
136
    bool IsCropped() const
137
123
    {
138
123
        return (mnLeftCrop != 0 || mnTopCrop != 0 || mnRightCrop != 0 || mnBottomCrop != 0);
139
123
    }
140
0
    bool IsRotated() const { return ((mnRotate10 % 3600_deg10) != 0_deg10); }
141
0
    bool IsTransparent() const { return (mcAlpha < 255); }
142
    bool IsAdjusted() const
143
621
    {
144
621
        return (mnLumPercent != 0 || mnContPercent != 0 || mnRPercent != 0 || mnGPercent != 0
145
621
                || mnBPercent != 0 || mfGamma != 1.0 || mbInvert);
146
621
    }
147
};
148
149
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */