diff options
-rw-r--r-- | include/svl/zforlist.hxx | 2 | ||||
-rw-r--r-- | svl/source/numbers/zforlist.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/table/swtable.cxx | 15 |
3 files changed, 23 insertions, 2 deletions
diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx index 8091c2faea71..b412a237aada 100644 --- a/include/svl/zforlist.hxx +++ b/include/svl/zforlist.hxx @@ -618,6 +618,8 @@ public: sal_uInt16& nPrecision, sal_uInt16& nLeadingCnt, LanguageType eLnge = LANGUAGE_DONTKNOW ); + bool IsUserDefinedAndNotOverloaded(sal_uInt32 F_Index) const; + /// Check if format code string may be deleted by user bool IsUserDefined( const OUString& sStr, LanguageType eLnge = LANGUAGE_DONTKNOW ); diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 5fd5a1e7c825..6230ea3f7223 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -3140,6 +3140,14 @@ OUString SvNumberFormatter::GenerateFormat(sal_uInt32 nIndex, return sString.makeStringAndClear(); } +bool SvNumberFormatter::IsUserDefinedAndNotOverloaded(sal_uInt32 F_Index) const +{ + ::osl::MutexGuard aGuard( GetInstanceMutex() ); + const SvNumberformat* pFormat = GetFormatEntry(F_Index); + + return pFormat && (pFormat->GetType() & SvNumFormatType::DEFINED); +} + bool SvNumberFormatter::IsUserDefined(const OUString& sStr, LanguageType eLnge) { diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 5a099eec65cf..11da5346c4d5 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -2327,6 +2327,7 @@ void SwTableBoxFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew // format contents with the new value assigned and write to paragraph Color* pCol = nullptr; OUString sNewText; + bool bChangeFormat = true; if( DBL_MAX == fVal ) { sNewText = SwViewShell::GetShellRes()->aCalc_Error; @@ -2351,6 +2352,14 @@ void SwTableBoxFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew #else sNewText = aOrigText; #endif + // Remove the newly assigned numbering format as well if text actually exists. + // Exception: assume user-defined formats are always intentional. + if (bChgText && pNumFormatr->IsTextFormat(nOldFormat) + && !pNumFormatr->IsUserDefinedAndNotOverloaded(nNewFormat)) + { + pBox->GetFrameFormat()->ResetFormatAttr(RES_BOXATR_FORMAT); + bChangeFormat = false; + } } if( !bChgText ) @@ -2360,9 +2369,11 @@ void SwTableBoxFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew } // across all boxes - ChgTextToNum( *pBox, sNewText, pCol, + if (bChangeFormat) + { + ChgTextToNum( *pBox, sNewText, pCol, GetDoc()->IsInsTableAlignNum() ); - + } } else if( bNewIsTextFormat && nOldFormat != nNewFormat ) { |