LibreOffice Module svx (master) 1
xpoly.hxx
Go to the documentation of this file.
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#ifndef INCLUDED_SVX_XPOLY_HXX
20#define INCLUDED_SVX_XPOLY_HXX
21
23#include <svx/svxdllapi.h>
24#include <o3tl/cow_wrapper.hxx>
25#include <tools/poly.hxx>
26#include <tools/degree.hxx>
27
28class Point;
29namespace tools { class Rectangle; }
30class SvStream;
31namespace tools {
32 class Polygon;
33 class PolyPolygon;
34}
35class OutputDevice;
36
37#define XPOLYPOLY_APPEND 0xFFFF
38#define XPOLY_APPEND 0xFFFF
39
40
41// Class XPolygon has a point-array and a flag-array, which contains information about a particular point
42
43class ImpXPolygon;
44
46{
48
49 // auxiliary functions for Bezier conversion
50 void SubdivideBezier(sal_uInt16 nPos, bool bCalcFirst, double fT);
51 void GenBezArc(const Point& rCenter, tools::Long nRx, tools::Long nRy,
52 tools::Long nXHdl, tools::Long nYHdl, Degree100 nStart, Degree100 nEnd,
53 sal_uInt16 nQuad, sal_uInt16 nFirst);
54 static bool CheckAngles(Degree100& nStart, Degree100 nEnd, Degree100& nA1, Degree100& nA2);
55
56public:
57 XPolygon( sal_uInt16 nSize=16 );
58 XPolygon( const XPolygon& );
60 XPolygon( const tools::Polygon& rPoly );
61 XPolygon( const tools::Rectangle& rRect, tools::Long nRx = 0, tools::Long nRy = 0 );
62 XPolygon( const Point& rCenter, tools::Long nRx, tools::Long nRy,
63 Degree100 nStartAngle = 0_deg100, Degree100 nEndAngle = 36000_deg100,
64 bool bClose = true );
65
67
68 sal_uInt16 GetSize() const;
69
70 void SetPointCount( sal_uInt16 nPoints );
71 sal_uInt16 GetPointCount() const;
72
73 void Insert( sal_uInt16 nPos, const Point& rPt, PolyFlags eFlags );
74 void Insert( sal_uInt16 nPos, const XPolygon& rXPoly );
75 void Remove( sal_uInt16 nPos, sal_uInt16 nCount );
76 void Move( tools::Long nHorzMove, tools::Long nVertMove );
77 tools::Rectangle GetBoundRect() const;
78
79 const Point& operator[]( sal_uInt16 nPos ) const;
80 Point& operator[]( sal_uInt16 nPos );
83 bool operator==( const XPolygon& rXPoly ) const;
84
85 PolyFlags GetFlags( sal_uInt16 nPos ) const;
86 void SetFlags( sal_uInt16 nPos, PolyFlags eFlags );
87 bool IsControl(sal_uInt16 nPos) const;
88 bool IsSmooth(sal_uInt16 nPos) const;
89
90 // distance between two points
91 double CalcDistance(sal_uInt16 nP1, sal_uInt16 nP2);
92
93 // Bezier conversion
94 void CalcSmoothJoin(sal_uInt16 nCenter, sal_uInt16 nDrag, sal_uInt16 nPnt);
95 void CalcTangent(sal_uInt16 nCenter, sal_uInt16 nPrev, sal_uInt16 nNext);
96 void PointsToBezier(sal_uInt16 nFirst);
97
98 // transformations
99 void Scale(double fSx, double fSy);
100 void Distort(const tools::Rectangle& rRefRect, const XPolygon& rDistortedRect);
101
102 // #116512# convert to basegfx::B2DPolygon and return
103 basegfx::B2DPolygon getB2DPolygon() const;
104
105 // #116512# constructor to convert from basegfx::B2DPolygon
106 // #i76339# made explicit
107 explicit XPolygon(const basegfx::B2DPolygon& rPolygon);
108};
109
110// Class XPolyPolygon; like PolyPolygon, composed of XPolygons instead of Polygons
111
112class ImpXPolyPolygon;
113
114class XPolyPolygon final
115{
117
118public:
122
124
125 void Insert( XPolygon&& rXPoly );
126 void Insert( const XPolyPolygon& rXPoly );
127 void Remove( sal_uInt16 nPos );
128 const XPolygon& GetObject( sal_uInt16 nPos ) const;
129
130 void Clear();
131 sal_uInt16 Count() const;
132
134
135 const XPolygon& operator[]( sal_uInt16 nPos ) const
136 { return GetObject( nPos ); }
137 XPolygon& operator[]( sal_uInt16 nPos );
138
141
142 // transformations
143 void Distort(const tools::Rectangle& rRefRect, const XPolygon& rDistortedRect);
144
145 // #116512# convert to basegfx::B2DPolyPolygon and return
147
148 // #116512# constructor to convert from basegfx::B2DPolyPolygon
149 // #i76339# made explicit
150 explicit XPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon);
151};
152
153#endif // INCLUDED_SVX_XPOLY_HXX
154
155/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
o3tl::cow_wrapper< ImpXPolyPolygon > pImpXPolyPolygon
Definition: xpoly.hxx:116
tools::Rectangle GetBoundRect() const
Definition: _xpoly.cxx:890
const XPolygon & operator[](sal_uInt16 nPos) const
Definition: xpoly.hxx:135
void Clear()
Definition: _xpoly.cxx:880
void Remove(sal_uInt16 nPos)
Definition: _xpoly.cxx:870
basegfx::B2DPolyPolygon getB2DPolyPolygon() const
Definition: _xpoly.cxx:930
XPolyPolygon & operator=(const XPolyPolygon &)
XPolyPolygon & operator=(XPolyPolygon &&)
void Insert(XPolygon &&rXPoly)
Definition: _xpoly.cxx:856
XPolyPolygon(XPolyPolygon &&)
XPolyPolygon(const XPolyPolygon &)
const XPolygon & GetObject(sal_uInt16 nPos) const
Definition: _xpoly.cxx:875
sal_uInt16 Count() const
Definition: _xpoly.cxx:885
void Distort(const tools::Rectangle &rRefRect, const XPolygon &rDistortedRect)
Distort a polygon by scaling its coordinates relative to a reference rectangle into an arbitrary rect...
Definition: _xpoly.cxx:923
XPolygon(XPolygon &&)
XPolygon & operator=(const XPolygon &)
XPolygon & operator=(XPolygon &&)
XPolygon(const XPolygon &)
o3tl::cow_wrapper< ImpXPolygon > pImpXPolygon
Definition: xpoly.hxx:47
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName) override
void SetFlags(EVControlBits &rBits, EVControlBits nMask, bool bOn)
sal_uInt16 nPos
long Long
PolyFlags
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)