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

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/72491Reviewed-by: 's avatarMichael Stahl <Michael.Stahl@cib.de>
Tested-by: Jenkins
üst 21e1aa9d
...@@ -22,10 +22,15 @@ ...@@ -22,10 +22,15 @@
#include <utility> #include <utility>
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <comphelper/processfactory.hxx>
#include <tools/stream.hxx> #include <tools/stream.hxx>
#include <tools/resary.hxx>
#include <svx/pageitem.hxx> #include <svx/pageitem.hxx>
#include <svx/strarray.hxx>
#include <editeng/itemtype.hxx> #include <editeng/itemtype.hxx>
#include <svx/unomid.hxx> #include <svx/unomid.hxx>
#include <com/sun/star/text/DefaultNumberingProvider.hpp>
#include <com/sun/star/text/XNumberingTypeInfo.hpp>
#include <com/sun/star/style/NumberingType.hpp> #include <com/sun/star/style/NumberingType.hpp>
#include <com/sun/star/style/PageStyleLayout.hpp> #include <com/sun/star/style/PageStyleLayout.hpp>
#include <com/sun/star/style/BreakType.hpp> #include <com/sun/star/style/BreakType.hpp>
...@@ -95,6 +100,26 @@ static const char* RID_SVXITEMS_PAGE_NUMS[] = ...@@ -95,6 +100,26 @@ static const char* RID_SVXITEMS_PAGE_NUMS[] =
RID_SVXITEMS_PAGE_NUM_NONE 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<css::uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
css::uno::Reference<css::text::XDefaultNumberingProvider> xDefNum = css::text::DefaultNumberingProvider::create(xContext);
css::uno::Reference<css::text::XNumberingTypeInfo> xInfo(xDefNum, css::uno::UNO_QUERY);
if (!xInfo.is())
return OUString();
return xInfo->getNumberingIdentifier(eNumType);
}
}
bool SvxPageItem::GetPresentation bool SvxPageItem::GetPresentation
( (
SfxItemPresentation ePres, SfxItemPresentation ePres,
...@@ -114,8 +139,7 @@ bool SvxPageItem::GetPresentation ...@@ -114,8 +139,7 @@ bool SvxPageItem::GetPresentation
{ {
rText = aDescName + cpDelimTmp; rText = aDescName + cpDelimTmp;
} }
assert(eNumType <= css::style::NumberingType::NUMBER_NONE && "enum overflow"); rText += GetNumberingDescription(eNumType) + cpDelimTmp;
rText += SvxResId(RID_SVXITEMS_PAGE_NUMS[eNumType]) + cpDelimTmp;
if ( bLandscape ) if ( bLandscape )
rText += SvxResId(RID_SVXITEMS_PAGE_LAND_TRUE); rText += SvxResId(RID_SVXITEMS_PAGE_LAND_TRUE);
else else
...@@ -134,8 +158,7 @@ bool SvxPageItem::GetPresentation ...@@ -134,8 +158,7 @@ bool SvxPageItem::GetPresentation
{ {
rText += aDescName + cpDelimTmp; rText += aDescName + cpDelimTmp;
} }
assert(eNumType <= css::style::NumberingType::NUMBER_NONE && "enum overflow"); rText += GetNumberingDescription(eNumType) + cpDelimTmp;
rText += SvxResId(RID_SVXITEMS_PAGE_NUMS[eNumType]) + cpDelimTmp;
if ( bLandscape ) if ( bLandscape )
rText += SvxResId(RID_SVXITEMS_PAGE_LAND_TRUE); rText += SvxResId(RID_SVXITEMS_PAGE_LAND_TRUE);
else else
......
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