From 66a7f8a49d2db1829dd533f32ae5818499f8544b Mon Sep 17 00:00:00 2001 From: Vasily Melenchuk Date: Sat, 25 Sep 2021 19:06:11 +0300 Subject: [PATCH] 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 --- sw/qa/extras/odfexport/odfexport2.cxx | 4 ++-- sw/source/core/doc/number.cxx | 9 +++++---- writerfilter/source/dmapper/NumberingManager.cxx | 8 ++++---- writerfilter/source/dmapper/NumberingManager.hxx | 5 +++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/sw/qa/extras/odfexport/odfexport2.cxx b/sw/qa/extras/odfexport/odfexport2.cxx index c73dc611db04..28d0cd873944 100644 --- a/sw/qa/extras/odfexport/odfexport2.cxx +++ b/sw/qa/extras/odfexport/odfexport2.cxx @@ -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(getParagraph(1), "ListLabelString")); + // With numbering type "none" there should be just prefix & suffix + CPPUNIT_ASSERT_EQUAL(OUString("."), getProperty(getParagraph(1), "ListLabelString")); } DECLARE_ODFEXPORT_TEST(testListFormatDocx, "listformat.docx") diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx index 6884418752ad..2f4cdf32b304 100644 --- a/sw/source/core/doc/number.cxx +++ b/sw/source/core/doc/number.cxx @@ -656,9 +656,6 @@ OUString SwNumRule::MakeNumString( const SwNumberTree::tNumberVector & rNumVecto const SwNumFormat& rMyNFormat = Get( o3tl::narrowing(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]); diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx index f003dba2abe7..51484b74408f 100644 --- a/writerfilter/source/dmapper/NumberingManager.cxx +++ b/writerfilter/source/dmapper/NumberingManager.cxx @@ -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 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 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(""))); diff --git a/writerfilter/source/dmapper/NumberingManager.hxx b/writerfilter/source/dmapper/NumberingManager.hxx index 252f26149fea..2c1e0af3cb77 100644 --- a/writerfilter/source/dmapper/NumberingManager.hxx +++ b/writerfilter/source/dmapper/NumberingManager.hxx @@ -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 m_sBulletChar; css::awt::Size m_aGraphicSize; css::uno::Reference m_xGraphicBitmap; std::optional 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.