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>
11 #include <vcl/floatwin.hxx>
12 #include <vcl/uitest/uitest.hxx>
13 #include <vcl/uitest/uiobject.hxx>
14 
15 #include <vcl/toolkit/dialog.hxx>
16 
17 #include <svdata.hxx>
18 
20 #include <com/sun/star/beans/PropertyValue.hpp>
21 
22 bool UITest::executeCommand(const OUString& rCommand)
23 {
25  rCommand,
26  {{"SynchronMode", -1, css::uno::Any(true),
27  css::beans::PropertyState_DIRECT_VALUE}});
28 }
29 
30 bool 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.begin(), nIndex));
43  }
44  return comphelper::dispatchCommand(rCommand,lNewArgs);
45 }
46 
47 bool UITest::executeDialog(const OUString& rCommand)
48 {
50  rCommand,
51  {{"SynchronMode", -1, css::uno::Any(false),
52  css::beans::PropertyState_DIRECT_VALUE}});
53 }
54 
55 std::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 
68 std::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: */
sal_Int32 nIndex
virtual FactoryFunction GetUITestFactory() const
Definition: window.cxx:3946
static std::unique_ptr< UIObject > getFloatWindow()
Definition: uitest.cxx:68
static bool executeCommand(const OUString &rCommand)
Definition: uitest.cxx:22
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)
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:75
std::vector< VclPtr< Dialog > > mpExecuteDialogs
Stack of dialogs that are Execute()'d - the last one is the top most one.
Definition: svdata.hxx:252
static std::unique_ptr< UIObject > getFocusTopWindow()
Definition: uitest.cxx:55
ImplSVFrameData maFrameData
Definition: svdata.hxx:395
VclPtr< FloatingWindow > mpFirstFloat
Definition: svdata.hxx:251
VclPtr< vcl::Window > mpFirstFrame
Definition: svdata.hxx:238
static bool executeCommandWithParameters(const OUString &rCommand, const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
Definition: uitest.cxx:30
static bool executeDialog(const OUString &rCommand)
Definition: uitest.cxx:47
ImplSVWinData * mpWinData
Definition: svdata.hxx:396