summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2021-10-20 18:09:46 +0200
committerAndras Timar <andras.timar@collabora.com>2022-05-31 15:43:25 +0200
commita8a4696b1e5097530cd1b7e9ad6798e7b0cc0fc6 (patch)
tree405005ba36349fd4c2bdc5bf4e8e3011c6ea3a8f /sw
parent1f5b520d7ac57deeeb8a8c2b98413d00f0c4f920 (diff)
tdf#131025 swtable: don't apply number format to non-number text
Applying a numbering style to text causes export to save that out as a number (valued as zero). That is not good because the ODF spec says that a number overrides a string. So don't accept a numbering format on non-number text. Why is this change good? -the cell previously had no direct formatting (by definition). -the cell's previous old format was text (tested). -any numbering format applied obviously isn't correct (by definition). -any previous formatting has already been overwritten with numformat. -the default numbering is appropriate for text. -empty cells still get the numbering format (tested). -odd human-designed formats are accepted as intentional (tested). What are the concerns? -the scope of this change is HUGE, way beyond this bug. -on both my dev box and patch box I saw occassional crashes. -the bug was "fixed" by a different import commit that ensured different languages were treated consistently. So this patch is no longer critical, just nice to have to avoid exporting out-of-spec content. Change-Id: Id3dc5f803c3cf4875bc0cab52d1019a18679da77 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123904 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Eike Rathke <erack@redhat.com> (cherry picked from commit 546e7d14b397cfd1210b891c8dc4a195c25f3876) Conflicts: include/svl/numformat.hxx svl/source/numbers/zforlist.cxx sw/source/core/table/swtable.cxx Change-Id: I94db018babf0323d84809accaaa898a9caf8edbe
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/table/swtable.cxx15
1 files changed, 13 insertions, 2 deletions
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 )
{