Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : */
9 :
10 : #include <unotest/filters-test.hxx>
11 : #include <test/bootstrapfixture.hxx>
12 :
13 : #include <vcl/wrkwin.hxx>
14 :
15 : #include <osl/file.hxx>
16 : #include <osl/process.h>
17 :
18 4 : class VclComplexTextTest : public test::BootstrapFixture
19 : {
20 : public:
21 2 : VclComplexTextTest() : BootstrapFixture(true, false) {}
22 :
23 : /// Play with font measuring etc.
24 : void testArabic();
25 :
26 4 : CPPUNIT_TEST_SUITE(VclComplexTextTest);
27 2 : CPPUNIT_TEST(testArabic);
28 4 : CPPUNIT_TEST_SUITE_END();
29 : };
30 :
31 2 : void VclComplexTextTest::testArabic()
32 : {
33 : #if !defined (LINUX)
34 : return;
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
42 2 : };
43 : OUString aOneTwoThree( (sal_Char *)pOneTwoThreeUTF8,
44 : SAL_N_ELEMENTS( pOneTwoThreeUTF8 ) - 1,
45 2 : RTL_TEXTENCODING_UTF8 );
46 2 : vcl::Window* pWin = new WorkWindow( (vcl::Window *)NULL );
47 2 : CPPUNIT_ASSERT( pWin != NULL );
48 :
49 2 : OutputDevice *pOutDev = static_cast< OutputDevice * >( pWin );
50 :
51 : vcl::Font aFont = OutputDevice::GetDefaultFont(
52 : DEFAULTFONT_CTL_SPREADSHEET,
53 : LANGUAGE_ARABIC_SAUDI_ARABIA,
54 4 : DEFAULTFONT_FLAGS_ONLYONE, 0 );
55 2 : pOutDev->SetFont( aFont );
56 :
57 : // normal orientation
58 2 : Rectangle aInput;
59 2 : Rectangle aRect = pOutDev->GetTextRect( aInput, aOneTwoThree );
60 :
61 : // now rotate 270 degress
62 4 : vcl::Font aRotated( aFont );
63 2 : aRotated.SetOrientation( 2700 );
64 2 : pOutDev->SetFont( aRotated );
65 2 : Rectangle aRectRot = pOutDev->GetTextRect( aInput, aOneTwoThree );
66 :
67 : // Check that we did do the rotation ...
68 : #if 0
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() );
74 : #else
75 2 : (void)aRect; (void)aRectRot;
76 : #endif
77 : #endif
78 2 : }
79 :
80 2 : CPPUNIT_TEST_SUITE_REGISTRATION(VclComplexTextTest);
81 :
82 8 : CPPUNIT_PLUGIN_IMPLEMENT();
83 :
84 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|