summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-07-17 11:36:29 +0200
committerAndras Timar <andras.timar@collabora.com>2017-07-31 12:03:54 +0200
commit65e13f3fe7db08bf384655675b2c0db43eba1e1c (patch)
tree78624c78cb1de652135361c33d5b5ad27ae725ae
parent63cbbd40b82e2f8180735a517ecb4ac6a97ee84d (diff)
Resolves: tdf#75650 reset boolean number format to General for new formula
Change-Id: Iec2feefcbb5a92c64f182d93b4055fc009dbe1e5 (cherry picked from commit 1c1783864a356a4394f80dec28db939f4cf572cd) Reviewed-on: https://gerrit.libreoffice.org/40053 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> (cherry picked from commit c967cebeab0d5b343bd33d3a6f758aeaa40258f8)
-rw-r--r--sc/source/ui/view/viewfunc.cxx26
1 files changed, 22 insertions, 4 deletions
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 61e8d27328e3..b8208b828106 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -509,10 +509,11 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
{
i = *itr;
aPos.SetTab( i );
- sal_uLong nIndex = (sal_uLong) static_cast<const SfxUInt32Item*>( pDoc->GetAttr(
- nCol, nRow, i, ATTR_VALUE_FORMAT ))->GetValue();
- if ( pFormatter->GetType( nIndex ) == css::util::NumberFormat::TEXT ||
- ( ( rString[0] == '+' || rString[0] == '-' ) && nError != FormulaError::NONE && rString == aFormula ) )
+ const sal_uInt32 nIndex = static_cast<const SfxUInt32Item*>( pDoc->GetAttr(
+ nCol, nRow, i, ATTR_VALUE_FORMAT ))->GetValue();
+ const sal_Int16 nType = pFormatter->GetType( nIndex);
+ if (nType == css::util::NumberFormat::TEXT ||
+ ((rString[0] == '+' || rString[0] == '-') && nError != FormulaError::NONE && rString == aFormula))
{
if ( pData )
{
@@ -532,6 +533,23 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
if(pCell->GetCode()->IsHyperLink())
pCell->GetCode()->SetHyperLink(false);
}
+ if (nType == css::util::NumberFormat::LOGICAL)
+ {
+ // Reset to General so the actual format can be determined
+ // after the cell has been interpreted. A sticky boolean
+ // number format is highly likely unwanted.. see tdf#75650.
+ // General of same locale as current number format.
+ const SvNumberformat* pEntry = pFormatter->GetEntry( nIndex);
+ const LanguageType nLang = (pEntry ? pEntry->GetLanguage() : ScGlobal::eLnge);
+ const sal_uInt32 nFormat = pFormatter->GetStandardFormat( css::util::NumberFormat::NUMBER, nLang);
+ ScPatternAttr aPattern( pDoc->GetPool());
+ aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nFormat));
+ ScMarkData aMark;
+ aMark.SelectTable( i, true);
+ aMark.SetMarkArea( ScRange( ScAddress( nCol, nRow, i)));
+ rFunc.ApplyAttributes( aMark, aPattern, false);
+ bNumFmtChanged = true;
+ }
rFunc.SetFormulaCell(aPos, pCell, true);
}
}