diff options
author | Mark Hung <marklh9@gmail.com> | 2016-11-06 13:03:29 +0800 |
---|---|---|
committer | Mark Hung <marklh9@gmail.com> | 2016-11-12 03:19:18 +0000 |
commit | a39a2d28acb7f6034379a3c7ad47974f9c703fb6 (patch) | |
tree | 1f7cb0b21ef5b2416c74f9bf2dd446467c47e854 | |
parent | a241009fea0375d82dda24e10f9a5736652e2753 (diff) |
tdf#100733 svx: use RefR and RefAngle for polar handles.
Shapes imports from ooxml use RefR and RefAngle that refers
to adjustment to be updated. Though the properties exist
but the functions weren't implemented before.
Change-Id: Ib45c2e8b16c9a7b41387a3e8c356b803eaf74b77
Reviewed-on: https://gerrit.libreoffice.org/30603
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mark Hung <marklh9@gmail.com>
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShape2d.cxx | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index 91bd8afc6f93..bfe5f520c04b 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -1204,14 +1204,32 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex fPos1 /= fXScale; fPos2 /= fYScale; + // Used for scaling the adjustment values based on handle positions + double fWidth; + double fHeight; + + if ( nCoordWidth || nCoordHeight ) + { + fWidth = nCoordWidth; + fHeight = nCoordHeight; + } + else + { + fWidth = aLogicRect.GetWidth(); + fHeight = aLogicRect.GetHeight(); + } + if ( aHandle.nFlags & HandleFlags::SWITCHED ) { if ( aLogicRect.GetHeight() > aLogicRect.GetWidth() ) { double fX = fPos1; double fY = fPos2; + double fTmp = fWidth; fPos1 = fY; fPos2 = fX; + fHeight = fWidth; + fWidth = fTmp; } } @@ -1222,11 +1240,22 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex if ( aHandle.aPosition.Second.Type == EnhancedCustomShapeParameterType::ADJUSTMENT ) aHandle.aPosition.Second.Value>>= nSecondAdjustmentValue; - if ( aHandle.nFlags & HandleFlags::POLAR ) + + // DrawingML polar handles set REFR or REFANGLE instead of POLAR + if ( aHandle.nFlags & ( HandleFlags::POLAR | HandleFlags::REFR | HandleFlags::REFANGLE ) ) { double fXRef, fYRef, fAngle; - GetParameter( fXRef, aHandle.aPolar.First, false, false ); - GetParameter( fYRef, aHandle.aPolar.Second, false, false ); + if ( aHandle.nFlags & HandleFlags::POLAR ) + { + GetParameter( fXRef, aHandle.aPolar.First, false, false ); + GetParameter( fYRef, aHandle.aPolar.Second, false, false ); + } + else + { + // DrawingML polar handles don't have reference center. + fXRef = fWidth / 2; + fYRef = fHeight / 2; + } const double fDX = fPos1 - fXRef; fAngle = -( atan2( -fPos2 + fYRef, ( ( fDX == 0.0L ) ? 0.000000001 : fDX ) ) / F_PI180 ); double fX = ( fPos1 - fXRef ); @@ -1246,6 +1275,21 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex if ( fRadius > fMax ) fRadius = fMax; } + if (aHandle.nFlags & HandleFlags::REFR) + { + fRadius *= 100000.0; + fRadius /= sqrt( fWidth * fWidth + fHeight * fHeight ); + nFirstAdjustmentValue = aHandle.nRefR; + } + if (aHandle.nFlags & HandleFlags::REFANGLE) + { + if ( fAngle < 0 ) + fAngle += 360.0; + // Adjustment value referred by nRefAngle needs to be in 60000th a degree + // from 0 to 21600000. + fAngle *= 60000.0; + nSecondAdjustmentValue = aHandle.nRefAngle; + } if ( nFirstAdjustmentValue >= 0 ) SetAdjustValueAsDouble( fRadius, nFirstAdjustmentValue ); if ( nSecondAdjustmentValue >= 0 ) |