Kaydet (Commit) 4075840e authored tarafından Caolán McNamara's avatar Caolán McNamara

weld OfaSwAutoFmtOptionsPage

Change-Id: Ia88fe2562dd87b33fdec0081a3adf27c8d10f407
Reviewed-on: https://gerrit.libreoffice.org/64449
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 7d22ed70
......@@ -1352,7 +1352,7 @@ void SbTreeListBox::AddEntry(
std::unique_ptr<Entry>&& rUserData)
{
OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(rUserData.release())));
m_xControl->insert(pParent, -1, rText, &sId, nullptr, nullptr, &rImage, bChildrenOnDemand);
m_xControl->insert(pParent, -1, &rText, &sId, nullptr, nullptr, &rImage, bChildrenOnDemand);
}
void SbTreeListBox::SetEntryBitmaps(weld::TreeIter& rIter, const OUString& rImage)
......
......@@ -352,9 +352,10 @@
#define RID_SVXSTR_ORDINAL NC_("RID_SVXSTR_ORDINAL", "Format ordinal numbers suffixes (1st -> 1^st)")
#define RID_SVXSTR_DEL_EMPTY_PARA NC_("RID_SVXSTR_DEL_EMPTY_PARA", "Remove blank paragraphs")
#define RID_SVXSTR_USER_STYLE NC_("RID_SVXSTR_USER_STYLE", "Replace Custom Styles")
#define RID_SVXSTR_BULLET NC_("RID_SVXSTR_BULLET", "Replace bullets with: ")
#define RID_SVXSTR_RIGHT_MARGIN NC_("RID_SVXSTR_RIGHT_MARGIN", "Combine single line paragraphs if length greater than")
#define RID_SVXSTR_NUM NC_("RID_SVXSTR_NUM", "Bulleted and numbered lists. Bullet symbol: ")
#define RID_SVXSTR_BULLET NC_("RID_SVXSTR_BULLET", "Replace bullets with: %1")
// To translators: %1 will be replaced with a percentage, e.g. "10%"
#define RID_SVXSTR_RIGHT_MARGIN NC_("RID_SVXSTR_RIGHT_MARGIN", "Combine single line paragraphs if length greater than %1")
#define RID_SVXSTR_NUM NC_("RID_SVXSTR_NUM", "Bulleted and numbered lists. Bullet symbol: %1")
#define RID_SVXSTR_BORDER NC_("RID_SVXSTR_BORDER", "Apply border")
#define RID_SVXSTR_CREATE_TABLE NC_("RID_SVXSTR_CREATE_TABLE", "Create table")
#define RID_SVXSTR_REPLACE_TEMPLATES NC_("RID_SVXSTR_REPLACE_TEMPLATES", "Apply Styles")
......
......@@ -1381,7 +1381,7 @@ void CuiConfigGroupListBox::FillScriptList(const css::uno::Reference< css::scrip
0, static_cast<void *>( theChild.get())));
OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())));
m_xTreeView->insert(pParentEntry, -1, uiName, &sId, nullptr, nullptr, &aImage, bChildOnDemand);
m_xTreeView->insert(pParentEntry, -1, &uiName, &sId, nullptr, nullptr, &aImage, bChildOnDemand);
}
}
}
......@@ -1451,7 +1451,7 @@ void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent
static_cast<void *>(rootNode.get())));
OUString aTitle(xImp->m_sDlgMacros);
OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())));
m_xTreeView->insert(nullptr, -1, aTitle, &sId, nullptr, nullptr, nullptr, true);
m_xTreeView->insert(nullptr, -1, &aTitle, &sId, nullptr, nullptr, nullptr, true);
}
else
{
......@@ -1467,7 +1467,7 @@ void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent
aArr.push_back( o3tl::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_STYLES, 0, nullptr ) ); // TODO last parameter should contain user data
OUString sStyle(xImp->m_aStrGroupStyles);
OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())));
m_xTreeView->insert(nullptr, -1, sStyle, &sId, nullptr, nullptr, nullptr, true);
m_xTreeView->insert(nullptr, -1, &sStyle, &sId, nullptr, nullptr, nullptr, true);
}
m_xTreeView->thaw();
......@@ -1759,7 +1759,7 @@ IMPL_LINK(CuiConfigGroupListBox, ExpandingHdl, weld::TreeIter&, rIter, bool)
SfxStyleInfo_Impl* pFamily = new SfxStyleInfo_Impl(lStyleFamily);
aArr.push_back( o3tl::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_STYLES, 0, pFamily ));
OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())));
m_xTreeView->insert(&rIter, -1, pFamily->sLabel, &sId, nullptr, nullptr, nullptr, false);
m_xTreeView->insert(&rIter, -1, &pFamily->sLabel, &sId, nullptr, nullptr, nullptr, false);
}
}
break;
......
......@@ -127,9 +127,6 @@ class OfaSwAutoFmtOptionsPage : public SfxTabPage
friend class VclPtr<OfaSwAutoFmtOptionsPage>;
using TabPage::ActivatePage;
VclPtr<OfaACorrCheckListBox> m_pCheckLB;
VclPtr<PushButton> m_pEditPB;
OUString sDeleteEmptyPara;
OUString sUseReplaceTbl;
OUString sCapitalStartWord;
......@@ -157,16 +154,16 @@ class OfaSwAutoFmtOptionsPage : public SfxTabPage
vcl::Font aByInputBulletFont;
sal_uInt16 nPercent;
std::unique_ptr<SvLBoxButtonData> m_xCheckButtonData;
std::unique_ptr<weld::TreeView> m_xCheckLB;
std::unique_ptr<weld::Button> m_xEditPB;
DECL_LINK(SelectHdl, SvTreeListBox*, void);
DECL_LINK(EditHdl, Button*, void);
DECL_LINK(DoubleClickEditHdl, SvTreeListBox*, bool);
SvTreeListEntry* CreateEntry(OUString& rTxt, sal_uInt16 nCol);
DECL_LINK(SelectHdl, weld::TreeView&, void);
DECL_LINK(EditHdl, weld::Button&, void);
DECL_LINK(DoubleClickEditHdl, weld::TreeView&, void);
void CreateEntry(const OUString& rTxt, sal_uInt16 nCol);
OfaSwAutoFmtOptionsPage( vcl::Window* pParent,
const SfxItemSet& rSet );
OfaSwAutoFmtOptionsPage(TabPageParent pParent, const SfxItemSet& rSet);
virtual ~OfaSwAutoFmtOptionsPage() override;
virtual void dispose() override;
......
......@@ -140,7 +140,7 @@ public:
void append(const OUString& rId, const OUString& rStr) { m_xTreeView->append(rId, rStr); }
void append(const OUString& rId, const OUString& rStr, const OUString& rImage)
{
m_xTreeView->insert(nullptr, -1, rStr, &rId, nullptr, nullptr, &rImage, false);
m_xTreeView->insert(nullptr, -1, &rStr, &rId, nullptr, nullptr, &rImage, false);
}
int n_children() const { return m_xTreeView->n_children(); }
void select(int pos) { m_xTreeView->select(pos); }
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface domain="cui">
<requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
<object class="GtkTreeStore" id="liststore1">
<columns>
<!-- column-name check1 -->
<column type="gboolean"/>
<!-- column-name check2 -->
<column type="gboolean"/>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkBox" id="ApplyAutoFmtPage">
<property name="visible">True</property>
<property name="can_focus">False</property>
......@@ -34,7 +46,6 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">2</property>
</packing>
</child>
......@@ -42,36 +53,30 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="applyautofmtpage|label1">[M]: Replace while modifying existing text</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="applyautofmtpage|label2">[T]: AutoCorrect while typing</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
......@@ -82,54 +87,78 @@
<property name="vexpand">True</property>
<property name="column_homogeneous">True</property>
<child>
<object class="GtkLabel" id="m">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="label" translatable="yes" context="applyautofmtpage|m">[M]</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="t">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="label" translatable="yes" context="applyautofmtpage|t">[T]</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="svtlo-SvSimpleTableContainer" id="list">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="Simple Table Container-selection1"/>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="list">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="model">liststore1</property>
<property name="search_column">0</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="Macro Library List-selection1"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="resizable">True</property>
<property name="spacing">6</property>
<property name="title" translatable="yes" context="applyautofmtpage|m">[M]</property>
<property name="alignment">0.5</property>
<child>
<object class="GtkCellRendererToggle" id="cellrenderer1"/>
<attributes>
<attribute name="active">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<property name="resizable">True</property>
<property name="spacing">6</property>
<property name="title" translatable="yes" context="applyautofmtpage|t">[T]</property>
<property name="alignment">0.5</property>
<child>
<object class="GtkCellRendererToggle" id="cellrenderer2"/>
<attributes>
<attribute name="active">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
<property name="resizable">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkCellRendererText" id="cellrenderer3"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="top_attach">0</property>
<property name="width">2</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
......
......@@ -75,7 +75,7 @@ HeaderBarItemBits::UPARROW An arrow pointing upwards is displayed behind
a corresponding list is sorted in ascending order.
The status of the arrow can be set/reset with SetItemBits().
HeaderBarItemBits::USERDRAW For this item, the UserDraw handler is called as well.
HeaderBarItemBits::STDSTYLE (HeaderBarItemBits::LEFT | HeaderBarItemBits::LEFTIMAGE | HeaderBarItemBits::VCENTER | HeaderBarItemBits::CLICKABLE)
HeaderBarItemBits::STDSTYLE (HeaderBarItemBits::LEFT | HeaderBarItemBits::LEFTIMAGE | HeaderBarItemBits::CLICKABLE)
--------------------------------------------------------------------------
......
......@@ -410,7 +410,7 @@ protected:
bool signal_expanding(TreeIter& rIter) { return m_aExpandingHdl.Call(rIter); }
public:
virtual void insert(weld::TreeIter* pParent, int pos, const OUString& rStr, const OUString* pId,
virtual void insert(weld::TreeIter* pParent, int pos, const OUString* pStr, const OUString* pId,
const OUString* pIconName, VirtualDevice* pImageSurface,
const OUString* pExpanderName, bool bChildrenOnDemand)
= 0;
......@@ -420,32 +420,32 @@ public:
void insert(int pos, const OUString& rStr, const OUString* pId, const OUString* pIconName,
VirtualDevice* pImageSurface)
{
insert(nullptr, pos, rStr, pId, pIconName, pImageSurface, nullptr, false);
insert(nullptr, pos, &rStr, pId, pIconName, pImageSurface, nullptr, false);
}
void insert_text(int pos, const OUString& rStr)
{
insert(nullptr, pos, rStr, nullptr, nullptr, nullptr, nullptr, false);
insert(nullptr, pos, &rStr, nullptr, nullptr, nullptr, nullptr, false);
}
void append_text(const OUString& rStr)
{
insert(nullptr, -1, rStr, nullptr, nullptr, nullptr, nullptr, false);
insert(nullptr, -1, &rStr, nullptr, nullptr, nullptr, nullptr, false);
}
void append(const OUString& rId, const OUString& rStr)
{
insert(nullptr, -1, rStr, &rId, nullptr, nullptr, nullptr, false);
insert(nullptr, -1, &rStr, &rId, nullptr, nullptr, nullptr, false);
}
void append(const OUString& rId, const OUString& rStr, const OUString& rImage)
{
insert(nullptr, -1, rStr, &rId, &rImage, nullptr, nullptr, false);
insert(nullptr, -1, &rStr, &rId, &rImage, nullptr, nullptr, false);
}
void append(weld::TreeIter* pParent, const OUString& rId, const OUString& rStr,
const OUString& rImage)
{
insert(pParent, -1, rStr, &rId, &rImage, nullptr, nullptr, false);
insert(pParent, -1, &rStr, &rId, &rImage, nullptr, nullptr, false);
}
void append(const OUString& rId, const OUString& rStr, VirtualDevice& rImage)
{
insert(nullptr, -1, rStr, &rId, nullptr, &rImage, nullptr, false);
insert(nullptr, -1, &rStr, &rId, nullptr, &rImage, nullptr, false);
}
void connect_changed(const Link<TreeView&, void>& rLink) { m_aChangeHdl = rLink; }
......@@ -456,6 +456,11 @@ public:
virtual void select(int pos) = 0;
virtual void unselect(int pos) = 0;
virtual void remove(int pos) = 0;
virtual OUString get_text(int row, int col = -1) const = 0;
virtual void set_text(int row, const OUString& rText, int col = -1) = 0;
virtual void set_id(int row, const OUString& rId) = 0;
virtual void set_toggle(int row, bool bOn, int col = -1) = 0;
virtual bool get_toggle(int row, int col = -1) const = 0;
virtual void set_top_entry(int pos) = 0;
virtual std::vector<int> get_selected_rows() const = 0;
virtual void set_font_color(int pos, const Color& rColor) const = 0;
......@@ -463,8 +468,6 @@ public:
virtual void set_cursor(int pos) = 0;
//by text
virtual OUString get_text(int row, int col = -1) const = 0;
virtual void set_text(int row, const OUString& rText, int col = -1) = 0;
virtual int find_text(const OUString& rText) const = 0;
OUString get_selected_text() const
{
......
......@@ -1823,6 +1823,7 @@ private:
// owner for UserData
std::vector<std::unique_ptr<OUString>> m_aUserData;
VclPtr<SvTabListBox> m_xTreeView;
SvLBoxButtonData m_aCheckButtonData;
DECL_LINK(SelectHdl, SvTreeListBox*, void);
DECL_LINK(DoubleClickHdl, SvTreeListBox*, bool);
......@@ -1833,6 +1834,7 @@ public:
SalInstanceTreeView(SvTabListBox* pTreeView, bool bTakeOwnership)
: SalInstanceContainer(pTreeView, bTakeOwnership)
, m_xTreeView(pTreeView)
, m_aCheckButtonData(pTreeView)
{
m_xTreeView->SetNodeDefaultImages();
m_xTreeView->SetSelectHdl(LINK(this, SalInstanceTreeView, SelectHdl));
......@@ -1876,7 +1878,7 @@ public:
return OUString();
}
virtual void insert(weld::TreeIter* pParent, int pos, const OUString& rStr, const OUString* pId,
virtual void insert(weld::TreeIter* pParent, int pos, const OUString* pStr, const OUString* pId,
const OUString* pIconName, VirtualDevice* pImageSurface, const OUString* pExpanderName,
bool bChildrenOnDemand) override
{
......@@ -1892,15 +1894,25 @@ public:
else
pUserData = nullptr;
bool bSimple = !pIconName && !pImageSurface && pStr;
SvTreeListEntry* pResult;
if (!pIconName && !pImageSurface)
pResult = m_xTreeView->InsertEntry(rStr, iter, false, nInsertPos, pUserData);
if (bSimple)
pResult = m_xTreeView->InsertEntry(*pStr, iter, false, nInsertPos, pUserData);
else
{
SvTreeListEntry* pEntry = new SvTreeListEntry;
Image aImage(pIconName ? createImage(*pIconName) : createImage(*pImageSurface));
pEntry->AddItem(o3tl::make_unique<SvLBoxContextBmp>(aImage, aImage, false));
pEntry->AddItem(o3tl::make_unique<SvLBoxString>(rStr));
if (pIconName || pImageSurface)
{
Image aImage(pIconName ? createImage(*pIconName) : createImage(*pImageSurface));
pEntry->AddItem(o3tl::make_unique<SvLBoxContextBmp>(aImage, aImage, false));
}
else
{
Image aDummy;
pEntry->AddItem(o3tl::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false));
}
if (pStr)
pEntry->AddItem(o3tl::make_unique<SvLBoxString>(*pStr));
pEntry->SetUserData(pUserData);
m_xTreeView->Insert(pEntry, iter, nInsertPos);
pResult = pEntry;
......@@ -2059,9 +2071,15 @@ public:
++col; //skip dummy/expander column
// blank out missing entries
for (int i = pEntry->ItemCount(); i < col ; ++i)
pEntry->AddItem(o3tl::make_unique<SvLBoxString>(""));
if (static_cast<size_t>(col) == pEntry->ItemCount())
{
pEntry->AddItem(o3tl::make_unique<SvLBoxString>(rText));
SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry);
m_xTreeView->InitViewData(pViewData, pEntry);
}
else
{
......@@ -2073,6 +2091,57 @@ public:
m_xTreeView->ModelHasEntryInvalidated(pEntry);
}
virtual bool get_toggle(int pos, int col) const override
{
SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
if (col == -1)
return m_xTreeView->GetCheckButtonState(pEntry) == SvButtonState::Checked;
++col; //skip dummy/expander column
if (static_cast<size_t>(col) == pEntry->ItemCount())
return false;
assert(col >= 0 && static_cast<size_t>(col) < pEntry->ItemCount());
SvLBoxItem& rItem = pEntry->GetItem(col);
assert(dynamic_cast<SvLBoxButton*>(&rItem));
return static_cast<SvLBoxButton&>(rItem).IsStateChecked();
}
virtual void set_toggle(int pos, bool bOn, int col) override
{
SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
if (col == -1)
{
m_xTreeView->SetCheckButtonState(pEntry, bOn ? SvButtonState::Checked : SvButtonState::Unchecked);
return;
}
++col; //skip dummy/expander column
// blank out missing entries
for (int i = pEntry->ItemCount(); i < col ; ++i)
pEntry->AddItem(o3tl::make_unique<SvLBoxString>(""));
if (static_cast<size_t>(col) == pEntry->ItemCount())
{
pEntry->AddItem(o3tl::make_unique<SvLBoxButton>(SvLBoxButtonKind::EnabledCheckbox,
&m_aCheckButtonData));
SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry);
m_xTreeView->InitViewData(pViewData, pEntry);
}
assert(col >= 0 && static_cast<size_t>(col) < pEntry->ItemCount());
SvLBoxItem& rItem = pEntry->GetItem(col);
assert(dynamic_cast<SvLBoxButton*>(&rItem));
if (bOn)
static_cast<SvLBoxButton&>(rItem).SetStateChecked();
else
static_cast<SvLBoxButton&>(rItem).SetStateUnchecked();
m_xTreeView->ModelHasEntryInvalidated(pEntry);
}
const OUString* getEntryData(int index) const
{
SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, index);
......@@ -2087,6 +2156,13 @@ public:
return *pRet;
}
virtual void set_id(int pos, const OUString& rId) override
{
SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
m_aUserData.emplace_back(o3tl::make_unique<OUString>(rId));
pEntry->SetUserData(m_aUserData.back().get());
}
virtual int get_selected_index() const override
{
assert(m_xTreeView->IsUpdateMode() && "don't request selection when frozen");
......
......@@ -1111,6 +1111,18 @@ namespace
return sTooltipText;
}
float extractAlignment(VclBuilder::stringmap &rMap)
{
float f = 0.0;
VclBuilder::stringmap::iterator aFind = rMap.find(OString("alignment"));
if (aFind != rMap.end())
{
f = aFind->second.toFloat();
rMap.erase(aFind);
}
return f;
}
OUString extractTitle(VclBuilder::stringmap &rMap)
{
OUString sTitle;
......@@ -1966,8 +1978,16 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
if (HeaderBar* pHeaderBar = pTreeView ? pTreeView->GetHeaderBar() : nullptr)
{
OUString sTitle(extractTitle(rMap));
HeaderBarItemBits nBits = (HeaderBarItemBits::LEFTIMAGE | HeaderBarItemBits::CLICKABLE);
float fAlign = extractAlignment(rMap);
if (fAlign == 0.0)
nBits |= HeaderBarItemBits::LEFT;
else if (fAlign == 1.0)
nBits |= HeaderBarItemBits::RIGHT;
else if (fAlign == 0.5)
nBits |= HeaderBarItemBits::CENTER;
auto nItemId = pHeaderBar->GetItemCount() + 1;
pHeaderBar->InsertItem(nItemId, sTitle, 100);
pHeaderBar->InsertItem(nItemId, sTitle, 100, nBits);
}
}
}
......
......@@ -4360,6 +4360,7 @@ private:
GtkTreeStore* m_pTreeStore;
std::unique_ptr<comphelper::string::NaturalStringSorter> m_xSorter;
gint m_nTextCol;
gint m_nToggleCol;
gint m_nImageCol;
gint m_nExpanderImageCol;
gint m_nIdCol;
......@@ -4388,11 +4389,11 @@ private:
pThis->signal_row_activated();
}
void insert_row(GtkTreeIter& iter, GtkTreeIter* parent, int pos, const OUString* pId, const OUString& rText,
void insert_row(GtkTreeIter& iter, GtkTreeIter* parent, int pos, const OUString* pId, const OUString* pText,
const OUString* pIconName, VirtualDevice* pDevice, const OUString* pExpanderName)
{
gtk_tree_store_insert_with_values(m_pTreeStore, &iter, parent, pos,
m_nTextCol, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(),
m_nTextCol, !pText ? nullptr : OUStringToOString(*pText, RTL_TEXTENCODING_UTF8).getStr(),
m_nIdCol, !pId ? nullptr : OUStringToOString(*pId, RTL_TEXTENCODING_UTF8).getStr(),
-1);
if (pIconName)
......@@ -4445,6 +4446,18 @@ private:
return sRet;
}
bool get_bool(int pos, int col) const
{
gboolean bRet(false);
GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore);
GtkTreeIter iter;
if (gtk_tree_model_iter_nth_child(pModel, &iter, nullptr, pos))
{
gtk_tree_model_get(pModel, &iter, col, &bRet, -1);
}
return bRet;
}
void set(int pos, int col, const OUString& rText)
{
GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore);
......@@ -4456,6 +4469,16 @@ private:
}
}
void set(int pos, int col, bool bOn)
{
GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore);
GtkTreeIter iter;
if (gtk_tree_model_iter_nth_child(pModel, &iter, nullptr, pos))
{
gtk_tree_store_set(m_pTreeStore, &iter, col, bOn, -1);
}
}
static gboolean signalTestExpandRow(GtkTreeView*, GtkTreeIter* iter, GtkTreePath*, gpointer widget)
{
GtkInstanceTreeView* pThis = static_cast<GtkInstanceTreeView*>(widget);
......@@ -4488,7 +4511,8 @@ private:
if (!bRet && bPlaceHolder)
{
GtkTreeIter subiter;
insert_row(subiter, &iter, -1, nullptr, "<dummy>", nullptr, nullptr, nullptr);
OUString sDummy("<dummy>");
insert_row(subiter, &iter, -1, nullptr, &sDummy, nullptr, nullptr, nullptr);
}
return bRet;
......@@ -4500,6 +4524,7 @@ public:
, m_pTreeView(pTreeView)
, m_pTreeStore(GTK_TREE_STORE(gtk_tree_view_get_model(m_pTreeView)))
, m_nTextCol(-1)
, m_nToggleCol(-1)
, m_nImageCol(-1)
, m_nExpanderImageCol(-1)
, m_nChangedSignalId(g_signal_connect(gtk_tree_view_get_selection(pTreeView), "changed",
......@@ -4518,6 +4543,8 @@ public:
GtkCellRenderer* pCellRenderer = GTK_CELL_RENDERER(pRenderer->data);
if (m_nTextCol == -1 && GTK_IS_CELL_RENDERER_TEXT(pCellRenderer))
m_nTextCol = nIndex;
else if (m_nToggleCol == -1 && GTK_IS_CELL_RENDERER_TOGGLE(pCellRenderer))
m_nToggleCol = nIndex;
else if (GTK_IS_CELL_RENDERER_PIXBUF(pCellRenderer))
{
const bool bExpander = g_list_next(pRenderer) != nullptr;
......@@ -4559,17 +4586,18 @@ public:
return sRet;
}
virtual void insert(weld::TreeIter* pParent, int pos, const OUString& rText, const OUString* pId, const OUString* pIconName,
virtual void insert(weld::TreeIter* pParent, int pos, const OUString* pText, const OUString* pId, const OUString* pIconName,
VirtualDevice* pImageSurface, const OUString* pExpanderName, bool bChildrenOnDemand) override
{
disable_notify_events();
GtkTreeIter iter;
GtkInstanceTreeIter* pGtkIter = static_cast<GtkInstanceTreeIter*>(pParent);
insert_row(iter, pGtkIter ? &pGtkIter->iter : nullptr, pos, pId, rText, pIconName, pImageSurface, pExpanderName);
insert_row(iter, pGtkIter ? &pGtkIter->iter : nullptr, pos, pId, pText, pIconName, pImageSurface, pExpanderName);
if (bChildrenOnDemand)
{
GtkTreeIter subiter;
insert_row(subiter, &iter, -1, nullptr, "<dummy>", nullptr, nullptr, nullptr);
OUString sDummy("<dummy>");
insert_row(subiter, &iter, -1, nullptr, &sDummy, nullptr, nullptr, nullptr);
}
enable_notify_events();
}
......@@ -4734,11 +4762,30 @@ public:
return set(pos, col, rText);
}
virtual bool get_toggle(int pos, int col) const override
{
if (col == -1)
return get_bool(pos, m_nToggleCol);
return get_bool(pos, col);
}
virtual void set_toggle(int pos, bool bOn, int col) override
{
if (col == -1)
return set(pos, m_nToggleCol, bOn);
return set(pos, col, bOn);
}
virtual OUString get_id(int pos) const override
{
return get(pos, m_nIdCol);
}
virtual void set_id(int pos, const OUString& rId) override
{
return set(pos, m_nIdCol, rId);
}
virtual int get_selected_index() const override
{
assert(gtk_tree_view_get_model(m_pTreeView) && "don't request selection when frozen");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment