Branch data Line data Source code
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 : :
20 : : #ifndef _SV_REGION_H
21 : : #define _SV_REGION_H
22 : :
23 : : #include <vcl/regband.hxx>
24 : : #include <tools/poly.hxx>
25 : : #include <vcl/region.hxx>
26 : :
27 : : // -----------------
28 : : // - Hilfsmethoden -
29 : : // -----------------
30 : :
31 : : #ifdef DBG_UTIL
32 : : const char* ImplDbgTestRegion( const void* pObj );
33 : : #endif
34 : :
35 : : // --------------------
36 : : // - ImplRegionHandle -
37 : : // --------------------
38 : :
39 : : struct ImplRegionHandle
40 : : {
41 : : Region* mpRegion;
42 : : ImplRegionBand* mpCurrRectBand;
43 : : ImplRegionBandSep* mpCurrRectBandSep;
44 : : sal_Bool mbFirst;
45 : : };
46 : :
47 : : // ------------------
48 : : // - ImplRegionInfo -
49 : : // ------------------
50 : :
51 : : struct ImplRegionInfo
52 : : {
53 : : void* mpVoidCurrRectBand;
54 : : void* mpVoidCurrRectBandSep;
55 : : };
56 : :
57 : : // --------------
58 : : // - ImplRegion -
59 : : // --------------
60 : :
61 : : struct ImplRegionBase
62 : : {
63 : : public:
64 : : ImplRegionBase( int nCount = 1 ); // TODO: replace manual refcounting
65 : : virtual ~ImplRegionBase();
66 : : public:
67 : : sal_uIntPtr mnRefCount;
68 : : sal_uIntPtr mnRectCount;
69 : : PolyPolygon* mpPolyPoly;
70 : : basegfx::B2DPolyPolygon* mpB2DPolyPoly;
71 : : };
72 : :
73 : : class ImplRegion : public ImplRegionBase
74 : : {
75 : : friend class Region;
76 : :
77 : : private:
78 : : ImplRegionBand* mpFirstBand; // root of the list with y-bands
79 : : ImplRegionBand* mpLastCheckedBand;
80 : :
81 : : public:
82 : : ImplRegion();
83 : : ImplRegion( const PolyPolygon& rPolyPoly );
84 : : ImplRegion( const basegfx::B2DPolyPolygon& );
85 : : ImplRegion( const ImplRegion& rImplRegion );
86 : : ~ImplRegion();
87 : :
88 : 136 : ImplRegionBand* ImplGetFirstRegionBand() const { return mpFirstBand; }
89 : : PolyPolygon* ImplGetPolyPoly() const { return mpPolyPoly; }
90 : :
91 : : void CreateBandRange( long nYTop, long nYBottom );
92 : : void InsertBands( long nYTop, long nYBottom );
93 : : sal_Bool InsertSingleBand( ImplRegionBand* mpImplRegionBand,
94 : : long nYBandPosition );
95 : : sal_Bool InsertLine( const Point & rFirstPoint,
96 : : const Point & rSecondPoint,
97 : : long nLineID );
98 : : sal_Bool InsertPoint( const Point &rPoint,
99 : : long nLineID,
100 : : sal_Bool bEndPoint, LineType eLineType );
101 : :
102 : : /** Insert one band either after another band or as the first or only
103 : : band. Both the forward as well as the backward links are updated.
104 : : @param pPreviousBand
105 : : When <NULL/> then pBandToInsert is inserted as first band or as
106 : : only band when there are no other bands.
107 : : When not <NULL/> then pBandToInsert is inserted directly after
108 : : pPreviousBand.
109 : : @param pBandToInsert
110 : : The band to insert.
111 : : */
112 : : void InsertBand (ImplRegionBand* pPreviousBand,
113 : : ImplRegionBand* pBandToInsert);
114 : :
115 : : void Union( long nLeft, long nTop, long nRight, long nBottom );
116 : : void Exclude( long nLeft, long nTop, long nRight, long nBottom );
117 : : void XOr( long nLeft, long nTop, long nRight, long nBottom );
118 : :
119 : : // remove emtpy rects
120 : : sal_Bool OptimizeBandList();
121 : :
122 : : friend SvStream& operator>>( SvStream& rIStm, Region& rRegion );
123 : : friend SvStream& operator<<( SvStream& rOStm, const Region& rRegion );
124 : : };
125 : :
126 : : #endif // _SV_REGION_H
127 : :
128 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|