Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/vcl/inc/regband.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/long.hxx>
23
24
/*
25
26
class ImplRegionBand
27
28
This class handles one y-band of the region. In this band may contain one
29
or more separations in x-direction. The y-Band do not contain any
30
separation after creation.
31
32
The separations are modified with basic clipping functions like Union and
33
Intersection - the Class will process the clipping for the actual band.
34
35
*/
36
37
// element for the list with x-separations
38
struct ImplRegionBandSep
39
{
40
    ImplRegionBandSep*          mpNextSep;
41
    tools::Long                        mnXLeft;
42
    tools::Long                        mnXRight;
43
    bool                        mbRemoved;
44
};
45
46
enum class LineType { Ascending, Descending };
47
48
// element for the list with x-separations
49
struct ImplRegionBandPoint
50
{
51
    ImplRegionBandPoint*        mpNextBandPoint;
52
    tools::Long                        mnX;
53
    tools::Long                        mnLineId;
54
    bool                        mbEndPoint;
55
    LineType                    meLineType;
56
};
57
58
class ImplRegionBand
59
{
60
public:
61
    ImplRegionBand*             mpNextBand;         // pointer to the next element of the list
62
    ImplRegionBand*             mpPrevBand;         // pointer to the previous element of the list (only used temporarily)
63
    ImplRegionBandSep*          mpFirstSep;         // root of the list with x-separations
64
    ImplRegionBandPoint*        mpFirstBandPoint;   // root of the list with lines
65
    tools::Long                        mnYTop;             // actual boundary of the band
66
    tools::Long                        mnYBottom;
67
68
    bool                        mbTouched : 1;
69
70
                                // create y-band with boundaries
71
                                ImplRegionBand( tools::Long nYTop, tools::Long nYBottom );
72
                                /** copy y-band with all data
73
                                    @param theSourceBand
74
                                        The new ImplRegionBand object will
75
                                        be a copy of this band.
76
                                    @param bIgnorePoints
77
                                        When true (the default) the
78
                                        band points pointed to by
79
                                        mpFirstBandPoint are not copied.
80
                                        When false they are copied.
81
                                        You need the points when you are
82
                                        planning to call ProcessPoints()
83
                                        later on.
84
                                */
85
                                ImplRegionBand( const ImplRegionBand & theSourceBand,
86
                                                const bool bIgnorePoints = true);
87
                                ~ImplRegionBand();
88
89
    tools::Long                        GetXLeftBoundary() const;
90
    tools::Long                        GetXRightBoundary() const;
91
92
                                // combine overlapping bands
93
    void                        OptimizeBand();
94
95
                                // generate separations from lines and process
96
                                // union with existing separations
97
    void                        ProcessPoints();
98
                                // insert point in the list for later processing
99
    bool                        InsertPoint( tools::Long nX, tools::Long nLineID,
100
                                             bool bEndPoint, LineType eLineType );
101
102
    void                        Union( tools::Long nXLeft, tools::Long nXRight );
103
    void                        Intersect( tools::Long nXLeft, tools::Long nXRight );
104
    void                        Exclude( tools::Long nXLeft, tools::Long nXRight );
105
    void                        XOr( tools::Long nXLeft, tools::Long nXRight );
106
107
    void                        MoveX( tools::Long nHorzMove );
108
    void                        ScaleX( double fHorzScale );
109
110
    bool                        Contains( tools::Long nX );
111
112
207k
    bool                        IsEmpty() const { return ((!mpFirstSep) && (!mpFirstBandPoint)); }
113
114
    bool                        operator==( const ImplRegionBand& rRegionBand ) const;
115
116
    /** Split the called band at the given vertical coordinate.  After the
117
        split the called band will cover the upper part not including nY.
118
        The new band will cover the lower part including nY.
119
        @param nY
120
            The band is split at this y coordinate.  The new, lower band
121
            will include this very value.
122
        @return
123
            Returns the new, lower band.
124
    */
125
    ImplRegionBand*             SplitBand (const sal_Int32 nY);
126
};
127
128
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */