From c25b5c2c3d019f1a282ba3fe65eb577ff1c8870b Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 17 May 2019 15:44:02 +0100 Subject: Resolves: tdf#125104 crash on getting text desc of numbering this seems to have been wrong for a very long time, but we used to get away with it back in the .src era with presumably amusingly random strings from other parts of the ui shown in the summary of changes are of the organizer page of the dialog Change-Id: If223182170ba8519d7899f8044f01c2a12f4e391 Reviewed-on: https://gerrit.libreoffice.org/72491 Reviewed-by: Michael Stahl Tested-by: Jenkins --- svx/source/items/pageitem.cxx | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/svx/source/items/pageitem.cxx b/svx/source/items/pageitem.cxx index bbf80d45d5c0..9f6c9a4ac3a1 100644 --- a/svx/source/items/pageitem.cxx +++ b/svx/source/items/pageitem.cxx @@ -22,10 +22,15 @@ #include #include +#include #include +#include #include +#include #include #include +#include +#include #include #include #include @@ -95,6 +100,26 @@ static const char* RID_SVXITEMS_PAGE_NUMS[] = RID_SVXITEMS_PAGE_NUM_NONE }; +namespace +{ + OUString GetNumberingDescription(SvxNumType eNumType) + { + // classic ones, keep displaying the old name + if (eNumType <= css::style::NumberingType::NUMBER_NONE) + return SvxResId(RID_SVXITEMS_PAGE_NUMS[eNumType]); + // new ones, reuse the text used in the numbering dropdown list + sal_uInt32 n = SvxNumberingTypeTable::FindIndex(eNumType); + if (n != RESARRAY_INDEX_NOTFOUND) + return SvxNumberingTypeTable::GetString(n); + css::uno::Reference xContext = comphelper::getProcessComponentContext(); + css::uno::Reference xDefNum = css::text::DefaultNumberingProvider::create(xContext); + css::uno::Reference xInfo(xDefNum, css::uno::UNO_QUERY); + if (!xInfo.is()) + return OUString(); + return xInfo->getNumberingIdentifier(eNumType); + } +} + bool SvxPageItem::GetPresentation ( SfxItemPresentation ePres, @@ -114,8 +139,7 @@ bool SvxPageItem::GetPresentation { rText = aDescName + cpDelimTmp; } - assert(eNumType <= css::style::NumberingType::NUMBER_NONE && "enum overflow"); - rText += SvxResId(RID_SVXITEMS_PAGE_NUMS[eNumType]) + cpDelimTmp; + rText += GetNumberingDescription(eNumType) + cpDelimTmp; if ( bLandscape ) rText += SvxResId(RID_SVXITEMS_PAGE_LAND_TRUE); else @@ -134,8 +158,7 @@ bool SvxPageItem::GetPresentation { rText += aDescName + cpDelimTmp; } - assert(eNumType <= css::style::NumberingType::NUMBER_NONE && "enum overflow"); - rText += SvxResId(RID_SVXITEMS_PAGE_NUMS[eNumType]) + cpDelimTmp; + rText += GetNumberingDescription(eNumType) + cpDelimTmp; if ( bLandscape ) rText += SvxResId(RID_SVXITEMS_PAGE_LAND_TRUE); else -- cgit