24 #include <rtl/ustrbuf.hxx>
43 SAL_WARN(
"svx.svdraw",
"invalid fraction xFract, using Fraction(1,1)" );
52 SAL_WARN(
"svx.svdraw",
"invalid fraction yFract, using Fraction(1,1)" );
57 rRect.
SetTop( rRef.Y() +
FRound( (rRect.
Top() - rRef.Y()) *
double(aYFact) ) );
67 for (sal_uInt16
i=0;
i<nCount;
i++) {
75 for (sal_uInt16
i=0;
i<nCount;
i++) {
83 for (sal_uInt16
i=0;
i<nCount;
i++) {
91 for (sal_uInt16
i=0;
i<nCount;
i++) {
99 for (sal_uInt16
i=0;
i<nCount;
i++) {
104 void MirrorPoint(Point& rPnt,
const Point& rRef1,
const Point& rRef2)
117 rPnt.setX(rRef1.X()+dy1 );
118 rPnt.setY(rRef1.Y()+dx1 );
119 }
else if (mx==-my) {
122 rPnt.setX(rRef1.X()-dy1 );
123 rPnt.setY(rRef1.Y()-dx1 );
129 Degree100 nAngle=2_deg100*(nRefAngle-nPntAngle);
141 for (sal_uInt16
i=0;
i<nCount;
i++) {
149 for (sal_uInt16
i=0;
i<nCount;
i++) {
157 for (sal_uInt16
i=0;
i<nCount;
i++) {
163 const Point& rRad,
double& rSin,
double& rCos,
bool bVert)
165 bool bC1=pC1!=
nullptr;
166 bool bC2=pC2!=
nullptr;
172 double sn=sin(nAngle);
173 double cs=cos(nAngle);
180 pC1->setY(
FRound(static_cast<double>(pC1->Y()) /rRad.X()*(cx-pC1->X())) );
187 double nFact=
static_cast<double>(nPntRad)/static_cast<double>(rRad.Y());
188 pC1->setX(
FRound(static_cast<double>(pC1->X())*nFact) );
198 pC2->setY(
FRound(static_cast<double>(pC2->Y()) /rRad.X()*(rCenter.X()-pC2->X())) );
205 double nFact=
static_cast<double>(nPntRad)/static_cast<double>(rRad.Y());
206 pC2->setX(
FRound(static_cast<double>(pC2->X())*nFact) );
217 const Point& rRad,
double& rSin,
double& rCos,
bool bVert)
219 bool bC1=pC1!=
nullptr;
220 bool bC2=pC2!=
nullptr;
231 dxC1=pC1->X()-nStart;
235 dxC2=pC2->X()-nStart;
243 dyC1=pC1->Y()-nStart;
247 dyC2=pC2->Y()-nStart;
252 double sn=sin(nAngle);
253 double cs=cos(nAngle);
255 if (bC1) {
if (bVert) pC1->AdjustY( -(y0-rCenter.Y()) );
else pC1->AdjustX( -(x0-rCenter.X()) );
RotatePoint(*pC1,rCenter,sn,cs); }
256 if (bC2) {
if (bVert) pC2->AdjustY( -(y0-rCenter.Y()) );
else pC2->AdjustX( -(x0-rCenter.X()) );
RotatePoint(*pC2,rCenter,sn,cs); }
259 if (bC1) pC1->AdjustX(dxC1 );
260 if (bC2) pC2->AdjustX(dxC2 );
263 if (bC1) pC1->AdjustY(dyC1 );
264 if (bC2) pC2->AdjustY(dyC2 );
272 const Point& rRad,
double& rSin,
double& rCos,
bool bVert,
283 double a=
static_cast<double>(y0-nTop)/nHgt;
296 while (i<nPointCnt) {
297 Point* pPnt=&rPoly[i];
300 if (i+1<nPointCnt && rPoly.
IsControl(i)) {
319 while (i<nPointCnt) {
320 Point* pPnt=&rPoly[i];
323 if (i+1<nPointCnt && rPoly.
IsControl(i)) {
342 while (i<nPointCnt) {
343 Point* pPnt=&rPoly[i];
346 if (i+1<nPointCnt && rPoly.
IsControl(i)) {
363 sal_uInt16 nPolyCount=rPoly.
Count();
364 for (sal_uInt16 nPolyNum=0; nPolyNum<nPolyCount; nPolyNum++) {
371 sal_uInt16 nPolyCount=rPoly.
Count();
372 for (sal_uInt16 nPolyNum=0; nPolyNum<nPolyCount; nPolyNum++) {
379 sal_uInt16 nPolyCount=rPoly.
Count();
380 for (sal_uInt16 nPolyNum=0; nPolyNum<nPolyCount; nPolyNum++) {
390 if (rPnt.X()<0) a=-18000_deg100;
391 }
else if (rPnt.X()==0) {
392 if (rPnt.Y()>0) a=-9000_deg100;
395 a =
Degree100(
FRound(atan2(static_cast<double>(-rPnt.Y()), static_cast<double>(rPnt.X()))
403 while (a<-18000_deg100) a+=36000_deg100;
404 while (a>=18000_deg100) a-=36000_deg100;
411 int a = 36000 + deg100.
get();
420 if (nAngle< 9000_deg100)
return 0;
421 if (nAngle<18000_deg100)
return 1;
422 if (nAngle<27000_deg100)
return 2;
434 x=
FRound(sqrt(static_cast<double>(x)));
495 Point aPt1(rPol[1]-rPol[0]);
500 Point aPt3(rPol[3]-rPol[0]);
509 bool bMirr=aPt3.Y()<0;
516 if (nShW<-9000_deg100 || nShW>9000_deg100) {
536 if (dx==0 || dy==0 || dxa==dya)
return;
537 if (dxa>=dya*2) { rPt.setY(rPt0.Y() );
return; }
538 if (dya>=dxa*2) { rPt.setX(rPt0.X() );
return; }
539 if ((dxa<dya) != bBigOrtho) {
540 rPt.setY(rPt0.Y()+(dxa* (dy>=0 ? 1 : -1) ) );
542 rPt.setX(rPt0.X()+(dya* (dx>=0 ? 1 : -1) ) );
552 if ((dxa<dya) != bBigOrtho) {
553 rPt.setY(rPt0.Y()+(dxa* (dy>=0 ? 1 : -1) ) );
555 rPt.setX(rPt0.X()+(dya* (dx>=0 ? 1 : -1) ) );
573 case MapUnit::Map1000thInch:
return FrPair(1000,1);
574 case MapUnit::Map100thInch :
return FrPair( 100,1);
575 case MapUnit::Map10thInch :
return FrPair( 10,1);
576 case MapUnit::MapInch :
return FrPair( 1,1);
577 case MapUnit::MapPoint :
return FrPair( 72,1);
578 case MapUnit::MapTwip :
return FrPair(1440,1);
579 case MapUnit::Map100thMM :
return FrPair( 100,1);
580 case MapUnit::Map10thMM :
return FrPair( 10,1);
581 case MapUnit::MapMM :
return FrPair( 1,1);
582 case MapUnit::MapCM :
return FrPair( 1,10);
583 case MapUnit::MapPixel : {
585 pVD->SetMapMode(
MapMode(MapUnit::Map100thMM));
587 return FrPair(6400,aP.X(),6400,aP.Y());
589 case MapUnit::MapAppFont:
case MapUnit::MapSysFont: {
593 pVD->SetMapMode(
MapMode(MapUnit::Map100thMM));
594 aP=pVD->PixelToLogic(aP);
595 return FrPair(3200,aP.X(),3200,aP.Y());
605 case FieldUnit::INCH :
return FrPair( 1,1);
606 case FieldUnit::POINT :
return FrPair( 72,1);
607 case FieldUnit::TWIP :
return FrPair(1440,1);
608 case FieldUnit::MM_100TH :
return FrPair( 100,1);
609 case FieldUnit::MM :
return FrPair( 1,1);
610 case FieldUnit::CM :
return FrPair( 1,10);
611 case FieldUnit::M :
return FrPair( 1,1000);
612 case FieldUnit::KM :
return FrPair( 1,1000000);
613 case FieldUnit::PICA :
return FrPair( 6,1);
614 case FieldUnit::FOOT :
return FrPair( 1,12);
615 case FieldUnit::MILE :
return FrPair( 1,63360);
626 if (eS==eD)
return FrPair(1,1,1,1);
633 if (!bSInch && bDInch) { aRet.X()*=
Fraction(5,127); aRet.Y()*=
Fraction(5,127); }
639 if (eS==eD)
return FrPair(1,1,1,1);
646 if (!bSInch && bDInch) { aRet.X()*=
Fraction(5,127); aRet.Y()*=
Fraction(5,127); }
662 bool bMetr =
false, bInch =
false;
665 case MapUnit::Map100thMM : bMetr =
true; nComma=5;
break;
666 case MapUnit::Map10thMM : bMetr =
true; nComma=4;
break;
667 case MapUnit::MapMM : bMetr =
true; nComma=3;
break;
668 case MapUnit::MapCM : bMetr =
true; nComma=2;
break;
670 case MapUnit::Map1000thInch: bInch =
true; nComma=3;
break;
671 case MapUnit::Map100thInch : bInch =
true; nComma=2;
break;
672 case MapUnit::Map10thInch : bInch =
true; nComma=1;
break;
673 case MapUnit::MapInch : bInch =
true; nComma=0;
break;
674 case MapUnit::MapPoint : bInch =
true; rnDiv=72;
break;
675 case MapUnit::MapTwip : bInch =
true; rnDiv=144; nComma=1;
break;
677 case MapUnit::MapPixel :
break;
678 case MapUnit::MapSysFont :
break;
679 case MapUnit::MapAppFont :
break;
680 case MapUnit::MapRelative :
break;
691 bool bSrcMetr,bSrcInch,bDstMetr,bDstInch;
693 short nComma1,nComma2;
699 nComma1=nComma1-nComma2;
701 if (bSrcInch && bDstMetr) {
705 if (bSrcMetr && bDstInch) {
724 const OUString aNullCode(
"0");
759 OUStringBuffer
aStr = OUString::number(nVal);
761 if(nC > 0 && aStr.getLength() <= nC )
764 sal_Int32
nCount(nC - aStr.getLength());
770 aStr.insert(0, aNullCode);
774 sal_Int32 nWeg(nC - nNumDigits);
779 aStr.remove(aStr.getLength() - nWeg, nWeg);
785 sal_Int32 nForComma(aStr.getLength() - nC);
791 while(nC > 0 && aStr[aStr.getLength() - 1] == aNullCode[0])
793 aStr.remove(aStr.getLength() - 1, 1);
801 aStr.insert(nForComma, cDec);
809 if ( aThoSep.getLength() > 0 )
812 sal_Int32
i(nForComma - 3);
816 aStr.insert(i, cTho);
823 aStr.append(aNullCode);
825 if(bNeg && (aStr.getLength() > 1 || aStr[0] != aNullCode[0]))
830 return aStr.makeStringAndClear();
838 case MapUnit::Map100thMM :
840 case MapUnit::Map10thMM :
842 case MapUnit::MapMM :
844 case MapUnit::MapCM :
848 case MapUnit::Map1000thInch:
850 case MapUnit::Map100thInch :
852 case MapUnit::Map10thInch :
854 case MapUnit::MapInch :
856 case MapUnit::MapPoint :
858 case MapUnit::MapTwip :
862 case MapUnit::MapPixel :
864 case MapUnit::MapSysFont :
866 case MapUnit::MapAppFont :
868 case MapUnit::MapRelative :
880 case FieldUnit::NONE :
881 case FieldUnit::CUSTOM :
885 case FieldUnit::MM_100TH:
897 case FieldUnit::TWIP :
899 case FieldUnit::POINT :
901 case FieldUnit::PICA :
903 case FieldUnit::INCH :
905 case FieldUnit::FOOT :
907 case FieldUnit::MILE :
911 case FieldUnit::PERCENT:
void ShearXPoly(XPolygon &rPoly, const Point &rRef, double tn, bool bVShear)
void ShearPoint(Point &rPnt, const Point &rRef, double tn, bool bVShear=false)
double GetCrookAngle(Point &rPnt, const Point &rCenter, const Point &rRad, bool bVertical)
rPnt.X/rPnt.Y is set to rCenter.X or rCenter.Y! We then only need to rotate rPnt by rCenter...
void ResizePoint(Point &rPnt, const Point &rRef, const Fraction &xFract, const Fraction &yFract)
void ResizePoly(tools::Polygon &rPoly, const Point &rRef, const Fraction &xFact, const Fraction &yFact)
constexpr Degree100 SDRMAXSHEAR(8900)
void ResizeXPoly(XPolygon &rPoly, const Point &rRef, const Fraction &xFact, const Fraction &yFact)
void Poly2Rect(const tools::Polygon &rPol, tools::Rectangle &rRect, GeoStat &rGeo)
static void GetMeterOrInch(MapUnit eMU, short &rnComma, tools::Long &rnMul, tools::Long &rnDiv, bool &rbMetr, bool &rbInch)
double mfSinRotationAngle
tools::Long GetLen(const Point &rPnt)
Determine sector within the cartesian coordinate system.
void Move(tools::Long nHorzMove, tools::Long nVertMove)
static sal_uInt16 getNumDigits()
static bool isNumLeadingZero()
static FrPair GetInchOrMM(MapUnit eU)
void RotatePoly(tools::Polygon &rPoly, const Point &rRef, double sn, double cs)
double CrookRotateXPoint(Point &rPnt, Point *pC1, Point *pC2, const Point &rCenter, const Point &rRad, double &rSin, double &rCos, bool bVert)
The following methods accept a point of an XPolygon, whereas the neighbouring control points of the a...
void ShearPoly(tools::Polygon &rPoly, const Point &rRef, double tn)
const LocaleDataWrapper & GetLocaleData() const
void CrookRotatePoly(XPolygon &rPoly, const Point &rCenter, const Point &rRad, bool bVert)
double CrookStretchXPoint(Point &rPnt, Point *pC1, Point *pC2, const Point &rCenter, const Point &rRad, double &rSin, double &rCos, bool bVert, const tools::Rectangle &rRefRect)
The transformation of a rectangle into a polygon, by using angle parameters from GeoStat.
Degree100 NormAngle36000(Degree100 deg100)
Normalize angle to -180.00..179.99.
tools::Long BigMulDiv(tools::Long nVal, tools::Long nMul, tools::Long nDiv)
const OUString & getNumDecimalSep() const
void ResizeRect(tools::Rectangle &rRect, const Point &rRef, const Fraction &rxFact, const Fraction &ryFact)
void CrookStretchPoly(XPolygon &rPoly, const Point &rCenter, const Point &rRad, bool bVert, const tools::Rectangle &rRefRect)
UNDERLYING_TYPE get() const
void MirrorXPoly(XPolygon &rPoly, const Point &rRef1, const Point &rRef2)
const Fraction & Y() const
tools::Long FRound(double fVal)
Degree100 GetAngle(const Point &rPnt)
The Y axis points down! The function negates the Y axis, when calculating the angle, such that GetAngle(Point(0,-1))=90 deg.
void MirrorPoint(Point &rPnt, const Point &rRef1, const Point &rRef2)
const Fraction & X() const
tools::Long Width() const
void OrthoDistance8(const Point &rPt0, Point &rPt, bool bBigOrtho)
tools::Polygon Rect2Poly(const tools::Rectangle &rRect, const GeoStat &rGeo)
void RotatePoint(Point &rPnt, const Point &rRef, double sn, double cs)
FrPair GetMapFactor(MapUnit eS, MapUnit eD)
sal_Int32 GetDenominator() 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...
double CrookSlantXPoint(Point &rPnt, Point *pC1, Point *pC2, const Point &rCenter, const Point &rRad, double &rSin, double &rCos, bool bVert)
double mfCosRotationAngle
tools::Long Height() const
sal_Int32 GetNumerator() const
static tools::Long Scale(tools::Long nVal, tools::Long nMult, tools::Long nDiv)
const OUString & getNumThousandSep() const
Degree100 NormAngle18000(Degree100 a)
void RotateXPoly(XPolygon &rPoly, const Point &rRef, double sn, double cs)
#define SAL_WARN(area, stream)
void CrookSlantPoly(XPolygon &rPoly, const Point &rCenter, const Point &rRad, bool bVert)
sal_uInt16 GetPointCount() const
void MoveXPoly(XPolygon &rPoly, const Size &S)
void OrthoDistance4(const Point &rPt0, Point &rPt, bool bBigOrtho)
sal_uInt16 GetAngleSector(Degree100 nAngle)
Normalize angle to 0.00..359.99.