24 #include <rtl/ustrbuf.hxx>
44 SAL_WARN(
"svx.svdraw",
"invalid fraction xFract, using Fraction(1,1)" );
53 SAL_WARN(
"svx.svdraw",
"invalid fraction yFract, using Fraction(1,1)" );
58 rRect.
SetTop( rRef.Y() +
FRound( (rRect.
Top() - rRef.Y()) *
double(aYFact) ) );
68 for (sal_uInt16
i=0;
i<nCount;
i++) {
76 for (sal_uInt16
i=0;
i<nCount;
i++) {
84 for (sal_uInt16
i=0;
i<nCount;
i++) {
92 for (sal_uInt16
i=0;
i<nCount;
i++) {
100 for (sal_uInt16
i=0;
i<nCount;
i++) {
105 void MirrorPoint(Point& rPnt,
const Point& rRef1,
const Point& rRef2)
118 rPnt.setX(rRef1.X()+dy1 );
119 rPnt.setY(rRef1.Y()+dx1 );
120 }
else if (mx==-my) {
123 rPnt.setX(rRef1.X()-dy1 );
124 rPnt.setY(rRef1.Y()-dx1 );
130 Degree100 nAngle=2_deg100*(nRefAngle-nPntAngle);
142 for (sal_uInt16
i=0;
i<nCount;
i++) {
150 for (sal_uInt16
i=0;
i<nCount;
i++) {
158 for (sal_uInt16
i=0;
i<nCount;
i++) {
164 const Point& rRad,
double& rSin,
double& rCos,
bool bVert)
166 bool bC1=pC1!=
nullptr;
167 bool bC2=pC2!=
nullptr;
173 double sn=sin(nAngle);
174 double cs=cos(nAngle);
181 pC1->setY(
FRound(static_cast<double>(pC1->Y()) /rRad.X()*(cx-pC1->X())) );
188 double nFact=
static_cast<double>(nPntRad)/static_cast<double>(rRad.Y());
189 pC1->setX(
FRound(static_cast<double>(pC1->X())*nFact) );
199 pC2->setY(
FRound(static_cast<double>(pC2->Y()) /rRad.X()*(rCenter.X()-pC2->X())) );
206 double nFact=
static_cast<double>(nPntRad)/static_cast<double>(rRad.Y());
207 pC2->setX(
FRound(static_cast<double>(pC2->X())*nFact) );
218 const Point& rRad,
double& rSin,
double& rCos,
bool bVert)
220 bool bC1=pC1!=
nullptr;
221 bool bC2=pC2!=
nullptr;
232 dxC1=pC1->X()-nStart;
236 dxC2=pC2->X()-nStart;
244 dyC1=pC1->Y()-nStart;
248 dyC2=pC2->Y()-nStart;
253 double sn=sin(nAngle);
254 double cs=cos(nAngle);
256 if (bC1) {
if (bVert) pC1->AdjustY( -(y0-rCenter.Y()) );
else pC1->AdjustX( -(x0-rCenter.X()) );
RotatePoint(*pC1,rCenter,sn,cs); }
257 if (bC2) {
if (bVert) pC2->AdjustY( -(y0-rCenter.Y()) );
else pC2->AdjustX( -(x0-rCenter.X()) );
RotatePoint(*pC2,rCenter,sn,cs); }
260 if (bC1) pC1->AdjustX(dxC1 );
261 if (bC2) pC2->AdjustX(dxC2 );
264 if (bC1) pC1->AdjustY(dyC1 );
265 if (bC2) pC2->AdjustY(dyC2 );
273 const Point& rRad,
double& rSin,
double& rCos,
bool bVert,
284 double a=
static_cast<double>(y0-nTop)/nHgt;
297 while (i<nPointCnt) {
298 Point* pPnt=&rPoly[i];
301 if (i+1<nPointCnt && rPoly.
IsControl(i)) {
320 while (i<nPointCnt) {
321 Point* pPnt=&rPoly[i];
324 if (i+1<nPointCnt && rPoly.
IsControl(i)) {
343 while (i<nPointCnt) {
344 Point* pPnt=&rPoly[i];
347 if (i+1<nPointCnt && rPoly.
IsControl(i)) {
364 sal_uInt16 nPolyCount=rPoly.
Count();
365 for (sal_uInt16 nPolyNum=0; nPolyNum<nPolyCount; nPolyNum++) {
372 sal_uInt16 nPolyCount=rPoly.
Count();
373 for (sal_uInt16 nPolyNum=0; nPolyNum<nPolyCount; nPolyNum++) {
380 sal_uInt16 nPolyCount=rPoly.
Count();
381 for (sal_uInt16 nPolyNum=0; nPolyNum<nPolyCount; nPolyNum++) {
391 if (rPnt.X()<0) a=-18000_deg100;
392 }
else if (rPnt.X()==0) {
393 if (rPnt.Y()>0) a=-9000_deg100;
396 a =
Degree100(
FRound(basegfx::rad2deg<100>(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;
426 x=
FRound(sqrt(static_cast<double>(x)));
487 Point aPt1(rPol[1]-rPol[0]);
492 Point aPt3(rPol[3]-rPol[0]);
501 bool bMirr=aPt3.Y()<0;
508 if (nShW<-9000_deg100 || nShW>9000_deg100) {
528 if (dx==0 || dy==0 || dxa==dya)
return;
529 if (dxa>=dya*2) { rPt.setY(rPt0.Y() );
return; }
530 if (dya>=dxa*2) { rPt.setX(rPt0.X() );
return; }
531 if ((dxa<dya) != bBigOrtho) {
532 rPt.setY(rPt0.Y()+(dxa* (dy>=0 ? 1 : -1) ) );
534 rPt.setX(rPt0.X()+(dya* (dx>=0 ? 1 : -1) ) );
544 if ((dxa<dya) != bBigOrtho) {
545 rPt.setY(rPt0.Y()+(dxa* (dy>=0 ? 1 : -1) ) );
547 rPt.setX(rPt0.X()+(dya* (dx>=0 ? 1 : -1) ) );
561 const auto& [nNum, nDen] = o3tl::getConversionMulDiv(eFrom, eTo);
562 return FrPair(nNum, nDen);
581 case MapUnit::MapPixel : {
583 pVD->SetMapMode(
MapMode(MapUnit::Map100thMM));
585 return FrPair(6400,aP.X(),6400,aP.Y());
587 case MapUnit::MapAppFont:
case MapUnit::MapSysFont: {
591 pVD->SetMapMode(
MapMode(MapUnit::Map100thMM));
592 aP=pVD->PixelToLogic(aP);
593 return FrPair(3200,aP.X(),3200,aP.Y());
605 if (eS==eD)
return FrPair(1,1,1,1);
609 return toPair(eFrom, eTo);
616 if (!bSInch && bDInch) { aRet.X()*=
Fraction(5,127); aRet.Y()*=
Fraction(5,127); }
622 if (eS==eD)
return FrPair(1,1,1,1);
632 return toPair(eFrom, eTo);
641 const auto& [mul,
div] = o3tl::getConversionMulDiv(eFrom, eTo);
642 sal_Int64 nMul = mul;
643 sal_Int64 nDiv =
div;
647 while (0 == (nMul % 10))
654 while (0 == (nDiv % 10))
674 const OUString aNullCode(
"0");
709 OUStringBuffer
aStr = OUString::number(nVal);
711 if(nC > 0 && aStr.getLength() <= nC )
714 sal_Int32
nCount(nC - aStr.getLength());
720 aStr.insert(0, aNullCode);
724 sal_Int32 nWeg(nC - nNumDigits);
729 aStr.remove(aStr.getLength() - nWeg, nWeg);
735 sal_Int32 nForComma(aStr.getLength() - nC);
741 while(nC > 0 && aStr[aStr.getLength() - 1] == aNullCode[0])
743 aStr.remove(aStr.getLength() - 1, 1);
751 aStr.insert(nForComma, cDec);
759 if ( aThoSep.getLength() > 0 )
762 sal_Int32
i(nForComma - 3);
766 aStr.insert(i, cTho);
773 aStr.append(aNullCode);
775 if(bNeg && (aStr.getLength() > 1 || aStr[0] != aNullCode[0]))
780 return aStr.makeStringAndClear();
788 case MapUnit::Map100thMM :
790 case MapUnit::Map10thMM :
792 case MapUnit::MapMM :
794 case MapUnit::MapCM :
798 case MapUnit::Map1000thInch:
800 case MapUnit::Map100thInch :
802 case MapUnit::Map10thInch :
804 case MapUnit::MapInch :
806 case MapUnit::MapPoint :
808 case MapUnit::MapTwip :
812 case MapUnit::MapPixel :
814 case MapUnit::MapSysFont :
816 case MapUnit::MapAppFont :
818 case MapUnit::MapRelative :
830 case FieldUnit::NONE :
831 case FieldUnit::CUSTOM :
835 case FieldUnit::MM_100TH:
847 case FieldUnit::TWIP :
849 case FieldUnit::POINT :
851 case FieldUnit::PICA :
853 case FieldUnit::INCH :
855 case FieldUnit::FOOT :
857 case FieldUnit::MILE :
861 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)
double mfSinRotationAngle
tools::Long GetLen(const Point &rPnt)
Determine sector within the cartesian coordinate system.
void Move(tools::Long nHorzMove, tools::Long nVertMove)
constexpr o3tl::Length FieldToO3tlLength(FieldUnit eU, o3tl::Length ePixelValue=o3tl::Length::px)
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)
constexpr tools::Long Width() const
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.
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)
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
static FrPair toPair(o3tl::Length eFrom, o3tl::Length eTo)
void OrthoDistance8(const Point &rPt0, Point &rPt, bool bBigOrtho)
tools::Polygon Rect2Poly(const tools::Rectangle &rRect, const GeoStat &rGeo)
Degree100 NormAngle36000(Degree100 a)
Normalize angle to -180.00..179.99.
void RotatePoint(Point &rPnt, const Point &rRef, double sn, double cs)
FrPair GetMapFactor(MapUnit eS, MapUnit eD)
constexpr tools::Long Height() 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...
constexpr o3tl::Length MapToO3tlLength(MapUnit eU, o3tl::Length ePixelValue=o3tl::Length::px)
double CrookSlantXPoint(Point &rPnt, Point *pC1, Point *pC2, const Point &rCenter, const Point &rRad, double &rSin, double &rCos, bool bVert)
double mfCosRotationAngle
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)
double div(const double &fNumerator, const double &fDenominator)
sal_uInt16 GetAngleSector(Degree100 nAngle)
Normalize angle to 0.00..359.99.