svx/inc/EnhancedCustomShapeEngine.hxx                 |    1 
 svx/source/customshapes/EnhancedCustomShapeEngine.cxx |   19 ++++++++++++++++++
 svx/source/svdraw/svdoashp.cxx                        |    6 ++---
 3 files changed, 23 insertions(+), 3 deletions(-)

New commits:
commit b0213f648fa4ed3bb99122aedf9f05dbbe1a2d9f
Author:     Noel Grandin <[email protected]>
AuthorDate: Fri Sep 26 11:20:35 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Sat Sep 27 13:37:33 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: I86ce4e0e72feae5970ea2d99194fbac718262fd7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191533
    Reviewed-by: Noel Grandin <[email protected]>
    Tested-by: Jenkins

diff --git a/svx/inc/EnhancedCustomShapeEngine.hxx 
b/svx/inc/EnhancedCustomShapeEngine.hxx
index 9bedb748ada3..71ed7f02d5b2 100644
--- a/svx/inc/EnhancedCustomShapeEngine.hxx
+++ b/svx/inc/EnhancedCustomShapeEngine.hxx
@@ -52,6 +52,7 @@ public:
     virtual 
css::uno::Sequence<css::uno::Reference<css::drawing::XCustomShapeHandle>>
         SAL_CALL getInteraction() override;
 
+    tools::Rectangle getTextBounds2() const;
     basegfx::B2DPolyPolygon getB2DLineGeometry() const;
 };
 
diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx 
b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
index 65a6787aa8ae..9d5cc59546a1 100644
--- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
@@ -333,6 +333,25 @@ awt::Rectangle SAL_CALL 
EnhancedCustomShapeEngine::getTextBounds()
     return aTextRect;
 }
 
+tools::Rectangle EnhancedCustomShapeEngine::getTextBounds2() const
+{
+    SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape(mxShape);
+    if (!pSdrObj)
+        return tools::Rectangle();
+
+    // the only two subclasses of SdrObject we see here are SdrObjCustomShape 
and SwDrawVirtObj
+    SdrObjCustomShape* pSdrObjCustomShape = dynamic_cast< SdrObjCustomShape* 
>(pSdrObj);
+    if (!pSdrObjCustomShape)
+        return tools::Rectangle();
+
+    uno::Reference< document::XActionLockable > xLockable( mxShape, 
uno::UNO_QUERY );
+    if(!xLockable.is() || xLockable->isActionLocked())
+        return tools::Rectangle();
+
+    EnhancedCustomShape2d aCustomShape2d(*pSdrObjCustomShape);
+    return aCustomShape2d.GetTextRect();
+}
+
 drawing::PolyPolygonBezierCoords SAL_CALL 
EnhancedCustomShapeEngine::getLineGeometry()
 {
     basegfx::B2DPolyPolygon aPolyPolygon = getB2DLineGeometry();
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 6a8680aeddd5..8e793a3551e2 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -526,10 +526,10 @@ bool SdrObjCustomShape::GetTextBounds( tools::Rectangle& 
rTextBound ) const
     rtl::Reference<EnhancedCustomShapeEngine> xCustomShapeEngine( 
GetCustomShapeEngine() );
     if ( xCustomShapeEngine.is() )
     {
-        awt::Rectangle aR( xCustomShapeEngine->getTextBounds() );
-        if ( aR.Width > 1 && aR.Height > 1 )
+        tools::Rectangle aR( xCustomShapeEngine->getTextBounds2() );
+        if ( aR.GetWidth() > 1 && aR.GetHeight() > 1 )
         {
-            rTextBound = tools::Rectangle( Point( aR.X, aR.Y ), Size( 
aR.Width, aR.Height ) );
+            rTextBound = aR;
             bRet = true;
         }
     }

Reply via email to