merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0179-calc-general-type-auto-decimal-sc.diff
blobc0a4db18478e8cbc2df6c77ead439e5ae07b1425
1 diff --git sc/inc/cellform.hxx sc/inc/cellform.hxx
2 index a94ef54..d5c5b20 100644
3 --- sc/inc/cellform.hxx
4 +++ sc/inc/cellform.hxx
5 @@ -58,7 +58,7 @@ public:
6 ScForceTextFmt eForceTextFmt = ftDontForce );
8 static void GetInputString( ScBaseCell* pCell, ULONG nFormat, String& rString,
9 - SvNumberFormatter& rFormatter );
10 + SvNumberFormatter& rFormatter, Color** ppColor = NULL );
14 diff --git sc/source/core/tool/cellform.cxx sc/source/core/tool/cellform.cxx
15 index e6177b0..e17ef9c 100644
16 --- sc/source/core/tool/cellform.cxx
17 +++ sc/source/core/tool/cellform.cxx
18 @@ -159,8 +159,11 @@ void ScCellFormat::GetString( ScBaseCell* pCell, ULONG nFormat, String& rString,
21 void ScCellFormat::GetInputString( ScBaseCell* pCell, ULONG nFormat, String& rString,
22 - SvNumberFormatter& rFormatter )
23 + SvNumberFormatter& rFormatter, Color** ppColor )
25 + if (ppColor)
26 + *ppColor = NULL;
28 if (&rFormatter==NULL)
30 rString.Erase();
31 @@ -173,17 +176,19 @@ void ScCellFormat::GetInputString( ScBaseCell* pCell, ULONG nFormat, String& rSt
32 case CELLTYPE_STRING:
34 ((ScStringCell*)pCell)->GetString( rString );
35 + rFormatter.GetStringColor(nFormat, ppColor);
37 break;
38 case CELLTYPE_EDIT:
40 ((ScEditCell*)pCell)->GetString( rString );
41 + rFormatter.GetStringColor(nFormat, ppColor);
43 break;
44 case CELLTYPE_VALUE:
46 double nValue = ((ScValueCell*)pCell)->GetValue();
47 - rFormatter.GetInputLineString( nValue, nFormat, rString );
48 + rFormatter.GetInputLineString( nValue, nFormat, rString, ppColor );
50 break;
51 case CELLTYPE_FORMULA:
52 @@ -195,7 +200,7 @@ void ScCellFormat::GetInputString( ScBaseCell* pCell, ULONG nFormat, String& rSt
53 else if (((ScFormulaCell*)pCell)->IsValue())
55 double nValue = ((ScFormulaCell*)pCell)->GetValue();
56 - rFormatter.GetInputLineString( nValue, nFormat, rString );
57 + rFormatter.GetInputLineString( nValue, nFormat, rString, ppColor );
59 else
61 diff --git sc/source/ui/view/output2.cxx sc/source/ui/view/output2.cxx
62 index 8942a38..5826bb1 100644
63 --- sc/source/ui/view/output2.cxx
64 +++ sc/source/ui/view/output2.cxx
65 @@ -451,12 +451,23 @@ BOOL ScDrawStringsVars::SetText( ScBaseCell* pCell )
67 Color* pColor;
68 ULONG nFormat = GetValueFormat();
69 - ScCellFormat::GetString( pCell,
70 - nFormat, aString, &pColor,
71 - *pOutput->pDoc->GetFormatTable(),
72 - pOutput->bShowNullValues,
73 - pOutput->bShowFormulas,
74 - ftCheck );
76 + if (static_cast<NfIndexTableOffset>(nFormat) == NF_NUMBER_STANDARD)
77 + // For 'General' format type, display the value the same way it
78 + // is displayed in the edit window, which automatically
79 + // adjusts the number of decimal places based on the value of
80 + // the cell.
81 + ScCellFormat::GetInputString( pCell,
82 + nFormat, aString,
83 + *pOutput->pDoc->GetFormatTable(),
84 + &pColor );
85 + else
86 + ScCellFormat::GetString( pCell,
87 + nFormat, aString, &pColor,
88 + *pOutput->pDoc->GetFormatTable(),
89 + pOutput->bShowNullValues,
90 + pOutput->bShowFormulas,
91 + ftCheck );
93 if (aString.Len() > DRAWTEXT_MAX)
94 aString.Erase(DRAWTEXT_MAX);