summaryrefslogtreecommitdiff
path: root/vcl/source/outdev
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-10-20 07:27:44 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-10-21 08:13:05 +0200
commit0fb58a1ff168ae122e9c8993a3136658e3b0e3f0 (patch)
tree908983b02f466e0a49599edc70aaa1baaa240371 /vcl/source/outdev
parentb84afd2188d6993c91081885dc24664bd3f1cc73 (diff)
new tools::Degree10 strong typedef
partly to flush some use of "long" out the codebase, but also to make it obvious which units are being used for angle values. Change-Id: I1dc22494ca42c4677a63f685d5903f2b89886dc2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104548 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source/outdev')
-rw-r--r--vcl/source/outdev/bitmap.cxx2
-rw-r--r--vcl/source/outdev/font.cxx4
-rw-r--r--vcl/source/outdev/gradient.cxx8
-rw-r--r--vcl/source/outdev/hatch.cxx26
-rw-r--r--vcl/source/outdev/text.cxx14
-rw-r--r--vcl/source/outdev/textline.cxx10
6 files changed, 32 insertions, 32 deletions
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 10c7f0d164d2..6ba48c1699d5 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -1434,7 +1434,7 @@ void OutputDevice::DrawTransformedBitmapEx(
{
fFullRotate += F_2PI;
}
- tools::Long nAngle10 = basegfx::fround(basegfx::rad2deg(fFullRotate) * 10);
+ Degree10 nAngle10(basegfx::fround(basegfx::rad2deg(fFullRotate) * 10));
aTransformed.Rotate(nAngle10, COL_TRANSPARENT);
}
basegfx::B2DRange aTargetRange(0.0, 0.0, 1.0, 1.0);
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 9d4883ccea8d..a5301e3a594a 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -1033,7 +1033,7 @@ bool OutputDevice::ImplNewFont() const
// get metric data from device layers
pFontInstance->mbInit = true;
- pFontInstance->mxFontMetric->SetOrientation( sal::static_int_cast<short>(mpFontInstance->GetFontSelectPattern().mnOrientation) );
+ pFontInstance->mxFontMetric->SetOrientation( mpFontInstance->GetFontSelectPattern().mnOrientation );
mpGraphics->GetFontMetric( pFontInstance->mxFontMetric, 0 );
pFontInstance->mxFontMetric->ImplInitTextLineSize( this );
@@ -1123,7 +1123,7 @@ void OutputDevice::SetFontOrientation( LogicalFontInstance* const pFontInstance
{
if( pFontInstance->GetFontSelectPattern().mnOrientation && !pFontInstance->mxFontMetric->GetOrientation() )
{
- pFontInstance->mnOwnOrientation = sal::static_int_cast<short>(pFontInstance->GetFontSelectPattern().mnOrientation);
+ pFontInstance->mnOwnOrientation = pFontInstance->GetFontSelectPattern().mnOrientation;
pFontInstance->mnOrientation = pFontInstance->mnOwnOrientation;
}
else
diff --git a/vcl/source/outdev/gradient.cxx b/vcl/source/outdev/gradient.cxx
index 0acd89dfdb18..d67430da187d 100644
--- a/vcl/source/outdev/gradient.cxx
+++ b/vcl/source/outdev/gradient.cxx
@@ -264,7 +264,7 @@ void OutputDevice::DrawLinearGradient( const tools::Rectangle& rRect,
// get BoundRect of rotated rectangle
tools::Rectangle aRect;
Point aCenter;
- sal_uInt16 nAngle = rGradient.GetAngle() % 3600;
+ Degree10 nAngle = rGradient.GetAngle() % Degree10(3600);
rGradient.GetBoundRect( rRect, aRect, aCenter );
@@ -469,7 +469,7 @@ void OutputDevice::DrawComplexGradient( const tools::Rectangle& rRect,
tools::Long nRedSteps = nEndRed - nStartRed;
tools::Long nGreenSteps = nEndGreen - nStartGreen;
tools::Long nBlueSteps = nEndBlue - nStartBlue;
- sal_uInt16 nAngle = rGradient.GetAngle() % 3600;
+ Degree10 nAngle = rGradient.GetAngle() % Degree10(3600);
rGradient.GetBoundRect( rRect, aRect, aCenter );
@@ -622,7 +622,7 @@ void OutputDevice::DrawLinearGradientToMetafile( const tools::Rectangle& rRect,
// get BoundRect of rotated rectangle
tools::Rectangle aRect;
Point aCenter;
- sal_uInt16 nAngle = rGradient.GetAngle() % 3600;
+ Degree10 nAngle = rGradient.GetAngle() % Degree10(3600);
rGradient.GetBoundRect( rRect, aRect, aCenter );
@@ -819,7 +819,7 @@ void OutputDevice::DrawComplexGradientToMetafile( const tools::Rectangle& rRect,
tools::Long nRedSteps = nEndRed - nStartRed;
tools::Long nGreenSteps = nEndGreen - nStartGreen;
tools::Long nBlueSteps = nEndBlue - nStartBlue;
- sal_uInt16 nAngle = rGradient.GetAngle() % 3600;
+ Degree10 nAngle = rGradient.GetAngle() % Degree10(3600);
rGradient.GetBoundRect( rRect, aRect, aCenter );
diff --git a/vcl/source/outdev/hatch.cxx b/vcl/source/outdev/hatch.cxx
index 4ee38bff1aa2..bb2cb67cb1ac 100644
--- a/vcl/source/outdev/hatch.cxx
+++ b/vcl/source/outdev/hatch.cxx
@@ -186,7 +186,7 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch&
if( ( rHatch.GetStyle() == HatchStyle::Double ) || ( rHatch.GetStyle() == HatchStyle::Triple ) )
{
// Double hatch
- CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 900, aPt1, aPt2, aInc, aEndPt1 );
+ CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + Degree10(900), aPt1, aPt2, aInc, aEndPt1 );
do
{
DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf );
@@ -198,7 +198,7 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch&
if( rHatch.GetStyle() == HatchStyle::Triple )
{
// Triple hatch
- CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 450, aPt1, aPt2, aInc, aEndPt1 );
+ CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + Degree10(450), aPt1, aPt2, aInc, aEndPt1 );
do
{
DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf );
@@ -211,19 +211,19 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch&
}
}
-void OutputDevice::CalcHatchValues( const tools::Rectangle& rRect, tools::Long nDist, sal_uInt16 nAngle10,
+void OutputDevice::CalcHatchValues( const tools::Rectangle& rRect, tools::Long nDist, Degree10 nAngle10,
Point& rPt1, Point& rPt2, Size& rInc, Point& rEndPt1 )
{
Point aRef;
- tools::Long nAngle = nAngle10 % 1800;
+ Degree10 nAngle = nAngle10 % Degree10(1800);
tools::Long nOffset = 0;
- if( nAngle > 900 )
- nAngle -= 1800;
+ if( nAngle > Degree10(900) )
+ nAngle -= Degree10(1800);
aRef = ( !IsRefPoint() ? rRect.TopLeft() : GetRefPoint() );
- if( 0 == nAngle )
+ if( Degree10(0) == nAngle )
{
rInc = Size( 0, nDist );
rPt1 = rRect.TopLeft();
@@ -238,7 +238,7 @@ void OutputDevice::CalcHatchValues( const tools::Rectangle& rRect, tools::Long n
rPt1.AdjustY( -nOffset );
rPt2.AdjustY( -nOffset );
}
- else if( 900 == nAngle )
+ else if( Degree10(900) == nAngle )
{
rInc = Size( nDist, 0 );
rPt1 = rRect.TopLeft();
@@ -253,9 +253,9 @@ void OutputDevice::CalcHatchValues( const tools::Rectangle& rRect, tools::Long n
rPt1.AdjustX( -nOffset );
rPt2.AdjustX( -nOffset );
}
- else if( nAngle >= -450 && nAngle <= 450 )
+ else if( nAngle >= Degree10(-450) && nAngle <= Degree10(450) )
{
- const double fAngle = F_PI1800 * labs( nAngle );
+ const double fAngle = F_PI1800 * labs( nAngle.get() );
const double fTan = tan( fAngle );
const tools::Long nYOff = FRound( ( rRect.Right() - rRect.Left() ) * fTan );
tools::Long nPY;
@@ -263,7 +263,7 @@ void OutputDevice::CalcHatchValues( const tools::Rectangle& rRect, tools::Long n
nDist = FRound( nDist / cos( fAngle ) );
rInc = Size( 0, nDist );
- if( nAngle > 0 )
+ if( nAngle > Degree10(0) )
{
rPt1 = rRect.TopLeft();
rPt2 = Point( rRect.Right(), rRect.Top() - nYOff );
@@ -288,7 +288,7 @@ void OutputDevice::CalcHatchValues( const tools::Rectangle& rRect, tools::Long n
}
else
{
- const double fAngle = F_PI1800 * labs( nAngle );
+ const double fAngle = F_PI1800 * labs( nAngle.get() );
const double fTan = tan( fAngle );
const tools::Long nXOff = FRound( ( rRect.Bottom() - rRect.Top() ) / fTan );
tools::Long nPX;
@@ -296,7 +296,7 @@ void OutputDevice::CalcHatchValues( const tools::Rectangle& rRect, tools::Long n
nDist = FRound( nDist / sin( fAngle ) );
rInc = Size( nDist, 0 );
- if( nAngle > 0 )
+ if( nAngle > Degree10(0) )
{
rPt1 = rRect.TopLeft();
rPt2 = Point( rRect.Left() - nXOff, rRect.Bottom() );
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 5c4b355c2536..8573affbae99 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -89,13 +89,13 @@ void OutputDevice::ImplDrawTextRect( tools::Long nBaseX, tools::Long nBaseY,
tools::Long nX = nDistX;
tools::Long nY = nDistY;
- short nOrientation = mpFontInstance->mnOrientation;
+ Degree10 nOrientation = mpFontInstance->mnOrientation;
if ( nOrientation )
{
// Rotate rect without rounding problems for 90 degree rotations
- if ( !(nOrientation % 900) )
+ if ( !(nOrientation % Degree10(900)) )
{
- if ( nOrientation == 900 )
+ if ( nOrientation == Degree10(900) )
{
tools::Long nTemp = nX;
nX = nY;
@@ -105,7 +105,7 @@ void OutputDevice::ImplDrawTextRect( tools::Long nBaseX, tools::Long nBaseY,
nHeight = nTemp;
nY -= nHeight;
}
- else if ( nOrientation == 1800 )
+ else if ( nOrientation == Degree10(1800) )
{
nX = -nX;
nY = -nY;
@@ -176,7 +176,7 @@ tools::Rectangle OutputDevice::ImplGetTextBoundRect( const SalLayout& rSalLayout
if ( mpFontInstance->mnOrientation )
{
tools::Long nBaseX = nX, nBaseY = nY;
- if ( !(mpFontInstance->mnOrientation % 900) )
+ if ( !(mpFontInstance->mnOrientation % Degree10(900)) )
{
tools::Long nX2 = nX+nWidth;
tools::Long nY2 = nY+nHeight;
@@ -228,7 +228,7 @@ bool OutputDevice::ImplDrawRotateText( SalLayout& rSalLayout )
const FontSelectPattern& rPattern = mpFontInstance->GetFontSelectPattern();
vcl::Font aFont( GetFont() );
- aFont.SetOrientation( 0 );
+ aFont.SetOrientation( Degree10(0) );
aFont.SetFontSize( Size( rPattern.mnWidth, rPattern.mnHeight ) );
pVDev->SetFont( aFont );
pVDev->SetTextColor( COL_BLACK );
@@ -1241,7 +1241,7 @@ ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr,
// set layout options
ImplLayoutArgs aLayoutArgs(rStr, nMinIndex, nEndIndex, nLayoutFlags, maFont.GetLanguageTag(), pLayoutCache);
- int nOrientation = mpFontInstance ? mpFontInstance->mnOrientation : 0;
+ Degree10 nOrientation = mpFontInstance ? mpFontInstance->mnOrientation : Degree10(0);
aLayoutArgs.SetOrientation( nOrientation );
aLayoutArgs.SetLayoutWidth( nPixelWidth );
diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx
index eb716ebdb49f..09ee52f6339a 100644
--- a/vcl/source/outdev/textline.cxx
+++ b/vcl/source/outdev/textline.cxx
@@ -49,7 +49,7 @@ void OutputDevice::ImplInitAboveTextLineSize()
void OutputDevice::ImplDrawWavePixel( tools::Long nOriginX, tools::Long nOriginY,
tools::Long nCurX, tools::Long nCurY,
- short nOrientation,
+ Degree10 nOrientation,
SalGraphics* pGraphics,
OutputDevice const * pOutDev,
bool bDrawPixAsRect,
@@ -75,7 +75,7 @@ void OutputDevice::ImplDrawWavePixel( tools::Long nOriginX, tools::Long nOriginY
void OutputDevice::ImplDrawWaveLine( tools::Long nBaseX, tools::Long nBaseY,
tools::Long nDistX, tools::Long nDistY,
tools::Long nWidth, tools::Long nHeight,
- tools::Long nLineWidth, short nOrientation,
+ tools::Long nLineWidth, Degree10 nOrientation,
const Color& rColor )
{
if ( !nHeight )
@@ -678,7 +678,7 @@ void OutputDevice::ImplDrawTextLine( tools::Long nX, tools::Long nY,
{
tools::Long nXAdd = nWidth - nDistX;
if( mpFontInstance->mnOrientation )
- nXAdd = FRound( nXAdd * cos( mpFontInstance->mnOrientation * F_PI1800 ) );
+ nXAdd = FRound( nXAdd * cos( mpFontInstance->mnOrientation.get() * F_PI1800 ) );
nX += nXAdd - 1;
}
@@ -750,7 +750,7 @@ void OutputDevice::ImplDrawTextLines( SalLayout& rSalLayout, FontStrikeout eStri
if( mpFontInstance->mnOrientation )
{
const tools::Long nDY = aPos.Y() - aStartPt.Y();
- const double fRad = mpFontInstance->mnOrientation * F_PI1800;
+ const double fRad = mpFontInstance->mnOrientation.get() * F_PI1800;
nDist = FRound( nDist*cos(fRad) - nDY*sin(fRad) );
}
}
@@ -972,7 +972,7 @@ void OutputDevice::DrawWaveLine(const Point& rStartPos, const Point& rEndPos, to
fOrientation = std::atan2(nStartY - nEndY, (nLengthX == 0 ? 0.000000001 : nLengthX));
fOrientation /= F_PI180;
// un-rotate the end point
- aStartPt.RotateAround(nEndX, nEndY, -fOrientation * 10.0);
+ aStartPt.RotateAround(nEndX, nEndY, Degree10(static_cast<sal_Int16>(-fOrientation * 10.0)));
}
tools::Long nWaveHeight = 3;