fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / basic / source / sbx / sbxvals.cxx
blob654f63f959876f4c3bede6bbbf34d24c0205d24b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #define _TLBIGINT_INT64
22 #include <tools/bigint.hxx>
23 #include <basic/sbx.hxx>
25 ///////////////////////////// BigInt/Currency //////////////////////////////
27 SbxValues::SbxValues( const BigInt &rBig ) : eType(SbxCURRENCY)
29 rBig.INT64( &nLong64 );
32 //TODO: BigInt is TOOLS_DLLPUBLIC, and its four member functions only declared
33 // and defined within basic (#define _TLBIGINT_INT64) are a bad hack that causes
34 // "warning C4273: 'function' : inconsistent dll linkage" on MSC; this whole
35 // mess should be cleaned up properly (e.g., by completely removing Sbx[U]INT64
36 // and using sal_[u]Int64 instead):
37 #if defined _MSC_VER
38 #pragma warning(disable: 4273)
39 #endif
41 sal_Bool BigInt::INT64( SbxINT64 *p ) const
43 if( bIsBig ) {
44 if( nLen > 4 || (nNum[3] & 0x8000) )
45 return sal_False;
47 p->nLow = ((sal_uInt32)nNum[1] << 16) | (sal_uInt32)nNum[0];
48 p->nHigh = ((sal_uInt32)nNum[3] << 16) | (sal_uInt32)nNum[2];
49 if( bIsNeg )
50 p->CHS();
52 else
53 p->Set( (sal_Int32)nVal );
55 return sal_True;
58 BigInt::BigInt( const SbxINT64 &r )
60 BigInt a10000 = 0x10000;
62 *this = r.nHigh;
63 if( r.nHigh )
64 *this *= a10000;
65 *this += (sal_uInt16)(r.nLow >> 16);
66 *this *= a10000;
67 *this += (sal_uInt16)r.nLow;
70 sal_Bool BigInt::UINT64( SbxUINT64 *p ) const
72 if( bIsBig ) {
73 if( bIsNeg || nLen > 4 )
74 return sal_False;
76 p->nLow = ((sal_uInt32)nNum[1] << 16) | (sal_uInt32)nNum[0];
77 p->nHigh = ((sal_uInt32)nNum[3] << 16) | (sal_uInt32)nNum[2];
79 else {
80 if( nVal < 0 )
81 return sal_False;
83 p->Set( (sal_uInt32)nVal );
86 return sal_True;
89 BigInt::BigInt( const SbxUINT64 &r )
91 BigInt a10000 = 0x10000;
93 *this = BigInt(r.nHigh);
94 if( r.nHigh )
95 *this *= a10000;
96 *this += (sal_uInt16)(r.nLow >> 16);
97 *this *= a10000;
98 *this += (sal_uInt16)r.nLow;
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */