summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-07-14 22:04:04 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-07-16 18:27:13 +0200
commit0f03a801318501a4904dbe7c1d09d0b9dd1cb852 (patch)
tree81c24296791bc0b09a87eaba92c9b1eac0df78b0
parentb1e1b38349d2c28420598f3b8612682989f5db90 (diff)
uitest: some initial work on the chart selection
Change-Id: I3317eba5383206de6f619da548ee3047861eef07
-rw-r--r--chart2/source/controller/inc/ChartWindow.hxx2
-rw-r--r--chart2/source/controller/main/ChartWindow.cxx5
-rw-r--r--chart2/source/controller/uitest/uiobject.cxx46
3 files changed, 51 insertions, 2 deletions
diff --git a/chart2/source/controller/inc/ChartWindow.hxx b/chart2/source/controller/inc/ChartWindow.hxx
index ca2bc710493f..4cbc69810d18 100644
--- a/chart2/source/controller/inc/ChartWindow.hxx
+++ b/chart2/source/controller/inc/ChartWindow.hxx
@@ -67,6 +67,8 @@ public:
virtual FactoryFunction GetUITestFactory() const override;
+ ChartController* GetController();
+
private:
ChartController* m_pWindowController;
bool m_bInPaint;
diff --git a/chart2/source/controller/main/ChartWindow.cxx b/chart2/source/controller/main/ChartWindow.cxx
index d84880017a08..ed053f67b8d4 100644
--- a/chart2/source/controller/main/ChartWindow.cxx
+++ b/chart2/source/controller/main/ChartWindow.cxx
@@ -312,6 +312,11 @@ FactoryFunction ChartWindow::GetUITestFactory() const
return ChartWindowUIObject::create;
}
+ChartController* ChartWindow::GetController()
+{
+ return m_pWindowController;
+}
+
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/uitest/uiobject.cxx b/chart2/source/controller/uitest/uiobject.cxx
index a343b50b2f3a..5ed1dd1b6781 100644
--- a/chart2/source/controller/uitest/uiobject.cxx
+++ b/chart2/source/controller/uitest/uiobject.cxx
@@ -9,6 +9,12 @@
#include "uiobject.hxx"
+#include "ChartWindow.hxx"
+#include "ChartController.hxx"
+#include "ObjectHierarchy.hxx"
+
+#include <algorithm>
+
ChartWindowUIObject::ChartWindowUIObject(VclPtr<chart::ChartWindow> xChartWindow):
WindowUIObject(xChartWindow),
mxChartWindow(xChartWindow)
@@ -19,16 +25,40 @@ StringMap ChartWindowUIObject::get_state()
{
StringMap aMap = WindowUIObject::get_state();
+ chart::ChartController* pController = mxChartWindow->GetController();
+ if (pController)
+ {
+ css::uno::Any aAny = pController->getSelection();
+ OUString aSelectedObject;
+ aAny >>= aSelectedObject;
+ aMap["SelectedObject"] = aSelectedObject;
+ }
+
return aMap;
}
void ChartWindowUIObject::execute(const OUString& rAction,
const StringMap& rParameters)
{
- WindowUIObject::execute(rAction, rParameters);
+ if (rAction == "SELECT")
+ {
+ auto itr = rParameters.find("NAME");
+ if (itr == rParameters.end())
+ throw css::uno::RuntimeException("Missing Parameter 'NAME' for action 'SELECT'");
+
+
+ const OUString& rName = itr->second;
+ css::uno::Any aAny;
+ aAny <<= rName;
+
+ chart::ChartController* pController = mxChartWindow->GetController();
+ pController->select(aAny);
+ }
+ else
+ WindowUIObject::execute(rAction, rParameters);
}
-std::unique_ptr<UIObject> ChartWindowUIObject::get_child(const OUString& rID)
+std::unique_ptr<UIObject> ChartWindowUIObject::get_child(const OUString& /*rID*/)
{
return nullptr;
}
@@ -37,6 +67,18 @@ std::set<OUString> ChartWindowUIObject::get_children() const
{
std::set<OUString> aChildren;
+ css::uno::Reference< css::chart2::XChartDocument > xChartDoc( mxChartWindow->GetController()->getModel(), css::uno::UNO_QUERY );
+ chart::ObjectHierarchy aHierarchy(xChartDoc, nullptr, true);
+ chart::ObjectIdentifier aIdentifier = aHierarchy.getRootNodeOID();
+ aChildren.insert(aIdentifier.getObjectCID());
+ std::vector<chart::ObjectIdentifier> aChildIndentifiers = aHierarchy.getChildren(aIdentifier);
+ std::transform(aChildIndentifiers.begin(), aChildIndentifiers.end(), std::inserter(aChildren, aChildren.begin()),
+ [](const chart::ObjectIdentifier& rObject)
+ {
+ return rObject.getObjectCID();
+ }
+ );
+
return aChildren;
}