Revert "tdf#151968: Fix vertical position of RTL spelling wavy line"

This reverts commit 5899b27e71430e490c2d3a6b87ae52c10f383ba7.

Reason for revert: tdf#155001

Change-Id: I95d21689a50f6413a7b5c126d6eb6b2c8802fbc2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152752
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@libreoffice.org>
(cherry picked from commit 4ceac7d67d3f3e09dc3f4a03b330d779e6a71e4c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152825
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index d4ff7a4..b2053f4 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, Degree10 nOrientation, tools::Long nLineWidth);
    SAL_DLLPRIVATE void         ImplDrawWaveLineBezier(tools::Long nStartX, tools::Long nStartY, tools::Long nEndX, tools::Long nEndY, tools::Long nWaveHeight, double fOrientation, tools::Long nLineWidth);


    /** @name Curved shape functions
diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx
index f88861d..7c0f2f5 100644
--- a/vcl/source/outdev/textline.cxx
+++ b/vcl/source/outdev/textline.cxx
@@ -996,13 +996,14 @@ 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();
    auto nOrientation = mpFontInstance->mnOrientation;
    double fOrientation = 0.0;

    // handle rotation
    if (nOrientation)
    if (nStartY != nEndY || nStartX > nEndX)
    {
        fOrientation = basegfx::rad2deg(std::atan2(nStartY - nEndY, nEndX - nStartX));
        // un-rotate the end point
        aStartPt.RotateAround(nEndX, nEndY, nOrientation);
        aStartPt.RotateAround(nEndX, nEndY, Degree10(static_cast<sal_Int16>(-fOrientation * 10.0)));
    }

    // Handle HiDPI
@@ -1029,9 +1030,7 @@ void OutputDevice::DrawWaveLine(const Point& rStartPos, const Point& rEndPos, to
        nLineWidth = 0;
    }

    // The code below does not work for RTL text, that is what nEndX > nStartX
    // check is for.
    if ( nOrientation == 0_deg10 && nEndX > nStartX )
    if ( fOrientation == 0.0 )
    {
        static vcl::DeleteOnDeinit< WavyLineCache > snLineCache {};
        if ( !snLineCache.get() )
@@ -1050,7 +1049,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, nOrientation, nLineWidth );
            pVirtDev->ImplDrawWaveLineBezier( 0, 0, nWordLength, 0, nWaveHeight, fOrientation, 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
@@ -1071,10 +1070,10 @@ void OutputDevice::DrawWaveLine(const Point& rStartPos, const Point& rEndPos, to
        return;
    }

    ImplDrawWaveLineBezier( nStartX, nStartY, nEndX, nEndY, nWaveHeight, nOrientation, nLineWidth );
    ImplDrawWaveLineBezier( nStartX, nStartY, nEndX, nEndY, nWaveHeight, fOrientation, nLineWidth );
}

void OutputDevice::ImplDrawWaveLineBezier(tools::Long nStartX, tools::Long nStartY, tools::Long nEndX, tools::Long nEndY, tools::Long nWaveHeight, Degree10 nOrientation, tools::Long nLineWidth)
void OutputDevice::ImplDrawWaveLineBezier(tools::Long nStartX, tools::Long nStartY, tools::Long nEndX, tools::Long nEndY, tools::Long nWaveHeight, double fOrientation, tools::Long nLineWidth)
{
    // we need a graphics
    if( !mpGraphics && !AcquireGraphics() )
@@ -1092,7 +1091,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, toRadians(nOrientation));
    const basegfx::B2DHomMatrix aRotationMatrix = basegfx::utils::createRotateAroundPoint(nStartX, nStartY, basegfx::deg2rad(-fOrientation));
    const bool bPixelSnapHairline(mnAntialiasing & AntialiasingFlags::PixelSnapHairline);

    mpGraphics->SetLineColor(GetLineColor());
@@ -1109,7 +1108,7 @@ void OutputDevice::ImplDrawWaveLineBezier(tools::Long nStartX, tools::Long nStar
            *this);

    if( mpAlphaVDev )
        mpAlphaVDev->ImplDrawWaveLineBezier(nStartX, nStartY, nEndX, nEndY, nWaveHeight, nOrientation, nLineWidth);
        mpAlphaVDev->ImplDrawWaveLineBezier(nStartX, nStartY, nEndX, nEndY, nWaveHeight, fOrientation, nLineWidth);
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */