[Libreoffice-commits] core.git: cppcanvas/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Nov 5 10:39:56 UTC 2018


 cppcanvas/source/mtfrenderer/textaction.cxx |   61 +++++++++++-----------------
 1 file changed, 24 insertions(+), 37 deletions(-)

New commits:
commit 19e004ed1c26842e68661000ecb568e96ca76a64
Author:     Mark Hung <marklh9 at gmail.com>
AuthorDate: Sat Nov 3 13:12:36 2018 +0800
Commit:     Mark Hung <marklh9 at gmail.com>
CommitDate: Mon Nov 5 11:38:58 2018 +0100

    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 at gmail.com>

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,


More information about the Libreoffice-commits mailing list