Kaydet (Commit) acf7e4c0 authored tarafından Eike Rathke's avatar Eike Rathke

Resolves: tdf#106322 keep original cell content when assigning number format

... and content can't be parsed as number. Instead of converting 0.

Change-Id: Ief0c0a0284762fc0e801d6cc598720a97d733e31
üst 350eec67
...@@ -2268,6 +2268,8 @@ void SwTableBoxFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ...@@ -2268,6 +2268,8 @@ void SwTableBoxFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew
if( (!bNewIsTextFormat && nOldFormat != nNewFormat) || pNewFormula ) if( (!bNewIsTextFormat && nOldFormat != nNewFormat) || pNewFormula )
{ {
bool bIsNumFormat = false;
OUString aOrigText;
bool bChgText = true; bool bChgText = true;
double fVal = 0; double fVal = 0;
if( !pNewVal && SfxItemState::SET != GetItemState( if( !pNewVal && SfxItemState::SET != GetItemState(
...@@ -2280,6 +2282,7 @@ void SwTableBoxFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ...@@ -2280,6 +2282,7 @@ void SwTableBoxFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew
sal_uInt32 nTmpFormatIdx = nNewFormat; sal_uInt32 nTmpFormatIdx = nNewFormat;
OUString aText( GetDoc()->GetNodes()[ nNdPos ] OUString aText( GetDoc()->GetNodes()[ nNdPos ]
->GetTextNode()->GetRedlineText()); ->GetTextNode()->GetRedlineText());
aOrigText = aText;
if( aText.isEmpty() ) if( aText.isEmpty() )
bChgText = false; bChgText = false;
else else
...@@ -2289,7 +2292,6 @@ void SwTableBoxFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ...@@ -2289,7 +2292,6 @@ void SwTableBoxFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew
// JP 22.04.98: Bug 49659 - // JP 22.04.98: Bug 49659 -
// Special casing for percent // Special casing for percent
bool bIsNumFormat = false;
if( css::util::NumberFormat::PERCENT == if( css::util::NumberFormat::PERCENT ==
pNumFormatr->GetType( nNewFormat )) pNumFormatr->GetType( nNewFormat ))
{ {
...@@ -2322,7 +2324,10 @@ void SwTableBoxFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ...@@ -2322,7 +2324,10 @@ void SwTableBoxFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew
} }
} }
else else
{
fVal = pNewVal->GetValue(); fVal = pNewVal->GetValue();
bIsNumFormat = true;
}
// format contents with the new value assigned and write to paragraph // format contents with the new value assigned and write to paragraph
Color* pCol = nullptr; Color* pCol = nullptr;
...@@ -2333,7 +2338,25 @@ void SwTableBoxFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ...@@ -2333,7 +2338,25 @@ void SwTableBoxFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew
} }
else else
{ {
pNumFormatr->GetOutputString( fVal, nNewFormat, sNewText, &pCol ); if (bIsNumFormat)
pNumFormatr->GetOutputString( fVal, nNewFormat, sNewText, &pCol );
else
{
// Original text could not be parsed as
// number/date/time/..., so keep the text.
#if 0
// Actually the text should be formatted
// according to the format, which may include
// additional text from the format, for example
// in {0;-0;"BAD: "@}. But other places when
// entering a new value or changing text or
// changing to a different format of type Text
// don't do this (yet?).
pNumFormatr->GetOutputString( aOrigText, nNewFormat, sNewText, &pCol );
#else
sNewText = aOrigText;
#endif
}
if( !bChgText ) if( !bChgText )
{ {
......
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