[Libreoffice-commits] core.git: 2 commits - include/vcl vcl/inc vcl/source
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Wed Nov 25 08:04:15 UTC 2020
include/vcl/toolkit/svtabbx.hxx | 2
vcl/inc/salvtables.hxx | 358 +++++
vcl/source/app/salvtables.cxx | 2446 +++++++++++++++++++---------------------
vcl/source/treelist/svtabbx.cxx | 49
4 files changed, 1608 insertions(+), 1247 deletions(-)
New commits:
commit 01e54822635b965c068094493294c579af4c4161
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Nov 24 16:31:40 2020 +0100
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Nov 25 09:03:43 2020 +0100
Move SalInstanceTreeView decl to header file
Change-Id: Ie49f4113332de5c4fa825f93dde46bb408187fe4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106536
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 4fca8ff49cc5..cb7ccc7b12e3 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -24,6 +24,9 @@
#include <vcl/tabctrl.hxx>
#include <vcl/layout.hxx>
#include "messagedialog.hxx"
+#include <vcl/toolkit/svtabbx.hxx>
+#include <vcl/toolkit/svlbitm.hxx>
+#include <o3tl/sorted_vector.hxx>
class SalInstanceBuilder : public weld::Builder
{
@@ -1297,4 +1300,359 @@ public:
virtual ~SalInstanceTextView() override;
};
+class SalInstanceTreeView : public SalInstanceContainer, public virtual weld::TreeView
+{
+private:
+ // owner for UserData
+ std::vector<std::unique_ptr<OUString>> m_aUserData;
+ VclPtr<SvTabListBox> m_xTreeView;
+ SvLBoxButtonData m_aCheckButtonData;
+ SvLBoxButtonData m_aRadioButtonData;
+ // currently expanding parent that logically, but not currently physically,
+ // contain placeholders
+ o3tl::sorted_vector<SvTreeListEntry*> m_aExpandingPlaceHolderParents;
+ // which columns should be custom rendered
+ o3tl::sorted_vector<int> m_aCustomRenders;
+ bool m_bTogglesAsRadio;
+ int m_nSortColumn;
+
+ DECL_LINK(SelectHdl, SvTreeListBox*, void);
+ DECL_LINK(DeSelectHdl, SvTreeListBox*, void);
+ DECL_LINK(DoubleClickHdl, SvTreeListBox*, bool);
+ DECL_LINK(ExpandingHdl, SvTreeListBox*, bool);
+ DECL_LINK(EndDragHdl, HeaderBar*, void);
+ DECL_LINK(HeaderBarClickedHdl, HeaderBar*, void);
+ DECL_LINK(ToggleHdl, SvLBoxButtonData*, void);
+ DECL_LINK(ModelChangedHdl, SvTreeListBox*, void);
+ DECL_LINK(StartDragHdl, SvTreeListBox*, bool);
+ DECL_STATIC_LINK(SalInstanceTreeView, FinishDragHdl, SvTreeListBox*, void);
+ DECL_LINK(EditingEntryHdl, SvTreeListEntry*, bool);
+ typedef std::pair<SvTreeListEntry*, OUString> IterString;
+ DECL_LINK(EditedEntryHdl, IterString, bool);
+ DECL_LINK(VisibleRangeChangedHdl, SvTreeListBox*, void);
+ DECL_LINK(CompareHdl, const SvSortData&, sal_Int32);
+ DECL_LINK(PopupMenuHdl, const CommandEvent&, bool);
+ DECL_LINK(TooltipHdl, const HelpEvent&, bool);
+ DECL_LINK(CustomRenderHdl, svtree_render_args, void);
+ DECL_LINK(CustomMeasureHdl, svtree_measure_args, Size);
+
+ // Each row has a cell for the expander image, (and an optional cell for a
+ // checkbutton if enable_toggle_buttons has been called) which precede
+ // index 0
+ int to_internal_model(int col) const;
+
+ int to_external_model(int col) const;
+
+ bool IsDummyEntry(SvTreeListEntry* pEntry) const;
+
+ SvTreeListEntry* GetPlaceHolderChild(SvTreeListEntry* pEntry) const;
+
+ static void set_font_color(SvTreeListEntry* pEntry, const Color& rColor);
+
+ void AddStringItem(SvTreeListEntry* pEntry, const OUString& rStr, int nCol);
+
+ void do_insert(const weld::TreeIter* pParent, int pos, const OUString* pStr,
+ const OUString* pId, const OUString* pIconName,
+ const VirtualDevice* pImageSurface, bool bChildrenOnDemand, weld::TreeIter* pRet,
+ bool bIsSeparator);
+
+ void update_checkbutton_column_width(SvTreeListEntry* pEntry);
+
+ void InvalidateModelEntry(SvTreeListEntry* pEntry);
+
+ void do_set_toggle(SvTreeListEntry* pEntry, TriState eState, int col);
+
+ static TriState do_get_toggle(SvTreeListEntry* pEntry, int col);
+
+ TriState get_toggle(SvTreeListEntry* pEntry, int col) const;
+
+ void set_toggle(SvTreeListEntry* pEntry, TriState eState, int col);
+
+ bool get_text_emphasis(SvTreeListEntry* pEntry, int col) const;
+
+ void set_header_item_width(const std::vector<int>& rWidths);
+
+public:
+ SalInstanceTreeView(SvTabListBox* pTreeView, SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+
+ virtual void connect_query_tooltip(const Link<const weld::TreeIter&, OUString>& rLink) override;
+
+ virtual void columns_autosize() override;
+
+ virtual void freeze() override;
+
+ virtual void thaw() override;
+
+ virtual void set_column_fixed_widths(const std::vector<int>& rWidths) override;
+
+ virtual void set_column_editables(const std::vector<bool>& rEditables) override;
+
+ virtual void set_centered_column(int nCol) override;
+
+ virtual int get_column_width(int nColumn) const override;
+
+ virtual OUString get_column_title(int nColumn) const override;
+
+ virtual void set_column_title(int nColumn, const OUString& rTitle) override;
+
+ virtual void set_column_custom_renderer(int nColumn, bool bEnable) override;
+
+ virtual void queue_draw() override;
+
+ virtual void show() override;
+
+ virtual void hide() override;
+
+ virtual void insert(const weld::TreeIter* pParent, int pos, const OUString* pStr,
+ const OUString* pId, const OUString* pIconName,
+ VirtualDevice* pImageSurface, bool bChildrenOnDemand,
+ weld::TreeIter* pRet) override;
+
+ virtual void insert_separator(int pos, const OUString& /*rId*/) override;
+
+ virtual void
+ bulk_insert_for_each(int nSourceCount,
+ const std::function<void(weld::TreeIter&, int nSourceIndex)>& func,
+ const std::vector<int>* pFixedWidths = nullptr) override;
+
+ virtual void set_font_color(int pos, const Color& rColor) override;
+
+ virtual void set_font_color(const weld::TreeIter& rIter, const Color& rColor) override;
+
+ virtual void remove(int pos) override;
+
+ virtual int find_text(const OUString& rText) const override;
+
+ virtual int find_id(const OUString& rId) const override;
+
+ virtual void swap(int pos1, int pos2) override;
+
+ virtual void clear() override;
+
+ virtual int n_children() const override;
+
+ virtual int iter_n_children(const weld::TreeIter& rIter) const override;
+
+ virtual void select(int pos) override;
+
+ virtual int get_cursor_index() const override;
+
+ virtual void set_cursor(int pos) override;
+
+ virtual void scroll_to_row(int pos) override;
+
+ virtual bool is_selected(int pos) const override;
+
+ virtual void unselect(int pos) override;
+
+ virtual std::vector<int> get_selected_rows() const override;
+
+ OUString get_text(SvTreeListEntry* pEntry, int col) const;
+
+ virtual OUString get_text(int pos, int col = -1) const override;
+
+ void set_text(SvTreeListEntry* pEntry, const OUString& rText, int col);
+
+ virtual void set_text(int pos, const OUString& rText, int col = -1) override;
+
+ void set_sensitive(SvTreeListEntry* pEntry, bool bSensitive, int col);
+
+ using SalInstanceWidget::set_sensitive;
+
+ virtual void set_sensitive(int pos, bool bSensitive, int col = -1) override;
+
+ virtual void set_sensitive(const weld::TreeIter& rIter, bool bSensitive, int col = -1) override;
+
+ virtual TriState get_toggle(int pos, int col = -1) const override;
+
+ virtual TriState get_toggle(const weld::TreeIter& rIter, int col = -1) const override;
+
+ virtual void enable_toggle_buttons(weld::ColumnToggleType eType) override;
+
+ virtual void set_toggle(int pos, TriState eState, int col = -1) override;
+
+ virtual void set_toggle(const weld::TreeIter& rIter, TriState eState, int col = -1) override;
+
+ virtual void set_extra_row_indent(const weld::TreeIter& rIter, int nIndentLevel) override;
+
+ void set_text_emphasis(SvTreeListEntry* pEntry, bool bOn, int col = -1);
+
+ virtual void set_text_emphasis(const weld::TreeIter& rIter, bool bOn, int col) override;
+
+ virtual void set_text_emphasis(int pos, bool bOn, int col) override;
+
+ virtual bool get_text_emphasis(const weld::TreeIter& rIter, int col) const override;
+
+ virtual bool get_text_emphasis(int pos, int col) const override;
+
+ void set_text_align(SvTreeListEntry* pEntry, double fAlign, int col);
+
+ virtual void set_text_align(const weld::TreeIter& rIter, double fAlign, int col) override;
+
+ virtual void set_text_align(int pos, double fAlign, int col) override;
+
+ virtual void connect_editing(const Link<const weld::TreeIter&, bool>& rStartLink,
+ const Link<const iter_string&, bool>& rEndLink) override;
+
+ virtual void start_editing(const weld::TreeIter& rIter) override;
+
+ virtual void end_editing() override;
+
+ void set_image(SvTreeListEntry* pEntry, const Image& rImage, int col);
+
+ virtual void set_image(int pos, const OUString& rImage, int col = -1) override;
+
+ virtual void set_image(int pos, const css::uno::Reference<css::graphic::XGraphic>& rImage,
+ int col = -1) override;
+
+ virtual void set_image(int pos, VirtualDevice& rImage, int col = -1) override;
+
+ virtual void set_image(const weld::TreeIter& rIter, const OUString& rImage,
+ int col = -1) override;
+
+ virtual void set_image(const weld::TreeIter& rIter,
+ const css::uno::Reference<css::graphic::XGraphic>& rImage,
+ int col = -1) override;
+
+ virtual void set_image(const weld::TreeIter& rIter, VirtualDevice& rImage,
+ int col = -1) override;
+
+ const OUString* getEntryData(int index) const;
+
+ virtual OUString get_id(int pos) const override;
+
+ void set_id(SvTreeListEntry* pEntry, const OUString& rId);
+
+ virtual void set_id(int pos, const OUString& rId) override;
+
+ virtual int get_selected_index() const override;
+
+ virtual OUString get_selected_text() const override;
+
+ virtual OUString get_selected_id() const override;
+
+ virtual std::unique_ptr<weld::TreeIter> make_iterator(const weld::TreeIter* pOrig
+ = nullptr) const override;
+
+ virtual void copy_iterator(const weld::TreeIter& rSource, weld::TreeIter& rDest) const override;
+
+ virtual bool get_selected(weld::TreeIter* pIter) const override;
+
+ virtual bool get_cursor(weld::TreeIter* pIter) const override;
+
+ virtual void set_cursor(const weld::TreeIter& rIter) override;
+
+ virtual bool get_iter_first(weld::TreeIter& rIter) const override;
+
+ virtual bool iter_next_sibling(weld::TreeIter& rIter) const override;
+
+ virtual bool iter_previous_sibling(weld::TreeIter& rIter) const override;
+
+ virtual bool iter_next(weld::TreeIter& rIter) const override;
+
+ virtual bool iter_previous(weld::TreeIter& rIter) const override;
+
+ virtual bool iter_children(weld::TreeIter& rIter) const override;
+
+ virtual bool iter_parent(weld::TreeIter& rIter) const override;
+
+ virtual void remove(const weld::TreeIter& rIter) override;
+
+ virtual void select(const weld::TreeIter& rIter) override;
+
+ virtual void scroll_to_row(const weld::TreeIter& rIter) override;
+
+ virtual void unselect(const weld::TreeIter& rIter) override;
+
+ virtual int get_iter_depth(const weld::TreeIter& rIter) const override;
+
+ virtual bool iter_has_child(const weld::TreeIter& rIter) const override;
+
+ virtual bool get_row_expanded(const weld::TreeIter& rIter) const override;
+
+ virtual bool get_children_on_demand(const weld::TreeIter& rIter) const override;
+
+ virtual void set_children_on_demand(const weld::TreeIter& rIter,
+ bool bChildrenOnDemand) override;
+
+ virtual void expand_row(const weld::TreeIter& rIter) override;
+
+ virtual void collapse_row(const weld::TreeIter& rIter) override;
+
+ virtual OUString get_text(const weld::TreeIter& rIter, int col = -1) const override;
+
+ virtual void set_text(const weld::TreeIter& rIter, const OUString& rText,
+ int col = -1) override;
+
+ virtual OUString get_id(const weld::TreeIter& rIter) const override;
+
+ virtual void set_id(const weld::TreeIter& rIter, const OUString& rId) override;
+
+ virtual void enable_drag_source(rtl::Reference<TransferDataContainer>& rHelper,
+ sal_uInt8 eDNDConstants) override;
+
+ virtual void set_selection_mode(SelectionMode eMode) override;
+
+ virtual void all_foreach(const std::function<bool(weld::TreeIter&)>& func) override;
+
+ virtual void selected_foreach(const std::function<bool(weld::TreeIter&)>& func) override;
+
+ virtual void visible_foreach(const std::function<bool(weld::TreeIter&)>& func) override;
+
+ virtual void connect_visible_range_changed(const Link<weld::TreeView&, void>& rLink) override;
+
+ virtual void remove_selection() override;
+
+ virtual bool is_selected(const weld::TreeIter& rIter) const override;
+
+ virtual int get_iter_index_in_parent(const weld::TreeIter& rIter) const override;
+
+ virtual int iter_compare(const weld::TreeIter& a, const weld::TreeIter& b) const override;
+
+ virtual void move_subtree(weld::TreeIter& rNode, const weld::TreeIter* pNewParent,
+ int nIndexInNewParent) override;
+
+ virtual int count_selected_rows() const override;
+
+ virtual int get_height_rows(int nRows) const override;
+
+ virtual void make_sorted() override;
+
+ virtual void set_sort_func(
+ const std::function<int(const weld::TreeIter&, const weld::TreeIter&)>& func) override;
+
+ virtual void make_unsorted() override;
+
+ virtual void set_sort_order(bool bAscending) override;
+
+ virtual bool get_sort_order() const override;
+
+ virtual void set_sort_indicator(TriState eState, int col) override;
+
+ virtual TriState get_sort_indicator(int col) const override;
+
+ virtual int get_sort_column() const override;
+
+ virtual void set_sort_column(int nColumn) override;
+
+ SvTabListBox& getTreeView();
+
+ virtual bool get_dest_row_at_pos(const Point& rPos, weld::TreeIter* pResult,
+ bool bDnDMode) override;
+
+ virtual void unset_drag_dest_row() override;
+
+ virtual tools::Rectangle get_row_area(const weld::TreeIter& rIter) const override;
+
+ virtual TreeView* get_drag_source() const override;
+
+ virtual int vadjustment_get_value() const override;
+
+ virtual void vadjustment_set_value(int nValue) override;
+
+ void set_show_expanders(bool bShow) override;
+
+ virtual ~SalInstanceTreeView() override;
+};
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index c1421562d2c0..4483e087c1e5 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -3323,1523 +3323,1478 @@ public:
};
}
-class SalInstanceTreeView : public SalInstanceContainer, public virtual weld::TreeView
+// Each row has a cell for the expander image, (and an optional cell for a
+// checkbutton if enable_toggle_buttons has been called) which precede
+// index 0
+int SalInstanceTreeView::to_internal_model(int col) const
{
-private:
- // owner for UserData
- std::vector<std::unique_ptr<OUString>> m_aUserData;
- VclPtr<SvTabListBox> m_xTreeView;
- SvLBoxButtonData m_aCheckButtonData;
- SvLBoxButtonData m_aRadioButtonData;
- // currently expanding parent that logically, but not currently physically,
- // contain placeholders
- o3tl::sorted_vector<SvTreeListEntry*> m_aExpandingPlaceHolderParents;
- // which columns should be custom rendered
- o3tl::sorted_vector<int> m_aCustomRenders;
- bool m_bTogglesAsRadio;
- int m_nSortColumn;
+ if (m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN)
+ ++col; // skip checkbutton column
+ ++col; //skip expander column
+ return col;
+}
- DECL_LINK(SelectHdl, SvTreeListBox*, void);
- DECL_LINK(DeSelectHdl, SvTreeListBox*, void);
- DECL_LINK(DoubleClickHdl, SvTreeListBox*, bool);
- DECL_LINK(ExpandingHdl, SvTreeListBox*, bool);
- DECL_LINK(EndDragHdl, HeaderBar*, void);
- DECL_LINK(HeaderBarClickedHdl, HeaderBar*, void);
- DECL_LINK(ToggleHdl, SvLBoxButtonData*, void);
- DECL_LINK(ModelChangedHdl, SvTreeListBox*, void);
- DECL_LINK(StartDragHdl, SvTreeListBox*, bool);
- DECL_STATIC_LINK(SalInstanceTreeView, FinishDragHdl, SvTreeListBox*, void);
- DECL_LINK(EditingEntryHdl, SvTreeListEntry*, bool);
- typedef std::pair<SvTreeListEntry*, OUString> IterString;
- DECL_LINK(EditedEntryHdl, IterString, bool);
- DECL_LINK(VisibleRangeChangedHdl, SvTreeListBox*, void);
- DECL_LINK(CompareHdl, const SvSortData&, sal_Int32);
- DECL_LINK(PopupMenuHdl, const CommandEvent&, bool);
- DECL_LINK(TooltipHdl, const HelpEvent&, bool);
- DECL_LINK(CustomRenderHdl, svtree_render_args, void);
- DECL_LINK(CustomMeasureHdl, svtree_measure_args, Size);
+int SalInstanceTreeView::to_external_model(int col) const
+{
+ if (m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN)
+ --col; // skip checkbutton column
+ --col; //skip expander column
+ return col;
+}
- // Each row has a cell for the expander image, (and an optional cell for a
- // checkbutton if enable_toggle_buttons has been called) which precede
- // index 0
- int to_internal_model(int col) const
- {
- if (m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN)
- ++col; // skip checkbutton column
- ++col; //skip expander column
- return col;
- }
+bool SalInstanceTreeView::IsDummyEntry(SvTreeListEntry* pEntry) const
+{
+ return m_xTreeView->GetEntryText(pEntry).trim() == "<dummy>";
+}
- int to_external_model(int col) const
+SvTreeListEntry* SalInstanceTreeView::GetPlaceHolderChild(SvTreeListEntry* pEntry) const
+{
+ if (pEntry->HasChildren())
{
- if (m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN)
- --col; // skip checkbutton column
- --col; //skip expander column
- return col;
+ auto pChild = m_xTreeView->FirstChild(pEntry);
+ assert(pChild);
+ if (IsDummyEntry(pChild))
+ return pChild;
}
+ return nullptr;
+}
- bool IsDummyEntry(SvTreeListEntry* pEntry) const
+void SalInstanceTreeView::set_font_color(SvTreeListEntry* pEntry, const Color& rColor)
+{
+ if (rColor == COL_AUTO)
+ pEntry->SetTextColor(std::optional<Color>());
+ else
+ pEntry->SetTextColor(rColor);
+}
+
+void SalInstanceTreeView::AddStringItem(SvTreeListEntry* pEntry, const OUString& rStr, int nCol)
+{
+ auto xCell = std::make_unique<SvLBoxString>(rStr);
+ if (m_aCustomRenders.count(nCol))
+ xCell->SetCustomRender();
+ pEntry->AddItem(std::move(xCell));
+}
+
+void SalInstanceTreeView::do_insert(const weld::TreeIter* pParent, int pos, const OUString* pStr,
+ const OUString* pId, const OUString* pIconName,
+ const VirtualDevice* pImageSurface, bool bChildrenOnDemand,
+ weld::TreeIter* pRet, bool bIsSeparator)
+{
+ disable_notify_events();
+ const SalInstanceTreeIter* pVclIter = static_cast<const SalInstanceTreeIter*>(pParent);
+ SvTreeListEntry* iter = pVclIter ? pVclIter->iter : nullptr;
+ auto nInsertPos = pos == -1 ? TREELIST_APPEND : pos;
+ void* pUserData;
+ if (pId)
{
- return m_xTreeView->GetEntryText(pEntry).trim() == "<dummy>";
+ m_aUserData.emplace_back(std::make_unique<OUString>(*pId));
+ pUserData = m_aUserData.back().get();
}
+ else
+ pUserData = nullptr;
+
+ SvTreeListEntry* pEntry = new SvTreeListEntry;
+ if (bIsSeparator)
+ pEntry->SetFlags(pEntry->GetFlags() | SvTLEntryFlags::IS_SEPARATOR);
- SvTreeListEntry* GetPlaceHolderChild(SvTreeListEntry* pEntry) const
+ if (m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN)
+ AddStringItem(pEntry, "", -1);
+
+ if (pIconName || pImageSurface)
{
- if (pEntry->HasChildren())
- {
- auto pChild = m_xTreeView->FirstChild(pEntry);
- assert(pChild);
- if (IsDummyEntry(pChild))
- return pChild;
- }
- return nullptr;
+ Image aImage(pIconName ? createImage(*pIconName) : createImage(*pImageSurface));
+ pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage, false));
}
-
- static void set_font_color(SvTreeListEntry* pEntry, const Color& rColor)
+ else
{
- if (rColor == COL_AUTO)
- pEntry->SetTextColor(std::optional<Color>());
- else
- pEntry->SetTextColor(rColor);
+ Image aDummy;
+ pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false));
}
+ if (pStr)
+ AddStringItem(pEntry, *pStr, 0);
+ pEntry->SetUserData(pUserData);
+ m_xTreeView->Insert(pEntry, iter, nInsertPos);
- void AddStringItem(SvTreeListEntry* pEntry, const OUString& rStr, int nCol)
+ if (pRet)
{
- auto xCell = std::make_unique<SvLBoxString>(rStr);
- if (m_aCustomRenders.count(nCol))
- xCell->SetCustomRender();
- pEntry->AddItem(std::move(xCell));
+ SalInstanceTreeIter* pVclRetIter = static_cast<SalInstanceTreeIter*>(pRet);
+ pVclRetIter->iter = pEntry;
}
- void do_insert(const weld::TreeIter* pParent, int pos, const OUString* pStr,
- const OUString* pId, const OUString* pIconName,
- const VirtualDevice* pImageSurface, bool bChildrenOnDemand, weld::TreeIter* pRet,
- bool bIsSeparator)
+ if (bChildrenOnDemand)
{
- disable_notify_events();
- const SalInstanceTreeIter* pVclIter = static_cast<const SalInstanceTreeIter*>(pParent);
- SvTreeListEntry* iter = pVclIter ? pVclIter->iter : nullptr;
- auto nInsertPos = pos == -1 ? TREELIST_APPEND : pos;
- void* pUserData;
- if (pId)
- {
- m_aUserData.emplace_back(std::make_unique<OUString>(*pId));
- pUserData = m_aUserData.back().get();
- }
- else
- pUserData = nullptr;
-
- SvTreeListEntry* pEntry = new SvTreeListEntry;
- if (bIsSeparator)
- pEntry->SetFlags(pEntry->GetFlags() | SvTLEntryFlags::IS_SEPARATOR);
-
- if (m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN)
- AddStringItem(pEntry, "", -1);
-
- if (pIconName || pImageSurface)
- {
- Image aImage(pIconName ? createImage(*pIconName) : createImage(*pImageSurface));
- pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage, false));
- }
- else
- {
- Image aDummy;
- pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false));
- }
- if (pStr)
- AddStringItem(pEntry, *pStr, 0);
- pEntry->SetUserData(pUserData);
- m_xTreeView->Insert(pEntry, iter, nInsertPos);
-
- if (pRet)
- {
- SalInstanceTreeIter* pVclRetIter = static_cast<SalInstanceTreeIter*>(pRet);
- pVclRetIter->iter = pEntry;
- }
-
- if (bChildrenOnDemand)
- {
- SvTreeListEntry* pPlaceHolder
- = m_xTreeView->InsertEntry("<dummy>", pEntry, false, 0, nullptr);
- SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pPlaceHolder);
- pViewData->SetSelectable(false);
- }
-
- if (bIsSeparator)
- {
- SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry);
- pViewData->SetSelectable(false);
- }
-
- enable_notify_events();
+ SvTreeListEntry* pPlaceHolder
+ = m_xTreeView->InsertEntry("<dummy>", pEntry, false, 0, nullptr);
+ SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pPlaceHolder);
+ pViewData->SetSelectable(false);
}
- void update_checkbutton_column_width(SvTreeListEntry* pEntry)
+ if (bIsSeparator)
{
SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry);
- m_xTreeView->InitViewData(pViewData, pEntry);
- m_xTreeView->CheckBoxInserted(pEntry);
+ pViewData->SetSelectable(false);
}
- void InvalidateModelEntry(SvTreeListEntry* pEntry)
- {
- if (!m_xTreeView->GetModel()->IsEnableInvalidate())
- return;
- m_xTreeView->ModelHasEntryInvalidated(pEntry);
- }
+ enable_notify_events();
+}
- void do_set_toggle(SvTreeListEntry* pEntry, TriState eState, int col)
- {
- assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
- // if its the placeholder to allow a blank column, replace it now
- if (pEntry->GetItem(col).GetType() != SvLBoxItemType::Button)
- {
- SvLBoxButtonData* pData = m_bTogglesAsRadio ? &m_aRadioButtonData : &m_aCheckButtonData;
- pEntry->ReplaceItem(std::make_unique<SvLBoxButton>(pData), 0);
- update_checkbutton_column_width(pEntry);
- }
- SvLBoxItem& rItem = pEntry->GetItem(col);
- assert(dynamic_cast<SvLBoxButton*>(&rItem));
- switch (eState)
- {
- case TRISTATE_TRUE:
- static_cast<SvLBoxButton&>(rItem).SetStateChecked();
- break;
- case TRISTATE_FALSE:
- static_cast<SvLBoxButton&>(rItem).SetStateUnchecked();
- break;
- case TRISTATE_INDET:
- static_cast<SvLBoxButton&>(rItem).SetStateTristate();
- break;
- }
+void SalInstanceTreeView::update_checkbutton_column_width(SvTreeListEntry* pEntry)
+{
+ SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry);
+ m_xTreeView->InitViewData(pViewData, pEntry);
+ m_xTreeView->CheckBoxInserted(pEntry);
+}
- InvalidateModelEntry(pEntry);
- }
+void SalInstanceTreeView::InvalidateModelEntry(SvTreeListEntry* pEntry)
+{
+ if (!m_xTreeView->GetModel()->IsEnableInvalidate())
+ return;
+ m_xTreeView->ModelHasEntryInvalidated(pEntry);
+}
- static TriState do_get_toggle(SvTreeListEntry* pEntry, int col)
+void SalInstanceTreeView::do_set_toggle(SvTreeListEntry* pEntry, TriState eState, int col)
+{
+ assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
+ // if its the placeholder to allow a blank column, replace it now
+ if (pEntry->GetItem(col).GetType() != SvLBoxItemType::Button)
{
- if (static_cast<size_t>(col) == pEntry->ItemCount())
- return TRISTATE_FALSE;
-
- assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
- SvLBoxItem& rItem = pEntry->GetItem(col);
- assert(dynamic_cast<SvLBoxButton*>(&rItem));
- SvLBoxButton& rToggle = static_cast<SvLBoxButton&>(rItem);
- if (rToggle.IsStateTristate())
- return TRISTATE_INDET;
- else if (rToggle.IsStateChecked())
- return TRISTATE_TRUE;
- return TRISTATE_FALSE;
+ SvLBoxButtonData* pData = m_bTogglesAsRadio ? &m_aRadioButtonData : &m_aCheckButtonData;
+ pEntry->ReplaceItem(std::make_unique<SvLBoxButton>(pData), 0);
+ update_checkbutton_column_width(pEntry);
}
-
- TriState get_toggle(SvTreeListEntry* pEntry, int col) const
+ SvLBoxItem& rItem = pEntry->GetItem(col);
+ assert(dynamic_cast<SvLBoxButton*>(&rItem));
+ switch (eState)
{
- if (col == -1)
- {
- assert(m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN);
- return do_get_toggle(pEntry, 0);
- }
- col = to_internal_model(col);
- return do_get_toggle(pEntry, col);
+ case TRISTATE_TRUE:
+ static_cast<SvLBoxButton&>(rItem).SetStateChecked();
+ break;
+ case TRISTATE_FALSE:
+ static_cast<SvLBoxButton&>(rItem).SetStateUnchecked();
+ break;
+ case TRISTATE_INDET:
+ static_cast<SvLBoxButton&>(rItem).SetStateTristate();
+ break;
}
- void set_toggle(SvTreeListEntry* pEntry, TriState eState, int col)
- {
- if (col == -1)
- {
- assert(m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN);
- do_set_toggle(pEntry, eState, 0);
- return;
- }
-
- col = to_internal_model(col);
-
- // blank out missing entries
- for (int i = pEntry->ItemCount(); i < col; ++i)
- AddStringItem(pEntry, "", i - 1);
+ InvalidateModelEntry(pEntry);
+}
- if (static_cast<size_t>(col) == pEntry->ItemCount())
- {
- SvLBoxButtonData* pData = m_bTogglesAsRadio ? &m_aRadioButtonData : &m_aCheckButtonData;
- pEntry->AddItem(std::make_unique<SvLBoxButton>(pData));
- update_checkbutton_column_width(pEntry);
- }
+TriState SalInstanceTreeView::do_get_toggle(SvTreeListEntry* pEntry, int col)
+{
+ if (static_cast<size_t>(col) == pEntry->ItemCount())
+ return TRISTATE_FALSE;
- do_set_toggle(pEntry, eState, col);
- }
+ assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
+ SvLBoxItem& rItem = pEntry->GetItem(col);
+ assert(dynamic_cast<SvLBoxButton*>(&rItem));
+ SvLBoxButton& rToggle = static_cast<SvLBoxButton&>(rItem);
+ if (rToggle.IsStateTristate())
+ return TRISTATE_INDET;
+ else if (rToggle.IsStateChecked())
+ return TRISTATE_TRUE;
+ return TRISTATE_FALSE;
+}
- bool get_text_emphasis(SvTreeListEntry* pEntry, int col) const
+TriState SalInstanceTreeView::get_toggle(SvTreeListEntry* pEntry, int col) const
+{
+ if (col == -1)
{
- col = to_internal_model(col);
-
- assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
- SvLBoxItem& rItem = pEntry->GetItem(col);
- assert(dynamic_cast<SvLBoxString*>(&rItem));
- return static_cast<SvLBoxString&>(rItem).IsEmphasized();
+ assert(m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN);
+ return do_get_toggle(pEntry, 0);
}
+ col = to_internal_model(col);
+ return do_get_toggle(pEntry, col);
+}
- void set_header_item_width(const std::vector<int>& rWidths)
+void SalInstanceTreeView::set_toggle(SvTreeListEntry* pEntry, TriState eState, int col)
+{
+ if (col == -1)
{
- LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get());
- if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
- {
- for (size_t i = 0; i < rWidths.size(); ++i)
- pHeaderBar->SetItemSize(pHeaderBar->GetItemId(i), rWidths[i]);
- }
+ assert(m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN);
+ do_set_toggle(pEntry, eState, 0);
+ return;
}
-public:
- SalInstanceTreeView(SvTabListBox* pTreeView, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
- : SalInstanceContainer(pTreeView, pBuilder, bTakeOwnership)
- , m_xTreeView(pTreeView)
- , m_aCheckButtonData(pTreeView, false)
- , m_aRadioButtonData(pTreeView, true)
- , m_bTogglesAsRadio(false)
- , m_nSortColumn(-1)
- {
- m_xTreeView->SetNodeDefaultImages();
- m_xTreeView->SetForceMakeVisible(true);
- m_xTreeView->SetSelectHdl(LINK(this, SalInstanceTreeView, SelectHdl));
- m_xTreeView->SetDeselectHdl(LINK(this, SalInstanceTreeView, DeSelectHdl));
- m_xTreeView->SetDoubleClickHdl(LINK(this, SalInstanceTreeView, DoubleClickHdl));
- m_xTreeView->SetExpandingHdl(LINK(this, SalInstanceTreeView, ExpandingHdl));
- m_xTreeView->SetPopupMenuHdl(LINK(this, SalInstanceTreeView, PopupMenuHdl));
- m_xTreeView->SetCustomRenderHdl(LINK(this, SalInstanceTreeView, CustomRenderHdl));
- m_xTreeView->SetCustomMeasureHdl(LINK(this, SalInstanceTreeView, CustomMeasureHdl));
- const tools::Long aTabPositions[] = { 0 };
- m_xTreeView->SetTabs(SAL_N_ELEMENTS(aTabPositions), aTabPositions);
- LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get());
-
- if (pHeaderBox)
- {
- if (HeaderBar* pHeaderBar = pHeaderBox->GetHeaderBar())
- {
- //make the last entry fill available space
- pHeaderBar->SetItemSize(pHeaderBar->GetItemId(pHeaderBar->GetItemCount() - 1),
- HEADERBAR_FULLSIZE);
- pHeaderBar->SetEndDragHdl(LINK(this, SalInstanceTreeView, EndDragHdl));
- pHeaderBar->SetSelectHdl(LINK(this, SalInstanceTreeView, HeaderBarClickedHdl));
- }
- pHeaderBox->SetEditingEntryHdl(LINK(this, SalInstanceTreeView, EditingEntryHdl));
- pHeaderBox->SetEditedEntryHdl(LINK(this, SalInstanceTreeView, EditedEntryHdl));
- }
- else
- {
- static_cast<LclTabListBox&>(*m_xTreeView)
- .SetModelChangedHdl(LINK(this, SalInstanceTreeView, ModelChangedHdl));
- static_cast<LclTabListBox&>(*m_xTreeView)
- .SetStartDragHdl(LINK(this, SalInstanceTreeView, StartDragHdl));
- static_cast<LclTabListBox&>(*m_xTreeView)
- .SetEndDragHdl(LINK(this, SalInstanceTreeView, FinishDragHdl));
- static_cast<LclTabListBox&>(*m_xTreeView)
- .SetEditingEntryHdl(LINK(this, SalInstanceTreeView, EditingEntryHdl));
- static_cast<LclTabListBox&>(*m_xTreeView)
- .SetEditedEntryHdl(LINK(this, SalInstanceTreeView, EditedEntryHdl));
- }
- m_aCheckButtonData.SetLink(LINK(this, SalInstanceTreeView, ToggleHdl));
- m_aRadioButtonData.SetLink(LINK(this, SalInstanceTreeView, ToggleHdl));
- }
+ col = to_internal_model(col);
- virtual void connect_query_tooltip(const Link<const weld::TreeIter&, OUString>& rLink) override
- {
- weld::TreeView::connect_query_tooltip(rLink);
- m_xTreeView->SetTooltipHdl(LINK(this, SalInstanceTreeView, TooltipHdl));
- }
+ // blank out missing entries
+ for (int i = pEntry->ItemCount(); i < col; ++i)
+ AddStringItem(pEntry, "", i - 1);
- virtual void columns_autosize() override
+ if (static_cast<size_t>(col) == pEntry->ItemCount())
{
- std::vector<tools::Long> aWidths;
- m_xTreeView->getPreferredDimensions(aWidths);
- if (aWidths.size() > 2)
- {
- std::vector<int> aColWidths;
- for (size_t i = 1; i < aWidths.size() - 1; ++i)
- aColWidths.push_back(aWidths[i] - aWidths[i - 1]);
- set_column_fixed_widths(aColWidths);
- }
+ SvLBoxButtonData* pData = m_bTogglesAsRadio ? &m_aRadioButtonData : &m_aCheckButtonData;
+ pEntry->AddItem(std::make_unique<SvLBoxButton>(pData));
+ update_checkbutton_column_width(pEntry);
}
- virtual void freeze() override
- {
- SalInstanceWidget::freeze();
- m_xTreeView->SetUpdateMode(false);
- m_xTreeView->GetModel()->EnableInvalidate(false);
- }
+ do_set_toggle(pEntry, eState, col);
+}
- virtual void thaw() override
- {
- m_xTreeView->GetModel()->EnableInvalidate(true);
- m_xTreeView->SetUpdateMode(true);
- SalInstanceWidget::thaw();
- }
+bool SalInstanceTreeView::get_text_emphasis(SvTreeListEntry* pEntry, int col) const
+{
+ col = to_internal_model(col);
+
+ assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
+ SvLBoxItem& rItem = pEntry->GetItem(col);
+ assert(dynamic_cast<SvLBoxString*>(&rItem));
+ return static_cast<SvLBoxString&>(rItem).IsEmphasized();
+}
- virtual void set_column_fixed_widths(const std::vector<int>& rWidths) override
+void SalInstanceTreeView::set_header_item_width(const std::vector<int>& rWidths)
+{
+ LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get());
+ if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
{
- std::vector<tools::Long> aTabPositions;
- aTabPositions.push_back(0);
for (size_t i = 0; i < rWidths.size(); ++i)
- aTabPositions.push_back(aTabPositions[i] + rWidths[i]);
- m_xTreeView->SetTabs(aTabPositions.size(), aTabPositions.data(), MapUnit::MapPixel);
- set_header_item_width(rWidths);
- // call Resize to recalculate based on the new tabs
- m_xTreeView->Resize();
+ pHeaderBar->SetItemSize(pHeaderBar->GetItemId(i), rWidths[i]);
}
+}
- virtual void set_column_editables(const std::vector<bool>& rEditables) override
- {
- size_t nTabCount = rEditables.size();
- for (size_t i = 0; i < nTabCount; ++i)
- m_xTreeView->SetTabEditable(i, rEditables[i]);
+SalInstanceTreeView::SalInstanceTreeView(SvTabListBox* pTreeView, SalInstanceBuilder* pBuilder,
+ bool bTakeOwnership)
+ : SalInstanceContainer(pTreeView, pBuilder, bTakeOwnership)
+ , m_xTreeView(pTreeView)
+ , m_aCheckButtonData(pTreeView, false)
+ , m_aRadioButtonData(pTreeView, true)
+ , m_bTogglesAsRadio(false)
+ , m_nSortColumn(-1)
+{
+ m_xTreeView->SetNodeDefaultImages();
+ m_xTreeView->SetForceMakeVisible(true);
+ m_xTreeView->SetSelectHdl(LINK(this, SalInstanceTreeView, SelectHdl));
+ m_xTreeView->SetDeselectHdl(LINK(this, SalInstanceTreeView, DeSelectHdl));
+ m_xTreeView->SetDoubleClickHdl(LINK(this, SalInstanceTreeView, DoubleClickHdl));
+ m_xTreeView->SetExpandingHdl(LINK(this, SalInstanceTreeView, ExpandingHdl));
+ m_xTreeView->SetPopupMenuHdl(LINK(this, SalInstanceTreeView, PopupMenuHdl));
+ m_xTreeView->SetCustomRenderHdl(LINK(this, SalInstanceTreeView, CustomRenderHdl));
+ m_xTreeView->SetCustomMeasureHdl(LINK(this, SalInstanceTreeView, CustomMeasureHdl));
+ const tools::Long aTabPositions[] = { 0 };
+ m_xTreeView->SetTabs(SAL_N_ELEMENTS(aTabPositions), aTabPositions);
+ LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get());
+
+ if (pHeaderBox)
+ {
+ if (HeaderBar* pHeaderBar = pHeaderBox->GetHeaderBar())
+ {
+ //make the last entry fill available space
+ pHeaderBar->SetItemSize(pHeaderBar->GetItemId(pHeaderBar->GetItemCount() - 1),
+ HEADERBAR_FULLSIZE);
+ pHeaderBar->SetEndDragHdl(LINK(this, SalInstanceTreeView, EndDragHdl));
+ pHeaderBar->SetSelectHdl(LINK(this, SalInstanceTreeView, HeaderBarClickedHdl));
+ }
+ pHeaderBox->SetEditingEntryHdl(LINK(this, SalInstanceTreeView, EditingEntryHdl));
+ pHeaderBox->SetEditedEntryHdl(LINK(this, SalInstanceTreeView, EditedEntryHdl));
}
-
- virtual void set_centered_column(int nCol) override
+ else
{
- m_xTreeView->SetTabJustify(nCol, SvTabJustify::AdjustCenter);
+ static_cast<LclTabListBox&>(*m_xTreeView)
+ .SetModelChangedHdl(LINK(this, SalInstanceTreeView, ModelChangedHdl));
+ static_cast<LclTabListBox&>(*m_xTreeView)
+ .SetStartDragHdl(LINK(this, SalInstanceTreeView, StartDragHdl));
+ static_cast<LclTabListBox&>(*m_xTreeView)
+ .SetEndDragHdl(LINK(this, SalInstanceTreeView, FinishDragHdl));
+ static_cast<LclTabListBox&>(*m_xTreeView)
+ .SetEditingEntryHdl(LINK(this, SalInstanceTreeView, EditingEntryHdl));
+ static_cast<LclTabListBox&>(*m_xTreeView)
+ .SetEditedEntryHdl(LINK(this, SalInstanceTreeView, EditedEntryHdl));
}
+ m_aCheckButtonData.SetLink(LINK(this, SalInstanceTreeView, ToggleHdl));
+ m_aRadioButtonData.SetLink(LINK(this, SalInstanceTreeView, ToggleHdl));
+}
- virtual int get_column_width(int nColumn) const override
- {
- LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get());
- if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
- return pHeaderBar->GetItemSize(pHeaderBar->GetItemId(nColumn));
- // GetTab(0) gives the position of the bitmap which is automatically inserted by the TabListBox.
- // So the first text column's width is Tab(2)-Tab(1).
- auto nWidthPixel
- = m_xTreeView->GetLogicTab(nColumn + 2) - m_xTreeView->GetLogicTab(nColumn + 1);
- nWidthPixel -= SV_TAB_BORDER;
- return nWidthPixel;
- }
+void SalInstanceTreeView::connect_query_tooltip(const Link<const weld::TreeIter&, OUString>& rLink)
+{
+ weld::TreeView::connect_query_tooltip(rLink);
+ m_xTreeView->SetTooltipHdl(LINK(this, SalInstanceTreeView, TooltipHdl));
+}
- virtual OUString get_column_title(int nColumn) const override
+void SalInstanceTreeView::columns_autosize()
+{
+ std::vector<tools::Long> aWidths;
+ m_xTreeView->getPreferredDimensions(aWidths);
+ if (aWidths.size() > 2)
{
- LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get());
- if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
- {
- return pHeaderBar->GetItemText(pHeaderBar->GetItemId(nColumn));
- }
- return OUString();
+ std::vector<int> aColWidths;
+ for (size_t i = 1; i < aWidths.size() - 1; ++i)
+ aColWidths.push_back(aWidths[i] - aWidths[i - 1]);
+ set_column_fixed_widths(aColWidths);
}
+}
- virtual void set_column_title(int nColumn, const OUString& rTitle) override
- {
- LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get());
- if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
- {
- return pHeaderBar->SetItemText(pHeaderBar->GetItemId(nColumn), rTitle);
- }
- }
+void SalInstanceTreeView::freeze()
+{
+ SalInstanceWidget::freeze();
+ m_xTreeView->SetUpdateMode(false);
+ m_xTreeView->GetModel()->EnableInvalidate(false);
+}
- virtual void set_column_custom_renderer(int nColumn, bool bEnable) override
- {
- assert(n_children() == 0 && "tree must be empty");
- if (bEnable)
- m_aCustomRenders.insert(nColumn);
- else
- m_aCustomRenders.erase(nColumn);
- }
+void SalInstanceTreeView::thaw()
+{
+ m_xTreeView->GetModel()->EnableInvalidate(true);
+ m_xTreeView->SetUpdateMode(true);
+ SalInstanceWidget::thaw();
+}
- virtual void queue_draw() override
- {
- // invalidate the entries
- SvTreeList* pModel = m_xTreeView->GetModel();
- for (SvTreeListEntry* pEntry = m_xTreeView->First(); pEntry;
- pEntry = m_xTreeView->Next(pEntry))
- pModel->InvalidateEntry(pEntry);
- }
+void SalInstanceTreeView::set_column_fixed_widths(const std::vector<int>& rWidths)
+{
+ std::vector<tools::Long> aTabPositions;
+ aTabPositions.push_back(0);
+ for (size_t i = 0; i < rWidths.size(); ++i)
+ aTabPositions.push_back(aTabPositions[i] + rWidths[i]);
+ m_xTreeView->SetTabs(aTabPositions.size(), aTabPositions.data(), MapUnit::MapPixel);
+ set_header_item_width(rWidths);
+ // call Resize to recalculate based on the new tabs
+ m_xTreeView->Resize();
+}
- virtual void show() override
- {
- if (LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get()))
- pHeaderBox->GetParent()->Show();
- SalInstanceContainer::show();
- }
+void SalInstanceTreeView::set_column_editables(const std::vector<bool>& rEditables)
+{
+ size_t nTabCount = rEditables.size();
+ for (size_t i = 0; i < nTabCount; ++i)
+ m_xTreeView->SetTabEditable(i, rEditables[i]);
+}
- virtual void hide() override
- {
- if (LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get()))
- pHeaderBox->GetParent()->Hide();
- SalInstanceContainer::hide();
- }
+void SalInstanceTreeView::set_centered_column(int nCol)
+{
+ m_xTreeView->SetTabJustify(nCol, SvTabJustify::AdjustCenter);
+}
+
+int SalInstanceTreeView::get_column_width(int nColumn) const
+{
+ LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get());
+ if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
+ return pHeaderBar->GetItemSize(pHeaderBar->GetItemId(nColumn));
+ // GetTab(0) gives the position of the bitmap which is automatically inserted by the TabListBox.
+ // So the first text column's width is Tab(2)-Tab(1).
+ auto nWidthPixel
+ = m_xTreeView->GetLogicTab(nColumn + 2) - m_xTreeView->GetLogicTab(nColumn + 1);
+ nWidthPixel -= SV_TAB_BORDER;
+ return nWidthPixel;
+}
- virtual void insert(const weld::TreeIter* pParent, int pos, const OUString* pStr,
- const OUString* pId, const OUString* pIconName,
- VirtualDevice* pImageSurface, bool bChildrenOnDemand,
- weld::TreeIter* pRet) override
+OUString SalInstanceTreeView::get_column_title(int nColumn) const
+{
+ LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get());
+ if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
{
- do_insert(pParent, pos, pStr, pId, pIconName, pImageSurface, bChildrenOnDemand, pRet,
- false);
+ return pHeaderBar->GetItemText(pHeaderBar->GetItemId(nColumn));
}
+ return OUString();
+}
- virtual void insert_separator(int pos, const OUString& /*rId*/) override
+void SalInstanceTreeView::set_column_title(int nColumn, const OUString& rTitle)
+{
+ LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get());
+ if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
{
- OUString sSep(VclResId(STR_SEPARATOR));
- do_insert(nullptr, pos, &sSep, nullptr, nullptr, nullptr, false, nullptr, true);
+ return pHeaderBar->SetItemText(pHeaderBar->GetItemId(nColumn), rTitle);
}
+}
- virtual void
- bulk_insert_for_each(int nSourceCount,
- const std::function<void(weld::TreeIter&, int nSourceIndex)>& func,
- const std::vector<int>* pFixedWidths) override
- {
- freeze();
- clear();
- SalInstanceTreeIter aVclIter(static_cast<SvTreeListEntry*>(nullptr));
+void SalInstanceTreeView::set_column_custom_renderer(int nColumn, bool bEnable)
+{
+ assert(n_children() == 0 && "tree must be empty");
+ if (bEnable)
+ m_aCustomRenders.insert(nColumn);
+ else
+ m_aCustomRenders.erase(nColumn);
+}
+
+void SalInstanceTreeView::queue_draw()
+{
+ // invalidate the entries
+ SvTreeList* pModel = m_xTreeView->GetModel();
+ for (SvTreeListEntry* pEntry = m_xTreeView->First(); pEntry; pEntry = m_xTreeView->Next(pEntry))
+ pModel->InvalidateEntry(pEntry);
+}
+
+void SalInstanceTreeView::show()
+{
+ if (LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get()))
+ pHeaderBox->GetParent()->Show();
+ SalInstanceContainer::show();
+}
- m_xTreeView->nTreeFlags |= SvTreeFlags::MANINS;
+void SalInstanceTreeView::hide()
+{
+ if (LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get()))
+ pHeaderBox->GetParent()->Hide();
+ SalInstanceContainer::hide();
+}
- if (pFixedWidths)
- set_header_item_width(*pFixedWidths);
+void SalInstanceTreeView::insert(const weld::TreeIter* pParent, int pos, const OUString* pStr,
+ const OUString* pId, const OUString* pIconName,
+ VirtualDevice* pImageSurface, bool bChildrenOnDemand,
+ weld::TreeIter* pRet)
+{
+ do_insert(pParent, pos, pStr, pId, pIconName, pImageSurface, bChildrenOnDemand, pRet, false);
+}
- bool bHasAutoCheckButton(m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN);
- size_t nExtraCols = bHasAutoCheckButton ? 2 : 1;
+void SalInstanceTreeView::insert_separator(int pos, const OUString& /*rId*/)
+{
+ OUString sSep(VclResId(STR_SEPARATOR));
+ do_insert(nullptr, pos, &sSep, nullptr, nullptr, nullptr, false, nullptr, true);
+}
- Image aDummy;
- for (int i = 0; i < nSourceCount; ++i)
- {
- aVclIter.iter = new SvTreeListEntry;
- if (bHasAutoCheckButton)
- AddStringItem(aVclIter.iter, "", -1);
- aVclIter.iter->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false));
- m_xTreeView->Insert(aVclIter.iter, nullptr, TREELIST_APPEND);
- func(aVclIter, i);
-
- if (!pFixedWidths)
- continue;
-
- size_t nFixedWidths = std::min(pFixedWidths->size(), aVclIter.iter->ItemCount());
- for (size_t j = 0; j < nFixedWidths; ++j)
- {
- SvLBoxItem& rItem = aVclIter.iter->GetItem(j + nExtraCols);
- SvViewDataItem* pViewDataItem = m_xTreeView->GetViewDataItem(aVclIter.iter, &rItem);
- pViewDataItem->mnWidth = (*pFixedWidths)[j];
- }
- }
+void SalInstanceTreeView::bulk_insert_for_each(
+ int nSourceCount, const std::function<void(weld::TreeIter&, int nSourceIndex)>& func,
+ const std::vector<int>* pFixedWidths)
+{
+ freeze();
+ clear();
+ SalInstanceTreeIter aVclIter(static_cast<SvTreeListEntry*>(nullptr));
- m_xTreeView->nTreeFlags &= ~SvTreeFlags::MANINS;
+ m_xTreeView->nTreeFlags |= SvTreeFlags::MANINS;
- thaw();
- }
+ if (pFixedWidths)
+ set_header_item_width(*pFixedWidths);
- virtual void set_font_color(int pos, const Color& rColor) override
- {
- SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
- set_font_color(pEntry, rColor);
- }
+ bool bHasAutoCheckButton(m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN);
+ size_t nExtraCols = bHasAutoCheckButton ? 2 : 1;
- virtual void set_font_color(const weld::TreeIter& rIter, const Color& rColor) override
+ Image aDummy;
+ for (int i = 0; i < nSourceCount; ++i)
{
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- set_font_color(rVclIter.iter, rColor);
- }
+ aVclIter.iter = new SvTreeListEntry;
+ if (bHasAutoCheckButton)
+ AddStringItem(aVclIter.iter, "", -1);
+ aVclIter.iter->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false));
+ m_xTreeView->Insert(aVclIter.iter, nullptr, TREELIST_APPEND);
+ func(aVclIter, i);
- virtual void remove(int pos) override
- {
- disable_notify_events();
- SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
- m_xTreeView->RemoveEntry(pEntry);
- enable_notify_events();
- }
+ if (!pFixedWidths)
+ continue;
- virtual int find_text(const OUString& rText) const override
- {
- for (SvTreeListEntry* pEntry = m_xTreeView->First(); pEntry;
- pEntry = m_xTreeView->Next(pEntry))
+ size_t nFixedWidths = std::min(pFixedWidths->size(), aVclIter.iter->ItemCount());
+ for (size_t j = 0; j < nFixedWidths; ++j)
{
- if (SvTabListBox::GetEntryText(pEntry, 0) == rText)
- return SvTreeList::GetRelPos(pEntry);
+ SvLBoxItem& rItem = aVclIter.iter->GetItem(j + nExtraCols);
+ SvViewDataItem* pViewDataItem = m_xTreeView->GetViewDataItem(aVclIter.iter, &rItem);
+ pViewDataItem->mnWidth = (*pFixedWidths)[j];
}
- return -1;
}
- virtual int find_id(const OUString& rId) const override
- {
- for (SvTreeListEntry* pEntry = m_xTreeView->First(); pEntry;
- pEntry = m_xTreeView->Next(pEntry))
- {
- const OUString* pId = static_cast<const OUString*>(pEntry->GetUserData());
- if (!pId)
- continue;
- if (rId == *pId)
- return SvTreeList::GetRelPos(pEntry);
- }
- return -1;
- }
+ m_xTreeView->nTreeFlags &= ~SvTreeFlags::MANINS;
- virtual void swap(int pos1, int pos2) override
- {
- int min = std::min(pos1, pos2);
- int max = std::max(pos1, pos2);
- SvTreeList* pModel = m_xTreeView->GetModel();
- SvTreeListEntry* pEntry1 = pModel->GetEntry(nullptr, min);
- SvTreeListEntry* pEntry2 = pModel->GetEntry(nullptr, max);
- pModel->Move(pEntry1, pEntry2);
- }
+ thaw();
+}
- virtual void clear() override
- {
- disable_notify_events();
- m_xTreeView->Clear();
- m_aUserData.clear();
- enable_notify_events();
- }
+void SalInstanceTreeView::set_font_color(int pos, const Color& rColor)
+{
+ SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
+ set_font_color(pEntry, rColor);
+}
- virtual int n_children() const override
- {
- return m_xTreeView->GetModel()->GetChildList(nullptr).size();
- }
+void SalInstanceTreeView::set_font_color(const weld::TreeIter& rIter, const Color& rColor)
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ set_font_color(rVclIter.iter, rColor);
+}
- virtual int iter_n_children(const weld::TreeIter& rIter) const override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- return m_xTreeView->GetModel()->GetChildList(rVclIter.iter).size();
- }
+void SalInstanceTreeView::remove(int pos)
+{
+ disable_notify_events();
+ SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
+ m_xTreeView->RemoveEntry(pEntry);
+ enable_notify_events();
+}
- virtual void select(int pos) override
+int SalInstanceTreeView::find_text(const OUString& rText) const
+{
+ for (SvTreeListEntry* pEntry = m_xTreeView->First(); pEntry; pEntry = m_xTreeView->Next(pEntry))
{
- assert(m_xTreeView->IsUpdateMode()
- && "don't select when frozen, select after thaw. Note selection doesn't survive a "
- "freeze");
- disable_notify_events();
- if (pos == -1 || (pos == 0 && n_children() == 0))
- m_xTreeView->SelectAll(false);
- else
- {
- SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
- m_xTreeView->Select(pEntry, true);
- m_xTreeView->MakeVisible(pEntry);
- }
- enable_notify_events();
+ if (SvTabListBox::GetEntryText(pEntry, 0) == rText)
+ return SvTreeList::GetRelPos(pEntry);
}
+ return -1;
+}
- virtual int get_cursor_index() const override
+int SalInstanceTreeView::find_id(const OUString& rId) const
+{
+ for (SvTreeListEntry* pEntry = m_xTreeView->First(); pEntry; pEntry = m_xTreeView->Next(pEntry))
{
- SvTreeListEntry* pEntry = m_xTreeView->GetCurEntry();
- if (!pEntry)
- return -1;
- return SvTreeList::GetRelPos(pEntry);
+ const OUString* pId = static_cast<const OUString*>(pEntry->GetUserData());
+ if (!pId)
+ continue;
+ if (rId == *pId)
+ return SvTreeList::GetRelPos(pEntry);
}
+ return -1;
+}
- virtual void set_cursor(int pos) override
- {
- disable_notify_events();
- if (pos == -1)
- m_xTreeView->SetCurEntry(nullptr);
- else
- {
- SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
- m_xTreeView->SetCurEntry(pEntry);
- }
- enable_notify_events();
- }
+void SalInstanceTreeView::swap(int pos1, int pos2)
+{
+ int min = std::min(pos1, pos2);
+ int max = std::max(pos1, pos2);
+ SvTreeList* pModel = m_xTreeView->GetModel();
+ SvTreeListEntry* pEntry1 = pModel->GetEntry(nullptr, min);
+ SvTreeListEntry* pEntry2 = pModel->GetEntry(nullptr, max);
+ pModel->Move(pEntry1, pEntry2);
+}
- virtual void scroll_to_row(int pos) override
+void SalInstanceTreeView::clear()
+{
+ disable_notify_events();
+ m_xTreeView->Clear();
+ m_aUserData.clear();
+ enable_notify_events();
+}
+
+int SalInstanceTreeView::n_children() const
+{
+ return m_xTreeView->GetModel()->GetChildList(nullptr).size();
+}
+
+int SalInstanceTreeView::iter_n_children(const weld::TreeIter& rIter) const
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ return m_xTreeView->GetModel()->GetChildList(rVclIter.iter).size();
+}
+
+void SalInstanceTreeView::select(int pos)
+{
+ assert(m_xTreeView->IsUpdateMode()
+ && "don't select when frozen, select after thaw. Note selection doesn't survive a "
+ "freeze");
+ disable_notify_events();
+ if (pos == -1 || (pos == 0 && n_children() == 0))
+ m_xTreeView->SelectAll(false);
+ else
{
- assert(m_xTreeView->IsUpdateMode()
- && "don't select when frozen, select after thaw. Note selection doesn't survive a "
- "freeze");
- disable_notify_events();
SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
+ m_xTreeView->Select(pEntry, true);
m_xTreeView->MakeVisible(pEntry);
- enable_notify_events();
}
+ enable_notify_events();
+}
+
+int SalInstanceTreeView::get_cursor_index() const
+{
+ SvTreeListEntry* pEntry = m_xTreeView->GetCurEntry();
+ if (!pEntry)
+ return -1;
+ return SvTreeList::GetRelPos(pEntry);
+}
- virtual bool is_selected(int pos) const override
+void SalInstanceTreeView::set_cursor(int pos)
+{
+ disable_notify_events();
+ if (pos == -1)
+ m_xTreeView->SetCurEntry(nullptr);
+ else
{
SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
- return m_xTreeView->IsSelected(pEntry);
+ m_xTreeView->SetCurEntry(pEntry);
}
+ enable_notify_events();
+}
- virtual void unselect(int pos) override
+void SalInstanceTreeView::scroll_to_row(int pos)
+{
+ assert(m_xTreeView->IsUpdateMode()
+ && "don't select when frozen, select after thaw. Note selection doesn't survive a "
+ "freeze");
+ disable_notify_events();
+ SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
+ m_xTreeView->MakeVisible(pEntry);
+ enable_notify_events();
+}
+
+bool SalInstanceTreeView::is_selected(int pos) const
+{
+ SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
+ return m_xTreeView->IsSelected(pEntry);
+}
+
+void SalInstanceTreeView::unselect(int pos)
+{
+ assert(m_xTreeView->IsUpdateMode()
+ && "don't select when frozen, select after thaw. Note selection doesn't survive a "
+ "freeze");
+ disable_notify_events();
+ if (pos == -1)
+ m_xTreeView->SelectAll(true);
+ else
{
- assert(m_xTreeView->IsUpdateMode()
- && "don't select when frozen, select after thaw. Note selection doesn't survive a "
- "freeze");
- disable_notify_events();
- if (pos == -1)
- m_xTreeView->SelectAll(true);
- else
- {
- SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
- m_xTreeView->Select(pEntry, false);
- }
- enable_notify_events();
+ SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
+ m_xTreeView->Select(pEntry, false);
}
+ enable_notify_events();
+}
- virtual std::vector<int> get_selected_rows() const override
- {
- std::vector<int> aRows;
+std::vector<int> SalInstanceTreeView::get_selected_rows() const
+{
+ std::vector<int> aRows;
- aRows.reserve(m_xTreeView->GetSelectionCount());
- for (SvTreeListEntry* pEntry = m_xTreeView->FirstSelected(); pEntry;
- pEntry = m_xTreeView->NextSelected(pEntry))
- aRows.push_back(SvTreeList::GetRelPos(pEntry));
+ aRows.reserve(m_xTreeView->GetSelectionCount());
+ for (SvTreeListEntry* pEntry = m_xTreeView->FirstSelected(); pEntry;
+ pEntry = m_xTreeView->NextSelected(pEntry))
+ aRows.push_back(SvTreeList::GetRelPos(pEntry));
- return aRows;
- }
+ return aRows;
+}
- OUString get_text(SvTreeListEntry* pEntry, int col) const
- {
- if (col == -1)
- return SvTabListBox::GetEntryText(pEntry, 0);
+OUString SalInstanceTreeView::get_text(SvTreeListEntry* pEntry, int col) const
+{
+ if (col == -1)
+ return SvTabListBox::GetEntryText(pEntry, 0);
- col = to_internal_model(col);
+ col = to_internal_model(col);
- if (static_cast<size_t>(col) == pEntry->ItemCount())
- return OUString();
+ if (static_cast<size_t>(col) == pEntry->ItemCount())
+ return OUString();
- assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
- SvLBoxItem& rItem = pEntry->GetItem(col);
- assert(dynamic_cast<SvLBoxString*>(&rItem));
- return static_cast<SvLBoxString&>(rItem).GetText();
- }
+ assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
+ SvLBoxItem& rItem = pEntry->GetItem(col);
+ assert(dynamic_cast<SvLBoxString*>(&rItem));
+ return static_cast<SvLBoxString&>(rItem).GetText();
+}
- virtual OUString get_text(int pos, int col) const override
- {
- SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
- return get_text(pEntry, col);
- }
+OUString SalInstanceTreeView::get_text(int pos, int col) const
+{
+ SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
+ return get_text(pEntry, col);
+}
- void set_text(SvTreeListEntry* pEntry, const OUString& rText, int col)
+void SalInstanceTreeView::set_text(SvTreeListEntry* pEntry, const OUString& rText, int col)
+{
+ if (col == -1)
{
- if (col == -1)
- {
- m_xTreeView->SetEntryText(pEntry, rText);
- return;
- }
-
- col = to_internal_model(col);
-
- // blank out missing entries
- for (int i = pEntry->ItemCount(); i < col; ++i)
- AddStringItem(pEntry, "", i - 1);
+ m_xTreeView->SetEntryText(pEntry, rText);
+ return;
+ }
- if (static_cast<size_t>(col) == pEntry->ItemCount())
- {
- AddStringItem(pEntry, rText, col - 1);
- SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry);
- m_xTreeView->InitViewData(pViewData, pEntry);
- }
- else
- {
- assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
- SvLBoxItem& rItem = pEntry->GetItem(col);
- assert(dynamic_cast<SvLBoxString*>(&rItem));
- static_cast<SvLBoxString&>(rItem).SetText(rText);
- }
+ col = to_internal_model(col);
- InvalidateModelEntry(pEntry);
- }
+ // blank out missing entries
+ for (int i = pEntry->ItemCount(); i < col; ++i)
+ AddStringItem(pEntry, "", i - 1);
- virtual void set_text(int pos, const OUString& rText, int col) override
+ if (static_cast<size_t>(col) == pEntry->ItemCount())
{
- SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
- set_text(pEntry, rText, col);
+ AddStringItem(pEntry, rText, col - 1);
+ SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry);
+ m_xTreeView->InitViewData(pViewData, pEntry);
}
-
- void set_sensitive(SvTreeListEntry* pEntry, bool bSensitive, int col)
+ else
{
- if (col == -1)
- {
- auto nFlags = pEntry->GetFlags() & ~SvTLEntryFlags::SEMITRANSPARENT;
- if (!bSensitive)
- nFlags = nFlags | SvTLEntryFlags::SEMITRANSPARENT;
- pEntry->SetFlags(nFlags);
- const sal_uInt16 nCount = pEntry->ItemCount();
- for (sal_uInt16 nCur = 0; nCur < nCount; ++nCur)
- {
- SvLBoxItem& rItem = pEntry->GetItem(nCur);
- if (rItem.GetType() == SvLBoxItemType::String)
- {
- rItem.Enable(bSensitive);
- InvalidateModelEntry(pEntry);
- break;
- }
- }
- return;
- }
-
- col = to_internal_model(col);
-
assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
SvLBoxItem& rItem = pEntry->GetItem(col);
- rItem.Enable(bSensitive);
-
- InvalidateModelEntry(pEntry);
- }
-
- using SalInstanceWidget::set_sensitive;
-
- virtual void set_sensitive(int pos, bool bSensitive, int col) override
- {
- SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
- set_sensitive(pEntry, bSensitive, col);
+ assert(dynamic_cast<SvLBoxString*>(&rItem));
+ static_cast<SvLBoxString&>(rItem).SetText(rText);
}
- virtual void set_sensitive(const weld::TreeIter& rIter, bool bSensitive, int col) override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- set_sensitive(rVclIter.iter, bSensitive, col);
- }
+ InvalidateModelEntry(pEntry);
+}
- virtual TriState get_toggle(int pos, int col) const override
- {
- SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
- return get_toggle(pEntry, col);
- }
+void SalInstanceTreeView::set_text(int pos, const OUString& rText, int col)
+{
+ SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
+ set_text(pEntry, rText, col);
+}
- virtual TriState get_toggle(const weld::TreeIter& rIter, int col) const override
+void SalInstanceTreeView::set_sensitive(SvTreeListEntry* pEntry, bool bSensitive, int col)
+{
+ if (col == -1)
{
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- return get_toggle(rVclIter.iter, col);
+ auto nFlags = pEntry->GetFlags() & ~SvTLEntryFlags::SEMITRANSPARENT;
+ if (!bSensitive)
+ nFlags = nFlags | SvTLEntryFlags::SEMITRANSPARENT;
+ pEntry->SetFlags(nFlags);
+ const sal_uInt16 nCount = pEntry->ItemCount();
+ for (sal_uInt16 nCur = 0; nCur < nCount; ++nCur)
+ {
+ SvLBoxItem& rItem = pEntry->GetItem(nCur);
+ if (rItem.GetType() == SvLBoxItemType::String)
+ {
+ rItem.Enable(bSensitive);
+ InvalidateModelEntry(pEntry);
+ break;
+ }
+ }
+ return;
}
- virtual void enable_toggle_buttons(weld::ColumnToggleType eType) override
- {
- assert(n_children() == 0 && "tree must be empty");
- m_bTogglesAsRadio = eType == weld::ColumnToggleType::Radio;
+ col = to_internal_model(col);
- SvLBoxButtonData* pData = m_bTogglesAsRadio ? &m_aRadioButtonData : &m_aCheckButtonData;
- m_xTreeView->EnableCheckButton(pData);
- // EnableCheckButton clobbered this, restore it
- pData->SetLink(LINK(this, SalInstanceTreeView, ToggleHdl));
- }
-
- virtual void set_toggle(int pos, TriState eState, int col) override
- {
- SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
- set_toggle(pEntry, eState, col);
- }
+ assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
+ SvLBoxItem& rItem = pEntry->GetItem(col);
+ rItem.Enable(bSensitive);
- virtual void set_toggle(const weld::TreeIter& rIter, TriState eState, int col) override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- set_toggle(rVclIter.iter, eState, col);
- }
+ InvalidateModelEntry(pEntry);
+}
- virtual void set_extra_row_indent(const weld::TreeIter& rIter, int nIndentLevel) override
- {
- weld::TreeIter& rNonConstIter = const_cast<weld::TreeIter&>(rIter);
- SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rNonConstIter);
- rVclIter.iter->SetExtraIndent(nIndentLevel);
- }
+void SalInstanceTreeView::set_sensitive(int pos, bool bSensitive, int col)
+{
+ SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
+ set_sensitive(pEntry, bSensitive, col);
+}
- void set_text_emphasis(SvTreeListEntry* pEntry, bool bOn, int col)
- {
- col = to_internal_model(col);
+void SalInstanceTreeView::set_sensitive(const weld::TreeIter& rIter, bool bSensitive, int col)
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ set_sensitive(rVclIter.iter, bSensitive, col);
+}
- assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
- SvLBoxItem& rItem = pEntry->GetItem(col);
- assert(dynamic_cast<SvLBoxString*>(&rItem));
- static_cast<SvLBoxString&>(rItem).Emphasize(bOn);
+TriState SalInstanceTreeView::get_toggle(int pos, int col) const
+{
+ SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
+ return get_toggle(pEntry, col);
+}
- InvalidateModelEntry(pEntry);
- }
+TriState SalInstanceTreeView::get_toggle(const weld::TreeIter& rIter, int col) const
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ return get_toggle(rVclIter.iter, col);
+}
- virtual void set_text_emphasis(const weld::TreeIter& rIter, bool bOn, int col) override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- set_text_emphasis(rVclIter.iter, bOn, col);
- }
+void SalInstanceTreeView::enable_toggle_buttons(weld::ColumnToggleType eType)
+{
+ assert(n_children() == 0 && "tree must be empty");
+ m_bTogglesAsRadio = eType == weld::ColumnToggleType::Radio;
- virtual void set_text_emphasis(int pos, bool bOn, int col) override
- {
- SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
- set_text_emphasis(pEntry, bOn, col);
- }
+ SvLBoxButtonData* pData = m_bTogglesAsRadio ? &m_aRadioButtonData : &m_aCheckButtonData;
+ m_xTreeView->EnableCheckButton(pData);
+ // EnableCheckButton clobbered this, restore it
+ pData->SetLink(LINK(this, SalInstanceTreeView, ToggleHdl));
+}
- virtual bool get_text_emphasis(const weld::TreeIter& rIter, int col) const override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- return get_text_emphasis(rVclIter.iter, col);
- }
+void SalInstanceTreeView::set_toggle(int pos, TriState eState, int col)
+{
+ SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
+ set_toggle(pEntry, eState, col);
+}
- virtual bool get_text_emphasis(int pos, int col) const override
- {
- SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
- return get_text_emphasis(pEntry, col);
- }
+void SalInstanceTreeView::set_toggle(const weld::TreeIter& rIter, TriState eState, int col)
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ set_toggle(rVclIter.iter, eState, col);
+}
- void set_text_align(SvTreeListEntry* pEntry, double fAlign, int col)
- {
- col = to_internal_model(col);
+void SalInstanceTreeView::set_extra_row_indent(const weld::TreeIter& rIter, int nIndentLevel)
+{
+ weld::TreeIter& rNonConstIter = const_cast<weld::TreeIter&>(rIter);
+ SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rNonConstIter);
+ rVclIter.iter->SetExtraIndent(nIndentLevel);
+}
- assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
- SvLBoxItem& rItem = pEntry->GetItem(col);
- assert(dynamic_cast<SvLBoxString*>(&rItem));
- static_cast<SvLBoxString&>(rItem).Align(fAlign);
+void SalInstanceTreeView::set_text_emphasis(SvTreeListEntry* pEntry, bool bOn, int col)
+{
+ col = to_internal_model(col);
- InvalidateModelEntry(pEntry);
- }
+ assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
+ SvLBoxItem& rItem = pEntry->GetItem(col);
+ assert(dynamic_cast<SvLBoxString*>(&rItem));
+ static_cast<SvLBoxString&>(rItem).Emphasize(bOn);
- virtual void set_text_align(const weld::TreeIter& rIter, double fAlign, int col) override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- set_text_align(rVclIter.iter, fAlign, col);
- }
+ InvalidateModelEntry(pEntry);
+}
- virtual void set_text_align(int pos, double fAlign, int col) override
- {
- SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
- set_text_align(pEntry, fAlign, col);
- }
+void SalInstanceTreeView::set_text_emphasis(const weld::TreeIter& rIter, bool bOn, int col)
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ set_text_emphasis(rVclIter.iter, bOn, col);
+}
- virtual void connect_editing(const Link<const weld::TreeIter&, bool>& rStartLink,
- const Link<const iter_string&, bool>& rEndLink) override
- {
- m_xTreeView->EnableInplaceEditing(rStartLink.IsSet() || rEndLink.IsSet());
- weld::TreeView::connect_editing(rStartLink, rEndLink);
- }
+void SalInstanceTreeView::set_text_emphasis(int pos, bool bOn, int col)
+{
+ SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
+ set_text_emphasis(pEntry, bOn, col);
+}
- virtual void start_editing(const weld::TreeIter& rIter) override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- m_xTreeView->EditEntry(rVclIter.iter);
- }
+bool SalInstanceTreeView::get_text_emphasis(const weld::TreeIter& rIter, int col) const
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ return get_text_emphasis(rVclIter.iter, col);
+}
- virtual void end_editing() override { m_xTreeView->EndEditing(); }
+bool SalInstanceTreeView::get_text_emphasis(int pos, int col) const
+{
+ SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
+ return get_text_emphasis(pEntry, col);
+}
- void set_image(SvTreeListEntry* pEntry, const Image& rImage, int col)
- {
- if (col == -1)
- {
- m_xTreeView->SetExpandedEntryBmp(pEntry, rImage);
- m_xTreeView->SetCollapsedEntryBmp(pEntry, rImage);
- return;
- }
+void SalInstanceTreeView::set_text_align(SvTreeListEntry* pEntry, double fAlign, int col)
+{
+ col = to_internal_model(col);
- col = to_internal_model(col);
+ assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
+ SvLBoxItem& rItem = pEntry->GetItem(col);
+ assert(dynamic_cast<SvLBoxString*>(&rItem));
+ static_cast<SvLBoxString&>(rItem).Align(fAlign);
- // blank out missing entries
- for (int i = pEntry->ItemCount(); i < col; ++i)
- AddStringItem(pEntry, "", i - 1);
+ InvalidateModelEntry(pEntry);
+}
- if (static_cast<size_t>(col) == pEntry->ItemCount())
- {
- pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(rImage, rImage, false));
- SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry);
- m_xTreeView->InitViewData(pViewData, pEntry);
- }
- else
- {
- assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
- SvLBoxItem& rItem = pEntry->GetItem(col);
- assert(dynamic_cast<SvLBoxContextBmp*>(&rItem));
- static_cast<SvLBoxContextBmp&>(rItem).SetBitmap1(rImage);
- static_cast<SvLBoxContextBmp&>(rItem).SetBitmap2(rImage);
- }
+void SalInstanceTreeView::set_text_align(const weld::TreeIter& rIter, double fAlign, int col)
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ set_text_align(rVclIter.iter, fAlign, col);
+}
- m_xTreeView->SetEntryHeight(pEntry);
- InvalidateModelEntry(pEntry);
- }
+void SalInstanceTreeView::set_text_align(int pos, double fAlign, int col)
+{
+ SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
+ set_text_align(pEntry, fAlign, col);
+}
- virtual void set_image(int pos, const OUString& rImage, int col) override
- {
- set_image(m_xTreeView->GetEntry(nullptr, pos), createImage(rImage), col);
- }
+void SalInstanceTreeView::connect_editing(const Link<const weld::TreeIter&, bool>& rStartLink,
+ const Link<const iter_string&, bool>& rEndLink)
+{
+ m_xTreeView->EnableInplaceEditing(rStartLink.IsSet() || rEndLink.IsSet());
+ weld::TreeView::connect_editing(rStartLink, rEndLink);
+}
- virtual void set_image(int pos, const css::uno::Reference<css::graphic::XGraphic>& rImage,
- int col) override
- {
- set_image(m_xTreeView->GetEntry(nullptr, pos), Image(rImage), col);
- }
+void SalInstanceTreeView::start_editing(const weld::TreeIter& rIter)
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ m_xTreeView->EditEntry(rVclIter.iter);
+}
- virtual void set_image(int pos, VirtualDevice& rImage, int col) override
- {
- set_image(m_xTreeView->GetEntry(nullptr, pos), createImage(rImage), col);
- }
+void SalInstanceTreeView::end_editing() { m_xTreeView->EndEditing(); }
- virtual void set_image(const weld::TreeIter& rIter, const OUString& rImage, int col) override
+void SalInstanceTreeView::set_image(SvTreeListEntry* pEntry, const Image& rImage, int col)
+{
+ if (col == -1)
{
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- set_image(rVclIter.iter, createImage(rImage), col);
+ m_xTreeView->SetExpandedEntryBmp(pEntry, rImage);
+ m_xTreeView->SetCollapsedEntryBmp(pEntry, rImage);
+ return;
}
- virtual void set_image(const weld::TreeIter& rIter,
- const css::uno::Reference<css::graphic::XGraphic>& rImage,
- int col) override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- set_image(rVclIter.iter, Image(rImage), col);
- }
+ col = to_internal_model(col);
- virtual void set_image(const weld::TreeIter& rIter, VirtualDevice& rImage, int col) override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- set_image(rVclIter.iter, createImage(rImage), col);
- }
+ // blank out missing entries
+ for (int i = pEntry->ItemCount(); i < col; ++i)
+ AddStringItem(pEntry, "", i - 1);
- const OUString* getEntryData(int index) const
+ if (static_cast<size_t>(col) == pEntry->ItemCount())
{
- SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, index);
- return pEntry ? static_cast<const OUString*>(pEntry->GetUserData()) : nullptr;
+ pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(rImage, rImage, false));
+ SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry);
+ m_xTreeView->InitViewData(pViewData, pEntry);
}
-
- virtual OUString get_id(int pos) const override
+ else
{
- const OUString* pRet = getEntryData(pos);
- if (!pRet)
- return OUString();
- return *pRet;
+ assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
+ SvLBoxItem& rItem = pEntry->GetItem(col);
+ assert(dynamic_cast<SvLBoxContextBmp*>(&rItem));
+ static_cast<SvLBoxContextBmp&>(rItem).SetBitmap1(rImage);
+ static_cast<SvLBoxContextBmp&>(rItem).SetBitmap2(rImage);
}
- void set_id(SvTreeListEntry* pEntry, const OUString& rId)
- {
- m_aUserData.emplace_back(std::make_unique<OUString>(rId));
- pEntry->SetUserData(m_aUserData.back().get());
- }
+ m_xTreeView->SetEntryHeight(pEntry);
+ InvalidateModelEntry(pEntry);
+}
- virtual void set_id(int pos, const OUString& rId) override
- {
- SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
- set_id(pEntry, rId);
- }
+void SalInstanceTreeView::set_image(int pos, const OUString& rImage, int col)
+{
+ set_image(m_xTreeView->GetEntry(nullptr, pos), createImage(rImage), col);
+}
- virtual int get_selected_index() const override
- {
- assert(m_xTreeView->IsUpdateMode() && "don't request selection when frozen");
- SvTreeListEntry* pEntry = m_xTreeView->FirstSelected();
- if (!pEntry)
- return -1;
- return SvTreeList::GetRelPos(pEntry);
- }
+void SalInstanceTreeView::set_image(int pos,
+ const css::uno::Reference<css::graphic::XGraphic>& rImage,
+ int col)
+{
+ set_image(m_xTreeView->GetEntry(nullptr, pos), Image(rImage), col);
+}
- virtual OUString get_selected_text() const override
- {
- assert(m_xTreeView->IsUpdateMode() && "don't request selection when frozen");
- if (SvTreeListEntry* pEntry = m_xTreeView->FirstSelected())
- return m_xTreeView->GetEntryText(pEntry);
- return OUString();
- }
+void SalInstanceTreeView::set_image(int pos, VirtualDevice& rImage, int col)
+{
+ set_image(m_xTreeView->GetEntry(nullptr, pos), createImage(rImage), col);
+}
- virtual OUString get_selected_id() const override
- {
- assert(m_xTreeView->IsUpdateMode() && "don't request selection when frozen");
- if (SvTreeListEntry* pEntry = m_xTreeView->FirstSelected())
- {
- if (const OUString* pStr = static_cast<const OUString*>(pEntry->GetUserData()))
- return *pStr;
- }
- return OUString();
- }
+void SalInstanceTreeView::set_image(const weld::TreeIter& rIter, const OUString& rImage, int col)
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ set_image(rVclIter.iter, createImage(rImage), col);
+}
- virtual std::unique_ptr<weld::TreeIter>
- make_iterator(const weld::TreeIter* pOrig) const override
- {
- return std::unique_ptr<weld::TreeIter>(
- new SalInstanceTreeIter(static_cast<const SalInstanceTreeIter*>(pOrig)));
- }
+void SalInstanceTreeView::set_image(const weld::TreeIter& rIter,
+ const css::uno::Reference<css::graphic::XGraphic>& rImage,
+ int col)
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ set_image(rVclIter.iter, Image(rImage), col);
+}
- virtual void copy_iterator(const weld::TreeIter& rSource, weld::TreeIter& rDest) const override
- {
- const SalInstanceTreeIter& rVclSource(static_cast<const SalInstanceTreeIter&>(rSource));
- SalInstanceTreeIter& rVclDest(static_cast<SalInstanceTreeIter&>(rDest));
- rVclDest.iter = rVclSource.iter;
- }
+void SalInstanceTreeView::set_image(const weld::TreeIter& rIter, VirtualDevice& rImage, int col)
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ set_image(rVclIter.iter, createImage(rImage), col);
+}
- virtual bool get_selected(weld::TreeIter* pIter) const override
- {
- SvTreeListEntry* pEntry = m_xTreeView->FirstSelected();
- auto pVclIter = static_cast<SalInstanceTreeIter*>(pIter);
- if (pVclIter)
- pVclIter->iter = pEntry;
- return pEntry != nullptr;
- }
+const OUString* SalInstanceTreeView::getEntryData(int index) const
+{
+ SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, index);
+ return pEntry ? static_cast<const OUString*>(pEntry->GetUserData()) : nullptr;
+}
- virtual bool get_cursor(weld::TreeIter* pIter) const override
- {
- SvTreeListEntry* pEntry = m_xTreeView->GetCurEntry();
- auto pVclIter = static_cast<SalInstanceTreeIter*>(pIter);
- if (pVclIter)
- pVclIter->iter = pEntry;
- return pEntry != nullptr;
- }
+OUString SalInstanceTreeView::get_id(int pos) const
+{
+ const OUString* pRet = getEntryData(pos);
+ if (!pRet)
+ return OUString();
+ return *pRet;
+}
- virtual void set_cursor(const weld::TreeIter& rIter) override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- disable_notify_events();
- m_xTreeView->SetCurEntry(rVclIter.iter);
- enable_notify_events();
- }
+void SalInstanceTreeView::set_id(SvTreeListEntry* pEntry, const OUString& rId)
+{
+ m_aUserData.emplace_back(std::make_unique<OUString>(rId));
+ pEntry->SetUserData(m_aUserData.back().get());
+}
- virtual bool get_iter_first(weld::TreeIter& rIter) const override
- {
- SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
- rVclIter.iter = m_xTreeView->GetEntry(0);
- return rVclIter.iter != nullptr;
- }
+void SalInstanceTreeView::set_id(int pos, const OUString& rId)
+{
+ SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
+ set_id(pEntry, rId);
+}
- virtual bool iter_next_sibling(weld::TreeIter& rIter) const override
- {
- SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
- rVclIter.iter = rVclIter.iter->NextSibling();
- return rVclIter.iter != nullptr;
- }
+int SalInstanceTreeView::get_selected_index() const
+{
+ assert(m_xTreeView->IsUpdateMode() && "don't request selection when frozen");
+ SvTreeListEntry* pEntry = m_xTreeView->FirstSelected();
+ if (!pEntry)
+ return -1;
+ return SvTreeList::GetRelPos(pEntry);
+}
- virtual bool iter_previous_sibling(weld::TreeIter& rIter) const override
- {
- SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
- rVclIter.iter = rVclIter.iter->PrevSibling();
- return rVclIter.iter != nullptr;
- }
+OUString SalInstanceTreeView::get_selected_text() const
+{
+ assert(m_xTreeView->IsUpdateMode() && "don't request selection when frozen");
+ if (SvTreeListEntry* pEntry = m_xTreeView->FirstSelected())
+ return m_xTreeView->GetEntryText(pEntry);
+ return OUString();
+}
- virtual bool iter_next(weld::TreeIter& rIter) const override
+OUString SalInstanceTreeView::get_selected_id() const
+{
+ assert(m_xTreeView->IsUpdateMode() && "don't request selection when frozen");
+ if (SvTreeListEntry* pEntry = m_xTreeView->FirstSelected())
{
- SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
- rVclIter.iter = m_xTreeView->Next(rVclIter.iter);
- if (rVclIter.iter && IsDummyEntry(rVclIter.iter))
- return iter_next(rVclIter);
- return rVclIter.iter != nullptr;
+ if (const OUString* pStr = static_cast<const OUString*>(pEntry->GetUserData()))
+ return *pStr;
}
+ return OUString();
+}
- virtual bool iter_previous(weld::TreeIter& rIter) const override
- {
- SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
- rVclIter.iter = m_xTreeView->Prev(rVclIter.iter);
- if (rVclIter.iter && IsDummyEntry(rVclIter.iter))
- return iter_previous(rVclIter);
- return rVclIter.iter != nullptr;
- }
+std::unique_ptr<weld::TreeIter>
+SalInstanceTreeView::make_iterator(const weld::TreeIter* pOrig) const
+{
+ return std::unique_ptr<weld::TreeIter>(
+ new SalInstanceTreeIter(static_cast<const SalInstanceTreeIter*>(pOrig)));
+}
- virtual bool iter_children(weld::TreeIter& rIter) const override
- {
- SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
- rVclIter.iter = m_xTreeView->FirstChild(rVclIter.iter);
- bool bRet = rVclIter.iter != nullptr;
- if (bRet)
- {
- //on-demand dummy entry doesn't count
- return !IsDummyEntry(rVclIter.iter);
- }
- return bRet;
- }
+void SalInstanceTreeView::copy_iterator(const weld::TreeIter& rSource, weld::TreeIter& rDest) const
+{
+ const SalInstanceTreeIter& rVclSource(static_cast<const SalInstanceTreeIter&>(rSource));
+ SalInstanceTreeIter& rVclDest(static_cast<SalInstanceTreeIter&>(rDest));
+ rVclDest.iter = rVclSource.iter;
+}
- virtual bool iter_parent(weld::TreeIter& rIter) const override
- {
- SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
- rVclIter.iter = m_xTreeView->GetParent(rVclIter.iter);
- return rVclIter.iter != nullptr;
- }
+bool SalInstanceTreeView::get_selected(weld::TreeIter* pIter) const
+{
+ SvTreeListEntry* pEntry = m_xTreeView->FirstSelected();
+ auto pVclIter = static_cast<SalInstanceTreeIter*>(pIter);
+ if (pVclIter)
+ pVclIter->iter = pEntry;
+ return pEntry != nullptr;
+}
- virtual void remove(const weld::TreeIter& rIter) override
- {
- disable_notify_events();
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- m_xTreeView->RemoveEntry(rVclIter.iter);
- enable_notify_events();
- }
+bool SalInstanceTreeView::get_cursor(weld::TreeIter* pIter) const
+{
+ SvTreeListEntry* pEntry = m_xTreeView->GetCurEntry();
+ auto pVclIter = static_cast<SalInstanceTreeIter*>(pIter);
+ if (pVclIter)
+ pVclIter->iter = pEntry;
+ return pEntry != nullptr;
+}
- virtual void select(const weld::TreeIter& rIter) override
- {
- assert(m_xTreeView->IsUpdateMode()
- && "don't select when frozen, select after thaw. Note selection doesn't survive a "
- "freeze");
- disable_notify_events();
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- m_xTreeView->Select(rVclIter.iter, true);
- enable_notify_events();
- }
+void SalInstanceTreeView::set_cursor(const weld::TreeIter& rIter)
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ disable_notify_events();
+ m_xTreeView->SetCurEntry(rVclIter.iter);
+ enable_notify_events();
+}
- virtual void scroll_to_row(const weld::TreeIter& rIter) override
- {
- assert(m_xTreeView->IsUpdateMode()
- && "don't select when frozen, select after thaw. Note selection doesn't survive a "
- "freeze");
- disable_notify_events();
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- m_xTreeView->MakeVisible(rVclIter.iter);
- enable_notify_events();
- }
+bool SalInstanceTreeView::get_iter_first(weld::TreeIter& rIter) const
+{
+ SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
+ rVclIter.iter = m_xTreeView->GetEntry(0);
+ return rVclIter.iter != nullptr;
+}
- virtual void unselect(const weld::TreeIter& rIter) override
- {
- assert(m_xTreeView->IsUpdateMode() && "don't unselect when frozen");
- disable_notify_events();
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- m_xTreeView->Select(rVclIter.iter, false);
- enable_notify_events();
- }
+bool SalInstanceTreeView::iter_next_sibling(weld::TreeIter& rIter) const
+{
+ SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
+ rVclIter.iter = rVclIter.iter->NextSibling();
+ return rVclIter.iter != nullptr;
+}
- virtual int get_iter_depth(const weld::TreeIter& rIter) const override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- return m_xTreeView->GetModel()->GetDepth(rVclIter.iter);
- }
+bool SalInstanceTreeView::iter_previous_sibling(weld::TreeIter& rIter) const
+{
+ SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
+ rVclIter.iter = rVclIter.iter->PrevSibling();
+ return rVclIter.iter != nullptr;
+}
- virtual bool iter_has_child(const weld::TreeIter& rIter) const override
- {
- weld::TreeIter& rNonConstIter = const_cast<weld::TreeIter&>(rIter);
- SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rNonConstIter);
- SvTreeListEntry* restore(rVclIter.iter);
- bool ret = iter_children(rNonConstIter);
- rVclIter.iter = restore;
- return ret;
- }
+bool SalInstanceTreeView::iter_next(weld::TreeIter& rIter) const
+{
+ SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
+ rVclIter.iter = m_xTreeView->Next(rVclIter.iter);
+ if (rVclIter.iter && IsDummyEntry(rVclIter.iter))
+ return iter_next(rVclIter);
+ return rVclIter.iter != nullptr;
+}
- virtual bool get_row_expanded(const weld::TreeIter& rIter) const override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- return m_xTreeView->IsExpanded(rVclIter.iter);
- }
+bool SalInstanceTreeView::iter_previous(weld::TreeIter& rIter) const
+{
+ SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
+ rVclIter.iter = m_xTreeView->Prev(rVclIter.iter);
+ if (rVclIter.iter && IsDummyEntry(rVclIter.iter))
+ return iter_previous(rVclIter);
+ return rVclIter.iter != nullptr;
+}
- virtual bool get_children_on_demand(const weld::TreeIter& rIter) const override
+bool SalInstanceTreeView::iter_children(weld::TreeIter& rIter) const
+{
+ SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
+ rVclIter.iter = m_xTreeView->FirstChild(rVclIter.iter);
+ bool bRet = rVclIter.iter != nullptr;
+ if (bRet)
{
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- if (m_aExpandingPlaceHolderParents.count(rVclIter.iter))
- return true;
- return GetPlaceHolderChild(rVclIter.iter) != nullptr;
+ //on-demand dummy entry doesn't count
+ return !IsDummyEntry(rVclIter.iter);
}
+ return bRet;
+}
- virtual void set_children_on_demand(const weld::TreeIter& rIter,
- bool bChildrenOnDemand) override
- {
- disable_notify_events();
+bool SalInstanceTreeView::iter_parent(weld::TreeIter& rIter) const
+{
+ SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
+ rVclIter.iter = m_xTreeView->GetParent(rVclIter.iter);
+ return rVclIter.iter != nullptr;
+}
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+void SalInstanceTreeView::remove(const weld::TreeIter& rIter)
+{
+ disable_notify_events();
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ m_xTreeView->RemoveEntry(rVclIter.iter);
+ enable_notify_events();
+}
- SvTreeListEntry* pPlaceHolder = GetPlaceHolderChild(rVclIter.iter);
+void SalInstanceTreeView::select(const weld::TreeIter& rIter)
+{
+ assert(m_xTreeView->IsUpdateMode()
+ && "don't select when frozen, select after thaw. Note selection doesn't survive a "
+ "freeze");
+ disable_notify_events();
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ m_xTreeView->Select(rVclIter.iter, true);
+ enable_notify_events();
+}
- if (bChildrenOnDemand && !pPlaceHolder)
- {
- pPlaceHolder = m_xTreeView->InsertEntry("<dummy>", rVclIter.iter, false, 0, nullptr);
- SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pPlaceHolder);
- pViewData->SetSelectable(false);
- }
- else if (!bChildrenOnDemand && pPlaceHolder)
- m_xTreeView->RemoveEntry(pPlaceHolder);
+void SalInstanceTreeView::scroll_to_row(const weld::TreeIter& rIter)
+{
+ assert(m_xTreeView->IsUpdateMode()
+ && "don't select when frozen, select after thaw. Note selection doesn't survive a "
+ "freeze");
+ disable_notify_events();
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ m_xTreeView->MakeVisible(rVclIter.iter);
+ enable_notify_events();
+}
- enable_notify_events();
- }
+void SalInstanceTreeView::unselect(const weld::TreeIter& rIter)
+{
+ assert(m_xTreeView->IsUpdateMode() && "don't unselect when frozen");
+ disable_notify_events();
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ m_xTreeView->Select(rVclIter.iter, false);
+ enable_notify_events();
+}
- virtual void expand_row(const weld::TreeIter& rIter) override
- {
- assert(m_xTreeView->IsUpdateMode() && "don't expand when frozen");
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- if (!m_xTreeView->IsExpanded(rVclIter.iter) && signal_expanding(rIter))
- m_xTreeView->Expand(rVclIter.iter);
- }
+int SalInstanceTreeView::get_iter_depth(const weld::TreeIter& rIter) const
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ return m_xTreeView->GetModel()->GetDepth(rVclIter.iter);
+}
- virtual void collapse_row(const weld::TreeIter& rIter) override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- if (m_xTreeView->IsExpanded(rVclIter.iter) && signal_collapsing(rIter))
- m_xTreeView->Collapse(rVclIter.iter);
- }
+bool SalInstanceTreeView::iter_has_child(const weld::TreeIter& rIter) const
+{
+ weld::TreeIter& rNonConstIter = const_cast<weld::TreeIter&>(rIter);
+ SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rNonConstIter);
+ SvTreeListEntry* restore(rVclIter.iter);
+ bool ret = iter_children(rNonConstIter);
+ rVclIter.iter = restore;
+ return ret;
+}
- virtual OUString get_text(const weld::TreeIter& rIter, int col) const override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- return get_text(rVclIter.iter, col);
- }
+bool SalInstanceTreeView::get_row_expanded(const weld::TreeIter& rIter) const
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ return m_xTreeView->IsExpanded(rVclIter.iter);
+}
- virtual void set_text(const weld::TreeIter& rIter, const OUString& rText, int col) override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- set_text(rVclIter.iter, rText, col);
- }
+bool SalInstanceTreeView::get_children_on_demand(const weld::TreeIter& rIter) const
+{
+ const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ if (m_aExpandingPlaceHolderParents.count(rVclIter.iter))
+ return true;
+ return GetPlaceHolderChild(rVclIter.iter) != nullptr;
+}
- virtual OUString get_id(const weld::TreeIter& rIter) const override
- {
- const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- const OUString* pStr = static_cast<const OUString*>(rVclIter.iter->GetUserData());
- if (pStr)
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list