[Libreoffice-commits] core.git: 9 commits - chart2/Library_chartcontroller.mk chart2/source uitest/calc_tests uitest/uitest
Markus Mohrhard
markus.mohrhard at googlemail.com
Sat Jul 16 16:29:29 UTC 2016
chart2/Library_chartcontroller.mk | 1
chart2/source/controller/inc/ChartController.hxx | 2
chart2/source/controller/inc/ChartWindow.hxx | 84 ++++++
chart2/source/controller/inc/uiobject.hxx | 70 +++++
chart2/source/controller/main/ChartController.cxx | 5
chart2/source/controller/main/ChartController_Window.cxx | 5
chart2/source/controller/main/ChartWindow.cxx | 11
chart2/source/controller/main/ChartWindow.hxx | 80 ------
chart2/source/controller/uitest/uiobject.cxx | 196 +++++++++++++++
uitest/calc_tests/edit_chart.py | 75 +++++
uitest/uitest/test.py | 15 +
11 files changed, 461 insertions(+), 83 deletions(-)
New commits:
commit bdf577a1b346b2494e6073810e0c059cdbae24af
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Jul 16 18:17:57 2016 +0200
uitest: remove some debug output from new test
Change-Id: Ib1342d4ea81885e4ca434f6f5f263af9a8a04e25
diff --git a/uitest/calc_tests/edit_chart.py b/uitest/calc_tests/edit_chart.py
index 63b7aed..b434503 100644
--- a/uitest/calc_tests/edit_chart.py
+++ b/uitest/calc_tests/edit_chart.py
@@ -48,8 +48,6 @@ class CalcChartEditUIDemo(UITestCase):
xNextBtn = xChartDlg.getChild("finish")
xNextBtn.executeAction("CLICK", tuple())
- xNextBtn = None
- xChartDlg = None
xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
@@ -59,11 +57,8 @@ class CalcChartEditUIDemo(UITestCase):
xChartMainTop = self.xUITest.getTopFocusWindow()
xChartMain = xChartMainTop.getChild("chart_window")
- print(xChartMainTop.getChildren())
- print(xChartMain.getChildren())
xSeriesObj = xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
- # xChartMain.executeAction("SELECT", mkPropertyValues({"NAME": "CID/D=0:CS=0:CT=0:Series=0"}))
self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatDataSeries"}))
xSeriesFormatDlg = self.xUITest.getTopFocusWindow()
commit 129e09efba3d5b7f8d6e3b43cb24cd4131398023
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Jul 16 18:15:06 2016 +0200
uitest: extend chart edit test to change chart through dialog
Change-Id: I9ffdddff84e290a4df25067be5bf574fac273ce7
diff --git a/uitest/calc_tests/edit_chart.py b/uitest/calc_tests/edit_chart.py
index 6f24ff4..63b7aed 100644
--- a/uitest/calc_tests/edit_chart.py
+++ b/uitest/calc_tests/edit_chart.py
@@ -33,7 +33,7 @@ class CalcChartEditUIDemo(UITestCase):
xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C2"}))
- def test_activate_chart(self):
+ def test_select_secondary_axis(self):
self.ui_test.create_doc_in_start_center("calc")
@@ -62,9 +62,16 @@ class CalcChartEditUIDemo(UITestCase):
print(xChartMainTop.getChildren())
print(xChartMain.getChildren())
- xChartMain.executeAction("SELECT", mkPropertyValues({"NAME": "CID/D=0:CS=0:CT=0:Series=0"}))
+ xSeriesObj = xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0")
+ # xChartMain.executeAction("SELECT", mkPropertyValues({"NAME": "CID/D=0:CS=0:CT=0:Series=0"}))
+ self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatDataSeries"}))
- time.sleep(10)
+ xSeriesFormatDlg = self.xUITest.getTopFocusWindow()
+ xAxis2 = xSeriesFormatDlg.getChild("RBT_OPT_AXIS_2")
+ xAxis2.executeAction("CLICK", tuple())
+
+ xCancelBtn = xSeriesFormatDlg.getChild("ok")
+ xCancelBtn.executeAction("CLICK", tuple())
xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
commit d2b2278aaba7f78afb1d8d3bf8fdb199f5a8cdbb
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Jul 16 18:07:36 2016 +0200
uitest: provide wrapper for chart objects
This allows now to operate on chart objects and call commands on them.
Change-Id: I399b275c563deb507aaf4f3f49373871e733af91
diff --git a/chart2/source/controller/inc/uiobject.hxx b/chart2/source/controller/inc/uiobject.hxx
index e458b6d..f5a2ede 100644
--- a/chart2/source/controller/inc/uiobject.hxx
+++ b/chart2/source/controller/inc/uiobject.hxx
@@ -14,6 +14,33 @@
#include "ChartWindow.hxx"
+class ChartUIObject : public UIObject
+{
+public:
+
+ ChartUIObject(VclPtr<chart::ChartWindow> xChartWindow,
+ const OUString& rCID);
+
+ StringMap get_state() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
+
+ virtual std::set<OUString> get_children() const override;
+
+ virtual OUString get_type() const override;
+
+private:
+
+ OUString maCID;
+ VclPtr<chart::ChartWindow> mxChartWindow;
+ std::vector<std::unique_ptr<OUString>> maCommands;
+
+ DECL_LINK_TYPED(PostCommand, void*, void);
+};
+
class ChartWindowUIObject : public WindowUIObject
{
VclPtr<chart::ChartWindow> mxChartWindow;
@@ -35,7 +62,7 @@ public:
protected:
- virtual OUString get_name() const;
+ virtual OUString get_name() const override;
};
#endif
diff --git a/chart2/source/controller/uitest/uiobject.cxx b/chart2/source/controller/uitest/uiobject.cxx
index d686d89..51e33bf 100644
--- a/chart2/source/controller/uitest/uiobject.cxx
+++ b/chart2/source/controller/uitest/uiobject.cxx
@@ -14,8 +14,82 @@
#include "ObjectHierarchy.hxx"
#include "chartview/ExplicitValueProvider.hxx"
+#include <vcl/svapp.hxx>
+
#include <algorithm>
+ChartUIObject::ChartUIObject(VclPtr<chart::ChartWindow> xChartWindow,
+ const OUString& rCID):
+ maCID(rCID),
+ mxChartWindow(xChartWindow)
+{
+}
+
+StringMap ChartUIObject::get_state()
+{
+ StringMap aMap;
+ aMap["CID"] = maCID;
+
+ return aMap;
+}
+
+void ChartUIObject::execute(const OUString& rAction,
+ const StringMap& rParameters)
+{
+ if (rAction == "SELECT")
+ {
+ std::unique_ptr<UIObject> pWindow = mxChartWindow->GetUITestFactory()(mxChartWindow.get());
+
+ StringMap aParams;
+ aParams["NAME"] = maCID;
+ pWindow->execute(rAction, aParams);
+ }
+ else if (rAction == "COMMAND")
+ {
+ // first select object
+ std::unique_ptr<UIObject> pWindow = mxChartWindow->GetUITestFactory()(mxChartWindow.get());
+
+ StringMap aParams;
+ aParams["NAME"] = maCID;
+ pWindow->execute("SELECT", aParams);
+
+ auto itr = rParameters.find("COMMAND");
+ if (itr == rParameters.end())
+ throw css::uno::RuntimeException("missing COMMAND parameter");
+
+ maCommands.emplace_back(new OUString(itr->second));
+ OUString* pCommand = maCommands.rbegin()->get();
+
+ Application::PostUserEvent(LINK(this, ChartUIObject, PostCommand), pCommand);
+ }
+}
+
+IMPL_LINK_TYPED(ChartUIObject, PostCommand, void*, pCommand, void)
+{
+ css::util::URL aURL;
+ aURL.Path = *static_cast<OUString*>(pCommand);
+ mxChartWindow->GetController()->dispatch(aURL, css::uno::Sequence<css::beans::PropertyValue>());
+}
+
+std::unique_ptr<UIObject> ChartUIObject::get_child(const OUString& rID)
+{
+ std::unique_ptr<UIObject> pWindow = mxChartWindow->GetUITestFactory()(mxChartWindow.get());
+
+ return pWindow->get_child(rID);
+}
+
+std::set<OUString> ChartUIObject::get_children() const
+{
+ std::unique_ptr<UIObject> pWindow = mxChartWindow->GetUITestFactory()(mxChartWindow.get());
+
+ return pWindow->get_children();
+}
+
+OUString ChartUIObject::get_type() const
+{
+ return OUString("ChartUIObject for type: ");
+}
+
ChartWindowUIObject::ChartWindowUIObject(VclPtr<chart::ChartWindow> xChartWindow):
WindowUIObject(xChartWindow),
mxChartWindow(xChartWindow)
@@ -59,9 +133,12 @@ void ChartWindowUIObject::execute(const OUString& rAction,
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;
+ if (chart::ObjectIdentifier::isCID(rID))
+ return std::unique_ptr<UIObject>(new ChartUIObject(mxChartWindow, rID));
+
+ throw css::uno::RuntimeException("unknown child");
}
namespace {
commit 1a20e663322d0c37e985df1b9cefdb4827ed74ef
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Jul 16 17:35:29 2016 +0200
uitest: provide a way to open a dialog through an action on an object
This allows for example to open a dialog through clicking on a button or
through a chart command.
Change-Id: Iaca6faa3a1b26f4f677a3a670e2c9891373524d3
diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 05e5c91..4eb8c84 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -49,6 +49,21 @@ class UITest(object):
raise DialogNotExecutedException(command)
+ def execute_dialog_through_action(self, ui_object, action, parameters = None):
+ if parameters is None:
+ parameters = tuple()
+
+ with EventListener(self._xContext, "DialogExecute") as event:
+ ui_object.executeAction(action, parameters)
+ time_ = 0
+ while time_ < 30:
+ if event.executed:
+ time.sleep(DEFAULT_SLEEP)
+ return
+ time_ += DEFAULT_SLEEP
+ time.sleep(DEFAULT_SLEEP)
+ raise DialogNotExecutedException(command)
+
def create_doc_in_start_center(self, app):
xStartCenter = self._xUITest.getTopFocusWindow()
xBtn = xStartCenter.getChild(app + "_all")
commit a980b6c8aee6e3f6916dc0dc617f53e70191234c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Jul 15 15:03:39 2016 +0200
no need for this temporary OString
Change-Id: I8b5d69f7e64a83e52a41c285f5ef186a666ccd55
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index a925bbb..4016635 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -1050,7 +1050,7 @@ void SAL_CALL ChartController::layoutEvent(
namespace
{
-bool lcl_isFormatObjectCommand( const OString& aCommand )
+bool lcl_isFormatObjectCommand( const OUString& aCommand )
{
if( aCommand == "MainTitle"
|| aCommand == "SubTitle"
@@ -1146,8 +1146,7 @@ void SAL_CALL ChartController::dispatch(
const uno::Sequence< beans::PropertyValue >& rArgs )
throw (uno::RuntimeException, std::exception)
{
- //@todo avoid OString
- OString aCommand( OUStringToOString( rURL.Path, RTL_TEXTENCODING_ASCII_US ) );
+ OUString aCommand = rURL.Path;
if(aCommand == "Paste")
this->executeDispatch_Paste();
commit 8781dbe09981bbca4b5ed792fdb6c82dc1b17d27
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Jul 15 10:31:39 2016 +0200
uitest: provide all the children for charts
This now also includes legend entries and data points.
Change-Id: I0e4d1f21a20035cd632a7755dbbea17baec4b083
diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx
index 810788f..00833b4 100644
--- a/chart2/source/controller/inc/ChartController.hxx
+++ b/chart2/source/controller/inc/ChartController.hxx
@@ -378,6 +378,8 @@ public:
DECL_LINK_TYPED( NotifyUndoActionHdl, SdrUndoAction*, void );
+ css::uno::Reference<css::uno::XInterface> getChartView();
+
private:
DrawViewWrapper* GetDrawViewWrapper();
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index 40f196f..944e876 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -1969,6 +1969,11 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent )
m_pChartWindow->SetPointer( Pointer( PointerStyle::Arrow ));
}
+css::uno::Reference<css::uno::XInterface> ChartController::getChartView()
+{
+ return m_xChartView;
+}
+
} //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 5ed1dd1..d686d89 100644
--- a/chart2/source/controller/uitest/uiobject.cxx
+++ b/chart2/source/controller/uitest/uiobject.cxx
@@ -12,6 +12,7 @@
#include "ChartWindow.hxx"
#include "ChartController.hxx"
#include "ObjectHierarchy.hxx"
+#include "chartview/ExplicitValueProvider.hxx"
#include <algorithm>
@@ -63,22 +64,42 @@ std::unique_ptr<UIObject> ChartWindowUIObject::get_child(const OUString& /*rID*/
return nullptr;
}
-std::set<OUString> ChartWindowUIObject::get_children() const
-{
- std::set<OUString> aChildren;
+namespace {
- 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()),
+void recursiveAdd(chart::ObjectIdentifier& rID, std::set<OUString>& rChildren, const chart::ObjectHierarchy& rHierarchy)
+{
+ std::vector<chart::ObjectIdentifier> aChildIndentifiers = rHierarchy.getChildren(rID);
+ std::transform(aChildIndentifiers.begin(), aChildIndentifiers.end(), std::inserter(rChildren, rChildren.begin()),
[](const chart::ObjectIdentifier& rObject)
{
return rObject.getObjectCID();
}
);
+ for (chart::ObjectIdentifier& ID: aChildIndentifiers)
+ recursiveAdd(ID, rChildren, rHierarchy);
+}
+
+}
+
+std::set<OUString> ChartWindowUIObject::get_children() const
+{
+ std::set<OUString> aChildren;
+
+ chart::ChartController* pController = mxChartWindow->GetController();
+ if (!pController)
+ return aChildren;
+
+ css::uno::Reference< css::chart2::XChartDocument > xChartDoc( pController->getModel(), css::uno::UNO_QUERY );
+
+ css::uno::Reference<css::uno::XInterface> xChartView = pController->getChartView();
+ chart::ExplicitValueProvider* pValueProvider = chart::ExplicitValueProvider::getExplicitValueProvider( xChartView );
+ chart::ObjectHierarchy aHierarchy(xChartDoc, pValueProvider, true);
+ chart::ObjectIdentifier aIdentifier = aHierarchy.getRootNodeOID();
+ aChildren.insert(aIdentifier.getObjectCID());
+
+ recursiveAdd(aIdentifier, aChildren, aHierarchy);
+
return aChildren;
}
commit 01767d5d9d43d4ef4bd948f00a1cd2c113714b20
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Jul 14 22:04:29 2016 +0200
uitest: add first demo for editing the chart
Change-Id: I28e1c4d4726afc97fd1a42fe1d931b195231cb12
diff --git a/uitest/calc_tests/edit_chart.py b/uitest/calc_tests/edit_chart.py
new file mode 100644
index 0000000..6f24ff4
--- /dev/null
+++ b/uitest/calc_tests/edit_chart.py
@@ -0,0 +1,73 @@
+# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#
+# 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/.
+#
+
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+from uitest.framework import UITestCase
+
+import time
+
+class CalcChartEditUIDemo(UITestCase):
+
+ def add_content_to_cell(self, gridwin, cell, content):
+ selectProps = mkPropertyValues({"CELL": cell})
+ gridwin.executeAction("SELECT", selectProps)
+
+ contentProps = mkPropertyValues({"TEXT": content})
+ gridwin.executeAction("TYPE", contentProps)
+
+ def fill_spreadsheet(self):
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ xGridWindow = xCalcDoc.getChild("grid_window")
+
+ self.add_content_to_cell(xGridWindow, "A1", "col1")
+ self.add_content_to_cell(xGridWindow, "B1", "col2")
+ self.add_content_to_cell(xGridWindow, "C1", "col3")
+ self.add_content_to_cell(xGridWindow, "A2", "1")
+ self.add_content_to_cell(xGridWindow, "B2", "3")
+ self.add_content_to_cell(xGridWindow, "C2", "5")
+
+ xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C2"}))
+
+ def test_activate_chart(self):
+
+ self.ui_test.create_doc_in_start_center("calc")
+
+ self.fill_spreadsheet()
+
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ xGridWindow = xCalcDoc.getChild("grid_window")
+
+ self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
+
+ xChartDlg = self.xUITest.getTopFocusWindow()
+
+ xNextBtn = xChartDlg.getChild("finish")
+ xNextBtn.executeAction("CLICK", tuple())
+ xNextBtn = None
+ xChartDlg = None
+
+ xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
+
+ xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
+
+ xGridWindow.executeAction("ACTIVATE", tuple())
+
+ xChartMainTop = self.xUITest.getTopFocusWindow()
+ xChartMain = xChartMainTop.getChild("chart_window")
+ print(xChartMainTop.getChildren())
+ print(xChartMain.getChildren())
+
+ xChartMain.executeAction("SELECT", mkPropertyValues({"NAME": "CID/D=0:CS=0:CT=0:Series=0"}))
+
+ time.sleep(10)
+
+ xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
+
+ self.ui_test.close_doc()
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 0f03a801318501a4904dbe7c1d09d0b9dd1cb852
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Jul 14 22:04:04 2016 +0200
uitest: some initial work on the chart selection
Change-Id: I3317eba5383206de6f619da548ee3047861eef07
diff --git a/chart2/source/controller/inc/ChartWindow.hxx b/chart2/source/controller/inc/ChartWindow.hxx
index ca2bc71..4cbc698 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 d848800..ed053f67 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 a343b50..5ed1dd1 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;
}
commit b1e1b38349d2c28420598f3b8612682989f5db90
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Jul 14 12:33:28 2016 +0200
uitest: add initial support for selecting chart elements
Change-Id: I3af11d44067618b5188f3dbf4abccc171dd98d0c
diff --git a/chart2/Library_chartcontroller.mk b/chart2/Library_chartcontroller.mk
index 080eef3..1f95bc0 100644
--- a/chart2/Library_chartcontroller.mk
+++ b/chart2/Library_chartcontroller.mk
@@ -199,6 +199,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcontroller,\
chart2/source/controller/sidebar/ChartSeriesPanel \
chart2/source/controller/sidebar/ChartSidebarModifyListener \
chart2/source/controller/sidebar/ChartSidebarSelectionListener \
+ chart2/source/controller/uitest/uiobject \
))
# Runtime dependency for unit-tests
diff --git a/chart2/source/controller/main/ChartWindow.hxx b/chart2/source/controller/inc/ChartWindow.hxx
similarity index 97%
rename from chart2/source/controller/main/ChartWindow.hxx
rename to chart2/source/controller/inc/ChartWindow.hxx
index 1ad1507..ca2bc71 100644
--- a/chart2/source/controller/main/ChartWindow.hxx
+++ b/chart2/source/controller/inc/ChartWindow.hxx
@@ -65,6 +65,8 @@ public:
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
+ virtual FactoryFunction GetUITestFactory() const override;
+
private:
ChartController* m_pWindowController;
bool m_bInPaint;
diff --git a/chart2/source/controller/inc/uiobject.hxx b/chart2/source/controller/inc/uiobject.hxx
new file mode 100644
index 0000000..e458b6d
--- /dev/null
+++ b/chart2/source/controller/inc/uiobject.hxx
@@ -0,0 +1,43 @@
+/* -*- 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 INCLUDED_CHART2_SOURCE_CONTROLLER_INC_UIOBJECT_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_INC_UIOBJECT_HXX
+
+#include <vcl/uitest/uiobject.hxx>
+
+#include "ChartWindow.hxx"
+
+class ChartWindowUIObject : public WindowUIObject
+{
+ VclPtr<chart::ChartWindow> mxChartWindow;
+
+public:
+
+ ChartWindowUIObject(VclPtr<chart::ChartWindow> xChartWindow);
+
+ virtual StringMap get_state() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
+
+ virtual std::set<OUString> get_children() const override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+protected:
+
+ virtual OUString get_name() const;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/main/ChartWindow.cxx b/chart2/source/controller/main/ChartWindow.cxx
index 2372119..d848800 100644
--- a/chart2/source/controller/main/ChartWindow.cxx
+++ b/chart2/source/controller/main/ChartWindow.cxx
@@ -20,6 +20,7 @@
#include "ChartWindow.hxx"
#include "ChartController.hxx"
#include "HelpIds.hrc"
+#include "uiobject.hxx"
#include <vcl/help.hxx>
#include <vcl/openglwin.hxx>
@@ -306,6 +307,11 @@ void ChartWindow::Invalidate( const vcl::Region& rRegion, InvalidateFlags nFlags
}
}
+FactoryFunction ChartWindow::GetUITestFactory() const
+{
+ return ChartWindowUIObject::create;
+}
+
} //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
new file mode 100644
index 0000000..a343b50
--- /dev/null
+++ b/chart2/source/controller/uitest/uiobject.cxx
@@ -0,0 +1,56 @@
+/* -*- 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"
+
+ChartWindowUIObject::ChartWindowUIObject(VclPtr<chart::ChartWindow> xChartWindow):
+ WindowUIObject(xChartWindow),
+ mxChartWindow(xChartWindow)
+{
+}
+
+StringMap ChartWindowUIObject::get_state()
+{
+ StringMap aMap = WindowUIObject::get_state();
+
+ return aMap;
+}
+
+void ChartWindowUIObject::execute(const OUString& rAction,
+ const StringMap& rParameters)
+{
+ WindowUIObject::execute(rAction, rParameters);
+}
+
+std::unique_ptr<UIObject> ChartWindowUIObject::get_child(const OUString& rID)
+{
+ return nullptr;
+}
+
+std::set<OUString> ChartWindowUIObject::get_children() const
+{
+ std::set<OUString> aChildren;
+
+ return aChildren;
+}
+
+std::unique_ptr<UIObject> ChartWindowUIObject::create(vcl::Window* pWindow)
+{
+ chart::ChartWindow* pChartWindow = dynamic_cast<chart::ChartWindow*>(pWindow);
+ assert(pChartWindow);
+
+ return std::unique_ptr<UIObject>(new ChartWindowUIObject(pChartWindow));
+}
+
+OUString ChartWindowUIObject::get_name() const
+{
+ return OUString("ChartWindowUIObject");
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list