1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_SWREGION_HXX
20 #define INCLUDED_SW_INC_SWREGION_HXX
26 typedef std::vector
<SwRect
> SwRects
;
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
37 SwRect m_aOrigin
; // Origin area, limits the total area e.g. for Invert()
39 inline void InsertRect( const SwRect
&rRect
, const sal_uInt16 nPos
, bool &rDel
);
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 );
48 // For punching from aOrigin.
49 void operator-=( const SwRect
& rRect
);
50 void operator+=( const SwRect
& rRect
);
52 // From holes to areas, from areas to holes, within the origin area.
55 // Ensures all rectangles are within the origin area.
58 enum CompressType
{ CompressExact
, CompressFuzzy
};
59 // Combine adjacent rectangles.
60 void Compress( CompressType type
);
62 const SwRect
&GetOrigin() const { return m_aOrigin
; }
63 void ChangeOrigin( const SwRect
&rRect
) { m_aOrigin
= rRect
; }
66 #endif // INCLUDED_SW_INC_SWREGION_HXX
68 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */