diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-04-14 15:04:43 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-04-14 17:05:50 +0200 |
commit | 67067c3fd017bd0d5cb91218c4ee4befd0f824ba (patch) | |
tree | bf9a2c642a15543e7df81cd22ea851cfb73adfd9 | |
parent | 306f6934ac6f0b012eaecd05bb4abb7c9d341993 (diff) |
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@collabora.co.uk>
-rw-r--r-- | svx/source/svdraw/svdoashp.cxx | 33 |
1 files changed, 17 insertions, 16 deletions
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 ) |