Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / vcl / source / uitest / uitest.cxx
blob58c58ab3c468f839b6c2580898e0704cae799a0a
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 <memory>
11 #include <vcl/uitest/uitest.hxx>
12 #include <vcl/uitest/uiobject.hxx>
14 #include <vcl/dialog.hxx>
16 #include <svdata.hxx>
18 #include <comphelper/dispatchcommand.hxx>
19 #include <com/sun/star/beans/PropertyValue.hpp>
21 bool UITest::executeCommand(const OUString& rCommand)
23 return comphelper::dispatchCommand(
24 rCommand,
25 {{"SynchronMode", -1, css::uno::Any(true),
26 css::beans::PropertyState_DIRECT_VALUE}});
29 bool UITest::executeCommandWithParameters(const OUString& rCommand,
30 const css::uno::Sequence< css::beans::PropertyValue >& rArgs)
32 css::uno::Sequence< css::beans::PropertyValue > lNewArgs =
33 {{"SynchronMode", -1, css::uno::Any(true),
34 css::beans::PropertyState_DIRECT_VALUE}};
36 if ( rArgs.hasElements() )
38 sal_uInt32 nIndex( lNewArgs.getLength() );
39 lNewArgs.realloc( lNewArgs.getLength()+rArgs.getLength() );
41 std::copy(rArgs.begin(), rArgs.end(), std::next(lNewArgs.begin(), nIndex));
43 return comphelper::dispatchCommand(rCommand,lNewArgs);
46 bool UITest::executeDialog(const OUString& rCommand)
48 return comphelper::dispatchCommand(
49 rCommand,
50 {{"SynchronMode", -1, css::uno::Any(false),
51 css::beans::PropertyState_DIRECT_VALUE}});
54 std::unique_ptr<UIObject> UITest::getFocusTopWindow()
56 ImplSVData* pSVData = ImplGetSVData();
57 ImplSVWinData& rWinData = pSVData->maWinData;
59 if (!rWinData.mpExecuteDialogs.empty())
61 return rWinData.mpExecuteDialogs.back()->GetUITestFactory()(rWinData.mpExecuteDialogs.back());
64 return rWinData.mpFirstFrame->GetUITestFactory()(rWinData.mpFirstFrame);
67 std::unique_ptr<UIObject> UITest::getFloatWindow()
69 ImplSVData* pSVData = ImplGetSVData();
70 ImplSVWinData& rWinData = pSVData->maWinData;
72 VclPtr<vcl::Window> pFloatWin = rWinData.mpFirstFloat;
73 if (pFloatWin)
74 return pFloatWin->GetUITestFactory()(pFloatWin);
76 return nullptr;
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */