1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <unotest/filters-test.hxx>
11 #include <test/bootstrapfixture.hxx>
13 #include <vcl/wrkwin.hxx>
15 #include <osl/file.hxx>
16 #include <osl/process.h>
18 class VclComplexTextTest
: public test::BootstrapFixture
21 VclComplexTextTest() : BootstrapFixture(true, false) {}
23 /// Play with font measuring etc.
26 CPPUNIT_TEST_SUITE(VclComplexTextTest
);
27 CPPUNIT_TEST(testArabic
);
28 CPPUNIT_TEST_SUITE_END();
31 void VclComplexTextTest::testArabic()
35 #else // only tested on Linux so far
36 const unsigned char pOneTwoThreeUTF8
[] = {
37 0xd9, 0x88, 0xd8, 0xa7, 0xd8, 0xad, 0xd9, 0x90,
38 0xd8, 0xaf, 0xd9, 0x92, 0x20, 0xd8, 0xa5, 0xd8,
39 0xab, 0xd9, 0x8d, 0xd9, 0x86, 0xd9, 0x8a, 0xd9,
40 0x86, 0x20, 0xd8, 0xab, 0xd9, 0x84, 0xd8, 0xa7,
41 0xd8, 0xab, 0xd8, 0xa9, 0xd9, 0x8c, 0x00
43 OUString
aOneTwoThree( reinterpret_cast<char const *>(pOneTwoThreeUTF8
),
44 SAL_N_ELEMENTS( pOneTwoThreeUTF8
) - 1,
45 RTL_TEXTENCODING_UTF8
);
46 VclPtr
<vcl::Window
> pWin
= VclPtr
<WorkWindow
>::Create( (vcl::Window
*)nullptr );
47 CPPUNIT_ASSERT( pWin
);
49 OutputDevice
*pOutDev
= static_cast< OutputDevice
* >( pWin
.get() );
51 vcl::Font aFont
= OutputDevice::GetDefaultFont(
52 DefaultFontType::CTL_SPREADSHEET
,
53 LANGUAGE_ARABIC_SAUDI_ARABIA
,
54 GetDefaultFontFlags::OnlyOne
, 0 );
55 pOutDev
->SetFont( aFont
);
59 Rectangle aRect
= pOutDev
->GetTextRect( aInput
, aOneTwoThree
);
61 // now rotate 270 degress
62 vcl::Font
aRotated( aFont
);
63 aRotated
.SetOrientation( 2700 );
64 pOutDev
->SetFont( aRotated
);
65 Rectangle aRectRot
= pOutDev
->GetTextRect( aInput
, aOneTwoThree
);
67 // Check that we did do the rotation ...
69 fprintf( stderr
, "%ld %ld %ld %ld\n",
70 aRect
.GetWidth(), aRect
.GetHeight(),
71 aRectRot
.GetWidth(), aRectRot
.GetHeight() );
72 CPPUNIT_ASSERT( aRectRot
.GetWidth() == aRect
.GetHeight() );
73 CPPUNIT_ASSERT( aRectRot
.GetHeight() == aRect
.GetWidth() );
75 (void)aRect
; (void)aRectRot
;
80 CPPUNIT_TEST_SUITE_REGISTRATION(VclComplexTextTest
);
82 CPPUNIT_PLUGIN_IMPLEMENT();
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */