diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-10-20 07:27:44 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-10-21 08:13:05 +0200 |
commit | 0fb58a1ff168ae122e9c8993a3136658e3b0e3f0 (patch) | |
tree | 908983b02f466e0a49599edc70aaa1baaa240371 /vcl | |
parent | b84afd2188d6993c91081885dc24664bd3f1cc73 (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')
60 files changed, 204 insertions, 197 deletions
diff --git a/vcl/backendtest/outputdevice/gradient.cxx b/vcl/backendtest/outputdevice/gradient.cxx index c0ed3fc1b717..e9b454660cbc 100644 --- a/vcl/backendtest/outputdevice/gradient.cxx +++ b/vcl/backendtest/outputdevice/gradient.cxx @@ -18,7 +18,7 @@ Bitmap OutputDeviceTestGradient::setupLinearGradient() initialSetup(12, 12, constBackgroundColor); Gradient aGradient(GradientStyle::Linear, Color(0xFF, 0xFF, 0xFF), Color(0x00, 0x00, 0x00)); - aGradient.SetAngle(900); + aGradient.SetAngle(Degree10(900)); tools::Rectangle aDrawRect(maVDRectangle.Left() + 1, maVDRectangle.Top() + 1, maVDRectangle.Right() - 1, maVDRectangle.Bottom() - 1); mpVirtualDevice->DrawGradient(aDrawRect, aGradient); @@ -31,7 +31,7 @@ Bitmap OutputDeviceTestGradient::setupLinearGradientAngled() initialSetup(12, 12, constBackgroundColor); Gradient aGradient(GradientStyle::Linear, Color(0xFF, 0xFF, 0xFF), Color(0x00, 0x00, 0x00)); - aGradient.SetAngle(450); + aGradient.SetAngle(Degree10(450)); tools::Rectangle aDrawRect(maVDRectangle.Left() + 1, maVDRectangle.Top() + 1, maVDRectangle.Right() - 1, maVDRectangle.Bottom() - 1); mpVirtualDevice->DrawGradient(aDrawRect, aGradient); @@ -70,7 +70,7 @@ Bitmap OutputDeviceTestGradient::setupLinearGradientSteps() initialSetup(12, 12, constBackgroundColor); Gradient aGradient(GradientStyle::Linear, Color(0xFF, 0xFF, 0xFF), Color(0x00, 0x00, 0x00)); - aGradient.SetAngle(900); + aGradient.SetAngle(Degree10(900)); aGradient.SetSteps(4); tools::Rectangle aDrawRect(maVDRectangle.Left() + 1, maVDRectangle.Top() + 1, maVDRectangle.Right() - 1, maVDRectangle.Bottom() - 1); @@ -84,7 +84,7 @@ Bitmap OutputDeviceTestGradient::setupAxialGradient() initialSetup(13, 13, constBackgroundColor); Gradient aGradient(GradientStyle::Axial, Color(0xFF, 0xFF, 0xFF), Color(0x00, 0x00, 0x00)); - aGradient.SetAngle(900); + aGradient.SetAngle(Degree10(900)); tools::Rectangle aDrawRect(maVDRectangle.Left() + 1, maVDRectangle.Top() + 1, maVDRectangle.Right() - 1, maVDRectangle.Bottom() - 1); mpVirtualDevice->DrawGradient(aDrawRect, aGradient); diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index edf0e061d0a6..7116cf70f7b2 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -1947,7 +1947,7 @@ bool SvpSalGraphics::drawGradient(const tools::PolyPolygon& rPolyPolygon, const tools::Rectangle aBoundRect; Point aCenter; - aGradient.SetAngle(aGradient.GetAngle() + 2700); + aGradient.SetAngle(aGradient.GetAngle() + Degree10(2700)); aGradient.GetBoundRect(aInputRect, aBoundRect, aCenter); Color aStartColor = aGradient.GetStartColor(); Color aEndColor = aGradient.GetEndColor(); @@ -1956,7 +1956,7 @@ bool SvpSalGraphics::drawGradient(const tools::PolyPolygon& rPolyPolygon, const if (rGradient.GetStyle() == GradientStyle::Linear) { tools::Polygon aPoly(aBoundRect); - aPoly.Rotate(aCenter, aGradient.GetAngle() % 3600); + aPoly.Rotate(aCenter, aGradient.GetAngle() % Degree10(3600)); pattern = cairo_pattern_create_linear(aPoly[0].X(), aPoly[0].Y(), aPoly[1].X(), aPoly[1].Y()); } else diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx index f20c0abbdfe7..7dc78ac05533 100644 --- a/vcl/inc/fontinstance.hxx +++ b/vcl/inc/fontinstance.hxx @@ -28,6 +28,7 @@ #include <salhelper/simplereferenceobject.hxx> #include <tools/gen.hxx> #include <tools/fontenum.hxx> +#include <tools/degree.hxx> #include <vcl/glyphitem.hxx> #include <optional> @@ -56,8 +57,8 @@ public: // TODO: make data members private const ConvertChar* mpConversion; // used e.g. for StarBats->StarSymbol tools::Long mnLineHeight; - short mnOwnOrientation; // text angle if lower layers don't rotate text themselves - short mnOrientation; // text angle in 3600 system + Degree10 mnOwnOrientation; // text angle if lower layers don't rotate text themselves + Degree10 mnOrientation; // text angle in 3600 system bool mbInit; // true if maFontMetric member is valid void AddFallbackForUnicode( sal_UCS4, FontWeight eWeight, const OUString& rFontName ); diff --git a/vcl/inc/fontselect.hxx b/vcl/inc/fontselect.hxx index 7df7dd93072a..c517268763d4 100644 --- a/vcl/inc/fontselect.hxx +++ b/vcl/inc/fontselect.hxx @@ -21,6 +21,7 @@ #define INCLUDED_VCL_INC_FONTSELECT_HXX #include <i18nlangtag/lang.h> +#include <tools/degree.hxx> #include <vcl/vclenum.hxx> #include "fontattributes.hxx" @@ -59,7 +60,7 @@ public: int mnWidth; // width of font in pixel units int mnHeight; // height of font in pixel units float mfExactHeight; // requested height (in pixels with subpixel details) - int mnOrientation; // text orientation in 1/10 degree (0-3600) + Degree10 mnOrientation; // text orientation in 1/10 degree (0-3600) LanguageType meLanguage; // text language bool mbVertical; // vertical mode of requested font bool mbNonAntialiased; // true if antialiasing is disabled diff --git a/vcl/inc/impfont.hxx b/vcl/inc/impfont.hxx index 7f4301d97778..caa917a751f0 100644 --- a/vcl/inc/impfont.hxx +++ b/vcl/inc/impfont.hxx @@ -126,7 +126,7 @@ private: bool mbWordLine:1; // TODO: metric data, should be migrated to ImplFontMetric - short mnOrientation; + Degree10 mnOrientation; int mnQuality; diff --git a/vcl/inc/impfontmetricdata.hxx b/vcl/inc/impfontmetricdata.hxx index ec1d98ccba41..a1d5db86bd8c 100644 --- a/vcl/inc/impfontmetricdata.hxx +++ b/vcl/inc/impfontmetricdata.hxx @@ -42,10 +42,10 @@ public: // font instance attributes from the font request tools::Long GetWidth() const { return mnWidth; } - short GetOrientation() const { return mnOrientation; } + Degree10 GetOrientation() const { return mnOrientation; } void SetWidth(tools::Long nWidth) { mnWidth=nWidth; } - void SetOrientation(short nOrientation) { mnOrientation=nOrientation; } + void SetOrientation(Degree10 nOrientation) { mnOrientation=nOrientation; } // font metrics measured for the font instance tools::Long GetAscent() const { return mnAscent; } @@ -102,7 +102,7 @@ private: // font instance attributes from the font request tools::Long mnHeight; // Font size tools::Long mnWidth; // Reference Width - short mnOrientation; // Rotation in 1/10 degrees + Degree10 mnOrientation; // Rotation in 1/10 degrees // font metrics measured for the font instance tools::Long mnAscent; // Ascent diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 6e8b2afb2854..bf93c0f64028 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -31,6 +31,7 @@ #include <basegfx/polygon/b2dpolypolygon.hxx> #include <i18nlangtag/languagetag.hxx> #include <tools/gen.hxx> +#include <tools/degree.hxx> #include <vcl/dllapi.h> #include <vcl/vclenum.hxx> // for typedef sal_UCS4 #include <vcl/devicecoordinate.hxx> @@ -88,7 +89,7 @@ public: // positioning related inputs const DeviceCoordinate* mpDXArray; // in pixel units DeviceCoordinate mnLayoutWidth; // in pixel units - int mnOrientation; // in 0-3600 system + Degree10 mnOrientation; // in 0-3600 system // data for bidi and glyph+script fallback ImplLayoutRuns maRuns; @@ -101,7 +102,7 @@ public: void SetLayoutWidth( DeviceCoordinate nWidth ) { mnLayoutWidth = nWidth; } void SetDXArray( const DeviceCoordinate* pDXArray ) { mpDXArray = pDXArray; } - void SetOrientation( int nOrientation ) { mnOrientation = nOrientation; } + void SetOrientation( Degree10 nOrientation ) { mnOrientation = nOrientation; } void ResetPos() { maRuns.ResetPos(); } diff --git a/vcl/inc/toolbox.h b/vcl/inc/toolbox.h index a1f0cd2aaf33..8aa6bb915fcb 100644 --- a/vcl/inc/toolbox.h +++ b/vcl/inc/toolbox.h @@ -38,7 +38,7 @@ struct ImplToolItem bool mbNonInteractiveWindow; void* mpUserData; Image maImage; - tools::Long mnImageAngle; + Degree10 mnImageAngle; bool mbMirrorMode; OUString maText; OUString maQuickHelpText; diff --git a/vcl/inc/unx/printergfx.hxx b/vcl/inc/unx/printergfx.hxx index fcb8a9241fd8..ff4b51cb04dc 100644 --- a/vcl/inc/unx/printergfx.hxx +++ b/vcl/inc/unx/printergfx.hxx @@ -183,7 +183,7 @@ private: std::vector< GlyphSet > maPS3Font; sal_Int32 mnFontID; - sal_Int32 mnTextAngle; + Degree10 mnTextAngle; bool mbTextVertical; PrintFontManager& mrFontMgr; @@ -243,7 +243,7 @@ public: void PSBinPath (const Point& rCurrent, Point& rOld, pspath_t eType, sal_Int32& nColumn); - void PSRotate (sal_Int32 nAngle); + void PSRotate (Degree10 nAngle); void PSTranslate (const Point& rPoint); void PSMoveTo (const Point& rPoint); void PSScale (double fScaleX, double fScaleY); @@ -315,7 +315,7 @@ public: sal_Int32 nFontID, sal_Int32 nPointHeight, sal_Int32 nPointWidth, - sal_Int32 nAngle, + Degree10 nAngle, bool bVertical, bool bArtItalic, bool bArtBold diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 1c20a8ef9a46..d2218590091b 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -1430,7 +1430,7 @@ void OpenGLSalGraphicsImpl::DrawLinearGradient( const Gradient& rGradient, const Point aCenter; rGradient.GetBoundRect( rRect, aBoundRect, aCenter ); tools::Polygon aPoly( aBoundRect ); - aPoly.Rotate( aCenter, rGradient.GetAngle() % 3600 ); + aPoly.Rotate( aCenter, rGradient.GetAngle() % Degree10(3600) ); GLfloat aTexCoord[8] = { 0, 1, 1, 1, 1, 0, 0, 0 }; GLfloat fMin = 1.0 - 100.0 / (100.0 - rGradient.GetBorder()); @@ -1482,7 +1482,7 @@ void OpenGLSalGraphicsImpl::DrawAxialGradient( const Gradient& rGradient, const aPoly.SetPoint( aRect.BottomRight(), 4 ); aPoly.SetPoint( aRect.BottomLeft(), 5 ); aPoly.SetPoint( aPt0, 6 ); - aPoly.Rotate( aCenter, rGradient.GetAngle() % 3600 ); + aPoly.Rotate( aCenter, rGradient.GetAngle() % Degree10(3600) ); GLfloat aTexCoord[12] = { 0, 1, 1, 0, 2, 0, 3, 1, 4, 0, 5, 0 }; GLfloat fMin = 1.0 - 100.0 / (100.0 - rGradient.GetBorder()); diff --git a/vcl/qa/cppunit/GraphicNativeMetadataTest.cxx b/vcl/qa/cppunit/GraphicNativeMetadataTest.cxx index 7e5d1adcba66..42683a1a3f06 100644 --- a/vcl/qa/cppunit/GraphicNativeMetadataTest.cxx +++ b/vcl/qa/cppunit/GraphicNativeMetadataTest.cxx @@ -46,7 +46,7 @@ void GraphicNativeMetadataTest::testReadFromGraphic() { GraphicNativeMetadata aMetadata; aMetadata.read(aFileStream); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(1800), aMetadata.getRotation()); + CPPUNIT_ASSERT_EQUAL(sal_Int16(1800), aMetadata.getRotation().get()); // just the metadata shouldn't make the graphic available CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable()); } @@ -58,7 +58,7 @@ void GraphicNativeMetadataTest::testReadFromGraphic() GraphicNativeMetadata aMetadata; aMetadata.read(aFileStream); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(1800), aMetadata.getRotation()); + CPPUNIT_ASSERT_EQUAL(sal_Int16(1800), aMetadata.getRotation().get()); } } @@ -69,28 +69,28 @@ void GraphicNativeMetadataTest::testExifRotationJpeg() SvFileStream aFileStream(getFullUrl("Exif1.jpg"), StreamMode::READ); GraphicNativeMetadata aMetadata; aMetadata.read(aFileStream); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), aMetadata.getRotation()); + CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aMetadata.getRotation().get()); } { // Rotation 90 degree clock-wise = 270 degree counter-clock-wise SvFileStream aFileStream(getFullUrl("Exif1_090CW.jpg"), StreamMode::READ); GraphicNativeMetadata aMetadata; aMetadata.read(aFileStream); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(2700), aMetadata.getRotation()); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2700), aMetadata.getRotation().get()); } { // Rotation 180 degree SvFileStream aFileStream(getFullUrl("Exif1_180.jpg"), StreamMode::READ); GraphicNativeMetadata aMetadata; aMetadata.read(aFileStream); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(1800), aMetadata.getRotation()); + CPPUNIT_ASSERT_EQUAL(sal_Int16(1800), aMetadata.getRotation().get()); } { // Rotation 270 degree clock-wise = 90 degree counter-clock-wise SvFileStream aFileStream(getFullUrl("Exif1_270CW.jpg"), StreamMode::READ); GraphicNativeMetadata aMetadata; aMetadata.read(aFileStream); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(900), aMetadata.getRotation()); + CPPUNIT_ASSERT_EQUAL(sal_Int16(900), aMetadata.getRotation().get()); } } diff --git a/vcl/qa/cppunit/TypeSerializerTest.cxx b/vcl/qa/cppunit/TypeSerializerTest.cxx index 30966700a3a3..fd45662bdf20 100644 --- a/vcl/qa/cppunit/TypeSerializerTest.cxx +++ b/vcl/qa/cppunit/TypeSerializerTest.cxx @@ -87,7 +87,7 @@ TypeSerializerTest::~TypeSerializerTest() void TypeSerializerTest::testGradient() { Gradient aGradient(GradientStyle::Radial, Color(0xFF, 0x00, 0x00), Color(0x00, 0xFF, 0x00)); - aGradient.SetAngle(900); + aGradient.SetAngle(Degree10(900)); aGradient.SetBorder(5); aGradient.SetOfsX(11); aGradient.SetOfsY(12); @@ -105,7 +105,7 @@ void TypeSerializerTest::testGradient() CPPUNIT_ASSERT_EQUAL(GradientStyle::Radial, aReadGradient.GetStyle()); CPPUNIT_ASSERT_EQUAL(Color(0xFF, 0x00, 0x00), aReadGradient.GetStartColor()); CPPUNIT_ASSERT_EQUAL(Color(0x00, 0xFF, 0x00), aReadGradient.GetEndColor()); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(900), aReadGradient.GetAngle()); + CPPUNIT_ASSERT_EQUAL(sal_Int16(900), aReadGradient.GetAngle().get()); CPPUNIT_ASSERT_EQUAL(sal_uInt16(5), aReadGradient.GetBorder()); CPPUNIT_ASSERT_EQUAL(sal_uInt16(11), aReadGradient.GetOfsX()); CPPUNIT_ASSERT_EQUAL(sal_uInt16(12), aReadGradient.GetOfsY()); diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx index 17878c0656e6..f3ed205b4d8f 100644 --- a/vcl/qa/cppunit/svm/svmtest.cxx +++ b/vcl/qa/cppunit/svm/svmtest.cxx @@ -1271,7 +1271,7 @@ void SvmTest::testGradient() aGradient2.SetStyle(GradientStyle::Radial); aGradient2.SetStartColor(COL_LIGHTRED); aGradient2.SetEndColor(COL_LIGHTGREEN); - aGradient2.SetAngle(55); + aGradient2.SetAngle(Degree10(55)); aGradient2.SetBorder(10); aGradient2.SetOfsX(22); aGradient2.SetOfsY(24); @@ -1323,7 +1323,7 @@ void SvmTest::testHatch() tools::PolyPolygon aPolyPolygon(1); aPolyPolygon.Insert(aPolygon); - Hatch aHatch(HatchStyle::Single, COL_YELLOW, 15, 900); + Hatch aHatch(HatchStyle::Single, COL_YELLOW, 15, Degree10(900)); pVirtualDev->DrawHatch(aPolyPolygon, aHatch); diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx index b9eb2864bb45..431ab4e32f3d 100644 --- a/vcl/qt5/Qt5Graphics_Text.cxx +++ b/vcl/qt5/Qt5Graphics_Text.cxx @@ -279,7 +279,7 @@ public: { } - void SetOrientation(int nOrientation) { mnOrientation = nOrientation; } + void SetOrientation(Degree10 nOrientation) { mnOrientation = nOrientation; } }; } @@ -304,9 +304,9 @@ void Qt5Graphics::DrawTextLayout(const GenericSalLayout& rLayout) // probably better to add a parameter to GetNextGlyphs? Qt5CommonSalLayout* pQt5Layout = static_cast<Qt5CommonSalLayout*>(const_cast<GenericSalLayout*>(&rLayout)); - int nOrientation = rLayout.GetOrientation(); + Degree10 nOrientation = rLayout.GetOrientation(); if (nOrientation) - pQt5Layout->SetOrientation(0); + pQt5Layout->SetOrientation(Degree10(0)); Point aPos; const GlyphItem* pGlyph; @@ -338,7 +338,7 @@ void Qt5Graphics::DrawTextLayout(const GenericSalLayout& rLayout) aPainter.setWindow(window); QTransform p; - p.rotate(-static_cast<qreal>(nOrientation) / 10.0); + p.rotate(-static_cast<qreal>(nOrientation.get()) / 10.0); p.translate(-positions[0].x(), -positions[0].y()); aPainter.setTransform(p); } diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx index eb67d981fe95..20c05c98bbb1 100644 --- a/vcl/quartz/ctfonts.cxx +++ b/vcl/quartz/ctfonts.cxx @@ -56,7 +56,7 @@ CoreTextStyle::CoreTextStyle(const PhysicalFontFace& rPFF, const FontSelectPatte double fScaledFontHeight = rFSP.mfExactHeight; // convert font rotation to radian - mfFontRotation = toRadian(rFSP.mnOrientation); + mfFontRotation = toRadian(rFSP.mnOrientation.get()); // dummy matrix so we can use CGAffineTransformConcat() below CGAffineTransform aMatrix = CGAffineTransformMakeTranslation(0, 0); diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index 067348d364ed..d9440df0795d 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -1823,7 +1823,7 @@ bool SkiaSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPolygon, Gradient aGradient(rGradient); tools::Rectangle aBoundRect; Point aCenter; - aGradient.SetAngle(aGradient.GetAngle() + 2700); + aGradient.SetAngle(aGradient.GetAngle() + Degree10(2700)); aGradient.GetBoundRect(boundRect, aBoundRect, aCenter); SkColor startColor @@ -1834,7 +1834,7 @@ bool SkiaSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPolygon, if (rGradient.GetStyle() == GradientStyle::Linear) { tools::Polygon aPoly(aBoundRect); - aPoly.Rotate(aCenter, aGradient.GetAngle() % 3600); + aPoly.Rotate(aCenter, aGradient.GetAngle() % Degree10(3600)); SkPoint points[2] = { SkPoint::Make(toSkX(aPoly[0].X()), toSkY(aPoly[0].Y())), SkPoint::Make(toSkX(aPoly[1].X()), toSkY(aPoly[1].Y())) }; SkColor colors[2] = { startColor, endColor }; @@ -1893,9 +1893,9 @@ bool SkiaSalGraphicsImpl::implDrawGradient(const basegfx::B2DPolyPolygon& rPolyP return true; } -static double toRadian(int degree10th) { return (3600 - degree10th) * M_PI / 1800.0; } -static double toCos(int degree10th) { return SkScalarCos(toRadian(degree10th)); } -static double toSin(int degree10th) { return SkScalarSin(toRadian(degree10th)); } +static double toRadian(Degree10 degree10th) { return (3600 - degree10th.get()) * M_PI / 1800.0; } +static double toCos(Degree10 degree10th) { return SkScalarCos(toRadian(degree10th)); } +static double toSin(Degree10 degree10th) { return SkScalarSin(toRadian(degree10th)); } void SkiaSalGraphicsImpl::drawGenericLayout(const GenericSalLayout& layout, Color textColor, const SkFont& font, GlyphOrientation glyphOrientation) @@ -1911,12 +1911,12 @@ void SkiaSalGraphicsImpl::drawGenericLayout(const GenericSalLayout& layout, Colo while (layout.GetNextGlyph(&pGlyph, aPos, nStart)) { glyphIds.push_back(pGlyph->glyphId()); - int angle = 0; // 10th of degree + Degree10 angle(0); // 10th of degree if (glyphOrientation == GlyphOrientation::Apply) { angle = layout.GetOrientation(); if (pGlyph->IsVertical()) - angle += 900; // 90 degree + angle += Degree10(900); // 90 degree } SkRSXform form = SkRSXform::Make(toCos(angle), toSin(angle), aPos.X(), aPos.Y()); glyphForms.emplace_back(std::move(form)); diff --git a/vcl/source/bitmap/bitmappaint.cxx b/vcl/source/bitmap/bitmappaint.cxx index ebc7e1288ef5..f9dff4ee0b26 100644 --- a/vcl/source/bitmap/bitmappaint.cxx +++ b/vcl/source/bitmap/bitmappaint.cxx @@ -209,16 +209,16 @@ bool Bitmap::Mirror(BmpMirrorFlags nMirrorFlags) return bRet; } -bool Bitmap::Rotate(tools::Long nAngle10, const Color& rFillColor) +bool Bitmap::Rotate(Degree10 nAngle10, const Color& rFillColor) { bool bRet = false; - nAngle10 %= 3600; - nAngle10 = (nAngle10 < 0) ? (3599L + nAngle10) : nAngle10; + nAngle10 %= Degree10(3600); + nAngle10 = (nAngle10 < Degree10(0)) ? (Degree10(3599) + nAngle10) : nAngle10; if (!nAngle10) bRet = true; - else if (nAngle10 == 1800) + else if (nAngle10 == Degree10(1800)) bRet = Mirror(BmpMirrorFlags::Horizontal | BmpMirrorFlags::Vertical); else { @@ -229,7 +229,7 @@ bool Bitmap::Rotate(tools::Long nAngle10, const Color& rFillColor) { const Size aSizePix(GetSizePixel()); - if (nAngle10 == 900 || nAngle10 == 2700) + if (nAngle10 == Degree10(900) || nAngle10 == Degree10(2700)) { const Size aNewSizePix(aSizePix.Height(), aSizePix.Width()); Bitmap aNewBmp(aNewSizePix, GetBitCount(), &pReadAcc->GetPalette()); @@ -244,7 +244,7 @@ bool Bitmap::Rotate(tools::Long nAngle10, const Color& rFillColor) const tools::Long nNewWidth = aNewSizePix.Width(); const tools::Long nNewHeight = aNewSizePix.Height(); - if (nAngle10 == 900) + if (nAngle10 == Degree10(900)) { for (tools::Long nY = 0, nOtherX = nWidth1; nY < nNewHeight; nY++, nOtherX--) @@ -257,7 +257,7 @@ bool Bitmap::Rotate(tools::Long nAngle10, const Color& rFillColor) } } } - else if (nAngle10 == 2700) + else if (nAngle10 == Degree10(2700)) { for (tools::Long nY = 0, nOtherX = 0; nY < nNewHeight; nY++, nOtherX++) { @@ -280,7 +280,7 @@ bool Bitmap::Rotate(tools::Long nAngle10, const Color& rFillColor) Point aTmpPoint; tools::Rectangle aTmpRectangle(aTmpPoint, aSizePix); tools::Polygon aPoly(aTmpRectangle); - aPoly.Rotate(aTmpPoint, static_cast<sal_uInt16>(nAngle10)); + aPoly.Rotate(aTmpPoint, nAngle10); tools::Rectangle aNewBound(aPoly.GetBoundRect()); const Size aNewSizePix(aNewBound.GetSize()); @@ -290,8 +290,8 @@ bool Bitmap::Rotate(tools::Long nAngle10, const Color& rFillColor) if (pWriteAcc) { const BitmapColor aFillColor(pWriteAcc->GetBestMatchingColor(rFillColor)); - const double fCosAngle = cos(nAngle10 * F_PI1800); - const double fSinAngle = sin(nAngle10 * F_PI1800); + const double fCosAngle = cos(nAngle10.get() * F_PI1800); + const double fSinAngle = sin(nAngle10.get() * F_PI1800); const double fXMin = aNewBound.Left(); const double fYMin = aNewBound.Top(); const tools::Long nWidth = aSizePix.Width(); diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx index 51688a092564..bb9831dcf425 100644 --- a/vcl/source/control/fixed.cxx +++ b/vcl/source/control/fixed.cxx @@ -507,7 +507,7 @@ void FixedLine::ImplDraw(vcl::RenderContext& rRenderContext) tools::Long nWidth = rRenderContext.GetTextWidth(aText); rRenderContext.Push(PushFlags::FONT); vcl::Font aFont(rRenderContext.GetFont()); - aFont.SetOrientation(900); + aFont.SetOrientation(Degree10(900)); SetFont(aFont); Point aStartPt(aOutSize.Width() / 2, aOutSize.Height() - 1); if (nWinStyle & WB_VCENTER) diff --git a/vcl/source/filter/GraphicNativeTransform.cxx b/vcl/source/filter/GraphicNativeTransform.cxx index b2d90f43e8d7..d6c77c71caba 100644 --- a/vcl/source/filter/GraphicNativeTransform.cxx +++ b/vcl/source/filter/GraphicNativeTransform.cxx @@ -35,16 +35,17 @@ GraphicNativeTransform::GraphicNativeTransform(Graphic& rGraphic) GraphicNativeTransform::~GraphicNativeTransform() {} -void GraphicNativeTransform::rotate(sal_uInt16 aInputRotation) +void GraphicNativeTransform::rotate(Degree10 aInputRotation) { // Rotation can be between 0 and 3600 - sal_uInt16 aRotation = aInputRotation % 3600; + Degree10 aRotation = aInputRotation % Degree10(3600); - if (aRotation == 0) + if (aRotation == Degree10(0)) { return; // No rotation is needed } - else if (aRotation != 900 && aRotation != 1800 && aRotation != 2700) + else if (aRotation != Degree10(900) && aRotation != Degree10(1800) + && aRotation != Degree10(2700)) { return; } @@ -68,7 +69,7 @@ void GraphicNativeTransform::rotate(sal_uInt16 aInputRotation) } } -bool GraphicNativeTransform::rotateBitmapOnly(sal_uInt16 aRotation) +bool GraphicNativeTransform::rotateBitmapOnly(Degree10 aRotation) { if (mrGraphic.IsAnimated()) { @@ -82,7 +83,7 @@ bool GraphicNativeTransform::rotateBitmapOnly(sal_uInt16 aRotation) return true; } -bool GraphicNativeTransform::rotateGeneric(sal_uInt16 aRotation, const OUString& aType) +bool GraphicNativeTransform::rotateGeneric(Degree10 aRotation, const OUString& aType) { // Can't rotate animations yet if (mrGraphic.IsAnimated()) @@ -117,7 +118,7 @@ bool GraphicNativeTransform::rotateGeneric(sal_uInt16 aRotation, const OUString& return true; } -void GraphicNativeTransform::rotateJPEG(sal_uInt16 aRotation) +void GraphicNativeTransform::rotateJPEG(Degree10 aRotation) { BitmapEx aBitmap = mrGraphic.GetBitmapEx(); diff --git a/vcl/source/filter/jpeg/Exif.cxx b/vcl/source/filter/jpeg/Exif.cxx index 4f773a48bc24..b8760b63aef7 100644 --- a/vcl/source/filter/jpeg/Exif.cxx +++ b/vcl/source/filter/jpeg/Exif.cxx @@ -49,21 +49,21 @@ exif::Orientation Exif::convertToOrientation(sal_Int32 value) return exif::TOP_LEFT; } -sal_Int32 Exif::getRotation() const +Degree10 Exif::getRotation() const { switch(maOrientation) { case exif::TOP_LEFT: - return 0; + return Degree10(0); case exif::BOTTOM_RIGHT: - return 1800; + return Degree10(1800); case exif::RIGHT_TOP: - return 2700; + return Degree10(2700); case exif::LEFT_BOTTOM: - return 900; + return Degree10(900); default: break; } - return 0; + return Degree10(0); } bool Exif::read(SvStream& rStream) diff --git a/vcl/source/filter/jpeg/Exif.hxx b/vcl/source/filter/jpeg/Exif.hxx index 6052a44842da..c39de1b08fdf 100644 --- a/vcl/source/filter/jpeg/Exif.hxx +++ b/vcl/source/filter/jpeg/Exif.hxx @@ -20,6 +20,7 @@ #pragma once #include <tools/stream.hxx> +#include <tools/degree.hxx> namespace exif { @@ -71,7 +72,7 @@ public: bool hasExif() const { return mbExifPresent;} exif::Orientation getOrientation() const { return maOrientation;} - sal_Int32 getRotation() const; + Degree10 getRotation() const; void setOrientation(exif::Orientation orientation); diff --git a/vcl/source/filter/jpeg/JpegTransform.cxx b/vcl/source/filter/jpeg/JpegTransform.cxx index f3b1e7723bdf..b1016c022272 100644 --- a/vcl/source/filter/jpeg/JpegTransform.cxx +++ b/vcl/source/filter/jpeg/JpegTransform.cxx @@ -37,7 +37,7 @@ void JpegTransform::perform() Transform( &mrInputStream, &mrOutputStream, maRotate ); } -void JpegTransform::setRotate(sal_uInt16 aRotate) +void JpegTransform::setRotate(Degree10 aRotate) { maRotate = aRotate; } diff --git a/vcl/source/filter/jpeg/JpegTransform.hxx b/vcl/source/filter/jpeg/JpegTransform.hxx index cb6d3acbcec1..ed5d550276fa 100644 --- a/vcl/source/filter/jpeg/JpegTransform.hxx +++ b/vcl/source/filter/jpeg/JpegTransform.hxx @@ -24,7 +24,7 @@ class JpegTransform final { - sal_uInt16 maRotate; + Degree10 maRotate; SvStream& mrInputStream; SvStream& mrOutputStream; @@ -33,7 +33,7 @@ public: JpegTransform(SvStream& rInputStream, SvStream& rOutputStream); ~JpegTransform(); - void setRotate(sal_uInt16 aRotate); + void setRotate(Degree10 aRotate); void perform(); }; diff --git a/vcl/source/filter/jpeg/jpeg.h b/vcl/source/filter/jpeg/jpeg.h index 908eee030d88..8a8e757a9719 100644 --- a/vcl/source/filter/jpeg/jpeg.h +++ b/vcl/source/filter/jpeg/jpeg.h @@ -50,7 +50,7 @@ void ReadJPEG( JPEGReader* pJPEGReader, void* pInputStream, tools::Long* pLin GraphicFilterImportFlags nImportFlags, BitmapScopedWriteAccess* ppAccess ); -void Transform(void* pInputStream, void* pOutputStream, tools::Long nAngle); +void Transform(void* pInputStream, void* pOutputStream, Degree10 nAngle); /* Expanded data source object for stdio input */ diff --git a/vcl/source/filter/jpeg/jpegc.cxx b/vcl/source/filter/jpeg/jpegc.cxx index 804278ec8300..4718ec94560c 100644 --- a/vcl/source/filter/jpeg/jpegc.cxx +++ b/vcl/source/filter/jpeg/jpegc.cxx @@ -425,7 +425,7 @@ bool WriteJPEG( JPEGWriter* pJPEGWriter, void* pOutputStream, return true; } -void Transform(void* pInputStream, void* pOutputStream, tools::Long nAngle) +void Transform(void* pInputStream, void* pOutputStream, Degree10 nAngle) { jpeg_transform_info aTransformOption; JCOPY_OPTION aCopyOption = JCOPYOPT_ALL; @@ -445,7 +445,7 @@ void Transform(void* pInputStream, void* pOutputStream, tools::Long nAngle) // Angle to transform option // 90 Clockwise = 270 Counterclockwise - switch (nAngle) + switch (nAngle.get()) { case 2700: aTransformOption.transform = JXFORM_ROT_90; diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index 754f1d46386c..63026cd2e7dc 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -463,7 +463,7 @@ void EMFWriter::ImplCheckTextAttr() m_rStm.WriteUInt32( mnTextHandle ); ImplWriteExtent( -rFont.GetFontSize().Height() ); ImplWriteExtent( rFont.GetFontSize().Width() ); - m_rStm.WriteInt32( rFont.GetOrientation() ).WriteInt32( rFont.GetOrientation() ); + m_rStm.WriteInt32( rFont.GetOrientation().get() ).WriteInt32( rFont.GetOrientation().get() ); switch( rFont.GetWeight() ) { diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx index 0ecbbc9be36e..43463c10e62e 100644 --- a/vcl/source/filter/wmf/wmfwr.cxx +++ b/vcl/source/filter/wmf/wmfwr.cxx @@ -312,7 +312,7 @@ void WMFWriter::WMFRecord_CreateFontIndirect(const vcl::Font & rFont) WriteRecordHeader(0x00000000,W_META_CREATEFONTINDIRECT); WriteHeightWidth(Size(rFont.GetFontSize().Width(),-rFont.GetFontSize().Height())); - pWMF->WriteInt16( rFont.GetOrientation() ).WriteInt16( rFont.GetOrientation() ); + pWMF->WriteInt16( rFont.GetOrientation().get() ).WriteInt16( rFont.GetOrientation().get() ); switch (rFont.GetWeight()) { case WEIGHT_THIN: nWeight=W_FW_THIN; break; diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx index b16488ddc88d..9610c1268057 100644 --- a/vcl/source/font/PhysicalFontFace.cxx +++ b/vcl/source/font/PhysicalFontFace.cxx @@ -161,7 +161,7 @@ bool PhysicalFontFace::IsBetterMatch( const FontSelectPattern& rFSD, FontMatchSt int nHeightMatch = 0; int nWidthMatch = 0; - if( rFSD.mnOrientation != 0 ) + if( rFSD.mnOrientation != Degree10(0) ) nMatch += 80; else if( rFSD.mnWidth != 0 ) nMatch += 25; diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx index f9ca44f061f9..2818e71e00ea 100644 --- a/vcl/source/font/font.cxx +++ b/vcl/source/font/font.cxx @@ -189,7 +189,7 @@ void Font::SetPitch( FontPitch ePitch ) mpImplFont->SetPitch( ePitch ); } -void Font::SetOrientation( short nOrientation ) +void Font::SetOrientation( Degree10 nOrientation ) { if (const_cast<const ImplType&>(mpImplFont)->mnOrientation != nOrientation) mpImplFont->mnOrientation = nOrientation; @@ -361,6 +361,7 @@ SvStream& ReadImplFont( SvStream& rIStm, ImplFont& rImplFont ) { VersionCompat aCompat( rIStm, StreamMode::READ ); sal_uInt16 nTmp16(0); + sal_Int16 nTmps16(0); bool bTmp(false); sal_uInt8 nTmp8(0); @@ -379,7 +380,7 @@ SvStream& ReadImplFont( SvStream& rIStm, ImplFont& rImplFont ) rIStm.ReadUInt16( nTmp16 ); rImplFont.maLanguageTag.reset( LanguageType(nTmp16) ); rIStm.ReadUInt16( nTmp16 ); rImplFont.meWidthType = static_cast<FontWidth>(nTmp16); - rIStm.ReadInt16( rImplFont.mnOrientation ); + rIStm.ReadInt16( nTmps16 ); rImplFont.mnOrientation = Degree10(nTmps16); rIStm.ReadCharAsBool( bTmp ); rImplFont.mbWordLine = bTmp; rIStm.ReadCharAsBool( bTmp ); rImplFont.mbOutline = bTmp; @@ -423,7 +424,7 @@ SvStream& WriteImplFont( SvStream& rOStm, const ImplFont& rImplFont ) rOStm.WriteUInt16( static_cast<sal_uInt16>(rImplFont.maLanguageTag.getLanguageType( false)) ); rOStm.WriteUInt16( rImplFont.GetWidthTypeNoAsk() ); - rOStm.WriteInt16( rImplFont.mnOrientation ); + rOStm.WriteInt16( rImplFont.mnOrientation.get() ); rOStm.WriteBool( rImplFont.mbWordLine ); rOStm.WriteBool( rImplFont.mbOutline ); @@ -683,7 +684,7 @@ const LanguageTag& Font::GetCJKContextLanguageTag() const { return mpImplFont->m LanguageType Font::GetLanguage() const { return mpImplFont->maLanguageTag.getLanguageType( false); } LanguageType Font::GetCJKContextLanguage() const { return mpImplFont->maCJKLanguageTag.getLanguageType( false); } -short Font::GetOrientation() const { return mpImplFont->mnOrientation; } +Degree10 Font::GetOrientation() const { return mpImplFont->mnOrientation; } bool Font::IsVertical() const { return mpImplFont->mbVertical; } FontKerning Font::GetKerning() const { return mpImplFont->meKerning; } diff --git a/vcl/source/font/fontselect.cxx b/vcl/source/font/fontselect.cxx index faafdb61b398..09fb90e8b15f 100644 --- a/vcl/source/font/fontselect.cxx +++ b/vcl/source/font/fontselect.cxx @@ -46,12 +46,12 @@ FontSelectPattern::FontSelectPattern( const vcl::Font& rFont, rFont.GetFontAttributes( *this ); // normalize orientation between 0 and 3600 - if( 3600 <= static_cast<unsigned>(mnOrientation) ) + if( mnOrientation < Degree10(0) || mnOrientation >= Degree10(3600) ) { - if( mnOrientation >= 0 ) - mnOrientation %= 3600; + if( mnOrientation >= Degree10(0) ) + mnOrientation %= Degree10(3600); else - mnOrientation = 3600 - (-mnOrientation % 3600); + mnOrientation = Degree10(3600) - (-mnOrientation % Degree10(3600)); } // normalize width and height @@ -99,7 +99,7 @@ size_t FontSelectPattern::hashCode() const nHash += 11U * mnHeight; nHash += 19 * GetWeight(); nHash += 29 * GetItalic(); - nHash += 37 * mnOrientation; + nHash += 37 * mnOrientation.get(); nHash += 41 * static_cast<sal_uInt16>(meLanguage); if( mbVertical ) nHash += 53; diff --git a/vcl/source/gdi/TypeSerializer.cxx b/vcl/source/gdi/TypeSerializer.cxx index ad5f3e3a6dc2..0b1b53372030 100644 --- a/vcl/source/gdi/TypeSerializer.cxx +++ b/vcl/source/gdi/TypeSerializer.cxx @@ -58,7 +58,7 @@ void TypeSerializer::readGradient(Gradient& rGradient) rGradient.SetStyle(static_cast<GradientStyle>(nStyle)); rGradient.SetStartColor(aStartColor); rGradient.SetEndColor(aEndColor); - rGradient.SetAngle(nAngle); + rGradient.SetAngle(Degree10(nAngle)); rGradient.SetBorder(nBorder); rGradient.SetOfsX(nOffsetX); rGradient.SetOfsY(nOffsetY); @@ -74,7 +74,7 @@ void TypeSerializer::writeGradient(const Gradient& rGradient) mrStream.WriteUInt16(static_cast<sal_uInt16>(rGradient.GetStyle())); writeColor(rGradient.GetStartColor()); writeColor(rGradient.GetEndColor()); - mrStream.WriteUInt16(rGradient.GetAngle()); + mrStream.WriteUInt16(rGradient.GetAngle().get()); mrStream.WriteUInt16(rGradient.GetBorder()); mrStream.WriteUInt16(rGradient.GetOfsX()); mrStream.WriteUInt16(rGradient.GetOfsY()); diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index 9e411aa02029..14733bf4b64a 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -383,7 +383,7 @@ bool BitmapEx::Scale( const Size& rNewSize, BmpScaleFlag nScaleFlag ) return bRet; } -bool BitmapEx::Rotate( tools::Long nAngle10, const Color& rFillColor ) +bool BitmapEx::Rotate( Degree10 nAngle10, const Color& rFillColor ) { bool bRet = false; diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index 18a45ea92dad..40c1d7aba529 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -819,17 +819,17 @@ void GDIMetaFile::ImplAddGradientEx( GDIMetaFile& rMtf, } } -void GDIMetaFile::Rotate( tools::Long nAngle10 ) +void GDIMetaFile::Rotate( Degree10 nAngle10 ) { - nAngle10 %= 3600; - nAngle10 = ( nAngle10 < 0 ) ? ( 3599 + nAngle10 ) : nAngle10; + nAngle10 %= Degree10(3600); + nAngle10 = ( nAngle10 < Degree10(0) ) ? ( Degree10(3599) + nAngle10 ) : nAngle10; if( !nAngle10 ) return; GDIMetaFile aMtf; ScopedVclPtrInstance< VirtualDevice > aMapVDev; - const double fAngle = F_PI1800 * nAngle10; + const double fAngle = F_PI1800 * nAngle10.get(); const double fSin = sin( fAngle ); const double fCos = cos( fAngle ); tools::Rectangle aRect( Point(), GetPrefSize() ); @@ -1148,7 +1148,7 @@ void GDIMetaFile::Rotate( tools::Long nAngle10 ) MetaHatchAction* pAct = static_cast<MetaHatchAction*>(pAction); Hatch aHatch( pAct->GetHatch() ); - aHatch.SetAngle( aHatch.GetAngle() + static_cast<sal_uInt16>(nAngle10) ); + aHatch.SetAngle( aHatch.GetAngle() + nAngle10 ); aMtf.AddAction( new MetaHatchAction( ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ), aHatch ) ); } @@ -1236,7 +1236,7 @@ void GDIMetaFile::Rotate( tools::Long nAngle10 ) MetaFontAction* pAct = static_cast<MetaFontAction*>(pAction); vcl::Font aFont( pAct->GetFont() ); - aFont.SetOrientation( aFont.GetOrientation() + static_cast<sal_uInt16>(nAngle10) ); + aFont.SetOrientation( aFont.GetOrientation() + nAngle10 ); aMtf.AddAction( new MetaFontAction( aFont ) ); } break; diff --git a/vcl/source/gdi/gradient.cxx b/vcl/source/gdi/gradient.cxx index ac826f985cdd..b5c331e6953c 100644 --- a/vcl/source/gdi/gradient.cxx +++ b/vcl/source/gdi/gradient.cxx @@ -26,7 +26,7 @@ public: GradientStyle meStyle; Color maStartColor; Color maEndColor; - sal_uInt16 mnAngle; + Degree10 mnAngle; sal_uInt16 mnBorder; sal_uInt16 mnOfsX; sal_uInt16 mnOfsY; @@ -125,12 +125,12 @@ void Gradient::SetEndColor( const Color& rColor ) mpImplGradient->maEndColor = rColor; } -sal_uInt16 Gradient::GetAngle() const +Degree10 Gradient::GetAngle() const { return mpImplGradient->mnAngle; } -void Gradient::SetAngle( sal_uInt16 nAngle ) +void Gradient::SetAngle( Degree10 nAngle ) { mpImplGradient->mnAngle = nAngle; } @@ -198,11 +198,11 @@ void Gradient::SetSteps( sal_uInt16 nSteps ) void Gradient::GetBoundRect( const tools::Rectangle& rRect, tools::Rectangle& rBoundRect, Point& rCenter ) const { tools::Rectangle aRect( rRect ); - sal_uInt16 nAngle = GetAngle() % 3600; + Degree10 nAngle = GetAngle() % Degree10(3600); if( GetStyle() == GradientStyle::Linear || GetStyle() == GradientStyle::Axial ) { - const double fAngle = nAngle * F_PI1800; + const double fAngle = nAngle.get() * F_PI1800; const double fWidth = aRect.GetWidth(); const double fHeight = aRect.GetHeight(); double fDX = fWidth * fabs( cos( fAngle ) ) + @@ -223,7 +223,7 @@ void Gradient::GetBoundRect( const tools::Rectangle& rRect, tools::Rectangle& rB { if( GetStyle() == GradientStyle::Square || GetStyle() == GradientStyle::Rect ) { - const double fAngle = nAngle * F_PI1800; + const double fAngle = nAngle.get() * F_PI1800; const double fWidth = aRect.GetWidth(); const double fHeight = aRect.GetHeight(); double fDX = fWidth * fabs( cos( fAngle ) ) + fHeight * fabs( sin( fAngle ) ); diff --git a/vcl/source/gdi/hatch.cxx b/vcl/source/gdi/hatch.cxx index 5d139b0a079e..353b8cbd01dd 100644 --- a/vcl/source/gdi/hatch.cxx +++ b/vcl/source/gdi/hatch.cxx @@ -43,7 +43,7 @@ Hatch::Hatch() = default; Hatch::Hatch( const Hatch& ) = default; Hatch::Hatch( HatchStyle eStyle, const Color& rColor, - tools::Long nDistance, sal_uInt16 nAngle10 ) : mpImplHatch() + tools::Long nDistance, Degree10 nAngle10 ) : mpImplHatch() { mpImplHatch->maColor = rColor; mpImplHatch->meStyle = eStyle; @@ -71,7 +71,7 @@ void Hatch::SetDistance( tools::Long nDistance ) mpImplHatch->mnDistance = nDistance; } -void Hatch::SetAngle( sal_uInt16 nAngle10 ) +void Hatch::SetAngle( Degree10 nAngle10 ) { mpImplHatch->mnAngle = nAngle10; } @@ -88,8 +88,9 @@ SvStream& ReadHatch( SvStream& rIStm, Hatch& rHatch ) tools::GenericTypeSerializer aSerializer(rIStm); aSerializer.readColor(rHatch.mpImplHatch->maColor); rIStm.ReadInt32(nTmp32); - rIStm.ReadUInt16(rHatch.mpImplHatch->mnAngle); rHatch.mpImplHatch->mnDistance = nTmp32; + rIStm.ReadUInt16(nTmp16); + rHatch.mpImplHatch->mnAngle = Degree10(nTmp16); return rIStm; } @@ -102,7 +103,7 @@ SvStream& WriteHatch( SvStream& rOStm, const Hatch& rHatch ) tools::GenericTypeSerializer aSerializer(rOStm); aSerializer.writeColor(rHatch.mpImplHatch->maColor); - rOStm.WriteInt32( rHatch.mpImplHatch->mnDistance ).WriteUInt16( rHatch.mpImplHatch->mnAngle ); + rOStm.WriteInt32( rHatch.mpImplHatch->mnDistance ).WriteUInt16( rHatch.mpImplHatch->mnAngle.get() ); return rOStm; } diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx index 229cecda695a..5e80e3f229f5 100644 --- a/vcl/source/gdi/mtfxmldump.cxx +++ b/vcl/source/gdi/mtfxmldump.cxx @@ -485,7 +485,7 @@ void writeGradient(tools::XmlWriter& rWriter, Gradient const& rGradient) rWriter.attribute("style", convertGradientStyle(rGradient.GetStyle())); rWriter.attribute("startcolor", convertColorToString(rGradient.GetStartColor())); rWriter.attribute("endcolor", convertColorToString(rGradient.GetEndColor())); - rWriter.attribute("angle", rGradient.GetAngle()); + rWriter.attribute("angle", rGradient.GetAngle().get()); rWriter.attribute("border", rGradient.GetBorder()); rWriter.attribute("offsetx", rGradient.GetOfsX()); rWriter.attribute("offsety", rGradient.GetOfsY()); @@ -963,7 +963,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r rWriter.attribute("style", convertHatchStyle(rHatch.GetStyle())); rWriter.attribute("color", convertColorToString(rHatch.GetColor())); rWriter.attribute("distance", sal_Int32(rHatch.GetDistance())); - rWriter.attribute("angle", sal_Int32(rHatch.GetAngle())); + rWriter.attribute("angle", sal_Int32(rHatch.GetAngle().get())); rWriter.endElement(); rWriter.endElement(); @@ -1144,7 +1144,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r rWriter.attribute("stylename", aFont.GetStyleName()); rWriter.attribute("width", aFont.GetFontSize().Width()); rWriter.attribute("height", aFont.GetFontSize().Height()); - rWriter.attribute("orientation", aFont.GetOrientation()); + rWriter.attribute("orientation", aFont.GetOrientation().get()); rWriter.attribute("weight", convertFontWeightToString(aFont.GetWeight())); rWriter.attribute("vertical", aFont.IsVertical() ? "true" : "false"); diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index a3390cca44f7..592638222b2c 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -6060,12 +6060,12 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool fXScale *= double(m_aCurrentPDFState.m_aMapMode.GetScaleX()) / double(m_aCurrentPDFState.m_aMapMode.GetScaleY()); } - int nAngle = m_aCurrentPDFState.m_aFont.GetOrientation(); + Degree10 nAngle = m_aCurrentPDFState.m_aFont.GetOrientation(); // normalize angles - while( nAngle < 0 ) - nAngle += 3600; - nAngle = nAngle % 3600; - double fAngle = static_cast<double>(nAngle) * M_PI / 1800.0; + while( nAngle < Degree10(0) ) + nAngle += Degree10(3600); + nAngle = nAngle % Degree10(3600); + double fAngle = static_cast<double>(nAngle.get()) * M_PI / 1800.0; Matrix3 aRotScale; aRotScale.scale( fXScale, 1.0 ); @@ -7155,7 +7155,7 @@ void PDFWriterImpl::drawTextLine( const Point& rPos, tools::Long nWidth, FontStr aLine.append( "q " ); // rotate and translate matrix - double fAngle = static_cast<double>(m_aCurrentPDFState.m_aFont.GetOrientation()) * M_PI / 1800.0; + double fAngle = static_cast<double>(m_aCurrentPDFState.m_aFont.GetOrientation().get()) * M_PI / 1800.0; Matrix3 aMat; aMat.rotate( fAngle ); aMat.translate( aPos.X(), aPos.Y() ); @@ -8300,7 +8300,7 @@ bool PDFWriterImpl::writeGradientFunction( GradientEmit const & rObject ) tools::Rectangle aBoundRect; Point aCenter; - sal_uInt16 nAngle = rObject.m_aGradient.GetAngle() % 3600; + Degree10 nAngle = rObject.m_aGradient.GetAngle() % Degree10(3600); rObject.m_aGradient.GetBoundRect( aRect, aBoundRect, aCenter ); const bool bLinear = (rObject.m_aGradient.GetStyle() == GradientStyle::Linear); @@ -8326,7 +8326,7 @@ bool PDFWriterImpl::writeGradientFunction( GradientEmit const & rObject ) tools::Polygon aPoly( 2 ); aPoly[0] = aBoundRect.BottomCenter(); aPoly[1] = aBoundRect.TopCenter(); - aPoly.Rotate( aCenter, 3600 - nAngle ); + aPoly.Rotate( aCenter, Degree10(3600) - nAngle ); aLine.append( static_cast<sal_Int32>(aPoly[0].X()) ); aLine.append( " " ); diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 95cf5d891521..16fa84ab95d5 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -562,17 +562,17 @@ Point SalLayout::GetDrawPosition( const Point& rRelative ) const Point aPos = maDrawBase; Point aOfs = rRelative + maDrawOffset; - if( mnOrientation == 0 ) + if( mnOrientation == Degree10(0) ) aPos += aOfs; else { // cache trigonometric results - static int nOldOrientation = 0; + static Degree10 nOldOrientation(0); static double fCos = 1.0, fSin = 0.0; if( nOldOrientation != mnOrientation ) { nOldOrientation = mnOrientation; - double fRad = mnOrientation * (M_PI / 1800.0); + double fRad = mnOrientation.get() * (M_PI / 1800.0); fCos = cos( fRad ); fSin = sin( fRad ); } diff --git a/vcl/source/gdi/svmconverter.cxx b/vcl/source/gdi/svmconverter.cxx index d0b1ac953d80..2af54eabf368 100644 --- a/vcl/source/gdi/svmconverter.cxx +++ b/vcl/source/gdi/svmconverter.cxx @@ -657,7 +657,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) aFont.SetItalic( bItalic ? ITALIC_NORMAL : ITALIC_NONE ); aFont.SetOutline( bOutline ); aFont.SetShadow( bShadow ); - aFont.SetOrientation( nLineOrient ); + aFont.SetOrientation( Degree10(nLineOrient) ); aFont.SetTransparent( bTransparent ); eActualCharSet = aFont.GetCharSet(); @@ -1055,7 +1055,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) Gradient aGrad( static_cast<GradientStyle>(nStyle), aStartCol, aEndCol ); - aGrad.SetAngle( nAngle ); + aGrad.SetAngle( Degree10(nAngle) ); aGrad.SetBorder( nBorder ); aGrad.SetOfsX( nOfsX ); aGrad.SetOfsY( nOfsY ); diff --git a/vcl/source/gdi/wall.cxx b/vcl/source/gdi/wall.cxx index 5170134cc24c..2300a8f8ad23 100644 --- a/vcl/source/gdi/wall.cxx +++ b/vcl/source/gdi/wall.cxx @@ -288,7 +288,7 @@ bool Wallpaper::IsGradient() const Gradient Wallpaper::ImplGetApplicationGradient() { Gradient g; - g.SetAngle( 900 ); + g.SetAngle( Degree10(900) ); g.SetStyle( GradientStyle::Linear ); g.SetStartColor( Application::GetSettings().GetStyleSettings().GetFaceColor() ); // no 'extreme' gradient when high contrast diff --git a/vcl/source/graphic/GraphicObject.cxx b/vcl/source/graphic/GraphicObject.cxx index 415e42e3313a..aa8b5a3169b7 100644 --- a/vcl/source/graphic/GraphicObject.cxx +++ b/vcl/source/graphic/GraphicObject.cxx @@ -110,7 +110,7 @@ bool lclDrawObj( OutputDevice* pOut, const Point& rPt, const Size& rSz, if( aGraphic.IsSupportedGraphic() ) { - const sal_uInt16 nRot10 = rAttr.GetRotation() % 3600; + const Degree10 nRot10 = rAttr.GetRotation() % Degree10(3600); if( nRot10 ) { @@ -353,7 +353,7 @@ bool GraphicObject::ImplGetCropParams( OutputDevice const * pOut, Point& rPt, Si if( GetType() != GraphicType::NONE ) { tools::Polygon aClipPoly( tools::Rectangle( rPt, rSz ) ); - const sal_uInt16 nRot10 = pAttr->GetRotation() % 3600; + const Degree10 nRot10 = pAttr->GetRotation() % Degree10(3600); const Point aOldOrigin( rPt ); const MapMode aMap100( MapUnit::Map100thMM ); Size aSize100; diff --git a/vcl/source/graphic/GraphicObject2.cxx b/vcl/source/graphic/GraphicObject2.cxx index d858b47b8f34..4153ff47a6ea 100644 --- a/vcl/source/graphic/GraphicObject2.cxx +++ b/vcl/source/graphic/GraphicObject2.cxx @@ -484,7 +484,7 @@ void GraphicObject::ImplTransformBitmap( BitmapEx& rBmpEx, const Size aSizePixel( rBmpEx.GetSizePixel() ); - if( rAttr.GetRotation() == 0 || IsAnimated() ) + if( rAttr.GetRotation() == Degree10(0) || IsAnimated() ) return; if( !(aSizePixel.Width() && aSizePixel.Height() && rDstSize.Width() && rDstSize.Height()) ) 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; diff --git a/vcl/source/window/cursor.cxx b/vcl/source/window/cursor.cxx index e80ba8d42b52..18773be22698 100644 --- a/vcl/source/window/cursor.cxx +++ b/vcl/source/window/cursor.cxx @@ -36,7 +36,7 @@ struct ImplCursorData Point maPixPos; // Pixel-Position Point maPixRotOff; // Pixel-Offset-Position Size maPixSize; // Pixel-Size - short mnOrientation; // Pixel-Orientation + Degree10 mnOrientation; // Pixel-Orientation CursorDirection mnDirection; // indicates writing direction sal_uInt16 mnStyle; // Cursor-Style bool mbCurVisible; // Is cursor currently visible @@ -332,7 +332,7 @@ vcl::Cursor::Cursor() { mpData = nullptr; mpWindow = nullptr; - mnOrientation = 0; + mnOrientation = Degree10(0); mnDirection = CursorDirection::NONE; mnStyle = 0; mbVisible = false; @@ -419,7 +419,7 @@ void vcl::Cursor::SetWidth( tools::Long nNewWidth ) } } -void vcl::Cursor::SetOrientation( short nNewOrientation ) +void vcl::Cursor::SetOrientation( Degree10 nNewOrientation ) { if ( mnOrientation != nNewOrientation ) { diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 0212f7da0e5f..88516e9f320b 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -188,7 +188,7 @@ void PrintDialog::PrintPreviewWindow::Paint(vcl::RenderContext& rRenderContext, { rRenderContext.Push(PushFlags::FONT); vcl::Font aFont(rRenderContext.GetFont()); - aFont.SetOrientation(900); + aFont.SetOrientation(Degree10(900)); rRenderContext.SetFont(aFont); auto nLeft = aOffset.X() - nTextHeight; diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index 344f60d175eb..ae9afe30250f 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -314,7 +314,7 @@ void ToolBox::ImplDrawGradientBackground(vcl::RenderContext& rRenderContext) startCol = endCol; Gradient g; - g.SetAngle(mbHorz ? 0 : 900); + g.SetAngle(Degree10(mbHorz ? 0 : 900)); g.SetStyle(GradientStyle::Linear); g.SetStartColor(startCol); @@ -1147,7 +1147,7 @@ void ToolBox::ImplInitToolBoxData() meTextPosition = ToolBoxTextPosition::Right; mnLastFocusItemId = 0; mnActivateCount = 0; - mnImagesRotationAngle = 0; + mnImagesRotationAngle = Degree10(0); mpStatusListener = new VclStatusListener<ToolBox>(this, ".uno:ImageOrientation"); mpStatusListener->startListening(); @@ -2716,7 +2716,7 @@ void ToolBox::ImplDrawItem(vcl::RenderContext& rRenderContext, ImplToolItems::si bRotate = true; vcl::Font aRotateFont = aOldFont; - aRotateFont.SetOrientation( 2700 ); + aRotateFont.SetOrientation( Degree10(2700) ); // center horizontally nTextOffX += aTxtSize.Height(); diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx index 59b7bbbbb01e..56abd3cea7ae 100644 --- a/vcl/source/window/toolbox2.cxx +++ b/vcl/source/window/toolbox2.cxx @@ -94,7 +94,7 @@ void ImplToolItem::init(sal_uInt16 nItemId, ToolBoxItemBits nItemBits, mbBreak = false; mnSepSize = TB_SEP_SIZE; mnDropDownArrowWidth = TB_DROPDOWNARROWWIDTH; - mnImageAngle = 0; + mnImageAngle = Degree10(0); mbMirrorMode = false; mbVisibleText = false; mbExpand = false; @@ -959,7 +959,7 @@ void ToolBox::SetItemImage( sal_uInt16 nItemId, const Image& rImage ) } } -static Image ImplRotImage( const Image& rImage, tools::Long nAngle10 ) +static Image ImplRotImage( const Image& rImage, Degree10 nAngle10 ) { BitmapEx aRotBitmapEx( rImage.GetBitmapEx() ); @@ -968,7 +968,7 @@ static Image ImplRotImage( const Image& rImage, tools::Long nAngle10 ) return Image( aRotBitmapEx ); } -void ToolBox::SetItemImageAngle( sal_uInt16 nItemId, tools::Long nAngle10 ) +void ToolBox::SetItemImageAngle( sal_uInt16 nItemId, Degree10 nAngle10 ) { ImplToolItems::size_type nPos = GetItemPos( nItemId ); @@ -978,9 +978,9 @@ void ToolBox::SetItemImageAngle( sal_uInt16 nItemId, tools::Long nAngle10 ) ImplToolItem* pItem = &mpData->m_aItems[nPos]; Size aOldSize = pItem->maImage.GetSizePixel(); - tools::Long nDeltaAngle = (nAngle10 - pItem->mnImageAngle) % 3600; - while( nDeltaAngle < 0 ) - nDeltaAngle += 3600; + Degree10 nDeltaAngle = (nAngle10 - pItem->mnImageAngle) % Degree10(3600); + while( nDeltaAngle < Degree10(0) ) + nDeltaAngle += Degree10(3600); pItem->mnImageAngle = nAngle10; if( nDeltaAngle && !!pItem->maImage ) diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx index 32e138457dd9..d3fd5f753983 100644 --- a/vcl/unx/generic/gdi/cairotextrender.cxx +++ b/vcl/unx/generic/gdi/cairotextrender.cxx @@ -89,9 +89,9 @@ namespace return nRotation != 0; } - double toRadian(int nDegree10th) + double toRadian(Degree10 nDegree10th) { - return (3600 - nDegree10th) * M_PI / 1800.0; + return (Degree10(3600) - nDegree10th).get() * M_PI / 1800.0; } cairo_t* syncCairoContext(cairo_t* cr) @@ -234,7 +234,7 @@ void CairoTextRender::DrawTextLayout(const GenericSalLayout& rLayout, const SalG if (nGlyphRotation) { - cairo_matrix_rotate(&m, toRadian(nGlyphRotation*900)); + cairo_matrix_rotate(&m, toRadian(Degree10(nGlyphRotation * 900))); cairo_matrix_t em_square; cairo_matrix_init_identity(&em_square); diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx index cbc8f7e1b4d5..cbca9eea1bac 100644 --- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx +++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx @@ -418,9 +418,9 @@ FreetypeFont::FreetypeFont(FreetypeFontInstance& rFontInstance, const std::share const FontSelectPattern& rFSD = rFontInstance.GetFontSelectPattern(); - if( rFSD.mnOrientation != 0 ) + if( rFSD.mnOrientation ) { - const double dRad = rFSD.mnOrientation * ( F_2PI / 3600.0 ); + const double dRad = rFSD.mnOrientation.get() * ( F_2PI / 3600.0 ); mnCos = static_cast<tools::Long>( 0x10000 * cos( dRad ) + 0.5 ); mnSin = static_cast<tools::Long>( 0x10000 * sin( dRad ) + 0.5 ); } diff --git a/vcl/unx/generic/print/common_gfx.cxx b/vcl/unx/generic/print/common_gfx.cxx index f43d38a76dbd..e39e4e331c76 100644 --- a/vcl/unx/generic/print/common_gfx.cxx +++ b/vcl/unx/generic/print/common_gfx.cxx @@ -125,7 +125,7 @@ PrinterGfx::Clear() mnDepth = 24; mnPSLevel = 2; mbColor = true; - mnTextAngle = 0; + mnTextAngle = Degree10(0); maClipRegion.clear(); maGraphicsStack.clear(); @@ -794,9 +794,9 @@ PrinterGfx::PSSetFont () } void -PrinterGfx::PSRotate (sal_Int32 nAngle) +PrinterGfx::PSRotate (Degree10 nAngle) { - sal_Int32 nPostScriptAngle = -nAngle; + sal_Int32 nPostScriptAngle = -nAngle.get(); while( nPostScriptAngle < 0 ) nPostScriptAngle += 3600; @@ -1007,7 +1007,7 @@ PrinterGfx::PSShowGlyph (const unsigned char nGlyphId) PSSetColor (); PSSetFont (); // rotate the user coordinate system - if (mnTextAngle != 0) + if (mnTextAngle) { PSGSave (); PSRotate (mnTextAngle); @@ -1036,7 +1036,7 @@ PrinterGfx::PSShowGlyph (const unsigned char nGlyphId) WritePS (mpPageBody, "show\n"); // restore the user coordinate system - if (mnTextAngle != 0) + if (mnTextAngle) PSGRestore (); } diff --git a/vcl/unx/generic/print/text_gfx.cxx b/vcl/unx/generic/print/text_gfx.cxx index d3153952b0a6..f87fe2176f20 100644 --- a/vcl/unx/generic/print/text_gfx.cxx +++ b/vcl/unx/generic/print/text_gfx.cxx @@ -33,7 +33,7 @@ void PrinterGfx::SetFont( sal_Int32 nFontID, sal_Int32 nHeight, sal_Int32 nWidth, - sal_Int32 nAngle, + Degree10 nAngle, bool bVertical, bool bArtItalic, bool bArtBold @@ -82,15 +82,15 @@ void PrinterGfx::DrawGlyph(const Point& rPoint, // move and rotate the user coordinate system // avoid the gsave/grestore for the simple cases since it allows // reuse of the current font if it hasn't changed - sal_Int32 nCurrentTextAngle = mnTextAngle; + Degree10 nCurrentTextAngle = mnTextAngle; Point aPoint( rPoint ); - if (nCurrentTextAngle != 0) + if (nCurrentTextAngle) { PSGSave (); PSTranslate (rPoint); PSRotate (nCurrentTextAngle); - mnTextAngle = 0; + mnTextAngle = Degree10(0); aPoint = Point( 0, 0 ); } @@ -114,7 +114,7 @@ void PrinterGfx::DrawGlyph(const Point& rPoint, maVirtualStatus.mnTextHeight = nTextWidth; if( aPoint.X() || aPoint.Y() ) PSTranslate( aPoint ); - PSRotate (900); + PSRotate (Degree10(900)); // draw the rotated glyph drawGlyph(aRotPoint, rGlyph.glyphId()); @@ -126,7 +126,7 @@ void PrinterGfx::DrawGlyph(const Point& rPoint, drawGlyph(aPoint, rGlyph.glyphId()); // restore the user coordinate system - if (nCurrentTextAngle != 0) + if (nCurrentTextAngle) { PSGRestore (); mnTextAngle = nCurrentTextAngle; diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx b/vcl/win/gdi/DWriteTextRenderer.cxx index 734b68b0780a..da8eab0e6ce0 100644 --- a/vcl/win/gdi/DWriteTextRenderer.cxx +++ b/vcl/win/gdi/DWriteTextRenderer.cxx @@ -397,13 +397,13 @@ WinFontTransformGuard::WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, f = aTransform * D2D1::Matrix3x2F::Scale(D2D1::Size(fHScale, 1.0f), D2D1::Point2F(0, 0)); } - if (rLayout.GetOrientation() != 0) + if (rLayout.GetOrientation()) { // DWrite angle is in clockwise degrees, our orientation is in counter-clockwise 10th // degrees. aTransform = aTransform * D2D1::Matrix3x2F::Rotation( - -static_cast<FLOAT>(rLayout.GetOrientation()) / 10, rBaseline); + -static_cast<FLOAT>(rLayout.GetOrientation().get()) / 10, rBaseline); } mpRenderTarget->SetTransform(aTransform); } diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index f37ae89a00a8..7b4c0f042d9e 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -603,7 +603,7 @@ void ImplSalLogFontToFontW( HDC hDC, const LOGFONTW& rLogFont, Font& rFont ) nFontHeight += nDPIY/2; nFontHeight /= nDPIY; rFont.SetFontSize( Size( 0, nFontHeight ) ); - rFont.SetOrientation( static_cast<short>(rLogFont.lfEscapement) ); + rFont.SetOrientation( Degree10(static_cast<sal_Int16>(rLogFont.lfEscapement)) ); if ( rLogFont.lfItalic ) rFont.SetItalic( ITALIC_NORMAL ); else @@ -805,7 +805,7 @@ void ImplGetLogFontFromFontSelect( HDC hDC, rLogFont.lfUnderline = 0; rLogFont.lfStrikeOut = 0; rLogFont.lfItalic = BYTE(rFont.GetItalic() != ITALIC_NONE); - rLogFont.lfEscapement = rFont.mnOrientation; + rLogFont.lfEscapement = rFont.mnOrientation.get(); rLogFont.lfOrientation = rLogFont.lfEscapement; rLogFont.lfClipPrecision = CLIP_DEFAULT_PRECIS; rLogFont.lfQuality = nDefaultQuality; diff --git a/vcl/workben/svptest.cxx b/vcl/workben/svptest.cxx index 77c7ac3cb28b..1e67f17b1942 100644 --- a/vcl/workben/svptest.cxx +++ b/vcl/workben/svptest.cxx @@ -234,7 +234,7 @@ void MyWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rR FontMetric aFont = rRenderContext.GetDevFont((i * nFontCount) / nFontSamples); aFont.SetFontHeight(400 + (i % 7) * 100); - aFont.SetOrientation(i * (3600 / nFontSamples)); + aFont.SetOrientation(Degree10(i * (3600 / nFontSamples))); rRenderContext.SetFont(aFont); sal_uInt8 nRed = (i << 6) & 0xC0; @@ -265,7 +265,7 @@ void MyWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rR Color const aDarkGreen(0, 0x40, 0); Gradient aGradient(GradientStyle::Linear, aBlack, aWhite); - aGradient.SetAngle(900); + aGradient.SetAngle(Degree10(900)); rRenderContext.DrawGradient(tools::Rectangle(Point(1000, 4500), Size(aPaperSize.Width() - 2000, 500)), aGradient); diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index a089301db7cf..36711fc58084 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -475,7 +475,7 @@ public: aFontRect.AdjustTop(nHeight/2 ); aFontRect.AdjustBottom(nHeight ); - aFont.SetOrientation(45 * 10); // 45 degrees + aFont.SetOrientation(Degree10(450)); // 45 degrees rDev.SetFont(aFont); rDev.DrawText(aFontRect, aText); @@ -691,7 +691,7 @@ public: case 2: { tools::Polygon aPoly(aSub); - aPoly.Rotate(aSub.Center(), 450); + aPoly.Rotate(aSub.Center(), Degree10(450)); aPoly.Clip(aSmaller); aRegion = vcl::Region(aPoly); break; @@ -834,7 +834,7 @@ public: aGradient.SetStartColor(nStartCols[i]); aGradient.SetEndColor(nEndCols[i]); aGradient.SetStyle(eStyles[i]); - aGradient.SetAngle(nAngles[i]); + aGradient.SetAngle(Degree10(nAngles[i])); aGradient.SetBorder(nBorders[i]); rDev.DrawGradient(aSub, aGradient); } @@ -1047,7 +1047,7 @@ public: case 3: case 0: // 45degree rectangle. aPoly = tools::Polygon(aPieces[i]); - aPoly.Rotate(aPieces[i].Center(), 450); + aPoly.Rotate(aPieces[i].Center(), Degree10(450)); break; case 1: // arc aPoly = tools::Polygon(aPieces[i], @@ -1058,7 +1058,7 @@ public: aPoly = tools::Polygon(aPieces[i], aPieces[i].GetWidth()/5, aPieces[i].GetHeight()/5); - aPoly.Rotate(aPieces[i].Center(), 450); + aPoly.Rotate(aPieces[i].Center(), Degree10(450)); break; } aClipRegion = vcl::Region(aPoly); |