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 .
20 #ifndef _SV_REGBAND_HXX
21 #define _SV_REGBAND_HXX
23 #include <tools/solar.h>
24 #include <tools/poly.hxx>
26 /* =======================================================================
30 This class handles one y-band of the region. In this band may contain one
31 or more seprarations in x-direction. The y-Band do not contain any
32 separation after creation.
34 The separations are modified with basic clipping functions like Union and
35 Intersection - the Class will process the clipping for the actual band.
37 The actual separations may be checked by functions like IsInside or
40 ======================================================================= */
42 // ------------------------
43 // - ImplRegionBand-Types -
44 // ------------------------
46 // element for the list with x-separations
47 struct ImplRegionBandSep
49 ImplRegionBandSep
* mpNextSep
;
55 enum LineType
{ LINE_ASCENDING
, LINE_DESCENDING
, LINE_HORIZONTAL
};
57 // element for the list with x-separations
58 struct ImplRegionBandPoint
60 ImplRegionBandPoint
* mpNextBandPoint
;
74 ImplRegionBand
* mpNextBand
; // pointer to the next element of the list
75 ImplRegionBand
* mpPrevBand
; // pointer to the previous element of the list (only used temporaery)
76 ImplRegionBandSep
* mpFirstSep
; // root of the list with x-separations
77 ImplRegionBandPoint
* mpFirstBandPoint
; // root of the list with lines
78 long mnYTop
; // actual boundary of the band
82 // create y-band with boundaries
83 ImplRegionBand( long nYTop
, long nYBottom
);
84 /** copy y-band with with all data
86 The new ImplRegionBand object will
87 be a copy of this band.
89 When <TRUE/> (the default) the
90 band points pointed to by
91 mpFirstBandPoint are not copied.
92 When <FALSE/> they are copied.
93 You need the points when you are
94 planning to call ProcessPoints()
97 ImplRegionBand( const ImplRegionBand
& theSourceBand
,
98 const bool bIgnorePoints
= true);
101 long GetXLeftBoundary() const;
102 long GetXRightBoundary() const;
104 // combine overlapping bands
105 sal_Bool
OptimizeBand();
107 // generate separations from lines and process
108 // union with existing separations
109 void ProcessPoints();
110 // insert point in the list for later processing
111 sal_Bool
InsertPoint( long nX
, long nLineID
,
112 sal_Bool bEndPoint
, LineType eLineType
);
114 void Union( long nXLeft
, long nXRight
);
115 void Intersect( long nXLeft
, long nXRight
);
116 void Exclude( long nXLeft
, long nXRight
);
117 void XOr( long nXLeft
, long nXRight
);
119 void MoveX( long nHorzMove
);
120 void ScaleX( double fHorzScale
);
122 sal_Bool
IsInside( long nX
);
124 sal_Bool
IsEmpty() const { return ((!mpFirstSep
) && (!mpFirstBandPoint
)); }
126 sal_Bool
operator==( const ImplRegionBand
& rRegionBand
) const;
128 /** Split the called band at the given vertical coordinate. After the
129 split the called band will cover the upper part not including nY.
130 The new band will cover the lower part including nY.
132 The band is split at this y coordinate. The new, lower band
133 will include this very value.
135 Returns the new, lower band.
137 ImplRegionBand
* SplitBand (const sal_Int32 nY
);
140 #endif // _SV_REGBAND_HXX
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */