From a801155464cf479b3fbf30f27e3f51030d69ba14 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Thu, 29 Sep 2016 17:08:48 +0200 Subject: add introspection support for SvSimpleTable This is the second part of the UI test tutorial. The tutorial shows how to add introspection support to a new vcl::Window based UI object. Change-Id: I2b3ed68d313749787869c7e85f2e27c9d01fff4a --- svtools/inc/uitest/uiobject.hxx | 17 +++++++++++++++++ svtools/source/contnr/simptabl.cxx | 11 +++++++++++ svtools/source/uitest/uiobject.cxx | 28 ++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) (limited to 'svtools') diff --git a/svtools/inc/uitest/uiobject.hxx b/svtools/inc/uitest/uiobject.hxx index 93cfc156a47b..873c3d57dedf 100644 --- a/svtools/inc/uitest/uiobject.hxx +++ b/svtools/inc/uitest/uiobject.hxx @@ -11,6 +11,7 @@ class SvTreeListBox; class SvTreeListEntry; +class SvSimpleTable; class TreeListUIObject : public WindowUIObject { @@ -61,4 +62,20 @@ private: SvTreeListEntry* mpEntry; }; +class SimpleTableUIObject : public TreeListUIObject +{ +public: + SimpleTableUIObject(VclPtr xTable); + + virtual StringMap get_state() override; + + static std::unique_ptr createFromContainer(vcl::Window* pWindow); + +protected: + virtual OUString get_type() const override; + +private: + VclPtr mxTable; +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/contnr/simptabl.cxx b/svtools/source/contnr/simptabl.cxx index 8515183e66b6..88a8cb3c11c2 100644 --- a/svtools/source/contnr/simptabl.cxx +++ b/svtools/source/contnr/simptabl.cxx @@ -24,6 +24,7 @@ #include #include #include +#include SvSimpleTableContainer::SvSimpleTableContainer(vcl::Window* pParent, WinBits nBits) : Control(pParent, nBits) @@ -50,6 +51,11 @@ void SvSimpleTableContainer::SetTable(SvSimpleTable* pTable) m_pTable = pTable; } +SvSimpleTable* SvSimpleTableContainer::GetTable() +{ + return m_pTable.get(); +} + bool SvSimpleTableContainer::PreNotify( NotifyEvent& rNEvt ) { bool bResult = true; @@ -84,6 +90,11 @@ void SvSimpleTableContainer::GetFocus() m_pTable->GrabFocus(); } +FactoryFunction SvSimpleTableContainer::GetUITestFactory() const +{ + return SimpleTableUIObject::createFromContainer; +} + // SvSimpleTable ------------------------------------------------------------ SvSimpleTable::SvSimpleTable(SvSimpleTableContainer& rParent, WinBits nBits): diff --git a/svtools/source/uitest/uiobject.cxx b/svtools/source/uitest/uiobject.cxx index 6156f4451918..0a4550ff1813 100644 --- a/svtools/source/uitest/uiobject.cxx +++ b/svtools/source/uitest/uiobject.cxx @@ -10,6 +10,7 @@ #include "uitest/uiobject.hxx" #include +#include TreeListUIObject::TreeListUIObject(VclPtr xTreeList): WindowUIObject(xTreeList), @@ -140,4 +141,31 @@ OUString TreeListEntryUIObject::get_type() const return OUString("TreeListEntry"); } +SimpleTableUIObject::SimpleTableUIObject(VclPtr xTable): + TreeListUIObject(xTable), + mxTable(xTable) +{ +} + +StringMap SimpleTableUIObject::get_state() +{ + StringMap aMap = TreeListUIObject::get_state(); + + aMap["ColumnCount"] = OUString::number(mxTable->TabCount()); + + return aMap; +} + +OUString SimpleTableUIObject::UIObject::get_type() const +{ + return OUString("SimpleTable"); +} + +std::unique_ptr SimpleTableUIObject::createFromContainer(vcl::Window* pWindow) +{ + SvSimpleTableContainer* pTableContainer = dynamic_cast(pWindow); + assert(pTableContainer); + return std::unique_ptr(new SimpleTableUIObject(pTableContainer->GetTable())); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit