Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/inc/swregion.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
#ifndef INCLUDED_SW_INC_SWREGION_HXX
20
#define INCLUDED_SW_INC_SWREGION_HXX
21
22
#include <vector>
23
24
#include "swrect.hxx"
25
26
typedef std::vector<SwRect> SwRects;
27
28
// A collection of rectangles within a given area (origin).
29
// One way to use is to initially set rStartRect, which will set the origin
30
// and the rectangles to rStartRect, and then use operator-= to punch holes.
31
// Other way to use is to use empty constructor, call ChangeOrigin() and
32
// then use operator+= to add rectangles, possibly followed by final
33
// LimitToOrigin() and Compress(). The second way should be faster than
34
// the first way followed by Invert().
35
class SwRegionRects : public SwRects
36
{
37
    SwRect m_aOrigin; // Origin area, limits the total area e.g. for Invert()
38
39
    inline void InsertRect( const SwRect &rRect, const sal_uInt16 nPos, bool &rDel);
40
41
public:
42
    // Sets rStartRect as the first element and also the origin area.
43
    explicit SwRegionRects( const SwRect& rStartRect, sal_uInt16 nInit = 20 );
44
    // Empty constructor, does not set elements or origin area. You may
45
    // most likely want to call ChangeOrigin() afterwards.
46
    explicit SwRegionRects( sal_uInt16 nInit = 20 );
47
48
    // For punching from aOrigin.
49
    void operator-=( const SwRect& rRect );
50
    void operator+=( const SwRect& rRect );
51
52
    // From holes to areas, from areas to holes, within the origin area.
53
    void Invert();
54
55
    // Ensures all rectangles are within the origin area.
56
    void LimitToOrigin();
57
58
    enum CompressType { CompressExact, CompressFuzzy };
59
    // Combine adjacent rectangles.
60
    void Compress( CompressType type );
61
62
2.87k
    const SwRect &GetOrigin() const { return m_aOrigin; }
63
1
    void ChangeOrigin( const SwRect &rRect ) { m_aOrigin = rRect; }
64
};
65
66
#endif // INCLUDED_SW_INC_SWREGION_HXX
67
68
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */