summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-03-04 13:31:38 -0500
committerKohei Yoshida <kyoshida@novell.com>2011-03-04 13:31:38 -0500
commitdfbc969ff099ffae187998cfc5ad88fbb52120f0 (patch)
tree9cc92ee09513f51a021f20e414c8220871f636ef
parentf87a0c0b9e4a98e0ab718377c4d4ab98eece6b37 (diff)
Don't strip the first apostrophe from a text input. (fdo#34260)
Also removed the abuse of this behavior during datapilot output construction. Thanks largely to the unit test. :-)
-rw-r--r--sc/source/core/data/column3.cxx13
-rw-r--r--sc/source/core/data/dpoutput.cxx8
-rw-r--r--sc/source/core/tool/cellform.cxx2
3 files changed, 14 insertions, 9 deletions
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 44931e79f..f5c5fc6ae 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1311,7 +1311,18 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString,
eConv), MM_NONE );
}
else if ( cFirstChar == '\'') // 'Text
- pNewCell = new ScStringCell( rString.Copy(1) );
+ {
+ // Cell format is not 'Text', and the first char
+ // is an apostrophe. Check if the input is considered a number.
+ String aTest = rString.Copy(1);
+ double fTest;
+ if (aParam.mpNumFormatter->IsNumberFormat(aTest, nIndex, fTest))
+ // This is a number. Strip out the first char.
+ pNewCell = new ScStringCell(aTest);
+ else
+ // This is a normal text. Take it as-is.
+ pNewCell = new ScStringCell(rString);
+ }
else
{
double nVal;
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index f41f4c260..60ad0fc8b 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -612,15 +612,9 @@ void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
{
long nFlags = rData.Flags;
- rtl::OUStringBuffer aCaptionBuf;
- if (!(nFlags & sheet::MemberResultFlags::NUMERIC))
- // This caption is not a number. Make sure it won't get parsed as one.
- aCaptionBuf.append(sal_Unicode('\''));
- aCaptionBuf.append(rData.Caption);
-
if ( nFlags & sheet::MemberResultFlags::HASMEMBER )
{
- pDoc->SetString( nCol, nRow, nTab, aCaptionBuf.makeStringAndClear() );
+ pDoc->SetString( nCol, nRow, nTab, rData.Caption);
}
if ( nFlags & sheet::MemberResultFlags::SUBTOTAL )
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index 0da2a8cdf..9c7d8093a 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -46,7 +46,7 @@
const ScFormulaCell* pLastFormulaTreeTop = 0;
// -----------------------------------------------------------------------
-
+#include <stdio.h>
void ScCellFormat::GetString( ScBaseCell* pCell, ULONG nFormat, String& rString,
Color** ppColor, SvNumberFormatter& rFormatter,
BOOL bNullVals,