20#include <com/sun/star/geometry/RealSize2D.hpp>
21#include <com/sun/star/geometry/RealPoint2D.hpp>
22#include <com/sun/star/geometry/RealRectangle2D.hpp>
23#include <com/sun/star/geometry/RealRectangle3D.hpp>
24#include <com/sun/star/geometry/RealBezierSegment2D.hpp>
25#include <com/sun/star/geometry/AffineMatrix2D.hpp>
26#include <com/sun/star/geometry/AffineMatrix3D.hpp>
27#include <com/sun/star/geometry/IntegerSize2D.hpp>
28#include <com/sun/star/geometry/IntegerRectangle2D.hpp>
29#include <com/sun/star/lang/IllegalArgumentException.hpp>
30#include <com/sun/star/rendering/XPolyPolygon2D.hpp>
31#include <com/sun/star/rendering/XGraphicDevice.hpp>
32#include <com/sun/star/awt/Rectangle.hpp>
51 uno::Sequence< geometry::RealBezierSegment2D > bezierSequenceFromB2DPolygon(const ::basegfx::B2DPolygon& rPoly)
53 const sal_uInt32 nPointCount(rPoly.count());
54 uno::Sequence< geometry::RealBezierSegment2D > outputSequence(nPointCount);
55 geometry::RealBezierSegment2D* pOutput = outputSequence.getArray();
58 for(sal_uInt32
a(0);
a < nPointCount;
a++)
64 pOutput[
a] = geometry::RealBezierSegment2D(
70 return outputSequence;
73 uno::Sequence< geometry::RealPoint2D > pointSequenceFromB2DPolygon( const ::basegfx::B2DPolygon& rPoly )
75 const sal_uInt32 nNumPoints( rPoly.count() );
77 uno::Sequence< geometry::RealPoint2D > outputSequence( nNumPoints );
78 geometry::RealPoint2D* pOutput = outputSequence.getArray();
82 for(
i=0;
i<nNumPoints; ++
i )
84 const ::basegfx::B2DPoint aPoint( rPoly.getB2DPoint(
i) );
86 pOutput[
i] = geometry::RealPoint2D( aPoint.getX(),
90 return outputSequence;
96 const sal_uInt32 nNumPolies( rPolyPoly.count() );
99 uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > > outputSequence( nNumPolies );
100 uno::Sequence< geometry::RealBezierSegment2D >* pOutput = outputSequence.getArray();
102 for(
i=0;
i<nNumPolies; ++
i )
104 pOutput[
i] = bezierSequenceFromB2DPolygon( rPolyPoly.getB2DPolygon(
i) );
107 return outputSequence;
112 const sal_uInt32 nNumPolies( rPolyPoly.count() );
115 uno::Sequence< uno::Sequence< geometry::RealPoint2D > > outputSequence( nNumPolies );
116 uno::Sequence< geometry::RealPoint2D >* pOutput = outputSequence.getArray();
118 for(
i=0;
i<nNumPolies; ++
i )
120 pOutput[
i] = pointSequenceFromB2DPolygon( rPolyPoly.getB2DPolygon(
i) );
123 return outputSequence;
127 const ::basegfx::B2DPolygon& rPoly )
129 uno::Reference< rendering::XPolyPolygon2D > xRes;
131 if( !xGraphicDevice.is() )
134 if( rPoly.areControlPointsUsed() )
136 uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > > outputSequence{ bezierSequenceFromB2DPolygon( rPoly )};
138 xRes = xGraphicDevice->createCompatibleBezierPolyPolygon( outputSequence );
142 uno::Sequence< uno::Sequence< geometry::RealPoint2D > > outputSequence{
143 pointSequenceFromB2DPolygon( rPoly )};
145 xRes = xGraphicDevice->createCompatibleLinePolyPolygon( outputSequence );
148 if( xRes.is() && rPoly.isClosed() )
149 xRes->setClosed( 0,
true );
155 const ::basegfx::B2DPolyPolygon& rPolyPoly )
157 uno::Reference< rendering::XPolyPolygon2D > xRes;
159 if( !xGraphicDevice.is() )
162 const sal_uInt32 nNumPolies( rPolyPoly.count() );
165 if( rPolyPoly.areControlPointsUsed() )
167 xRes = xGraphicDevice->createCompatibleBezierPolyPolygon(
172 xRes = xGraphicDevice->createCompatibleLinePolyPolygon(
176 for(
i=0;
i<nNumPolies; ++
i )
178 xRes->setClosed(
i, rPolyPoly.getB2DPolygon(
i).isClosed() );
186 const sal_Int32 nCurrSize( points.getLength() );
190 for( sal_Int32 nCurrPoint=0; nCurrPoint<nCurrSize; ++nCurrPoint )
200 for(
const auto &
p : points )
210 const sal_Int32 nSize(curves.getLength());
217 const geometry::RealBezierSegment2D& rFirstSegment(curves[0]);
220 for(sal_Int32
a(0);
a < nSize;
a++)
222 const geometry::RealBezierSegment2D& rCurrSegment(curves[
a]);
223 const geometry::RealBezierSegment2D& rNextSegment(curves[(
a + 1) % nSize]);
244 for(
const auto & c : curves )
265 const sal_Int32 nPolys( xPoly->getNumberOfPolygons() );
267 uno::Reference< rendering::XBezierPolyPolygon2D > xBezierPoly(
271 if( xBezierPoly.is() )
274 xBezierPoly->getBezierSegments( 0,
281 uno::Reference< rendering::XLinePolyPolygon2D > xLinePoly(
287 if( !xLinePoly.is() )
289 throw lang::IllegalArgumentException(
290 "basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(): Invalid input"
291 "poly-polygon, cannot retrieve vertex data",
292 uno::Reference< uno::XInterface >(),
297 xLinePoly->getPoints( 0,
306 const geometry::AffineMatrix2D& input )
311 output.
set(0,0, input.m00);
312 output.
set(0,1, input.m01);
313 output.
set(0,2, input.m02);
314 output.
set(1,0, input.m10);
315 output.
set(1,1, input.m11);
316 output.
set(1,2, input.m12);
325 output.
set(0,0, input.m00);
326 output.
set(0,1, input.m01);
327 output.
set(0,2, input.m02);
328 output.
set(0,3, input.m03);
330 output.
set(1,0, input.m10);
331 output.
set(1,1, input.m11);
332 output.
set(1,2, input.m12);
333 output.
set(1,3, input.m13);
335 output.
set(2,0, input.m20);
336 output.
set(2,1, input.m21);
337 output.
set(2,2, input.m22);
338 output.
set(2,3, input.m23);
344 const ::basegfx::B2DHomMatrix& input)
346 output.m00 = input.get(0,0);
347 output.m01 = input.get(0,1);
348 output.m02 = input.get(0,2);
349 output.m10 = input.get(1,0);
350 output.m11 = input.get(1,1);
351 output.m12 = input.get(1,2);
357 geometry::AffineMatrix3D& output,
358 const ::basegfx::B3DHomMatrix& input)
360 output.m00 = input.get(0,0);
361 output.m01 = input.get(0,1);
362 output.m02 = input.get(0,2);
363 output.m03 = input.get(0,3);
365 output.m10 = input.get(1,0);
366 output.m11 = input.get(1,1);
367 output.m12 = input.get(1,2);
368 output.m13 = input.get(1,3);
370 output.m20 = input.get(2,0);
371 output.m21 = input.get(2,1);
372 output.m22 = input.get(2,2);
373 output.m23 = input.get(2,3);
380 return geometry::RealSize2D(rSize.getWidth(), rSize.getHeight());
385 return geometry::RealPoint2D( rPoint.getX(),
391 return geometry::RealRectangle2D( rRect.getMinX(),
399 return geometry::RealRectangle3D( rRect.getMinX(),
409 return ::basegfx::B2DPoint( rPoint.X,
415 return ::basegfx::B2DRange( rRect.X1,
423 return ::basegfx::B3DRange( rRect.X1,
433 return geometry::IntegerSize2D( rSize.getWidth(),
444 return ::basegfx::B2IRange( rRectangle.X1, rRectangle.Y1,
445 rRectangle.X2, rRectangle.Y2 );
450 return ::basegfx::B2IRange( rRect.X,
452 rRect.X + rRect.Width,
453 rRect.Y + rRect.Height );
458 return ::basegfx::B2IRange(
static_cast<sal_Int32
>( floor(rRange.getMinX()) ),
459 static_cast<sal_Int32
>( floor(rRange.getMinY()) ),
460 static_cast<sal_Int32
>( ceil(rRange.getMaxX()) ),
461 static_cast<sal_Int32
>( ceil(rRange.getMaxY()) ) );
466 return ::basegfx::B2DRange( floor(rRange.getMinX()),
467 floor(rRange.getMinY()),
468 ceil(rRange.getMaxX()),
469 ceil(rRange.getMaxY()) );
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
Base Point class with two double values.
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
void setPrevControlPoint(sal_uInt32 nIndex, const basegfx::B2DPoint &rValue)
basegfx::B2DPoint getPrevControlPoint(sal_uInt32 nIndex) const
Basic ControlPoint interface.
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
sal_uInt32 count() const
member count
void remove(sal_uInt32 nIndex, sal_uInt32 nCount=1)
remove points
void appendBezierSegment(const basegfx::B2DPoint &rNextControlPoint, const basegfx::B2DPoint &rPrevControlPoint, const basegfx::B2DPoint &rPoint)
Bezier segment append with control points. The current last polygon point is implicitly taken as star...
A two-dimensional interval over doubles.
A two-dimensional interval over integers.
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
TYPE getX() const
Get X-Coordinate of 2D Tuple.
TYPE getY() const
Get Y-Coordinate of 2D Tuple.