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 /sw | |
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 'sw')
-rw-r--r-- | sw/source/filter/ww8/ww8graf.cxx | 24 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par2.cxx | 12 |
2 files changed, 5 insertions, 31 deletions
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index b20d5e229cea..35059e45b998 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -1678,26 +1678,10 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject* pSdrObj, rInnerDist.Right()+=nLineThick; rInnerDist.Bottom()+=nLineThick; - const SvxBorderLine *pLine; - if (nullptr != (pLine = aBox.GetLine(SvxBoxItemLine::LEFT))) - { - rInnerDist.Left() -= (pLine->GetScaledWidth()); - } - - if (nullptr != (pLine = aBox.GetLine(SvxBoxItemLine::TOP))) - { - rInnerDist.Top() -= (pLine->GetScaledWidth()); - } - - if (nullptr != (pLine = aBox.GetLine(SvxBoxItemLine::RIGHT))) - { - rInnerDist.Right() -= (pLine->GetScaledWidth()); - } - - if (nullptr != (pLine = aBox.GetLine(SvxBoxItemLine::BOTTOM))) - { - rInnerDist.Bottom() -= (pLine->GetScaledWidth()); - } + rInnerDist.Left() -= aBox.CalcLineWidth( SvxBoxItemLine::LEFT ); + rInnerDist.Top() -= aBox.CalcLineWidth( SvxBoxItemLine::TOP ); + rInnerDist.Right() -= aBox.CalcLineWidth( SvxBoxItemLine::RIGHT ); + rInnerDist.Bottom() -= aBox.CalcLineWidth( SvxBoxItemLine::BOTTOM ); // set distances from box's border to text contained within the box if( 0 < rInnerDist.Left() ) diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 0f9f245aa315..d7375533feb6 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -3231,21 +3231,11 @@ void WW8TabDesc::AdjustNewBand() // we have to mimic this in the filter by picking the larger of the // sides and using that one on one side of the line (right) SvxBoxItem aCurrentBox(sw::util::ItemGet<SvxBoxItem>(*(pBox->GetFrameFormat()), RES_BOX)); - const ::editeng::SvxBorderLine *pLeftLine = aCurrentBox.GetLine(SvxBoxItemLine::LEFT); - int nCurrentRightLineWidth = 0; - if(pLeftLine) - nCurrentRightLineWidth = pLeftLine->GetScaledWidth(); - if (i != 0) { SwTableBox* pBox2 = (*m_pTabBoxes)[i-1]; SvxBoxItem aOldBox(sw::util::ItemGet<SvxBoxItem>(*(pBox2->GetFrameFormat()), RES_BOX)); - const ::editeng::SvxBorderLine *pRightLine = aOldBox.GetLine(SvxBoxItemLine::RIGHT); - int nOldBoxRightLineWidth = 0; - if(pRightLine) - nOldBoxRightLineWidth = pRightLine->GetScaledWidth(); - - if(nOldBoxRightLineWidth>nCurrentRightLineWidth) + if( aOldBox.CalcLineWidth(SvxBoxItemLine::RIGHT) > aCurrentBox.CalcLineWidth(SvxBoxItemLine::LEFT) ) aCurrentBox.SetLine(aOldBox.GetLine(SvxBoxItemLine::RIGHT), SvxBoxItemLine::LEFT); aOldBox.SetLine(nullptr, SvxBoxItemLine::RIGHT); |