2015-12-09 08:04:30 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2016-03-30 05:27:54 +02:00
|
|
|
#include <vcl/uitest/uiobject.hxx>
|
2015-12-09 08:04:30 +01:00
|
|
|
|
2016-01-09 05:13:47 +01:00
|
|
|
#include <vcl/event.hxx>
|
2016-03-28 18:29:48 +02:00
|
|
|
#include <vcl/tabpage.hxx>
|
2016-01-19 12:28:28 +01:00
|
|
|
#include <vcl/lstbox.hxx>
|
2016-03-28 18:33:30 +02:00
|
|
|
#include <vcl/combobox.hxx>
|
2016-03-28 18:34:44 +02:00
|
|
|
#include <vcl/spin.hxx>
|
2016-03-28 20:58:13 +02:00
|
|
|
#include <vcl/spinfld.hxx>
|
2016-03-29 05:19:13 +02:00
|
|
|
#include <vcl/button.hxx>
|
|
|
|
#include <vcl/dialog.hxx>
|
|
|
|
#include <vcl/edit.hxx>
|
2016-01-09 05:13:47 +01:00
|
|
|
|
2016-05-06 00:42:16 +02:00
|
|
|
#include <comphelper/string.hxx>
|
|
|
|
|
2016-01-12 04:03:13 +01:00
|
|
|
#include <rtl/ustrbuf.hxx>
|
|
|
|
|
2016-01-06 21:39:52 +01:00
|
|
|
#include <iostream>
|
2016-01-09 05:13:47 +01:00
|
|
|
#include <vector>
|
2016-01-06 21:39:52 +01:00
|
|
|
|
2015-12-09 08:04:30 +01:00
|
|
|
UIObject::~UIObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-06 21:39:52 +01:00
|
|
|
StringMap UIObject::get_state()
|
2015-12-09 08:04:30 +01:00
|
|
|
{
|
2016-01-06 21:39:52 +01:00
|
|
|
StringMap aMap;
|
2015-12-09 08:04:30 +01:00
|
|
|
aMap["NotImplemented"] = "NotImplemented";
|
|
|
|
return aMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UIObject::execute(const OUString& /*rAction*/,
|
2016-01-06 21:39:52 +01:00
|
|
|
const StringMap& /*rParameters*/)
|
2015-12-09 08:04:30 +01:00
|
|
|
{
|
|
|
|
// should never be called
|
|
|
|
throw std::exception();
|
|
|
|
}
|
|
|
|
|
2016-04-10 07:02:23 +02:00
|
|
|
OUString UIObject::get_type() const
|
2015-12-09 08:04:30 +01:00
|
|
|
{
|
2016-04-10 07:02:23 +02:00
|
|
|
return OUString("Generic UIObject");
|
2015-12-09 08:04:30 +01:00
|
|
|
}
|
|
|
|
|
2016-01-06 21:39:52 +01:00
|
|
|
std::unique_ptr<UIObject> UIObject::get_child(const OUString&)
|
|
|
|
{
|
|
|
|
return std::unique_ptr<UIObject>();
|
|
|
|
}
|
|
|
|
|
2016-05-11 01:42:39 +02:00
|
|
|
std::set<OUString> UIObject::get_children() const
|
|
|
|
{
|
|
|
|
return std::set<OUString>();
|
|
|
|
}
|
|
|
|
|
2017-02-06 18:09:12 +01:00
|
|
|
OUString UIObject::dumpState() const
|
2016-01-09 02:01:43 +01:00
|
|
|
{
|
2017-02-06 18:09:12 +01:00
|
|
|
return OUString();
|
2016-01-09 02:01:43 +01:00
|
|
|
}
|
|
|
|
|
2017-02-06 18:09:12 +01:00
|
|
|
OUString UIObject::dumpHierarchy() const
|
2016-01-09 02:01:43 +01:00
|
|
|
{
|
2017-02-06 18:09:12 +01:00
|
|
|
return OUString();
|
2016-01-09 02:01:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
bool isDialogWindow(vcl::Window* pWindow)
|
|
|
|
{
|
|
|
|
WindowType nType = pWindow->GetType();
|
2016-01-19 08:32:49 +01:00
|
|
|
// DIALOG to FONTDIALOG
|
2017-02-13 19:08:14 +02:00
|
|
|
if (nType >= WindowType::DIALOG && nType <= WindowType::FONTDIALOG)
|
2016-01-19 08:32:49 +01:00
|
|
|
return true;
|
|
|
|
|
2017-02-13 19:08:14 +02:00
|
|
|
// MESSBOX, INFOBOX, WARNINGBOX, ERRORBOX, QUERYBOX
|
|
|
|
if (nType >= WindowType::MESSBOX && nType <= WindowType::QUERYBOX)
|
2016-01-19 08:32:49 +01:00
|
|
|
return true;
|
|
|
|
|
2017-02-13 19:08:14 +02:00
|
|
|
if (nType == WindowType::TABDIALOG)
|
2016-01-09 02:01:43 +01:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
vcl::Window* get_dialog_parent(vcl::Window* pWindow)
|
|
|
|
{
|
|
|
|
if (isDialogWindow(pWindow))
|
|
|
|
return pWindow;
|
|
|
|
|
|
|
|
vcl::Window* pParent = pWindow->GetParent();
|
|
|
|
if (!pParent)
|
|
|
|
return pWindow;
|
|
|
|
|
|
|
|
return get_dialog_parent(pParent);
|
|
|
|
}
|
|
|
|
|
2016-01-09 05:30:42 +01:00
|
|
|
std::vector<KeyEvent> generate_key_events_from_text(const OUString& rStr)
|
|
|
|
{
|
|
|
|
std::vector<KeyEvent> aEvents;
|
|
|
|
vcl::KeyCode aCode;
|
|
|
|
for (sal_Int32 i = 0, n = rStr.getLength();
|
|
|
|
i != n; ++i)
|
|
|
|
{
|
|
|
|
aEvents.push_back(KeyEvent(rStr[i], aCode));
|
|
|
|
}
|
|
|
|
return aEvents;
|
|
|
|
}
|
|
|
|
|
2016-05-06 00:42:16 +02:00
|
|
|
sal_uInt16 get_key(sal_Unicode cChar, bool& bShift)
|
|
|
|
{
|
|
|
|
bShift = false;
|
|
|
|
if (cChar >= 'a' && cChar <= 'z')
|
|
|
|
return KEY_A + (cChar - 'a');
|
|
|
|
else if (cChar >= 'A' && cChar <= 'Z')
|
|
|
|
{
|
|
|
|
bShift = true;
|
|
|
|
return KEY_A + (cChar - 'A');
|
|
|
|
}
|
|
|
|
else if (cChar >= '0' && cChar <= '9')
|
|
|
|
return KEY_0 + (cChar - 'A');
|
|
|
|
|
|
|
|
return cChar;
|
|
|
|
}
|
|
|
|
|
2016-07-17 17:12:32 +02:00
|
|
|
bool isFunctionKey(const OUString& rStr, sal_uInt16& rKeyCode)
|
|
|
|
{
|
|
|
|
std::map<OUString, sal_uInt16> aFunctionKeyMap = {
|
|
|
|
{"F1", KEY_F1},
|
|
|
|
{"F2", KEY_F2},
|
|
|
|
{"F3", KEY_F3},
|
|
|
|
{"F4", KEY_F4},
|
|
|
|
{"F5", KEY_F5},
|
|
|
|
{"F6", KEY_F6},
|
|
|
|
{"F7", KEY_F7},
|
|
|
|
{"F8", KEY_F8},
|
|
|
|
{"F9", KEY_F9},
|
|
|
|
{"F10", KEY_F10},
|
|
|
|
{"F11", KEY_F11},
|
|
|
|
{"F12", KEY_F12}
|
|
|
|
};
|
|
|
|
|
|
|
|
rKeyCode = 0;
|
|
|
|
auto itr = aFunctionKeyMap.find(rStr);
|
|
|
|
if (itr == aFunctionKeyMap.end())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
rKeyCode = itr->second;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-06 00:42:16 +02:00
|
|
|
std::vector<KeyEvent> generate_key_events_from_keycode(const OUString& rStr)
|
|
|
|
{
|
|
|
|
std::vector<KeyEvent> aEvents;
|
|
|
|
|
2016-05-20 04:58:56 +02:00
|
|
|
std::map<OUString, sal_uInt16> aKeyMap = {
|
|
|
|
{"ESC", KEY_ESCAPE},
|
2016-07-17 17:12:32 +02:00
|
|
|
{"TAB", KEY_TAB},
|
2016-05-20 04:58:56 +02:00
|
|
|
{"DOWN", KEY_DOWN},
|
|
|
|
{"UP", KEY_UP},
|
|
|
|
{"LEFT", KEY_LEFT},
|
|
|
|
{"RIGHT", KEY_RIGHT},
|
|
|
|
{"DELETE", KEY_DELETE},
|
|
|
|
{"INSERT", KEY_INSERT},
|
|
|
|
{"BACKSPACE", KEY_BACKSPACE},
|
|
|
|
{"RETURN", KEY_RETURN},
|
|
|
|
{"HOME", KEY_HOME},
|
|
|
|
{"END", KEY_END},
|
|
|
|
{"PAGEUP", KEY_PAGEUP},
|
|
|
|
{"PAGEDOWN", KEY_PAGEDOWN}
|
|
|
|
};
|
|
|
|
|
2016-05-06 00:42:16 +02:00
|
|
|
// split string along '+'
|
|
|
|
// then translate to keycodes
|
|
|
|
bool bShift = false;
|
|
|
|
bool bMod1 = false;
|
|
|
|
bool bMod2 = false;
|
|
|
|
OUString aRemainingText;
|
|
|
|
|
|
|
|
std::vector<OUString> aTokens = comphelper::string::split(rStr, '+');
|
|
|
|
for (auto itr = aTokens.begin(), itrEnd = aTokens.end(); itr != itrEnd; ++itr)
|
|
|
|
{
|
|
|
|
OUString aToken = itr->trim();
|
|
|
|
if (aToken == "CTRL")
|
|
|
|
{
|
|
|
|
bMod1 = true;
|
|
|
|
}
|
|
|
|
else if (aToken == "SHIFT")
|
|
|
|
{
|
|
|
|
bShift = true;
|
|
|
|
}
|
|
|
|
else if (aToken == "ALT")
|
|
|
|
{
|
|
|
|
bMod2 = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aRemainingText = aToken;
|
|
|
|
}
|
|
|
|
|
2016-07-17 17:12:32 +02:00
|
|
|
sal_uInt16 nFunctionKey = 0;
|
|
|
|
if (isFunctionKey(aRemainingText, nFunctionKey))
|
|
|
|
{
|
|
|
|
vcl::KeyCode aCode(nFunctionKey, bShift, bMod1, bMod2, false);
|
|
|
|
aEvents.push_back(KeyEvent(0, aCode));
|
|
|
|
}
|
|
|
|
else if (aKeyMap.find(aRemainingText) != aKeyMap.end())
|
2016-05-20 04:58:56 +02:00
|
|
|
{
|
|
|
|
sal_uInt16 nKey = aKeyMap[aRemainingText];
|
|
|
|
vcl::KeyCode aCode(nKey, bShift, bMod1, bMod2, false);
|
|
|
|
aEvents.push_back(KeyEvent( 'a', aCode));
|
|
|
|
}
|
|
|
|
else
|
2016-05-06 00:42:16 +02:00
|
|
|
{
|
2016-05-20 04:58:56 +02:00
|
|
|
for (sal_Int32 i = 0; i < aRemainingText.getLength(); ++i)
|
|
|
|
{
|
|
|
|
bool bShiftThroughKey = false;
|
|
|
|
sal_uInt16 nKey = get_key(aRemainingText[i], bShiftThroughKey);
|
|
|
|
vcl::KeyCode aCode(nKey, bShift || bShiftThroughKey, bMod1, bMod2, false);
|
|
|
|
aEvents.push_back(KeyEvent(aRemainingText[i], aCode));
|
|
|
|
}
|
2016-05-06 00:42:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return aEvents;
|
|
|
|
}
|
|
|
|
|
2016-01-12 04:03:13 +01:00
|
|
|
OUString to_string(const Point& rPos)
|
|
|
|
{
|
|
|
|
OUStringBuffer aBuffer;
|
|
|
|
aBuffer.append(OUString::number(rPos.X()));
|
|
|
|
aBuffer.append("x");
|
|
|
|
aBuffer.append(OUString::number(rPos.Y()));
|
|
|
|
|
|
|
|
return aBuffer.makeStringAndClear();
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString to_string(const Size& rSize)
|
|
|
|
{
|
|
|
|
OUStringBuffer aBuffer;
|
|
|
|
aBuffer.append(rSize.Width());
|
|
|
|
aBuffer.append("x");
|
|
|
|
aBuffer.append(rSize.Height());
|
|
|
|
|
|
|
|
return aBuffer.makeStringAndClear();
|
|
|
|
}
|
|
|
|
|
2016-01-09 02:01:43 +01:00
|
|
|
}
|
|
|
|
|
2016-01-06 21:39:52 +01:00
|
|
|
WindowUIObject::WindowUIObject(VclPtr<vcl::Window> xWindow):
|
|
|
|
mxWindow(xWindow)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
StringMap WindowUIObject::get_state()
|
|
|
|
{
|
|
|
|
StringMap aMap;
|
|
|
|
aMap["Visible"] = OUString::boolean(mxWindow->IsVisible());
|
2016-01-09 22:17:29 +01:00
|
|
|
aMap["ReallyVisible"] = OUString::boolean(mxWindow->IsReallyVisible());
|
2016-01-06 21:39:52 +01:00
|
|
|
aMap["Enabled"] = OUString::boolean(mxWindow->IsEnabled());
|
2017-02-13 19:08:14 +02:00
|
|
|
aMap["WindowType"] = OUString::number((sal_uInt16)mxWindow->GetType(), 16);
|
2016-01-12 04:03:13 +01:00
|
|
|
|
|
|
|
Point aPos = mxWindow->GetPosPixel();
|
|
|
|
aMap["RelPosition"] = to_string(aPos);
|
|
|
|
aMap["Size"] = to_string(mxWindow->GetSizePixel());
|
|
|
|
aMap["ID"] = mxWindow->get_id();
|
|
|
|
vcl::Window* pParent = mxWindow->GetParent();
|
|
|
|
if (pParent)
|
2016-01-06 21:39:52 +01:00
|
|
|
aMap["Parent"] = mxWindow->GetParent()->get_id();
|
|
|
|
|
2016-01-12 04:03:13 +01:00
|
|
|
bool bIgnoreAllExceptTop = isDialogWindow(mxWindow.get());
|
|
|
|
while(pParent)
|
|
|
|
{
|
|
|
|
Point aParentPos = pParent->GetPosPixel();
|
|
|
|
if (!bIgnoreAllExceptTop)
|
|
|
|
aPos += aParentPos;
|
|
|
|
|
|
|
|
if (isDialogWindow(pParent))
|
|
|
|
{
|
|
|
|
bIgnoreAllExceptTop = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
pParent = pParent->GetParent();
|
|
|
|
|
|
|
|
if (!pParent && bIgnoreAllExceptTop)
|
|
|
|
aPos += aParentPos;
|
|
|
|
}
|
|
|
|
aMap["AbsPosition"] = to_string(aPos);
|
2016-03-28 18:26:34 +02:00
|
|
|
aMap["Text"] = mxWindow->GetText();
|
|
|
|
aMap["DisplayText"] = mxWindow->GetDisplayText();
|
2016-01-12 04:03:13 +01:00
|
|
|
|
2016-01-06 21:39:52 +01:00
|
|
|
return aMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowUIObject::execute(const OUString& rAction,
|
|
|
|
const StringMap& rParameters)
|
|
|
|
{
|
2016-01-09 05:37:49 +01:00
|
|
|
bool bHandled = true;
|
2016-01-06 21:39:52 +01:00
|
|
|
if (rAction == "SET")
|
|
|
|
{
|
|
|
|
for (auto itr = rParameters.begin(); itr != rParameters.end(); ++itr)
|
|
|
|
{
|
|
|
|
std::cout << itr->first;
|
|
|
|
}
|
|
|
|
}
|
2016-01-09 05:30:42 +01:00
|
|
|
else if (rAction == "TYPE")
|
|
|
|
{
|
2016-03-28 19:07:07 +02:00
|
|
|
auto it = rParameters.find("TEXT");
|
2016-05-06 00:42:16 +02:00
|
|
|
if (it != rParameters.end())
|
2016-03-28 19:01:14 +02:00
|
|
|
{
|
2016-05-06 00:42:16 +02:00
|
|
|
const OUString& rText = it->second;
|
|
|
|
auto aKeyEvents = generate_key_events_from_text(rText);
|
|
|
|
for (auto itr = aKeyEvents.begin(), itrEnd = aKeyEvents.end();
|
|
|
|
itr != itrEnd; ++itr)
|
|
|
|
{
|
|
|
|
mxWindow->KeyInput(*itr);
|
|
|
|
}
|
2016-03-28 19:01:14 +02:00
|
|
|
}
|
2016-05-06 00:42:16 +02:00
|
|
|
else if (rParameters.find("KEYCODE") != rParameters.end())
|
2016-01-09 05:30:42 +01:00
|
|
|
{
|
2016-05-06 00:42:16 +02:00
|
|
|
auto itr = rParameters.find("KEYCODE");
|
|
|
|
const OUString rText = itr->second;
|
|
|
|
auto aKeyEvents = generate_key_events_from_keycode(rText);
|
|
|
|
for (auto itrKey = aKeyEvents.begin(), itrKeyEnd = aKeyEvents.end();
|
|
|
|
itrKey != itrKeyEnd; ++itrKey)
|
|
|
|
{
|
|
|
|
mxWindow->KeyInput(*itrKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SAL_WARN("vcl.uitest", "missing parameter TEXT to action TYPE");
|
|
|
|
return;
|
2016-01-09 05:30:42 +01:00
|
|
|
}
|
|
|
|
}
|
2016-01-09 05:37:49 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
bHandled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bHandled)
|
|
|
|
{
|
2016-09-10 12:51:15 +02:00
|
|
|
SAL_WARN("vcl.uitest", "unknown action or parameter for " << get_name() << ". Action: " << rAction);
|
2016-01-09 05:37:49 +01:00
|
|
|
}
|
2016-01-06 21:39:52 +01:00
|
|
|
}
|
|
|
|
|
2016-04-10 07:02:23 +02:00
|
|
|
OUString WindowUIObject::get_type() const
|
2016-01-06 21:39:52 +01:00
|
|
|
{
|
2016-04-10 07:02:23 +02:00
|
|
|
return get_name();
|
2016-01-06 21:39:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
vcl::Window* findChild(vcl::Window* pParent, const OUString& rID)
|
|
|
|
{
|
|
|
|
if (!pParent)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
size_t nCount = pParent->GetChildCount();
|
|
|
|
for (size_t i = 0; i < nCount; ++i)
|
|
|
|
{
|
|
|
|
vcl::Window* pChild = pParent->GetChild(i);
|
|
|
|
if (pChild && pChild->get_id() == rID)
|
|
|
|
return pChild;
|
|
|
|
|
|
|
|
vcl::Window* pResult = findChild(pChild, rID);
|
|
|
|
if (pResult)
|
|
|
|
return pResult;
|
|
|
|
}
|
2016-01-07 01:34:23 +01:00
|
|
|
|
|
|
|
return nullptr;
|
2016-01-06 21:39:52 +01:00
|
|
|
}
|
|
|
|
|
2016-05-11 01:42:39 +02:00
|
|
|
void addChildren(vcl::Window* pParent, std::set<OUString>& rChildren)
|
|
|
|
{
|
|
|
|
if (!pParent)
|
|
|
|
return;
|
|
|
|
|
|
|
|
size_t nCount = pParent->GetChildCount();
|
|
|
|
for (size_t i = 0; i < nCount; ++i)
|
|
|
|
{
|
|
|
|
vcl::Window* pChild = pParent->GetChild(i);
|
|
|
|
if (pChild)
|
|
|
|
{
|
|
|
|
OUString aId = pChild->get_id();
|
|
|
|
if (!aId.isEmpty())
|
|
|
|
{
|
|
|
|
auto ret = rChildren.insert(aId);
|
|
|
|
SAL_WARN_IF(!ret.second, "vcl.uitest", "duplicate ids for ui elements. violates locally unique requirement");
|
|
|
|
}
|
|
|
|
|
|
|
|
addChildren(pChild, rChildren);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-06 21:39:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<UIObject> WindowUIObject::get_child(const OUString& rID)
|
|
|
|
{
|
2016-01-09 02:01:43 +01:00
|
|
|
vcl::Window* pDialogParent = get_dialog_parent(mxWindow.get());
|
|
|
|
vcl::Window* pWindow = findChild(pDialogParent, rID);
|
2016-01-06 21:39:52 +01:00
|
|
|
|
2016-07-09 14:45:41 +02:00
|
|
|
if (!pWindow)
|
|
|
|
throw css::uno::RuntimeException("Could not find child with id: " + rID);
|
|
|
|
|
2016-03-30 05:14:50 +02:00
|
|
|
FactoryFunction aFunction = pWindow->GetUITestFactory();
|
|
|
|
return aFunction(pWindow);
|
2016-01-09 02:01:43 +01:00
|
|
|
}
|
2016-01-07 01:34:23 +01:00
|
|
|
|
2016-05-11 01:42:39 +02:00
|
|
|
std::set<OUString> WindowUIObject::get_children() const
|
|
|
|
{
|
|
|
|
vcl::Window* pDialogParent = get_dialog_parent(mxWindow.get());
|
|
|
|
std::set<OUString> aChildren;
|
|
|
|
aChildren.insert(pDialogParent->get_id());
|
|
|
|
addChildren(pDialogParent, aChildren);
|
|
|
|
return aChildren;
|
|
|
|
}
|
|
|
|
|
2016-01-09 02:01:43 +01:00
|
|
|
OUString WindowUIObject::get_name() const
|
|
|
|
{
|
|
|
|
return OUString("WindowUIObject");
|
|
|
|
}
|
|
|
|
|
2017-02-06 18:09:12 +01:00
|
|
|
OUString WindowUIObject::dumpState() const
|
2016-01-09 02:01:43 +01:00
|
|
|
{
|
2017-02-06 18:09:12 +01:00
|
|
|
OUStringBuffer aStateString = "{\"name\":\"" + mxWindow->get_id() + "\"";
|
|
|
|
aStateString.append(", \"ImplementationName\":\"").appendAscii(typeid(*mxWindow.get()).name()).append("\"");
|
2016-01-09 02:01:43 +01:00
|
|
|
StringMap aState = const_cast<WindowUIObject*>(this)->get_state();
|
|
|
|
for (auto itr = aState.begin(), itrEnd = aState.end(); itr != itrEnd; ++itr)
|
|
|
|
{
|
2017-02-06 18:09:12 +01:00
|
|
|
OUString property = ",\"" + itr->first + "\":\"" + itr->second + "\"";
|
|
|
|
aStateString.append(property);
|
2016-01-09 02:01:43 +01:00
|
|
|
}
|
2017-02-06 18:09:12 +01:00
|
|
|
|
2016-01-09 02:01:43 +01:00
|
|
|
size_t nCount = mxWindow->GetChildCount();
|
2017-02-06 18:09:12 +01:00
|
|
|
|
2016-01-09 02:01:43 +01:00
|
|
|
if (nCount)
|
2017-02-06 18:09:12 +01:00
|
|
|
aStateString.append(",\"children\":[");
|
2016-01-09 02:01:43 +01:00
|
|
|
|
|
|
|
for (size_t i = 0; i < nCount; ++i)
|
|
|
|
{
|
2017-02-06 18:09:12 +01:00
|
|
|
if (i != 0)
|
|
|
|
{
|
|
|
|
aStateString.append(",");
|
|
|
|
}
|
2016-01-09 02:01:43 +01:00
|
|
|
vcl::Window* pChild = mxWindow->GetChild(i);
|
|
|
|
std::unique_ptr<UIObject> pChildWrapper =
|
2016-03-30 05:14:50 +02:00
|
|
|
pChild->GetUITestFactory()(pChild);
|
2017-02-06 18:09:12 +01:00
|
|
|
OUString children = pChildWrapper->dumpState();
|
|
|
|
aStateString.append(children);
|
2016-01-09 02:01:43 +01:00
|
|
|
}
|
2017-02-06 18:09:12 +01:00
|
|
|
|
|
|
|
if (nCount)
|
|
|
|
aStateString.append("]");
|
|
|
|
|
|
|
|
aStateString.append("}");
|
|
|
|
|
|
|
|
OUString aString = aStateString.makeStringAndClear();
|
|
|
|
return aString.replaceAll("\n", "\\n");
|
2016-01-09 02:01:43 +01:00
|
|
|
}
|
|
|
|
|
2017-02-06 18:09:12 +01:00
|
|
|
OUString WindowUIObject::dumpHierarchy() const
|
2016-01-09 02:01:43 +01:00
|
|
|
{
|
|
|
|
vcl::Window* pDialogParent = get_dialog_parent(mxWindow.get());
|
|
|
|
std::unique_ptr<UIObject> pParentWrapper =
|
2016-03-30 05:14:50 +02:00
|
|
|
pDialogParent->GetUITestFactory()(pDialogParent);
|
2017-02-06 18:09:12 +01:00
|
|
|
return pParentWrapper->dumpState();
|
2016-01-09 02:01:43 +01:00
|
|
|
}
|
|
|
|
|
2016-03-30 05:14:50 +02:00
|
|
|
std::unique_ptr<UIObject> WindowUIObject::create(vcl::Window* pWindow)
|
|
|
|
{
|
|
|
|
return std::unique_ptr<UIObject>(new WindowUIObject(pWindow));
|
|
|
|
}
|
|
|
|
|
2016-01-09 02:01:43 +01:00
|
|
|
ButtonUIObject::ButtonUIObject(VclPtr<Button> xButton):
|
|
|
|
WindowUIObject(xButton),
|
|
|
|
mxButton(xButton)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-30 05:27:54 +02:00
|
|
|
ButtonUIObject::~ButtonUIObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-09 02:01:43 +01:00
|
|
|
StringMap ButtonUIObject::get_state()
|
|
|
|
{
|
|
|
|
StringMap aMap = WindowUIObject::get_state();
|
|
|
|
// Move that to a Contrl base class
|
|
|
|
aMap["Label"] = mxButton->GetDisplayText();
|
|
|
|
|
|
|
|
return aMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ButtonUIObject::execute(const OUString& rAction,
|
|
|
|
const StringMap& rParameters)
|
|
|
|
{
|
|
|
|
if (rAction == "CLICK")
|
|
|
|
mxButton->Click();
|
|
|
|
else
|
|
|
|
WindowUIObject::execute(rAction, rParameters);
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString ButtonUIObject::get_name() const
|
|
|
|
{
|
|
|
|
return OUString("ButtonUIObject");
|
|
|
|
}
|
|
|
|
|
2016-03-30 05:14:50 +02:00
|
|
|
std::unique_ptr<UIObject> ButtonUIObject::create(vcl::Window* pWindow)
|
|
|
|
{
|
|
|
|
Button* pButton = dynamic_cast<Button*>(pWindow);
|
|
|
|
assert(pButton);
|
|
|
|
return std::unique_ptr<UIObject>(new ButtonUIObject(pButton));
|
|
|
|
}
|
|
|
|
|
2016-01-09 02:01:43 +01:00
|
|
|
DialogUIObject::DialogUIObject(VclPtr<Dialog> xDialog):
|
|
|
|
WindowUIObject(xDialog),
|
|
|
|
mxDialog(xDialog)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-30 05:27:54 +02:00
|
|
|
DialogUIObject::~DialogUIObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-09 02:01:43 +01:00
|
|
|
StringMap DialogUIObject::get_state()
|
|
|
|
{
|
|
|
|
StringMap aMap = WindowUIObject::get_state();
|
|
|
|
aMap["Modal"] = OUString::boolean(mxDialog->IsModalInputMode());
|
|
|
|
|
|
|
|
return aMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString DialogUIObject::get_name() const
|
|
|
|
{
|
|
|
|
return OUString("DialogUIObject");
|
|
|
|
}
|
|
|
|
|
2016-03-30 05:14:50 +02:00
|
|
|
std::unique_ptr<UIObject> DialogUIObject::create(vcl::Window* pWindow)
|
|
|
|
{
|
|
|
|
Dialog* pDialog = dynamic_cast<Dialog*>(pWindow);
|
|
|
|
assert(pDialog);
|
|
|
|
return std::unique_ptr<UIObject>(new DialogUIObject(pDialog));
|
|
|
|
}
|
|
|
|
|
2016-01-09 04:56:47 +01:00
|
|
|
EditUIObject::EditUIObject(VclPtr<Edit> xEdit):
|
|
|
|
WindowUIObject(xEdit),
|
|
|
|
mxEdit(xEdit)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-30 05:27:54 +02:00
|
|
|
EditUIObject::~EditUIObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-09 04:56:47 +01:00
|
|
|
void EditUIObject::execute(const OUString& rAction,
|
|
|
|
const StringMap& rParameters)
|
|
|
|
{
|
2016-11-13 19:13:36 +01:00
|
|
|
bool bHandled = true;
|
2016-01-09 04:56:47 +01:00
|
|
|
if (rAction == "SET")
|
|
|
|
{
|
|
|
|
if (rParameters.find("TEXT") != rParameters.end())
|
|
|
|
{
|
2016-03-28 19:07:07 +02:00
|
|
|
auto it = rParameters.find("TEXT");
|
|
|
|
if (it == rParameters.end())
|
2016-03-28 19:01:14 +02:00
|
|
|
{
|
|
|
|
SAL_WARN("vcl.uitest", "missing parameter TEXT to action SET");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-28 19:07:07 +02:00
|
|
|
const OUString& rText = it->second;
|
2016-01-09 05:13:47 +01:00
|
|
|
auto aKeyEvents = generate_key_events_from_text(rText);
|
|
|
|
for (auto itr = aKeyEvents.begin(), itrEnd = aKeyEvents.end();
|
|
|
|
itr != itrEnd; ++itr)
|
|
|
|
{
|
|
|
|
mxEdit->KeyInput(*itr);
|
|
|
|
}
|
2016-01-09 04:56:47 +01:00
|
|
|
}
|
|
|
|
else if (rParameters.find("SELECTION") != rParameters.end())
|
|
|
|
{
|
|
|
|
// TODO: moggi: add code
|
|
|
|
}
|
|
|
|
else
|
2016-01-09 05:37:49 +01:00
|
|
|
{
|
|
|
|
bHandled = false;
|
|
|
|
}
|
2016-01-09 04:56:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-01-09 05:37:49 +01:00
|
|
|
bHandled = false;
|
2016-01-09 04:56:47 +01:00
|
|
|
}
|
2016-01-09 05:37:49 +01:00
|
|
|
|
|
|
|
if (!bHandled)
|
|
|
|
WindowUIObject::execute(rAction, rParameters);
|
2016-01-09 04:56:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
StringMap EditUIObject::get_state()
|
|
|
|
{
|
|
|
|
StringMap aMap = WindowUIObject::get_state();
|
|
|
|
aMap["MaxTextLength"] = OUString::number(mxEdit->GetMaxTextLen());
|
|
|
|
aMap["SelectedText"] = mxEdit->GetSelected();
|
|
|
|
aMap["Text"] = mxEdit->GetText();
|
|
|
|
|
|
|
|
return aMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString EditUIObject::get_name() const
|
|
|
|
{
|
|
|
|
return OUString("EditUIObject");
|
|
|
|
}
|
|
|
|
|
2016-03-30 05:14:50 +02:00
|
|
|
std::unique_ptr<UIObject> EditUIObject::create(vcl::Window* pWindow)
|
|
|
|
{
|
|
|
|
Edit* pEdit = dynamic_cast<Edit*>(pWindow);
|
|
|
|
assert(pEdit);
|
|
|
|
return std::unique_ptr<UIObject>(new EditUIObject(pEdit));
|
|
|
|
}
|
|
|
|
|
2016-01-19 08:31:54 +01:00
|
|
|
CheckBoxUIObject::CheckBoxUIObject(VclPtr<CheckBox> xCheckbox):
|
|
|
|
WindowUIObject(xCheckbox),
|
|
|
|
mxCheckBox(xCheckbox)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-30 05:27:54 +02:00
|
|
|
CheckBoxUIObject::~CheckBoxUIObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-19 08:31:54 +01:00
|
|
|
void CheckBoxUIObject::execute(const OUString& rAction,
|
|
|
|
const StringMap& /*rParameters*/)
|
|
|
|
{
|
|
|
|
if (rAction == "CLICK")
|
|
|
|
{
|
|
|
|
// don't use toggle directly, it does not set the value
|
|
|
|
mxCheckBox->ImplCheck();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StringMap CheckBoxUIObject::get_state()
|
|
|
|
{
|
|
|
|
StringMap aMap = WindowUIObject::get_state();
|
|
|
|
aMap["Selected"] = OUString::boolean(mxCheckBox->IsChecked());
|
|
|
|
aMap["TriStateEnabled"] = OUString::boolean(mxCheckBox->IsTriStateEnabled());
|
|
|
|
return aMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString CheckBoxUIObject::get_name() const
|
|
|
|
{
|
|
|
|
return OUString("CheckBoxUIObject");
|
|
|
|
}
|
|
|
|
|
2016-03-30 05:14:50 +02:00
|
|
|
std::unique_ptr<UIObject> CheckBoxUIObject::create(vcl::Window* pWindow)
|
|
|
|
{
|
|
|
|
CheckBox* pCheckBox = dynamic_cast<CheckBox*>(pWindow);
|
|
|
|
assert(pCheckBox);
|
|
|
|
return std::unique_ptr<UIObject>(new CheckBoxUIObject(pCheckBox));
|
|
|
|
}
|
|
|
|
|
2016-05-19 03:36:18 +02:00
|
|
|
RadioButtonUIObject::RadioButtonUIObject(VclPtr<RadioButton> xRadioButton):
|
|
|
|
WindowUIObject(xRadioButton),
|
|
|
|
mxRadioButton(xRadioButton)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
RadioButtonUIObject::~RadioButtonUIObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void RadioButtonUIObject::execute(const OUString& rAction,
|
|
|
|
const StringMap& /*rParameters*/)
|
|
|
|
{
|
|
|
|
if (rAction == "CLICK")
|
|
|
|
{
|
|
|
|
mxRadioButton->ImplCallClick();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StringMap RadioButtonUIObject::get_state()
|
|
|
|
{
|
|
|
|
StringMap aMap = WindowUIObject::get_state();
|
|
|
|
|
|
|
|
return aMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString RadioButtonUIObject::get_name() const
|
|
|
|
{
|
|
|
|
return OUString("RadioButtonUIObject");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<UIObject> RadioButtonUIObject::create(vcl::Window* pWindow)
|
|
|
|
{
|
|
|
|
RadioButton* pRadioButton = dynamic_cast<RadioButton*>(pWindow);
|
|
|
|
assert(pRadioButton);
|
|
|
|
return std::unique_ptr<UIObject>(new RadioButtonUIObject(pRadioButton));
|
|
|
|
}
|
|
|
|
|
2016-03-28 18:29:48 +02:00
|
|
|
TabPageUIObject::TabPageUIObject(VclPtr<TabPage> xTabPage):
|
|
|
|
WindowUIObject(xTabPage),
|
|
|
|
mxTabPage(xTabPage)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-30 05:27:54 +02:00
|
|
|
TabPageUIObject::~TabPageUIObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-28 18:29:48 +02:00
|
|
|
void TabPageUIObject::execute(const OUString& rAction,
|
2016-03-28 19:07:07 +02:00
|
|
|
const StringMap& /*rParameters*/)
|
2016-03-28 18:29:48 +02:00
|
|
|
{
|
2016-03-28 19:07:07 +02:00
|
|
|
if (rAction == "SELECT")
|
|
|
|
{
|
2016-03-28 18:29:48 +02:00
|
|
|
|
2016-03-28 19:07:07 +02:00
|
|
|
}
|
2016-03-28 18:29:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
StringMap TabPageUIObject::get_state()
|
|
|
|
{
|
|
|
|
StringMap aMap = WindowUIObject::get_state();
|
|
|
|
|
|
|
|
return aMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString TabPageUIObject::get_name() const
|
|
|
|
{
|
|
|
|
return OUString("TabPageUIObject");
|
|
|
|
}
|
|
|
|
|
2016-01-19 12:28:28 +01:00
|
|
|
ListBoxUIObject::ListBoxUIObject(VclPtr<ListBox> xListBox):
|
|
|
|
WindowUIObject(xListBox),
|
|
|
|
mxListBox(xListBox)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-30 05:27:54 +02:00
|
|
|
ListBoxUIObject::~ListBoxUIObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-19 12:28:28 +01:00
|
|
|
void ListBoxUIObject::execute(const OUString& rAction,
|
|
|
|
const StringMap& rParameters)
|
|
|
|
{
|
2016-03-28 18:30:57 +02:00
|
|
|
if (!mxListBox->IsEnabled() || !mxListBox->IsReallyVisible())
|
|
|
|
return;
|
|
|
|
|
2016-01-19 12:28:28 +01:00
|
|
|
if (rAction == "SELECT")
|
|
|
|
{
|
|
|
|
bool bSelect = true;
|
|
|
|
if (rParameters.find("POS") != rParameters.end())
|
|
|
|
{
|
|
|
|
auto itr = rParameters.find("POS");
|
|
|
|
OUString aVal = itr->second;
|
|
|
|
sal_Int32 nPos = aVal.toInt32();
|
|
|
|
mxListBox->SelectEntryPos(nPos, bSelect);
|
|
|
|
}
|
|
|
|
else if (rParameters.find("TEXT") != rParameters.end())
|
|
|
|
{
|
|
|
|
auto itr = rParameters.find("TEXT");
|
|
|
|
OUString aText = itr->second;
|
|
|
|
mxListBox->SelectEntry(aText, bSelect);
|
|
|
|
}
|
|
|
|
mxListBox->Select();
|
|
|
|
}
|
2016-12-21 14:35:20 +01:00
|
|
|
else
|
|
|
|
WindowUIObject::execute(rAction, rParameters);
|
2016-01-19 12:28:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
StringMap ListBoxUIObject::get_state()
|
|
|
|
{
|
|
|
|
StringMap aMap = WindowUIObject::get_state();
|
|
|
|
aMap["ReadOnly"] = OUString::boolean(mxListBox->IsReadOnly());
|
|
|
|
aMap["MultiSelect"] = OUString::boolean(mxListBox->IsMultiSelectionEnabled());
|
2016-03-28 18:27:00 +02:00
|
|
|
aMap["EntryCount"] = OUString::number(mxListBox->GetEntryCount());
|
|
|
|
aMap["SelectEntryCount"] = OUString::number(mxListBox->GetSelectEntryCount());
|
2016-07-17 00:53:17 +02:00
|
|
|
aMap["SelectEntryPos"] = OUString::number(mxListBox->GetSelectEntryPos());
|
|
|
|
aMap["SelectEntryText"] = mxListBox->GetSelectEntry();
|
2016-01-19 12:28:28 +01:00
|
|
|
|
|
|
|
return aMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString ListBoxUIObject::get_name() const
|
|
|
|
{
|
|
|
|
return OUString("ListBoxUIObject");
|
|
|
|
}
|
|
|
|
|
2016-03-30 05:14:50 +02:00
|
|
|
std::unique_ptr<UIObject> ListBoxUIObject::create(vcl::Window* pWindow)
|
|
|
|
{
|
|
|
|
ListBox* pListBox = dynamic_cast<ListBox*>(pWindow);
|
|
|
|
assert(pListBox);
|
|
|
|
return std::unique_ptr<UIObject>(new ListBoxUIObject(pListBox));
|
|
|
|
}
|
|
|
|
|
2016-03-28 18:33:30 +02:00
|
|
|
ComboBoxUIObject::ComboBoxUIObject(VclPtr<ComboBox> xComboBox):
|
|
|
|
WindowUIObject(xComboBox),
|
|
|
|
mxComboBox(xComboBox)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-30 05:27:54 +02:00
|
|
|
ComboBoxUIObject::~ComboBoxUIObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-28 18:33:30 +02:00
|
|
|
void ComboBoxUIObject::execute(const OUString& rAction,
|
|
|
|
const StringMap& rParameters)
|
|
|
|
{
|
|
|
|
if (rAction == "SELECT")
|
|
|
|
{
|
|
|
|
if (rParameters.find("POS") != rParameters.end())
|
|
|
|
{
|
|
|
|
auto itr = rParameters.find("POS");
|
|
|
|
OUString aVal = itr->second;
|
|
|
|
sal_Int32 nPos = aVal.toInt32();
|
|
|
|
mxComboBox->SelectEntryPos(nPos);
|
|
|
|
}
|
|
|
|
mxComboBox->Select();
|
|
|
|
}
|
2016-12-21 14:36:31 +01:00
|
|
|
else if (rAction == "TYPE")
|
|
|
|
{
|
|
|
|
if (mxComboBox->GetSubEdit())
|
|
|
|
{
|
|
|
|
Edit* pEdit = mxComboBox->GetSubEdit();
|
|
|
|
std::unique_ptr<UIObject> pObj = EditUIObject::create(pEdit);
|
|
|
|
pObj->execute(rAction, rParameters);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
WindowUIObject::execute(rAction, rParameters);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
WindowUIObject::execute(rAction, rParameters);
|
2016-03-28 18:33:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
StringMap ComboBoxUIObject::get_state()
|
|
|
|
{
|
|
|
|
StringMap aMap = WindowUIObject::get_state();
|
|
|
|
|
|
|
|
return aMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString ComboBoxUIObject::get_name() const
|
|
|
|
{
|
|
|
|
return OUString("ComboBoxUIObject");
|
|
|
|
}
|
|
|
|
|
2016-03-30 05:14:50 +02:00
|
|
|
std::unique_ptr<UIObject> ComboBoxUIObject::create(vcl::Window* pWindow)
|
|
|
|
{
|
|
|
|
ComboBox* pComboBox = dynamic_cast<ComboBox*>(pWindow);
|
|
|
|
assert(pComboBox);
|
|
|
|
return std::unique_ptr<UIObject>(new ComboBoxUIObject(pComboBox));
|
|
|
|
}
|
|
|
|
|
2016-03-28 18:34:44 +02:00
|
|
|
SpinUIObject::SpinUIObject(VclPtr<SpinButton> xSpinButton):
|
|
|
|
WindowUIObject(xSpinButton),
|
|
|
|
mxSpinButton(xSpinButton)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-30 05:27:54 +02:00
|
|
|
SpinUIObject::~SpinUIObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-28 18:34:44 +02:00
|
|
|
void SpinUIObject::execute(const OUString& rAction,
|
2016-03-28 19:07:07 +02:00
|
|
|
const StringMap& /*rParameters*/)
|
2016-03-28 18:34:44 +02:00
|
|
|
{
|
|
|
|
if (rAction == "UP")
|
|
|
|
{
|
|
|
|
/* code */
|
|
|
|
}
|
|
|
|
else if (rAction == "DOWN")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StringMap SpinUIObject::get_state()
|
|
|
|
{
|
|
|
|
StringMap aMap = WindowUIObject::get_state();
|
|
|
|
aMap["Min"] = OUString::number(mxSpinButton->GetRangeMin());
|
|
|
|
aMap["Max"] = OUString::number(mxSpinButton->GetRangeMax());
|
|
|
|
aMap["Step"] = OUString::number(mxSpinButton->GetValueStep());
|
|
|
|
aMap["Value"] = OUString::number(mxSpinButton->GetValue());
|
|
|
|
|
|
|
|
return aMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString SpinUIObject::get_name() const
|
|
|
|
{
|
|
|
|
return OUString("SpinUIObject");
|
|
|
|
}
|
2016-03-28 20:58:13 +02:00
|
|
|
|
|
|
|
SpinFieldUIObject::SpinFieldUIObject(VclPtr<SpinField> xSpinField):
|
|
|
|
EditUIObject(xSpinField),
|
|
|
|
mxSpinField(xSpinField)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-30 05:27:54 +02:00
|
|
|
SpinFieldUIObject::~SpinFieldUIObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-28 20:58:13 +02:00
|
|
|
void SpinFieldUIObject::execute(const OUString& rAction,
|
2016-06-20 02:56:10 +02:00
|
|
|
const StringMap& rParameters)
|
2016-03-28 20:58:13 +02:00
|
|
|
{
|
|
|
|
if (rAction == "UP")
|
|
|
|
{
|
|
|
|
mxSpinField->Up();
|
|
|
|
}
|
|
|
|
else if (rAction == "DOWN")
|
|
|
|
{
|
|
|
|
mxSpinField->Down();
|
|
|
|
}
|
2016-06-20 02:56:10 +02:00
|
|
|
else if (rAction == "TYPE")
|
|
|
|
{
|
|
|
|
if (mxSpinField->GetSubEdit())
|
|
|
|
{
|
|
|
|
Edit* pSubEdit = mxSpinField->GetSubEdit();
|
|
|
|
EditUIObject aSubObject(pSubEdit);
|
|
|
|
aSubObject.execute(rAction, rParameters);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
EditUIObject::execute(rAction, rParameters);
|
2016-03-28 20:58:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
StringMap SpinFieldUIObject::get_state()
|
|
|
|
{
|
|
|
|
StringMap aMap = EditUIObject::get_state();
|
|
|
|
|
|
|
|
return aMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString SpinFieldUIObject::get_name() const
|
|
|
|
{
|
|
|
|
return OUString("SpinFieldUIObject");
|
|
|
|
}
|
|
|
|
|
2016-03-30 05:14:50 +02:00
|
|
|
std::unique_ptr<UIObject> SpinFieldUIObject::create(vcl::Window* pWindow)
|
|
|
|
{
|
|
|
|
SpinField* pSpinField = dynamic_cast<SpinField*>(pWindow);
|
|
|
|
assert(pSpinField);
|
|
|
|
return std::unique_ptr<UIObject>(new SpinFieldUIObject(pSpinField));
|
|
|
|
}
|
|
|
|
|
2016-06-21 16:44:30 +02:00
|
|
|
TabControlUIObject::TabControlUIObject(VclPtr<TabControl> xTabControl):
|
|
|
|
WindowUIObject(xTabControl),
|
|
|
|
mxTabControl(xTabControl)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TabControlUIObject::~TabControlUIObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabControlUIObject::execute(const OUString& rAction,
|
|
|
|
const StringMap& rParameters)
|
|
|
|
{
|
|
|
|
if (rAction == "SELECT")
|
|
|
|
{
|
|
|
|
if (rParameters.find("POS") != rParameters.end())
|
|
|
|
{
|
|
|
|
auto itr = rParameters.find("POS");
|
|
|
|
sal_uInt32 nPos = itr->second.toUInt32();
|
|
|
|
std::vector<sal_uInt16> aIds = mxTabControl->GetPageIDs();
|
|
|
|
mxTabControl->SelectTabPage(aIds[nPos]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
WindowUIObject::execute(rAction, rParameters);
|
|
|
|
}
|
|
|
|
|
|
|
|
StringMap TabControlUIObject::get_state()
|
|
|
|
{
|
|
|
|
StringMap aMap = WindowUIObject::get_state();
|
|
|
|
|
|
|
|
return aMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString TabControlUIObject::get_name() const
|
|
|
|
{
|
|
|
|
return OUString("TabControlUIObject");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<UIObject> TabControlUIObject::create(vcl::Window* pWindow)
|
|
|
|
{
|
|
|
|
TabControl* pTabControl = dynamic_cast<TabControl*>(pWindow);
|
|
|
|
assert(pTabControl);
|
|
|
|
return std::unique_ptr<UIObject>(new TabControlUIObject(pTabControl));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-12-09 08:04:30 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|