diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-10-14 17:19:56 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-10-22 18:07:29 -0400 |
commit | df3995232349ac5aac14e28d2931b9862b5c047a (patch) | |
tree | 38ceeead61b5a49ff5fc1fc52874cd6882a3128c /svx | |
parent | 96554f0590841bc03e90a15b98e9455d478ee31f (diff) |
Reduce scope level & Annotate the code a bit.
Change-Id: I6ebf849243000920b1c1f7e67d2dc81fcee9e16b
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdotext.cxx | 78 |
1 files changed, 43 insertions, 35 deletions
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 9fa6cb62b248..86893c53b825 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -548,51 +548,59 @@ bool SdrTextObj::NbcSetEckenradius(long nRad) // states of IsAutoGrowWidth/Height to correctly set TextMinFrameWidth/Height void SdrTextObj::AdaptTextMinSize() { - if(bTextFrame && (!pModel || !pModel->IsPasteResize())) - { - const bool bW(IsAutoGrowWidth()); - const bool bH(IsAutoGrowHeight()); + if (!bTextFrame) + // Only do this for text frame. + return; - if(bW || bH) - { - SfxItemSet aSet( - *GetObjectItemSet().GetPool(), - SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT, - SDRATTR_TEXT_MINFRAMEWIDTH, SDRATTR_TEXT_AUTOGROWWIDTH, // contains SDRATTR_TEXT_MAXFRAMEWIDTH - 0, 0); + if (pModel && pModel->IsPasteResize()) + // Don't do this during paste resize. + return; - if(bW) - { - const long nDist(GetTextLeftDistance() + GetTextRightDistance()); - const long nW(std::max(long(0), (long)(aRect.GetWidth() - 1 - nDist))); + const bool bW = IsAutoGrowWidth(); + const bool bH = IsAutoGrowHeight(); - aSet.Put(makeSdrTextMinFrameWidthItem(nW)); + if (!bW && !bH) + // No auto grow requested. Bail out. + return; - if(!IsVerticalWriting() && bDisableAutoWidthOnDragging) - { - bDisableAutoWidthOnDragging = true; - aSet.Put(makeSdrTextAutoGrowWidthItem(false)); - } - } + SfxItemSet aSet( + *GetObjectItemSet().GetPool(), + SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT, + SDRATTR_TEXT_MINFRAMEWIDTH, SDRATTR_TEXT_AUTOGROWWIDTH, // contains SDRATTR_TEXT_MAXFRAMEWIDTH + 0, 0); - if(bH) - { - const long nDist(GetTextUpperDistance() + GetTextLowerDistance()); - const long nH(std::max(long(0), (long)(aRect.GetHeight() - 1 - nDist))); + if(bW) + { + // Set minimum width. + const long nDist = GetTextLeftDistance() + GetTextRightDistance(); + const long nW = std::max<long>(0, aRect.GetWidth() - 1 - nDist); // text width without margins - aSet.Put(makeSdrTextMinFrameHeightItem(nH)); + aSet.Put(makeSdrTextMinFrameWidthItem(nW)); - if(IsVerticalWriting() && bDisableAutoWidthOnDragging) - { - bDisableAutoWidthOnDragging = false; - aSet.Put(makeSdrTextAutoGrowHeightItem(false)); - } - } + if(!IsVerticalWriting() && bDisableAutoWidthOnDragging) + { + bDisableAutoWidthOnDragging = true; + aSet.Put(makeSdrTextAutoGrowWidthItem(false)); + } + } - SetObjectItemSet(aSet); - NbcAdjustTextFrameWidthAndHeight(); + if(bH) + { + // Set Minimum height. + const long nDist = GetTextUpperDistance() + GetTextLowerDistance(); + const long nH = std::max<long>(0, aRect.GetHeight() - 1 - nDist); // text height without margins + + aSet.Put(makeSdrTextMinFrameHeightItem(nH)); + + if(IsVerticalWriting() && bDisableAutoWidthOnDragging) + { + bDisableAutoWidthOnDragging = false; + aSet.Put(makeSdrTextAutoGrowHeightItem(false)); } } + + SetObjectItemSet(aSet); + NbcAdjustTextFrameWidthAndHeight(); } void SdrTextObj::ImpSetContourPolygon( SdrOutliner& rOutliner, Rectangle& rAnchorRect, bool bLineWidth ) const |