37 : pOldPointAry(nullptr)
38 , bDeleteOldPoints(false)
47 : pOldPointAry(nullptr)
48 , bDeleteOldPoints(false)
50 , nResize(rImpXPoly.nResize)
91 if( nNewSize ==
nSize )
95 sal_uInt16 nOldSize =
nSize;
118 if( nOldSize <
nSize )
121 memcpy(
pFlagAry.get(), pOldFlagAry, nOldSize );
140 delete[] pOldFlagAry;
159 nMove *
sizeof(
Point) );
180 nMove *
sizeof(
Point) );
209 : pImpXPolygon( rPoly.GetSize() )
211 sal_uInt16 nSize = rPoly.
GetSize();
214 for( sal_uInt16
i = 0;
i < nSize;
i++ )
228 if ( nRx > nWh ) nRx = nWh;
229 if ( nRy > nHh ) nRy = nHh;
243 for (sal_uInt16 nQuad = 0; nQuad < 4; nQuad++)
247 case 0: aCenter = rRect.
TopLeft();
264 GenBezArc(aCenter, nRx, nRy, nXHdl, nYHdl, 0_deg100, 9000_deg100, nQuad,
nPos);
286 nStartAngle %= 36000_deg100;
287 if ( nEndAngle > 36000_deg100 ) nEndAngle %= 36000_deg100;
288 bool bFull = (nStartAngle == 0_deg100 && nEndAngle == 36000_deg100);
294 bool bLoopEnd =
false;
299 sal_uInt16 nQuad = nStartAngle.
get() / 9000;
300 if ( nQuad == 4 ) nQuad = 0;
301 bLoopEnd =
CheckAngles(nStartAngle, nEndAngle, nA1, nA2);
302 GenBezArc(rCenter, nRx, nRy, nXHdl, nYHdl, nA1, nA2, nQuad,
nPos);
307 }
while ( !bLoopEnd );
310 if ( !bFull && bClose )
330 if ( nPoints < pImpXPolygon->nPoints )
370 nPoints*
sizeof(
Point ) );
383 if ( !nHorzMove && !nVertMove )
388 for ( sal_uInt16
i = 0;
i <
nCount;
i++ )
420 DBG_ASSERT(nPos < pImpXPolygon->nPoints,
"Invalid index at const array access to XPolygon");
475 return ( eFlag == PolyFlags::Smooth || eFlag == PolyFlags::Symmetric );
487 double fDx = rP2.
X() - rP1.
X();
488 double fDy = rP2.
Y() - rP1.
Y();
489 return std::hypot(fDx, fDy);
495 double fT2 = fT * fT;
496 double fT3 = fT * fT2;
497 double fU = 1.0 - fT;
498 double fU2 = fU * fU;
499 double fU3 = fU * fU2;
500 sal_uInt16 nIdx =
nPos;
501 short nPosInc, nIdxInc;
515 fT * fU2 * pPoints[nIdx+1].
X() * 3 +
516 fT2 * fU * pPoints[nIdx+2].
X() * 3 +
517 fT3 * pPoints[nIdx+3].
X()) );
519 fT * fU2 * pPoints[nIdx+1].
Y() * 3 +
520 fT2 * fU * pPoints[nIdx+2].
Y() * 3 +
521 fT3 * pPoints[nIdx+3].
Y()) );
523 nIdx = nIdx + nIdxInc;
525 fT * fU * pPoints[nIdx+1].
X() * 2 +
526 fT2 * pPoints[nIdx+2].
X()) );
528 fT * fU * pPoints[nIdx+1].
Y() * 2 +
529 fT2 * pPoints[nIdx+2].
Y()) );
531 nIdx = nIdx + nIdxInc;
533 fT * pPoints[nIdx+1].
X()) );
535 fT * pPoints[nIdx+1].
Y()) );
541 sal_uInt16 nQuad, sal_uInt16 nFirst)
544 pPoints[nFirst ] = rCenter;
545 pPoints[nFirst+3] = rCenter;
547 if ( nQuad == 1 || nQuad == 2 )
549 nRx = -nRx; nXHdl = -nXHdl;
551 if ( nQuad == 0 || nQuad == 1 )
553 nRy = -nRy; nYHdl = -nYHdl;
556 if ( nQuad == 0 || nQuad == 2 )
558 pPoints[nFirst].
AdjustX( nRx );
559 pPoints[nFirst+3].
AdjustY( nRy );
563 pPoints[nFirst].
AdjustY( nRy );
564 pPoints[nFirst+3].
AdjustX( nRx );
566 pPoints[nFirst+1] = pPoints[nFirst];
567 pPoints[nFirst+2] = pPoints[nFirst+3];
569 if ( nQuad == 0 || nQuad == 2 )
571 pPoints[nFirst+1].
AdjustY( nYHdl );
572 pPoints[nFirst+2].
AdjustX( nXHdl );
576 pPoints[nFirst+1].
AdjustX( nXHdl );
577 pPoints[nFirst+2].
AdjustY( nYHdl );
579 if ( nStart > 0_deg100 )
581 if ( nEnd < 9000_deg100 )
582 SubdivideBezier(nFirst,
true,
static_cast<double>((nEnd-nStart).
get()) / (9000_deg100-nStart).
get());
583 SetFlags(nFirst+1, PolyFlags::Control);
584 SetFlags(nFirst+2, PolyFlags::Control);
589 if ( nStart == 36000_deg100 ) nStart = 0_deg100;
590 if ( nEnd == 0_deg100 ) nEnd = 36000_deg100;
595 if ( nEnd >= nMax || nEnd <= nStart ) nA2 = 9000_deg100;
596 else nA2 = nEnd - nMin;
601 return (nStPrev < nEnd && nStart >= nEnd);
620 std::swap( nDrag, nPnt );
622 Point aDiff = pPoints[nDrag] - pPoints[nCenter];
634 pPoints[nPnt] = pPoints[nCenter] - aDiff;
654 Point aDiff = rNext - rPrev;
655 double fNextLen =
CalcDistance(nCenter, nNext) / fAbsLen;
656 double fPrevLen =
CalcDistance(nCenter, nPrev) / fAbsLen;
659 if (
GetFlags(nCenter) == PolyFlags::Symmetric )
661 fPrevLen = (fNextLen + fPrevLen) / 2;
673 double nFullLength, nPart1Length, nPart2Length;
674 double fX0, fY0, fX1, fY1, fX2, fY2, fX3, fY3;
675 double fTx1, fTx2, fTy1, fTy2;
676 double fT1, fU1, fT2, fU2, fV;
683 fTx1 = pPoints[nFirst+1].
X();
684 fTy1 = pPoints[nFirst+1].
Y();
685 fTx2 = pPoints[nFirst+2].
X();
686 fTy2 = pPoints[nFirst+2].
Y();
687 fX0 = pPoints[nFirst ].
X();
688 fY0 = pPoints[nFirst ].
Y();
689 fX3 = pPoints[nFirst+3].
X();
690 fY3 = pPoints[nFirst+3].
Y();
693 nPart2Length = nPart1Length +
CalcDistance(nFirst+1, nFirst+2);
694 nFullLength = nPart2Length +
CalcDistance(nFirst+2, nFirst+3);
695 if ( nFullLength < 20 )
698 if ( nPart2Length == nFullLength )
700 if ( nPart1Length == nFullLength )
701 nPart1Length = nPart2Length - 1;
702 if ( nPart1Length <= 0 )
704 if ( nPart2Length <= 0 || nPart2Length == nPart1Length )
705 nPart2Length = nPart1Length + 1;
707 fT1 = nPart1Length / nFullLength;
709 fT2 = nPart2Length / nFullLength;
711 fV = 3 * (1.0 - (fT1 * fU2) / (fT2 * fU1));
713 fX1 = fTx1 / (fT1 * fU1 * fU1) - fTx2 * fT1 / (fT2 * fT2 * fU1 * fU2);
715 fX1 -= fX0 * ( fU1 / fT1 + fU2 / fT2) / 3;
716 fX1 += fX3 * ( fT1 * fT2 / (fU1 * fU2)) / 3;
718 fY1 = fTy1 / (fT1 * fU1 * fU1) - fTy2 * fT1 / (fT2 * fT2 * fU1 * fU2);
720 fY1 -= fY0 * ( fU1 / fT1 + fU2 / fT2) / 3;
721 fY1 += fY3 * ( fT1 * fT2 / (fU1 * fU2)) / 3;
723 fX2 = fTx2 / (fT2 * fT2 * fU2 * 3) - fX0 * fU2 * fU2 / ( fT2 * fT2 * 3);
724 fX2 -= fX1 * fU2 / fT2;
725 fX2 -= fX3 * fT2 / (fU2 * 3);
727 fY2 = fTy2 / (fT2 * fT2 * fU2 * 3) - fY0 * fU2 * fU2 / ( fT2 * fT2 * 3);
728 fY2 -= fY1 * fU2 / fT2;
729 fY2 -= fY3 * fT2 / (fU2 * 3);
733 SetFlags(nFirst+1, PolyFlags::Control);
734 SetFlags(nFirst+2, PolyFlags::Control);
744 for (sal_uInt16
i = 0;
i < nPntCnt;
i++)
770 Xr = rRefRect.
Left();
781 "Distort: rectangle too small");
783 X1 = rDistortedRect[0].X();
784 Y1 = rDistortedRect[0].Y();
785 X2 = rDistortedRect[1].X();
786 Y2 = rDistortedRect[1].Y();
787 X3 = rDistortedRect[3].X();
788 Y3 = rDistortedRect[3].Y();
789 X4 = rDistortedRect[2].X();
790 Y4 = rDistortedRect[2].Y();
794 for (sal_uInt16
i = 0;
i < nPntCnt;
i++)
796 double fTx, fTy, fUx, fUy;
799 fTx =
static_cast<double>(rPnt.
X() - Xr) / Wr;
800 fTy =
static_cast<double>(rPnt.
Y() - Yr) / Hr;
805 fTy * (fUx * X3 + fTx * X4) ) );
807 fTx * (fUy *
Y2 + fTy * Y4) ) );
829 sal_uInt16 nSize = aSource.
GetSize();
832 for( sal_uInt16
i = 0;
i < nSize;
i++ )
848 for(
auto const& rCandidate : rPolyPolygon)
864 for (
size_t i = 0;
i < rXPolyPoly.
Count();
i++)
895 for (
size_t n = 0;
n < nXPoly;
n++ )
926 for (
size_t i = 0;
i <
Count();
i++)
934 for(sal_uInt16
a(0);
a <
Count();
a++)
bool operator==(const ImpXPolygon &rImpXPoly) const
void Resize(sal_uInt16 nNewSize, bool bDeletePoints=true)
Change polygon size.
ImpXPolygon(sal_uInt16 nInitSize, sal_uInt16 nResize=16)
void Remove(sal_uInt16 nPos, sal_uInt16 nCount)
void InsertSpace(sal_uInt16 nPos, sal_uInt16 nCount)
std::unique_ptr< PolyFlags[]> pFlagAry
std::unique_ptr< Point[]> pPointAry
void CheckPointDelete() const
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
o3tl::cow_wrapper< ImpXPolyPolygon > pImpXPolyPolygon
tools::Rectangle GetBoundRect() const
const XPolygon & operator[](sal_uInt16 nPos) const
void Remove(sal_uInt16 nPos)
basegfx::B2DPolyPolygon getB2DPolyPolygon() const
XPolyPolygon & operator=(const XPolyPolygon &)
void Insert(XPolygon &&rXPoly)
const XPolygon & GetObject(sal_uInt16 nPos) const
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...
sal_uInt16 GetSize() const
void Remove(sal_uInt16 nPos, sal_uInt16 nCount)
void Move(tools::Long nHorzMove, tools::Long nVertMove)
void CalcSmoothJoin(sal_uInt16 nCenter, sal_uInt16 nDrag, sal_uInt16 nPnt)
Calculate a smooth transition to connect two Bézier curves.
const Point & operator[](sal_uInt16 nPos) const
bool IsControl(sal_uInt16 nPos) const
short path to read the CONTROL flag directly (TODO: better explain what the sense behind this flag is...
sal_uInt16 GetPointCount() const
void GenBezArc(const Point &rCenter, tools::Long nRx, tools::Long nRy, tools::Long nXHdl, tools::Long nYHdl, Degree100 nStart, Degree100 nEnd, sal_uInt16 nQuad, sal_uInt16 nFirst)
Generate a Bézier arc.
void Insert(sal_uInt16 nPos, const Point &rPt, PolyFlags eFlags)
double CalcDistance(sal_uInt16 nP1, sal_uInt16 nP2)
calculate the euclidean distance between two points
bool operator==(const XPolygon &rXPoly) const
void SetFlags(sal_uInt16 nPos, PolyFlags eFlags)
set the flags for the point at the given position
XPolygon & operator=(const XPolygon &)
XPolygon(sal_uInt16 nSize=16)
void Scale(double fSx, double fSy)
scale in X- and/or Y-direction
void PointsToBezier(sal_uInt16 nFirst)
convert four polygon points into a Bézier curve
bool IsSmooth(sal_uInt16 nPos) const
short path to read the SMOOTH and SYMMTR flag directly (TODO: better explain what the sense behind th...
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...
void SetPointCount(sal_uInt16 nPoints)
void CalcTangent(sal_uInt16 nCenter, sal_uInt16 nPrev, sal_uInt16 nNext)
Calculate tangent between two Bézier curves.
void SubdivideBezier(sal_uInt16 nPos, bool bCalcFirst, double fT)
basegfx::B2DPolygon getB2DPolygon() const
PolyFlags GetFlags(sal_uInt16 nPos) const
get the flags for the point at the given position
o3tl::cow_wrapper< ImpXPolygon > pImpXPolygon
static bool CheckAngles(Degree100 &nStart, Degree100 nEnd, Degree100 &nA1, Degree100 &nA2)
tools::Rectangle GetBoundRect() const
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
#define DBG_ASSERT(sCon, aError)
tools::Long FRound(double fVal)
B2DRange getRange(const B2DPolygon &rCandidate)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
UNDERLYING_TYPE get() const