[Libreoffice-commits] core.git: include/vcl sfx2/source sw/source vcl/source vcl/unx
Caolán McNamara
caolanm at redhat.com
Sun Mar 18 19:12:02 UTC 2018
include/vcl/weld.hxx | 17 +++++---
sfx2/source/doc/new.cxx | 6 +--
sfx2/source/doc/saveastemplatedlg.cxx | 2 -
sw/source/ui/table/instable.cxx | 4 +-
sw/source/ui/table/tautofmt.cxx | 8 ++--
vcl/source/app/salvtables.cxx | 43 ++++++++++++---------
vcl/unx/gtk3/gtk3gtkinst.cxx | 68 ++++++++++++++++++++--------------
7 files changed, 85 insertions(+), 63 deletions(-)
New commits:
commit 16f84d79ad209a4a6e033880d3059810c37e73c0
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sun Mar 18 16:54:43 2018 +0000
add id column support to tree view
Change-Id: I11702f58e488bcf3fcd49c45c11b5059298f81fd
Reviewed-on: https://gerrit.libreoffice.org/51512
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index b6c635e89e57..e63c20e75dbc 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -167,10 +167,10 @@ public:
virtual void set_active_id(const OUString& rStr) = 0;
virtual OUString get_text(int pos) const = 0;
virtual OUString get_id(int pos) const = 0;
- virtual void append_text(const OUString& rStr) = 0;
virtual void insert_text(int pos, const OUString& rStr) = 0;
- virtual void append(const OUString& rId, const OUString& rStr) = 0;
+ void append_text(const OUString& rStr) { insert_text(-1, rStr); }
virtual void insert(int pos, const OUString& rId, const OUString& rStr) = 0;
+ void append(const OUString& rId, const OUString& rStr) { insert(-1, rId, rStr); }
virtual int find_text(const OUString& rStr) const = 0;
virtual int find_id(const OUString& rId) const = 0;
virtual int get_count() const = 0;
@@ -199,8 +199,10 @@ protected:
void signal_row_activated() { m_aRowActivatedHdl.Call(*this); }
public:
- virtual void append(const OUString& rText) = 0;
- virtual void insert(const OUString& rText, int pos) = 0;
+ virtual void insert_text(const OUString& rText, int pos) = 0;
+ virtual void append_text(const OUString& rText) { insert_text(rText, -1); }
+ virtual void insert(int pos, const OUString& rId, const OUString& rStr) = 0;
+ virtual void append(const OUString& rId, const OUString& rStr) { insert(-1, rId, rStr); }
virtual int n_children() const = 0;
virtual void select(int pos) = 0;
using Container::remove;
@@ -208,9 +210,10 @@ public:
virtual int find(const OUString& rText) const = 0;
virtual void set_top_entry(int pos) = 0;
virtual void clear() = 0;
- virtual OUString get_selected() = 0;
- virtual int get_selected_index() = 0;
- virtual OUString get(int pos) = 0;
+ virtual OUString get_selected() const = 0;
+ virtual int get_selected_index() const = 0;
+ virtual OUString get(int pos) const = 0;
+ virtual OUString get_id(int pos) const = 0;
virtual int get_height_rows(int nRows) const = 0;
virtual void freeze() = 0;
diff --git a/sfx2/source/doc/new.cxx b/sfx2/source/doc/new.cxx
index ef6fbf939a93..1ec298ac3e52 100644
--- a/sfx2/source/doc/new.cxx
+++ b/sfx2/source/doc/new.cxx
@@ -188,9 +188,9 @@ IMPL_LINK( SfxNewFileDialog, RegionSelect, weld::TreeView&, rBox, void )
if (nc != -1 && nc != 0)
aSel = aSel.replaceAt(nc-1, 1, "");
if ( aSel.compareToIgnoreAsciiCase( SfxResId(STR_STANDARD) ) == 0 )
- m_xTemplateLb->append(SfxResId(STR_NONE));
+ m_xTemplateLb->append_text(SfxResId(STR_NONE));
for (sal_uInt16 i = 0; i < nCount; ++i)
- m_xTemplateLb->append(m_aTemplates.GetName(nRegion, i));
+ m_xTemplateLb->append_text(m_aTemplates.GetName(nRegion, i));
m_xTemplateLb->thaw();
m_xTemplateLb->select(0);
TemplateSelect(*m_xTemplateLb);
@@ -303,7 +303,7 @@ SfxNewFileDialog::SfxNewFileDialog(weld::Window *pParent, SfxNewFileDialogMode n
if (nCount)
{
for(sal_uInt16 i = 0; i < nCount; ++i)
- m_xRegionLb->append(m_aTemplates.GetFullRegionName(i));
+ m_xRegionLb->append_text(m_aTemplates.GetFullRegionName(i));
m_xRegionLb->connect_changed(LINK(this, SfxNewFileDialog, RegionSelect));
}
diff --git a/sfx2/source/doc/saveastemplatedlg.cxx b/sfx2/source/doc/saveastemplatedlg.cxx
index 76a647e94fa6..16295a606d09 100644
--- a/sfx2/source/doc/saveastemplatedlg.cxx
+++ b/sfx2/source/doc/saveastemplatedlg.cxx
@@ -117,7 +117,7 @@ void SfxSaveAsTemplateDialog::SetCategoryLBEntries(const std::vector<OUString>&
if (!rFolderNames.empty())
{
for (size_t i = 0, n = rFolderNames.size(); i < n; ++i)
- m_xLBCategory->insert(rFolderNames[i], i+1);
+ m_xLBCategory->insert_text(rFolderNames[i], i+1);
}
m_xLBCategory->select(0);
}
diff --git a/sw/source/ui/table/instable.cxx b/sw/source/ui/table/instable.cxx
index 1b1f46f52be5..958d3fde05de 100644
--- a/sw/source/ui/table/instable.cxx
+++ b/sw/source/ui/table/instable.cxx
@@ -132,14 +132,14 @@ void SwInsTableDlg::InitAutoTableFormat()
pTableTable->Load();
// Add "- none -" style autoformat table.
- m_xLbFormat->append( SwViewShell::GetShellRes()->aStrNone ); // Insert to listbox
+ m_xLbFormat->append_text(SwViewShell::GetShellRes()->aStrNone); // Insert to listbox
// Add other styles of autoformat tables.
for (sal_uInt8 i = 0, nCount = static_cast<sal_uInt8>(pTableTable->size());
i < nCount; i++)
{
SwTableAutoFormat const& rFormat = (*pTableTable)[ i ];
- m_xLbFormat->append(rFormat.GetName());
+ m_xLbFormat->append_text(rFormat.GetName());
if (pTAutoFormat && rFormat.GetName() == pTAutoFormat->GetName())
lbIndex = i;
}
diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx
index 68e5ba5b46c5..ce1a60a59e10 100644
--- a/sw/source/ui/table/tautofmt.cxx
+++ b/sw/source/ui/table/tautofmt.cxx
@@ -118,7 +118,7 @@ void SwAutoFormatDlg::Init( const SwTableAutoFormat* pSelFormat )
if( !bSetAutoFormat )
{
// Then the list to be expanded by the entry "- none -".
- m_xLbFormat->append(SwViewShell::GetShellRes()->aStrNone);
+ m_xLbFormat->append_text(SwViewShell::GetShellRes()->aStrNone);
nDfltStylePos = 1;
m_nIndex = 255;
}
@@ -127,7 +127,7 @@ void SwAutoFormatDlg::Init( const SwTableAutoFormat* pSelFormat )
i < nCount; i++)
{
SwTableAutoFormat const& rFormat = (*m_xTableTable)[ i ];
- m_xLbFormat->append(rFormat.GetName());
+ m_xLbFormat->append_text(rFormat.GetName());
if (pSelFormat && rFormat.GetName() == pSelFormat->GetName())
m_nIndex = i;
}
@@ -229,7 +229,7 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, AddHdl, weld::Button&, void)
break;
m_xTableTable->InsertAutoFormat(n, std::move(pNewData));
- m_xLbFormat->insert(aFormatName, nDfltStylePos + n);
+ m_xLbFormat->insert_text(aFormatName, nDfltStylePos + n);
m_xLbFormat->select(nDfltStylePos + n);
bFormatInserted = true;
m_xBtnAdd->set_sensitive(false);
@@ -329,7 +329,7 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, RenameHdl, weld::Button&, void)
}
m_xTableTable->InsertAutoFormat( n, std::move(p) );
- m_xLbFormat->insert(aFormatName, nDfltStylePos + n);
+ m_xLbFormat->insert_text(aFormatName, nDfltStylePos + n);
m_xLbFormat->select(nDfltStylePos + n);
if ( !bCoreDataChanged )
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index bb66da6b4fb5..1373baff4f03 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -857,14 +857,15 @@ public:
m_xTreeView->SetDoubleClickHdl(LINK(this, SalInstanceTreeView, DoubleClickHdl));
}
- virtual void append(const OUString& rText) override
+ virtual void insert_text(const OUString& rText, int pos) override
{
- m_xTreeView->InsertEntry(rText);
+ m_xTreeView->InsertEntry(rText, pos);
}
- virtual void insert(const OUString& rText, int pos) override
+ virtual void insert(int pos, const OUString& rId, const OUString& rStr) override
{
- m_xTreeView->InsertEntry(rText, pos);
+ m_xTreeView->SetEntryData(m_xTreeView->InsertEntry(rStr, pos == -1 ? COMBOBOX_APPEND : pos),
+ new OUString(rId));
}
using SalInstanceContainer::remove;
@@ -906,17 +907,30 @@ public:
m_xTreeView->SelectEntryPos(pos);
}
- virtual OUString get_selected() override
+ virtual OUString get_selected() const override
{
return m_xTreeView->GetSelectedEntry();
}
- virtual OUString get(int pos) override
+ virtual OUString get(int pos) const override
{
return m_xTreeView->GetEntry(pos);
}
- virtual int get_selected_index() override
+ const OUString* getEntryData(int index) const
+ {
+ return static_cast<const OUString*>(m_xTreeView->GetEntryData(index));
+ }
+
+ virtual OUString get_id(int pos) const override
+ {
+ const OUString* pRet = getEntryData(pos);
+ if (!pRet)
+ return OUString();
+ return *pRet;
+ }
+
+ virtual int get_selected_index() const override
{
const sal_Int32 nRet = m_xTreeView->GetSelectedEntryPos();
if (nRet == LISTBOX_ENTRY_NOTFOUND)
@@ -1278,24 +1292,15 @@ public:
return *pRet;
}
- virtual void append_text(const OUString& rStr) override
- {
- m_xComboBoxText->InsertEntry(rStr);
- }
-
virtual void insert_text(int pos, const OUString& rStr) override
{
- m_xComboBoxText->InsertEntry(rStr, pos);
- }
-
- virtual void append(const OUString& rId, const OUString& rStr) override
- {
- m_xComboBoxText->SetEntryData(m_xComboBoxText->InsertEntry(rStr), new OUString(rId));
+ m_xComboBoxText->InsertEntry(rStr, pos == -1 ? COMBOBOX_APPEND : pos);
}
virtual void insert(int pos, const OUString& rId, const OUString& rStr) override
{
- m_xComboBoxText->SetEntryData(m_xComboBoxText->InsertEntry(rStr, pos), new OUString(rId));
+ m_xComboBoxText->SetEntryData(m_xComboBoxText->InsertEntry(rStr, pos == -1 ? COMBOBOX_APPEND : pos),
+ new OUString(rId));
}
virtual int get_count() const override
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index e249a21dc5aa..13b957dff0f2 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -2080,6 +2080,22 @@ private:
GtkInstanceTreeView* pThis = static_cast<GtkInstanceTreeView*>(widget);
pThis->signal_row_activated();
}
+
+ OUString get(int pos, int col) const
+ {
+ OUString sRet;
+ GtkTreeModel *pModel = GTK_TREE_MODEL(m_pListStore);
+ GtkTreeIter iter;
+ if (gtk_tree_model_iter_nth_child(pModel, &iter, nullptr, pos))
+ {
+ gchar* pStr;
+ gtk_tree_model_get(pModel, &iter, col, &pStr, -1);
+ sRet = OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8);
+ g_free(pStr);
+ }
+ return sRet;
+ }
+
public:
GtkInstanceTreeView(GtkTreeView* pTreeView, bool bTakeOwnership)
: GtkInstanceContainer(GTK_CONTAINER(pTreeView), bTakeOwnership)
@@ -2091,17 +2107,24 @@ public:
{
}
- virtual void append(const OUString& rText) override
+ virtual void insert_text(const OUString& rText, int pos) override
{
- insert(rText, -1);
+ disable_notify_events();
+ GtkTreeIter iter;
+ gtk_list_store_insert(m_pListStore, &iter, pos);
+ gtk_list_store_set(m_pListStore, &iter, 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), -1);
+ enable_notify_events();
}
- virtual void insert(const OUString& rText, int pos) override
+ virtual void insert(int pos, const OUString& rId, const OUString& rText) override
{
disable_notify_events();
GtkTreeIter iter;
gtk_list_store_insert(m_pListStore, &iter, pos);
- gtk_list_store_set(m_pListStore, &iter, 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), -1);
+ gtk_list_store_set(m_pListStore, &iter,
+ 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(),
+ 1, OUStringToOString(rId, RTL_TEXTENCODING_UTF8).getStr(),
+ -1);
enable_notify_events();
}
@@ -2175,7 +2198,7 @@ public:
enable_notify_events();
}
- virtual OUString get_selected() override
+ virtual OUString get_selected() const override
{
OUString sRet;
GtkTreeIter iter;
@@ -2190,18 +2213,17 @@ public:
return sRet;
}
- virtual OUString get(int pos) override
+ virtual OUString get(int pos) const override
{
- GtkTreeIter iter;
- gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(m_pListStore), &iter, nullptr, pos);
- gchar *pStr = nullptr;
- gtk_tree_model_get(GTK_TREE_MODEL(m_pListStore), &iter, 0, &pStr, -1);
- OUString sRet = OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8);
- g_free(pStr);
- return sRet;
+ return get(pos, 0);
}
- virtual int get_selected_index() override
+ virtual OUString get_id(int pos) const override
+ {
+ return get(pos, 1);
+ }
+
+ virtual int get_selected_index() const override
{
int nRet = -1;
GtkTreeIter iter;
@@ -2632,7 +2654,7 @@ private:
{
gchar* pStr;
gtk_tree_model_get(pModel, &iter, col, &pStr, -1);
- sRet = OUString(pStr, strlen(pStr), RTL_TEXTENCODING_UTF8);
+ sRet = OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8);
g_free(pStr);
}
return sRet;
@@ -2730,28 +2752,20 @@ public:
return get(pos, id_column);
}
- virtual void append_text(const OUString& rStr) override
- {
- gtk_combo_box_text_append_text(m_pComboBoxText, OUStringToOString(rStr, RTL_TEXTENCODING_UTF8).getStr());
- }
-
virtual void insert_text(int pos, const OUString& rStr) override
{
+ disable_notify_events();
gtk_combo_box_text_insert_text(m_pComboBoxText, pos, OUStringToOString(rStr, RTL_TEXTENCODING_UTF8).getStr());
- }
-
- virtual void append(const OUString& rId, const OUString& rStr) override
- {
- gtk_combo_box_text_append(m_pComboBoxText,
- OUStringToOString(rId, RTL_TEXTENCODING_UTF8).getStr(),
- OUStringToOString(rStr, RTL_TEXTENCODING_UTF8).getStr());
+ enable_notify_events();
}
virtual void insert(int pos, const OUString& rId, const OUString& rStr) override
{
+ disable_notify_events();
gtk_combo_box_text_insert(m_pComboBoxText, pos,
OUStringToOString(rId, RTL_TEXTENCODING_UTF8).getStr(),
OUStringToOString(rStr, RTL_TEXTENCODING_UTF8).getStr());
+ enable_notify_events();
}
virtual int get_count() const override
More information about the Libreoffice-commits
mailing list