[Libreoffice-commits] core.git: 2 commits - desktop/source filter/source include/vcl vcl/source

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 16 12:55:32 UTC 2021


 desktop/source/lib/init.cxx     |   11 +++++++++++
 filter/source/svg/svgexport.cxx |    2 ++
 include/vcl/layout.hxx          |    7 +------
 include/vcl/uitest/uiobject.hxx |    2 ++
 vcl/source/uitest/uiobject.cxx  |   39 +++++++++++++++++++++++++++++++++++++++
 vcl/source/window/layout.cxx    |    8 ++++++++
 6 files changed, 63 insertions(+), 6 deletions(-)

New commits:
commit ebeb1d1ae554e8301d876b19afc05f454acdfc1c
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Fri Apr 2 20:13:32 2021 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri Apr 16 14:55:04 2021 +0200

    jsdialog: uitest: handle click for drawing area
    
    Change-Id: I5ea78697b87f4b2a468f8507470b62031bee4aa0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113524
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114202
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e2027ab218ba..cd4b3da2d729 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3809,6 +3809,17 @@ static void lcl_sendDialogEvent(unsigned long long int nWindowId, const char* pA
                     aMap["VALUE"] = aMap["data"];
                     pUIWindow->execute(sValue, aMap);
                 }
+                else if (sAction == "click" && aMap["type"] == "drawingarea")
+                {
+                    int separatorPos = aMap["data"].indexOf(';');
+                    if (separatorPos > 0)
+                    {
+                        // x;y
+                        aMap["POSX"] = aMap["data"].copy(0, separatorPos);
+                        aMap["POSY"] = aMap["data"].copy(separatorPos + 1);
+                    }
+                    pUIWindow->execute(sClickAction, aMap);
+                }
                 else
                     pUIWindow->execute(sClickAction, aMap);
             }
diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index 9a896915b1ed..5a2b7310ea48 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -707,12 +707,7 @@ private:
         }
     }
     virtual void StartDrag(sal_Int8 nAction, const Point& rPosPixel) override;
-    virtual FactoryFunction GetUITestFactory() const override
-    {
-        if (m_pFactoryFunction)
-            return m_pFactoryFunction;
-        return Control::GetUITestFactory();
-    }
+    virtual FactoryFunction GetUITestFactory() const override;
 
 public:
     VclDrawingArea(vcl::Window *pParent, WinBits nStyle)
diff --git a/include/vcl/uitest/uiobject.hxx b/include/vcl/uitest/uiobject.hxx
index 1a2c192a4c63..b4df10a40c9e 100644
--- a/include/vcl/uitest/uiobject.hxx
+++ b/include/vcl/uitest/uiobject.hxx
@@ -557,6 +557,8 @@ protected:
 public:
     DrawingAreaUIObject(const VclPtr<vcl::Window>& rDrawingArea);
     virtual ~DrawingAreaUIObject() override;
+    virtual void execute(const OUString& rAction, const StringMap& rParameters) override;
+    static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
 };
 
 #endif
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index 4d8390e212a2..11c6e7ec7d6e 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -1735,6 +1735,45 @@ DrawingAreaUIObject::~DrawingAreaUIObject()
 {
 }
 
+void DrawingAreaUIObject::execute(const OUString& rAction, const StringMap& rParameters)
+{
+    if (rAction == "CLICK")
+    {
+        // POSX and POSY are percentage of width/height dimensions
+        if (rParameters.find("POSX") != rParameters.end() &&
+            rParameters.find("POSY") != rParameters.end())
+        {
+            auto aPosX = rParameters.find("POSX");
+            auto aPosY = rParameters.find("POSY");
+
+            OString sPosX2 = OUStringToOString(aPosX->second, RTL_TEXTENCODING_ASCII_US);
+            OString sPoxY2 = OUStringToOString(aPosY->second, RTL_TEXTENCODING_ASCII_US);
+
+            if (!sPosX2.isEmpty() && !sPoxY2.isEmpty())
+            {
+                double fPosX = std::atof(sPosX2.getStr());
+                double fPosY = std::atof(sPoxY2.getStr());
+
+                fPosX = fPosX * mxDrawingArea->GetOutputWidthPixel();
+                fPosY = fPosY * mxDrawingArea->GetOutputHeightPixel();
+
+                MouseEvent aEvent(Point(fPosX, fPosY), 1, MouseEventModifiers::NONE, MOUSE_LEFT, 0);
+                mxDrawingArea->MouseButtonDown(aEvent);
+                mxDrawingArea->MouseButtonUp(aEvent);
+            }
+        }
+    }
+    else
+        WindowUIObject::execute(rAction, rParameters);
+}
+
+std::unique_ptr<UIObject> DrawingAreaUIObject::create(vcl::Window* pWindow)
+{
+    VclDrawingArea* pVclDrawingArea = dynamic_cast<VclDrawingArea*>(pWindow);
+    assert(pVclDrawingArea);
+    return std::unique_ptr<UIObject>(new DrawingAreaUIObject(pVclDrawingArea));
+}
+
 IconViewUIObject::IconViewUIObject(const VclPtr<SvTreeListBox>& xIconView):
     TreeListUIObject(xIconView)
 {
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index d5e5839583fd..0a79fb7f78dc 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -30,6 +30,7 @@
 #include <window.h>
 #include <boost/multi_array.hpp>
 #include <vcl/toolkit/vclmedit.hxx>
+#include <vcl/uitest/uiobject.hxx>
 #include <sal/log.hxx>
 #include <tools/json_writer.hxx>
 
@@ -2954,4 +2955,11 @@ void VclDrawingArea::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
     rJsonWriter.put("text", GetQuickHelpText());
 }
 
+FactoryFunction VclDrawingArea::GetUITestFactory() const
+{
+    if (m_pFactoryFunction)
+        return m_pFactoryFunction;
+    return DrawingAreaUIObject::create;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit f38465834acf42b6a6023ea4b1bb7cdd09c77030
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu Mar 25 10:41:11 2021 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri Apr 16 14:54:52 2021 +0200

    SVGFilter::implGenerateMetaData check page before use
    
    Avoid crash in online impress:
    1. session A edits the textbox
    2. session B removed slide which is edited by A
    3. session A tries to edit another textbox on other slide
    
    Change-Id: Ic875321107baa48fd2a5b52aa2580a8fcde40823
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113077
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114203
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index d3e074620e66..fd94e541ac2b 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -1227,6 +1227,8 @@ void SVGFilter::implGenerateMetaData()
         {
             const Reference< css::drawing::XDrawPage > & xDrawPage = mSelectedPages[i];
             Reference< css::drawing::XMasterPageTarget > xMasterPageTarget( xDrawPage, UNO_QUERY );
+            if (!xMasterPageTarget.is())
+                    continue;
             Reference< css::drawing::XDrawPage > xMasterPage = xMasterPageTarget->getMasterPage();
             OUString aSlideId(aId + "_" + OUString::number( i ));
 


More information about the Libreoffice-commits mailing list