1*e1f63238SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*e1f63238SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*e1f63238SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*e1f63238SAndrew Rist * distributed with this work for additional information
6*e1f63238SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*e1f63238SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*e1f63238SAndrew Rist * "License"); you may not use this file except in compliance
9*e1f63238SAndrew Rist * with the License. You may obtain a copy of the License at
10*e1f63238SAndrew Rist *
11*e1f63238SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*e1f63238SAndrew Rist *
13*e1f63238SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*e1f63238SAndrew Rist * software distributed under the License is distributed on an
15*e1f63238SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*e1f63238SAndrew Rist * KIND, either express or implied. See the License for the
17*e1f63238SAndrew Rist * specific language governing permissions and limitations
18*e1f63238SAndrew Rist * under the License.
19*e1f63238SAndrew Rist *
20*e1f63238SAndrew Rist *************************************************************/
21*e1f63238SAndrew Rist
22*e1f63238SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_basic.hxx"
26cdf0e10cSrcweir #include <vcl/svapp.hxx>
27cdf0e10cSrcweir #include <svl/zforlist.hxx>
28cdf0e10cSrcweir #include <tools/errcode.hxx>
29cdf0e10cSrcweir #include <tools/color.hxx>
30cdf0e10cSrcweir #include <i18npool/lang.h>
31cdf0e10cSrcweir #include <basic/sbx.hxx>
32cdf0e10cSrcweir #include "sbxconv.hxx"
33cdf0e10cSrcweir #include "math.h"
34cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
35cdf0e10cSrcweir
36cdf0e10cSrcweir
ImpGetDate(const SbxValues * p)37cdf0e10cSrcweir double ImpGetDate( const SbxValues* p )
38cdf0e10cSrcweir {
39cdf0e10cSrcweir double nRes;
40cdf0e10cSrcweir switch( +p->eType )
41cdf0e10cSrcweir {
42cdf0e10cSrcweir case SbxNULL:
43cdf0e10cSrcweir SbxBase::SetError( SbxERR_CONVERSION );
44cdf0e10cSrcweir case SbxEMPTY:
45cdf0e10cSrcweir nRes = 0; break;
46cdf0e10cSrcweir case SbxCHAR:
47cdf0e10cSrcweir nRes = p->nChar; break;
48cdf0e10cSrcweir case SbxBYTE:
49cdf0e10cSrcweir nRes = p->nByte; break;
50cdf0e10cSrcweir case SbxINTEGER:
51cdf0e10cSrcweir case SbxBOOL:
52cdf0e10cSrcweir nRes = p->nInteger; break;
53cdf0e10cSrcweir case SbxERROR:
54cdf0e10cSrcweir case SbxUSHORT:
55cdf0e10cSrcweir nRes = p->nUShort; break;
56cdf0e10cSrcweir case SbxLONG:
57cdf0e10cSrcweir nRes = (double) p->nLong; break;
58cdf0e10cSrcweir case SbxULONG:
59cdf0e10cSrcweir nRes = (double) p->nULong; break;
60cdf0e10cSrcweir case SbxSINGLE:
61cdf0e10cSrcweir nRes = p->nSingle; break;
62cdf0e10cSrcweir case SbxDATE:
63cdf0e10cSrcweir case SbxDOUBLE:
64cdf0e10cSrcweir nRes = p->nDouble; break;
65cdf0e10cSrcweir case SbxULONG64:
66cdf0e10cSrcweir nRes = ImpUINT64ToDouble( p->nULong64 ); break;
67cdf0e10cSrcweir case SbxLONG64:
68cdf0e10cSrcweir nRes = ImpINT64ToDouble( p->nLong64 ); break;
69cdf0e10cSrcweir case SbxCURRENCY:
70cdf0e10cSrcweir nRes = ImpCurrencyToDouble( p->nLong64 ); break;
71cdf0e10cSrcweir case SbxSALINT64:
72cdf0e10cSrcweir nRes = static_cast< double >(p->nInt64); break;
73cdf0e10cSrcweir case SbxSALUINT64:
74cdf0e10cSrcweir nRes = ImpSalUInt64ToDouble( p->uInt64 ); break;
75cdf0e10cSrcweir case SbxDECIMAL:
76cdf0e10cSrcweir case SbxBYREF | SbxDECIMAL:
77cdf0e10cSrcweir if( p->pDecimal )
78cdf0e10cSrcweir p->pDecimal->getDouble( nRes );
79cdf0e10cSrcweir else
80cdf0e10cSrcweir nRes = 0.0;
81cdf0e10cSrcweir break;
82cdf0e10cSrcweir case SbxBYREF | SbxSTRING:
83cdf0e10cSrcweir case SbxSTRING:
84cdf0e10cSrcweir case SbxLPSTR:
85cdf0e10cSrcweir if( !p->pOUString )
86cdf0e10cSrcweir nRes = 0;
87cdf0e10cSrcweir else
88cdf0e10cSrcweir {
89cdf0e10cSrcweir LanguageType eLangType = GetpApp()->GetSettings().GetLanguage();
90cdf0e10cSrcweir
91cdf0e10cSrcweir SvNumberFormatter* pFormatter;
92cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
93cdf0e10cSrcweir xFactory = comphelper::getProcessServiceFactory();
94cdf0e10cSrcweir pFormatter = new SvNumberFormatter( xFactory, eLangType );
95cdf0e10cSrcweir
96cdf0e10cSrcweir sal_uInt32 nIndex;
97cdf0e10cSrcweir xub_StrLen nCheckPos = 0;
98cdf0e10cSrcweir short nType = 127;
99cdf0e10cSrcweir
100cdf0e10cSrcweir // Standard-Vorlagen des Formatters haben nur zweistellige
101cdf0e10cSrcweir // Jahreszahl. Deshalb eigenes Format registrieren
102cdf0e10cSrcweir
103cdf0e10cSrcweir // HACK, da der Numberformatter in PutandConvertEntry die Platzhalter
104cdf0e10cSrcweir // fuer Monat, Tag, Jahr nicht entsprechend der Systemeinstellung
105cdf0e10cSrcweir // austauscht. Problem: Print Year(Date) unter engl. BS
106cdf0e10cSrcweir // siehe auch basic\source\runtime\runtime.cxx
107cdf0e10cSrcweir
108cdf0e10cSrcweir SvtSysLocale aSysLocale;
109cdf0e10cSrcweir DateFormat eDate = aSysLocale.GetLocaleData().getDateFormat();
110cdf0e10cSrcweir String aDateStr;
111cdf0e10cSrcweir switch( eDate )
112cdf0e10cSrcweir {
113cdf0e10cSrcweir case MDY: aDateStr.AssignAscii( "MM.TT.JJJJ" ); break;
114cdf0e10cSrcweir case DMY: aDateStr.AssignAscii( "TT.MM.JJJJ" ); break;
115cdf0e10cSrcweir case YMD: aDateStr.AssignAscii( "JJJJ.MM.TT" ); break;
116cdf0e10cSrcweir default: aDateStr.AssignAscii( "MM.TT.JJJJ" );
117cdf0e10cSrcweir }
118cdf0e10cSrcweir
119cdf0e10cSrcweir String aStr( aDateStr );
120cdf0e10cSrcweir aStr.AppendAscii( " HH:MM:SS" );
121cdf0e10cSrcweir
122cdf0e10cSrcweir pFormatter->PutandConvertEntry( aStr, nCheckPos, nType,
123cdf0e10cSrcweir nIndex, LANGUAGE_GERMAN, eLangType );
124cdf0e10cSrcweir sal_Bool bSuccess = pFormatter->IsNumberFormat( *p->pOUString, nIndex, nRes );
125cdf0e10cSrcweir if ( bSuccess )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir short nType_ = pFormatter->GetType( nIndex );
128cdf0e10cSrcweir if(!(nType_ & ( NUMBERFORMAT_DATETIME | NUMBERFORMAT_DATE |
129cdf0e10cSrcweir NUMBERFORMAT_TIME | NUMBERFORMAT_DEFINED )))
130cdf0e10cSrcweir bSuccess = sal_False;
131cdf0e10cSrcweir }
132cdf0e10cSrcweir
133cdf0e10cSrcweir if ( !bSuccess )
134cdf0e10cSrcweir {
135cdf0e10cSrcweir SbxBase::SetError( SbxERR_CONVERSION ); nRes = 0;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir
138cdf0e10cSrcweir delete pFormatter;
139cdf0e10cSrcweir }
140cdf0e10cSrcweir break;
141cdf0e10cSrcweir case SbxOBJECT:
142cdf0e10cSrcweir {
143cdf0e10cSrcweir SbxValue* pVal = PTR_CAST(SbxValue,p->pObj);
144cdf0e10cSrcweir if( pVal )
145cdf0e10cSrcweir nRes = pVal->GetDate();
146cdf0e10cSrcweir else
147cdf0e10cSrcweir {
148cdf0e10cSrcweir SbxBase::SetError( SbxERR_NO_OBJECT ); nRes = 0;
149cdf0e10cSrcweir }
150cdf0e10cSrcweir break;
151cdf0e10cSrcweir }
152cdf0e10cSrcweir
153cdf0e10cSrcweir case SbxBYREF | SbxCHAR:
154cdf0e10cSrcweir nRes = *p->pChar; break;
155cdf0e10cSrcweir case SbxBYREF | SbxBYTE:
156cdf0e10cSrcweir nRes = *p->pByte; break;
157cdf0e10cSrcweir case SbxBYREF | SbxINTEGER:
158cdf0e10cSrcweir case SbxBYREF | SbxBOOL:
159cdf0e10cSrcweir nRes = *p->pInteger; break;
160cdf0e10cSrcweir case SbxBYREF | SbxLONG:
161cdf0e10cSrcweir nRes = *p->pLong; break;
162cdf0e10cSrcweir case SbxBYREF | SbxULONG:
163cdf0e10cSrcweir nRes = *p->pULong; break;
164cdf0e10cSrcweir case SbxBYREF | SbxERROR:
165cdf0e10cSrcweir case SbxBYREF | SbxUSHORT:
166cdf0e10cSrcweir nRes = *p->pUShort; break;
167cdf0e10cSrcweir case SbxBYREF | SbxSINGLE:
168cdf0e10cSrcweir nRes = *p->pSingle; break;
169cdf0e10cSrcweir case SbxBYREF | SbxDATE:
170cdf0e10cSrcweir case SbxBYREF | SbxDOUBLE:
171cdf0e10cSrcweir nRes = *p->pDouble; break;
172cdf0e10cSrcweir case SbxBYREF | SbxULONG64:
173cdf0e10cSrcweir nRes = ImpUINT64ToDouble( *p->pULong64 ); break;
174cdf0e10cSrcweir case SbxBYREF | SbxLONG64:
175cdf0e10cSrcweir nRes = ImpINT64ToDouble( *p->pLong64 ); break;
176cdf0e10cSrcweir case SbxBYREF | SbxCURRENCY:
177cdf0e10cSrcweir nRes = ImpCurrencyToDouble( *p->pLong64 ); break;
178cdf0e10cSrcweir case SbxBYREF | SbxSALINT64:
179cdf0e10cSrcweir nRes = static_cast< double >(*p->pnInt64); break;
180cdf0e10cSrcweir case SbxBYREF | SbxSALUINT64:
181cdf0e10cSrcweir nRes = ImpSalUInt64ToDouble( *p->puInt64 ); break;
182cdf0e10cSrcweir
183cdf0e10cSrcweir default:
184cdf0e10cSrcweir SbxBase::SetError( SbxERR_CONVERSION ); nRes = 0;
185cdf0e10cSrcweir }
186cdf0e10cSrcweir return nRes;
187cdf0e10cSrcweir }
188cdf0e10cSrcweir
ImpPutDate(SbxValues * p,double n)189cdf0e10cSrcweir void ImpPutDate( SbxValues* p, double n )
190cdf0e10cSrcweir {
191cdf0e10cSrcweir SbxValues aTmp;
192cdf0e10cSrcweir
193cdf0e10cSrcweir start:
194cdf0e10cSrcweir switch( +p->eType )
195cdf0e10cSrcweir {
196cdf0e10cSrcweir case SbxDATE:
197cdf0e10cSrcweir case SbxDOUBLE:
198cdf0e10cSrcweir p->nDouble = n; break;
199cdf0e10cSrcweir
200cdf0e10cSrcweir // ab hier wird getestet
201cdf0e10cSrcweir case SbxCHAR:
202cdf0e10cSrcweir aTmp.pChar = &p->nChar; goto direct;
203cdf0e10cSrcweir case SbxBYTE:
204cdf0e10cSrcweir aTmp.pByte = &p->nByte; goto direct;
205cdf0e10cSrcweir case SbxINTEGER:
206cdf0e10cSrcweir case SbxBOOL:
207cdf0e10cSrcweir aTmp.pInteger = &p->nInteger; goto direct;
208cdf0e10cSrcweir case SbxLONG:
209cdf0e10cSrcweir aTmp.pLong = &p->nLong; goto direct;
210cdf0e10cSrcweir case SbxULONG:
211cdf0e10cSrcweir aTmp.pULong = &p->nULong; goto direct;
212cdf0e10cSrcweir case SbxERROR:
213cdf0e10cSrcweir case SbxUSHORT:
214cdf0e10cSrcweir aTmp.pUShort = &p->nUShort; goto direct;
215cdf0e10cSrcweir case SbxSINGLE:
216cdf0e10cSrcweir aTmp.pSingle = &p->nSingle; goto direct;
217cdf0e10cSrcweir case SbxULONG64:
218cdf0e10cSrcweir aTmp.pULong64 = &p->nULong64; goto direct;
219cdf0e10cSrcweir case SbxLONG64:
220cdf0e10cSrcweir case SbxCURRENCY:
221cdf0e10cSrcweir aTmp.pLong64 = &p->nLong64; goto direct;
222cdf0e10cSrcweir case SbxSALINT64:
223cdf0e10cSrcweir aTmp.pnInt64 = &p->nInt64; goto direct;
224cdf0e10cSrcweir case SbxSALUINT64:
225cdf0e10cSrcweir aTmp.puInt64 = &p->uInt64; goto direct;
226cdf0e10cSrcweir case SbxDECIMAL:
227cdf0e10cSrcweir case SbxBYREF | SbxDECIMAL:
228cdf0e10cSrcweir {
229cdf0e10cSrcweir SbxDecimal* pDec = ImpCreateDecimal( p );
230cdf0e10cSrcweir if( !pDec->setDouble( n ) )
231cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW );
232cdf0e10cSrcweir break;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir direct:
235cdf0e10cSrcweir aTmp.eType = SbxDataType( p->eType | SbxBYREF );
236cdf0e10cSrcweir p = &aTmp; goto start;
237cdf0e10cSrcweir
238cdf0e10cSrcweir case SbxBYREF | SbxSTRING:
239cdf0e10cSrcweir case SbxSTRING:
240cdf0e10cSrcweir case SbxLPSTR:
241cdf0e10cSrcweir {
242cdf0e10cSrcweir if( !p->pOUString )
243cdf0e10cSrcweir p->pOUString = new ::rtl::OUString;
244cdf0e10cSrcweir Color* pColor;
245cdf0e10cSrcweir
246cdf0e10cSrcweir LanguageType eLangType = GetpApp()->GetSettings().GetLanguage();
247cdf0e10cSrcweir SvNumberFormatter* pFormatter;
248cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
249cdf0e10cSrcweir xFactory = comphelper::getProcessServiceFactory();
250cdf0e10cSrcweir pFormatter = new SvNumberFormatter( xFactory, eLangType );
251cdf0e10cSrcweir
252cdf0e10cSrcweir sal_uInt32 nIndex;
253cdf0e10cSrcweir xub_StrLen nCheckPos = 0;
254cdf0e10cSrcweir short nType;
255cdf0e10cSrcweir
256cdf0e10cSrcweir SvtSysLocale aSysLocale;
257cdf0e10cSrcweir DateFormat eDate = aSysLocale.GetLocaleData().getDateFormat();
258cdf0e10cSrcweir String aStr;
259cdf0e10cSrcweir // ist der ganzzahlige Teil 0, wollen wir kein Jahr!
260cdf0e10cSrcweir if( n <= -1.0 || n >= 1.0 )
261cdf0e10cSrcweir {
262cdf0e10cSrcweir // Time only if != 00:00:00
263cdf0e10cSrcweir if( floor( n ) == n )
264cdf0e10cSrcweir {
265cdf0e10cSrcweir switch( eDate )
266cdf0e10cSrcweir {
267cdf0e10cSrcweir case MDY: aStr.AssignAscii( "MM.TT.JJJJ" ); break;
268cdf0e10cSrcweir case DMY: aStr.AssignAscii( "TT.MM.JJJJ" ); break;
269cdf0e10cSrcweir case YMD: aStr.AssignAscii( "JJJJ.MM.TT" ); break;
270cdf0e10cSrcweir default: aStr.AssignAscii( "MM.TT.JJJJ" );
271cdf0e10cSrcweir }
272cdf0e10cSrcweir }
273cdf0e10cSrcweir else
274cdf0e10cSrcweir {
275cdf0e10cSrcweir switch( eDate )
276cdf0e10cSrcweir {
277cdf0e10cSrcweir case MDY: aStr.AssignAscii( "MM.TT.JJJJ HH:MM:SS" ); break;
278cdf0e10cSrcweir case DMY: aStr.AssignAscii( "TT.MM.JJJJ HH:MM:SS" ); break;
279cdf0e10cSrcweir case YMD: aStr.AssignAscii( "JJJJ.MM.TT HH:MM:SS" ); break;
280cdf0e10cSrcweir default: aStr.AssignAscii( "MM.TT.JJJJ HH:MM:SS" );
281cdf0e10cSrcweir }
282cdf0e10cSrcweir }
283cdf0e10cSrcweir }
284cdf0e10cSrcweir else
285cdf0e10cSrcweir aStr.AppendAscii( "HH:MM:SS" );
286cdf0e10cSrcweir
287cdf0e10cSrcweir pFormatter->PutandConvertEntry( aStr,
288cdf0e10cSrcweir nCheckPos,
289cdf0e10cSrcweir nType,
290cdf0e10cSrcweir nIndex,
291cdf0e10cSrcweir LANGUAGE_GERMAN,
292cdf0e10cSrcweir eLangType );
293cdf0e10cSrcweir String aTmpString;
294cdf0e10cSrcweir pFormatter->GetOutputString( n, nIndex, aTmpString, &pColor );
295cdf0e10cSrcweir *p->pOUString = aTmpString;
296cdf0e10cSrcweir delete pFormatter;
297cdf0e10cSrcweir break;
298cdf0e10cSrcweir }
299cdf0e10cSrcweir case SbxOBJECT:
300cdf0e10cSrcweir {
301cdf0e10cSrcweir SbxValue* pVal = PTR_CAST(SbxValue,p->pObj);
302cdf0e10cSrcweir if( pVal )
303cdf0e10cSrcweir pVal->PutDate( n );
304cdf0e10cSrcweir else
305cdf0e10cSrcweir SbxBase::SetError( SbxERR_NO_OBJECT );
306cdf0e10cSrcweir break;
307cdf0e10cSrcweir }
308cdf0e10cSrcweir case SbxBYREF | SbxCHAR:
309cdf0e10cSrcweir if( n > SbxMAXCHAR )
310cdf0e10cSrcweir {
311cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXCHAR;
312cdf0e10cSrcweir }
313cdf0e10cSrcweir else if( n < SbxMINCHAR )
314cdf0e10cSrcweir {
315cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMINCHAR;
316cdf0e10cSrcweir }
317cdf0e10cSrcweir *p->pChar = (xub_Unicode) n; break;
318cdf0e10cSrcweir case SbxBYREF | SbxBYTE:
319cdf0e10cSrcweir if( n > SbxMAXBYTE )
320cdf0e10cSrcweir {
321cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXBYTE;
322cdf0e10cSrcweir }
323cdf0e10cSrcweir else if( n < 0 )
324cdf0e10cSrcweir {
325cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); n = 0;
326cdf0e10cSrcweir }
327cdf0e10cSrcweir *p->pByte = (sal_uInt8) n; break;
328cdf0e10cSrcweir case SbxBYREF | SbxINTEGER:
329cdf0e10cSrcweir case SbxBYREF | SbxBOOL:
330cdf0e10cSrcweir if( n > SbxMAXINT )
331cdf0e10cSrcweir {
332cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXINT;
333cdf0e10cSrcweir }
334cdf0e10cSrcweir else if( n < SbxMININT )
335cdf0e10cSrcweir {
336cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMININT;
337cdf0e10cSrcweir }
338cdf0e10cSrcweir *p->pInteger = (sal_Int16) n; break;
339cdf0e10cSrcweir case SbxBYREF | SbxERROR:
340cdf0e10cSrcweir case SbxBYREF | SbxUSHORT:
341cdf0e10cSrcweir if( n > SbxMAXUINT )
342cdf0e10cSrcweir {
343cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXUINT;
344cdf0e10cSrcweir }
345cdf0e10cSrcweir else if( n < 0 )
346cdf0e10cSrcweir {
347cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); n = 0;
348cdf0e10cSrcweir }
349cdf0e10cSrcweir *p->pUShort = (sal_uInt16) n; break;
350cdf0e10cSrcweir case SbxBYREF | SbxLONG:
351cdf0e10cSrcweir if( n > SbxMAXLNG )
352cdf0e10cSrcweir {
353cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXLNG;
354cdf0e10cSrcweir }
355cdf0e10cSrcweir else if( n < SbxMINLNG )
356cdf0e10cSrcweir {
357cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMINLNG;
358cdf0e10cSrcweir }
359cdf0e10cSrcweir *p->pLong = (sal_Int32) n; break;
360cdf0e10cSrcweir case SbxBYREF | SbxULONG:
361cdf0e10cSrcweir if( n > SbxMAXULNG )
362cdf0e10cSrcweir {
363cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXULNG;
364cdf0e10cSrcweir }
365cdf0e10cSrcweir else if( n < 0 )
366cdf0e10cSrcweir {
367cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); n = 0;
368cdf0e10cSrcweir }
369cdf0e10cSrcweir *p->pULong = (sal_uInt32) n; break;
370cdf0e10cSrcweir case SbxBYREF | SbxSINGLE:
371cdf0e10cSrcweir if( n > SbxMAXSNG )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXSNG;
374cdf0e10cSrcweir }
375cdf0e10cSrcweir else if( n < SbxMINSNG )
376cdf0e10cSrcweir {
377cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMINSNG;
378cdf0e10cSrcweir }
379cdf0e10cSrcweir *p->pSingle = (float) n; break;
380cdf0e10cSrcweir case SbxBYREF | SbxSALINT64:
381cdf0e10cSrcweir *p->pnInt64 = ImpDoubleToSalInt64( n ); break;
382cdf0e10cSrcweir case SbxBYREF | SbxSALUINT64:
383cdf0e10cSrcweir *p->puInt64 = ImpDoubleToSalUInt64( n ); break;
384cdf0e10cSrcweir case SbxBYREF | SbxDATE:
385cdf0e10cSrcweir case SbxBYREF | SbxDOUBLE:
386cdf0e10cSrcweir *p->pDouble = (double) n; break;
387cdf0e10cSrcweir case SbxBYREF | SbxCURRENCY:
388cdf0e10cSrcweir if( n > SbxMAXCURR )
389cdf0e10cSrcweir {
390cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXCURR;
391cdf0e10cSrcweir }
392cdf0e10cSrcweir else if( n < SbxMINCURR )
393cdf0e10cSrcweir {
394cdf0e10cSrcweir SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMINCURR;
395cdf0e10cSrcweir }
396cdf0e10cSrcweir *p->pLong64 = ImpDoubleToCurrency( n ); break;
397cdf0e10cSrcweir
398cdf0e10cSrcweir default:
399cdf0e10cSrcweir SbxBase::SetError( SbxERR_CONVERSION );
400cdf0e10cSrcweir }
401cdf0e10cSrcweir }
402cdf0e10cSrcweir
403