diff options
-rw-r--r-- | chart2/source/controller/inc/ChartWindow.hxx | 2 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartWindow.cxx | 5 | ||||
-rw-r--r-- | chart2/source/controller/uitest/uiobject.cxx | 46 |
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; } |