diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-05-20 20:49:40 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-06-18 17:02:28 +0200 |
commit | 4eae49218f449b4057d15633c5be2b3b0f9b88f9 (patch) | |
tree | 32d2fbff6b7574906304b31be486b979ab340a5c /sw/source | |
parent | 725815366eb5543b4465af60a1072f1738db9147 (diff) |
uitest: add wrapper for writer's main edit window
Change-Id: Ibd6ffe85ca95cdc915f5c73b1b566de1d7413ee7
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/uibase/docvw/edtwin3.cxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/inc/edtwin.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/inc/uiobject.hxx | 42 | ||||
-rw-r--r-- | sw/source/uibase/uitest/uiobject.cxx | 55 |
4 files changed, 105 insertions, 0 deletions
diff --git a/sw/source/uibase/docvw/edtwin3.cxx b/sw/source/uibase/docvw/edtwin3.cxx index 745bbd4ca864..52c56de46ecb 100644 --- a/sw/source/uibase/docvw/edtwin3.cxx +++ b/sw/source/uibase/docvw/edtwin3.cxx @@ -34,6 +34,7 @@ #include "pagedesc.hxx" #include <frmatr.hxx> #include <editeng/frmdiritem.hxx> +#include "uiobject.hxx" // Core-Notify void ScrollMDI( SwViewShell* pVwSh, const SwRect &rRect, @@ -165,4 +166,9 @@ void SwEditWin::DataChanged( const DataChangedEvent& rDCEvt ) pSh->UnlockPaint(); } +FactoryFunction SwEditWin::GetUITestFactory() const +{ + return SwEditWinUIObject::create; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx index cc4d52800ffa..1b713de27748 100644 --- a/sw/source/uibase/inc/edtwin.hxx +++ b/sw/source/uibase/inc/edtwin.hxx @@ -307,6 +307,8 @@ public: void SetCursorTwipPosition(const Point& rPosition, bool bPoint, bool bClearMark); /// Allows starting or ending a graphic move or resize action. void SetGraphicTwipPosition(bool bStart, const Point& rPosition); + + virtual FactoryFunction GetUITestFactory() const override; }; #endif diff --git a/sw/source/uibase/inc/uiobject.hxx b/sw/source/uibase/inc/uiobject.hxx new file mode 100644 index 000000000000..568aa6c487d0 --- /dev/null +++ b/sw/source/uibase/inc/uiobject.hxx @@ -0,0 +1,42 @@ +/* -*- 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/. + */ + +#ifndef SW_SOURCE_UIBASE_INC_UIOBJECT_HXX +#define SW_SOURCE_UIBASE_INC_UIOBJECT_HXX + +#include <vcl/uitest/uiobject.hxx> + +class SwEditWin; + +class SwEditWinUIObject : public WindowUIObject +{ +public: + + SwEditWinUIObject(VclPtr<SwEditWin> xEditWin); + + 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<SwEditWin> mxEditWin; + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/uitest/uiobject.cxx b/sw/source/uibase/uitest/uiobject.cxx new file mode 100644 index 000000000000..9d45be13910f --- /dev/null +++ b/sw/source/uibase/uitest/uiobject.cxx @@ -0,0 +1,55 @@ +/* -*- 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 "edtwin.hxx" +#include "view.hxx" + +SwEditWinUIObject::SwEditWinUIObject(VclPtr<SwEditWin> xEditWin): + WindowUIObject(xEditWin), + mxEditWin(xEditWin) +{ +} + +StringMap SwEditWinUIObject::get_state() +{ + StringMap aMap = WindowUIObject::get_state(); + + // aMap["SelectedText"] = mxEditWin + return aMap; +} + +void SwEditWinUIObject::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(); + mxEditWin->GetView().SetZoom(SvxZoomType::PERCENT, nVal); + } + } +} + +OUString SwEditWinUIObject::get_name() const +{ + return OUString("SwEditWinUIObject"); +} + +std::unique_ptr<UIObject> SwEditWinUIObject::create(vcl::Window* pWindow) +{ + SwEditWin* pEditWin = dynamic_cast<SwEditWin*>(pWindow); + assert(pEditWin); + return std::unique_ptr<UIObject>(new SwEditWinUIObject(pEditWin)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |