include/vcl/outdev.hxx         |    2 +-
 vcl/source/outdev/textline.cxx |   21 +++++++++++----------
 2 files changed, 12 insertions(+), 11 deletions(-)

New commits:
commit 254ea7e592aca39a55205bb91cc255f4aba4d7c9
Author:     خالد حسني <kha...@libreoffice.org>
AuthorDate: Sat Jun 10 17:39:16 2023 +0200
Commit:     خالد حسني <kha...@libreoffice.org>
CommitDate: Sat Jun 10 18:40:05 2023 +0200

    Revert "Revert "tdf#151968: Fix vertical position of RTL spelling wavy 
line""
    
    This reverts commit b78330e8a627f049016aa0a2de354855231bd32a.
    
    Reason for revert: lacks required number of reviewers
    
    Change-Id: I1357a673692f7bfab5664399e6ebd936c8be607f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152824
    Tested-by: Jenkins
    Reviewed-by: خالد حسني <kha...@libreoffice.org>

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index b2053f412b49..d4ff7a457a9a 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -758,7 +758,7 @@ private:
     SAL_DLLPRIVATE void         ImplDrawPolyPolygonWithB2DPolyPolygon(const 
basegfx::B2DPolyPolygon& rB2DPolyPoly);
     ///@}
 
-    SAL_DLLPRIVATE void         ImplDrawWaveLineBezier(tools::Long nStartX, 
tools::Long nStartY, tools::Long nEndX, tools::Long nEndY, tools::Long 
nWaveHeight, double fOrientation, tools::Long nLineWidth);
+    SAL_DLLPRIVATE void         ImplDrawWaveLineBezier(tools::Long nStartX, 
tools::Long nStartY, tools::Long nEndX, tools::Long nEndY, tools::Long 
nWaveHeight, Degree10 nOrientation, tools::Long nLineWidth);
 
 
     /** @name Curved shape functions
diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx
index 7c0f2f55d7ce..f88861d4c2f9 100644
--- a/vcl/source/outdev/textline.cxx
+++ b/vcl/source/outdev/textline.cxx
@@ -996,14 +996,13 @@ void OutputDevice::DrawWaveLine(const Point& rStartPos, 
const Point& rEndPos, to
     tools::Long nStartY = aStartPt.Y();
     tools::Long nEndX = aEndPt.X();
     tools::Long nEndY = aEndPt.Y();
-    double fOrientation = 0.0;
+    auto nOrientation = mpFontInstance->mnOrientation;
 
     // handle rotation
-    if (nStartY != nEndY || nStartX > nEndX)
+    if (nOrientation)
     {
-        fOrientation = basegfx::rad2deg(std::atan2(nStartY - nEndY, nEndX - 
nStartX));
         // un-rotate the end point
-        aStartPt.RotateAround(nEndX, nEndY, 
Degree10(static_cast<sal_Int16>(-fOrientation * 10.0)));
+        aStartPt.RotateAround(nEndX, nEndY, nOrientation);
     }
 
     // Handle HiDPI
@@ -1030,7 +1029,9 @@ void OutputDevice::DrawWaveLine(const Point& rStartPos, 
const Point& rEndPos, to
         nLineWidth = 0;
     }
 
-    if ( fOrientation == 0.0 )
+    // The code below does not work for RTL text, that is what nEndX > nStartX
+    // check is for.
+    if ( nOrientation == 0_deg10 && nEndX > nStartX )
     {
         static vcl::DeleteOnDeinit< WavyLineCache > snLineCache {};
         if ( !snLineCache.get() )
@@ -1049,7 +1050,7 @@ void OutputDevice::DrawWaveLine(const Point& rStartPos, 
const Point& rEndPos, to
             pVirtDev->SetBackground( Wallpaper( COL_TRANSPARENT ) );
             pVirtDev->Erase();
             pVirtDev->SetAntialiasing( AntialiasingFlags::Enable );
-            pVirtDev->ImplDrawWaveLineBezier( 0, 0, nWordLength, 0, 
nWaveHeight, fOrientation, nLineWidth );
+            pVirtDev->ImplDrawWaveLineBezier( 0, 0, nWordLength, 0, 
nWaveHeight, nOrientation, nLineWidth );
             BitmapEx aBitmapEx(pVirtDev->GetBitmapEx(Point(0, 0), 
pVirtDev->GetOutputSize()));
 
             // Ideally we don't need this block, but in the split rgb surface 
+ separate alpha surface
@@ -1070,10 +1071,10 @@ void OutputDevice::DrawWaveLine(const Point& rStartPos, 
const Point& rEndPos, to
         return;
     }
 
-    ImplDrawWaveLineBezier( nStartX, nStartY, nEndX, nEndY, nWaveHeight, 
fOrientation, nLineWidth );
+    ImplDrawWaveLineBezier( nStartX, nStartY, nEndX, nEndY, nWaveHeight, 
nOrientation, nLineWidth );
 }
 
-void OutputDevice::ImplDrawWaveLineBezier(tools::Long nStartX, tools::Long 
nStartY, tools::Long nEndX, tools::Long nEndY, tools::Long nWaveHeight, double 
fOrientation, tools::Long nLineWidth)
+void OutputDevice::ImplDrawWaveLineBezier(tools::Long nStartX, tools::Long 
nStartY, tools::Long nEndX, tools::Long nEndY, tools::Long nWaveHeight, 
Degree10 nOrientation, tools::Long nLineWidth)
 {
     // we need a graphics
     if( !mpGraphics && !AcquireGraphics() )
@@ -1091,7 +1092,7 @@ void OutputDevice::ImplDrawWaveLineBezier(tools::Long 
nStartX, tools::Long nStar
 
     const basegfx::B2DRectangle aWaveLineRectangle(nStartX, nStartY, nEndX, 
nEndY + nWaveHeight);
     const basegfx::B2DPolygon aWaveLinePolygon = 
basegfx::createWaveLinePolygon(aWaveLineRectangle);
-    const basegfx::B2DHomMatrix aRotationMatrix = 
basegfx::utils::createRotateAroundPoint(nStartX, nStartY, 
basegfx::deg2rad(-fOrientation));
+    const basegfx::B2DHomMatrix aRotationMatrix = 
basegfx::utils::createRotateAroundPoint(nStartX, nStartY, 
toRadians(nOrientation));
     const bool bPixelSnapHairline(mnAntialiasing & 
AntialiasingFlags::PixelSnapHairline);
 
     mpGraphics->SetLineColor(GetLineColor());
@@ -1108,7 +1109,7 @@ void OutputDevice::ImplDrawWaveLineBezier(tools::Long 
nStartX, tools::Long nStar
             *this);
 
     if( mpAlphaVDev )
-        mpAlphaVDev->ImplDrawWaveLineBezier(nStartX, nStartY, nEndX, nEndY, 
nWaveHeight, fOrientation, nLineWidth);
+        mpAlphaVDev->ImplDrawWaveLineBezier(nStartX, nStartY, nEndX, nEndY, 
nWaveHeight, nOrientation, nLineWidth);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to