summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/source/lib/init.cxx6
-rw-r--r--include/vcl/field.hxx2
-rw-r--r--include/vcl/toolkit/field.hxx1
-rw-r--r--include/vcl/uitest/metricfielduiobject.hxx35
-rw-r--r--include/vcl/uitest/uiobject.hxx3
-rw-r--r--vcl/source/control/field.cxx23
-rw-r--r--vcl/source/uitest/uiobject.cxx40
7 files changed, 108 insertions, 2 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 86212ed28e8e..1a26cdd20b94 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3568,6 +3568,7 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin
const OUString sTypeAction("TYPE");
const OUString sUpAction("UP");
const OUString sDownAction("DOWN");
+ const OUString sValue("VALUE");
try
{
@@ -3599,6 +3600,11 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin
pUIWindow->execute(sClearAction, aMap);
pUIWindow->execute(sTypeAction, aMap);
}
+ else if (aMap["cmd"] == "value")
+ {
+ aMap["VALUE"] = aMap["data"];
+ pUIWindow->execute(sValue, aMap);
+ }
else
bIsClickAction = true;
}
diff --git a/include/vcl/field.hxx b/include/vcl/field.hxx
index d9b76c56680d..beb3a30c356f 100644
--- a/include/vcl/field.hxx
+++ b/include/vcl/field.hxx
@@ -150,6 +150,8 @@ public:
sal_Int64 Normalize( sal_Int64 nValue ) const;
sal_Int64 Denormalize( sal_Int64 nValue ) const;
+ virtual void SetValueFromString(const OUString& rStr);
+
protected:
sal_Int64 mnLastValue;
sal_Int64 mnMin;
diff --git a/include/vcl/toolkit/field.hxx b/include/vcl/toolkit/field.hxx
index bd3e92e13dcc..76c998b22c11 100644
--- a/include/vcl/toolkit/field.hxx
+++ b/include/vcl/toolkit/field.hxx
@@ -101,6 +101,7 @@ public:
virtual void dispose() override;
virtual boost::property_tree::ptree DumpAsPropertyTree() override;
+ virtual FactoryFunction GetUITestFactory() const override;
};
class VCL_DLLPUBLIC MetricBox : public ComboBox, public MetricFormatter
diff --git a/include/vcl/uitest/metricfielduiobject.hxx b/include/vcl/uitest/metricfielduiobject.hxx
new file mode 100644
index 000000000000..a23c555225a0
--- /dev/null
+++ b/include/vcl/uitest/metricfielduiobject.hxx
@@ -0,0 +1,35 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_VCL_UITEST_METRICFIELDUIOBJECT_HXX
+#define INCLUDED_VCL_UITEST_METRICFIELDUIOBJECT_HXX
+
+#include <vcl/uitest/uiobject.hxx>
+
+class MetricField;
+
+class UITEST_DLLPUBLIC MetricFieldUIObject : public SpinFieldUIObject
+{
+ VclPtr<MetricField> mxMetricField;
+
+public:
+ MetricFieldUIObject(const VclPtr<MetricField>& xEdit);
+ virtual ~MetricFieldUIObject() override;
+
+ virtual void execute(const OUString& rAction, const StringMap& rParameters) override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+protected:
+ virtual OUString get_name() const override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/uitest/uiobject.hxx b/include/vcl/uitest/uiobject.hxx
index 3de90891015e..2c9a3e36cc60 100644
--- a/include/vcl/uitest/uiobject.hxx
+++ b/include/vcl/uitest/uiobject.hxx
@@ -15,7 +15,6 @@
#include <memory>
#include <vcl/window.hxx>
-
#include <vcl/dllapi.h>
#include <set>
@@ -364,7 +363,7 @@ private:
virtual OUString get_name() const override;
};
-class SpinFieldUIObject final : public EditUIObject
+class SpinFieldUIObject : public EditUIObject
{
VclPtr<SpinField> mxSpinField;
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index c7d088d643b5..c10e6a409855 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -32,6 +32,8 @@
#include <vcl/event.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
+#include <vcl/uitest/uiobject.hxx>
+#include <vcl/uitest/metricfielduiobject.hxx>
#include <svdata.hxx>
@@ -623,6 +625,22 @@ sal_Int64 NumericFormatter::GetValueFromString(const OUString& rStr) const
return mnLastValue;
}
+// currently used by online
+void NumericFormatter::SetValueFromString(const OUString& rStr)
+{
+ sal_Int64 nValue;
+
+ if (ImplNumericGetValue(rStr, nValue, GetDecimalDigits(),
+ Application::GetSettings().GetNeutroLocaleDataWrapper()))
+ {
+ SetValue(nValue);
+ }
+ else
+ {
+ SAL_WARN("vcl", "fail to convert the value: " << rStr );
+ }
+}
+
sal_Int64 NumericFormatter::GetValue() const
{
if (mbFormatting) //don't parse the entry if we're currently formatting what to put in it
@@ -1701,6 +1719,11 @@ boost::property_tree::ptree MetricField::DumpAsPropertyTree()
return aTree;
}
+FactoryFunction MetricField::GetUITestFactory() const
+{
+ return MetricFieldUIObject::create;
+}
+
MetricBox::MetricBox(vcl::Window* pParent, WinBits nWinStyle)
: ComboBox(pParent, nWinStyle)
, MetricFormatter(this)
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index cbbd35f26754..a387fb41ab02 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -8,6 +8,7 @@
*/
#include <vcl/uitest/uiobject.hxx>
+#include <vcl/uitest/metricfielduiobject.hxx>
#include <vcl/combobox.hxx>
#include <vcl/event.hxx>
@@ -19,6 +20,7 @@
#include <vcl/spinfld.hxx>
#include <vcl/toolkit/button.hxx>
#include <vcl/toolkit/dialog.hxx>
+#include <vcl/toolkit/field.hxx>
#include <vcl/edit.hxx>
#include <vcl/vclmedit.hxx>
#include <vcl/uitest/logger.hxx>
@@ -1289,6 +1291,44 @@ std::unique_ptr<UIObject> SpinFieldUIObject::create(vcl::Window* pWindow)
return std::unique_ptr<UIObject>(new SpinFieldUIObject(pSpinField));
}
+
+MetricFieldUIObject::MetricFieldUIObject(const VclPtr<MetricField>& xMetricField):
+ SpinFieldUIObject(xMetricField),
+ mxMetricField(xMetricField)
+{
+}
+
+MetricFieldUIObject::~MetricFieldUIObject()
+{
+}
+
+void MetricFieldUIObject::execute(const OUString& rAction,
+ const StringMap& rParameters)
+{
+ if (rAction == "VALUE")
+ {
+ auto itPos = rParameters.find("VALUE");
+ if (itPos != rParameters.end())
+ {
+ mxMetricField->SetValueFromString(itPos->second);
+ }
+ }
+ else
+ SpinFieldUIObject::execute(rAction, rParameters);
+}
+
+OUString MetricFieldUIObject::get_name() const
+{
+ return "MetricFieldUIObject";
+}
+
+std::unique_ptr<UIObject> MetricFieldUIObject::create(vcl::Window* pWindow)
+{
+ MetricField* pMetricField = dynamic_cast<MetricField*>(pWindow);
+ assert(pMetricField);
+ return std::unique_ptr<UIObject>(new MetricFieldUIObject(pMetricField));
+}
+
TabControlUIObject::TabControlUIObject(const VclPtr<TabControl>& xTabControl):
WindowUIObject(xTabControl),
mxTabControl(xTabControl)