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

optimize adding a block of entries at one time

Change-Id: I9a59154fa445cf3c44ede3ceb1d09f408d906530
Reviewed-on: https://gerrit.libreoffice.org/61618
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst ee68b450
......@@ -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();
......
......@@ -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())
......
......@@ -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);
}
}
......
......@@ -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);
}
}
......
......@@ -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);
......
......@@ -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(); }
......
......@@ -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++;
}
......
......@@ -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);
}
......
......@@ -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)
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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++;
......
......@@ -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
{
......
......@@ -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
......@@ -680,6 +689,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
......@@ -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)
......
......@@ -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];
......
......@@ -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 );
......
......@@ -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++;
}
......
......@@ -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 )
......
......@@ -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)
......
......@@ -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)
......
......@@ -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
......
......@@ -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)
......
This diff is collapsed.
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