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 : : #ifndef _XPOLY_HXX
29 : : #define _XPOLY_HXX
30 : :
31 : : #include <tools/solar.h>
32 : : #include <basegfx/polygon/b2dpolypolygon.hxx>
33 : : #include "svx/svxdllapi.h"
34 : :
35 : : class Point;
36 : : class Rectangle;
37 : : class SvStream;
38 : : class Polygon;
39 : : class PolyPolygon;
40 : : class OutputDevice;
41 : :
42 : : /************************************************************************/
43 : :
44 : : #define XPOLYPOLY_APPEND 0xFFFF
45 : : #define XPOLY_APPEND 0xFFFF
46 : :
47 : : #define XPOLY_MAXPOINTS 0xFFF0 /* Auch fuer die 32-Bitter etwas Luft lassen */
48 : :
49 : : /************************************************************************/
50 : : // Punktstile im XPolygon:
51 : : // NORMAL : Anfangs- oder Endpunkt einer Kurve oder Linie
52 : : // SMOOTH : Glatter Uebergang zwischen Kurven
53 : : // SYMMTR : glatter und symmetrischer Uebergang zwischen Kurven
54 : : // CONTROL: Kontrollpunkt einer Bezierkurve
55 : :
56 : : enum XPolyFlags { XPOLY_NORMAL, XPOLY_SMOOTH, XPOLY_CONTROL, XPOLY_SYMMTR };
57 : :
58 : :
59 : : /*************************************************************************
60 : : |*
61 : : |* Klasse XPolygon; hat neben dem Point-Array noch ein Array mit Flags,
62 : : |* die Informationen ueber den jeweiligen Punkt enthalten
63 : : |*
64 : : \************************************************************************/
65 : :
66 : : class ImpXPolygon;
67 : :
68 : : class SVX_DLLPUBLIC XPolygon
69 : : {
70 : : protected:
71 : : ImpXPolygon* pImpXPolygon;
72 : :
73 : : // ImpXPolygon-ReferenceCount pruefen und ggf. abkoppeln
74 : : void CheckReference();
75 : :
76 : : // Hilfsfunktionen fuer Bezierkonvertierung
77 : : void SubdivideBezier(sal_uInt16 nPos, sal_Bool bCalcFirst, double fT);
78 : : void GenBezArc(const Point& rCenter, long nRx, long nRy,
79 : : long nXHdl, long nYHdl, sal_uInt16 nStart, sal_uInt16 nEnd,
80 : : sal_uInt16 nQuad, sal_uInt16 nFirst);
81 : : sal_Bool CheckAngles(sal_uInt16& nStart, sal_uInt16 nEnd, sal_uInt16& nA1, sal_uInt16& nA2);
82 : :
83 : : public:
84 : : XPolygon( sal_uInt16 nSize=16, sal_uInt16 nResize=16 );
85 : : XPolygon( const XPolygon& rXPoly );
86 : : XPolygon( const Rectangle& rRect, long nRx = 0, long nRy = 0 );
87 : : XPolygon( const Point& rCenter, long nRx, long nRy,
88 : : sal_uInt16 nStartAngle = 0, sal_uInt16 nEndAngle = 3600,
89 : : sal_Bool bClose = sal_True );
90 : :
91 : : ~XPolygon();
92 : :
93 : : void SetPointCount( sal_uInt16 nPoints );
94 : : sal_uInt16 GetPointCount() const;
95 : :
96 : : void Insert( sal_uInt16 nPos, const Point& rPt, XPolyFlags eFlags );
97 : : void Insert( sal_uInt16 nPos, const XPolygon& rXPoly );
98 : : void Remove( sal_uInt16 nPos, sal_uInt16 nCount );
99 : : void Move( long nHorzMove, long nVertMove );
100 : : Rectangle GetBoundRect() const;
101 : :
102 : : const Point& operator[]( sal_uInt16 nPos ) const;
103 : : Point& operator[]( sal_uInt16 nPos );
104 : : XPolygon& operator=( const XPolygon& rXPoly );
105 : : sal_Bool operator==( const XPolygon& rXPoly ) const;
106 : : sal_Bool operator!=( const XPolygon& rXPoly ) const;
107 : :
108 : : XPolyFlags GetFlags( sal_uInt16 nPos ) const;
109 : : void SetFlags( sal_uInt16 nPos, XPolyFlags eFlags );
110 : : sal_Bool IsControl(sal_uInt16 nPos) const;
111 : : sal_Bool IsSmooth(sal_uInt16 nPos) const;
112 : :
113 : : // Abstand zwischen zwei Punkten
114 : : double CalcDistance(sal_uInt16 nP1, sal_uInt16 nP2);
115 : :
116 : : // Bezierkonvertierungen
117 : : void CalcSmoothJoin(sal_uInt16 nCenter, sal_uInt16 nDrag, sal_uInt16 nPnt);
118 : : void CalcTangent(sal_uInt16 nCenter, sal_uInt16 nPrev, sal_uInt16 nNext);
119 : : void PointsToBezier(sal_uInt16 nFirst);
120 : :
121 : : // Transformationen
122 : : void Translate(const Point& rTrans);
123 : : void Scale(double fSx, double fSy);
124 : : void Distort(const Rectangle& rRefRect, const XPolygon& rDistortedRect);
125 : :
126 : : // #116512# convert to basegfx::B2DPolygon and return
127 : : basegfx::B2DPolygon getB2DPolygon() const;
128 : :
129 : : // #116512# constructor to convert from basegfx::B2DPolygon
130 : : // #i76339# made explicit
131 : : explicit XPolygon(const basegfx::B2DPolygon& rPolygon);
132 : : };
133 : :
134 : : /*************************************************************************
135 : : |*
136 : : |* Klasse XPolyPolygon; wie PolyPolygon, nur statt aus Polygonen aus
137 : : |* XPolygonen bestehend
138 : : |*
139 : : \************************************************************************/
140 : :
141 : : class ImpXPolyPolygon;
142 : :
143 : : class SVX_DLLPUBLIC XPolyPolygon
144 : : {
145 : : protected:
146 : : ImpXPolyPolygon* pImpXPolyPolygon;
147 : :
148 : : // ImpXPolyPolygon-ReferenceCount pruefen und ggf. abkoppeln
149 : : void CheckReference();
150 : :
151 : : public:
152 : : XPolyPolygon( sal_uInt16 nInitSize = 16, sal_uInt16 nResize = 16 );
153 : : XPolyPolygon( const XPolyPolygon& rXPolyPoly );
154 : :
155 : : ~XPolyPolygon();
156 : :
157 : : void Insert( const XPolygon& rXPoly,
158 : : sal_uInt16 nPos = XPOLYPOLY_APPEND );
159 : : void Insert( const XPolyPolygon& rXPoly,
160 : : sal_uInt16 nPos=XPOLYPOLY_APPEND );
161 : : XPolygon Remove( sal_uInt16 nPos );
162 : : const XPolygon& GetObject( sal_uInt16 nPos ) const;
163 : :
164 : : void Clear();
165 : : sal_uInt16 Count() const;
166 : :
167 : : Rectangle GetBoundRect() const;
168 : :
169 : 0 : const XPolygon& operator[]( sal_uInt16 nPos ) const
170 : 0 : { return GetObject( nPos ); }
171 : : XPolygon& operator[]( sal_uInt16 nPos );
172 : :
173 : : XPolyPolygon& operator=( const XPolyPolygon& rXPolyPoly );
174 : : sal_Bool operator==( const XPolyPolygon& rXPolyPoly ) const;
175 : : sal_Bool operator!=( const XPolyPolygon& rXPolyPoly ) const;
176 : :
177 : : // Transformationen
178 : : void Distort(const Rectangle& rRefRect, const XPolygon& rDistortedRect);
179 : :
180 : : // #116512# convert to basegfx::B2DPolyPolygon and return
181 : : basegfx::B2DPolyPolygon getB2DPolyPolygon() const;
182 : :
183 : : // #116512# constructor to convert from basegfx::B2DPolyPolygon
184 : : // #i76339# made explicit
185 : : explicit XPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon);
186 : : };
187 : :
188 : : #endif // _XPOLY_HXX
189 : :
190 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|