summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2005-04-13 08:21:14 +0000
committerOliver Bolte <obo@openoffice.org>2005-04-13 08:21:14 +0000
commit5d2efcf037f81495caa993dc4635e4f17ebadd4c (patch)
tree1e7b78c7d52267d56ae78ae7f14aa2aee4908194 /basic
parent82012f7b91058d0e19b04e59d41f9935f0bd7ea4 (diff)
INTEGRATION: CWS visibility03 (1.1.2); FILE ADDED
2005/03/24 18:04:25 mhu 1.1.2.1: #i45006# Moved from svtools/source/sbx/
Diffstat (limited to 'basic')
-rw-r--r--basic/source/sbx/sbxcoll.cxx334
-rw-r--r--basic/source/sbx/sbxconv.hxx179
-rw-r--r--basic/source/sbx/sbxcurr.cxx431
3 files changed, 944 insertions, 0 deletions
diff --git a/basic/source/sbx/sbxcoll.cxx b/basic/source/sbx/sbxcoll.cxx
new file mode 100644
index 000000000000..cca6c670d4ce
--- /dev/null
+++ b/basic/source/sbx/sbxcoll.cxx
@@ -0,0 +1,334 @@
+/*************************************************************************
+ *
+ * $RCSfile: sbxcoll.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2005-04-13 09:20:44 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#ifndef _STREAM_HXX //autogen
+#include <tools/stream.hxx>
+#endif
+
+#include "sbx.hxx"
+#include "sbxres.hxx"
+
+TYPEINIT1(SbxCollection,SbxObject)
+TYPEINIT1(SbxStdCollection,SbxCollection)
+
+static const char* pCount;
+static const char* pAdd;
+static const char* pItem;
+static const char* pRemove;
+static USHORT nCountHash = 0, nAddHash, nItemHash, nRemoveHash;
+
+/////////////////////////////////////////////////////////////////////////
+
+SbxCollection::SbxCollection( const XubString& rClass )
+ : SbxObject( rClass )
+{
+ if( !nCountHash )
+ {
+ pCount = GetSbxRes( STRING_COUNTPROP );
+ pAdd = GetSbxRes( STRING_ADDMETH );
+ pItem = GetSbxRes( STRING_ITEMMETH );
+ pRemove = GetSbxRes( STRING_REMOVEMETH );
+ nCountHash = MakeHashCode( String::CreateFromAscii( pCount ) );
+ nAddHash = MakeHashCode( String::CreateFromAscii( pAdd ) );
+ nItemHash = MakeHashCode( String::CreateFromAscii( pItem ) );
+ nRemoveHash = MakeHashCode( String::CreateFromAscii( pRemove ) );
+ }
+ Initialize();
+ // Fuer Zugriffe auf sich selbst
+ StartListening( GetBroadcaster(), TRUE );
+}
+
+SbxCollection::SbxCollection( const SbxCollection& rColl )
+ : SbxObject( rColl )
+{}
+
+SbxCollection& SbxCollection::operator=( const SbxCollection& r )
+{
+ if( &r != this )
+ SbxObject::operator=( r );
+ return *this;
+}
+
+SbxCollection::~SbxCollection()
+{}
+
+void SbxCollection::Clear()
+{
+ SbxObject::Clear();
+ Initialize();
+}
+
+void SbxCollection::Initialize()
+{
+ SetType( SbxOBJECT );
+ SetFlag( SBX_FIXED );
+ ResetFlag( SBX_WRITE );
+ SbxVariable* p;
+ p = Make( String::CreateFromAscii( pCount ), SbxCLASS_PROPERTY, SbxINTEGER );
+ p->ResetFlag( SBX_WRITE );
+ p->SetFlag( SBX_DONTSTORE );
+ p = Make( String::CreateFromAscii( pAdd ), SbxCLASS_METHOD, SbxEMPTY );
+ p->SetFlag( SBX_DONTSTORE );
+ p = Make( String::CreateFromAscii( pItem ), SbxCLASS_METHOD, SbxOBJECT );
+ p->SetFlag( SBX_DONTSTORE );
+ p = Make( String::CreateFromAscii( pRemove ), SbxCLASS_METHOD, SbxEMPTY );
+ p->SetFlag( SBX_DONTSTORE );
+}
+
+SbxVariable* SbxCollection::FindUserData( UINT32 nData )
+{
+ if( GetParameters() )
+ {
+ SbxObject* pObj = (SbxObject*) GetObject();
+ return pObj ? pObj->FindUserData( nData ) : NULL;
+ }
+ else
+ return SbxObject::FindUserData( nData );
+}
+
+SbxVariable* SbxCollection::Find( const XubString& rName, SbxClassType t )
+{
+ if( GetParameters() )
+ {
+ SbxObject* pObj = (SbxObject*) GetObject();
+ return pObj ? pObj->Find( rName, t ) : NULL;
+ }
+ else
+ return SbxObject::Find( rName, t );
+}
+
+void SbxCollection::SFX_NOTIFY( SfxBroadcaster& rCst, const TypeId& rId1,
+ const SfxHint& rHint, const TypeId& rId2 )
+{
+ const SbxHint* p = PTR_CAST(SbxHint,&rHint);
+ if( p )
+ {
+ ULONG nId = p->GetId();
+ BOOL bRead = BOOL( nId == SBX_HINT_DATAWANTED );
+ BOOL bWrite = BOOL( nId == SBX_HINT_DATACHANGED );
+ SbxVariable* pVar = p->GetVar();
+ SbxArray* pArg = pVar->GetParameters();
+ if( bRead || bWrite )
+ {
+ XubString aVarName( pVar->GetName() );
+ if( pVar == this )
+ CollItem( pArg );
+ else if( pVar->GetHashCode() == nCountHash
+ && aVarName.EqualsIgnoreCaseAscii( pCount ) )
+ pVar->PutLong( pObjs->Count() );
+ else if( pVar->GetHashCode() == nAddHash
+ && aVarName.EqualsIgnoreCaseAscii( pAdd ) )
+ CollAdd( pArg );
+ else if( pVar->GetHashCode() == nItemHash
+ && aVarName.EqualsIgnoreCaseAscii( pItem ) )
+ CollItem( pArg );
+ else if( pVar->GetHashCode() == nRemoveHash
+ && aVarName.EqualsIgnoreCaseAscii( pRemove ) )
+ CollRemove( pArg );
+ else
+ SbxObject::SFX_NOTIFY( rCst, rId1, rHint, rId2 );
+ return;
+ }
+ }
+ SbxObject::SFX_NOTIFY( rCst, rId1, rHint, rId2 );
+}
+
+// Default: Argument ist Objekt
+
+void SbxCollection::CollAdd( SbxArray* pPar )
+{
+ if( pPar->Count() != 2 )
+ SetError( SbxERR_WRONG_ARGS );
+ else
+ {
+ SbxBase* pObj = pPar->Get( 1 )->GetObject();
+ if( !pObj || !( pObj->ISA(SbxObject) ) )
+ SetError( SbxERR_NOTIMP );
+ else
+ Insert( (SbxObject*) pObj );
+ }
+}
+
+// Default: Index ab 1 oder der Objektname
+
+void SbxCollection::CollItem( SbxArray* pPar )
+{
+ if( pPar->Count() != 2 )
+ SetError( SbxERR_WRONG_ARGS );
+ else
+ {
+ SbxVariable* pRes = NULL;
+ SbxVariable* p = pPar->Get( 1 );
+ if( p->GetType() == SbxSTRING )
+ pRes = Find( p->GetString(), SbxCLASS_OBJECT );
+ else
+ {
+ short n = p->GetInteger();
+ if( n >= 1 && n <= (short) pObjs->Count() )
+ pRes = pObjs->Get( (USHORT) n - 1 );
+ }
+ if( !pRes )
+ SetError( SbxERR_BAD_INDEX );
+ pPar->Get( 0 )->PutObject( pRes );
+ }
+}
+
+// Default: Index ab 1
+
+void SbxCollection::CollRemove( SbxArray* pPar )
+{
+ if( pPar->Count() != 2 )
+ SetError( SbxERR_WRONG_ARGS );
+ else
+ {
+ short n = pPar->Get( 1 )->GetInteger();
+ if( n < 1 || n > (short) pObjs->Count() )
+ SetError( SbxERR_BAD_INDEX );
+ else
+ Remove( pObjs->Get( (USHORT) n - 1 ) );
+ }
+}
+
+BOOL SbxCollection::LoadData( SvStream& rStrm, USHORT nVer )
+{
+ BOOL bRes = SbxObject::LoadData( rStrm, nVer );
+ Initialize();
+ return bRes;
+}
+
+/////////////////////////////////////////////////////////////////////////
+
+SbxStdCollection::SbxStdCollection
+ ( const XubString& rClass, const XubString& rElem, BOOL b )
+ : SbxCollection( rClass ), aElemClass( rElem ),
+ bAddRemoveOk( b )
+{}
+
+SbxStdCollection::SbxStdCollection( const SbxStdCollection& r )
+ : SbxCollection( r ), aElemClass( r.aElemClass ),
+ bAddRemoveOk( r.bAddRemoveOk )
+{}
+
+SbxStdCollection& SbxStdCollection::operator=( const SbxStdCollection& r )
+{
+ if( &r != this )
+ {
+ if( !r.aElemClass.EqualsIgnoreCaseAscii( aElemClass ) )
+ SetError( SbxERR_CONVERSION );
+ else
+ SbxCollection::operator=( r );
+ }
+ return *this;
+}
+
+SbxStdCollection::~SbxStdCollection()
+{}
+
+// Default: Fehler, wenn falsches Objekt
+
+void SbxStdCollection::Insert( SbxVariable* p )
+{
+ SbxObject* pObj = PTR_CAST(SbxObject,p);
+ if( pObj && !pObj->IsClass( aElemClass ) )
+ SetError( SbxERR_BAD_ACTION );
+ else
+ SbxCollection::Insert( p );
+}
+
+void SbxStdCollection::CollAdd( SbxArray* pPar )
+{
+ if( !bAddRemoveOk )
+ SetError( SbxERR_BAD_ACTION );
+ else
+ SbxCollection::CollAdd( pPar );
+}
+
+void SbxStdCollection::CollRemove( SbxArray* pPar )
+{
+ if( !bAddRemoveOk )
+ SetError( SbxERR_BAD_ACTION );
+ else
+ SbxCollection::CollRemove( pPar );
+}
+
+BOOL SbxStdCollection::LoadData( SvStream& rStrm, USHORT nVer )
+{
+ BOOL bRes = SbxCollection::LoadData( rStrm, nVer );
+ if( bRes )
+ {
+ rStrm.ReadByteString( aElemClass, RTL_TEXTENCODING_ASCII_US );
+ rStrm >> bAddRemoveOk;
+ }
+ return bRes;
+}
+
+BOOL SbxStdCollection::StoreData( SvStream& rStrm ) const
+{
+ BOOL bRes = SbxCollection::StoreData( rStrm );
+ if( bRes )
+ {
+ rStrm.WriteByteString( aElemClass, RTL_TEXTENCODING_ASCII_US );
+ rStrm << bAddRemoveOk;
+ }
+ return bRes;
+}
+
diff --git a/basic/source/sbx/sbxconv.hxx b/basic/source/sbx/sbxconv.hxx
new file mode 100644
index 000000000000..ffff5b0b0208
--- /dev/null
+++ b/basic/source/sbx/sbxconv.hxx
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * $RCSfile: sbxconv.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2005-04-13 09:21:01 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _SBXCONV_HXX
+#define _SBXCONV_HXX
+
+#include "sbxdec.hxx"
+
+// SBXSCAN.CXX
+extern void ImpCvtNum( double nNum, short nPrec, String& rRes, BOOL bCoreString=FALSE );
+extern SbxError ImpScan
+ ( const String& rSrc, double& nVal, SbxDataType& rType, USHORT* pLen,
+ BOOL bAllowIntntl=FALSE, BOOL bOnlyIntntl=FALSE );
+
+// mit erweiterter Auswertung (International, "TRUE"/"FALSE")
+extern BOOL ImpConvStringExt( String& rSrc, SbxDataType eTargetType );
+
+// SBXINT.CXX
+
+double ImpRound( double );
+INT16 ImpGetInteger( const SbxValues* );
+void ImpPutInteger( SbxValues*, INT16 );
+sal_Int64 ImpGetInt64( const SbxValues* );
+void ImpPutInt64( SbxValues*, sal_Int64 );
+sal_uInt64 ImpGetUInt64( const SbxValues* );
+void ImpPutUInt64( SbxValues*, sal_uInt64 );
+
+sal_Int64 ImpDoubleToSalInt64( double d );
+sal_uInt64 ImpDoubleToSalUInt64( double d );
+double ImpSalUInt64ToDouble( sal_uInt64 n );
+
+// SBXLNG.CXX
+
+INT32 ImpGetLong( const SbxValues* );
+void ImpPutLong( SbxValues*, INT32 );
+
+// SBXSNG.CXX
+
+float ImpGetSingle( const SbxValues* );
+void ImpPutSingle( SbxValues*, float );
+
+// SBXDBL.CXX
+
+double ImpGetDouble( const SbxValues* );
+void ImpPutDouble( SbxValues*, double, BOOL bCoreString=FALSE );
+
+#if FALSE
+// SBX64.CXX
+
+SbxINT64 ImpGetINT64( const SbxValues* );
+void ImpPutINT64( SbxValues*, const SbxINT64& );
+SbxUINT64 ImpGetUINT64( const SbxValues* );
+void ImpPutUINT64( SbxValues*, const SbxUINT64& );
+#endif
+
+// SBXCURR.CXX
+
+SbxUINT64 ImpDoubleToUINT64( double );
+double ImpUINT64ToDouble( const SbxUINT64& );
+SbxINT64 ImpDoubleToINT64( double );
+double ImpINT64ToDouble( const SbxINT64& );
+
+#if TRUE
+INT32 ImpGetCurrLong( const SbxValues* );
+void ImpPutCurrLong( SbxValues*, INT32 );
+INT32 ImpDoubleToCurrLong( double );
+double ImpCurrLongToDouble( INT32 );
+#endif
+
+SbxINT64 ImpGetCurrency( const SbxValues* );
+void ImpPutCurrency( SbxValues*, const SbxINT64& );
+inline
+SbxINT64 ImpDoubleToCurrency( double d )
+ { return ImpDoubleToINT64( d * CURRENCY_FACTOR ); }
+inline
+double ImpCurrencyToDouble( const SbxINT64 &r )
+ { return ImpINT64ToDouble( r ) / CURRENCY_FACTOR; }
+
+
+// SBXDEC.CXX
+
+SbxDecimal* ImpCreateDecimal( SbxValues* p );
+SbxDecimal* ImpGetDecimal( const SbxValues* p );
+void ImpPutDecimal( SbxValues* p, SbxDecimal* pDec );
+
+// SBXDATE.CXX
+
+double ImpGetDate( const SbxValues* );
+void ImpPutDate( SbxValues*, double );
+
+// SBXSTR.CXX
+
+String ImpGetString( const SbxValues* );
+String ImpGetCoreString( const SbxValues* );
+void ImpPutString( SbxValues*, const String* );
+
+// SBXCHAR.CXX
+
+sal_Unicode ImpGetChar( const SbxValues* );
+void ImpPutChar( SbxValues*, sal_Unicode );
+
+// SBXBYTE.CXX
+BYTE ImpGetByte( const SbxValues* );
+void ImpPutByte( SbxValues*, BYTE );
+
+// SBXUINT.CXX
+
+UINT16 ImpGetUShort( const SbxValues* );
+void ImpPutUShort( SbxValues*, UINT16 );
+
+// SBXULNG.CXX
+
+UINT32 ImpGetULong( const SbxValues* );
+void ImpPutULong( SbxValues*, UINT32 );
+
+// SBXBOOL.CXX
+
+INT16 ImpGetBool( const SbxValues* );
+void ImpPutBool( SbxValues*, INT16 );
+
+#endif
diff --git a/basic/source/sbx/sbxcurr.cxx b/basic/source/sbx/sbxcurr.cxx
new file mode 100644
index 000000000000..5863bf69a564
--- /dev/null
+++ b/basic/source/sbx/sbxcurr.cxx
@@ -0,0 +1,431 @@
+/*************************************************************************
+ *
+ * $RCSfile: sbxcurr.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2005-04-13 09:21:14 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <sbx.hxx>
+
+#ifndef _ERRCODE_HXX //autogen
+#include <tools/errcode.hxx>
+#endif
+
+#define _TLBIGINT_INT64
+#ifndef _BIGINT_HXX //autogen
+#include <tools/bigint.hxx>
+#endif
+
+#include "sbxvar.hxx"
+#include "sbxconv.hxx"
+
+static String ImpCurrencyToString( const SbxINT64& );
+static SbxINT64 ImpStringToCurrency( const String& );
+
+SbxINT64 ImpGetCurrency( const SbxValues* p )
+{
+ SbxValues aTmp;
+ SbxINT64 nRes;
+start:
+ switch( p->eType )
+ {
+ case SbxNULL:
+ SbxBase::SetError( SbxERR_CONVERSION );
+ case SbxEMPTY:
+ nRes.SetNull(); break;
+ case SbxCHAR:
+ nRes = ImpDoubleToCurrency( (double)p->nChar ); break;
+ case SbxBYTE:
+ nRes = ImpDoubleToCurrency( (double)p->nByte ); break;
+ case SbxINTEGER:
+ case SbxBOOL:
+ nRes = ImpDoubleToCurrency( (double)p->nInteger ); break;
+ case SbxERROR:
+ case SbxUSHORT:
+ nRes = ImpDoubleToCurrency( (double)p->nUShort ); break;
+ case SbxCURRENCY:
+ nRes = p->nLong64; break;
+ case SbxLONG:
+ nRes = ImpDoubleToCurrency( (double)p->nLong );
+ break;
+ case SbxULONG:
+ nRes = ImpDoubleToCurrency( (double)p->nULong );
+ break;
+ case SbxSALINT64:
+ nRes = ImpDoubleToCurrency( (double)p->nInt64 );
+ break;
+ case SbxSALUINT64:
+ nRes = ImpDoubleToCurrency( ImpSalUInt64ToDouble( p->uInt64 ) );
+ break;
+ case SbxSINGLE:
+ if( p->nSingle > SbxMAXCURR )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMax();
+ }
+ else if( p->nSingle < SbxMINCURR )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMin();
+ }
+ else
+ nRes = ImpDoubleToCurrency( (double)p->nSingle );
+ break;
+ case SbxDATE:
+ case SbxDOUBLE:
+ if( p->nDouble > SbxMAXCURR )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMax();
+ }
+ else if( p->nDouble < SbxMINCURR )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMin();
+ }
+ else
+ nRes = ImpDoubleToCurrency( p->nDouble );
+ break;
+ case SbxDECIMAL:
+ case SbxBYREF | SbxDECIMAL:
+ {
+ double d = 0.0;
+ if( p->pDecimal )
+ p->pDecimal->getDouble( d );
+ if( d > SbxMAXCURR )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMax();
+ }
+ else if( d < SbxMINCURR )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMin();
+ }
+ else
+ nRes = ImpDoubleToCurrency( d );
+ break;
+ }
+ case SbxBYREF | SbxSTRING:
+ case SbxSTRING:
+ case SbxLPSTR:
+ if( !p->pString )
+ nRes.SetNull();
+ else
+ nRes = ImpStringToCurrency( *p->pString );
+ break;
+ case SbxOBJECT:
+ {
+ SbxValue* pVal = PTR_CAST(SbxValue,p->pObj);
+ if( pVal )
+ nRes = pVal->GetCurrency();
+ else
+ {
+ SbxBase::SetError( SbxERR_NO_OBJECT ); nRes.SetNull();
+ }
+ break;
+ }
+
+ case SbxBYREF | SbxCHAR:
+ nRes = ImpDoubleToCurrency( (double)*p->pChar ); break;
+ case SbxBYREF | SbxBYTE:
+ nRes = ImpDoubleToCurrency( (double)*p->pByte ); break;
+ case SbxBYREF | SbxINTEGER:
+ case SbxBYREF | SbxBOOL:
+ nRes = ImpDoubleToCurrency( (double)*p->pInteger ); break;
+ case SbxBYREF | SbxERROR:
+ case SbxBYREF | SbxUSHORT:
+ nRes = ImpDoubleToCurrency( (double)*p->pUShort ); break;
+ case SbxBYREF | SbxCURRENCY:
+ nRes = *p->pLong64; break;
+
+ // ab hier muss getestet werden
+ case SbxBYREF | SbxLONG:
+ aTmp.nLong = *p->pLong; goto ref;
+ case SbxBYREF | SbxULONG:
+ aTmp.nULong = *p->pULong; goto ref;
+ case SbxBYREF | SbxSINGLE:
+ aTmp.nSingle = *p->pSingle; goto ref;
+ case SbxBYREF | SbxDATE:
+ case SbxBYREF | SbxDOUBLE:
+ aTmp.nDouble = *p->pDouble; goto ref;
+ case SbxBYREF | SbxSALINT64:
+ aTmp.nInt64 = *p->pnInt64; goto ref;
+ case SbxBYREF | SbxSALUINT64:
+ aTmp.uInt64 = *p->puInt64; goto ref;
+ ref:
+ aTmp.eType = SbxDataType( p->eType & 0x0FFF );
+ p = &aTmp; goto start;
+
+ default:
+ SbxBase::SetError( SbxERR_CONVERSION ); nRes.SetNull();
+ }
+ return nRes;
+}
+
+void ImpPutCurrency( SbxValues* p, const SbxINT64 &r )
+{
+ double dVal = ImpCurrencyToDouble( r );
+ SbxValues aTmp;
+start:
+ switch( p->eType )
+ {
+ // Hier sind Tests notwendig
+ case SbxCHAR:
+ aTmp.pChar = &p->nChar; goto direct;
+ case SbxBYTE:
+ aTmp.pByte = &p->nByte; goto direct;
+ case SbxINTEGER:
+ case SbxBOOL:
+ aTmp.pInteger = &p->nInteger; goto direct;
+ case SbxLONG:
+ aTmp.pLong = &p->nLong; goto direct;
+ case SbxULONG:
+ aTmp.pULong = &p->nULong; goto direct;
+ case SbxERROR:
+ case SbxUSHORT:
+ aTmp.pUShort = &p->nUShort; goto direct;
+ direct:
+ aTmp.eType = SbxDataType( p->eType | SbxBYREF );
+ p = &aTmp; goto start;
+
+ // ab hier nicht mehr
+ case SbxSINGLE:
+ p->nSingle = (float)dVal; break;
+ case SbxDATE:
+ case SbxDOUBLE:
+ p->nDouble = dVal; break;
+ case SbxSALINT64:
+ p->nInt64 = ImpDoubleToSalInt64( dVal ); break;
+ case SbxSALUINT64:
+ p->uInt64 = ImpDoubleToSalUInt64( dVal ); break;
+ case SbxCURRENCY:
+ p->nLong64 = r; break;
+ case SbxDECIMAL:
+ case SbxBYREF | SbxDECIMAL:
+ {
+ SbxDecimal* pDec = ImpCreateDecimal( p );
+ if( !pDec->setDouble( dVal ) )
+ SbxBase::SetError( SbxERR_OVERFLOW );
+ break;
+ }
+ case SbxBYREF | SbxSTRING:
+ case SbxSTRING:
+ case SbxLPSTR:
+ if( !p->pString )
+ p->pString = new XubString;
+
+ *p->pString = ImpCurrencyToString( r );
+ break;
+ case SbxOBJECT:
+ {
+ SbxValue* pVal = PTR_CAST(SbxValue,p->pObj);
+ if( pVal )
+ pVal->PutCurrency( r );
+ else
+ SbxBase::SetError( SbxERR_NO_OBJECT );
+ break;
+ }
+ case SbxBYREF | SbxCHAR:
+ if( dVal > SbxMAXCHAR )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXCHAR;
+ }
+ else if( dVal < SbxMINCHAR )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMINCHAR;
+ }
+ *p->pChar = (xub_Unicode) dVal; break;
+ case SbxBYREF | SbxBYTE:
+ if( dVal > SbxMAXBYTE )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXBYTE;
+ }
+ else if( dVal < 0 )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); dVal = 0;
+ }
+ *p->pByte = (BYTE) dVal; break;
+ case SbxBYREF | SbxINTEGER:
+ case SbxBYREF | SbxBOOL:
+ if( dVal > SbxMAXINT )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXINT;
+ }
+ else if( dVal < SbxMININT )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMININT;
+ }
+ *p->pInteger = (INT16) dVal; break;
+ case SbxBYREF | SbxERROR:
+ case SbxBYREF | SbxUSHORT:
+ if( dVal > SbxMAXUINT )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXUINT;
+ }
+ else if( dVal < 0 )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); dVal = 0;
+ }
+ *p->pUShort = (UINT16) dVal; break;
+ case SbxBYREF | SbxLONG:
+ if( dVal > SbxMAXLNG )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXLNG;
+ }
+ else if( dVal < SbxMINLNG )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMINLNG;
+ }
+ *p->pLong = (INT32) dVal; break;
+ case SbxBYREF | SbxULONG:
+ if( dVal > SbxMAXULNG )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXULNG;
+ }
+ else if( dVal < 0 )
+ {
+ SbxBase::SetError( SbxERR_OVERFLOW ); dVal = 0;
+ }
+ *p->pULong = (UINT32) dVal; break;
+ case SbxBYREF | SbxSALINT64:
+ *p->pnInt64 = ImpDoubleToSalInt64( dVal ); break;
+ case SbxBYREF | SbxSALUINT64:
+ *p->puInt64 = ImpDoubleToSalUInt64( dVal ); break;
+ case SbxBYREF | SbxSINGLE:
+ *p->pSingle = (float) dVal; break;
+ case SbxBYREF | SbxDATE:
+ case SbxBYREF | SbxDOUBLE:
+ *p->pDouble = (double) dVal; break;
+ case SbxBYREF | SbxCURRENCY:
+ *p->pLong64 = r; break;
+
+ default:
+ SbxBase::SetError( SbxERR_CONVERSION );
+ }
+}
+
+// Hilfs-Funktionen zur Wandlung
+
+static String ImpCurrencyToString( const SbxINT64 &r )
+{
+ BigInt a10000 = 10000;
+
+ //return GetpApp()->GetAppInternational().GetCurr( BigInt( r ), 4 );
+ BigInt aInt( r );
+ aInt.Abs();
+ BigInt aFrac = aInt;
+ aInt /= a10000;
+ aFrac %= a10000;
+ aFrac += a10000;
+
+ String aString;
+ if( r.nHigh < 0 )
+ aString = '-';
+ aString += aInt.GetString();
+ aString += '.';
+ aString += aFrac.GetString().GetBuffer()+1;
+ return aString;
+}
+
+static SbxINT64 ImpStringToCurrency( const String &r )
+{
+ int nDec = 4;
+ String aStr;
+ const sal_Unicode* p = r.GetBuffer();
+
+ if( *p == '-' )
+ aStr += *p++;
+
+ while( *p >= '0' && *p <= '9' ) {
+ aStr += *p++;
+ if( *p == ',' )
+ p++;
+ }
+
+ if( *p == '.' ) {
+ p++;
+ while( nDec && *p >= '0' && *p <= '9' ) {
+ aStr += *p++;
+ nDec--;
+ }
+ }
+ while( nDec ) {
+ aStr += '0';
+ nDec--;
+ }
+
+ BigInt aBig( aStr );
+ SbxINT64 nRes;
+ aBig.INT64( &nRes );
+ return nRes;
+}
+
+double ImpINT64ToDouble( const SbxINT64 &r )
+{ return (double)r.nHigh*(double)4294967296.0 + (double)r.nLow; }
+
+SbxINT64 ImpDoubleToINT64( double d )
+{
+ SbxINT64 nRes;
+ nRes.Set( d );
+ return nRes;
+}
+
+double ImpUINT64ToDouble( const SbxUINT64 &r )
+{ return (double)r.nHigh*(double)4294967296.0 + (double)r.nLow; }
+
+SbxUINT64 ImpDoubleToUINT64( double d )
+{
+ SbxUINT64 nRes;
+ nRes.Set( d );
+ return nRes;
+}
+