24#include <rtl/ustrbuf.hxx>
35 rPoly.
Move(
S.Width(),
S.Height());
44 SAL_WARN(
"svx.svdraw",
"invalid fraction xFract, using Fraction(1,1)" );
53 SAL_WARN(
"svx.svdraw",
"invalid fraction yFract, using Fraction(1,1)" );
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);
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); }
273 const Point& rRad,
double& rSin,
double& rCos,
bool bVert,
284 double a=
static_cast<double>(y0-nTop)/nHgt;
297 while (
i<nPointCnt) {
320 while (
i<nPointCnt) {
343 while (
i<nPointCnt) {
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)));
490 Point aPoint1(rPolygon[1] - rPolygon[0]);
495 Point aPoint0(rPolygon[0]);
496 Point aPoint3(rPolygon[3] - rPolygon[0]);
502 nShearAngle -= 27000_deg100;
503 nShearAngle = -nShearAngle;
505 bool bMirror = aPoint3.
Y() < 0;
509 nShearAngle += 18000_deg100;
510 aPoint0 = rPolygon[3];
514 if (nShearAngle < -9000_deg100 || nShearAngle > 9000_deg100)
543 if (dx==0 || dy==0 || dxa==dya)
return;
544 if (dxa>=dya*2) { rPt.
setY(rPt0.
Y() );
return; }
545 if (dya>=dxa*2) { rPt.
setX(rPt0.
X() );
return; }
546 if ((dxa<dya) != bBigOrtho) {
547 rPt.
setY(rPt0.
Y()+(dxa* (dy>=0 ? 1 : -1) ) );
549 rPt.
setX(rPt0.
X()+(dya* (dx>=0 ? 1 : -1) ) );
559 if ((dxa<dya) != bBigOrtho) {
560 rPt.
setY(rPt0.
Y()+(dxa* (dy>=0 ? 1 : -1) ) );
562 rPt.
setX(rPt0.
X()+(dya* (dx>=0 ? 1 : -1) ) );
576 const auto& [nNum, nDen] = o3tl::getConversionMulDiv(eFrom, eTo);
577 return FrPair(nNum, nDen);
596 case MapUnit::MapPixel : {
598 pVD->SetMapMode(
MapMode(MapUnit::Map100thMM));
600 return FrPair(6400,aP.
X(),6400,aP.
Y());
602 case MapUnit::MapAppFont:
case MapUnit::MapSysFont: {
606 pVD->SetMapMode(
MapMode(MapUnit::Map100thMM));
607 aP=pVD->PixelToLogic(aP);
608 return FrPair(3200,aP.
X(),3200,aP.
Y());
620 if (eS==eD)
return FrPair(1,1,1,1);
624 return toPair(eFrom, eTo);
637 if (eS==eD)
return FrPair(1,1,1,1);
647 return toPair(eFrom, eTo);
656 const auto& [mul,
div] = o3tl::getConversionMulDiv(eFrom, eTo);
657 sal_Int64 nMul = mul;
658 sal_Int64 nDiv =
div;
662 while (0 == (nMul % 10))
669 while (0 == (nDiv % 10))
689 static constexpr OUStringLiteral aNullCode(
u"0");
724 OUStringBuffer
aStr = OUString::number(nVal);
726 if(nC > 0 &&
aStr.getLength() <= nC )
735 aStr.insert(0, aNullCode);
739 sal_Int32 nWeg(nC - nNumDigits);
744 aStr.remove(
aStr.getLength() - nWeg, nWeg);
750 sal_Int32 nForComma(
aStr.getLength() - nC);
756 while(nC > 0 &&
aStr[
aStr.getLength() - 1] == aNullCode.getStr()[0])
758 aStr.remove(
aStr.getLength() - 1, 1);
766 aStr.insert(nForComma, cDec);
774 if ( aThoSep.getLength() > 0 )
777 sal_Int32
i(nForComma - 3);
781 aStr.insert(
i, cTho);
788 aStr.append(aNullCode);
790 if(bNeg && (
aStr.getLength() > 1 ||
aStr[0] != aNullCode.getStr()[0]))
795 return aStr.makeStringAndClear();
803 case MapUnit::Map100thMM :
805 case MapUnit::Map10thMM :
807 case MapUnit::MapMM :
809 case MapUnit::MapCM :
813 case MapUnit::Map1000thInch:
815 case MapUnit::Map100thInch :
817 case MapUnit::Map10thInch :
819 case MapUnit::MapInch :
821 case MapUnit::MapPoint :
823 case MapUnit::MapTwip :
827 case MapUnit::MapPixel :
829 case MapUnit::MapSysFont :
831 case MapUnit::MapAppFont :
833 case MapUnit::MapRelative :
845 case FieldUnit::NONE :
846 case FieldUnit::CUSTOM :
850 case FieldUnit::MM_100TH:
862 case FieldUnit::TWIP :
864 case FieldUnit::POINT :
866 case FieldUnit::PICA :
868 case FieldUnit::INCH :
870 case FieldUnit::FOOT :
872 case FieldUnit::MILE :
876 case FieldUnit::PERCENT:
constexpr o3tl::Length FieldToO3tlLength(FieldUnit eU, o3tl::Length ePixelValue=o3tl::Length::px)
constexpr o3tl::Length MapToO3tlLength(MapUnit eU, o3tl::Length ePixelValue=o3tl::Length::px)
static tools::Long Scale(tools::Long nVal, tools::Long nMult, tools::Long nDiv)
const Fraction & X() const
const Fraction & Y() const
The transformation of a rectangle into a polygon, by using angle parameters from GeoStat.
double mfCosRotationAngle
double mfSinRotationAngle
Degree100 m_nRotationAngle
const OUString & getNumThousandSep() const
const OUString & getNumDecimalSep() const
static sal_uInt16 getNumDigits()
static bool isNumLeadingZero()
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
const LocaleDataWrapper & GetLocaleData() const
void Move(tools::Long nHorzMove, tools::Long nVertMove)
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
tools::Long FRound(double fVal)
#define SAL_WARN(area, stream)
double div(const double &fNumerator, const double &fDenominator)
tools::Rectangle polygonToRectangle(const tools::Polygon &rPolygon, GeoStat &rGeo)
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 CrookRotatePoly(XPolygon &rPoly, const Point &rCenter, const Point &rRad, bool bVert)
void ResizeXPoly(XPolygon &rPoly, const Point &rRef, const Fraction &xFact, const Fraction &yFact)
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 ShearXPoly(XPolygon &rPoly, const Point &rRef, double tn, bool bVShear)
FrPair GetMapFactor(MapUnit eS, MapUnit eD)
void OrthoDistance4(const Point &rPt0, Point &rPt, bool bBigOrtho)
tools::Polygon Rect2Poly(const tools::Rectangle &rRect, const GeoStat &rGeo)
void RotateXPoly(XPolygon &rPoly, const Point &rRef, double sn, double cs)
double CrookSlantXPoint(Point &rPnt, Point *pC1, Point *pC2, const Point &rCenter, const Point &rRad, double &rSin, double &rCos, bool bVert)
static FrPair GetInchOrMM(MapUnit eU)
void OrthoDistance8(const Point &rPt0, Point &rPt, bool bBigOrtho)
double CrookStretchXPoint(Point &rPnt, Point *pC1, Point *pC2, const Point &rCenter, const Point &rRad, double &rSin, double &rCos, bool bVert, const tools::Rectangle &rRefRect)
sal_uInt16 GetAngleSector(Degree100 nAngle)
Normalize angle to 0.00..359.99.
void CrookSlantPoly(XPolygon &rPoly, const Point &rCenter, const Point &rRad, bool bVert)
Degree100 GetAngle(const Point &rPnt)
The Y axis points down! The function negates the Y axis, when calculating the angle,...
void MirrorPoint(Point &rPnt, const Point &rRef1, const Point &rRef2)
void RotatePoly(tools::Polygon &rPoly, const Point &rRef, double sn, double cs)
void ShearPoly(tools::Polygon &rPoly, const Point &rRef, double tn)
Degree100 NormAngle18000(Degree100 a)
tools::Long GetLen(const Point &rPnt)
Determine sector within the cartesian coordinate system.
static FrPair toPair(o3tl::Length eFrom, o3tl::Length eTo)
tools::Long BigMulDiv(tools::Long nVal, tools::Long nMul, tools::Long nDiv)
Degree100 NormAngle36000(Degree100 a)
Normalize angle to -180.00..179.99.
void ResizePoly(tools::Polygon &rPoly, const Point &rRef, const Fraction &xFact, const Fraction &yFact)
void MoveXPoly(XPolygon &rPoly, const Size &S)
void MirrorXPoly(XPolygon &rPoly, const Point &rRef1, const Point &rRef2)
void ShearPoint(Point &rPnt, const Point &rRef, double tn, bool bVShear=false)
void RotatePoint(Point &rPnt, const Point &rRef, double sn, double cs)
constexpr Degree100 SDRMAXSHEAR(8900)
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)