tdf#144609: numbering "None" should still show prefix/suffix

Unlike it was implemented in tdf#143605, prefix and suffix
should be displayed anyway, we do not display only numbers.

Moreover tdf#143605 did accidentally fix tdf#135164
in a invalid way. So this patch is also providing a better
fix for it: untittest is already created and failing without it.

Problem in tdf#135164 is inability to distingush missing level
text (bullet char in given case) and empty ("") one. In first
case we should use abstract level definition. In second - not.

Change-Id: Ica3a714d22de4d2f14ebbcb12f0e1311dbc9b801
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122609
Tested-by: Jenkins
Reviewed-by: Vasily Melenchuk <vasily.melenchuk@cib.de>
This commit is contained in:
Vasily Melenchuk 2021-09-25 19:06:11 +03:00
parent 1ecc5d98ae
commit 66a7f8a49d
4 changed files with 14 additions and 12 deletions

View file

@ -81,8 +81,8 @@ DECLARE_ODFEXPORT_TEST(testTdf137199, "tdf137199.docx")
DECLARE_ODFEXPORT_TEST(testTdf143605, "tdf143605.odt")
{
CPPUNIT_ASSERT_EQUAL(1, getPages());
// With numbering type "none" there should be nothing
CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(getParagraph(1), "ListLabelString"));
// With numbering type "none" there should be just prefix & suffix
CPPUNIT_ASSERT_EQUAL(OUString("."), getProperty<OUString>(getParagraph(1), "ListLabelString"));
}
DECLARE_ODFEXPORT_TEST(testListFormatDocx, "listformat.docx")

View file

@ -656,9 +656,6 @@ OUString SwNumRule::MakeNumString( const SwNumberTree::tNumberVector & rNumVecto
const SwNumFormat& rMyNFormat = Get( o3tl::narrowing<sal_uInt16>(nLevel) );
if (rMyNFormat.GetNumberingType() == SVX_NUM_NUMBER_NONE)
return OUString();
css::lang::Locale aLocale( LanguageTag::convertToLocale(nLang));
if (rMyNFormat.HasListFormat())
@ -670,7 +667,11 @@ OUString SwNumRule::MakeNumString( const SwNumberTree::tNumberVector & rNumVecto
for (SwNumberTree::tNumberVector::size_type i=0; i <= nLevel; ++i)
{
OUString sReplacement;
if (rNumVector[i])
if (rMyNFormat.GetNumberingType() == SVX_NUM_NUMBER_NONE)
{
// Numbering disabled - replacement is empty
}
else if (rNumVector[i])
{
if (bOnlyArabic)
sReplacement = OUString::number(rNumVector[i]);

View file

@ -175,7 +175,7 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetCharStyleProperties( )
uno::Sequence< beans::PropertyValue > vPropVals = PropertyMap::GetPropertyValues();
beans::PropertyValue* aValIter = vPropVals.begin();
beans::PropertyValue* aEndIter = vPropVals.end();
const bool bIsSymbol(m_sBulletChar.getLength() <= 1);
const bool bIsSymbol(GetBulletChar().getLength() <= 1);
for( ; aValIter != aEndIter; ++aValIter )
if (! IgnoreForCharStyle(aValIter->Name, bIsSymbol))
rProperties.emplace_back(aValIter->Name, 0, aValIter->Value, beans::PropertyState_DIRECT_VALUE);
@ -211,9 +211,9 @@ uno::Sequence<beans::PropertyValue> ListLevel::GetLevelProperties(bool bDefaults
// todo: this is not the bullet char
if( nNumberFormat == style::NumberingType::CHAR_SPECIAL )
{
if (!m_sBulletChar.isEmpty())
if (!GetBulletChar().isEmpty())
{
aNumberingProperties.push_back(lcl_makePropVal(PROP_BULLET_CHAR, m_sBulletChar.copy(0, 1)));
aNumberingProperties.push_back(lcl_makePropVal(PROP_BULLET_CHAR, m_sBulletChar->copy(0, 1)));
}
else
{
@ -584,7 +584,7 @@ void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
? pAbsLevel->GetBulletChar()
: OUString();
// Inherit <w:lvlText> from the abstract level in case the override would be empty.
if (pLevel && !pLevel->GetBulletChar().isEmpty())
if (pLevel && pLevel->HasBulletChar())
sText = pLevel->GetBulletChar( );
aLvlProps.push_back(comphelper::makePropertyValue(getPropertyName(PROP_PREFIX), OUString("")));

View file

@ -46,7 +46,7 @@ class ListLevel : public PropertyMap
/// LN_CT_NumFmt_format, in case m_nNFC is custom.
OUString m_aCustomNumberFormat;
sal_Int16 m_nXChFollow; //LN_IXCHFOLLOW
OUString m_sBulletChar;
std::optional<OUString> m_sBulletChar;
css::awt::Size m_aGraphicSize;
css::uno::Reference<css::awt::XBitmap> m_xGraphicBitmap;
std::optional<sal_Int32> m_nTabstop;
@ -76,7 +76,8 @@ public:
// Getters
sal_Int16 GetNumberingType(sal_Int16 nDefault) const;
const OUString& GetBulletChar( ) const { return m_sBulletChar; };
bool HasBulletChar() const { return m_sBulletChar.has_value(); };
OUString GetBulletChar( ) const { return m_sBulletChar.has_value()? *m_sBulletChar : OUString(); };
const tools::SvRef< StyleSheetEntry >& GetParaStyle( ) const { return m_pParaStyle; };
sal_Int32 GetStartOverride() const { return m_nStartOverride; };
/// Determines if SetValue() was called at least once.