svx/inc/EnhancedCustomShapeEngine.hxx                 |    2 
 svx/source/customshapes/EnhancedCustomShapeEngine.cxx |  119 +++++++++---------
 svx/source/svdraw/svdoashp.cxx                        |    3 
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx            |    4 
 4 files changed, 67 insertions(+), 61 deletions(-)

New commits:
commit c2352b10d4fff29023decd3daf4be80f58c3062b
Author:     Noel Grandin <[email protected]>
AuthorDate: Fri Sep 26 11:16:58 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Sat Sep 27 08:33:24 2025 +0200

    avoid converting twice in EnhancedCustomShapeEngine
    
    now that we know which concrete class we are dealing with
    we can avoid converting backwards and forwards between geometry
    types.
    
    Change-Id: I0891e3a35a7bbf0f8672ba24ee72686fa5e6db3c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191532
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/svx/inc/EnhancedCustomShapeEngine.hxx 
b/svx/inc/EnhancedCustomShapeEngine.hxx
index df240853ef45..9bedb748ada3 100644
--- a/svx/inc/EnhancedCustomShapeEngine.hxx
+++ b/svx/inc/EnhancedCustomShapeEngine.hxx
@@ -51,6 +51,8 @@ public:
     virtual css::drawing::PolyPolygonBezierCoords SAL_CALL getLineGeometry() 
override;
     virtual 
css::uno::Sequence<css::uno::Reference<css::drawing::XCustomShapeHandle>>
         SAL_CALL getInteraction() override;
+
+    basegfx::B2DPolyPolygon getB2DLineGeometry() const;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx 
b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
index 3793b2ce1066..65a6787aa8ae 100644
--- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
@@ -334,84 +334,89 @@ awt::Rectangle SAL_CALL 
EnhancedCustomShapeEngine::getTextBounds()
 }
 
 drawing::PolyPolygonBezierCoords SAL_CALL 
EnhancedCustomShapeEngine::getLineGeometry()
+{
+    basegfx::B2DPolyPolygon aPolyPolygon = getB2DLineGeometry();
+    drawing::PolyPolygonBezierCoords aPolyPolygonBezierCoords;
+    basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( aPolyPolygon,
+                                                          
aPolyPolygonBezierCoords );
+    return aPolyPolygonBezierCoords;
+}
+
+basegfx::B2DPolyPolygon EnhancedCustomShapeEngine::getB2DLineGeometry() const
 {
     SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape(mxShape);
     if (!pSdrObj)
-        return drawing::PolyPolygonBezierCoords();
+        return basegfx::B2DPolyPolygon();
 
     // the only two subclasses of SdrObject we see here are SdrObjCustomShape 
and SwDrawVirtObj
     SdrObjCustomShape* pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* 
>(pSdrObj);
     if (!pSdrObjCustomShape)
-        return drawing::PolyPolygonBezierCoords();
-
-    drawing::PolyPolygonBezierCoords aPolyPolygonBezierCoords;
+        return basegfx::B2DPolyPolygon();
 
     EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape);
     rtl::Reference<SdrObject> pObj = aCustomShape2d.CreateLineGeometry();
 
-    if ( pObj )
-    {
-        tools::Rectangle aRect(pSdrObjCustomShape->GetSnapRect());
-        bool bFlipV = aCustomShape2d.IsFlipVert();
-        bool bFlipH = aCustomShape2d.IsFlipHorz();
-        const GeoStat& rGeoStat(pSdrObjCustomShape->GetGeoStat());
+    if ( !pObj )
+        return basegfx::B2DPolyPolygon();
 
-        if ( rGeoStat.m_nShearAngle )
+    tools::Rectangle aRect(pSdrObjCustomShape->GetSnapRect());
+    bool bFlipV = aCustomShape2d.IsFlipVert();
+    bool bFlipH = aCustomShape2d.IsFlipHorz();
+    const GeoStat& rGeoStat(pSdrObjCustomShape->GetGeoStat());
+
+    if ( rGeoStat.m_nShearAngle )
+    {
+        Degree100 nShearAngle = rGeoStat.m_nShearAngle;
+        double nTan = rGeoStat.mfTanShearAngle;
+        if (bFlipV != bFlipH)
         {
-            Degree100 nShearAngle = rGeoStat.m_nShearAngle;
-            double nTan = rGeoStat.mfTanShearAngle;
-            if (bFlipV != bFlipH)
-            {
-                nShearAngle = -nShearAngle;
-                nTan = -nTan;
-            }
-            pObj->Shear( aRect.Center(), nShearAngle, nTan, false);
+            nShearAngle = -nShearAngle;
+            nTan = -nTan;
         }
-        Degree100 nRotateAngle = aCustomShape2d.GetRotateAngle();
-        if( nRotateAngle )
-            pObj->NbcRotate( aRect.Center(), nRotateAngle );
-        if ( bFlipH )
+        pObj->Shear( aRect.Center(), nShearAngle, nTan, false);
+    }
+    Degree100 nRotateAngle = aCustomShape2d.GetRotateAngle();
+    if( nRotateAngle )
+        pObj->NbcRotate( aRect.Center(), nRotateAngle );
+    if ( bFlipH )
+    {
+        Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() );
+        Point aBottom( aTop.X(), aTop.Y() + 1000 );
+        pObj->NbcMirror( aTop, aBottom );
+    }
+    if ( bFlipV )
+    {
+        Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 );
+        Point aRight( aLeft.X() + 1000, aLeft.Y() );
+        pObj->NbcMirror( aLeft, aRight );
+    }
+
+    basegfx::B2DPolyPolygon aPolyPolygon;
+    SdrObjListIter aIter( *pObj, SdrIterMode::DeepWithGroups );
+
+    while ( aIter.IsMore() )
+    {
+        basegfx::B2DPolyPolygon aPP;
+        const SdrObject* pNext = aIter.Next();
+
+        if ( auto pPathObj = dynamic_cast<const SdrPathObj*>(pNext) )
         {
-            Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() );
-            Point aBottom( aTop.X(), aTop.Y() + 1000 );
-            pObj->NbcMirror( aTop, aBottom );
+            aPP = pPathObj->GetPathPoly();
         }
