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 27cdf0e10cSrcweir #define _TLBIGINT_INT64 28cdf0e10cSrcweir #include <tools/bigint.hxx> 29cdf0e10cSrcweir #include <basic/sbx.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir ///////////////////////////// BigInt/Currency ////////////////////////////// 32cdf0e10cSrcweir SbxValues(const BigInt & rBig)33cdf0e10cSrcweirSbxValues::SbxValues( const BigInt &rBig ) : eType(SbxCURRENCY) 34cdf0e10cSrcweir { 35cdf0e10cSrcweir rBig.INT64( &nLong64 ); 36cdf0e10cSrcweir } 37cdf0e10cSrcweir 38cdf0e10cSrcweir //TODO: BigInt is TOOLS_DLLPUBLIC, and its four member functions only declared 39cdf0e10cSrcweir // and defined within basic (#define _TLBIGINT_INT64) are a bad hack that causes 40cdf0e10cSrcweir // "warning C4273: 'function' : inconsistent dll linkage" on MSC; this whole 41cdf0e10cSrcweir // mess should be cleaned up properly (e.g., by completely removing Sbx[U]INT64 42cdf0e10cSrcweir // and using sal_[u]Int64 instead): 43cdf0e10cSrcweir #if defined _MSC_VER 44cdf0e10cSrcweir #pragma warning(disable: 4273) 45cdf0e10cSrcweir #endif 46cdf0e10cSrcweir INT64(SbxINT64 * p) const47cdf0e10cSrcweirsal_Bool BigInt::INT64( SbxINT64 *p ) const 48cdf0e10cSrcweir { 49cdf0e10cSrcweir if( bIsBig ) { 50cdf0e10cSrcweir if( nLen > 4 || (nNum[3] & 0x8000) ) 51cdf0e10cSrcweir return sal_False; 52cdf0e10cSrcweir 53cdf0e10cSrcweir p->nLow = ((sal_uInt32)nNum[1] << 16) | (sal_uInt32)nNum[0]; 54cdf0e10cSrcweir p->nHigh = ((sal_uInt32)nNum[3] << 16) | (sal_uInt32)nNum[2]; 55cdf0e10cSrcweir if( bIsNeg ) 56cdf0e10cSrcweir p->CHS(); 57cdf0e10cSrcweir } 58cdf0e10cSrcweir else 59cdf0e10cSrcweir p->Set( (sal_Int32)nVal ); 60cdf0e10cSrcweir 61cdf0e10cSrcweir return sal_True; 62cdf0e10cSrcweir } 63cdf0e10cSrcweir BigInt(const SbxINT64 & r)64cdf0e10cSrcweirBigInt::BigInt( const SbxINT64 &r ) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir BigInt a10000 = 0x10000; 67cdf0e10cSrcweir 68cdf0e10cSrcweir *this = r.nHigh; 69cdf0e10cSrcweir if( r.nHigh ) 70cdf0e10cSrcweir *this *= a10000; 71cdf0e10cSrcweir *this += (sal_uInt16)(r.nLow >> 16); 72cdf0e10cSrcweir *this *= a10000; 73cdf0e10cSrcweir *this += (sal_uInt16)r.nLow; 74cdf0e10cSrcweir } 75cdf0e10cSrcweir UINT64(SbxUINT64 * p) const76cdf0e10cSrcweirsal_Bool BigInt::UINT64( SbxUINT64 *p ) const 77cdf0e10cSrcweir { 78cdf0e10cSrcweir if( bIsBig ) { 79cdf0e10cSrcweir if( bIsNeg || nLen > 4 ) 80cdf0e10cSrcweir return sal_False; 81cdf0e10cSrcweir 82cdf0e10cSrcweir p->nLow = ((sal_uInt32)nNum[1] << 16) | (sal_uInt32)nNum[0]; 83cdf0e10cSrcweir p->nHigh = ((sal_uInt32)nNum[3] << 16) | (sal_uInt32)nNum[2]; 84cdf0e10cSrcweir } 85cdf0e10cSrcweir else { 86cdf0e10cSrcweir if( nVal < 0 ) 87cdf0e10cSrcweir return sal_False; 88cdf0e10cSrcweir 89cdf0e10cSrcweir p->Set( (sal_uInt32)nVal ); 90cdf0e10cSrcweir } 91cdf0e10cSrcweir 92cdf0e10cSrcweir return sal_True; 93cdf0e10cSrcweir } 94cdf0e10cSrcweir BigInt(const SbxUINT64 & r)95cdf0e10cSrcweirBigInt::BigInt( const SbxUINT64 &r ) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir BigInt a10000 = 0x10000; 98cdf0e10cSrcweir 99cdf0e10cSrcweir *this = BigInt(r.nHigh); 100cdf0e10cSrcweir if( r.nHigh ) 101cdf0e10cSrcweir *this *= a10000; 102cdf0e10cSrcweir *this += (sal_uInt16)(r.nLow >> 16); 103cdf0e10cSrcweir *this *= a10000; 104cdf0e10cSrcweir *this += (sal_uInt16)r.nLow; 105cdf0e10cSrcweir } 106