/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
double CrookRotateXPoint(Point& rPnt, Point* pC1, Point* pC2, const Point& rCenter, const Point& rRad, double& rSin, double& rCos, bool bVert)
{ bool bC1=pC1!=nullptr; bool bC2=pC2!=nullptr;
tools::Long x0=rPnt.X();
tools::Long y0=rPnt.Y();
tools::Long cx=rCenter.X();
tools::Long cy=rCenter.Y(); double nAngle=GetCrookAngle(rPnt,rCenter,rRad,bVert); double sn=sin(nAngle); double cs=cos(nAngle);
RotatePoint(rPnt,rCenter,sn,cs); if (bC1) { if (bVert) { // move into the direction of the center, as a basic position for the rotation
pC1->AdjustY( -y0 ); // resize, account for the distance from the center
pC1->setY(basegfx::fround<tools::Long>(static_cast<double>(pC1->Y()) /rRad.X()*(cx-pC1->X())) );
pC1->AdjustY(cy );
} else { // move into the direction of the center, as a basic position for the rotation
pC1->AdjustX( -x0 ); // resize, account for the distance from the center
tools::Long nPntRad=cy-pC1->Y(); double nFact=static_cast<double>(nPntRad)/static_cast<double>(rRad.Y());
pC1->setX(basegfx::fround<tools::Long>(static_cast<double>(pC1->X()) * nFact));
pC1->AdjustX(cx );
}
RotatePoint(*pC1,rCenter,sn,cs);
} if (bC2) { if (bVert) { // move into the direction of the center, as a basic position for the rotation
pC2->AdjustY( -y0 ); // resize, account for the distance from the center
pC2->setY(basegfx::fround<tools::Long>(static_cast<double>(pC2->Y()) /rRad.X()*(rCenter.X()-pC2->X())) );
pC2->AdjustY(cy );
} else { // move into the direction of the center, as a basic position for the rotation
pC2->AdjustX( -x0 ); // resize, account for the distance from the center
tools::Long nPntRad=rCenter.Y()-pC2->Y(); double nFact=static_cast<double>(nPntRad)/static_cast<double>(rRad.Y());
pC2->setX(basegfx::fround<tools::Long>(static_cast<double>(pC2->X()) * nFact));
pC2->AdjustX(cx );
}
RotatePoint(*pC2,rCenter,sn,cs);
}
rSin=sn;
rCos=cs; return nAngle;
}
void CrookRotatePoly(XPolygon& rPoly, const Point& rCenter, const Point& rRad, bool bVert)
{ double nSin,nCos;
sal_uInt16 nPointCnt=rPoly.GetPointCount();
sal_uInt16 i=0; while (i<nPointCnt) {
Point* pPnt=&rPoly[i];
Point* pC1=nullptr;
Point* pC2=nullptr; if (i+1<nPointCnt && rPoly.IsControl(i)) { // control point to the left
pC1=pPnt;
i++;
pPnt=&rPoly[i];
}
i++; if (i<nPointCnt && rPoly.IsControl(i)) { // control point to the right
pC2=&rPoly[i];
i++;
}
CrookRotateXPoint(*pPnt,pC1,pC2,rCenter,rRad,nSin,nCos,bVert);
}
}
void CrookSlantPoly(XPolygon& rPoly, const Point& rCenter, const Point& rRad, bool bVert)
{ double nSin,nCos;
sal_uInt16 nPointCnt=rPoly.GetPointCount();
sal_uInt16 i=0; while (i<nPointCnt) {
Point* pPnt=&rPoly[i];
Point* pC1=nullptr;
Point* pC2=nullptr; if (i+1<nPointCnt && rPoly.IsControl(i)) { // control point to the left
pC1=pPnt;
i++;
pPnt=&rPoly[i];
}
i++; if (i<nPointCnt && rPoly.IsControl(i)) { // control point to the right
pC2=&rPoly[i];
i++;
}
CrookSlantXPoint(*pPnt,pC1,pC2,rCenter,rRad,nSin,nCos,bVert);
}
}
void CrookStretchPoly(XPolygon& rPoly, const Point& rCenter, const Point& rRad, bool bVert, const tools::Rectangle& rRefRect)
{ double nSin,nCos;
sal_uInt16 nPointCnt=rPoly.GetPointCount();
sal_uInt16 i=0; while (i<nPointCnt) {
Point* pPnt=&rPoly[i];
Point* pC1=nullptr;
Point* pC2=nullptr; if (i+1<nPointCnt && rPoly.IsControl(i)) { // control point to the left
pC1=pPnt;
i++;
pPnt=&rPoly[i];
}
i++; if (i<nPointCnt && rPoly.IsControl(i)) { // control point to the right
pC2=&rPoly[i];
i++;
}
CrookStretchXPoint(*pPnt,pC1,pC2,rCenter,rRad,nSin,nCos,bVert,rRefRect);
}
}
Point aPoint1(rPolygon[1] - rPolygon[0]); if (rGeo.m_nRotationAngle)
RotatePoint(aPoint1, Point(0,0), -rGeo.mfSinRotationAngle, rGeo.mfCosRotationAngle); // -Sin to reverse rotation
tools::Long nWidth = aPoint1.X();
Point aPoint0(rPolygon[0]);
Point aPoint3(rPolygon[3] - rPolygon[0]); if (rGeo.m_nRotationAngle)
RotatePoint(aPoint3, Point(0,0), -rGeo.mfSinRotationAngle, rGeo.mfCosRotationAngle); // -Sin to reverse rotation
tools::Long nHeight = aPoint3.Y();
Degree100 nShearAngle = GetAngle(aPoint3);
nShearAngle -= 27000_deg100; // ShearWink is measured against a vertical line
nShearAngle = -nShearAngle; // negating, because '+' is shearing clock-wise
bool bMirror = aPoint3.Y() < 0; if (bMirror)
{ // "exchange of points" when mirroring
nHeight = -nHeight;
nShearAngle += 18000_deg100;
aPoint0 = rPolygon[3];
}
// we may lose some decimal places here, because of MulDiv instead of Real bool bNeg(nVal < 0);
SvtSysLocale aSysLoc; const LocaleDataWrapper& rLoc = aSysLoc.GetLocaleData();
if (m_bDirty) const_cast<SdrFormatter*>(this)->Undirty();
OUString SdrFormatter::GetUnitStr(MapUnit eUnit)
{ switch(eUnit)
{ // metrically case MapUnit::Map100thMM : return u"/100mm"_ustr; case MapUnit::Map10thMM : return u"/10mm"_ustr; case MapUnit::MapMM : return u"mm"_ustr; case MapUnit::MapCM : return u"cm"_ustr;
// Inch case MapUnit::Map1000thInch: return u"/1000\""_ustr; case MapUnit::Map100thInch : return u"/100\""_ustr; case MapUnit::Map10thInch : return u"/10\""_ustr; case MapUnit::MapInch : return u"\""_ustr; case MapUnit::MapPoint : return u"pt"_ustr; case MapUnit::MapTwip : return u"twip"_ustr;
// others case MapUnit::MapPixel : return u"pixel"_ustr; case MapUnit::MapSysFont : return u"sysfont"_ustr; case MapUnit::MapAppFont : return u"appfont"_ustr; case MapUnit::MapRelative : return u"%"_ustr; default: return OUString();
}
}
OUString SdrFormatter::GetUnitStr(FieldUnit eUnit)
{ switch(eUnit)
{ default : case FieldUnit::NONE : case FieldUnit::CUSTOM : return OUString();
// metrically case FieldUnit::MM_100TH: return u"/100mm"_ustr; case FieldUnit::MM : return u"mm"_ustr; case FieldUnit::CM : return u"cm"_ustr; case FieldUnit::M : return u"m"_ustr; case FieldUnit::KM : return u"km"_ustr;
// Inch case FieldUnit::TWIP : return u"twip"_ustr; case FieldUnit::POINT : return u"pt"_ustr; case FieldUnit::PICA : return u"pica"_ustr; case FieldUnit::INCH : return u"\""_ustr; case FieldUnit::FOOT : return u"ft"_ustr; case FieldUnit::MILE : return u"mile(s)"_ustr;
// others case FieldUnit::PERCENT: return u"%"_ustr;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.