summaryrefslogtreecommitdiff
path: root/sd/source/ui
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-05-22 05:54:11 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-06-18 17:02:38 +0200
commitfdfc55da301435dfd52b0365b8edda7aa893f983 (patch)
treeabc8c696491fc6d69faefcffbf98ea2f0c4bb458 /sd/source/ui
parentb67527fb75cd95201d9251064e8b9d5b1c4fe62a (diff)
uitest: add initial code for impress main edit window
Change-Id: I82eabe1df33878316907e664ddbcd8edf6a73d33
Diffstat (limited to 'sd/source/ui')
-rw-r--r--sd/source/ui/inc/Window.hxx3
-rw-r--r--sd/source/ui/inc/uiobject.hxx43
-rw-r--r--sd/source/ui/uitest/uiobject.cxx77
-rw-r--r--sd/source/ui/view/sdwindow.cxx14
4 files changed, 137 insertions, 0 deletions
diff --git a/sd/source/ui/inc/Window.hxx b/sd/source/ui/inc/Window.hxx
index 6d9d8697f36c..bfd38f430031 100644
--- a/sd/source/ui/inc/Window.hxx
+++ b/sd/source/ui/inc/Window.hxx
@@ -49,6 +49,7 @@ public:
virtual void dispose() override;
void SetViewShell (ViewShell* pViewSh);
+ ViewShell* GetViewShell();
/** Set the zoom factor to the specified value and center the display
area around the zoom center.
@@ -192,6 +193,8 @@ protected:
Selection GetSurroundingTextSelection() const override;
/// @see OutputDevice::LogicInvalidate().
void LogicInvalidate(const Rectangle* pRectangle) override;
+
+ FactoryFunction GetUITestFactory() const override;
};
} // end of namespace sd
diff --git a/sd/source/ui/inc/uiobject.hxx b/sd/source/ui/inc/uiobject.hxx
new file mode 100644
index 000000000000..f8b7e572899e
--- /dev/null
+++ b/sd/source/ui/inc/uiobject.hxx
@@ -0,0 +1,43 @@
+/* -*- 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/.
+ */
+
+#include <vcl/uitest/uiobject.hxx>
+
+namespace sd {
+
+class Window;
+class DrawViewShell;
+
+}
+
+class ImpressWindowUIObject : public WindowUIObject
+{
+public:
+
+ ImpressWindowUIObject(VclPtr<sd::Window> xWindow);
+
+ virtual StringMap get_state() 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;
+
+private:
+
+ VclPtr<sd::Window> mxWindow;
+
+ sd::DrawViewShell* getViewShell();
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/uitest/uiobject.cxx b/sd/source/ui/uitest/uiobject.cxx
new file mode 100644
index 000000000000..90535c6d66aa
--- /dev/null
+++ b/sd/source/ui/uitest/uiobject.cxx
@@ -0,0 +1,77 @@
+/* -*- 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/.
+ */
+
+#include "uiobject.hxx"
+
+#include "Window.hxx"
+#include "DrawViewShell.hxx"
+
+ImpressWindowUIObject::ImpressWindowUIObject(VclPtr<sd::Window> xWindow):
+ WindowUIObject(xWindow),
+ mxWindow(xWindow)
+{
+}
+
+StringMap ImpressWindowUIObject::get_state()
+{
+ StringMap aMap = WindowUIObject::get_state();
+
+ aMap["SelectedText"] = getViewShell()->GetSelectionText();
+ aMap["CurrentSlide"] = OUString::number(getViewShell()->GetCurPageId());
+
+ return aMap;
+}
+
+void ImpressWindowUIObject::execute(const OUString& rAction,
+ const StringMap& rParameters)
+{
+ if (rAction == "SET")
+ {
+ if (rParameters.find("ZOOM") != rParameters.end())
+ {
+ auto itr = rParameters.find("ZOOM");
+ OUString aVal = itr->second;
+ sal_Int32 nVal = aVal.toInt32();
+ getViewShell()->SetZoom(nVal);
+ }
+ }
+ else if (rAction == "GOTO")
+ {
+ if (rParameters.find("PAGE") != rParameters.end())
+ {
+ auto itr = rParameters.find("PAGE");
+ OUString aVal = itr->second;
+ sal_Int32 nVal = aVal.toInt32();
+ getViewShell()->SwitchPage(nVal);
+ }
+ }
+ WindowUIObject::execute(rAction, rParameters);
+}
+
+OUString ImpressWindowUIObject::get_name() const
+{
+ return OUString("ImpressWindowUIObject");
+}
+
+std::unique_ptr<UIObject> ImpressWindowUIObject::create(vcl::Window* pWindow)
+{
+ sd::Window* pWin = dynamic_cast<sd::Window*>(pWindow);
+ assert(pWin);
+ return std::unique_ptr<UIObject>(new ImpressWindowUIObject(pWin));
+}
+
+sd::DrawViewShell* ImpressWindowUIObject::getViewShell()
+{
+ sd::DrawViewShell* pViewShell = dynamic_cast<sd::DrawViewShell*>(mxWindow->GetViewShell());
+ assert(pViewShell);
+
+ return pViewShell;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx
index 580e7a664fef..f400e7816945 100644
--- a/sd/source/ui/view/sdwindow.cxx
+++ b/sd/source/ui/view/sdwindow.cxx
@@ -38,6 +38,7 @@
#include "AccessibleDrawDocumentView.hxx"
#include "WindowUpdater.hxx"
#include "ViewShellBase.hxx"
+#include "uiobject.hxx"
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
@@ -129,6 +130,11 @@ void Window::SetViewShell (ViewShell* pViewSh)
}
}
+ViewShell* Window::GetViewShell()
+{
+ return mpViewShell;
+}
+
void Window::CalcMinZoom()
{
// Are we entitled to change the minimal zoom factor?
@@ -1021,6 +1027,14 @@ void Window::LogicInvalidate(const Rectangle* pRectangle)
rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
}
+FactoryFunction Window::GetUITestFactory() const
+{
+ if (get_id() == "impress_win")
+ return ImpressWindowUIObject::create;
+
+ return WindowUIObject::create;
+}
+
} // end of namespace sd
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */