LibreOffice Module vcl (master) 1
uitest.cxx
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#include <memory>
12#include <vcl/uitest/uitest.hxx>
14
16
17#include <svdata.hxx>
18
20#include <com/sun/star/beans/PropertyValue.hpp>
21
22bool UITest::executeCommand(const OUString& rCommand)
23{
25 rCommand,
26 {{"SynchronMode", -1, css::uno::Any(true),
27 css::beans::PropertyState_DIRECT_VALUE}});
28}
29
30bool UITest::executeCommandWithParameters(const OUString& rCommand,
31 const css::uno::Sequence< css::beans::PropertyValue >& rArgs)
32{
33 css::uno::Sequence< css::beans::PropertyValue > lNewArgs =
34 {{"SynchronMode", -1, css::uno::Any(true),
35 css::beans::PropertyState_DIRECT_VALUE}};
36
37 if ( rArgs.hasElements() )
38 {
39 sal_uInt32 nIndex( lNewArgs.getLength() );
40 lNewArgs.realloc( lNewArgs.getLength()+rArgs.getLength() );
41
42 std::copy(rArgs.begin(), rArgs.end(), std::next(lNewArgs.getArray(), nIndex));
43 }
44 return comphelper::dispatchCommand(rCommand,lNewArgs);
45}
46
47bool UITest::executeDialog(const OUString& rCommand)
48{
50 rCommand,
51 {{"SynchronMode", -1, css::uno::Any(false),
52 css::beans::PropertyState_DIRECT_VALUE}});
53}
54
55std::unique_ptr<UIObject> UITest::getFocusTopWindow()
56{
57 ImplSVData* pSVData = ImplGetSVData();
58 ImplSVWinData& rWinData = *pSVData->mpWinData;
59
60 if (!rWinData.mpExecuteDialogs.empty())
61 {
62 return rWinData.mpExecuteDialogs.back()->GetUITestFactory()(rWinData.mpExecuteDialogs.back());
63 }
64
66}
67
68std::unique_ptr<UIObject> UITest::getFloatWindow()
69{
70 ImplSVData* pSVData = ImplGetSVData();
71 ImplSVWinData& rWinData = *pSVData->mpWinData;
72
73 VclPtr<vcl::Window> pFloatWin = rWinData.mpFirstFloat;
74 if (pFloatWin)
75 return pFloatWin->GetUITestFactory()(pFloatWin);
76
77 return nullptr;
78}
79
80/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual FactoryFunction GetUITestFactory() const
Definition: window.cxx:3941
sal_Int32 nIndex
std::unique_ptr< UIObject > getFocusTopWindow()
Definition: uitest.cxx:55
bool executeCommand(const OUString &rCommand)
Definition: uitest.cxx:22
std::unique_ptr< UIObject > getFloatWindow()
Definition: uitest.cxx:68
bool executeDialog(const OUString &rCommand)
Definition: uitest.cxx:47
bool executeCommandWithParameters(const OUString &rCommand, const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
Definition: uitest.cxx:30
bool dispatchCommand(const OUString &rCommand, const uno::Reference< css::frame::XFrame > &rFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const uno::Reference< css::frame::XDispatchResultListener > &rListener)
ImplSVFrameData maFrameData
Definition: svdata.hxx:399
ImplSVWinData * mpWinData
Definition: svdata.hxx:400
VclPtr< vcl::Window > mpFirstFrame
Definition: svdata.hxx:241
VclPtr< FloatingWindow > mpFirstFloat
Definition: svdata.hxx:254
std::vector< VclPtr< Dialog > > mpExecuteDialogs
Stack of dialogs that are Execute()'d - the last one is the top most one.
Definition: svdata.hxx:255
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:77