[Libreoffice-commits] core.git: cui/source include/svx include/vcl sc/source sd/source sfx2/source svtools/source svx/source sw/source vcl/source vcl/unx
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Oct 10 14:57:43 UTC 2018
cui/source/customize/cfg.cxx | 4
cui/source/dialogs/cuicharmap.cxx | 15 +--
cui/source/options/optjava.cxx | 2
cui/source/tabpages/chardlg.cxx | 7 -
include/svx/langbox.hxx | 4
include/vcl/weld.hxx | 69 ++++++++++---
sc/source/ui/miscdlgs/mvtabdlg.cxx | 3
sd/source/ui/dlg/PhotoAlbumDialog.cxx | 8 -
sd/source/ui/dlg/custsdlg.cxx | 5 -
sfx2/source/dialog/mgetempl.cxx | 3
sfx2/source/doc/saveastemplatedlg.cxx | 2
svtools/source/control/ctrlbox.cxx | 4
svx/source/dialog/dlgctrl.cxx | 4
svx/source/dialog/langbox.cxx | 53 +++++++---
sw/source/ui/dbui/customizeaddresslistdialog.cxx | 4
sw/source/ui/frmdlg/column.cxx | 3
sw/source/ui/misc/outline.cxx | 2
sw/source/ui/table/tautofmt.cxx | 4
sw/source/uibase/misc/numberingtypelistbox.cxx | 3
sw/source/uibase/utlui/uitool.cxx | 2
vcl/source/app/salvtables.cxx | 32 +++---
vcl/unx/generic/print/prtsetup.cxx | 3
vcl/unx/gtk3/gtk3gtkinst.cxx | 114 +++++++++++------------
23 files changed, 209 insertions(+), 141 deletions(-)
New commits:
commit 3b21fed4b153e3bbf1d47c3073f31a3735538596
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Oct 10 12:18:13 2018 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Oct 10 16:57:12 2018 +0200
optimize adding a block of entries at one time
Change-Id: I9a59154fa445cf3c44ede3ceb1d09f408d906530
Reviewed-on: https://gerrit.libreoffice.org/61618
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index af8fea0455f7..3d48ae269a56 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -1971,7 +1971,7 @@ IMPL_LINK_NOARG(SvxMainMenuOrganizerDialog, ModifyHdl, weld::Entry&, void)
const int nNewMenuPos = m_xMenuListBox->find_id(m_sNewMenuEntryId);
const int nOldSelection = m_xMenuListBox->get_selected_index();
m_xMenuListBox->remove(nNewMenuPos);
- m_xMenuListBox->insert(nNewMenuPos, m_sNewMenuEntryId, pNewEntryData->GetName(), nullptr, nullptr);
+ m_xMenuListBox->insert(nNewMenuPos, pNewEntryData->GetName(), &m_sNewMenuEntryId, nullptr, nullptr);
m_xMenuListBox->select(nOldSelection);
}
@@ -2009,7 +2009,7 @@ IMPL_LINK( SvxMainMenuOrganizerDialog, MoveHdl, weld::Button&, rButton, void )
OUString sId = m_xMenuListBox->get_id(nSourceEntry);
OUString sEntry = m_xMenuListBox->get_text(nSourceEntry);
m_xMenuListBox->remove(nSourceEntry);
- m_xMenuListBox->insert(nTargetEntry, sId, sEntry, nullptr, nullptr);
+ m_xMenuListBox->insert(nTargetEntry, sEntry, &sId, nullptr, nullptr);
m_xMenuListBox->select(nTargetEntry);
UpdateButtonStates();
diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx
index c0de50c1e564..4ffc213003ca 100644
--- a/cui/source/dialogs/cuicharmap.cxx
+++ b/cui/source/dialogs/cuicharmap.cxx
@@ -422,17 +422,18 @@ void SvxCharacterMap::init()
OUString aDefStr( aFont.GetFamilyName() );
OUString aLastName;
int nCount = m_xVirDev->GetDevFontCount();
- m_xFontLB->freeze();
+ std::vector<weld::ComboBoxEntry> aEntries;
+ aEntries.reserve(nCount);
for (int i = 0; i < nCount; ++i)
{
OUString aFontName( m_xVirDev->GetDevFont( i ).GetFamilyName() );
if (aFontName != aLastName)
{
aLastName = aFontName;
- m_xFontLB->append(OUString::number(i), aFontName);
+ aEntries.emplace_back(aFontName, OUString::number(i));
}
}
- m_xFontLB->thaw();
+ m_xFontLB->insert_vector(aEntries, true);
// the font may not be in the list =>
// try to find a font name token in list and select found font,
// else select topmost entry
@@ -596,14 +597,12 @@ void SvxCharacterMap::SetCharFont( const vcl::Font& rFont )
void SvxCharacterMap::fillAllSubsets(weld::ComboBox& rListBox)
{
SubsetMap aAll(nullptr);
- rListBox.clear();
- rListBox.freeze();
+ std::vector<weld::ComboBoxEntry> aEntries;
for (auto & subset : aAll.GetSubsetMap())
- rListBox.append_text(subset.GetName());
- rListBox.thaw();
+ aEntries.emplace_back(subset.GetName());
+ rListBox.insert_vector(aEntries, true);
}
-
void SvxCharacterMap::insertCharToDoc(const OUString& sGlyph)
{
if(sGlyph.isEmpty())
diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx
index f115faedc701..9b3660d35592 100644
--- a/cui/source/options/optjava.cxx
+++ b/cui/source/options/optjava.cxx
@@ -804,7 +804,7 @@ void SvxJavaParameterDlg::EditParameter()
if ( !editedClassPath.isEmpty() && editableClassPath != editedClassPath )
{
m_xAssignedList->remove(nPos);
- m_xAssignedList->insert_text(editedClassPath, nPos);
+ m_xAssignedList->insert_text(nPos, editedClassPath);
m_xAssignedList->select(nPos);
}
}
diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx
index c4b7432e1bdc..eb80b4187fdf 100644
--- a/cui/source/tabpages/chardlg.cxx
+++ b/cui/source/tabpages/chardlg.cxx
@@ -604,14 +604,15 @@ namespace
void FillFontNames(weld::ComboBox& rBox, const FontList& rList)
{
// insert fonts
- rBox.freeze();
sal_uInt16 nFontCount = rList.GetFontNameCount();
+ std::vector<weld::ComboBoxEntry> aVector;
+ aVector.reserve(nFontCount);
for (sal_uInt16 i = 0; i < nFontCount; ++i)
{
const FontMetric& rFontMetric = rList.GetFontName(i);
- rBox.append_text(rFontMetric.GetFamilyName());
+ aVector.emplace_back(rFontMetric.GetFamilyName());
}
- rBox.thaw();
+ rBox.insert_vector(aVector, false);
}
}
diff --git a/include/svx/langbox.hxx b/include/svx/langbox.hxx
index 3dbb96977e37..74ecd76673d9 100644
--- a/include/svx/langbox.hxx
+++ b/include/svx/langbox.hxx
@@ -150,6 +150,10 @@ private:
bool m_bLangNoneIsLangAll;
bool m_bWithCheckmark;
+ SVX_DLLPRIVATE weld::ComboBoxEntry BuildEntry(const LanguageType nLangType);
+ SVX_DLLPRIVATE void AddLanguages(const std::vector< LanguageType >& rLanguageTypes, SvxLanguageListFlags nLangList,
+ std::vector<weld::ComboBoxEntry>& rEntries);
+
SVX_DLLPRIVATE int ImplTypeToPos(LanguageType eType) const;
SVX_DLLPRIVATE void ImplClear();
DECL_LINK(ChangeHdl, weld::ComboBox&, void);
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 86ecdfe01032..b7f39954be2c 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -253,6 +253,28 @@ public:
virtual Container* weld_message_area() = 0;
};
+struct VCL_DLLPUBLIC ComboBoxEntry
+{
+ OUString sString;
+ OUString sId;
+ OUString sImage;
+ ComboBoxEntry(const OUString& rString)
+ : sString(rString)
+ {
+ }
+ ComboBoxEntry(const OUString& rString, const OUString& rId)
+ : sString(rString)
+ , sId(rId)
+ {
+ }
+ ComboBoxEntry(const OUString& rString, const OUString& rId, const OUString& rImage)
+ : sString(rString)
+ , sId(rId)
+ , sImage(rImage)
+ {
+ }
+};
+
class VCL_DLLPUBLIC ComboBox : virtual public Container
{
private:
@@ -265,22 +287,27 @@ protected:
void signal_changed() { m_aChangeHdl.Call(*this); }
public:
- virtual void insert_text(int pos, 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,
+ virtual void insert(int pos, const OUString& rStr, const OUString* pId,
const OUString* pIconName, VirtualDevice* pImageSurface)
= 0;
+ virtual void insert_vector(const std::vector<weld::ComboBoxEntry>& rItems, bool bKeepExisting)
+ = 0;
+ void insert_text(int pos, const OUString& rStr)
+ {
+ insert(pos, rStr, nullptr, nullptr, nullptr);
+ }
+ void append_text(const OUString& rStr) { insert(-1, rStr, nullptr, nullptr, nullptr); }
void append(const OUString& rId, const OUString& rStr)
{
- insert(-1, rId, rStr, nullptr, nullptr);
+ insert(-1, rStr, &rId, nullptr, nullptr);
}
void append(const OUString& rId, const OUString& rStr, const OUString& rImage)
{
- insert(-1, rId, rStr, &rImage, nullptr);
+ insert(-1, rStr, &rId, &rImage, nullptr);
}
void append(const OUString& rId, const OUString& rStr, VirtualDevice& rImage)
{
- insert(-1, rId, rStr, nullptr, &rImage);
+ insert(-1, rStr, &rId, nullptr, &rImage);
}
virtual int get_count() const = 0;
@@ -334,22 +361,25 @@ protected:
void signal_row_activated() { m_aRowActivatedHdl.Call(*this); }
public:
- virtual void insert_text(const OUString& rText, int pos) = 0;
- virtual void insert(int pos, const OUString& rId, const OUString& rStr,
+ virtual void insert(int pos, const OUString& rStr, const OUString* pId,
const OUString* pIconName, VirtualDevice* pImageSurface)
= 0;
- void append_text(const OUString& rText) { insert_text(rText, -1); }
+ void insert_text(int pos, const OUString& rStr)
+ {
+ insert(pos, rStr, nullptr, nullptr, nullptr);
+ }
+ void append_text(const OUString& rStr) { insert(-1, rStr, nullptr, nullptr, nullptr); }
void append(const OUString& rId, const OUString& rStr)
{
- insert(-1, rId, rStr, nullptr, nullptr);
+ insert(-1, rStr, &rId, nullptr, nullptr);
}
void append(const OUString& rId, const OUString& rStr, const OUString& rImage)
{
- insert(-1, rId, rStr, &rImage, nullptr);
+ insert(-1, rStr, &rId, &rImage, nullptr);
}
void append(const OUString& rId, const OUString& rStr, VirtualDevice& rImage)
{
- insert(-1, rId, rStr, nullptr, &rImage);
+ insert(-1, rStr, &rId, nullptr, &rImage);
}
void connect_changed(const Link<TreeView&, void>& rLink) { m_aChangeHdl = rLink; }
@@ -671,14 +701,21 @@ protected:
public:
EntryTreeView(std::unique_ptr<Entry> xEntry, std::unique_ptr<TreeView> xTreeView);
- virtual void insert_text(int pos, const OUString& rStr) override
+ virtual void insert_vector(const std::vector<weld::ComboBoxEntry>& rItems,
+ bool bKeepExisting) override
{
- m_xTreeView->insert_text(rStr, pos);
+ m_xTreeView->freeze();
+ if (!bKeepExisting)
+ m_xTreeView->clear();
+ for (const auto& rItem : rItems)
+ m_xTreeView->insert(-1, rItem.sString, &rItem.sId, &rItem.sImage, nullptr);
+ m_xTreeView->thaw();
}
- virtual void insert(int pos, const OUString& rId, const OUString& rStr,
+
+ virtual void insert(int pos, const OUString& rStr, const OUString* pId,
const OUString* pIconName, VirtualDevice* pImageSurface) override
{
- m_xTreeView->insert(pos, rId, rStr, pIconName, pImageSurface);
+ m_xTreeView->insert(pos, rStr, pId, pIconName, pImageSurface);
}
virtual int get_count() const override { return m_xTreeView->n_children(); }
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx
index 95762ac114c5..ab594ee8bf9f 100644
--- a/sc/source/ui/miscdlgs/mvtabdlg.cxx
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -220,7 +220,8 @@ void ScMoveTableDlg::InitDocListBox()
aEntryName += msCurrentDoc;
}
- m_xLbDoc->insert(i, OUString::number(reinterpret_cast<sal_uInt64>(&pScSh->GetDocument())), aEntryName, nullptr, nullptr);
+ OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(&pScSh->GetDocument())));
+ m_xLbDoc->insert(i, aEntryName, &sId, nullptr, nullptr);
i++;
}
diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
index 403876b7c3da..934e3be37217 100644
--- a/sd/source/ui/dlg/PhotoAlbumDialog.cxx
+++ b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
@@ -550,8 +550,8 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, UpHdl, weld::Button&, void)
m_xImagesLst->remove_text(sActEntry);
m_xImagesLst->remove_text(sUpperEntry);
- m_xImagesLst->insert(nActPos - 1, sAct, sActEntry, nullptr, nullptr);
- m_xImagesLst->insert(nActPos, sUpper, sUpperEntry, nullptr, nullptr);
+ m_xImagesLst->insert(nActPos - 1, sActEntry, &sAct, nullptr, nullptr);
+ m_xImagesLst->insert(nActPos, sUpperEntry, &sUpper, nullptr, nullptr);
m_xImagesLst->select(nActPos - 1);
}
@@ -573,8 +573,8 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, DownHdl, weld::Button&, void)
m_xImagesLst->remove_text(sActEntry);
m_xImagesLst->remove_text(sDownEntry);
- m_xImagesLst->insert(nActPos, sDown, sDownEntry, nullptr, nullptr);
- m_xImagesLst->insert(nActPos + 1, sAct, sActEntry, nullptr, nullptr);
+ m_xImagesLst->insert(nActPos, sDownEntry, &sDown, nullptr, nullptr);
+ m_xImagesLst->insert(nActPos + 1, sActEntry, &sAct, nullptr, nullptr);
m_xImagesLst->select(nActPos + 1);
}
diff --git a/sd/source/ui/dlg/custsdlg.cxx b/sd/source/ui/dlg/custsdlg.cxx
index b7b384073666..da736e59f8ac 100644
--- a/sd/source/ui/dlg/custsdlg.cxx
+++ b/sd/source/ui/dlg/custsdlg.cxx
@@ -154,7 +154,7 @@ void SdCustomShowDlg::SelectHdl(void const *p)
(*pCustomShowList)[nPos] = pCustomShow;
pCustomShowList->Seek(nPos);
m_xLbCustomShows->remove(nPos);
- m_xLbCustomShows->insert_text(pCustomShow->GetName(), nPos);
+ m_xLbCustomShows->insert_text(nPos, pCustomShow->GetName());
m_xLbCustomShows->select(nPos);
}
if (aDlg.IsModified())
@@ -378,7 +378,8 @@ void SdDefineCustomShowDlg::ClickButtonHdl2(void const * p)
{
OUString aStr = m_xLbPages->get_text(i);
SdPage* pPage = rDoc.GetSdPage(i, PageKind::Standard);
- m_xLbCustomPages->insert(nPosCP, OUString::number(reinterpret_cast<sal_uInt64>(pPage)), aStr, nullptr, nullptr);
+ OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(pPage)));
+ m_xLbCustomPages->insert(nPosCP, aStr, &sId, nullptr, nullptr);
m_xLbCustomPages->select(nPosCP != -1 ? nPosCP : m_xLbCustomPages->n_children() - 1);
if (nPosCP != -1)
diff --git a/sfx2/source/dialog/mgetempl.cxx b/sfx2/source/dialog/mgetempl.cxx
index db19bb92dc1f..7557fead6834 100644
--- a/sfx2/source/dialog/mgetempl.cxx
+++ b/sfx2/source/dialog/mgetempl.cxx
@@ -208,7 +208,8 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(TabPageParent pParent, const Sf
rTupel.nFlags != SfxStyleSearchBits::AllVisible &&
rTupel.nFlags != SfxStyleSearchBits::All )
{
- m_xFilterLb->insert(nIdx, OUString::number(i), rTupel.aName, nullptr, nullptr);
+ OUString sId(OUString::number(i));
+ m_xFilterLb->insert(nIdx, rTupel.aName, &sId, nullptr, nullptr);
if ( ( rTupel.nFlags & nMask ) == nMask )
nStyleFilterIdx = nIdx;
++nIdx;
diff --git a/sfx2/source/doc/saveastemplatedlg.cxx b/sfx2/source/doc/saveastemplatedlg.cxx
index 85eee202541e..a7af9dda560e 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_text(rFolderNames[i], i+1);
+ m_xLBCategory->insert_text(i+1, rFolderNames[i]);
}
m_xLBCategory->select(0);
}
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 38a42a46567d..6efb5c2a9777 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -1682,7 +1682,7 @@ void SvtFontSizeBox::Fill( const FontMetric* pFontMetric, const FontList* pList
OUString aSizeName = aFontSizeNames.GetIndexName( i );
sal_IntPtr nSize = aFontSizeNames.GetIndexSize( i );
OUString sId(OUString::number(-nSize)); // mark as special
- m_xComboBox->insert(nPos, sId, aSizeName, nullptr, nullptr);
+ m_xComboBox->insert(nPos, aSizeName, &sId, nullptr, nullptr);
nPos++;
}
}
@@ -1696,7 +1696,7 @@ void SvtFontSizeBox::Fill( const FontMetric* pFontMetric, const FontList* pList
if ( !aSizeName.isEmpty() )
{
OUString sId(OUString::number(-(*pTempAry))); // mark as special
- m_xComboBox->insert(nPos, sId, aSizeName, nullptr, nullptr);
+ m_xComboBox->insert(nPos, aSizeName, &sId, nullptr, nullptr);
nPos++;
}
pTempAry++;
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx
index 37c647280206..d2f6b9d3e7bc 100644
--- a/svx/source/dialog/dlgctrl.cxx
+++ b/svx/source/dialog/dlgctrl.cxx
@@ -1060,7 +1060,7 @@ void SvxLineLB::Modify(const XDashEntry& rEntry, sal_Int32 nPos, const BitmapEx&
const Size aBmpSize(rBitmap.GetSizePixel());
pVD->SetOutputSizePixel(aBmpSize, false);
pVD->DrawBitmapEx(Point(), rBitmap);
- m_xControl->insert(nPos, "", rEntry.GetName(), nullptr, pVD);
+ m_xControl->insert(nPos, rEntry.GetName(), nullptr, nullptr, pVD);
}
else
{
@@ -1128,7 +1128,7 @@ void SvxLineEndLB::Modify( const XLineEndEntry& rEntry, sal_Int32 nPos, const Bi
const Size aBmpSize(rBitmap.GetSizePixel());
pVD->SetOutputSizePixel(Size(aBmpSize.Width() / 2, aBmpSize.Height()), false);
pVD->DrawBitmapEx(Point(-aBmpSize.Width() / 2, 0), rBitmap);
- m_xControl->insert(nPos, "", rEntry.GetName(), nullptr, pVD);
+ m_xControl->insert(nPos, rEntry.GetName(), nullptr, nullptr, pVD);
}
else
{
diff --git a/svx/source/dialog/langbox.cxx b/svx/source/dialog/langbox.cxx
index 4c22822f5eb8..abac537091ad 100644
--- a/svx/source/dialog/langbox.cxx
+++ b/svx/source/dialog/langbox.cxx
@@ -530,8 +530,8 @@ void LanguageBox::set_active_id(const LanguageType eLangType)
m_xControl->set_active(nAt);
}
-void LanguageBox::AddLanguages( const std::vector< LanguageType >& rLanguageTypes,
- SvxLanguageListFlags nLangList )
+void LanguageBox::AddLanguages(const std::vector< LanguageType >& rLanguageTypes,
+ SvxLanguageListFlags nLangList, std::vector<weld::ComboBoxEntry>& rEntries)
{
for ( auto const & nLangType : rLanguageTypes )
{
@@ -542,7 +542,11 @@ void LanguageBox::AddLanguages( const std::vector< LanguageType >& rLanguageType
{
int nAt = ImplTypeToPos(nLang);
if (nAt == -1)
- InsertLanguage( nLang );
+ {
+ rEntries.push_back(BuildEntry(nLang));
+ if (rEntries.back().sString.isEmpty())
+ rEntries.pop_back();
+ }
}
}
}
@@ -556,14 +560,15 @@ void LanguageBox::ImplClear()
void LanguageBox::SetLanguageList( SvxLanguageListFlags nLangList,
bool bHasLangNone, bool bLangNoneIsLangAll, bool bCheckSpellAvail )
{
- ImplClear();
-
m_bHasLangNone = bHasLangNone;
m_bLangNoneIsLangAll = bLangNoneIsLangAll;
m_bWithCheckmark = bCheckSpellAvail;
- if ( SvxLanguageListFlags::EMPTY == nLangList )
+ if (SvxLanguageListFlags::EMPTY == nLangList)
+ {
+ ImplClear();
return;
+ }
bool bAddAvailable = (!(nLangList & SvxLanguageListFlags::ONLY_KNOWN) &&
((nLangList & SvxLanguageListFlags::ALL) ||
@@ -632,7 +637,7 @@ void LanguageBox::SetLanguageList( SvxLanguageListFlags nLangList,
nCount = SvtLanguageTable::GetLanguageEntryCount();
}
- m_xControl->freeze();
+ std::vector<weld::ComboBoxEntry> aEntries;
for ( sal_uInt32 i = 0; i < nCount; i++ )
{
LanguageType nLangType;
@@ -656,22 +661,26 @@ void LanguageBox::SetLanguageList( SvxLanguageListFlags nLangList,
lcl_SeqHasLang(aHyphUsedLang, nLangType)) ||
(bool(nLangList & SvxLanguageListFlags::THES_USED) &&
lcl_SeqHasLang(aThesUsedLang, nLangType))) )
- InsertLanguage( nLangType );
+ {
+ aEntries.push_back(BuildEntry(nLangType));
+ if (aEntries.back().sString.isEmpty())
+ aEntries.pop_back();
+ }
}
if (bAddAvailable)
{
// Spell checkers, hyphenators and thesauri may add language tags
// unknown so far.
- AddLanguages( aSpellAvailLang, nLangList);
- AddLanguages( aHyphAvailLang, nLangList);
- AddLanguages( aThesAvailLang, nLangList);
+ AddLanguages(aSpellAvailLang, nLangList, aEntries);
+ AddLanguages(aHyphAvailLang, nLangList, aEntries);
+ AddLanguages(aThesAvailLang, nLangList, aEntries);
}
if (bHasLangNone)
- InsertLanguage( LANGUAGE_NONE );
+ aEntries.push_back(BuildEntry(LANGUAGE_NONE));
- m_xControl->thaw();
+ m_xControl->insert_vector(aEntries, false);
}
int LanguageBox::ImplTypeToPos(LanguageType eType) const
@@ -681,6 +690,17 @@ int LanguageBox::ImplTypeToPos(LanguageType eType) const
void LanguageBox::InsertLanguage(const LanguageType nLangType)
{
+ weld::ComboBoxEntry aEntry = BuildEntry(nLangType);
+ if (aEntry.sString.isEmpty())
+ return;
+ if (aEntry.sImage.isEmpty())
+ m_xControl->append(aEntry.sId, aEntry.sString);
+ else
+ m_xControl->append(aEntry.sId, aEntry.sString, aEntry.sImage);
+}
+
+weld::ComboBoxEntry LanguageBox::BuildEntry(const LanguageType nLangType)
+{
LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage(nLangType);
// For obsolete and to be replaced languages check whether an entry of the
// replacement already exists and if so don't add an entry with identical
@@ -689,7 +709,7 @@ void LanguageBox::InsertLanguage(const LanguageType nLangType)
{
int nAt = ImplTypeToPos( nLang );
if (nAt != -1)
- return;
+ return weld::ComboBoxEntry("");
}
OUString aStrEntry = SvtLanguageTable::GetLanguageString( nLang );
@@ -721,11 +741,10 @@ void LanguageBox::InsertLanguage(const LanguageType nLangType)
bool bFound = m_xSpellUsedLang && lcl_SeqHasLang(*m_xSpellUsedLang, static_cast<sal_uInt16>(nRealLang));
- m_xControl->append(OUString::number(static_cast<sal_uInt16>(nLangType)), aStrEntry,
- bFound ? OUString(RID_SVXBMP_CHECKED) : OUString(RID_SVXBMP_NOTCHECKED));
+ return weld::ComboBoxEntry(aStrEntry, OUString::number(static_cast<sal_uInt16>(nLangType)), bFound ? OUString(RID_SVXBMP_CHECKED) : OUString(RID_SVXBMP_NOTCHECKED));
}
else
- m_xControl->append(OUString::number(static_cast<sal_uInt16>(nLangType)), aStrEntry);
+ return weld::ComboBoxEntry(aStrEntry, OUString::number(static_cast<sal_uInt16>(nLangType)));
}
IMPL_LINK(LanguageBox, ChangeHdl, weld::ComboBox&, rControl, void)
diff --git a/sw/source/ui/dbui/customizeaddresslistdialog.cxx b/sw/source/ui/dbui/customizeaddresslistdialog.cxx
index ee0ad8e15c0e..af6162bfd0f5 100644
--- a/sw/source/ui/dbui/customizeaddresslistdialog.cxx
+++ b/sw/source/ui/dbui/customizeaddresslistdialog.cxx
@@ -103,7 +103,7 @@ IMPL_LINK(SwCustomizeAddressListDialog, AddRenameHdl_Impl, weld::Button&, rButto
}
- m_xFieldsLB->insert_text(sNew, nPos);
+ m_xFieldsLB->insert_text(nPos, sNew);
m_xFieldsLB->select(nPos);
}
UpdateButtons();
@@ -135,7 +135,7 @@ IMPL_LINK(SwCustomizeAddressListDialog, UpDownHdl_Impl, weld::Button&, rButton,
--nPos;
else
++nPos;
- m_xFieldsLB->insert_text(aTemp, nPos);
+ m_xFieldsLB->insert_text(nPos, aTemp);
m_xFieldsLB->select(nPos);
//align m_xNewData
OUString sHeader = m_xNewData->aDBColumnHeaders[nOldPos];
diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx
index 8c8b155b3a46..d7a327bc2dad 100644
--- a/sw/source/ui/frmdlg/column.cxx
+++ b/sw/source/ui/frmdlg/column.cxx
@@ -189,7 +189,8 @@ SwColumnDlg::SwColumnDlg(weld::Window* pParent, SwWrtShell& rSh)
{
const OUString sPageStr = pApplyToLB->get_text(nPagePos) + pPageDesc->GetName();
pApplyToLB->remove(nPagePos);
- pApplyToLB->insert(nPagePos, OUString::number(LISTBOX_PAGE), sPageStr, nullptr, nullptr);
+ OUString sId(OUString::number(LISTBOX_PAGE));
+ pApplyToLB->insert(nPagePos, sPageStr, &sId, nullptr, nullptr);
}
else
pApplyToLB->remove( nPagePos );
diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx
index 7b70104318fd..8cf7246243d7 100644
--- a/sw/source/ui/misc/outline.cxx
+++ b/sw/source/ui/misc/outline.cxx
@@ -91,7 +91,7 @@ void SwNumNamesDlg::SetUserNames(const OUString *pList[])
if(pList[i])
{
m_xFormBox->remove(i);
- m_xFormBox->insert_text(*pList[i], i);
+ m_xFormBox->insert_text(i, *pList[i]);
if (i == nSelect && nSelect < SwChapterNumRules::nMaxRules)
nSelect++;
}
diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx
index 5e666a2e31bc..a395be977d54 100644
--- a/sw/source/ui/table/tautofmt.cxx
+++ b/sw/source/ui/table/tautofmt.cxx
@@ -236,7 +236,7 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, AddHdl, weld::Button&, void)
break;
m_xTableTable->InsertAutoFormat(n, std::move(pNewData));
- m_xLbFormat->insert_text(aFormatName, m_nDfltStylePos + n);
+ m_xLbFormat->insert_text(m_nDfltStylePos + n, aFormatName);
m_xLbFormat->select(m_nDfltStylePos + n);
bFormatInserted = true;
m_xBtnAdd->set_sensitive(false);
@@ -336,7 +336,7 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, RenameHdl, weld::Button&, void)
}
m_xTableTable->InsertAutoFormat( n, std::move(p) );
- m_xLbFormat->insert_text(aFormatName, m_nDfltStylePos + n);
+ m_xLbFormat->insert_text(m_nDfltStylePos + n, aFormatName);
m_xLbFormat->select(m_nDfltStylePos + n);
if ( !m_bCoreDataChanged )
diff --git a/sw/source/uibase/misc/numberingtypelistbox.cxx b/sw/source/uibase/misc/numberingtypelistbox.cxx
index 396546199d2c..66ec98433785 100644
--- a/sw/source/uibase/misc/numberingtypelistbox.cxx
+++ b/sw/source/uibase/misc/numberingtypelistbox.cxx
@@ -113,7 +113,8 @@ void SwNumberingTypeListBox::Reload(SwInsertNumTypes nTypeFlags)
}
if (bInsert)
{
- m_xWidget->insert(nPos, OUString::number(nValue), SvxNumberingTypeTable::GetString(i), nullptr, nullptr);
+ OUString sId(OUString::number(nValue));
+ m_xWidget->insert(nPos, SvxNumberingTypeTable::GetString(i), &sId, nullptr, nullptr);
}
}
if (nTypeFlags & SwInsertNumTypes::Extended)
diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx
index ff9438a8111f..79036c5ebdf8 100644
--- a/sw/source/uibase/utlui/uitool.cxx
+++ b/sw/source/uibase/utlui/uitool.cxx
@@ -687,7 +687,7 @@ void InsertStringSorted(const OUString& rId, const OUString& rEntry, weld::Combo
break;
++nOffset;
}
- rToFill.insert(nOffset, rId, rEntry, nullptr, nullptr);
+ rToFill.insert(nOffset, rEntry, &rId, nullptr, nullptr);
}
void FillCharStyleListBox(ListBox& rToFill, SwDocShell* pDocSh, bool bSorted, bool bWithDefault)
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 102aa450c70a..ffae3928610e 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1692,12 +1692,7 @@ public:
m_xTreeView->SetDoubleClickHdl(LINK(this, SalInstanceTreeView, DoubleClickHdl));
}
- virtual void insert_text(const OUString& rText, int pos) override
- {
- m_xTreeView->InsertEntry(rText, pos == -1 ? LISTBOX_APPEND : pos);
- }
-
- virtual void insert(int pos, const OUString& rId, const OUString& rStr, const OUString* pIconName, VirtualDevice* pImageSurface) override
+ virtual void insert(int pos, const OUString& rStr, const OUString* pId, const OUString* pIconName, VirtualDevice* pImageSurface) override
{
auto nInsertPos = pos == -1 ? COMBOBOX_APPEND : pos;
sal_Int32 nInsertedAt;
@@ -1707,7 +1702,8 @@ public:
nInsertedAt = m_xTreeView->InsertEntry(rStr, createImage(*pIconName), nInsertPos);
else
nInsertedAt = m_xTreeView->InsertEntry(rStr, createImage(*pImageSurface), nInsertPos);
- m_xTreeView->SetEntryData(nInsertedAt, new OUString(rId));
+ if (pId)
+ m_xTreeView->SetEntryData(nInsertedAt, new OUString(*pId));
}
virtual void set_font_color(int pos, const Color& rColor) const override
@@ -2307,9 +2303,17 @@ public:
return *pRet;
}
- virtual void insert_text(int pos, const OUString& rStr) override
+ virtual void insert_vector(const std::vector<weld::ComboBoxEntry>& rItems, bool bKeepExisting) override
{
- m_xComboBox->InsertEntry(rStr, pos == -1 ? COMBOBOX_APPEND : pos);
+ freeze();
+ if (!bKeepExisting)
+ clear();
+ for (const auto& rItem : rItems)
+ {
+ insert(-1, rItem.sString, rItem.sId.isEmpty() ? nullptr : &rItem.sId,
+ rItem.sImage.isEmpty() ? nullptr : &rItem.sImage, nullptr);
+ }
+ thaw();
}
virtual int get_count() const override
@@ -2381,7 +2385,7 @@ public:
m_xComboBox->RemoveEntry(pos);
}
- virtual void insert(int pos, const OUString& rId, const OUString& rStr, const OUString* pIconName, VirtualDevice* pImageSurface) override
+ virtual void insert(int pos, const OUString& rStr, const OUString* pId, const OUString* pIconName, VirtualDevice* pImageSurface) override
{
auto nInsertPos = pos == -1 ? COMBOBOX_APPEND : pos;
sal_Int32 nInsertedAt;
@@ -2391,7 +2395,8 @@ public:
nInsertedAt = m_xComboBox->InsertEntry(rStr, createImage(*pIconName), nInsertPos);
else
nInsertedAt = m_xComboBox->InsertEntry(rStr, createImage(*pImageSurface), nInsertPos);
- m_xComboBox->SetEntryData(nInsertedAt, new OUString(rId));
+ if (pId)
+ m_xComboBox->SetEntryData(nInsertedAt, new OUString(*pId));
}
virtual bool has_entry() const override
@@ -2477,7 +2482,7 @@ public:
m_xComboBox->RemoveEntryAt(pos);
}
- virtual void insert(int pos, const OUString& rId, const OUString& rStr, const OUString* pIconName, VirtualDevice* pImageSurface) override
+ virtual void insert(int pos, const OUString& rStr, const OUString* pId, const OUString* pIconName, VirtualDevice* pImageSurface) override
{
auto nInsertPos = pos == -1 ? COMBOBOX_APPEND : pos;
sal_Int32 nInsertedAt;
@@ -2487,7 +2492,8 @@ public:
nInsertedAt = m_xComboBox->InsertEntryWithImage(rStr, createImage(*pIconName), nInsertPos);
else
nInsertedAt = m_xComboBox->InsertEntryWithImage(rStr, createImage(*pImageSurface), nInsertPos);
- m_xComboBox->SetEntryData(nInsertedAt, new OUString(rId));
+ if (pId)
+ m_xComboBox->SetEntryData(nInsertedAt, new OUString(*pId));
}
virtual void set_entry_text(const OUString& rText) override
diff --git a/vcl/unx/generic/print/prtsetup.cxx b/vcl/unx/generic/print/prtsetup.cxx
index 45efe3dc9feb..6a38db31b1d9 100644
--- a/vcl/unx/generic/print/prtsetup.cxx
+++ b/vcl/unx/generic/print/prtsetup.cxx
@@ -329,7 +329,8 @@ RTSDevicePage::RTSDevicePage(weld::Widget* pPage, RTSDialog* pParent)
|| int(bAutoIsPDF) == m_pParent->m_aJobData.m_nPDFDevice);
OUString sStr = m_xLevelBox->get_text(0);
- m_xLevelBox->insert(0, m_xLevelBox->get_id(0), sStr.replaceAll("%s", bAutoIsPDF ? m_xLevelBox->get_text(5) : m_xLevelBox->get_text(1)), nullptr, nullptr);
+ OUString sId = m_xLevelBox->get_id(0);
+ m_xLevelBox->insert(0, sStr.replaceAll("%s", bAutoIsPDF ? m_xLevelBox->get_text(5) : m_xLevelBox->get_text(1)), &sId, nullptr, nullptr);
m_xLevelBox->remove(1);
for (int i = 0; i < m_xLevelBox->get_count(); ++i)
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 71131528dd46..5930e6a42441 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -3783,16 +3783,14 @@ namespace
return found;
}
- void insert_row(GtkListStore* pListStore, int pos, const OUString& rId, const OUString& rText, const OUString* pIconName, VirtualDevice* pDevice)
+ void insert_row(GtkListStore* pListStore, GtkTreeIter& iter, int pos, const OUString* pId, const OUString& rText, const OUString* pIconName, VirtualDevice* pDevice)
{
- GtkTreeIter iter;
- gtk_list_store_insert(pListStore, &iter, pos);
if (!pIconName && !pDevice)
{
- gtk_list_store_set(pListStore, &iter,
- 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(),
- 1, OUStringToOString(rId, RTL_TEXTENCODING_UTF8).getStr(),
- -1);
+ gtk_list_store_insert_with_values(pListStore, &iter, pos,
+ 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(),
+ 1, !pId ? nullptr : OUStringToOString(*pId, RTL_TEXTENCODING_UTF8).getStr(),
+ -1);
}
else
{
@@ -3818,11 +3816,11 @@ namespace
rSettings.GetUILanguageTag().getBcp47());
}
- gtk_list_store_set(pListStore, &iter,
- 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(),
- 1, OUStringToOString(rId, RTL_TEXTENCODING_UTF8).getStr(),
- 2, pixbuf,
- -1);
+ gtk_list_store_insert_with_values(pListStore, &iter, pos,
+ 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(),
+ 1, !pId ? nullptr : OUStringToOString(*pId, RTL_TEXTENCODING_UTF8).getStr(),
+ 2, pixbuf,
+ -1);
if (pixbuf)
g_object_unref(pixbuf);
@@ -3842,11 +3840,11 @@ namespace
cairo_paint(cr);
cairo_destroy(cr);
- gtk_list_store_set(pListStore, &iter,
- 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(),
- 1, OUStringToOString(rId, RTL_TEXTENCODING_UTF8).getStr(),
- 3, target,
- -1);
+ gtk_list_store_insert_with_values(pListStore, &iter, pos,
+ 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(),
+ 1, !pId ? nullptr : OUStringToOString(*pId, RTL_TEXTENCODING_UTF8).getStr(),
+ 3, target,
+ -1);
cairo_surface_destroy(target);
}
}
@@ -3908,19 +3906,11 @@ public:
{
}
- virtual void insert_text(const OUString& rText, int pos) override
+ virtual void insert(int pos, const OUString& rText, const OUString* pId, const OUString* pIconName, VirtualDevice* pImageSurface) 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);
- enable_notify_events();
- }
-
- virtual void insert(int pos, const OUString& rId, const OUString& rText, const OUString* pIconName, VirtualDevice* pImageSurface) override
- {
- disable_notify_events();
- insert_row(m_pListStore, pos, rId, rText, pIconName, pImageSurface);
+ insert_row(m_pListStore, iter, pos, pId, rText, pIconName, pImageSurface);
enable_notify_events();
}
@@ -4799,6 +4789,7 @@ class GtkInstanceComboBox : public GtkInstanceContainer, public vcl::ISearchable
{
private:
GtkComboBox* m_pComboBox;
+ GtkTreeModel* m_pTreeModel;
GtkMenu* m_pMenu;
std::unique_ptr<comphelper::string::NaturalStringSorter> m_xSorter;
vcl::QuickSelectionEngine m_aQuickSelectionEngine;
@@ -4854,12 +4845,11 @@ private:
OUString get(int pos, int col) const
{
OUString sRet;
- GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBox);
GtkTreeIter iter;
- if (gtk_tree_model_iter_nth_child(pModel, &iter, nullptr, pos))
+ if (gtk_tree_model_iter_nth_child(m_pTreeModel, &iter, nullptr, pos))
{
gchar* pStr;
- gtk_tree_model_get(pModel, &iter, col, &pStr, -1);
+ gtk_tree_model_get(m_pTreeModel, &iter, col, &pStr, -1);
sRet = OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8);
g_free(pStr);
}
@@ -4868,9 +4858,8 @@ private:
int find(const OUString& rStr, int col) const
{
- GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBox);
GtkTreeIter iter;
- if (!gtk_tree_model_get_iter_first(pModel, &iter))
+ if (!gtk_tree_model_get_iter_first(m_pTreeModel, &iter))
return -1;
OString aStr(OUStringToOString(rStr, RTL_TEXTENCODING_UTF8).getStr());
@@ -4878,13 +4867,13 @@ private:
do
{
gchar* pStr;
- gtk_tree_model_get(pModel, &iter, col, &pStr, -1);
+ gtk_tree_model_get(m_pTreeModel, &iter, col, &pStr, -1);
const bool bEqual = g_strcmp0(pStr, aStr.getStr()) == 0;
g_free(pStr);
if (bEqual)
return nRet;
++nRet;
- } while (gtk_tree_model_iter_next(pModel, &iter));
+ } while (gtk_tree_model_iter_next(m_pTreeModel, &iter));
return -1;
}
@@ -4902,7 +4891,7 @@ private:
if (gtk_entry_get_completion(pEntry))
return;
GtkEntryCompletion* pCompletion = gtk_entry_completion_new();
- gtk_entry_completion_set_model(pCompletion, gtk_combo_box_get_model(m_pComboBox));
+ gtk_entry_completion_set_model(pCompletion, m_pTreeModel);
gtk_entry_completion_set_text_column(pCompletion, 0);
gtk_entry_completion_set_inline_selection(pCompletion, true);
gtk_entry_completion_set_inline_completion(pCompletion, true);
@@ -5052,6 +5041,7 @@ public:
GtkInstanceComboBox(GtkComboBox* pComboBox, bool bTakeOwnership)
: GtkInstanceContainer(GTK_CONTAINER(pComboBox), bTakeOwnership)
, m_pComboBox(pComboBox)
+ , m_pTreeModel(gtk_combo_box_get_model(m_pComboBox))
, m_pMenu(nullptr)
, m_aQuickSelectionEngine(*this)
, m_bPopupActive(false)
@@ -5149,10 +5139,9 @@ public:
if (!gtk_combo_box_get_active_iter(m_pComboBox, &iter))
return OUString();
- GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBox);
gint col = gtk_combo_box_get_entry_text_column(m_pComboBox);
gchar* pStr = nullptr;
- gtk_tree_model_get(pModel, &iter, col, &pStr, -1);
+ gtk_tree_model_get(m_pTreeModel, &iter, col, &pStr, -1);
OUString sRet(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8);
g_free(pStr);
@@ -5188,40 +5177,42 @@ public:
#endif
}
- virtual void insert_text(int pos, const OUString& rText) override
+ virtual void insert_vector(const std::vector<weld::ComboBoxEntry>& rItems, bool bKeepExisting) override
{
- disable_notify_events();
+ freeze();
+ if (!bKeepExisting)
+ clear();
GtkTreeIter iter;
- GtkListStore* pListStore = GTK_LIST_STORE(gtk_combo_box_get_model(m_pComboBox));
- gtk_list_store_insert(pListStore, &iter, pos);
- gtk_list_store_set(pListStore, &iter, 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), -1);
- enable_notify_events();
- bodge_wayland_menu_not_appearing();
+ for (const auto& rItem : rItems)
+ {
+ insert_row(GTK_LIST_STORE(m_pTreeModel), iter, -1, rItem.sId.isEmpty() ? nullptr : &rItem.sId,
+ rItem.sString, rItem.sImage.isEmpty() ? nullptr : &rItem.sImage, nullptr);
+ }
+ thaw();
}
virtual void remove(int pos) override
{
disable_notify_events();
GtkTreeIter iter;
- GtkListStore* pListStore = GTK_LIST_STORE(gtk_combo_box_get_model(m_pComboBox));
- gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(pListStore), &iter, nullptr, pos);
- gtk_list_store_remove(pListStore, &iter);
+ gtk_tree_model_iter_nth_child(m_pTreeModel, &iter, nullptr, pos);
+ gtk_list_store_remove(GTK_LIST_STORE(m_pTreeModel), &iter);
enable_notify_events();
bodge_wayland_menu_not_appearing();
}
- virtual void insert(int pos, const OUString& rId, const OUString& rText, const OUString* pIconName, VirtualDevice* pImageSurface) override
+ virtual void insert(int pos, const OUString& rText, const OUString* pId, const OUString* pIconName, VirtualDevice* pImageSurface) override
{
disable_notify_events();
- insert_row(GTK_LIST_STORE(gtk_combo_box_get_model(m_pComboBox)), pos, rId, rText, pIconName, pImageSurface);
+ GtkTreeIter iter;
+ insert_row(GTK_LIST_STORE(m_pTreeModel), iter, pos, pId, rText, pIconName, pImageSurface);
enable_notify_events();
bodge_wayland_menu_not_appearing();
}
virtual int get_count() const override
{
- GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBox);
- return gtk_tree_model_iter_n_children(pModel, nullptr);
+ return gtk_tree_model_iter_n_children(m_pTreeModel, nullptr);
}
virtual int find_text(const OUString& rStr) const override
@@ -5237,8 +5228,7 @@ public:
virtual void clear() override
{
disable_notify_events();
- GtkTreeModel *pModel = gtk_combo_box_get_model(m_pComboBox);
- gtk_list_store_clear(GTK_LIST_STORE(pModel));
+ gtk_list_store_clear(GTK_LIST_STORE(m_pTreeModel));
enable_notify_events();
bodge_wayland_menu_not_appearing();
}
@@ -5248,8 +5238,7 @@ public:
m_xSorter.reset(new comphelper::string::NaturalStringSorter(
::comphelper::getProcessComponentContext(),
Application::GetSettings().GetUILanguageTag().getLocale()));
- GtkTreeModel* pModel = gtk_combo_box_get_model(m_pComboBox);
- GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(pModel);
+ GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(m_pTreeModel);
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);
}
@@ -5340,24 +5329,31 @@ public:
virtual void freeze() override
{
+ disable_notify_events();
+ g_object_ref(m_pTreeModel);
GtkInstanceContainer::freeze();
+ gtk_combo_box_set_model(m_pComboBox, nullptr);
if (m_xSorter)
{
- GtkTreeModel* pModel = gtk_combo_box_get_model(m_pComboBox);
- GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(pModel);
+ GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(m_pTreeModel);
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)
{
- GtkTreeModel* pModel = gtk_combo_box_get_model(m_pComboBox);
- GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(pModel);
+ GtkTreeSortable* pSortable = GTK_TREE_SORTABLE(m_pTreeModel);
gtk_tree_sortable_set_sort_column_id(pSortable, 0, GTK_SORT_ASCENDING);
}
+ gtk_combo_box_set_model(m_pComboBox, m_pTreeModel);
GtkInstanceContainer::thaw();
+ g_object_unref(m_pTreeModel);
+ enable_notify_events();
+
bodge_wayland_menu_not_appearing();
}
More information about the Libreoffice-commits
mailing list