diff options
author | Henry Castro <hcastro@collabora.com> | 2019-10-19 14:58:56 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2019-10-23 02:38:33 +0200 |
commit | 7c6226bee72805db7f0e567ca9f06c786a7d0da2 (patch) | |
tree | e1c7a996d2527f136f87e8e9033133ef53df0f0f /svtools/source | |
parent | d2b5ab3498a78c6d164a15b3bf2b947553ea2743 (diff) |
lok: svtools: create ValueSetUIObject class
The ValueSet control is used in Layouts panel inside Sidebar of the
impress document. Once the LO server sends the UI data to the client side
that is transformed to mobile view using Mobile Wizard framework.
The loleaflet client side has to send commands for the user interactions
like to touch an item.
e.g. Send "WindowId SELECT ID=300"
The unit test simulates the scenario, so the ValueSet control executes
the action.
Change-Id: Ib6ec5db6ce2777e819f81a9dae74c4641bb7053b
Reviewed-on: https://gerrit.libreoffice.org/81141
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Henry Castro <hcastro@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/81354
Tested-by: Jenkins
Diffstat (limited to 'svtools/source')
-rw-r--r-- | svtools/source/control/valueset.cxx | 6 | ||||
-rw-r--r-- | svtools/source/uitest/uiobject.cxx | 66 |
2 files changed, 72 insertions, 0 deletions
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 494583799287..462cd55e99d1 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -27,6 +27,7 @@ #include <vcl/settings.hxx> #include <vcl/commandevent.hxx> #include <vcl/virdev.hxx> +#include <uitest/uiobject.hxx> #include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <com/sun/star/lang/XComponent.hpp> @@ -1455,6 +1456,11 @@ boost::property_tree::ptree ValueSet::DumpAsPropertyTree() return aTree; } +FactoryFunction ValueSet::GetUITestFactory() const +{ + return ValueSetUIObject::create; +} + void ValueSet::Select() { maSelectHdl.Call( this ); diff --git a/svtools/source/uitest/uiobject.cxx b/svtools/source/uitest/uiobject.cxx new file mode 100644 index 000000000000..2b1933a19e21 --- /dev/null +++ b/svtools/source/uitest/uiobject.cxx @@ -0,0 +1,66 @@ +/* -*- 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/. + */ + +#include <memory> +#include <uitest/uiobject.hxx> + +#include <svtools/valueset.hxx> + +ValueSetUIObject::ValueSetUIObject(const VclPtr<ValueSet>& xValueSet) + : WindowUIObject(xValueSet) + , mxValueSet(xValueSet) +{ +} + +ValueSetUIObject::~ValueSetUIObject() {} + +void ValueSetUIObject::execute(const OUString& rAction, const StringMap& rParameters) +{ + if (!mxValueSet->IsEnabled() || !mxValueSet->IsReallyVisible()) + return; + + if (rAction == "SELECT") + { + if (rParameters.find("ID") != rParameters.end()) + { + auto aPos = rParameters.find("ID"); + OUString aVal = aPos->second; + sal_Int32 nPos = aVal.toInt32(); + mxValueSet->SelectItem(nPos); + mxValueSet->Select(); + } + } + else + WindowUIObject::execute(rAction, rParameters); +} + +StringMap ValueSetUIObject::get_state() +{ + StringMap aMap = WindowUIObject::get_state(); + aMap["EntryCount"] = OUString::number(mxValueSet->GetItemCount()); + + return aMap; +} + +OUString ValueSetUIObject::get_name() const { return "ValueSetUIObject"; } + +OUString ValueSetUIObject::get_action(VclEventId /*nEvent*/) const +{ + // No action for this control that trigger item selection after mouse tracking end + return OUString(); +} + +std::unique_ptr<UIObject> ValueSetUIObject::create(vcl::Window* pWindow) +{ + ValueSet* pValueSet = dynamic_cast<ValueSet*>(pWindow); + assert(pValueSet); + return std::unique_ptr<UIObject>(new ValueSetUIObject(pValueSet)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |