--- sc/inc/cellform.hxx +++ sc/inc/cellform.hxx @@ -58,7 +58,7 @@ public: ScForceTextFmt eForceTextFmt = ftDontForce ); static void GetInputString( ScBaseCell* pCell, ULONG nFormat, String& rString, - SvNumberFormatter& rFormatter ); + SvNumberFormatter& rFormatter, Color** ppColor = NULL ); }; --- sc/source/core/tool/cellform.cxx +++ sc/source/core/tool/cellform.cxx @@ -159,8 +159,11 @@ void ScCellFormat::GetString( ScBaseCell* pCell, ULONG nFormat, String& rString, } void ScCellFormat::GetInputString( ScBaseCell* pCell, ULONG nFormat, String& rString, - SvNumberFormatter& rFormatter ) + SvNumberFormatter& rFormatter, Color** ppColor ) { + if (ppColor) + *ppColor = NULL; + if (&rFormatter==NULL) { rString.Erase(); @@ -173,17 +176,19 @@ void ScCellFormat::GetInputString( ScBaseCell* pCell, ULONG nFormat, String& rSt case CELLTYPE_STRING: { ((ScStringCell*)pCell)->GetString( rString ); + rFormatter.GetStringColor(nFormat, ppColor); } break; case CELLTYPE_EDIT: { ((ScEditCell*)pCell)->GetString( rString ); + rFormatter.GetStringColor(nFormat, ppColor); } break; case CELLTYPE_VALUE: { double nValue = ((ScValueCell*)pCell)->GetValue(); - rFormatter.GetInputLineString( nValue, nFormat, rString ); + rFormatter.GetInputLineString( nValue, nFormat, rString, ppColor ); } break; case CELLTYPE_FORMULA: @@ -195,7 +200,7 @@ void ScCellFormat::GetInputString( ScBaseCell* pCell, ULONG nFormat, String& rSt else if (((ScFormulaCell*)pCell)->IsValue()) { double nValue = ((ScFormulaCell*)pCell)->GetValue(); - rFormatter.GetInputLineString( nValue, nFormat, rString ); + rFormatter.GetInputLineString( nValue, nFormat, rString, ppColor ); } else { --- sc/source/ui/view/output2.cxx +++ sc/source/ui/view/output2.cxx @@ -451,12 +451,23 @@ BOOL ScDrawStringsVars::SetText( ScBaseCell* pCell ) Color* pColor; ULONG nFormat = GetValueFormat(); - ScCellFormat::GetString( pCell, - nFormat, aString, &pColor, - *pOutput->pDoc->GetFormatTable(), - pOutput->bShowNullValues, - pOutput->bShowFormulas, - ftCheck ); + + if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0) + // For 'General' format type, display the value the same way it + // is displayed in the edit window, which automatically + // adjusts the number of decimal places based on the value of + // the cell. + ScCellFormat::GetInputString( pCell, + nFormat, aString, + *pOutput->pDoc->GetFormatTable(), + &pColor ); + else + ScCellFormat::GetString( pCell, + nFormat, aString, &pColor, + *pOutput->pDoc->GetFormatTable(), + pOutput->bShowNullValues, + pOutput->bShowFormulas, + ftCheck ); if (aString.Len() > DRAWTEXT_MAX) aString.Erase(DRAWTEXT_MAX);