2005-04-13 08:20:02 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 11:10:02 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2005-04-13 08:20:02 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2005-04-13 08:20:02 +00:00
|
|
|
*
|
2008-04-11 11:10:02 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2005-04-13 08:20:02 +00:00
|
|
|
*
|
2008-04-11 11:10:02 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2005-04-13 08:20:02 +00:00
|
|
|
*
|
2008-04-11 11:10:02 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2005-04-13 08:20:02 +00:00
|
|
|
*
|
2008-04-11 11:10:02 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2005-04-13 08:20:02 +00:00
|
|
|
*
|
2008-04-11 11:10:02 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2005-04-13 08:20:02 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 09:08:09 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_basic.hxx"
|
2005-04-13 08:20:02 +00:00
|
|
|
#include <tools/errcode.hxx>
|
2007-06-27 13:32:17 +00:00
|
|
|
#include <basic/sbx.hxx>
|
2005-04-13 08:20:02 +00:00
|
|
|
#include "sbxconv.hxx"
|
|
|
|
#include "sbxres.hxx"
|
|
|
|
|
|
|
|
// AB 29.10.99 Unicode
|
|
|
|
#ifndef _USE_NO_NAMESPACE
|
|
|
|
using namespace rtl;
|
|
|
|
#endif
|
|
|
|
|
2006-10-12 13:32:10 +00:00
|
|
|
enum SbxBOOL ImpGetBool( const SbxValues* p )
|
2005-04-13 08:20:02 +00:00
|
|
|
{
|
2006-10-12 13:32:10 +00:00
|
|
|
enum SbxBOOL nRes;
|
2007-11-13 14:21:21 +00:00
|
|
|
switch( +p->eType )
|
2005-04-13 08:20:02 +00:00
|
|
|
{
|
|
|
|
case SbxNULL:
|
|
|
|
SbxBase::SetError( SbxERR_CONVERSION );
|
|
|
|
case SbxEMPTY:
|
|
|
|
nRes = SbxFALSE; break;
|
|
|
|
case SbxCHAR:
|
|
|
|
nRes = p->nChar ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxBYTE:
|
|
|
|
nRes = p->nByte ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxINTEGER:
|
|
|
|
case SbxBOOL:
|
|
|
|
nRes = p->nInteger ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxERROR:
|
|
|
|
case SbxUSHORT:
|
|
|
|
nRes = p->nUShort ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxLONG:
|
|
|
|
nRes = p->nLong ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxULONG:
|
|
|
|
nRes = p->nULong ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxSINGLE:
|
|
|
|
nRes = p->nSingle ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxDATE:
|
|
|
|
case SbxDOUBLE:
|
|
|
|
nRes = p->nDouble ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxDECIMAL:
|
|
|
|
case SbxBYREF | SbxDECIMAL:
|
|
|
|
{
|
|
|
|
double dVal = 0.0;
|
|
|
|
if( p->pDecimal )
|
|
|
|
p->pDecimal->getDouble( dVal );
|
|
|
|
nRes = dVal ? SbxTRUE : SbxFALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SbxSALINT64:
|
|
|
|
nRes = p->nInt64 ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxSALUINT64:
|
|
|
|
nRes = p->uInt64 ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxULONG64:
|
|
|
|
nRes = !!p->nULong64 ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxLONG64:
|
|
|
|
case SbxCURRENCY:
|
|
|
|
nRes = !!p->nLong64 ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxBYREF | SbxSTRING:
|
|
|
|
case SbxSTRING:
|
|
|
|
case SbxLPSTR:
|
|
|
|
nRes = SbxFALSE;
|
|
|
|
if( p->pString )
|
|
|
|
{
|
|
|
|
if( p->pString->EqualsIgnoreCaseAscii( SbxRes( STRING_TRUE ) ) )
|
|
|
|
nRes = SbxTRUE;
|
|
|
|
else if( !p->pString->EqualsIgnoreCaseAscii( SbxRes( STRING_FALSE ) ) )
|
|
|
|
{
|
|
|
|
// Jetzt kann es noch in eine Zahl konvertierbar sein
|
|
|
|
BOOL bError = TRUE;
|
|
|
|
double n;
|
|
|
|
SbxDataType t;
|
|
|
|
USHORT nLen = 0;
|
|
|
|
String s( *p->pString );
|
|
|
|
if( ImpScan( s, n, t, &nLen ) == SbxERR_OK )
|
|
|
|
{
|
|
|
|
if( nLen == s.Len() )
|
|
|
|
{
|
|
|
|
bError = FALSE;
|
|
|
|
if( n != 0.0 )
|
|
|
|
nRes = SbxTRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( bError )
|
|
|
|
SbxBase::SetError( SbxERR_CONVERSION );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SbxOBJECT:
|
|
|
|
{
|
|
|
|
SbxValue* pVal = PTR_CAST(SbxValue,p->pObj);
|
|
|
|
if( pVal )
|
2006-10-12 13:32:10 +00:00
|
|
|
nRes = pVal->GetBool() ? SbxTRUE : SbxFALSE;
|
2005-04-13 08:20:02 +00:00
|
|
|
else
|
|
|
|
{
|
2006-10-12 13:32:10 +00:00
|
|
|
SbxBase::SetError( SbxERR_NO_OBJECT ); nRes = SbxFALSE;
|
2005-04-13 08:20:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SbxBYREF | SbxCHAR:
|
|
|
|
nRes = *p->pChar ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxBYREF | SbxBYTE:
|
|
|
|
nRes = *p->pByte ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxBYREF | SbxINTEGER:
|
|
|
|
case SbxBYREF | SbxBOOL:
|
|
|
|
nRes = *p->pInteger ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxBYREF | SbxLONG:
|
|
|
|
nRes = *p->pLong ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxBYREF | SbxULONG:
|
|
|
|
nRes = *p->pULong ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxBYREF | SbxERROR:
|
|
|
|
case SbxBYREF | SbxUSHORT:
|
|
|
|
nRes = *p->pUShort ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxBYREF | SbxSINGLE:
|
|
|
|
nRes = ( *p->pSingle != 0 ) ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxBYREF | SbxDATE:
|
|
|
|
case SbxBYREF | SbxDOUBLE:
|
|
|
|
nRes = ( *p->pDouble != 0 ) ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxBYREF | SbxSALINT64:
|
|
|
|
nRes = ( *p->pnInt64 ) ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxBYREF | SbxSALUINT64:
|
|
|
|
nRes = ( *p->puInt64 ) ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxBYREF | SbxULONG64:
|
|
|
|
nRes = !!*p->pULong64 ? SbxTRUE : SbxFALSE; break;
|
|
|
|
case SbxBYREF | SbxLONG64:
|
|
|
|
case SbxBYREF | SbxCURRENCY:
|
|
|
|
nRes = !!*p->pLong64 ? SbxTRUE : SbxFALSE; break;
|
|
|
|
|
|
|
|
default:
|
2006-10-12 13:32:10 +00:00
|
|
|
SbxBase::SetError( SbxERR_CONVERSION ); nRes = SbxFALSE;
|
2005-04-13 08:20:02 +00:00
|
|
|
}
|
|
|
|
return nRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImpPutBool( SbxValues* p, INT16 n )
|
|
|
|
{
|
|
|
|
if( n )
|
|
|
|
n = SbxTRUE;
|
2007-11-13 14:21:21 +00:00
|
|
|
switch( +p->eType )
|
2005-04-13 08:20:02 +00:00
|
|
|
{
|
|
|
|
case SbxCHAR:
|
|
|
|
p->nChar = (xub_Unicode) n; break;
|
|
|
|
case SbxUINT:
|
|
|
|
p->nByte = (BYTE) n; break;
|
|
|
|
case SbxINTEGER:
|
|
|
|
case SbxBOOL:
|
|
|
|
p->nInteger = n; break;
|
|
|
|
case SbxLONG:
|
|
|
|
p->nLong = n; break;
|
|
|
|
case SbxULONG:
|
|
|
|
p->nULong = (UINT32) n; break;
|
|
|
|
case SbxERROR:
|
|
|
|
case SbxUSHORT:
|
|
|
|
p->nUShort = (UINT16) n; break;
|
|
|
|
case SbxSINGLE:
|
|
|
|
p->nSingle = n; break;
|
|
|
|
case SbxDATE:
|
|
|
|
case SbxDOUBLE:
|
|
|
|
p->nDouble = n; break;
|
|
|
|
case SbxSALINT64:
|
|
|
|
p->nInt64 = n; break;
|
|
|
|
case SbxSALUINT64:
|
|
|
|
p->uInt64 = n; break;
|
|
|
|
case SbxULONG64:
|
|
|
|
p->nULong64.Set( (UINT32)n ); break;
|
|
|
|
case SbxLONG64:
|
|
|
|
case SbxCURRENCY:
|
|
|
|
p->nLong64.Set( (INT32)n ); break;
|
|
|
|
case SbxDECIMAL:
|
|
|
|
case SbxBYREF | SbxDECIMAL:
|
|
|
|
ImpCreateDecimal( p )->setInt( (INT16)n );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SbxBYREF | SbxSTRING:
|
|
|
|
case SbxSTRING:
|
|
|
|
case SbxLPSTR:
|
|
|
|
if( !p->pString )
|
|
|
|
p->pString = new XubString;
|
|
|
|
*p->pString = SbxRes( n ? STRING_TRUE : STRING_FALSE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SbxOBJECT:
|
|
|
|
{
|
|
|
|
SbxValue* pVal = PTR_CAST(SbxValue,p->pObj);
|
|
|
|
if( pVal )
|
|
|
|
pVal->PutBool( BOOL( n != 0 ) );
|
|
|
|
else
|
|
|
|
SbxBase::SetError( SbxERR_NO_OBJECT );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SbxBYREF | SbxCHAR:
|
|
|
|
*p->pChar = (xub_Unicode) n; break;
|
|
|
|
case SbxBYREF | SbxBYTE:
|
|
|
|
*p->pByte = (BYTE) n; break;
|
|
|
|
case SbxBYREF | SbxINTEGER:
|
|
|
|
case SbxBYREF | SbxBOOL:
|
|
|
|
*p->pInteger = (INT16) n; break;
|
|
|
|
case SbxBYREF | SbxERROR:
|
|
|
|
case SbxBYREF | SbxUSHORT:
|
|
|
|
*p->pUShort = (UINT16) n; break;
|
|
|
|
case SbxBYREF | SbxLONG:
|
|
|
|
*p->pLong = n; break;
|
|
|
|
case SbxBYREF | SbxULONG:
|
|
|
|
*p->pULong = (UINT32) n; break;
|
|
|
|
case SbxBYREF | SbxSINGLE:
|
|
|
|
*p->pSingle = n; break;
|
|
|
|
case SbxBYREF | SbxDATE:
|
|
|
|
case SbxBYREF | SbxDOUBLE:
|
|
|
|
*p->pDouble = n; break;
|
|
|
|
case SbxBYREF | SbxSALINT64:
|
|
|
|
*p->pnInt64 = n; break;
|
|
|
|
case SbxBYREF | SbxSALUINT64:
|
|
|
|
*p->puInt64 = n; break;
|
|
|
|
case SbxBYREF | SbxULONG64:
|
|
|
|
p->pULong64->Set( (UINT32)n ); break;
|
|
|
|
case SbxBYREF | SbxLONG64:
|
|
|
|
case SbxBYREF | SbxCURRENCY:
|
|
|
|
p->pLong64->Set( (INT32)n ); break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
SbxBase::SetError( SbxERR_CONVERSION );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|