Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/tools/inc/poly.h
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
#pragma once
20
21
#include <sal/types.h>
22
#include <memory>
23
#include <tools/gen.hxx>
24
#include <tools/poly.hxx>
25
26
class SAL_WARN_UNUSED ImplPolygon
27
{
28
public:
29
    std::unique_ptr<Point[]> mxPointAry;
30
    std::unique_ptr<PolyFlags[]> mxFlagAry;
31
    sal_uInt16      mnPoints;
32
33
public:
34
115k
                    ImplPolygon() : mnPoints(0) {}
35
                    ImplPolygon( sal_uInt16 nInitSize );
36
                    ImplPolygon( sal_uInt16 nPoints, const Point* pPtAry, const PolyFlags* pInitFlags );
37
                    ImplPolygon( const ImplPolygon& rImplPoly );
38
                    ImplPolygon( ImplPolygon&& rImplPoly ) noexcept;
39
                    ImplPolygon( const tools::Rectangle& rRect );
40
                    ImplPolygon( const tools::Rectangle& rRect, sal_uInt32 nHorzRound, sal_uInt32 nVertRound);
41
                    ImplPolygon( const Point& rCenter, tools::Long nRadX, tools::Long nRadY );
42
                    ImplPolygon( const tools::Rectangle& rBound, const Point& rStart, const Point& rEnd,
43
                                    PolyStyle eStyle, bool bClockWiseArcDirection );
44
                    ImplPolygon( const Point& aCenter, const sal_uInt32 nRadius,
45
                                    const float fStartAngle, const float fSweepAngle,
46
                                    const bool bClockWiseArcDirection );
47
                    ImplPolygon( const Point& rBezPt1, const Point& rCtrlPt1, const Point& rBezPt2,
48
                                    const Point& rCtrlPt2, sal_uInt16 nPoints );
49
                    ImplPolygon(const basegfx::B2DPolygon& rPolygon);
50
51
    bool            operator==( const ImplPolygon& rCandidate ) const;
52
53
    void            ImplInitSize(sal_uInt16 nInitSize, bool bFlags = false);
54
    void            ImplSetSize( sal_uInt16 nSize, bool bResize = true );
55
    void            ImplCreateFlagArray();
56
    bool            ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon const * pInitPoly = nullptr );
57
};
58
59
#define MAX_POLYGONS        SAL_MAX_UINT16
60
61
struct ImplPolyPolygon
62
{
63
    std::vector<tools::Polygon> mvPolyAry;
64
65
    typedef std::vector<tools::Polygon>::iterator iterator;
66
    typedef std::vector<tools::Polygon>::const_iterator const_iterator;
67
68
    ImplPolyPolygon( sal_uInt16 nInitSize )
69
516k
    {
70
516k
       if ( !nInitSize )
71
508
            nInitSize = 1;
72
516k
       mvPolyAry.reserve(nInitSize);
73
516k
    }
74
75
    ImplPolyPolygon( const tools::Polygon& rPoly )
76
6.25k
    {
77
6.25k
        if ( rPoly.GetSize() )
78
1.40k
            mvPolyAry.push_back(rPoly);
79
4.85k
        else
80
4.85k
            mvPolyAry.reserve(16);
81
6.25k
    }
82
83
    ImplPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon);
84
85
    bool operator==(ImplPolyPolygon const & other) const
86
0
    {
87
0
        return mvPolyAry == other.mvPolyAry;
88
0
    }
89
90
0
    iterator begin() { return mvPolyAry.begin(); }
91
0
    iterator end() { return mvPolyAry.end(); }
92
93
7.07k
    const_iterator begin() const { return mvPolyAry.begin(); }
94
7.07k
    const_iterator end() const { return mvPolyAry.end(); }
95
};
96
97
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */