diff options
-rw-r--r-- | sd/Library_sd.mk | 1 | ||||
-rw-r--r-- | sd/source/ui/inc/Window.hxx | 3 | ||||
-rw-r--r-- | sd/source/ui/inc/uiobject.hxx | 43 | ||||
-rw-r--r-- | sd/source/ui/uitest/uiobject.cxx | 77 | ||||
-rw-r--r-- | sd/source/ui/view/sdwindow.cxx | 14 |
5 files changed, 138 insertions, 0 deletions
diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index 76e35ae4a4bc..ae04336e21fb 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -411,6 +411,7 @@ $(eval $(call gb_Library_add_exception_objects,sd,\ sd/source/ui/tools/SdGlobalResourceContainer \ sd/source/ui/tools/SlotStateListener \ sd/source/ui/tools/TimerBasedTaskExecution \ + sd/source/ui/uitest/uiobject \ sd/source/ui/unoidl/DrawController \ sd/source/ui/unoidl/SdUnoDrawView \ sd/source/ui/unoidl/SdUnoOutlineView \ 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: */ |