build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / vcl / source / window / keyevent.cxx
blobf5a7c5b1abe8f87a8d4314655850c1fc48172333
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/awt/KeyEvent.hpp>
21 #include <com/sun/star/awt/KeyModifier.hpp>
22 #include <tools/debug.hxx>
23 #include <vcl/event.hxx>
25 KeyEvent::KeyEvent (const KeyEvent& rKeyEvent) :
26 maKeyCode (rKeyEvent.maKeyCode),
27 mnRepeat (rKeyEvent.mnRepeat),
28 mnCharCode(rKeyEvent.mnCharCode)
31 KeyEvent KeyEvent::LogicalTextDirectionality (TextDirectionality eMode) const
33 KeyEvent aClone(*this);
35 sal_uInt16 nCode = maKeyCode.GetCode();
36 sal_uInt16 nMod = maKeyCode.GetModifier();
38 switch (eMode)
40 case TextDirectionality::RightToLeft_TopToBottom:
41 switch (nCode)
43 case KEY_LEFT: aClone.maKeyCode = vcl::KeyCode(KEY_RIGHT, nMod); break;
44 case KEY_RIGHT: aClone.maKeyCode = vcl::KeyCode(KEY_LEFT, nMod); break;
46 break;
48 case TextDirectionality::TopToBottom_RightToLeft:
49 switch (nCode)
51 case KEY_DOWN: aClone.maKeyCode = vcl::KeyCode(KEY_RIGHT, nMod); break;
52 case KEY_UP: aClone.maKeyCode = vcl::KeyCode(KEY_LEFT, nMod); break;
53 case KEY_LEFT: aClone.maKeyCode = vcl::KeyCode(KEY_DOWN, nMod); break;
54 case KEY_RIGHT: aClone.maKeyCode = vcl::KeyCode(KEY_UP, nMod); break;
56 break;
58 case TextDirectionality::BottomToTop_LeftToRight:
59 switch (nCode)
61 case KEY_DOWN: aClone.maKeyCode = vcl::KeyCode(KEY_LEFT, nMod); break;
62 case KEY_UP: aClone.maKeyCode = vcl::KeyCode(KEY_RIGHT, nMod); break;
63 case KEY_LEFT: aClone.maKeyCode = vcl::KeyCode(KEY_UP, nMod); break;
64 case KEY_RIGHT: aClone.maKeyCode = vcl::KeyCode(KEY_DOWN, nMod); break;
66 break;
68 case TextDirectionality::LeftToRight_TopToBottom:
69 /* do nothing */
70 break;
73 return aClone;
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */