1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cellform.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
33 // INCLUDE ---------------------------------------------------------------
35 #include <sfx2/objsh.hxx>
36 #include <svtools/smplhint.hxx>
37 #include <svtools/zforlist.hxx>
39 #include "cellform.hxx"
41 #include "document.hxx"
42 #include "formula/errorcodes.hxx"
45 // STATIC DATA -----------------------------------------------------------
48 const ScFormulaCell
* pLastFormulaTreeTop
= 0;
50 // -----------------------------------------------------------------------
52 void ScCellFormat::GetString( ScBaseCell
* pCell
, ULONG nFormat
, String
& rString
,
53 Color
** ppColor
, SvNumberFormatter
& rFormatter
,
56 ScForceTextFmt eForceTextFmt
)
59 if (&rFormatter
==NULL
)
65 CellType eType
= pCell
->GetCellType();
71 ((ScStringCell
*)pCell
)->GetString( aCellString
);
72 rFormatter
.GetOutputString( aCellString
, nFormat
, rString
, ppColor
);
78 ((ScEditCell
*)pCell
)->GetString( aCellString
);
79 rFormatter
.GetOutputString( aCellString
, nFormat
, rString
, ppColor
);
84 double nValue
= ((ScValueCell
*)pCell
)->GetValue();
85 if ( !bNullVals
&& nValue
== 0.0 )
89 if( eForceTextFmt
== ftCheck
)
91 if( nFormat
&& rFormatter
.IsTextFormat( nFormat
) )
92 eForceTextFmt
= ftForce
;
94 if( eForceTextFmt
== ftForce
)
97 rFormatter
.GetOutputString( nValue
, 0, aTemp
, ppColor
);
98 rFormatter
.GetOutputString( aTemp
, nFormat
, rString
, ppColor
);
101 rFormatter
.GetOutputString( nValue
, nFormat
, rString
, ppColor
);
105 case CELLTYPE_FORMULA
:
107 ScFormulaCell
* pFCell
= (ScFormulaCell
*)pCell
;
109 pFCell
->GetFormula( rString
);
112 // #62160# Ein via Interpreter gestartetes Makro, das hart
113 // auf Formelzellen zugreift, bekommt einen CellText, auch
114 // wenn dadurch ein weiterer Interpreter gestartet wird,
115 // aber nicht wenn diese Zelle gerade interpretiert wird.
116 // IdleCalc startet generell keine weiteren Interpreter,
117 // um keine Err522 (zirkulaer) zu bekommen.
118 if ( pFCell
->GetDocument()->IsInInterpreter() &&
119 (!pFCell
->GetDocument()->GetMacroInterpretLevel()
120 || pFCell
->IsRunning()) )
122 rString
.AssignAscii( RTL_CONSTASCII_STRINGPARAM("...") );
126 USHORT nErrCode
= pFCell
->GetErrCode();
128 // erst nach dem Interpretieren (GetErrCode) das Zahlformat holen:
129 if ( (nFormat
% SV_COUNTRY_LANGUAGE_OFFSET
) == 0 )
130 nFormat
= pFCell
->GetStandardFormat( rFormatter
,
134 rString
= ScGlobal::GetErrorString(nErrCode
);
135 else if ( pFCell
->IsEmptyDisplayedAsString() )
137 else if ( pFCell
->IsValue() )
139 double fValue
= pFCell
->GetValue();
140 if ( !bNullVals
&& fValue
== 0.0 )
143 rFormatter
.GetOutputString( fValue
, nFormat
, rString
, ppColor
);
148 pFCell
->GetString( aCellString
);
149 rFormatter
.GetOutputString( aCellString
, nFormat
, rString
, ppColor
);
161 void ScCellFormat::GetInputString( ScBaseCell
* pCell
, ULONG nFormat
, String
& rString
,
162 SvNumberFormatter
& rFormatter
)
164 if (&rFormatter
==NULL
)
170 CellType eType
= pCell
->GetCellType();
173 case CELLTYPE_STRING
:
175 ((ScStringCell
*)pCell
)->GetString( rString
);
180 ((ScEditCell
*)pCell
)->GetString( rString
);
185 double nValue
= ((ScValueCell
*)pCell
)->GetValue();
186 rFormatter
.GetInputLineString( nValue
, nFormat
, rString
);
189 case CELLTYPE_FORMULA
:
191 if (((ScFormulaCell
*)pCell
)->IsEmptyDisplayedAsString())
195 else if (((ScFormulaCell
*)pCell
)->IsValue())
197 double nValue
= ((ScFormulaCell
*)pCell
)->GetValue();
198 rFormatter
.GetInputLineString( nValue
, nFormat
, rString
);
202 ((ScFormulaCell
*)pCell
)->GetString( rString
);
205 USHORT nErrCode
= ((ScFormulaCell
*)pCell
)->GetErrCode();