diff options
author | Mark Hung <marklh9@gmail.com> | 2018-11-03 13:12:36 +0800 |
---|---|---|
committer | Mark Hung <marklh9@gmail.com> | 2018-11-05 11:38:58 +0100 |
commit | 19e004ed1c26842e68661000ecb568e96ca76a64 (patch) | |
tree | 2c1e8accf19585610963d664ebd3ebbaa3f73543 /cppcanvas/source/mtfrenderer | |
parent | 3c92c347881eee4c63d111fc576c2fb2312f0de7 (diff) |
cppcanvas::mtfrenderer refactor
to get rid of one of the initEffectLinePolyPolygon we used.
Change-Id: I04c6e1dc72e1f3936bfd268a3b1092bdc4a9b199
Reviewed-on: https://gerrit.libreoffice.org/62828
Tested-by: Jenkins
Reviewed-by: Mark Hung <marklh9@gmail.com>
Diffstat (limited to 'cppcanvas/source/mtfrenderer')
-rw-r--r-- | cppcanvas/source/mtfrenderer/textaction.cxx | 61 |
1 files changed, 24 insertions, 37 deletions
diff --git a/cppcanvas/source/mtfrenderer/textaction.cxx b/cppcanvas/source/mtfrenderer/textaction.cxx index 76bccef0ba8a..3784d435b086 100644 --- a/cppcanvas/source/mtfrenderer/textaction.cxx +++ b/cppcanvas/source/mtfrenderer/textaction.cxx @@ -152,14 +152,11 @@ namespace cppcanvas rTextTransform ); } - ::basegfx::B2DPolyPolygon textLinesFromLogicalOffsets( const uno::Sequence< double >& rOffsets, - const tools::TextLineInfo& rTextLineInfo ) - { - return tools::createTextLinesPolyPolygon( - 0.0, - // extract character cell furthest to the right - *(std::max_element( rOffsets.begin(), rOffsets.end() )), - rTextLineInfo ); + void initLayoutWidth(double& rLayoutWidth, const uno::Sequence<double>& rOffsets) + { + ENSURE_OR_THROW(rOffsets.getLength(), + "::cppcanvas::internal::initLayoutWidth(): zero-length array" ); + rLayoutWidth = *(std::max_element(rOffsets.begin(), rOffsets.end())); } uno::Sequence< double > setupDXArray( const long* pCharWidths, @@ -229,7 +226,6 @@ namespace cppcanvas */ void initArrayAction( rendering::RenderState& o_rRenderState, uno::Reference< rendering::XTextLayout >& o_rTextLayout, - double& nLayoutWidth, const ::basegfx::B2DPoint& rStartPoint, const OUString& rText, sal_Int32 nStartPos, @@ -262,8 +258,6 @@ namespace cppcanvas o_rTextLayout->applyLogicalAdvancements( rOffsets ); - const double* pOffsets(rOffsets.getConstArray()); - nLayoutWidth = *std::max_element(pOffsets, pOffsets + rOffsets.getLength()); } double getLineWidth( ::VirtualDevice const & rVDev, @@ -581,24 +575,6 @@ namespace cppcanvas void initEffectLinePolyPolygon( ::basegfx::B2DSize& o_rOverallSize, uno::Reference< rendering::XPolyPolygon2D >& o_rTextLines, const CanvasSharedPtr& rCanvas, - const uno::Sequence< double >& rOffsets, - const tools::TextLineInfo& rLineInfo ) - { - const ::basegfx::B2DPolyPolygon aPoly( - textLinesFromLogicalOffsets( - rOffsets, - rLineInfo ) ); - - o_rOverallSize = ::basegfx::utils::getRange( aPoly ).getRange(); - - o_rTextLines = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon( - rCanvas->getUNOCanvas()->getDevice(), - aPoly ); - } - - void initEffectLinePolyPolygon( ::basegfx::B2DSize& o_rOverallSize, - uno::Reference< rendering::XPolyPolygon2D >& o_rTextLines, - const CanvasSharedPtr& rCanvas, double nLineWidth, const tools::TextLineInfo& rLineInfo ) { @@ -1094,9 +1070,10 @@ namespace cppcanvas mpCanvas( rCanvas ), maState() { + initLayoutWidth(mnLayoutWidth, rOffsets); + initArrayAction( maState, mxTextLayout, - mnLayoutWidth, rStartPoint, rString, nStartPos, @@ -1118,9 +1095,10 @@ namespace cppcanvas mpCanvas( rCanvas ), maState() { + initLayoutWidth(mnLayoutWidth, rOffsets); + initArrayAction( maState, mxTextLayout, - mnLayoutWidth, rStartPoint, rString, nStartPos, @@ -1318,15 +1296,16 @@ namespace cppcanvas maShadowColor( rShadowColor ), maTextFillColor( rTextFillColor ) { + initLayoutWidth(mnLayoutWidth, rOffsets); + initEffectLinePolyPolygon( maLinesOverallSize, mxTextLines, rCanvas, - rOffsets, + mnLayoutWidth, maTextLineInfo ); initArrayAction( maState, mxTextLayout, - mnLayoutWidth, rStartPoint, rText, nStartPos, @@ -1362,15 +1341,16 @@ namespace cppcanvas maShadowColor( rShadowColor ), maTextFillColor( rTextFillColor ) { + initLayoutWidth(mnLayoutWidth, rOffsets); + initEffectLinePolyPolygon( maLinesOverallSize, mxTextLines, rCanvas, - rOffsets, + mnLayoutWidth, maTextLineInfo ); initArrayAction( maState, mxTextLayout, - mnLayoutWidth, rStartPoint, rText, nStartPos, @@ -1723,10 +1703,14 @@ namespace cppcanvas maShadowOffset( rShadowOffset ), maShadowColor( rShadowColor ) { + double nLayoutWidth = 0.0; + + initLayoutWidth(nLayoutWidth, rOffsets); + initEffectLinePolyPolygon( maLinesOverallSize, mxTextLines, rCanvas, - rOffsets, + nLayoutWidth, maTextLineInfo ); init( maState, @@ -1765,10 +1749,13 @@ namespace cppcanvas maShadowOffset( rShadowOffset ), maShadowColor( rShadowColor ) { + double nLayoutWidth = 0.0; + initLayoutWidth(nLayoutWidth, rOffsets); + initEffectLinePolyPolygon( maLinesOverallSize, mxTextLines, rCanvas, - rOffsets, + nLayoutWidth, maTextLineInfo ); init( maState, |