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 /filter | |
parent | CppunitTest_sc_subsequent_export: factor out duplicated code (diff) | |
download | core-0fb58a1ff168ae122e9c8993a3136658e3b0e3f0.tar.gz core-0fb58a1ff168ae122e9c8993a3136658e3b0e3f0.zip |
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 'filter')
-rw-r--r-- | filter/source/graphicfilter/eps/eps.cxx | 10 | ||||
-rw-r--r-- | filter/source/graphicfilter/idxf/dxf2mtf.cxx | 2 | ||||
-rw-r--r-- | filter/source/graphicfilter/ios2met/ios2met.cxx | 16 | ||||
-rw-r--r-- | filter/source/msfilter/escherex.cxx | 7 | ||||
-rw-r--r-- | filter/source/msfilter/eschesdo.cxx | 2 | ||||
-rw-r--r-- | filter/source/msfilter/msdffimp.cxx | 6 | ||||
-rw-r--r-- | filter/source/pdf/pdfexport.cxx | 4 | ||||
-rw-r--r-- | filter/source/svg/svgwriter.cxx | 8 |
8 files changed, 28 insertions, 27 deletions
diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx index 61502b06c503..e8cca292467c 100644 --- a/filter/source/graphicfilter/eps/eps.cxx +++ b/filter/source/graphicfilter/eps/eps.cxx @@ -2002,14 +2002,14 @@ void PSWriter::ImplText( const OUString& rUniString, const Point& rPos, const lo if ( mnTextMode == 0 ) // using glyph outlines { vcl::Font aNotRotatedFont( maFont ); - aNotRotatedFont.SetOrientation( 0 ); + aNotRotatedFont.SetOrientation( Degree10(0) ); ScopedVclPtrInstance< VirtualDevice > pVirDev(DeviceFormat::BITMASK); pVirDev->SetMapMode( rVDev.GetMapMode() ); pVirDev->SetFont( aNotRotatedFont ); pVirDev->SetTextAlign( eTextAlign ); - sal_Int16 nRotation = maFont.GetOrientation(); + Degree10 nRotation = maFont.GetOrientation(); tools::Polygon aPolyDummy( 1 ); Point aPos( rPos ); @@ -2031,7 +2031,7 @@ void PSWriter::ImplText( const OUString& rUniString, const Point& rPos, const lo ImplWriteLine( "t" ); if ( nRotation ) { - ImplWriteF( nRotation, 1 ); + ImplWriteF( nRotation.get(), 1 ); mpPS->WriteCharPtr( "r " ); } for (auto const& elem : aPolyPolyVec) @@ -2057,7 +2057,7 @@ void PSWriter::ImplSetAttrForText( const Point& rPoint ) { Point aPoint( rPoint ); - long nRotation = maFont.GetOrientation(); + Degree10 nRotation = maFont.GetOrientation(); ImplWriteTextColor(PS_RET); Size aSize = maFont.GetFontSize(); @@ -2089,7 +2089,7 @@ void PSWriter::ImplSetAttrForText( const Point& rPoint ) if ( nRotation ) { mpPS->WriteCharPtr( "gs " ); - ImplWriteF( nRotation, 1 ); + ImplWriteF( nRotation.get(), 1 ); mpPS->WriteCharPtr( "r " ); } } diff --git a/filter/source/graphicfilter/idxf/dxf2mtf.cxx b/filter/source/graphicfilter/idxf/dxf2mtf.cxx index 3d9e6c9ed463..f6fc91ae792d 100644 --- a/filter/source/graphicfilter/idxf/dxf2mtf.cxx +++ b/filter/source/graphicfilter/idxf/dxf2mtf.cxx @@ -206,7 +206,7 @@ bool DXF2GDIMetaFile::SetFontAttribute(const DXFBasicEntity & rE, short nAngle, aFont.SetFamily(FAMILY_SWISS); aFont.SetFontSize(Size(0,nHeight)); aFont.SetAlignment(ALIGN_BASELINE); - aFont.SetOrientation(nAngle); + aFont.SetOrientation(Degree10(nAngle)); if (aActFont!=aFont) { aActFont=aFont; pVirDev->SetFont(aActFont); diff --git a/filter/source/graphicfilter/ios2met/ios2met.cxx b/filter/source/graphicfilter/ios2met/ios2met.cxx index 7746b579df1d..cdf18abc66e4 100644 --- a/filter/source/graphicfilter/ios2met/ios2met.cxx +++ b/filter/source/graphicfilter/ios2met/ios2met.cxx @@ -286,7 +286,7 @@ struct OSAttr RasterOp eImgMix; RasterOp eImgBgMix; sal_Int32 nArcP, nArcQ, nArcR, nArcS; - short nChrAng; + Degree10 nChrAng; Size aChrCellSize; sal_uInt32 nChrSet; Point aCurPos; @@ -1013,7 +1013,7 @@ void OS2METReader::ReadChrStr(bool bGivenPos, bool bMove, bool bExtra, sal_uInt1 aFont = pF->aFont; aFont.SetColor(aAttr.aChrCol); aFont.SetFontSize(Size(0,aAttr.aChrCellSize.Height())); - if ( aAttr.nChrAng != 0 ) + if ( aAttr.nChrAng ) aFont.SetOrientation(aAttr.nChrAng); if (bGivenPos) @@ -1049,7 +1049,7 @@ void OS2METReader::ReadChrStr(bool bGivenPos, bool bMove, bool bExtra, sal_uInt1 pVirDev->DrawText(aP0,aStr); aSize = Size( pVirDev->GetTextWidth(aStr), pVirDev->GetTextHeight() ); - if ( aAttr.nChrAng == 0 ) + if ( !aAttr.nChrAng ) { aCalcBndRect.Union(tools::Rectangle( Point(aP0.X(),aP0.Y()-aSize.Height()), Size(aSize.Width(),aSize.Height()*2))); @@ -2037,11 +2037,11 @@ void OS2METReader::ReadOrder(sal_uInt16 nOrderID, sal_uInt16 nOrderLen) case GOrdSChAng: { sal_Int32 nX = ReadCoord(bCoord32); sal_Int32 nY = ReadCoord(bCoord32); - if (nX>=0 && nY==0) aAttr.nChrAng=0; + if (nX>=0 && nY==0) aAttr.nChrAng=Degree10(0); else { - aAttr.nChrAng=static_cast<short>(atan2(static_cast<double>(nY),static_cast<double>(nX))/3.1415926539*1800.0); - while (aAttr.nChrAng<0) aAttr.nChrAng+=3600; - aAttr.nChrAng%=3600; + aAttr.nChrAng = Degree10(static_cast<short>(atan2(static_cast<double>(nY),static_cast<double>(nX))/3.1415926539*1800.0)); + while (aAttr.nChrAng < Degree10(0)) aAttr.nChrAng += Degree10(3600); + aAttr.nChrAng %= Degree10(3600); } break; } @@ -2689,7 +2689,7 @@ void OS2METReader::ReadOS2MET( SvStream & rStreamOS2MET, GDIMetaFile & rGDIMetaF aDefAttr.nArcQ =1; aDefAttr.nArcR =0; aDefAttr.nArcS =0; - aDefAttr.nChrAng =0; + aDefAttr.nChrAng =Degree10(0); aDefAttr.aChrCellSize=Size(12,12); aDefAttr.nChrSet =0; aDefAttr.aCurPos =Point(0,0); diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index f9f3f7197f21..ce03064a89c0 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -1452,7 +1452,8 @@ Graphic lclDrawHatch( const drawing::Hatch& rHatch, const Color& rBackColor, boo pVDev->SetLineColor(); pVDev->SetFillColor(bFillBackground ? rBackColor : COL_TRANSPARENT); pVDev->DrawRect(rRect); - pVDev->DrawHatch(tools::PolyPolygon(rRect), Hatch(static_cast<HatchStyle>(rHatch.Style), Color(rHatch.Color), rHatch.Distance, static_cast<sal_uInt16>(rHatch.Angle))); + pVDev->DrawHatch(tools::PolyPolygon(rRect), Hatch(static_cast<HatchStyle>(rHatch.Style), Color(rHatch.Color), rHatch.Distance, + Degree10(rHatch.Angle))); aMtf.Stop(); aMtf.WindStart(); aMtf.SetPrefMapMode(MapMode(MapUnit::Map100thMM)); @@ -3926,7 +3927,7 @@ EscherBlibEntry::EscherBlibEntry( sal_uInt32 nPictureOffset, const GraphicObject .WriteInt32( pGraphicAttr->GetTopCrop() ) .WriteInt32( pGraphicAttr->GetRightCrop() ) .WriteInt32( pGraphicAttr->GetBottomCrop() ) - .WriteUInt16( pGraphicAttr->GetRotation() ) + .WriteUInt16( pGraphicAttr->GetRotation().get() ) .WriteInt16( pGraphicAttr->GetLuminance() ) .WriteInt16( pGraphicAttr->GetContrast() ) .WriteInt16( pGraphicAttr->GetChannelR() ) @@ -4622,7 +4623,7 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst ) sal_Int32 nAngle = ( EscherPropertyValueHelper::GetPropertyValue( aAny, aPropertySet, "RotateAngle", true ) ) ? *o3tl::doAccess<sal_Int32>(aAny) : 0; if ( nAngle ) - aPoly.Rotate( aRect.TopLeft(), static_cast<sal_uInt16>( ( nAngle + 5 ) / 10 ) ); + aPoly.Rotate( aRect.TopLeft(), Degree10(static_cast<sal_Int16>( ( nAngle + 5 ) / 10 )) ); nRule = GetClosestPoint( aPoly, aRefPoint ); if (aType == OString( "drawing.Ellipse" )) diff --git a/filter/source/msfilter/eschesdo.cxx b/filter/source/msfilter/eschesdo.cxx index 5619e1e09fa9..7132b8067e98 100644 --- a/filter/source/msfilter/eschesdo.cxx +++ b/filter/source/msfilter/eschesdo.cxx @@ -364,7 +364,7 @@ sal_uInt32 ImplEESdrWriter::ImplWriteShape( ImplEESdrObject& rObj, tools::Polygon aPolygon( rRect, aStart, aEnd, ePolyKind ); if( rObj.GetAngle() ) { - aPolygon.Rotate( rRect.TopLeft(), static_cast<sal_uInt16>( rObj.GetAngle() / 10 ) ); + aPolygon.Rotate( rRect.TopLeft(), Degree10(static_cast<sal_Int16>( rObj.GetAngle() / 10 )) ); rObj.SetAngle( 0 ); } mpEscherEx->OpenContainer( ESCHER_SpContainer ); diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index bd29942a6931..a32eed5a017d 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -1288,7 +1288,7 @@ static void ApplyRectangularGradientAsBitmap( const SvxMSDffManager& rManager, S rIn.Seek( nPos ); if ( bRotateWithShape ) { - aBitmapEx.Rotate( nFix16Angle / 10, rShadeColors[ 0 ].aColor ); + aBitmapEx.Rotate( Degree10(nFix16Angle / 10), rShadeColors[ 0 ].aColor ); BmpMirrorFlags nMirrorFlags = BmpMirrorFlags::NONE; if ( rObjData.nSpFlags & ShapeFlag::FlipV ) @@ -2865,7 +2865,7 @@ void DffPropertyReader::ImportGradientColor( SfxItemSet& aSet, sal_uInt32 eMSO_F } //Construct gradient item - XGradient aGrad( aCol2, aCol1, eGrad, nAngle, nFocusX, nFocusY ); + XGradient aGrad( aCol2, aCol1, eGrad, Degree10(nAngle), nFocusX, nFocusY ); //Intensity has been merged into color. So here just set is as 100 aGrad.SetStartIntens( 100 ); aGrad.SetEndIntens( 100 ); @@ -2878,7 +2878,7 @@ void DffPropertyReader::ImportGradientColor( SfxItemSet& aSet, sal_uInt32 eMSO_F aCol1 = Color(nStartCol, nStartCol, nStartCol); aCol2 = Color(nEndCol, nEndCol, nEndCol); - XGradient aGrad2( aCol2 , aCol1 , eGrad, nAngle, nFocusX, nFocusY ); + XGradient aGrad2( aCol2 , aCol1 , eGrad, Degree10(nAngle), nFocusX, nFocusY ); aSet.Put( XFillFloatTransparenceItem( OUString(), aGrad2 ) ); } } diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index 6a0794e94f15..7fa83e05bc75 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -1117,7 +1117,7 @@ void PDFExport::ImplWriteWatermark( vcl::PDFWriter& rWriter, const Size& rPageSi if( rPageSize.Width() < rPageSize.Height() ) { nTextWidth = rPageSize.Height(); - aFont.SetOrientation( 2700 ); + aFont.SetOrientation( Degree10(2700) ); } // adjust font height for text to fit @@ -1185,7 +1185,7 @@ void PDFExport::ImplWriteTiledWatermark( vcl::PDFWriter& rWriter, const Size& rP aFont.SetWeight( WEIGHT_NORMAL ); aFont.SetAlignment( ALIGN_BOTTOM ); aFont.SetFontHeight(40); - aFont.SetOrientation(450); + aFont.SetOrientation(Degree10(450)); OutputDevice* pDev = rWriter.GetReferenceDevice(); pDev->SetFont(aFont); diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index 7998d56754d0..37c301f2a3bf 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -221,7 +221,7 @@ void SVGAttributeWriter::AddGradientDef( const tools::Rectangle& rObjRect, const { SvXMLElementExport aDesc( mrExport, XML_NAMESPACE_NONE, aXMLElemDefs, true, true ); Color aStartColor( rGradient.GetStartColor() ), aEndColor( rGradient.GetEndColor() ); - sal_uInt16 nAngle = rGradient.GetAngle() % 3600; + Degree10 nAngle = rGradient.GetAngle() % Degree10(3600); Point aObjRectCenter( rObjRect.Center() ); tools::Polygon aPoly( rObjRect ); static sal_Int32 nCurGradientId = 1; @@ -1252,7 +1252,7 @@ void SVGTextWriter::startTextShape() { Point aRot( maTextPos ); OUString aTransform = "rotate(" + - OUString::number( rFont.GetOrientation() * -0.1 ) + " " + + OUString::number( rFont.GetOrientation().get() * -0.1 ) + " " + OUString::number( aRot.X() ) + " " + OUString::number( aRot.Y() ) + ")"; mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTransform, aTransform ); @@ -2249,7 +2249,7 @@ void SVGActionWriter::ImplWriteGradientLinear( const tools::PolyPolygon& rPolyPo rGradient.GetBoundRect( rPolyPoly.GetBoundRect(), aTmpRect, aTmpCenter ); ImplMap( aTmpRect, aRect ); ImplMap( aTmpCenter, aCenter ); - const sal_uInt16 nAngle = rGradient.GetAngle() % 3600; + const Degree10 nAngle = rGradient.GetAngle() % Degree10(3600); tools::Polygon aPoly( 2 ); // Setting x value of a gradient vector to rotation center to @@ -2601,7 +2601,7 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const OUString& rText, { Point aRot( aPos ); OUString aTransform = "rotate(" + - OUString::number( rFont.GetOrientation() * -0.1 ) + " " + + OUString::number( rFont.GetOrientation().get() * -0.1 ) + " " + OUString::number( aRot.X() ) + " " + OUString::number( aRot.Y() ) + ")"; mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTransform, aTransform ); |