summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--desktop/source/lib/init.cxx6
-rw-r--r--include/vcl/field.hxx3
-rw-r--r--include/vcl/uitest/uiobject.hxx19
-rw-r--r--vcl/source/control/field.cxx22
-rw-r--r--vcl/source/uitest/uiobject.cxx38
5 files changed, 88 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index daf2eb90b8bc..cde112ba3fa4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3559,6 +3559,7 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin
static const OUString sTypeAction("TYPE");
static const OUString sUpAction("UP");
static const OUString sDownAction("DOWN");
+ static const OUString sValue("VALUE");
try
{
@@ -3590,6 +3591,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 172c128c0f3e..c855fa8c69f3 100644
--- a/include/vcl/field.hxx
+++ b/include/vcl/field.hxx
@@ -155,6 +155,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 mnFieldValue;
sal_Int64 mnLastValue;
@@ -519,6 +521,7 @@ public:
virtual void dispose() override;
virtual boost::property_tree::ptree DumpAsPropertyTree() override;
+ virtual FactoryFunction GetUITestFactory() const override;
};
diff --git a/include/vcl/uitest/uiobject.hxx b/include/vcl/uitest/uiobject.hxx
index e56801af17f4..f5734e1a2949 100644
--- a/include/vcl/uitest/uiobject.hxx
+++ b/include/vcl/uitest/uiobject.hxx
@@ -381,6 +381,25 @@ protected:
virtual OUString get_name() const override;
};
+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;
+};
+
class UITEST_DLLPUBLIC TabControlUIObject : public WindowUIObject
{
private:
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)