diff options
Diffstat (limited to 'cui/source')
-rw-r--r-- | cui/source/dialogs/DiagramDialog.cxx | 20 | ||||
-rw-r--r-- | cui/source/inc/DiagramDialog.hxx | 4 |
2 files changed, 24 insertions, 0 deletions
diff --git a/cui/source/dialogs/DiagramDialog.cxx b/cui/source/dialogs/DiagramDialog.cxx index c48e8f58089d..f3b84c0fcc4e 100644 --- a/cui/source/dialogs/DiagramDialog.cxx +++ b/cui/source/dialogs/DiagramDialog.cxx @@ -9,7 +9,9 @@ #include <DiagramDialog.hxx> +#include <comphelper/dispatchcommand.hxx> #include <svx/DiagramDataInterface.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> DiagramDialog::DiagramDialog(weld::Window* pWindow, std::shared_ptr<DiagramDataInterface> pDiagramData) @@ -17,8 +19,12 @@ DiagramDialog::DiagramDialog(weld::Window* pWindow, , mpDiagramData(pDiagramData) , mpBtnOk(m_xBuilder->weld_button("btnOk")) , mpBtnCancel(m_xBuilder->weld_button("btnCancel")) + , mpBtnAdd(m_xBuilder->weld_button("btnAdd")) , mpTreeDiagram(m_xBuilder->weld_tree_view("treeDiagram")) + , mpTextAdd(m_xBuilder->weld_text_view("textAdd")) { + mpBtnAdd->connect_clicked(LINK(this, DiagramDialog, OnAddClick)); + populateTree(nullptr, OUString()); // expand all items @@ -29,6 +35,20 @@ DiagramDialog::DiagramDialog(weld::Window* pWindow, }); } +IMPL_LINK_NOARG(DiagramDialog, OnAddClick, weld::Button&, void) +{ + OUString sText = mpTextAdd->get_text(); + if (!sText.isEmpty()) + { + std::unique_ptr<weld::TreeIter> pEntry(mpTreeDiagram->make_iterator()); + mpTreeDiagram->insert(nullptr, -1, &sText, nullptr, nullptr, nullptr, nullptr, false, + pEntry.get()); + mpTreeDiagram->select(*pEntry); + mpDiagramData->addNode(sText); + comphelper::dispatchCommand(".uno:RegenerateDiagram", {}); + } +} + void DiagramDialog::populateTree(weld::TreeIter* pParent, const OUString& rParentId) { auto aItems = mpDiagramData->getChildren(rParentId); diff --git a/cui/source/inc/DiagramDialog.hxx b/cui/source/inc/DiagramDialog.hxx index ec47de6414bd..c1ce3316427e 100644 --- a/cui/source/inc/DiagramDialog.hxx +++ b/cui/source/inc/DiagramDialog.hxx @@ -26,7 +26,11 @@ private: std::shared_ptr<DiagramDataInterface> mpDiagramData; std::unique_ptr<weld::Button> mpBtnOk; std::unique_ptr<weld::Button> mpBtnCancel; + std::unique_ptr<weld::Button> mpBtnAdd; std::unique_ptr<weld::TreeView> mpTreeDiagram; + std::unique_ptr<weld::TextView> mpTextAdd; + + DECL_LINK(OnAddClick, weld::Button&, void); void populateTree(weld::TreeIter* pParent, const OUString& rParentId); }; |