merge the formfield patch from ooo-build
[ooovba.git] / basic / source / sbx / sbxvals.cxx
blobb5a27e371878dfa2ac44fa0318fe191812e122c9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sbxvals.cxx,v $
10 * $Revision: 1.8 $
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_basic.hxx"
34 #define _TLBIGINT_INT64
35 #include <tools/bigint.hxx>
36 #include <basic/sbx.hxx>
38 ///////////////////////////// BigInt/Currency //////////////////////////////
40 SbxValues::SbxValues( const BigInt &rBig ) : eType(SbxCURRENCY)
42 rBig.INT64( &nLong64 );
45 //TODO: BigInt is TOOLS_DLLPUBLIC, and its four member functions only declared
46 // and defined within basic (#define _TLBIGINT_INT64) are a bad hack that causes
47 // "warning C4273: 'function' : inconsistent dll linkage" on MSC; this whole
48 // mess should be cleaned up properly (e.g., by completely removing Sbx[U]INT64
49 // and using sal_[u]Int64 instead):
50 #if defined _MSC_VER
51 #pragma warning(disable: 4273)
52 #endif
54 BOOL BigInt::INT64( SbxINT64 *p ) const
56 if( bIsBig ) {
57 if( nLen > 4 || (nNum[3] & 0x8000) )
58 return FALSE;
60 p->nLow = ((UINT32)nNum[1] << 16) | (UINT32)nNum[0];
61 p->nHigh = ((UINT32)nNum[3] << 16) | (UINT32)nNum[2];
62 if( bIsNeg )
63 p->CHS();
65 else
66 p->Set( (INT32)nVal );
68 return TRUE;
71 BigInt::BigInt( const SbxINT64 &r )
73 BigInt a10000 = 0x10000;
75 *this = r.nHigh;
76 if( r.nHigh )
77 *this *= a10000;
78 *this += (USHORT)(r.nLow >> 16);
79 *this *= a10000;
80 *this += (USHORT)r.nLow;
83 BOOL BigInt::UINT64( SbxUINT64 *p ) const
85 if( bIsBig ) {
86 if( bIsNeg || nLen > 4 )
87 return FALSE;
89 p->nLow = ((UINT32)nNum[1] << 16) | (UINT32)nNum[0];
90 p->nHigh = ((UINT32)nNum[3] << 16) | (UINT32)nNum[2];
92 else {
93 if( nVal < 0 )
94 return FALSE;
96 p->Set( (UINT32)nVal );
99 return TRUE;
102 BigInt::BigInt( const SbxUINT64 &r )
104 BigInt a10000 = 0x10000;
106 *this = BigInt(r.nHigh);
107 if( r.nHigh )
108 *this *= a10000;
109 *this += (USHORT)(r.nLow >> 16);
110 *this *= a10000;
111 *this += (USHORT)r.nLow;