vcl/qa/cppunit/complextext.cxx |   14 +++-----------
 vcl/source/outdev/text.cxx     |    8 ++++++++
 2 files changed, 11 insertions(+), 11 deletions(-)

New commits:
commit 4d9e9ff5f4cb199844eb1d2b4000bb837089347f
Author:     Chris Sherlock <chris.sherloc...@gmail.com>
AuthorDate: Thu Jun 30 21:07:26 2022 +1000
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Tue Jul 19 12:59:54 2022 +0200

    vcl: allow OutputDevice::GetTextRect() cater for rotated fonts
    
    Change-Id: I52bdfe75ef1dd7973d14cad72e31a1e559bb7876
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136667
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index a7cf83d4edfd..d6c624fa7406 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -98,27 +98,19 @@ void VclComplexTextTest::testArabic()
     CPPUNIT_ASSERT_DOUBLES_EQUAL(71, aBoundRect.GetWidth(), 2); // This 
sometimes equals to 70
     CPPUNIT_ASSERT_DOUBLES_EQUAL(15, aBoundRect.getOpenHeight(), 1);
 
-#if 0
-    // FIXME: This seems to be wishful thinking, GetTextRect() does not take
-    // rotation into account.
-
     // normal orientation
     tools::Rectangle aInput;
     tools::Rectangle aRect = pOutDev->GetTextRect( aInput, aOneTwoThree );
 
     // now rotate 270 degrees
     vcl::Font aRotated( aFont );
-    aRotated.SetOrientation( 2700 );
+    aRotated.SetOrientation( 2700_deg10 );
     pOutDev->SetFont( aRotated );
     tools::Rectangle aRectRot = pOutDev->GetTextRect( aInput, aOneTwoThree );
 
     // Check that we did do the rotation...
-    fprintf( stderr, "%" SAL_PRIdINT64 " %" SAL_PRIdINT64 " %" SAL_PRIdINT64 " 
%" SAL_PRIdINT64 "\n",
-             sal_Int64(aRect.GetWidth()), sal_Int64(aRect.GetHeight()),
-             sal-Int64(aRectRot.GetWidth()), sal_Int64(aRectRot.GetHeight()) );
-    CPPUNIT_ASSERT( aRectRot.GetWidth() == aRect.GetHeight() );
-    CPPUNIT_ASSERT( aRectRot.GetHeight() == aRect.GetWidth() );
-#endif
+    CPPUNIT_ASSERT_EQUAL( aRectRot.GetWidth(), aRect.GetHeight() );
+    CPPUNIT_ASSERT_EQUAL( aRectRot.GetHeight(), aRect.GetWidth() );
 #endif
 }
 
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index e82d89930b6d..2f7199fa3fa3 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -2042,6 +2042,14 @@ tools::Rectangle OutputDevice::GetTextRect( const 
tools::Rectangle& rRect,
         aRect.AdjustLeft( -1 );
     else
         aRect.AdjustRight( 1 );
+
+    if (maFont.GetOrientation() != 0_deg10)
+    {
+        tools::Polygon aRotatedPolygon(aRect);
+        aRotatedPolygon.Rotate(Point(aRect.GetWidth() / 2, aRect.GetHeight() / 
2), maFont.GetOrientation());
+        return aRotatedPolygon.GetBoundRect();
+    }
+
     return aRect;
 }
 

Reply via email to