From 7ead98eec843e68dcec6c4d5c97a577be7adec4c Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Mon, 22 Nov 2021 12:22:45 +0300 Subject: [PATCH] Use less DegreeN::get() Change-Id: I97b8d6282c72307cc29a913af221d283523f2fae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125653 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- .../controller/itemsetwrapper/AxisItemConverter.cxx | 5 +---- .../itemsetwrapper/DataPointItemConverter.cxx | 4 +--- editeng/source/items/textitem.cxx | 4 ++-- filter/source/msfilter/msdffimp.cxx | 17 +++++++---------- oox/source/export/drawingml.cxx | 2 +- sc/source/ui/sidebar/AlignmentPropertyPanel.cxx | 2 +- svx/source/fmcomp/fmgridif.cxx | 2 +- svx/source/sidebar/area/AreaPropertyPanelBase.cxx | 4 ++-- .../sidebar/area/AreaTransparencyGradientPopup.cxx | 4 ++-- svx/source/table/cell.cxx | 2 +- sw/source/core/graphic/grfatr.cxx | 8 ++++---- sw/source/filter/ww8/docxattributeoutput.cxx | 3 +-- sw/source/filter/ww8/docxsdrexport.cxx | 2 +- vcl/win/gdi/DWriteTextRenderer.cxx | 2 +- 14 files changed, 26 insertions(+), 35 deletions(-) diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx index 6a1bb0867803..0dd0e5b6b6fe 100644 --- a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx @@ -878,10 +878,7 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet case SCHATTR_TEXT_DEGREES: { - // convert int to double (divided by 100) - double fVal = static_cast< double >( - static_cast< const SdrAngleItem & >( - rItemSet.Get( nWhichId )).GetValue().get()) / 100.0; + double fVal = toDegrees(rItemSet.Get(SCHATTR_TEXT_DEGREES).GetValue()); double fOldVal = 0.0; bool bPropExisted = ( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fOldVal ); diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx index 5b6e9523fbef..990120a97a04 100644 --- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx @@ -551,9 +551,7 @@ bool DataPointItemConverter::ApplySpecialItem( case SCHATTR_TEXT_DEGREES: { - double fValue = static_cast< double >( - static_cast< const SdrAngleItem & >( - rItemSet.Get( nWhichId )).GetValue().get()) / 100.0; + double fValue = toDegrees(rItemSet.Get(SCHATTR_TEXT_DEGREES).GetValue()); double fOldValue = 0.0; bool bPropExisted = ( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fOldValue ); diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index 8ecfa67584aa..02f8d6a9be4e 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -2196,7 +2196,7 @@ bool SvxTextRotateItem::GetPresentation( { rText = EditResId(RID_SVXITEMS_TEXTROTATE); rText = rText.replaceFirst("$(ARG1)", - OUString::number(GetValue().get() / 10)); + OUString::number(toDegrees(GetValue()))); } return true; } @@ -2275,7 +2275,7 @@ bool SvxCharRotateItem::GetPresentation( { rText = EditResId( RID_SVXITEMS_CHARROTATE ); rText = rText.replaceFirst( "$(ARG1)", - OUString::number( GetValue().get() / 10 )); + OUString::number( toDegrees(GetValue()) )); if( IsFitToLine() ) rText += EditResId( RID_SVXITEMS_CHARROTATE_FITLINE ); } diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 8e35938ceb5c..8de295d6b897 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -2774,7 +2774,7 @@ void DffPropertyReader::CheckAndCorrectExcelTextRotation( SvStream& rIn, SfxItem *pAny >>= fExtraTextRotateAngle; if ( rManager.mnFix16Angle ) - fExtraTextRotateAngle += mnFix16Angle.get() / 100.0; + fExtraTextRotateAngle += toDegrees(mnFix16Angle); if ( rObjData.nSpFlags & ShapeFlag::FlipV ) fExtraTextRotateAngle -= 180.0; @@ -2797,24 +2797,21 @@ void DffPropertyReader::ImportGradientColor( SfxItemSet& aSet, sal_uInt32 eMSO_F nChgColors ^= 1; //Translate a MS clockwise(+) or count clockwise angle(-) into an AOO count clock wise angle - Degree10 nAngle( 3600 - ( ( Fix16ToAngle(nAngleFix16).get() + 5 ) / 10 ) ); + Degree10 nAngle( 3600_deg10 - to( Fix16ToAngle(nAngleFix16) ) ); //Make sure this angle belongs to 0~3600 - while ( nAngle >= Degree10(3600) ) nAngle -= Degree10(3600); - while ( nAngle < Degree10(0) ) nAngle += Degree10(3600); + while ( nAngle >= 3600_deg10 ) nAngle -= 3600_deg10; + while ( nAngle < 0_deg10 ) nAngle += 3600_deg10; //Rotate angle if ( mbRotateGranientFillWithAngle ) { sal_Int32 nRotateAngle = GetPropertyValue( DFF_Prop_Rotation, 0 ); - if(nRotateAngle)//fixed point number - nRotateAngle = ( static_cast( nRotateAngle >> 16) * 100L ) + ( ( ( nRotateAngle & 0x0000ffff) * 100L ) >> 16 ); - nRotateAngle = ( nRotateAngle + 5 ) / 10 ;//round up //nAngle is a clockwise angle. If nRotateAngle is a clockwise angle, then gradient needs to be rotated a little less //or it needs to be rotated a little more - nAngle -= Degree10(nRotateAngle); + nAngle -= to(Fix16ToAngle(nRotateAngle)); } - while ( nAngle >= Degree10(3600) ) nAngle -= Degree10(3600); - while ( nAngle < Degree10(0) ) nAngle += Degree10(3600); + while ( nAngle >= 3600_deg10 ) nAngle -= 3600_deg10; + while ( nAngle < 0_deg10 ) nAngle += 3600_deg10; css::awt::GradientStyle eGrad = css::awt::GradientStyle_LINEAR; diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index dd112c9b6643..3371c04eac8e 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1858,7 +1858,7 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa // OOXML flips shapes before rotating them. if(bFlipH != bFlipV) - nRotation = Degree100(nRotation.get() * -1 + 36000); + nRotation = 36000_deg100 - nRotation; WriteTransformation(rXShape, tools::Rectangle(Point(aPos.X, aPos.Y), Size(aSize.Width, aSize.Height)), nXmlNamespace, bFlipHWrite, bFlipVWrite, ExportRotateClockwisify(nRotation + nCameraRotation), IsGroupShape( rXShape )); diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx index 28f17f3054dc..370b791573ed 100644 --- a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx +++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx @@ -322,7 +322,7 @@ void AlignmentPropertyPanel::NotifyItemUpdate( if (eState >= SfxItemState::DEFAULT) { Degree100 nTmp = static_cast(pState)->GetValue(); - mxMtrAngle->set_value(nTmp.get() / 100, FieldUnit::DEGREE); + mxMtrAngle->set_value(toDegrees(nTmp), FieldUnit::DEGREE); } else { diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index 40e4eefd7d44..a96472e3ad14 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -97,7 +97,7 @@ static css::awt::FontDescriptor ImplCreateFontDescriptor( const vcl::Font& rFont aFD.Slant = vcl::unohelper::ConvertFontSlant( rFont.GetItalic() ); aFD.Underline = static_cast(rFont.GetUnderline()); aFD.Strikeout = static_cast(rFont.GetStrikeout()); - aFD.Orientation = rFont.GetOrientation().get() / 10.0; + aFD.Orientation = toDegrees(rFont.GetOrientation()); aFD.Kerning = rFont.IsKerning(); aFD.WordLineMode = rFont.IsWordLineMode(); aFD.Type = 0; // ??? => only to metric... diff --git a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx index f5d550ab51f7..428d35d94d59 100644 --- a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx +++ b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx @@ -307,7 +307,7 @@ IMPL_LINK_NOARG(AreaPropertyPanelBase, SelectFillTypeHdl, weld::ComboBox&, void) mxLbFillGradFrom->SelectEntry(aGradient.GetStartColor()); mxLbFillGradTo->SelectEntry(aGradient.GetEndColor()); - mxMTRAngle->set_value(aGradient.GetAngle().get() / 10, FieldUnit::DEGREE); + mxMTRAngle->set_value(toDegrees(aGradient.GetAngle()), FieldUnit::DEGREE); css::awt::GradientStyle eXGS = aGradient.GetGradientStyle(); mxGradientStyle->set_active(sal::static_int_cast< sal_Int32 >( eXGS )); } @@ -1148,7 +1148,7 @@ void AreaPropertyPanelBase::Update() if(mxGradientStyle->get_active() == sal_Int32(GradientStyle::Radial)) mxMTRAngle->set_sensitive(false); else - mxMTRAngle->set_value(aGradient.GetAngle().get() / 10, FieldUnit::DEGREE); + mxMTRAngle->set_value(toDegrees(aGradient.GetAngle()), FieldUnit::DEGREE); } else { diff --git a/svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx b/svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx index 581d302a9d7d..c6c3fa4e4bbd 100644 --- a/svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx +++ b/svx/source/sidebar/area/AreaTransparencyGradientPopup.cxx @@ -63,7 +63,7 @@ void AreaTransparencyGradientPopup::InitStatus(XFillFloatTransparenceItem const if (rGradient.GetXOffset() == AreaPropertyPanelBase::DEFAULT_CENTERX && rGradient.GetYOffset() == AreaPropertyPanelBase::DEFAULT_CENTERY - && (rGradient.GetAngle().get() / 10) == AreaPropertyPanelBase::DEFAULT_ANGLE + && static_cast(toDegrees(rGradient.GetAngle())) == AreaPropertyPanelBase::DEFAULT_ANGLE && static_cast(((static_cast(rGradient.GetStartColor().GetRed()) + 1) * 100) / 255) == AreaPropertyPanelBase::DEFAULT_STARTVALUE && static_cast(((static_cast(rGradient.GetEndColor().GetRed()) + 1) * 100) / 255) @@ -78,7 +78,7 @@ void AreaTransparencyGradientPopup::InitStatus(XFillFloatTransparenceItem const } mxMtrTrgrCenterX->set_value(aGradient.GetXOffset(), FieldUnit::PERCENT); mxMtrTrgrCenterY->set_value(aGradient.GetYOffset(), FieldUnit::PERCENT); - mxMtrTrgrAngle->set_value(aGradient.GetAngle().get() / 10, FieldUnit::DEGREE); + mxMtrTrgrAngle->set_value(toDegrees(aGradient.GetAngle()), FieldUnit::DEGREE); mxMtrTrgrStartValue->set_value(static_cast(((static_cast(aGradient.GetStartColor().GetRed()) + 1) * 100) / 255), FieldUnit::PERCENT); mxMtrTrgrEndValue->set_value(static_cast(((static_cast(aGradient.GetEndColor().GetRed()) + 1) * 100) / 255), FieldUnit::PERCENT); mxMtrTrgrBorder->set_value(aGradient.GetBorder(), FieldUnit::PERCENT); diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index 134becd88e8b..f09de95e7826 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -1218,7 +1218,7 @@ Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName ) case SDRATTR_TABLE_TEXT_ROTATION: { const SvxTextRotateItem& rTextRotate = mpProperties->GetItem(SDRATTR_TABLE_TEXT_ROTATION); - return Any(sal_Int32(rTextRotate.GetValue().get() * 10)); + return Any(sal_Int32(to(rTextRotate.GetValue()))); } default: { diff --git a/sw/source/core/graphic/grfatr.cxx b/sw/source/core/graphic/grfatr.cxx index b267a55c19d2..50a84c12fb8e 100644 --- a/sw/source/core/graphic/grfatr.cxx +++ b/sw/source/core/graphic/grfatr.cxx @@ -148,17 +148,17 @@ SwCropGrf* SwCropGrf::Clone( SfxItemPool* ) const Degree10 SwRotationGrf::checkAndCorrectValue(Degree10 nValue) { - if(nValue.get() < 0) + if (nValue < 0_deg10) { // smaller zero, modulo (will keep negative) and add one range DBG_ASSERT(false, "SwRotationGrf: Value is in 10th degree and *has* to be in [0 .. 3600[ (!)"); - return Degree10(3600 + (nValue.get() % 3600)); + return 3600_deg10 + nValue % 3600_deg10; } - else if (nValue.get() >= 3600) + else if (nValue >= 3600_deg10) { // bigger range, use modulo DBG_ASSERT(false, "SwRotationGrf: Value is in 10th degree and *has* to be in [0 .. 3600[ (!)"); - return Degree10(nValue.get() % 3600); + return nValue % 3600_deg10; } return nValue; diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index bcdd1af1af4f..9b6a144ed481 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -9388,8 +9388,7 @@ void DocxAttributeOutput::FormatFillGradient( const XFillGradientItem& rFillGrad // /oox/source/vml/vmlformatting.cxx :: FillModel::pushToPropMap // and also in // /oox/source/drawingml/fillproperties.cxx :: FillProperties::pushToPropMap - sal_Int32 nReverseAngle = (4500_deg10 - rGradient.GetAngle()).get(); - nReverseAngle = nReverseAngle / 10; + sal_Int32 nReverseAngle = toDegrees(4500_deg10 - rGradient.GetAngle()); nReverseAngle = (270 - nReverseAngle) % 360; if (nReverseAngle != 0) AddToAttrList( m_rExport.SdrExporter().getFlyFillAttrList(), diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index dd15aeee8445..7166ed49565f 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -2082,7 +2082,7 @@ void DocxSdrExport::writeVMLTextFrame(ww8::Frame const* pParentFrame, bool bText m_pImpl->getTextFrameStyle() = "position:absolute"; if (!bTextBoxOnly) { - OString sRotation(OString::number(m_pImpl->getDMLandVMLTextFrameRotation().get() / -100)); + OString sRotation(OString::number(-toDegrees(m_pImpl->getDMLandVMLTextFrameRotation()))); m_pImpl->getExport().SdrExporter().getTextFrameStyle().append(";rotation:" + sRotation); } m_pImpl->getExport().OutputFormat(pParentFrame->GetFrameFormat(), false, false, true); diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx b/vcl/win/gdi/DWriteTextRenderer.cxx index 177f1e7c3384..edd0b700bdf6 100644 --- a/vcl/win/gdi/DWriteTextRenderer.cxx +++ b/vcl/win/gdi/DWriteTextRenderer.cxx @@ -414,7 +414,7 @@ WinFontTransformGuard::WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, f // degrees. aTransform = aTransform * D2D1::Matrix3x2F::Rotation( - -static_cast(angle.get()) / 10, rBaseline); + -toDegrees(angle), rBaseline); } mpRenderTarget->SetTransform(aTransform); } -- 2.11.4.GIT