Coverage Report

Created: 2026-10-14 09:33

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
    SwRects* m_pSubtracted = nullptr;
39
40
    inline void InsertRect( const SwRect &rRect, const sal_uInt16 nPos, bool &rDel);
41
42
public:
43
    // Sets rStartRect as the first element and also the origin area.
44
    explicit SwRegionRects( const SwRect& rStartRect, sal_uInt16 nInit = 20 );
45
    // Empty constructor, does not set elements or origin area. You may
46
    // most likely want to call ChangeOrigin() afterwards.
47
    explicit SwRegionRects( sal_uInt16 nInit = 20 );
48
49
    // Append every rectangle punched from here on, for a caller that wants the pieces a
50
    // selection was built from and not only the region Invert() leaves. Invert() punches
51
    // into a region of its own, so its own work is not recorded.
52
4.64k
    void RecordSubtracted(SwRects* pRects) { m_pSubtracted = pRects; }
53
54
    // For punching from aOrigin.
55
    void operator-=( const SwRect& rRect );
56
    void operator+=( const SwRect& rRect );
57
58
    // From holes to areas, from areas to holes, within the origin area.
59
    void Invert();
60
61
    // Ensures all rectangles are within the origin area.
62
    void LimitToOrigin();
63
64
    enum CompressType { CompressExact, CompressFuzzy };
65
    // Combine adjacent rectangles.
66
    void Compress( CompressType type );
67
68
17.7k
    const SwRect &GetOrigin() const { return m_aOrigin; }
69
2
    void ChangeOrigin( const SwRect &rRect ) { m_aOrigin = rRect; }
70
};
71
72
#endif // INCLUDED_SW_INC_SWREGION_HXX
73
74
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */