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

weld SwTOXStylesTabPage

Change-Id: I1e7056ef8293ddc7072e95ee248e45b2785d1234
Reviewed-on: https://gerrit.libreoffice.org/62347
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 749ef30c
......@@ -429,6 +429,7 @@ public:
void unselect_all() { select(-1); }
virtual int n_children() const = 0;
virtual void make_sorted() = 0;
virtual void clear() = 0;
virtual int get_height_rows(int nRows) const = 0;
......
This diff is collapsed.
......@@ -447,34 +447,33 @@ public:
class SwTOXStylesTabPage : public SfxTabPage
{
VclPtr<ListBox> m_pLevelLB;
VclPtr<PushButton> m_pAssignBT;
VclPtr<ListBox> m_pParaLayLB;
VclPtr<PushButton> m_pStdBT;
VclPtr<PushButton> m_pEditStyleBT;
std::unique_ptr<SwForm> m_pCurrentForm;
DECL_LINK( EditStyleHdl, Button *, void );
DECL_LINK( StdHdl, Button*, void );
DECL_LINK(EnableSelectHdl, ListBox&, void);
DECL_LINK( DoubleClickHdl, ListBox&, void );
DECL_LINK( AssignHdl, Button*, void );
std::unique_ptr<weld::TreeView> m_xLevelLB;
std::unique_ptr<weld::Button> m_xAssignBT;
std::unique_ptr<weld::TreeView> m_xParaLayLB;
std::unique_ptr<weld::Button> m_xStdBT;
std::unique_ptr<weld::Button> m_xEditStyleBT;
DECL_LINK(EditStyleHdl, weld::Button&, void);
DECL_LINK(StdHdl, weld::Button&, void);
DECL_LINK(EnableSelectHdl, weld::TreeView&, void);
DECL_LINK(DoubleClickHdl, weld::TreeView&, void);
DECL_LINK(AssignHdl, weld::Button&, void);
void Modify();
SwForm& GetForm()
{
SwMultiTOXTabDialog* pDlg = static_cast<SwMultiTOXTabDialog*>(GetTabDialog());
return *pDlg->GetForm(pDlg->GetCurrentTOXType());
}
{
SwMultiTOXTabDialog* pDlg = static_cast<SwMultiTOXTabDialog*>(GetTabDialog());
return *pDlg->GetForm(pDlg->GetCurrentTOXType());
}
using SfxTabPage::ActivatePage;
using SfxTabPage::DeactivatePage;
public:
SwTOXStylesTabPage(vcl::Window* pParent, const SfxItemSet& rAttrSet);
SwTOXStylesTabPage(TabPageParent pParent, const SfxItemSet& rAttrSet);
virtual ~SwTOXStylesTabPage() override;
virtual void dispose() override;
virtual bool FillItemSet( SfxItemSet* ) override;
virtual void Reset( const SfxItemSet* ) override;
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface domain="sw">
<!-- interface-requires gtk+ 3.0 -->
<requires lib="gtk+" version="3.18"/>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">sw/res/one_left.png</property>
</object>
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="liststore2">
<columns>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkBox" id="TocStylesPage">
<property name="visible">True</property>
<property name="can_focus">False</property>
......@@ -35,81 +57,106 @@
<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="tocstylespage|label1">_Levels</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">levels:border</property>
<property name="mnemonic_widget">levels</property>
<property name="xalign">0</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="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="tocstylespage|label2">Paragraph _Styles</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">styles:border</property>
<property name="mnemonic_widget">styles</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="levels:border">
<object class="GtkTreeView" id="levels">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="model">liststore1</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="search_column">0</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<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="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="styles:border">
<object class="GtkTreeView" id="styles">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="model">liststore2</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="search_column">0</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection2"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
......@@ -125,8 +172,6 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
......@@ -142,8 +187,6 @@
<packing>
<property name="left_attach">2</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
......@@ -158,8 +201,6 @@
<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>
<child>
......@@ -190,11 +231,6 @@
</packing>
</child>
</object>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixbuf">sw/res/one_left.png</property>
</object>
<object class="GtkSizeGroup" id="sizegroup1">
<widgets>
<widget name="default"/>
......@@ -203,8 +239,8 @@
</object>
<object class="GtkSizeGroup" id="sizegroup2">
<widgets>
<widget name="levels:border"/>
<widget name="styles:border"/>
<widget name="levels"/>
<widget name="styles"/>
</widgets>
</object>
</interface>
......@@ -1860,6 +1860,11 @@ public:
return m_xTreeView->CalcWindowSizePixel(nRows);
}
virtual void make_sorted() override
{
m_xTreeView->SetStyle(m_xTreeView->GetStyle() | WB_SORT);
}
ListBox& getTreeView()
{
return *m_xTreeView;
......
......@@ -3912,11 +3912,29 @@ namespace
}
}
namespace
{
gint sort_func(GtkTreeModel* pModel, GtkTreeIter* a, GtkTreeIter* b, gpointer data)
{
comphelper::string::NaturalStringSorter* pSorter = static_cast<comphelper::string::NaturalStringSorter*>(data);
gchar* pName1;
gchar* pName2;
gtk_tree_model_get(pModel, a, 0, &pName1, -1);
gtk_tree_model_get(pModel, b, 0, &pName2, -1);
gint ret = pSorter->compare(OUString(pName1, strlen(pName1), RTL_TEXTENCODING_UTF8),
OUString(pName2, strlen(pName2), RTL_TEXTENCODING_UTF8));
g_free(pName1);
g_free(pName2);
return ret;
}
}
class GtkInstanceTreeView : public GtkInstanceContainer, public virtual weld::TreeView
{
private:
GtkTreeView* m_pTreeView;
GtkListStore* m_pListStore;
std::unique_ptr<comphelper::string::NaturalStringSorter> m_xSorter;
gulong m_nChangedSignalId;
gulong m_nRowActivatedSignalId;
......@@ -4036,6 +4054,16 @@ public:
enable_notify_events();
}
virtual void make_sorted() override
{
m_xSorter.reset(new comphelper::string::NaturalStringSorter(
::comphelper::getProcessComponentContext(),
Application::GetSettings().GetUILanguageTag().getLocale()));
GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(m_pListStore);
gtk_tree_sortable_set_sort_func(pSortable, 0, sort_func, m_xSorter.get(), nullptr);
gtk_tree_sortable_set_sort_column_id(pSortable, 0, GTK_SORT_ASCENDING);
}
virtual int n_children() const override
{
return gtk_tree_model_iter_n_children(GTK_TREE_MODEL(m_pListStore), nullptr);
......@@ -4122,12 +4150,22 @@ public:
g_object_ref(m_pListStore);
GtkInstanceContainer::freeze();
gtk_tree_view_set_model(m_pTreeView, nullptr);
if (m_xSorter)
{
GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(m_pListStore);
gtk_tree_sortable_set_sort_column_id(pSortable, GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
}
enable_notify_events();
}
virtual void thaw() override
{
disable_notify_events();
if (m_xSorter)
{
GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(m_pListStore);
gtk_tree_sortable_set_sort_column_id(pSortable, 0, GTK_SORT_ASCENDING);
}
gtk_tree_view_set_model(m_pTreeView, GTK_TREE_MODEL(m_pListStore));
GtkInstanceContainer::thaw();
g_object_unref(m_pListStore);
......@@ -4853,23 +4891,6 @@ public:
}
};
namespace
{
gint sort_func(GtkTreeModel* pModel, GtkTreeIter* a, GtkTreeIter* b, gpointer data)
{
comphelper::string::NaturalStringSorter* pSorter = static_cast<comphelper::string::NaturalStringSorter*>(data);
gchar* pName1;
gchar* pName2;
gtk_tree_model_get(pModel, a, 0, &pName1, -1);
gtk_tree_model_get(pModel, b, 0, &pName2, -1);
gint ret = pSorter->compare(OUString(pName1, strlen(pName1), RTL_TEXTENCODING_UTF8),
OUString(pName2, strlen(pName2), RTL_TEXTENCODING_UTF8));
g_free(pName1);
g_free(pName2);
return ret;
}
}
class GtkInstanceComboBox : public GtkInstanceContainer, public vcl::ISearchableStringList, public virtual weld::ComboBox
{
private:
......
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