Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SV_REGBAND_HXX
30 : : #define _SV_REGBAND_HXX
31 : :
32 : : #include <tools/solar.h>
33 : : #include <tools/poly.hxx>
34 : :
35 : : /* =======================================================================
36 : :
37 : : class ImplRegionBand
38 : :
39 : : This class handles one y-band of the region. In this band may contain one
40 : : or more seprarations in x-direction. The y-Band do not contain any
41 : : separation after creation.
42 : :
43 : : The separations are modified with basic clipping functions like Union and
44 : : Intersection - the Class will process the clipping for the actual band.
45 : :
46 : : The actual separations may be checked by functions like IsInside or
47 : : IsOver.
48 : :
49 : : ======================================================================= */
50 : :
51 : : // ------------------------
52 : : // - ImplRegionBand-Types -
53 : : // ------------------------
54 : :
55 : : // element for the list with x-separations
56 : : struct ImplRegionBandSep
57 : : {
58 : : ImplRegionBandSep* mpNextSep;
59 : : long mnXLeft;
60 : : long mnXRight;
61 : : sal_Bool mbRemoved;
62 : : };
63 : :
64 : : enum LineType { LINE_ASCENDING, LINE_DESCENDING, LINE_HORIZONTAL };
65 : :
66 : : // element for the list with x-separations
67 : : struct ImplRegionBandPoint
68 : : {
69 : : ImplRegionBandPoint* mpNextBandPoint;
70 : : long mnX;
71 : : long mnLineId;
72 : : sal_Bool mbEndPoint;
73 : : LineType meLineType;
74 : : };
75 : :
76 : : // ------------------
77 : : // - ImplRegionBand -
78 : : // ------------------
79 : :
80 : : class ImplRegionBand
81 : : {
82 : : public:
83 : : ImplRegionBand* mpNextBand; // pointer to the next element of the list
84 : : ImplRegionBand* mpPrevBand; // pointer to the previous element of the list (only used temporaery)
85 : : ImplRegionBandSep* mpFirstSep; // root of the list with x-separations
86 : : ImplRegionBandPoint* mpFirstBandPoint; // root of the list with lines
87 : : long mnYTop; // actual boundary of the band
88 : : long mnYBottom;
89 : : sal_Bool mbTouched;
90 : :
91 : : // create y-band with boundaries
92 : : ImplRegionBand( long nYTop, long nYBottom );
93 : : /** copy y-band with with all data
94 : : @param theSourceBand
95 : : The new ImplRegionBand object will
96 : : be a copy of this band.
97 : : @param bIgnorePoints
98 : : When <TRUE/> (the default) the
99 : : band points pointed to by
100 : : mpFirstBandPoint are not copied.
101 : : When <FALSE/> they are copied.
102 : : You need the points when you are
103 : : planning to call ProcessPoints()
104 : : later on.
105 : : */
106 : : ImplRegionBand( const ImplRegionBand & theSourceBand,
107 : : const bool bIgnorePoints = true);
108 : : ~ImplRegionBand();
109 : :
110 : : long GetXLeftBoundary() const;
111 : : long GetXRightBoundary() const;
112 : :
113 : : // combine overlapping bands
114 : : sal_Bool OptimizeBand();
115 : :
116 : : // generate separations from lines and process
117 : : // union with existing separations
118 : : void ProcessPoints();
119 : : // insert point in the list for later processing
120 : : sal_Bool InsertPoint( long nX, long nLineID,
121 : : sal_Bool bEndPoint, LineType eLineType );
122 : :
123 : : void Union( long nXLeft, long nXRight );
124 : : void Intersect( long nXLeft, long nXRight );
125 : : void Exclude( long nXLeft, long nXRight );
126 : : void XOr( long nXLeft, long nXRight );
127 : :
128 : : void MoveX( long nHorzMove );
129 : : void ScaleX( double fHorzScale );
130 : :
131 : : sal_Bool IsInside( long nX );
132 : :
133 [ + + ][ + - ]: 3636876 : sal_Bool IsEmpty() const { return ((!mpFirstSep) && (!mpFirstBandPoint)); }
134 : :
135 : : sal_Bool operator==( const ImplRegionBand& rRegionBand ) const;
136 : :
137 : : /** Split the called band at the given vertical coordinate. After the
138 : : split the called band will cover the upper part not including nY.
139 : : The new band will cover the lower part including nY.
140 : : @param nY
141 : : The band is split at this y coordinate. The new, lower band
142 : : will include this very value.
143 : : @return
144 : : Returns the new, lower band.
145 : : */
146 : : ImplRegionBand* SplitBand (const sal_Int32 nY);
147 : : };
148 : :
149 : : #endif // _SV_REGBAND_HXX
150 : :
151 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|