diff options
-rw-r--r-- | include/tools/degree.hxx | 7 | ||||
-rw-r--r-- | svx/source/svdraw/svdmrkv.cxx | 5 | ||||
-rw-r--r-- | sw/inc/grfatr.hxx | 8 | ||||
-rw-r--r-- | sw/source/core/doc/notxtfrm.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/draw/dflyobj.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/graphic/grfatr.cxx | 16 | ||||
-rw-r--r-- | sw/source/core/graphic/ndgrf.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/inc/dflyobj.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/frmdlg/frmmgr.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/inc/frmmgr.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/shells/frmsh.cxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/shells/grfsh.cxx | 26 | ||||
-rw-r--r-- | sw/source/uibase/utlui/attrdesc.cxx | 2 |
15 files changed, 51 insertions, 47 deletions
diff --git a/include/tools/degree.hxx b/include/tools/degree.hxx index d7ff625b0de2..27bdffaa5de1 100644 --- a/include/tools/degree.hxx +++ b/include/tools/degree.hxx @@ -10,6 +10,7 @@ #include <sal/types.h> #include <o3tl/strong_int.hxx> +#include <math.h> /** tenths of a Degree, normally rotation */ typedef o3tl::strong_int<sal_Int16, struct Degree10Tag> Degree10; @@ -17,4 +18,10 @@ typedef o3tl::strong_int<sal_Int16, struct Degree10Tag> Degree10; /** custom literal */ constexpr Degree10 operator""_deg10(unsigned long long n) { return Degree10{ n }; } +/** conversion functions */ + +inline sal_Int32 toDegree100(Degree10 x) { return x.get() * 10; } +inline double toRadians(Degree10 x) { return x.get() * M_PI / 1800.0; } +inline double toDegrees(Degree10 x) { return x.get() / 10.0; } + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index 5e528e5947db..0d6911e71a1d 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -743,11 +743,6 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S // (SwVirtFlyDrawObj with a SwGrfNode) bool bWriterGraphic = pO->HasLimitedRotation(); - if (bWriterGraphic) - { - nRotAngle *= 10; - } - OStringBuffer aExtraInfo; aExtraInfo.append("{\"id\":\""); diff --git a/sw/inc/grfatr.hxx b/sw/inc/grfatr.hxx index 954a1a39dc28..05bf13ae591c 100644 --- a/sw/inc/grfatr.hxx +++ b/sw/inc/grfatr.hxx @@ -84,13 +84,13 @@ private: // tdf#115529 check and evtl. correct value, it is in 10th // degrees and *has* to be in the range [0 .. 3600[ - static sal_Int16 checkAndCorrectValue(sal_Int16 nValue); + static Degree10 checkAndCorrectValue(Degree10 nValue); public: SwRotationGrf() : SfxUInt16Item( RES_GRFATR_ROTATION, 0 ) {} - SwRotationGrf( sal_Int16 nVal, const Size& rSz ); + SwRotationGrf( Degree10 nVal, const Size& rSz ); // pure virtual methods from SfxInt16Item virtual SwRotationGrf* Clone( SfxItemPool *pPool = nullptr ) const override; @@ -105,7 +105,9 @@ public: virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; - const Size& GetUnrotatedSize() const { return m_aUnrotatedSize; } + const Size& GetUnrotatedSize() const { return m_aUnrotatedSize; } + Degree10 GetValue() const { return Degree10(SfxUInt16Item::GetValue()); } + void SetValue(Degree10 d) { SfxUInt16Item::SetValue(d.get()); } }; class SW_DLLPUBLIC SwLuminanceGrf : public SfxInt16Item diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 15778a3a5863..0a9225fd93f5 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -642,7 +642,7 @@ double SwNoTextFrame::getLocalFrameRotation() const { const SwAttrSet& rSwAttrSet(pSwGrfNode->GetSwAttrSet()); const SwRotationGrf& rSwRotationGrf(rSwAttrSet.GetRotationGrf()); - const double fRotate(static_cast< double >(-rSwRotationGrf.GetValue()) * (M_PI/1800.0)); + const double fRotate = -toRadians(rSwRotationGrf.GetValue()); return basegfx::normalizeToRange(fRotate, F_2PI); } diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx index 1d46ff307b63..31ddcf4dd727 100644 --- a/sw/source/core/draw/dflyobj.cxx +++ b/sw/source/core/draw/dflyobj.cxx @@ -396,10 +396,10 @@ void SwVirtFlyDrawObj::Rotate(const Point& rRef, tools::Long nAngle, double sn, { // RotGrfFlyFrame: Add transformation to placeholder object Size aSize; - const sal_uInt16 nOldRot(SwVirtFlyDrawObj::getPossibleRotationFromFraphicFrame(aSize)); + const Degree10 nOldRot(SwVirtFlyDrawObj::getPossibleRotationFromFraphicFrame(aSize)); SwFlyFrameAttrMgr aMgr(false, pShForAngle, Frmmgr_Type::NONE, nullptr); - aMgr.SetRotation(nOldRot, (nOldRot + static_cast<sal_uInt16>(nAngle)) % 3600, aSize); + aMgr.SetRotation(nOldRot, (nOldRot + Degree10(nAngle)) % 3600_deg10, aSize); } } else @@ -1144,9 +1144,9 @@ void SwVirtFlyDrawObj::Crop(const basegfx::B2DPoint& rRef, double fxFact, double } // RotGrfFlyFrame: Helper to access possible rotation of Graphic contained in FlyFrame -sal_uInt16 SwVirtFlyDrawObj::getPossibleRotationFromFraphicFrame(Size& rSize) const +Degree10 SwVirtFlyDrawObj::getPossibleRotationFromFraphicFrame(Size& rSize) const { - sal_uInt16 nRetval(0); + Degree10 nRetval; const SwNoTextFrame* pNoTx = dynamic_cast< const SwNoTextFrame* >(GetFlyFrame()->Lower()); if(pNoTx) @@ -1172,7 +1172,7 @@ tools::Long SwVirtFlyDrawObj::GetRotateAngle() const if(ContainsSwGrfNode()) { Size aSize; - return getPossibleRotationFromFraphicFrame(aSize); + return toDegree100(getPossibleRotationFromFraphicFrame(aSize)); } else { diff --git a/sw/source/core/graphic/grfatr.cxx b/sw/source/core/graphic/grfatr.cxx index 9c30a4bc9072..48e56afb585e 100644 --- a/sw/source/core/graphic/grfatr.cxx +++ b/sw/source/core/graphic/grfatr.cxx @@ -145,27 +145,27 @@ SwCropGrf* SwCropGrf::Clone( SfxItemPool* ) const return new SwCropGrf( *this ); } -sal_Int16 SwRotationGrf::checkAndCorrectValue(sal_Int16 nValue) +Degree10 SwRotationGrf::checkAndCorrectValue(Degree10 nValue) { - if(nValue < 0) + if(nValue.get() < 0) { // 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 3600 + (nValue % 3600); + return Degree10(3600 + (nValue.get() % 3600)); } - else if (nValue >= 3600) + else if (nValue.get() >= 3600) { // bigger range, use modulo DBG_ASSERT(false, "SwRotationGrf: Value is in 10th degree and *has* to be in [0 .. 3600[ (!)"); - return nValue % 3600; + return Degree10(nValue.get() % 3600); } return nValue; } -SwRotationGrf::SwRotationGrf( sal_Int16 nVal, const Size& rSz ) +SwRotationGrf::SwRotationGrf( Degree10 nVal, const Size& rSz ) // tdf#115529 check and evtl. correct value -: SfxUInt16Item( RES_GRFATR_ROTATION, checkAndCorrectValue(nVal) ), +: SfxUInt16Item( RES_GRFATR_ROTATION, checkAndCorrectValue(nVal).get() ), m_aUnrotatedSize( rSz ) { } @@ -198,7 +198,7 @@ bool SwRotationGrf::PutValue( const uno::Any& rVal, sal_uInt8 ) { // sal_uInt16 argument needed // tdf#115529 check and evtl. correct value - SetValue(static_cast<sal_uInt16>(checkAndCorrectValue(nValue))); + SetValue(checkAndCorrectValue(Degree10(nValue))); return true; } diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx index 5446ba6eed00..017a226c82a8 100644 --- a/sw/source/core/graphic/ndgrf.cxx +++ b/sw/source/core/graphic/ndgrf.cxx @@ -776,7 +776,7 @@ GraphicAttr& SwGrfNode::GetGraphicAttr( GraphicAttr& rGA, convertTwipToMm100( rCrop.GetBottom() )); const SwRotationGrf& rRotation = rSet.GetRotationGrf(); - rGA.SetRotation( Degree10(rRotation.GetValue()) ); + rGA.SetRotation( rRotation.GetValue() ); rGA.SetLuminance( rSet.GetLuminanceGrf().GetValue() ); rGA.SetContrast( rSet.GetContrastGrf().GetValue() ); diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx index a59e7cf23d54..e05fe4ec5526 100644 --- a/sw/source/core/inc/dflyobj.hxx +++ b/sw/source/core/inc/dflyobj.hxx @@ -63,7 +63,7 @@ private: // RotGrfFlyFrame: Helper to access the rotation angle (in 10th degrees, left-handed) // of a GraphicFrame - sal_uInt16 getPossibleRotationFromFraphicFrame(Size& rSize) const; + Degree10 getPossibleRotationFromFraphicFrame(Size& rSize) const; protected: // AW: Need own sdr::contact::ViewContact since AnchorPos from parent is diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index fb5eac573767..6f76dcbaebaa 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -5027,10 +5027,10 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size // Mirror on the vertical axis is a horizontal flip. xFrameAttributes->add(XML_flipH, "1"); // RES_GRFATR_ROTATION is sal_uInt16; use sal_uInt32 for multiplication later - if (sal_uInt32 nRot = rSet.Get(RES_GRFATR_ROTATION).GetValue()) + if (Degree10 nRot = rSet.Get(RES_GRFATR_ROTATION).GetValue()) { // RES_GRFATR_ROTATION is in 10ths of degree; convert to 100ths for macro - sal_uInt32 mOOXMLRot = oox::drawingml::ExportRotateClockwisify(nRot*10); + sal_uInt32 mOOXMLRot = oox::drawingml::ExportRotateClockwisify(nRot.get()*10); xFrameAttributes->add(XML_rot, OString::number(mOOXMLRot)); } } diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index bfea2e309526..5fdabb896756 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -4256,13 +4256,13 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat if (pAttrSet) { - if (sal_Int32 nRot = pAttrSet->Get(RES_GRFATR_ROTATION).GetValue()) + if (Degree10 nRot10 = pAttrSet->Get(RES_GRFATR_ROTATION).GetValue()) { // See writerfilter::rtftok::RTFSdrImport::applyProperty(), // positive rotation angles are clockwise in RTF, we have them // as counter-clockwise. // Additionally, RTF type is 0..360*2^16, our is 0..360*10. - nRot = nRot * -1 * RTF_MULTIPLIER / 10; + sal_Int32 nRot = nRot10.get() * -1 * RTF_MULTIPLIER / 10; aFlyProperties.emplace_back("rotation", OString::number(nRot)); } } diff --git a/sw/source/uibase/frmdlg/frmmgr.cxx b/sw/source/uibase/frmdlg/frmmgr.cxx index 3428c075c9c2..e8a3ba892829 100644 --- a/sw/source/uibase/frmdlg/frmmgr.cxx +++ b/sw/source/uibase/frmdlg/frmmgr.cxx @@ -584,7 +584,7 @@ void SwFlyFrameAttrMgr::SetHeightSizeType( SwFrameSize eType ) m_aSet.Put( aSize ); } -void SwFlyFrameAttrMgr::SetRotation(sal_uInt16 nOld, sal_uInt16 nNew, const Size& rUnrotatedSize) +void SwFlyFrameAttrMgr::SetRotation(Degree10 nOld, Degree10 nNew, const Size& rUnrotatedSize) { // RotGrfFlyFrame: Central handling of real change of rotation here, all adaptations use this. // Adaptation of pos/size may be wanted in the future. Already tried to keep last Size in diff --git a/sw/source/uibase/inc/frmmgr.hxx b/sw/source/uibase/inc/frmmgr.hxx index fc038f96d77d..27ebc70a66d3 100644 --- a/sw/source/uibase/inc/frmmgr.hxx +++ b/sw/source/uibase/inc/frmmgr.hxx @@ -93,7 +93,7 @@ public: void SetHeightSizeType(SwFrameSize eType); // rotation - void SetRotation(sal_uInt16 nOld, sal_uInt16 nNew, const Size& rUnrotatedSize); + void SetRotation(Degree10 nOld, Degree10 nNew, const Size& rUnrotatedSize); // space to content void SetLRSpace( tools::Long nLeft, diff --git a/sw/source/uibase/shells/frmsh.cxx b/sw/source/uibase/shells/frmsh.cxx index 1d352cafb16a..f529d30f4be0 100644 --- a/sw/source/uibase/shells/frmsh.cxx +++ b/sw/source/uibase/shells/frmsh.cxx @@ -396,11 +396,11 @@ void SwFrameShell::Execute(SfxRequest &rReq) SfxItemSet aSet(rSh.GetAttrPool(), svl::Items<RES_GRFATR_ROTATION, RES_GRFATR_ROTATION>{} ); rSh.GetCurAttr(aSet); const SwRotationGrf& rRotation = aSet.Get(RES_GRFATR_ROTATION); - const sal_uInt32 nOldRot(rRotation.GetValue()); + const Degree10 nOldRot(rRotation.GetValue()); if (pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_TRANSFORM_DELTA_ANGLE, false, &pItem)) { - const sal_uInt32 nDeltaRot(static_cast<const SfxUInt32Item*>(pItem)->GetValue() / 10); + const Degree10 nDeltaRot(static_cast<const SfxUInt32Item*>(pItem)->GetValue() / 10); aMgr.SetRotation(nOldRot, nOldRot + nDeltaRot, rRotation.GetUnrotatedSize()); } @@ -410,7 +410,7 @@ void SwFrameShell::Execute(SfxRequest &rReq) // 100th degrees in SID_ATTR_TRANSFORM_ANGLE to 10th degrees in RES_GRFATR_ROTATION if (pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_TRANSFORM_ANGLE, false, &pItem)) { - const sal_uInt32 nNewRot(static_cast<const SdrAngleItem*>(pItem)->GetValue() / 10); + const Degree10 nNewRot(static_cast<const SdrAngleItem*>(pItem)->GetValue() / 10); // RotGrfFlyFrame: Rotation change here, SwFlyFrameAttrMgr aMgr is available aMgr.SetRotation(nOldRot, nNewRot, rRotation.GetUnrotatedSize()); diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx index 76139243ca92..c3eedb17a7d6 100644 --- a/sw/source/uibase/shells/grfsh.cxx +++ b/sw/source/uibase/shells/grfsh.cxx @@ -385,7 +385,7 @@ void SwGrfShell::Execute(SfxRequest &rReq) } Size aUnrotatedSize; - sal_uInt16 nCurrentRotation(0); + Degree10 nCurrentRotation; { // RotGrfFlyFrame: Add current RotationAngle value, convert from // RES_GRFATR_ROTATION to SID_ATTR_TRANSFORM_ANGLE. Do not forget to // convert from 10th degrees to 100th degrees @@ -394,7 +394,7 @@ void SwGrfShell::Execute(SfxRequest &rReq) const SwRotationGrf& rRotation = aTmpSet.Get(RES_GRFATR_ROTATION); nCurrentRotation = rRotation.GetValue(); aUnrotatedSize = rRotation.GetUnrotatedSize(); - aSet.Put(SdrAngleItem(SID_ATTR_TRANSFORM_ANGLE, nCurrentRotation * 10)); + aSet.Put(SdrAngleItem(SID_ATTR_TRANSFORM_ANGLE, toDegree100(nCurrentRotation))); } SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); @@ -511,7 +511,7 @@ void SwGrfShell::Execute(SfxRequest &rReq) // RotGrfFlyFrame: Get and process evtl. changed RotationAngle if ( SfxItemState::SET == pSet->GetItemState(SID_ATTR_TRANSFORM_ANGLE, false, &pItem )) { - const sal_Int32 aNewRotation((static_cast<const SdrAngleItem*>(pItem)->GetValue() / 10) % 3600); + const Degree10 aNewRotation((static_cast<const SdrAngleItem*>(pItem)->GetValue() / 10) % 3600); // RotGrfFlyFrame: Possible rotation change here, SwFlyFrameAttrMgr aMgr is available aMgr.SetRotation(nCurrentRotation, aNewRotation, aUnrotatedSize); @@ -913,22 +913,22 @@ void SwGrfShell::GetAttrState(SfxItemSet &rSet) void SwGrfShell::ExecuteRotation(SfxRequest const &rReq) { // RotGrfFlyFrame: Modify rotation attribute instead of manipulating the graphic - sal_uInt16 aRotation(0); + Degree10 aRotation; if (rReq.GetSlot() == SID_ROTATE_GRAPHIC_LEFT) { - aRotation = 900; + aRotation = 900_deg10; } else if (rReq.GetSlot() == SID_ROTATE_GRAPHIC_RIGHT) { - aRotation = 2700; + aRotation = 2700_deg10; } else if (rReq.GetSlot() == SID_ROTATE_GRAPHIC_180) { - aRotation = 1800; + aRotation = 1800_deg10; } - if (rReq.GetSlot() != SID_ROTATE_GRAPHIC_RESET && 0 == aRotation) + if (rReq.GetSlot() != SID_ROTATE_GRAPHIC_RESET && 0_deg10 == aRotation) return; SwWrtShell& rShell = GetShell(); @@ -940,11 +940,11 @@ void SwGrfShell::ExecuteRotation(SfxRequest const &rReq) // RotGrfFlyFrame: Possible rotation change here, SwFlyFrameAttrMgr aMgr is available if (rReq.GetSlot() == SID_ROTATE_GRAPHIC_RESET) { - aMgr.SetRotation(rRotation.GetValue(), 0, rRotation.GetUnrotatedSize()); + aMgr.SetRotation(rRotation.GetValue(), 0_deg10, rRotation.GetUnrotatedSize()); } - else if(0 != aRotation) + else if(0_deg10 != aRotation) { - const sal_uInt16 aNewRotation((aRotation + rRotation.GetValue()) % 3600); + const Degree10 aNewRotation((aRotation + rRotation.GetValue()) % 3600_deg10); aMgr.SetRotation(rRotation.GetValue(), aNewRotation, rRotation.GetUnrotatedSize()); } @@ -980,7 +980,7 @@ void SwGrfShell::GetAttrStateForRotation(SfxItemSet &rSet) SfxItemSet aSet( rShell.GetAttrPool(), svl::Items<RES_GRFATR_ROTATION, RES_GRFATR_ROTATION>{} ); rShell.GetCurAttr( aSet ); const SwRotationGrf& rRotation = aSet.Get(RES_GRFATR_ROTATION); - bDisable = (0 == rRotation.GetValue()); + bDisable = (0_deg10 == rRotation.GetValue()); break; } case SID_ATTR_TRANSFORM_ANGLE: @@ -990,7 +990,7 @@ void SwGrfShell::GetAttrStateForRotation(SfxItemSet &rSet) SfxItemSet aSet( rShell.GetAttrPool(), svl::Items<RES_GRFATR_ROTATION, RES_GRFATR_ROTATION>{} ); rShell.GetCurAttr( aSet ); const SwRotationGrf& rRotation = aSet.Get(RES_GRFATR_ROTATION); - rSet.Put(SdrAngleItem(SID_ATTR_TRANSFORM_ANGLE, rRotation.GetValue() * 10)); + rSet.Put(SdrAngleItem(SID_ATTR_TRANSFORM_ANGLE, toDegree100(rRotation.GetValue()))); break; } default: diff --git a/sw/source/uibase/utlui/attrdesc.cxx b/sw/source/uibase/utlui/attrdesc.cxx index 53239a1d6a3a..861697d5e329 100644 --- a/sw/source/uibase/utlui/attrdesc.cxx +++ b/sw/source/uibase/utlui/attrdesc.cxx @@ -702,7 +702,7 @@ bool SwRotationGrf::GetPresentation( rText = SwResId( STR_ROTATION ); else if( rText.getLength() ) rText.clear(); - rText += OUString::number( GetValue() ) + "\xB0"; + rText += OUString::number( toDegrees(GetValue()) ) + "\xB0"; return true; } |