summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-10-06 21:29:26 +0200
committerEike Rathke <erack@redhat.com>2016-10-06 21:43:07 +0200
commite6b0ad680e6fa122e49bf01116edb049dc4b0570 (patch)
tree990df8ee34c898036e85df143225752430680794
parentc872e3c432566811e7644e76d1359b91fb377144 (diff)
Resolves: tdf#76836 use text format only for text content
Numeric content is not to be formatted with the text format. Entering a value in such formatted cell still forces it to text content as usual and then it is displayed using the text format. The previous behavior displaying also numeric content using the text format was always wrong and neither Excel nor Gnumeric do it. A numeric content is displayed left aligned though, which also Excel does. Change-Id: I3038123b2bfdc4669a8f73840742da92a1df895d
-rw-r--r--sc/inc/cellform.hxx11
-rw-r--r--sc/source/core/data/column2.cxx8
-rw-r--r--sc/source/core/tool/cellform.cxx23
-rw-r--r--sc/source/ui/view/output2.cxx8
4 files changed, 13 insertions, 37 deletions
diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx
index 84ee916e0468..ff2bb8ae328b 100644
--- a/sc/inc/cellform.hxx
+++ b/sc/inc/cellform.hxx
@@ -30,12 +30,6 @@ class ScDocument;
class ScAddress;
struct ScRefCellValue;
-enum ScForceTextFmt {
- ftDontForce, ///< numbers as numbers
- ftForce, ///< numbers as text
- ftCheck ///< is the numberformat a textformat?
-};
-
class SC_DLLPUBLIC ScCellFormat
{
public:
@@ -43,13 +37,12 @@ public:
static void GetString(
ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString,
Color** ppColor, SvNumberFormatter& rFormatter, const ScDocument* pDoc, bool bNullVals = true,
- bool bFormula = false, ScForceTextFmt eForceTextFmt = ftDontForce,
- bool bUseStarFormat = false );
+ bool bFormula = false, bool bUseStarFormat = false );
static OUString GetString(
ScDocument& rDoc, const ScAddress& rPos, sal_uLong nFormat,
Color** ppColor, SvNumberFormatter& rFormatter, bool bNullVals = true,
- bool bFormula = false, ScForceTextFmt eForceTextFmt = ftDontForce );
+ bool bFormula = false );
static void GetInputString(
ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString, SvNumberFormatter& rFormatter,
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 85ab7e6cb719..063e14e5d10f 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -271,7 +271,7 @@ long ScColumn::GetNeededSize(
Color* pColor;
OUString aValStr;
ScCellFormat::GetString(
- aCell, nFormat, aValStr, &pColor, *pFormatter, pDocument, true, rOptions.bFormula, ftCheck);
+ aCell, nFormat, aValStr, &pColor, *pFormatter, pDocument, true, rOptions.bFormula);
if (!aValStr.isEmpty())
{
@@ -443,7 +443,7 @@ long ScColumn::GetNeededSize(
OUString aString;
ScCellFormat::GetString(
aCell, nFormat, aString, &pColor, *pFormatter, pDocument, true,
- rOptions.bFormula, ftCheck);
+ rOptions.bFormula);
if (!aString.isEmpty())
pEngine->SetTextNewDefaults(aString, pSet);
@@ -581,7 +581,7 @@ class MaxStrLenFinder
Color* pColor;
OUString aValStr;
ScCellFormat::GetString(
- rCell, mnFormat, aValStr, &pColor, *mrDoc.GetFormatTable(), &mrDoc, true, false, ftCheck);
+ rCell, mnFormat, aValStr, &pColor, *mrDoc.GetFormatTable(), &mrDoc, true, false);
if (aValStr.getLength() > mnMaxLen)
{
@@ -668,7 +668,7 @@ sal_uInt16 ScColumn::GetOptimalColWidth(
{
ScRefCellValue aCell = GetCellValue(pParam->mnMaxTextRow);
ScCellFormat::GetString(
- aCell, nFormat, aLongStr, &pColor, *pFormatter, pDocument, true, false, ftCheck);
+ aCell, nFormat, aLongStr, &pColor, *pFormatter, pDocument, true, false);
}
else
{
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index 0507d7c17abf..afa9eeaedcba 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -35,8 +35,7 @@ const ScFormulaCell* pLastFormulaTreeTop = nullptr;
void ScCellFormat::GetString( ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString,
Color** ppColor, SvNumberFormatter& rFormatter, const ScDocument* pDoc,
- bool bNullVals, bool bFormula, ScForceTextFmt eForceTextFmt,
- bool bUseStarFormat )
+ bool bNullVals, bool bFormula, bool bUseStarFormat )
{
*ppColor = nullptr;
@@ -54,21 +53,7 @@ void ScCellFormat::GetString( ScRefCellValue& rCell, sal_uLong nFormat, OUString
if (!bNullVals && nValue == 0.0)
rString.clear();
else
- {
- if( eForceTextFmt == ftCheck )
- {
- if( nFormat && rFormatter.IsTextFormat( nFormat ) )
- eForceTextFmt = ftForce;
- }
- if( eForceTextFmt == ftForce )
- {
- OUString aTemp;
- rFormatter.GetOutputString( nValue, 0, aTemp, ppColor );
- rFormatter.GetOutputString( aTemp, nFormat, rString, ppColor );
- }
- else
- rFormatter.GetOutputString( nValue, nFormat, rString, ppColor, bUseStarFormat );
- }
+ rFormatter.GetOutputString( nValue, nFormat, rString, ppColor, bUseStarFormat );
}
break;
case CELLTYPE_FORMULA:
@@ -127,13 +112,13 @@ void ScCellFormat::GetString( ScRefCellValue& rCell, sal_uLong nFormat, OUString
OUString ScCellFormat::GetString(
ScDocument& rDoc, const ScAddress& rPos, sal_uLong nFormat, Color** ppColor,
- SvNumberFormatter& rFormatter, bool bNullVals, bool bFormula, ScForceTextFmt eForceTextFmt )
+ SvNumberFormatter& rFormatter, bool bNullVals, bool bFormula )
{
OUString aString;
*ppColor = nullptr;
ScRefCellValue aCell(rDoc, rPos);
- GetString(aCell, nFormat, aString, ppColor, rFormatter, &rDoc, bNullVals, bFormula, eForceTextFmt);
+ GetString(aCell, nFormat, aString, ppColor, rFormatter, &rDoc, bNullVals, bFormula);
return aString;
}
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index e6e75b2bd31c..0db71478e121 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -505,7 +505,7 @@ bool ScDrawStringsVars::SetText( ScRefCellValue& rCell )
pOutput->mpDoc,
pOutput->mbShowNullValues,
pOutput->mbShowFormulas,
- ftCheck, true );
+ true );
if ( nFormat )
{
nRepeatPos = aString.indexOf( 0x1B );
@@ -2394,8 +2394,7 @@ bool ScOutputData::DrawEditParam::readCellContent(
*pDoc->GetFormatTable(),
pDoc,
bShowNullValues,
- bShowFormulas,
- ftCheck );
+ bShowFormulas);
mpEngine->SetText(aString);
if ( pColor && !bSyntaxMode && !( bUseStyleColor && bForceAutoColor ) )
@@ -4922,8 +4921,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic)
*mpDoc->GetFormatTable(),
mpDoc,
mbShowNullValues,
- mbShowFormulas,
- ftCheck );
+ mbShowFormulas);
pEngine->SetText(aString);
if ( pColor && !mbSyntaxMode && !( mbUseStyleColor && mbForceAutoColor ) )