From 0fb58a1ff168ae122e9c8993a3136658e3b0e3f0 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 20 Oct 2020 07:27:44 +0200 Subject: 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 Reviewed-by: Noel Grandin --- include/vcl/GraphicAttributes.hxx | 9 +++++---- include/vcl/GraphicNativeMetadata.hxx | 7 ++++--- include/vcl/GraphicNativeTransform.hxx | 9 +++++---- include/vcl/bitmap.hxx | 3 ++- include/vcl/bitmapex.hxx | 3 ++- include/vcl/cursor.hxx | 4 ++-- include/vcl/font.hxx | 5 +++-- include/vcl/gdimtf.hxx | 2 +- include/vcl/gradient.hxx | 5 +++-- include/vcl/hatch.hxx | 9 +++++---- include/vcl/outdev.hxx | 6 +++--- include/vcl/toolbox.hxx | 5 +++-- include/vcl/vcllayout.hxx | 5 +++-- 13 files changed, 41 insertions(+), 31 deletions(-) (limited to 'include/vcl') diff --git a/include/vcl/GraphicAttributes.hxx b/include/vcl/GraphicAttributes.hxx index a26f59edc890..5216d2934166 100644 --- a/include/vcl/GraphicAttributes.hxx +++ b/include/vcl/GraphicAttributes.hxx @@ -19,6 +19,7 @@ #pragma once +#include #include #include @@ -39,7 +40,7 @@ private: tools::Long mnTopCrop; tools::Long mnRightCrop; tools::Long mnBottomCrop; - sal_uInt16 mnRotate10; + Degree10 mnRotate10; short mnContPercent; short mnLumPercent; short mnRPercent; @@ -74,8 +75,8 @@ public: tools::Long GetRightCrop() const { return mnRightCrop; } tools::Long GetBottomCrop() const { return mnBottomCrop; } - void SetRotation(sal_uInt16 nRotate10) { mnRotate10 = nRotate10; } - sal_uInt16 GetRotation() const { return mnRotate10; } + void SetRotation(Degree10 nRotate10) { mnRotate10 = nRotate10; } + Degree10 GetRotation() const { return mnRotate10; } void SetLuminance(short nLuminancePercent) { mnLumPercent = nLuminancePercent; } short GetLuminance() const { return mnLumPercent; } @@ -107,7 +108,7 @@ public: { return (mnLeftCrop != 0 || mnTopCrop != 0 || mnRightCrop != 0 || mnBottomCrop != 0); } - bool IsRotated() const { return ((mnRotate10 % 3600) != 0); } + bool IsRotated() const { return ((mnRotate10 % Degree10(3600)) != Degree10(0)); } bool IsTransparent() const { return (mcTransparency > 0); } bool IsAdjusted() const { diff --git a/include/vcl/GraphicNativeMetadata.hxx b/include/vcl/GraphicNativeMetadata.hxx index 3dbd7ff8a7d2..7cc8b663f18a 100644 --- a/include/vcl/GraphicNativeMetadata.hxx +++ b/include/vcl/GraphicNativeMetadata.hxx @@ -21,10 +21,11 @@ #include #include +#include class VCL_DLLPUBLIC GraphicNativeMetadata final { - sal_uInt16 mRotation; + Degree10 mRotation; public: GraphicNativeMetadata(); @@ -33,8 +34,8 @@ public: bool read(Graphic const& rGraphic); bool read(SvStream& rStream); - // counter-clock-wise rotation in permille - sal_uInt16 getRotation() const { return mRotation; } + // counter-clock-wise rotation 10ths of a degree + Degree10 getRotation() const { return mRotation; } }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/GraphicNativeTransform.hxx b/include/vcl/GraphicNativeTransform.hxx index b4d71f2d53d0..3b05ac323232 100644 --- a/include/vcl/GraphicNativeTransform.hxx +++ b/include/vcl/GraphicNativeTransform.hxx @@ -20,6 +20,7 @@ #pragma once #include +#include #include #include @@ -29,15 +30,15 @@ class VCL_DLLPUBLIC GraphicNativeTransform final { Graphic& mrGraphic; - bool rotateBitmapOnly(sal_uInt16 aRotation); - void rotateJPEG(sal_uInt16 aRotation); - bool rotateGeneric(sal_uInt16 aRotation, const OUString& aType); + bool rotateBitmapOnly(Degree10 aRotation); + void rotateJPEG(Degree10 aRotation); + bool rotateGeneric(Degree10 aRotation, const OUString& aType); public: GraphicNativeTransform(Graphic& rGraphic); ~GraphicNativeTransform(); - void rotate(sal_uInt16 aRotation); + void rotate(Degree10 aRotation); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx index 932bab285784..74d3a2e11724 100644 --- a/include/vcl/bitmap.hxx +++ b/include/vcl/bitmap.hxx @@ -21,6 +21,7 @@ #define INCLUDED_VCL_BITMAP_HXX #include +#include #include #include #include @@ -349,7 +350,7 @@ public: @return true, if the operation was completed successfully. */ - bool Rotate( tools::Long nAngle10, const Color& rFillColor ); + bool Rotate( Degree10 nAngle10, const Color& rFillColor ); /** Create on-off mask from bitmap diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx index 7c9eb69383c1..dc9f8a837502 100644 --- a/include/vcl/bitmapex.hxx +++ b/include/vcl/bitmapex.hxx @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -233,7 +234,7 @@ public: @return true, if the operation was completed successfully. */ bool Rotate( - tools::Long nAngle10, + Degree10 nAngle10, const Color& rFillColor ); /** Replace all pixel having the search color with the specified color diff --git a/include/vcl/cursor.hxx b/include/vcl/cursor.hxx index 3937c0e48c4e..ff66326d90b9 100644 --- a/include/vcl/cursor.hxx +++ b/include/vcl/cursor.hxx @@ -50,7 +50,7 @@ private: VclPtr mpWindow; // only for shadow cursor Size maSize; Point maPos; - short mnOrientation; + Degree10 mnOrientation; sal_uInt16 mnStyle; bool mbVisible; CursorDirection mnDirection; @@ -87,7 +87,7 @@ public: tools::Long GetWidth() const { return maSize.Width(); } tools::Long GetHeight() const { return maSize.Height(); } - void SetOrientation( short nOrientation = 0 ); + void SetOrientation( Degree10 nOrientation = Degree10(0) ); void SetDirection( CursorDirection nDirection = CursorDirection::NONE ); diff --git a/include/vcl/font.hxx b/include/vcl/font.hxx index 02f4a6d3f264..2d437c5b3da0 100644 --- a/include/vcl/font.hxx +++ b/include/vcl/font.hxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -122,8 +123,8 @@ public: void SetCJKContextLanguage( LanguageType ); LanguageType GetCJKContextLanguage() const; - void SetOrientation( short nLineOrientation ); - short GetOrientation() const; + void SetOrientation( Degree10 nLineOrientation ); + Degree10 GetOrientation() const; void SetVertical( bool bVertical ); bool IsVertical() const; void SetKerning( FontKerning nKerning ); diff --git a/include/vcl/gdimtf.hxx b/include/vcl/gdimtf.hxx index bb20b618719a..202480faa818 100644 --- a/include/vcl/gdimtf.hxx +++ b/include/vcl/gdimtf.hxx @@ -116,7 +116,7 @@ public: void Move( tools::Long nX, tools::Long nY, tools::Long nDPIX, tools::Long nDPIY ); void Scale( double fScaleX, double fScaleY ); void Scale( const Fraction& rScaleX, const Fraction& rScaleY ); - void Rotate( tools::Long nAngle10 ); + void Rotate( Degree10 nAngle10 ); void Clip( const tools::Rectangle& ); bool HasTransparentActions() const; diff --git a/include/vcl/gradient.hxx b/include/vcl/gradient.hxx index aee89e06b50e..f2336d797703 100644 --- a/include/vcl/gradient.hxx +++ b/include/vcl/gradient.hxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -56,8 +57,8 @@ public: void SetEndColor( const Color& rColor ); const Color& GetEndColor() const; - void SetAngle( sal_uInt16 nAngle ); - sal_uInt16 GetAngle() const; + void SetAngle( Degree10 nAngle ); + Degree10 GetAngle() const; void SetBorder( sal_uInt16 nBorder ); sal_uInt16 GetBorder() const; diff --git a/include/vcl/hatch.hxx b/include/vcl/hatch.hxx index 92afd57b6126..713f22b95dd1 100644 --- a/include/vcl/hatch.hxx +++ b/include/vcl/hatch.hxx @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -35,7 +36,7 @@ struct ImplHatch Color maColor; HatchStyle meStyle; tools::Long mnDistance; - sal_uInt16 mnAngle; + Degree10 mnAngle; ImplHatch(); @@ -48,7 +49,7 @@ public: Hatch(); Hatch( const Hatch& rHatch ); - Hatch( HatchStyle eStyle, const Color& rHatchColor, tools::Long nDistance, sal_uInt16 nAngle10 ); + Hatch( HatchStyle eStyle, const Color& rHatchColor, tools::Long nDistance, Degree10 nAngle10 ); ~Hatch(); Hatch& operator=( const Hatch& rHatch ); @@ -63,8 +64,8 @@ public: void SetDistance( tools::Long nDistance ); tools::Long GetDistance() const { return mpImplHatch->mnDistance; } - void SetAngle( sal_uInt16 nAngle10 ); - sal_uInt16 GetAngle() const { return mpImplHatch->mnAngle; } + void SetAngle( Degree10 nAngle10 ); + Degree10 GetAngle() const { return mpImplHatch->mnAngle; } friend SvStream& ReadHatch( SvStream& rIStm, Hatch& rHatch ); friend SvStream& WriteHatch( SvStream& rOStm, const Hatch& rHatch ); diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index e1f6b17c47a0..60664ce3de02 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -959,7 +959,7 @@ public: private: - SAL_DLLPRIVATE void CalcHatchValues( const tools::Rectangle& rRect, tools::Long nDist, sal_uInt16 nAngle10, Point& rPt1, Point& rPt2, Size& rInc, Point& rEndPt1 ); + SAL_DLLPRIVATE void CalcHatchValues( const tools::Rectangle& rRect, tools::Long nDist, Degree10 nAngle10, Point& rPt1, Point& rPt2, Size& rInc, Point& rEndPt1 ); SAL_DLLPRIVATE void DrawHatchLine( const tools::Line& rLine, const tools::PolyPolygon& rPolyPoly, Point* pPtBuffer, bool bMtf ); ///@} @@ -1207,9 +1207,9 @@ private: SAL_DLLPRIVATE void ImplDrawSpecialText( SalLayout& ); SAL_DLLPRIVATE void ImplDrawTextRect( tools::Long nBaseX, tools::Long nBaseY, tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ); - SAL_DLLPRIVATE static void ImplDrawWavePixel( tools::Long nOriginX, tools::Long nOriginY, tools::Long nCurX, tools::Long nCurY, short nOrientation, SalGraphics* pGraphics, OutputDevice const * pOutDev, + SAL_DLLPRIVATE static void ImplDrawWavePixel( tools::Long nOriginX, tools::Long nOriginY, tools::Long nCurX, tools::Long nCurY, Degree10 nOrientation, SalGraphics* pGraphics, OutputDevice const * pOutDev, bool bDrawPixAsRect, tools::Long nPixWidth, tools::Long nPixHeight ); - SAL_DLLPRIVATE void ImplDrawWaveLine( tools::Long nBaseX, tools::Long nBaseY, tools::Long nStartX, tools::Long nStartY, tools::Long nWidth, tools::Long nHeight, tools::Long nLineWidth, short nOrientation, const Color& rColor ); + SAL_DLLPRIVATE void ImplDrawWaveLine( tools::Long nBaseX, tools::Long nBaseY, tools::Long nStartX, tools::Long nStartY, tools::Long nWidth, tools::Long nHeight, tools::Long nLineWidth, Degree10 nOrientation, const Color& rColor ); SAL_DLLPRIVATE void ImplDrawWaveTextLine( tools::Long nBaseX, tools::Long nBaseY, tools::Long nX, tools::Long nY, tools::Long nWidth, FontLineStyle eTextLine, Color aColor, bool bIsAbove ); SAL_DLLPRIVATE void ImplDrawStraightTextLine( tools::Long nBaseX, tools::Long nBaseY, tools::Long nX, tools::Long nY, tools::Long nWidth, FontLineStyle eTextLine, Color aColor, bool bIsAbove ); SAL_DLLPRIVATE void ImplDrawStrikeoutLine( tools::Long nBaseX, tools::Long nBaseY, tools::Long nX, tools::Long nY, tools::Long nWidth, FontStrikeout eStrikeout, Color aColor ); diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx index 8a5b9d2f502b..8546e3870418 100644 --- a/include/vcl/toolbox.hxx +++ b/include/vcl/toolbox.hxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -114,7 +115,7 @@ private: tools::Long mnBottomBorder; tools::Long mnLastResizeDY; tools::Long mnActivateCount; - tools::Long mnImagesRotationAngle; + Degree10 mnImagesRotationAngle; sal_uInt16 mnLastFocusItemId; sal_uInt16 mnOutStyle; sal_uInt16 mnHighItemId; @@ -369,7 +370,7 @@ public: void* GetItemData( sal_uInt16 nItemId ) const; void SetItemImage( sal_uInt16 nItemId, const Image& rImage ); Image GetItemImage( sal_uInt16 nItemId ) const; - void SetItemImageAngle( sal_uInt16 nItemId, tools::Long nAngle10 ); + void SetItemImageAngle( sal_uInt16 nItemId, Degree10 nAngle10 ); void SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror ); void SetItemText( sal_uInt16 nItemId, const OUString& rText ); const OUString& GetItemText( sal_uInt16 nItemId ) const; diff --git a/include/vcl/vcllayout.hxx b/include/vcl/vcllayout.hxx index ea8da12b7a9d..7d53d12bd40b 100644 --- a/include/vcl/vcllayout.hxx +++ b/include/vcl/vcllayout.hxx @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -78,7 +79,7 @@ public: virtual void DrawText( SalGraphics& ) const = 0; int GetUnitsPerPixel() const { return mnUnitsPerPixel; } - int GetOrientation() const { return mnOrientation; } + Degree10 GetOrientation() const { return mnOrientation; } // methods using string indexing virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const = 0; @@ -108,7 +109,7 @@ protected: int mnEndCharPos; int mnUnitsPerPixel; - int mnOrientation; + Degree10 mnOrientation; mutable Point maDrawOffset; Point maDrawBase; -- cgit