-        if ( bFlipV )
+        else
         {
-            Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 );
-            Point aRight( aLeft.X() + 1000, aLeft.Y() );
-            pObj->NbcMirror( aLeft, aRight );
+            rtl::Reference<SdrObject> pNewObj = pNext->ConvertToPolyObj( 
false, false );
+            SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pNewObj.get() );
+            if ( pPath )
+                aPP = pPath->GetPathPoly();
         }
 
-        basegfx::B2DPolyPolygon aPolyPolygon;
-        SdrObjListIter aIter( *pObj, SdrIterMode::DeepWithGroups );
-
-        while ( aIter.IsMore() )
-        {
-            basegfx::B2DPolyPolygon aPP;
-            const SdrObject* pNext = aIter.Next();
-
-            if ( auto pPathObj = dynamic_cast<const SdrPathObj*>(pNext) )
-            {
-                aPP = pPathObj->GetPathPoly();
-            }
-            else
-            {
-                rtl::Reference<SdrObject> pNewObj = pNext->ConvertToPolyObj( 
false, false );
-                SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pNewObj.get() );
-                if ( pPath )
-                    aPP = pPath->GetPathPoly();
-            }
-
-            if ( aPP.count() )
-                aPolyPolygon.append(aPP);
-        }
-        pObj.clear();
-        basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( 
aPolyPolygon,
-                                                              
aPolyPolygonBezierCoords );
+        if ( aPP.count() )
+            aPolyPolygon.append(aPP);
     }
+    pObj.clear();
 
-    return aPolyPolygonBezierCoords;
+    return aPolyPolygon;
 }
 
 Sequence< Reference< drawing::XCustomShapeHandle > > SAL_CALL 
EnhancedCustomShapeEngine::getInteraction()
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index e66fc228dc46..6a8680aeddd5 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -541,10 +541,9 @@ basegfx::B2DPolyPolygon 
SdrObjCustomShape::GetLineGeometry( const bool bBezierAl
     rtl::Reference<EnhancedCustomShapeEngine> xCustomShapeEngine( 
GetCustomShapeEngine() );
     if ( xCustomShapeEngine.is() )
     {
-        drawing::PolyPolygonBezierCoords aBezierCoords = 
xCustomShapeEngine->getLineGeometry();
+        aRetval = xCustomShapeEngine->getB2DLineGeometry();
         try
         {
-            aRetval = 
basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon( aBezierCoords );
             if ( !bBezierAllowed && aRetval.areControlPointsUsed())
             {
                 aRetval = basegfx::utils::adaptiveSubdivideByAngle(aRetval);
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index 0596168a4c53..f14474c01cb2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -125,9 +125,9 @@ CPPUNIT_TEST_FIXTURE(Test, 
testTdf134219ContourWrap_glow_rotate)
         CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(1461),
                                      getProperty<sal_Int32>(getShape(1), 
u"LeftMargin"_ustr), 2);
         CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(1302),
-                                     getProperty<sal_Int32>(getShape(1), 
u"RightMargin"_ustr), 1);
+                                     getProperty<sal_Int32>(getShape(1), 
u"RightMargin"_ustr), 2);
         CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(1522),
-                                     getProperty<sal_Int32>(getShape(1), 
u"TopMargin"_ustr), 1);
+                                     getProperty<sal_Int32>(getShape(1), 
u"TopMargin"_ustr), 2);
         CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(1296),
                                      getProperty<sal_Int32>(getShape(1), 
u"BottomMargin"_ustr), 1);
     };

Reply via email to