[Libreoffice-commits] core.git: svx/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 14 15:06:26 UTC 2021


 svx/source/svdraw/svdoashp.cxx |   33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

New commits:
commit 67067c3fd017bd0d5cb91218c4ee4befd0f824ba
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Apr 14 15:04:43 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Apr 14 17:05:50 2021 +0200

    avoid creating an SfxItemSet here
    
    Change-Id: I9bd65c5938c5a500acc026a95de186fdae33e2fe
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114093
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 855d6e0e12ec..409915bc1c8a 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -1376,12 +1376,21 @@ void SdrObjCustomShape::AdaptTextMinSize()
     if (getSdrModelFromSdrObject().IsCreatingDataObj() || getSdrModelFromSdrObject().IsPasteResize())
         return;
 
+    // check if we need to change anything before creating an SfxItemSet, because that is expensive
     const bool bResizeShapeToFitText(GetObjectItem(SDRATTR_TEXT_AUTOGROWHEIGHT).GetValue());
+    tools::Rectangle aTextBound(maRect);
+    bool bChanged(false);
+    if(bResizeShapeToFitText)
+        bChanged = true;
+    else if(GetTextBounds(aTextBound))
+        bChanged = true;
+    if (!bChanged)
+       return;
+
     SfxItemSet aSet(
         *GetObjectItemSet().GetPool(),
         svl::Items<SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT,
         SDRATTR_TEXT_MINFRAMEWIDTH, SDRATTR_TEXT_AUTOGROWWIDTH>{}); // contains SDRATTR_TEXT_MAXFRAMEWIDTH
-    bool bChanged(false);
 
     if(bResizeShapeToFitText)
     {
@@ -1389,28 +1398,20 @@ void SdrObjCustomShape::AdaptTextMinSize()
         // to allow resizing being completely dependent on text size only
         aSet.Put(makeSdrTextMinFrameWidthItem(0));
         aSet.Put(makeSdrTextMinFrameHeightItem(0));
-        bChanged = true;
     }
     else
     {
         // recreate from CustomShape-specific TextBounds
-        tools::Rectangle aTextBound(maRect);
+        const tools::Long nHDist(GetTextLeftDistance() + GetTextRightDistance());
+        const tools::Long nVDist(GetTextUpperDistance() + GetTextLowerDistance());
+        const tools::Long nTWdt(std::max(tools::Long(0), static_cast<tools::Long>(aTextBound.GetWidth() - 1 - nHDist)));
+        const tools::Long nTHgt(std::max(tools::Long(0), static_cast<tools::Long>(aTextBound.GetHeight() - 1 - nVDist)));
 
-        if(GetTextBounds(aTextBound))
-        {
-            const tools::Long nHDist(GetTextLeftDistance() + GetTextRightDistance());
-            const tools::Long nVDist(GetTextUpperDistance() + GetTextLowerDistance());
-            const tools::Long nTWdt(std::max(tools::Long(0), static_cast<tools::Long>(aTextBound.GetWidth() - 1 - nHDist)));
-            const tools::Long nTHgt(std::max(tools::Long(0), static_cast<tools::Long>(aTextBound.GetHeight() - 1 - nVDist)));
-
-            aSet.Put(makeSdrTextMinFrameWidthItem(nTWdt));
-            aSet.Put(makeSdrTextMinFrameHeightItem(nTHgt));
-            bChanged = true;
-        }
+        aSet.Put(makeSdrTextMinFrameWidthItem(nTWdt));
+        aSet.Put(makeSdrTextMinFrameHeightItem(nTHgt));
     }
 
-    if(bChanged)
-        SetObjectItemSet(aSet);
+    SetObjectItemSet(aSet);
 }
 
 void SdrObjCustomShape::NbcSetSnapRect( const tools::Rectangle& rRect )


More information about the Libreoffice-commits mailing list