diff options
author | Justin Luth <justin_luth@sil.org> | 2016-11-05 15:40:29 +0300 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2016-11-05 20:03:57 +0000 |
commit | a5f8c5f9338e140c8ec3198228917a8a1a54dc35 (patch) | |
tree | d07d84a959a0ce0ba67b774579bc84b7553d954f /editeng/source | |
parent | db380aab1063e8a5e40111c40ee9f7921aa82601 (diff) |
make a useful function - SvxBoxItem::CalcLineWidth
It saves lots of extra code: no separately checking if a line exists,
and then getting the width. Closely matches the existing CalcLineSpace.
sc/source/ui/view/printfun.cxx is another place that could use this
heavily to replace their lcl_LineTotal function. Perhaps something
good for an easyHack. (Wait until LO5.4, since much of the logic
should use CalcLineSpace(,true) instead, and that function probably
will have the default bEvenIfNoLine changed to true. Compiler doesn't
like providing "true" when the default value is also "true".)
Change-Id: I298d057b2bf04959434736f6ab2666d2de4222f9
Reviewed-on: https://gerrit.libreoffice.org/30589
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'editeng/source')
-rw-r--r-- | editeng/source/items/frmitems.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index ffd0caff7814..7de28e36d49d 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -2420,6 +2420,33 @@ void SvxBoxItem::SetDistance( sal_uInt16 nNew, SvxBoxItemLine nLine ) } } +sal_uInt16 SvxBoxItem::CalcLineWidth( SvxBoxItemLine nLine ) const +{ + SvxBorderLine* pTmp = nullptr; + sal_uInt16 nWidth = 0; + switch ( nLine ) + { + case SvxBoxItemLine::TOP: + pTmp = pTop; + break; + case SvxBoxItemLine::BOTTOM: + pTmp = pBottom; + break; + case SvxBoxItemLine::LEFT: + pTmp = pLeft; + break; + case SvxBoxItemLine::RIGHT: + pTmp = pRight; + break; + default: + OSL_FAIL( "wrong line" ); + } + + if( pTmp ) + nWidth = pTmp->GetScaledWidth(); + + return nWidth; +} sal_uInt16 SvxBoxItem::CalcLineSpace( SvxBoxItemLine nLine, bool bEvenIfNoLine ) const { |