Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/mapmod.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
#ifndef INCLUDED_VCL_MAPMOD_HXX
21
#define INCLUDED_VCL_MAPMOD_HXX
22
23
#include <vcl/dllapi.h>
24
#include <o3tl/cow_wrapper.hxx>
25
26
#include <ostream>
27
28
class Point;
29
enum class MapUnit : sal_uInt8;
30
31
class SAL_WARN_UNUSED VCL_DLLPUBLIC MapMode
32
{
33
    friend class        OutputDevice;
34
35
public:
36
    struct SAL_DLLPRIVATE ImplMapMode;
37
38
    MapMode();
39
    MapMode( const MapMode& rMapMode );
40
    explicit MapMode( MapUnit eUnit );
41
    MapMode( MapUnit eUnit, const Point& rLogicOrg, double fScaleX, double fScaleY );
42
    ~MapMode();
43
44
    void            SetMapUnit( MapUnit eUnit );
45
    MapUnit         GetMapUnit() const;
46
47
    void            SetOrigin( const Point& rOrigin );
48
    const Point&    GetOrigin() const;
49
50
    void            SetScaleX( double fScaleX );
51
    double          GetScaleX() const;
52
    void            SetScaleY( double fScaleY );
53
    double          GetScaleY() const;
54
55
    MapMode&        operator=( const MapMode& rMapMode );
56
    MapMode&        operator=( MapMode&& rMapMode );
57
    bool            operator==( const MapMode& rMapMode ) const;
58
    bool            operator!=( const MapMode& rMapMode ) const
59
342k
    {
60
342k
        return !(MapMode::operator==( rMapMode ));
61
342k
    }
62
    bool            IsDefault() const;
63
64
    // Compute value usable as hash.
65
    size_t          GetHashValue() const;
66
67
    // tdf#117984 needs to be thread-safe due to being used e.g. in Bitmaps
68
    // vcl::ScopedBitmapAccess in parallelized 3D renderer
69
    typedef o3tl::cow_wrapper< ImplMapMode, o3tl::ThreadSafeRefCountingPolicy > ImplType;
70
71
    // If only the map unit is set.
72
    bool IsSimple() const;
73
74
private:
75
    ImplType        mpImplMapMode;
76
};
77
78
template<typename charT, typename traits>
79
inline std::basic_ostream<charT, traits> & operator <<(
80
    std::basic_ostream<charT, traits> & rStream, const MapMode& rMode)
81
{
82
    rStream << "MapMode(" << static_cast<unsigned>(rMode.GetMapUnit()) << ",(" << rMode.GetScaleX() << "," << rMode.GetScaleY() << ")@(" << rMode.GetOrigin() << "))";
83
    return rStream;
84
}
85
86
#endif // INCLUDED_VCL_MAPMOD_HXX
87
88
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */