Kaydet (Commit) f2bccf36 authored tarafından Mark Hung's avatar Mark Hung

oox: exporting the block arc as its corresponding drawingml preset shape.

block arcs were exported as paths, stretching it to the whole
viewport. Exporting it as a preset shape to prevents distortion.

Change-Id: I68bac6ee273d89c0a4333d4d6a4816c6a7f802a0
Reviewed-on: https://gerrit.libreoffice.org/29679Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMark Hung <marklh9@gmail.com>
üst d4f78fa3
...@@ -536,6 +536,7 @@ static bool lcl_IsOnBlacklist(OUString& rShapeType) ...@@ -536,6 +536,7 @@ static bool lcl_IsOnBlacklist(OUString& rShapeType)
static static
#endif #endif
const std::initializer_list<OUStringLiteral> vBlacklist = { const std::initializer_list<OUStringLiteral> vBlacklist = {
OUStringLiteral("block-arc"),
OUStringLiteral("rectangle"), OUStringLiteral("rectangle"),
OUStringLiteral("ellipse"), OUStringLiteral("ellipse"),
OUStringLiteral("ring"), OUStringLiteral("ring"),
...@@ -656,8 +657,6 @@ void lcl_AnalyzeHandles( const uno::Sequence<beans::PropertyValues> & rHandles, ...@@ -656,8 +657,6 @@ void lcl_AnalyzeHandles( const uno::Sequence<beans::PropertyValues> & rHandles,
{ {
const OUString sSwitched( "Switched" ); const OUString sSwitched( "Switched" );
const OUString sPosition( "Position" ); const OUString sPosition( "Position" );
sal_Int32 nXPosition = 0;
sal_Int32 nYPosition = 0;
bool bSwitched = false; bool bSwitched = false;
bool bPosition = false; bool bPosition = false;
EnhancedCustomShapeParameterPair aPosition; EnhancedCustomShapeParameterPair aPosition;
...@@ -678,6 +677,9 @@ void lcl_AnalyzeHandles( const uno::Sequence<beans::PropertyValues> & rHandles, ...@@ -678,6 +677,9 @@ void lcl_AnalyzeHandles( const uno::Sequence<beans::PropertyValues> & rHandles,
} }
if ( bPosition ) if ( bPosition )
{ {
sal_Int32 nXPosition = 0;
sal_Int32 nYPosition = 0;
// For polar handles, nXPosition is radius and nYPosition is angle
lcl_GetHandlePosition( nXPosition, aPosition.First , rSeq ); lcl_GetHandlePosition( nXPosition, aPosition.First , rSeq );
lcl_GetHandlePosition( nYPosition, aPosition.Second, rSeq ); lcl_GetHandlePosition( nYPosition, aPosition.Second, rSeq );
rHandlePositionList.push_back( std::pair<sal_Int32, sal_Int32> ( nXPosition, nYPosition ) ); rHandlePositionList.push_back( std::pair<sal_Int32, sal_Int32> ( nXPosition, nYPosition ) );
...@@ -690,6 +692,12 @@ void lcl_AppendAdjustmentValue( std::vector< std::pair< sal_Int32, sal_Int32> > ...@@ -690,6 +692,12 @@ void lcl_AppendAdjustmentValue( std::vector< std::pair< sal_Int32, sal_Int32> >
rAvList.push_back( std::pair<sal_Int32, sal_Int32> ( nAdjIdx , nValue ) ); rAvList.push_back( std::pair<sal_Int32, sal_Int32> ( nAdjIdx , nValue ) );
} }
sal_Int32 lcl_NormalizeAngle( sal_Int32 nAngle )
{
nAngle = nAngle % 360;
return nAngle < 0 ? ( nAngle + 360 ) : nAngle ;
}
ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape ) ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
{ {
SAL_INFO("oox.shape", "write custom shape"); SAL_INFO("oox.shape", "write custom shape");
...@@ -942,6 +950,16 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape ) ...@@ -942,6 +950,16 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
lcl_AppendAdjustmentValue( aAvList, 0, adj ); lcl_AppendAdjustmentValue( aAvList, 0, adj );
break; break;
} }
case mso_sptBlockArc:
{
sal_Int32 nRadius = 50000 * ( 1 - double(nXPosition) / 10800);
sal_Int32 nAngleStart = lcl_NormalizeAngle( nYPosition );
sal_Int32 nAngleEnd = lcl_NormalizeAngle( 180 - nAngleStart );
lcl_AppendAdjustmentValue( aAvList, 1, 21600000 / 360 * nAngleStart );
lcl_AppendAdjustmentValue( aAvList, 2, 21600000 / 360 * nAngleEnd );
lcl_AppendAdjustmentValue( aAvList, 3, nRadius );
break;
}
// case mso_sptNil: // case mso_sptNil:
// case mso_sptBentConnector3: // case mso_sptBentConnector3:
// case mso_sptBorderCallout3: // case mso_sptBorderCallout3:
......
...@@ -496,6 +496,10 @@ void SdOOXMLExportTest2::testPresetShapesExport() ...@@ -496,6 +496,10 @@ void SdOOXMLExportTest2::testPresetShapesExport()
"adj4","val -81930", "adj4","val -81930",
"adj5","val -22375", "adj5","val -22375",
"adj6","val -134550", "adj6","val -134550",
"blockArc",
"adj1","val 13020000",
"adj2","val 19380000",
"adj3","val 3773",
}; };
utl::TempFile tempFile; utl::TempFile tempFile;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment