16#include <com/sun/star/beans/PropertyValue.hpp>
21 : GenericDialogController(pWindow,
"cui/ui/diagramdialog.ui",
"DiagramDialog")
22 , m_rDiagram(rDiagram)
24 , mpBtnCancel(m_xBuilder->weld_button(
"btnCancel"))
25 , mpBtnAdd(m_xBuilder->weld_button(
"btnAdd"))
26 , mpBtnRemove(m_xBuilder->weld_button(
"btnRemove"))
27 , mpTreeDiagram(m_xBuilder->weld_tree_view(
"treeDiagram"))
28 , mpTextAdd(m_xBuilder->weld_text_view(
"textAdd"))
60 if (!m_rDiagram.isDiagram())
63 OUString sText = mpTextAdd->get_text();
64 const std::shared_ptr< svx::diagram::IDiagramHelper >& pDiagramHelper(m_rDiagram.getDiagramHelper());
66 if (pDiagramHelper && !sText.isEmpty())
68 SdrModel& rDrawModel(m_rDiagram.getSdrModelFromSdrObject());
75 aStartState = pDiagramHelper->extractDiagramDataState();
78 OUString sNodeId = pDiagramHelper->addNode(sText);
89 std::unique_ptr<weld::TreeIter> pEntry(mpTreeDiagram->make_iterator());
90 mpTreeDiagram->insert(
nullptr, -1, &sText, &sNodeId,
nullptr,
nullptr,
false, pEntry.get());
91 mpTreeDiagram->select(*pEntry);
98 if (!m_rDiagram.isDiagram())
101 std::unique_ptr<weld::TreeIter> pEntry(mpTreeDiagram->make_iterator());
102 const std::shared_ptr< svx::diagram::IDiagramHelper >& pDiagramHelper(m_rDiagram.getDiagramHelper());
104 if (pDiagramHelper && mpTreeDiagram->get_selected(pEntry.get()))
106 SdrModel& rDrawModel(m_rDiagram.getSdrModelFromSdrObject());
113 aStartState = pDiagramHelper->extractDiagramDataState();
116 if (pDiagramHelper->removeNode(mpTreeDiagram->get_id(*pEntry)))
123 m_rDiagram, aStartState));
127 mpTreeDiagram->remove(*pEntry);
143 auto aItems = pDiagramHelper->getChildren(rParentId);
144 for (
auto& aItem : aItems)
146 std::unique_ptr<weld::TreeIter> pEntry(
mpTreeDiagram->make_iterator());
147 mpTreeDiagram->insert(pParent, -1, &aItem.second, &aItem.first,
nullptr,
nullptr,
false,
IMPL_LINK_NOARG(DiagramDialog, OnAddCancel, weld::Button &, void)
Reference< XExecutableDialog > m_xDialog
std::unique_ptr< weld::Button > mpBtnRemove
std::unique_ptr< weld::TreeView > mpTreeDiagram
DiagramDialog(weld::Window *pWindow, SdrObjGroup &rDiagram)
std::unique_ptr< weld::Button > mpBtnAdd
void populateTree(const weld::TreeIter *pParent, const OUString &rParentId)
virtual ~DiagramDialog() override
std::unique_ptr< weld::Button > mpBtnCancel
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
SdrUndoFactory & GetSdrUndoFactory() const
bool IsUndoEnabled() const
virtual const std::shared_ptr< svx::diagram::IDiagramHelper > & getDiagramHelper() const override
virtual std::unique_ptr< SdrUndoAction > CreateUndoDiagramModelData(SdrObject &rObject, std::shared_ptr< svx::diagram::DiagramDataState > &rStartState)
virtual void expand_row(const TreeIter &rIter)=0
virtual void all_foreach(const std::function< bool(TreeIter &)> &func)=0
#define LINK(Instance, Class, Member)
bool dispatchCommand(const OUString &rCommand, const uno::Reference< css::frame::XFrame > &rFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const uno::Reference< css::frame::XDispatchResultListener > &rListener)
std::shared_ptr< DiagramDataState > DiagramDataStatePtr