[Libreoffice-commits] core.git: oox/source sd/qa

Mark Hung marklh9 at gmail.com
Mon Nov 7 12:20:10 UTC 2016


 oox/source/export/shapes.cxx       |   22 ++++++++++++++++++++--
 sd/qa/unit/export-tests-ooxml2.cxx |    4 ++++
 2 files changed, 24 insertions(+), 2 deletions(-)

New commits:
commit f2bccf3685bdbd4ce8d72367e3af439470872fee
Author: Mark Hung <marklh9 at gmail.com>
Date:   Mon Oct 10 00:57:05 2016 +0800

    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/29679
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mark Hung <marklh9 at gmail.com>

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index a44f2ee..c9d693c 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -536,6 +536,7 @@ static bool lcl_IsOnBlacklist(OUString& rShapeType)
     static
 #endif
     const std::initializer_list<OUStringLiteral> vBlacklist = {
+        OUStringLiteral("block-arc"),
         OUStringLiteral("rectangle"),
         OUStringLiteral("ellipse"),
         OUStringLiteral("ring"),
@@ -656,8 +657,6 @@ void lcl_AnalyzeHandles( const uno::Sequence<beans::PropertyValues> & rHandles,
     {
         const OUString sSwitched( "Switched"  );
         const OUString sPosition( "Position"  );
-        sal_Int32 nXPosition = 0;
-        sal_Int32 nYPosition = 0;
         bool bSwitched = false;
         bool bPosition = false;
         EnhancedCustomShapeParameterPair aPosition;
@@ -678,6 +677,9 @@ void lcl_AnalyzeHandles( const uno::Sequence<beans::PropertyValues> & rHandles,
         }
         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( nYPosition, aPosition.Second, rSeq );
             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> >
     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 )
 {
     SAL_INFO("oox.shape", "write custom shape");
@@ -942,6 +950,16 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
                 lcl_AppendAdjustmentValue( aAvList, 0, adj );
                 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_sptBentConnector3:
             // case mso_sptBorderCallout3:
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 4bc7585..03cff30 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -496,6 +496,10 @@ void SdOOXMLExportTest2::testPresetShapesExport()
         "adj4","val -81930",
         "adj5","val -22375",
         "adj6","val -134550",
+        "blockArc",
+        "adj1","val 13020000",
+        "adj2","val 19380000",
+        "adj3","val 3773",
     };
 
     utl::TempFile tempFile;


More information about the Libreoffice-commits mailing list