Entry may have no text

... after the changes made to IconView.

This partially reverts commit 54725f6e5f
  Author Mike Kaganski <mike.kaganski@collabora.com>
  Date   Tue May 03 09:49:07 2022 +0100
    Don't add empty labels to fontwork's icon view

and instead, makes SvTreeListBox::GetEntryText tolerate absent text.

Change-Id: Ifc386263ad656478416907a6f6b567cd1f3331ae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135582
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
This commit is contained in:
Mike Kaganski 2022-06-10 12:51:29 +03:00
parent 629a9b92da
commit e52a805172
3 changed files with 4 additions and 14 deletions

View file

@ -564,8 +564,6 @@ public:
void SetCheckButtonState( SvTreeListEntry*, SvButtonState );
SvButtonState GetCheckButtonState( SvTreeListEntry* ) const;
static bool HasEntryText(const SvTreeListEntry* pEntry);
void SetEntryText(SvTreeListEntry*, const OUString& );
void SetExpandedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage );
void SetCollapsedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage );

View file

@ -1510,8 +1510,9 @@ OUString SvTreeListBox::GetEntryText(SvTreeListEntry* pEntry) const
{
assert(pEntry);
SvLBoxString* pItem = static_cast<SvLBoxString*>(pEntry->GetFirstItem(SvLBoxItemType::String));
assert(pItem);
return pItem->GetText();
if (pItem) // There may be entries without text items, e.g. in IconView
return pItem->GetText();
return {};
}
const Image& SvTreeListBox::GetExpandedEntryBmp(const SvTreeListEntry* pEntry)
@ -1569,13 +1570,6 @@ SvTreeListEntry* SvTreeListBox::InsertEntry(
return pEntry;
}
// static
bool SvTreeListBox::HasEntryText(const SvTreeListEntry* pEntry)
{
assert(pEntry);
return pEntry->GetFirstItem(SvLBoxItemType::String) != nullptr;
}
void SvTreeListBox::SetEntryText(SvTreeListEntry* pEntry, const OUString& rStr)
{
SvLBoxString* pItem = static_cast<SvLBoxString*>(pEntry->GetFirstItem(SvLBoxItemType::String));

View file

@ -38,9 +38,7 @@ StringMap TreeListUIObject::get_state()
aMap["LevelChildren"] = OUString::number(mxTreeList->GetLevelChildCount(nullptr));
aMap["CheckBoxList"] = OUString::boolean(isCheckBoxList(mxTreeList));
SvTreeListEntry* pEntry = mxTreeList->FirstSelected();
aMap["SelectEntryText"] = (pEntry && SvTreeListBox::HasEntryText(pEntry))
? mxTreeList->GetEntryText(pEntry)
: OUString();
aMap["SelectEntryText"] = pEntry ? mxTreeList->GetEntryText(pEntry) : OUString();
return aMap;
}