summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-03-31 06:10:50 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-06-18 17:01:54 +0200
commite407b0e6861175dca85d08e013a639c11d372589 (patch)
tree807a000f2b5b737126363f93b7870c98d96318d7
parent2a9253d3f5b0eba7b9129f7e64aec1e8867719f6 (diff)
uitest: support selecting different tab pages in tab dialog
Change-Id: I541f83a87f5f3d459b2baf4587b76cb2fce5d5fc
-rw-r--r--include/sfx2/tabdlg.hxx1
-rw-r--r--include/vcl/tabctrl.hxx2
-rw-r--r--sfx2/source/uitest/sfx_uiobject.cxx39
-rw-r--r--vcl/source/control/tabctrl.cxx12
4 files changed, 53 insertions, 1 deletions
diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx
index 99e223ab61b9..2f624453b87a 100644
--- a/include/sfx2/tabdlg.hxx
+++ b/include/sfx2/tabdlg.hxx
@@ -61,6 +61,7 @@ class SFX2_DLLPUBLIC SfxTabDialog : public TabDialog
private:
friend class SfxTabPage;
friend class SfxTabDialogController;
+friend class SfxTabDialogUIObject;
VclPtr<VclBox> m_pBox;
VclPtr<TabControl> m_pTabCtrl;
diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx
index 4b34ae0f40e7..2d60b40f2608 100644
--- a/include/vcl/tabctrl.hxx
+++ b/include/vcl/tabctrl.hxx
@@ -189,6 +189,8 @@ public:
mbLayoutDirty = true;
}
+ std::vector<sal_uInt16> GetPageIDs() const;
+
virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
};
diff --git a/sfx2/source/uitest/sfx_uiobject.cxx b/sfx2/source/uitest/sfx_uiobject.cxx
index 138e4858fcbc..1f416277b497 100644
--- a/sfx2/source/uitest/sfx_uiobject.cxx
+++ b/sfx2/source/uitest/sfx_uiobject.cxx
@@ -25,16 +25,53 @@ StringMap SfxTabDialogUIObject::get_state()
{
StringMap aMap = WindowUIObject::get_state();
sal_uInt16 nPageId = mxTabDialog->GetCurPageId();
+ std::vector<sal_uInt16> aPageIds = mxTabDialog->m_pTabCtrl->GetPageIDs();
+ OUString aStrIds;
+ OUString aStrNames;
+ for (auto itr = aPageIds.begin(), itrEnd = aPageIds.end();
+ itr != itrEnd; ++itr)
+ {
+ aStrIds = aStrIds + OUString::number(*itr) + ";";
+ aStrNames = aStrNames + mxTabDialog->GetPageText(*itr) + ";";
+ }
+
+ aMap["PageIds"] = aStrIds;
+ aMap["PageNames"] = aStrNames;
aMap["CurrentPageID"] = OUString::number(nPageId);
aMap["CurrentPageText"] = mxTabDialog->GetPageText(nPageId);
return aMap;
}
void SfxTabDialogUIObject::execute(const OUString& rAction,
- const StringMap& /*rParameters*/)
+ const StringMap& rParameters)
{
if (rAction == "SELECT")
{
+ if (rParameters.find("POS") != rParameters.end())
+ {
+ auto itr = rParameters.find("POS");
+ sal_uInt32 nPos = itr->second.toUInt32();
+ std::vector<sal_uInt16> aIds = mxTabDialog->m_pTabCtrl->GetPageIDs();
+ sal_uInt16 nPageId = aIds[nPos];
+ mxTabDialog->ShowPage(nPageId);
+ }
+ else if (rParameters.find("NAME") != rParameters.end())
+ {
+ auto itr = rParameters.find("NAME");
+ OUString aName = itr->second;
+ std::vector<sal_uInt16> aIds = mxTabDialog->m_pTabCtrl->GetPageIDs();
+ auto it = aIds.begin(), itEnd = aIds.end();
+ for (; it != itEnd; ++it)
+ {
+ if (mxTabDialog->GetPageText(*it) == aName)
+ break;
+ }
+
+ if (it == aIds.end())
+ return;
+
+ mxTabDialog->ShowPage(*it);
+ }
}
}
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 8b970309ff0c..d72056fb19d1 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -2181,4 +2181,16 @@ void TabControl::queue_resize(StateChangedType eReason)
Window::queue_resize(eReason);
}
+std::vector<sal_uInt16> TabControl::GetPageIDs() const
+{
+ std::vector<sal_uInt16> aIDs;
+ for (auto itr = mpTabCtrlData->maItemList.begin(), itrEnd = mpTabCtrlData->maItemList.end();
+ itr != itrEnd; ++itr)
+ {
+ aIDs.push_back(itr->mnId);
+ }
+
+ return aIDs;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */