LibreOffice Module test (master) 1
eventposter.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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#pragma once
11
12#include <test/testdllapi.hxx>
13
14#include <com/sun/star/accessibility/XAccessible.hpp>
15#include <com/sun/star/accessibility/XAccessibleContext.hpp>
16#include <com/sun/star/uno/Reference.hxx>
17
18#include <LibreOfficeKit/LibreOfficeKitEnums.h>
19#include <rtl/ustring.hxx>
20#include <vcl/window.hxx>
21
22namespace test
23{
35{
36public:
38
40 virtual void postKeyEventAsync(int nType, int nCharCode, int nKeyCode) const = 0;
41
43 void postKeyEventAsync(int nCharCode, int nKeyCode) const
44 {
45 postKeyEventAsync(LOK_KEYEVENT_KEYINPUT, nCharCode, nKeyCode);
46 postKeyEventAsync(LOK_KEYEVENT_KEYUP, nCharCode, nKeyCode);
47 }
48
50 virtual void postExtTextEventAsync(int nType, const OUString& rText) const = 0;
51
53 void postExtTextEventAsync(const OUString& rText) const
54 {
55 postExtTextEventAsync(LOK_EXT_TEXTINPUT, rText);
56 postExtTextEventAsync(LOK_EXT_TEXTINPUT_END, rText);
57 }
58};
59
67{
68protected:
70
71public:
73 : mxWindow(nullptr)
74 {
75 }
77 : mxWindow(xWindow)
78 {
79 }
81 : mxWindow(pWindow)
82 {
83 }
84
85 vcl::Window* getWindow() const { return mxWindow; }
86
87 void setWindow(VclPtr<vcl::Window> xWindow) { mxWindow = xWindow; }
88 void setWindow(vcl::Window* pWindow) { mxWindow = pWindow; }
89
90 explicit operator bool() const { return mxWindow && !mxWindow->isDisposed(); }
91 bool operator!() const { return !bool(*this); }
92
95
97 virtual void postKeyEventAsync(int nType, int nCharCode, int nKeyCode) const override;
99 virtual void postExtTextEventAsync(int nType, const OUString& rText) const override;
100};
101
108{
109public:
112 {
113 }
114 AccessibleEventPosterHelper(const css::uno::Reference<css::accessibility::XAccessible> xAcc)
115 {
116 setWindow(xAcc);
117 }
118
128 void setWindow(css::uno::Reference<css::accessibility::XAccessible> xAcc);
129};
130}
131
132/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
Accessibility-specialized helper to send events to a window.
AccessibleEventPosterHelper(const css::uno::Reference< css::accessibility::XAccessible > xAcc)
Base helper class to send events to a window.
Definition: eventposter.hxx:35
void postExtTextEventAsync(const OUString &rText) const
Posts a full text input + commit sequence.
Definition: eventposter.hxx:53
virtual void postExtTextEventAsync(int nType, const OUString &rText) const =0
void postKeyEventAsync(int nCharCode, int nKeyCode) const
Posts a full key down/up cycle.
Definition: eventposter.hxx:43
virtual void postKeyEventAsync(int nType, int nCharCode, int nKeyCode) const =0
Helper to send events to a window.
Definition: eventposter.hxx:67
VclPtr< vcl::Window > mxWindow
Definition: eventposter.hxx:69
EventPosterHelper(vcl::Window *pWindow)
Definition: eventposter.hxx:80
EventPosterHelper(VclPtr< vcl::Window > xWindow)
Definition: eventposter.hxx:76
void setWindow(vcl::Window *pWindow)
Definition: eventposter.hxx:88
void setWindow(VclPtr< vcl::Window > xWindow)
Definition: eventposter.hxx:87
vcl::Window * getWindow() const
Definition: eventposter.hxx:85
#define OOO_DLLPUBLIC_TEST
Definition: testdllapi.hxx:28