LibreOffice Module vcl (master) 1
uiobject.hxx
Go to the documentation of this file.
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#ifndef INCLUDED_VCL_UITEST_UIOBJECT_HXX
11#define INCLUDED_VCL_UITEST_UIOBJECT_HXX
12
13#include <rtl/ustring.hxx>
14#include <map>
15#include <memory>
16
17#include <vcl/vclevent.hxx>
18#include <vcl/vclptr.hxx>
19#include <vcl/dllapi.h>
20#include <vcl/window.hxx>
21
22#include <set>
23
24class Button;
25class CheckBox;
26class ComboBox;
27class Dialog;
28class Edit;
29class IconView;
30class ListBox;
31class RadioButton;
32class TabControl;
33class TabPage;
34class SvTreeListBox;
35class SvTreeListEntry;
36class SpinButton;
37class SpinField;
39class VclExpander;
40class VclDrawingArea;
42class MenuButton;
43class ToolBox;
44namespace vcl { class Window; }
45namespace weld { class CustomWidgetController; }
46
47typedef std::map<OUString, OUString> StringMap;
48
56{
57 UIObject(UIObject const &) = delete;
58 UIObject& operator =(UIObject const &) = delete;
59
60public:
61 UIObject() = default;
62
63 virtual ~UIObject();
64
69 virtual StringMap get_state();
70
75 virtual void execute(const OUString& rAction,
76 const StringMap& rParameters);
77
82 virtual OUString get_type() const;
83
89 virtual std::unique_ptr<UIObject> get_child(const OUString& rID);
90
94 virtual std::set<OUString> get_children() const;
95
102 virtual OUString dumpState() const;
103
110 virtual OUString dumpHierarchy() const;
111
115 virtual OUString get_action(VclEventId nEvent) const;
116};
117
119{
121
122public:
123
124 WindowUIObject(const VclPtr<vcl::Window>& xWindow);
125
126 virtual StringMap get_state() override;
127
128 virtual void execute(const OUString& rAction,
129 const StringMap& rParameters) override;
130
131 virtual OUString get_type() const override;
132
133 virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
134
135 std::unique_ptr<UIObject> get_visible_child(const OUString& rID);
136
137 virtual std::set<OUString> get_children() const override;
138
139 virtual OUString dumpState() const override;
140
141 virtual OUString dumpHierarchy() const override;
142
143 virtual OUString get_action(VclEventId nEvent) const override;
144
145 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
146
147protected:
148
149 virtual OUString get_name() const;
150
151};
152
153// TODO: moggi: what about push buttons?
154class ButtonUIObject final : public WindowUIObject
155{
157public:
158
159 ButtonUIObject(const VclPtr<Button>& xButton);
160 virtual ~ButtonUIObject() override;
161
162 virtual StringMap get_state() override;
163
164 virtual void execute(const OUString& rAction,
165 const StringMap& rParameters) override;
166
167 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
168
169 virtual OUString get_action(VclEventId nEvent) const override;
170
171private:
172
173 virtual OUString get_name() const override;
174};
175
176class DialogUIObject final : public WindowUIObject
177{
179
180public:
181
182 DialogUIObject(const VclPtr<Dialog>& xDialog);
183 virtual ~DialogUIObject() override;
184
185 virtual StringMap get_state() override;
186
187 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
188
189private:
190
191 virtual OUString get_name() const override;
192};
193
195{
197
198public:
199
200 EditUIObject(const VclPtr<Edit>& xEdit);
201 virtual ~EditUIObject() override;
202
203 virtual void execute(const OUString& rAction,
204 const StringMap& rParameters) override;
205
206 virtual StringMap get_state() override;
207
208 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
209
210 virtual OUString get_action(VclEventId nEvent) const override;
211
212protected:
213
214 virtual OUString get_name() const override;
215};
216
218{
220
221public:
222
224 virtual ~MultiLineEditUIObject() override;
225
226 virtual void execute(const OUString& rAction,
227 const StringMap& rParameters) override;
228
229 virtual StringMap get_state() override;
230
231 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
232
233private:
234
235 virtual OUString get_name() const override;
236};
237
239{
241
242public:
243
244 ExpanderUIObject(const VclPtr<VclExpander>& xExpander);
245 virtual ~ExpanderUIObject() override;
246
247 virtual void execute(const OUString& rAction,
248 const StringMap& rParameters) override;
249
250 virtual StringMap get_state() override;
251
252 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
253private:
254
255 virtual OUString get_name() const override;
256};
257
258
259// TODO: moggi: maybe let it inherit from the button case
261{
262private:
264
265public:
266 CheckBoxUIObject(const VclPtr<CheckBox>& xCheckbox);
267 virtual ~CheckBoxUIObject() override;
268
269 virtual void execute(const OUString& rAction,
270 const StringMap& rParameters) override;
271
272 virtual StringMap get_state() override;
273
274 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
275
276 virtual OUString get_action(VclEventId nEvent) const override;
277
278private:
279
280 virtual OUString get_name() const override;
281};
282
284{
285private:
287
288public:
290 virtual ~RadioButtonUIObject() override;
291
292 virtual void execute(const OUString& rAction,
293 const StringMap& rParameters) override;
294
295 virtual StringMap get_state() override;
296
297 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
298
299 virtual OUString get_action(VclEventId nEvent) const override;
300
301private:
302
303 virtual OUString get_name() const override;
304};
305
306class TabPageUIObject final : public WindowUIObject
307{
308private:
310public:
311 TabPageUIObject(const VclPtr<TabPage>& xTabPage);
312 virtual ~TabPageUIObject() override;
313
314 virtual void execute(const OUString& rAction,
315 const StringMap& rParameters) override;
316
317 virtual StringMap get_state() override;
318
319 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
320
321private:
322
323 virtual OUString get_name() const override;
324};
325
326class ListBoxUIObject final : public WindowUIObject
327{
328private:
330
331public:
332
333 ListBoxUIObject(const VclPtr<ListBox>& xListBox);
334 virtual ~ListBoxUIObject() override;
335
336 virtual void execute(const OUString& rAction,
337 const StringMap& rParameters) override;
338
339 virtual StringMap get_state() override;
340
341 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
342
343 virtual OUString get_action(VclEventId nEvent) const override;
344
345private:
346
347 virtual OUString get_name() const override;
348};
349
350// TODO: moggi: should it inherit from EditUIObject?
352{
353private:
355
356public:
357
358 ComboBoxUIObject(const VclPtr<ComboBox>& xListBox);
359 virtual ~ComboBoxUIObject() override;
360
361 virtual void execute(const OUString& rAction,
362 const StringMap& rParameters) override;
363
364 virtual StringMap get_state() override;
365
366 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
367
368 virtual OUString get_action(VclEventId nEvent) const override;
369
370private:
371
372 virtual OUString get_name() const override;
373};
374
375class SpinUIObject final : public WindowUIObject
376{
377private:
379
380public:
381
382 SpinUIObject(const VclPtr<SpinButton>& xSpinButton);
383 virtual ~SpinUIObject() override;
384
385 virtual void execute(const OUString& rAction,
386 const StringMap& rParameters) override;
387
388 virtual StringMap get_state() override;
389
390 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
391
392 virtual OUString get_action(VclEventId nEvent) const override;
393
394private:
395
396 virtual OUString get_name() const override;
397};
398
400{
402
403public:
404
406 virtual ~SpinFieldUIObject() override;
407
408 virtual void execute(const OUString& rAction,
409 const StringMap& rParameters) override;
410
411 virtual StringMap get_state() override;
412
413 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
414
415 virtual OUString get_action(VclEventId nEvent) const override;
416
417private:
418
419 virtual OUString get_name() const override;
420};
421
423{
424private:
426
427public:
428
430 virtual ~TabControlUIObject() override;
431
432 virtual void execute(const OUString& rAction,
433 const StringMap& rParameters) override;
434
435 virtual StringMap get_state() override;
436
437 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
438
439 virtual OUString get_action(VclEventId nEvent) const override;
440
441private:
442
443 virtual OUString get_name() const override;
444};
445
447{
448private:
450
451public:
452
454 virtual ~VerticalTabControlUIObject() override;
455
456 virtual void execute(const OUString& rAction,
457 const StringMap& rParameters) override;
458
459 virtual StringMap get_state() override;
460
461 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
462
463private:
464
465 virtual OUString get_name() const override;
466};
467
469{
470public:
471 TreeListUIObject(const VclPtr<SvTreeListBox>& xTreeList);
472
473 virtual StringMap get_state() override;
474
475 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
476
477 virtual void execute(const OUString& rAction,
478 const StringMap& rParameters) override;
479
480 virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
481
482 virtual std::set<OUString> get_children() const override;
483
484protected:
485
486 virtual OUString get_name() const override;
487
489};
490
491class TreeListEntryUIObject final : public UIObject
492{
493public:
494
496
497 virtual StringMap get_state() override;
498
499 virtual void execute(const OUString& rAction,
500 const StringMap& rParameters) override;
501
502 virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
503
504 virtual std::set<OUString> get_children() const override;
505
506 virtual OUString get_type() const override;
507
508private:
509
511
513};
514
516{
517public:
518 IconViewUIObject(const VclPtr<SvTreeListBox>& xIconView);
519
520 virtual StringMap get_state() override;
521
522 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
523
524private:
525
526 virtual OUString get_name() const override;
527};
528
529class ToolBoxUIObject final : public WindowUIObject
530{
531private:
533
534public:
535
537 virtual ~ToolBoxUIObject() override;
538
539 virtual void execute(const OUString& rAction,
540 const StringMap& rParameters) override;
541
542 virtual StringMap get_state() override;
543
544 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
545
546 virtual OUString get_action(VclEventId nEvent) const override;
547
548private:
549
550 virtual OUString get_name() const override;
551};
552
554{
556
557public:
558
559 MenuButtonUIObject(const VclPtr<MenuButton>& xMenuButton);
560 virtual ~MenuButtonUIObject() override;
561
562 virtual StringMap get_state() override;
563
564 virtual void execute(const OUString& rAction,
565 const StringMap& rParameters) override;
566
567 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
568
569private:
570
571 virtual OUString get_name() const override;
572};
573
575{
576private:
578protected:
580public:
581 DrawingAreaUIObject(const VclPtr<vcl::Window>& rDrawingArea);
582 virtual ~DrawingAreaUIObject() override;
583 virtual void execute(const OUString& rAction, const StringMap& rParameters) override;
584 static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
585};
586
587#endif
588
589/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
virtual OUString get_name() const override
VclPtr< Button > mxButton
Definition: uiobject.hxx:156
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
ButtonUIObject(const VclPtr< Button > &xButton)
virtual ~ButtonUIObject() override
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
virtual ~CheckBoxUIObject() override
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
CheckBoxUIObject(const VclPtr< CheckBox > &xCheckbox)
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
VclPtr< CheckBox > mxCheckBox
Definition: uiobject.hxx:263
virtual OUString get_name() const override
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual OUString get_name() const override
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual ~ComboBoxUIObject() override
VclPtr< ComboBox > mxComboBox
Definition: uiobject.hxx:354
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
ComboBoxUIObject(const VclPtr< ComboBox > &xListBox)
A widget used to choose from a list of items and which has an entry.
Definition: combobox.hxx:39
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
VclPtr< Dialog > mxDialog
Definition: uiobject.hxx:178
virtual OUString get_name() const override
virtual ~DialogUIObject() override
DialogUIObject(const VclPtr< Dialog > &xDialog)
VclPtr< VclDrawingArea > mxDrawingArea
Definition: uiobject.hxx:577
weld::CustomWidgetController * mpController
Definition: uiobject.hxx:579
EditUIObject(const VclPtr< Edit > &xEdit)
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual ~EditUIObject() override
VclPtr< Edit > mxEdit
Definition: uiobject.hxx:196
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
virtual OUString get_name() const override
Definition: edit.hxx:56
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual ~ExpanderUIObject() override
VclPtr< VclExpander > mxExpander
Definition: uiobject.hxx:240
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual OUString get_name() const override
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
ExpanderUIObject(const VclPtr< VclExpander > &xExpander)
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
IconViewUIObject(const VclPtr< SvTreeListBox > &xIconView)
virtual OUString get_name() const override
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual ~ListBoxUIObject() override
virtual OUString get_name() const override
VclPtr< ListBox > mxListBox
Definition: uiobject.hxx:329
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
ListBoxUIObject(const VclPtr< ListBox > &xListBox)
A widget used to choose from a list of items and which has no entry.
Definition: lstbox.hxx:83
MenuButtonUIObject(const VclPtr< MenuButton > &xMenuButton)
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual ~MenuButtonUIObject() override
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual OUString get_name() const override
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
VclPtr< MenuButton > mxMenuButton
Definition: uiobject.hxx:555
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual OUString get_name() const override
MultiLineEditUIObject(const VclPtr< VclMultiLineEdit > &xEdit)
virtual ~MultiLineEditUIObject() override
VclPtr< VclMultiLineEdit > mxEdit
Definition: uiobject.hxx:219
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual ~RadioButtonUIObject() override
VclPtr< RadioButton > mxRadioButton
Definition: uiobject.hxx:286
RadioButtonUIObject(const VclPtr< RadioButton > &xCheckbox)
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
virtual OUString get_name() const override
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
SpinFieldUIObject(const VclPtr< SpinField > &xEdit)
VclPtr< SpinField > mxSpinField
Definition: uiobject.hxx:401
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
virtual OUString get_name() const override
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual ~SpinFieldUIObject() override
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual OUString get_name() const override
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
SpinUIObject(const VclPtr< SpinButton > &xSpinButton)
VclPtr< SpinButton > mxSpinButton
Definition: uiobject.hxx:378
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual ~SpinUIObject() override
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
TabControlUIObject(const VclPtr< TabControl > &mxTabControl)
virtual ~TabControlUIObject() override
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
VclPtr< TabControl > mxTabControl
Definition: uiobject.hxx:425
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual OUString get_name() const override
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual OUString get_name() const override
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
TabPageUIObject(const VclPtr< TabPage > &xTabPage)
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
VclPtr< TabPage > mxTabPage
Definition: uiobject.hxx:309
virtual ~TabPageUIObject() override
ToolBoxUIObject(const VclPtr< ToolBox > &mxToolBox)
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual ~ToolBoxUIObject() override
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual OUString get_name() const override
VclPtr< ToolBox > mxToolBox
Definition: uiobject.hxx:532
A toolbar: contains all those icons, typically below the menu bar.
Definition: toolbox.hxx:74
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual std::set< OUString > get_children() const override
Returns a set containing all descendants of the object.
VclPtr< SvTreeListBox > mxTreeList
Definition: uiobject.hxx:510
SvTreeListEntry *const mpEntry
Definition: uiobject.hxx:512
virtual std::unique_ptr< UIObject > get_child(const OUString &rID) override
Returns the child of the current UIObject with the corresponding id.
virtual OUString get_type() const override
Returns the type of the UIObject.
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
TreeListEntryUIObject(const VclPtr< SvTreeListBox > &xTreeList, SvTreeListEntry *pEntry)
VclPtr< SvTreeListBox > mxTreeList
Definition: uiobject.hxx:488
TreeListUIObject(const VclPtr< SvTreeListBox > &xTreeList)
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual std::set< OUString > get_children() const override
Returns a set containing all descendants of the object.
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual std::unique_ptr< UIObject > get_child(const OUString &rID) override
Returns the child of the current UIObject with the corresponding id.
virtual OUString get_name() const override
This class wraps a UI object like vcl::Window and provides an interface for the UI testing.
Definition: uiobject.hxx:56
UIObject(UIObject const &)=delete
UIObject()=default
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual OUString get_name() const override
VerticalTabControlUIObject(const VclPtr< VerticalTabControl > &mxTabControl)
virtual ~VerticalTabControlUIObject() override
VclPtr< VerticalTabControl > mxTabControl
Definition: uiobject.hxx:449
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
VclPtr< vcl::Window > mxWindow
Definition: uiobject.hxx:120
#define UITEST_DLLPUBLIC
Definition: dllapi.h:36
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
void dumpState(rtl::OStringBuffer &rState)
Definition: svapp.cxx:1705
std::map< OUString, OUString > StringMap
Definition: uiobject.hxx:47
VclEventId
Definition: vclevent.hxx:38
std::map< OUString, OUString > StringMap