build fix
[LibreOffice.git] / vcl / qa / cppunit / complextext.cxx
blobcb5abbdbb83c9ba2771b0aaf4509166217bc228c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
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
20 public:
21 VclComplexTextTest() : BootstrapFixture(true, false) {}
23 /// Play with font measuring etc.
24 void testArabic();
25 #if defined(_WIN32)
26 void testTdf95650(); // Windows-only issue
27 #endif
29 CPPUNIT_TEST_SUITE(VclComplexTextTest);
30 CPPUNIT_TEST(testArabic);
31 #if defined(_WIN32)
32 CPPUNIT_TEST(testTdf95650);
33 #endif
34 CPPUNIT_TEST_SUITE_END();
37 void VclComplexTextTest::testArabic()
39 #if !defined (LINUX)
40 return;
41 #else // only tested on Linux so far
42 const unsigned char pOneTwoThreeUTF8[] = {
43 0xd9, 0x88, 0xd8, 0xa7, 0xd8, 0xad, 0xd9, 0x90,
44 0xd8, 0xaf, 0xd9, 0x92, 0x20, 0xd8, 0xa5, 0xd8,
45 0xab, 0xd9, 0x8d, 0xd9, 0x86, 0xd9, 0x8a, 0xd9,
46 0x86, 0x20, 0xd8, 0xab, 0xd9, 0x84, 0xd8, 0xa7,
47 0xd8, 0xab, 0xd8, 0xa9, 0xd9, 0x8c, 0x00
49 OUString aOneTwoThree( reinterpret_cast<char const *>(pOneTwoThreeUTF8),
50 SAL_N_ELEMENTS( pOneTwoThreeUTF8 ) - 1,
51 RTL_TEXTENCODING_UTF8 );
52 VclPtr<vcl::Window> pWin = VclPtr<WorkWindow>::Create( static_cast<vcl::Window *>(nullptr) );
53 CPPUNIT_ASSERT( pWin );
55 OutputDevice *pOutDev = static_cast< OutputDevice * >( pWin.get() );
57 vcl::Font aFont = OutputDevice::GetDefaultFont(
58 DefaultFontType::CTL_SPREADSHEET,
59 LANGUAGE_ARABIC_SAUDI_ARABIA,
60 GetDefaultFontFlags::OnlyOne );
61 pOutDev->SetFont( aFont );
63 // normal orientation
64 Rectangle aInput;
65 Rectangle aRect = pOutDev->GetTextRect( aInput, aOneTwoThree );
67 // now rotate 270 degress
68 vcl::Font aRotated( aFont );
69 aRotated.SetOrientation( 2700 );
70 pOutDev->SetFont( aRotated );
71 Rectangle aRectRot = pOutDev->GetTextRect( aInput, aOneTwoThree );
73 // Check that we did do the rotation ...
74 #if 0
75 fprintf( stderr, "%ld %ld %ld %ld\n",
76 aRect.GetWidth(), aRect.GetHeight(),
77 aRectRot.GetWidth(), aRectRot.GetHeight() );
78 CPPUNIT_ASSERT( aRectRot.GetWidth() == aRect.GetHeight() );
79 CPPUNIT_ASSERT( aRectRot.GetHeight() == aRect.GetWidth() );
80 #else
81 (void)aRect; (void)aRectRot;
82 #endif
83 #endif
86 #if defined(_WIN32)
87 void VclComplexTextTest::testTdf95650()
89 const sal_Unicode pTxt[] = {
90 0x0131, 0x0302, 0x0504, 0x4E44, 0x3031, 0x3030, 0x3531, 0x2D30,
91 0x3037, 0x0706, 0x0908, 0x0B0A, 0x0D0C, 0x0F0E, 0x072E, 0x100A,
92 0x0D11, 0x1312, 0x0105, 0x020A, 0x0512, 0x1403, 0x030C, 0x1528,
93 0x2931, 0x632E, 0x7074, 0x0D20, 0x0E0A, 0x100A, 0xF00D, 0x0D20,
94 0x030A, 0x0C0B, 0x20E0, 0x0A0D
96 OUString aTxt(pTxt, SAL_N_ELEMENTS(pTxt) - 1);
97 VclPtr<vcl::Window> pWin = VclPtr<WorkWindow>::Create(static_cast<vcl::Window *>(nullptr));
98 CPPUNIT_ASSERT(pWin);
100 OutputDevice *pOutDev = static_cast< OutputDevice * >(pWin.get());
101 // Check that the following executes without failing assertion
102 pOutDev->ImplLayout(aTxt, 9, 1, Point(), 0, nullptr, SalLayoutFlags::BiDiRtl);
104 #endif
106 CPPUNIT_TEST_SUITE_REGISTRATION(VclComplexTextTest);
108 CPPUNIT_PLUGIN_IMPLEMENT();
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */