[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - desktop/source include/vcl vcl/source

Henry Castro (via logerrit) logerrit at kemper.freedesktop.org
Tue Apr 28 02:54:09 UTC 2020


 desktop/source/lib/init.cxx     |    6 ++++++
 include/vcl/field.hxx           |    3 +++
 include/vcl/uitest/uiobject.hxx |   19 +++++++++++++++++++
 vcl/source/control/field.cxx    |   22 ++++++++++++++++++++++
 vcl/source/uitest/uiobject.cxx  |   38 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 88 insertions(+)

New commits:
commit 08dbff244c6b58e34ca9658b7405b641fcaaffec
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Wed Apr 22 18:22:33 2020 -0400
Commit:     Henry Castro <hcastro at collabora.com>
CommitDate: Tue Apr 28 04:53:40 2020 +0200

    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 at gmail.com>
    Reviewed-by: Henry Castro <hcastro at collabora.com>

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)


More information about the Libreoffice-commits mailing list