[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - canvas/source

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Thu May 6 02:08:35 UTC 2021


 canvas/source/cairo/cairo_canvashelper.cxx |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

New commits:
commit 51510392e9372a698045bc83b44900cd80a6271c
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Wed May 5 14:20:01 2021 +0200
Commit:     Adolfo Jayme Barrientos <fitojb at ubuntu.com>
CommitDate: Thu May 6 04:08:03 2021 +0200

    scale stroked line properly in cairocanvas
    
    - Line width should be scaled by the scaled vector, not just its X
    component (see VclMetafileProcessor2D::getTransformedLineWidth()).
    - Lenths of dashes should not be scaled by the scaled line width,
    but by the scaling.
    Testcase document sd/qa/unit/data/pptx/tdf134053_dashdot.pptx .
    
    Change-Id: I4116f82e91620f5612f5e4e187468508f683b93e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115147
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
    (cherry picked from commit 3a1d150eb99b5875e6e86117029a72e4c87b0547)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115089
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>

diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx
index 7d4cdba478f4..08066c27537f 100644
--- a/canvas/source/cairo/cairo_canvashelper.cxx
+++ b/canvas/source/cairo/cairo_canvashelper.cxx
@@ -914,10 +914,12 @@ namespace cairocanvas
             useStates( viewState, renderState, true );
 
             cairo_matrix_t aMatrix;
-            double w = strokeAttributes.StrokeWidth, h = 0;
             cairo_get_matrix( mpCairo.get(), &aMatrix );
-            cairo_matrix_transform_distance( &aMatrix, &w, &h );
-            cairo_set_line_width( mpCairo.get(), w );
+            double scaleFactorX = 1;
+            double scaleFactorY = 0;
+            cairo_matrix_transform_distance( &aMatrix, &scaleFactorX, &scaleFactorY );
+            double scaleFactor = basegfx::B2DVector( scaleFactorX, scaleFactorY ).getLength();
+            cairo_set_line_width( mpCairo.get(), strokeAttributes.StrokeWidth * scaleFactor );
 
             cairo_set_miter_limit( mpCairo.get(), strokeAttributes.MiterLimit );
 
@@ -953,14 +955,14 @@ namespace cairocanvas
                     break;
             }
 
-            //tdf#103026 If the w scaling is 0, then all dashes become zero so
+            //tdf#103026 If the scaling is 0, then all dashes become zero so
             //cairo will set the cairo_t status to CAIRO_STATUS_INVALID_DASH
             //and no further drawing will occur
-            if (strokeAttributes.DashArray.hasElements() && w > 0.0)
+            if (strokeAttributes.DashArray.hasElements() && scaleFactor > 0.0)
             {
                 auto aDashArray(comphelper::sequenceToContainer<std::vector<double>>(strokeAttributes.DashArray));
                 for (auto& rDash : aDashArray)
-                    rDash *= w;
+                    rDash *= scaleFactor;
                 cairo_set_dash(mpCairo.get(), aDashArray.data(), aDashArray.size(), 0);
             }
 


More information about the Libreoffice-commits mailing list