summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2020-04-22 18:22:33 -0400
committerHenry Castro <hcastro@collabora.com>2020-04-28 04:53:40 +0200
commit08dbff244c6b58e34ca9658b7405b641fcaaffec (patch)
treef5d8dbb79558ec4c1b3e6b97c6703a9a87bda42a /vcl
parent5d6c71151e8c3ae710e4f57dccebf5f1073a399c (diff)
lok: add MetricFieldUIObject class
Add new action "VALUE" to set the value number for metric input controls Change-Id: I5058260c2e1562cfc6d10508d5981d185c5f2212 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92738 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/control/field.cxx22
-rw-r--r--vcl/source/uitest/uiobject.cxx38
2 files changed, 60 insertions, 0 deletions
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index e75a55b52c5c..abdcaa798bc6 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -29,6 +29,7 @@
#include <vcl/event.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
+#include <vcl/uitest/uiobject.hxx>
#include <strings.hrc>
#include <svdata.hxx>
@@ -640,6 +641,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
@@ -1715,6 +1732,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 af3f486569d8..671e698e494d 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -1205,6 +1205,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 OUString("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)