summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-02-18 22:57:39 -0500
committerEike Rathke <erack@redhat.com>2014-03-06 14:51:15 -0600
commit016a231ef0a6bfb3c4b74a0e6d6d7431f42755c1 (patch)
tree21741b964953fe3cc82ce8c642fc697e39a8ad5c
parentebdf24c6731ccffb6dbd6e3487cd919890c844b3 (diff)
fdo#72491: Always set input as text when that's requested.
Even when the text begins with '='. (cherry picked from commit ca50752c34de4477c696471b707e1b8136e27661) Conflicts: sc/source/core/data/column3.cxx Change-Id: I6e0a995f3042240b9f78068b5d0b9b758eb253ed Reviewed-on: https://gerrit.libreoffice.org/8123 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/source/core/data/column3.cxx25
1 files changed, 20 insertions, 5 deletions
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index c19662ef69f4..4bd6a5a99d43 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1185,6 +1185,19 @@ void ScColumn::StartListeningInArea( sc::StartListeningContext& rCxt, SCROW nRow
}
}
+namespace {
+
+void applyTextNumFormat( ScColumn& rCol, ScDocument& rDoc, SCROW nRow, SvNumberFormatter* pFormatter )
+{
+ sal_uInt32 nFormat = pFormatter->GetStandardFormat(NUMBERFORMAT_TEXT);
+ ScPatternAttr aNewAttrs(rDoc.GetPool());
+ SfxItemSet& rSet = aNewAttrs.GetItemSet();
+ rSet.Put(SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat));
+ rCol.ApplyPattern(nRow, aNewAttrs);
+}
+
+}
+
bool ScColumn::ParseString(
ScCellValue& rCell, SCROW nRow, SCTAB nTabP, const String& rString,
formula::FormulaGrammar::AddressConvention eConv,
@@ -1217,6 +1230,12 @@ bool ScColumn::ParseString(
{
if ( rString.Len() == 1 ) // = Text
rCell.set(rString);
+ else if (aParam.meSetTextNumFormat == ScSetStringParam::Always)
+ {
+ // Set the cell format type to Text.
+ applyTextNumFormat(*this, *pDocument, nRow, aParam.mpNumFormatter);
+ rCell.set(rString);
+ }
else // = Formula
rCell.set(
new ScFormulaCell(
@@ -1325,11 +1344,7 @@ bool ScColumn::ParseString(
if (aParam.meSetTextNumFormat != ScSetStringParam::Never && aParam.mpNumFormatter->IsNumberFormat(rString, nIndex, nVal))
{
// Set the cell format type to Text.
- sal_uInt32 nFormat = aParam.mpNumFormatter->GetStandardFormat(NUMBERFORMAT_TEXT);
- ScPatternAttr aNewAttrs(pDocument->GetPool());
- SfxItemSet& rSet = aNewAttrs.GetItemSet();
- rSet.Put( SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat) );
- ApplyPattern(nRow, aNewAttrs);
+ applyTextNumFormat(*this, *pDocument, nRow, aParam.mpNumFormatter);
}
rCell.set(rString);