xref: /aoo41x/main/basic/source/sbx/sbxdec.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 
29 #ifndef __SBX_SBX_DEC_HXX
30 #define __SBX_SBX_DEC_HXX
31 
32 #ifdef WIN32
33 
34 #undef WB_LEFT
35 #undef WB_RIGHT
36 #include <tools/prewin.h>
37 }	// close extern "C" {
38 
39 #ifndef __MINGW32__
40 #include <comutil.h>
41 #endif
42 #include <oleauto.h>
43 
44 extern "C" {	// reopen extern "C" {
45 #include <tools/postwin.h>
46 
47 #endif
48 #endif
49 #include <basic/sbx.hxx>
50 
51 #include <com/sun/star/bridge/oleautomation/Decimal.hpp>
52 
53 
54 // Decimal support
55 // Implementation only for windows
56 
57 class SbxDecimal
58 {
59 	friend void releaseDecimalPtr( SbxDecimal*& rpDecimal );
60 
61 #ifdef WIN32
62 	DECIMAL		maDec;
63 #endif
64 	sal_Int32		mnRefCount;
65 
66 public:
67 	SbxDecimal( void );
68 	SbxDecimal( const SbxDecimal& rDec );
69 	SbxDecimal( const com::sun::star::bridge::oleautomation::Decimal& rAutomationDec );
70 
71 	~SbxDecimal();
72 
73 	void addRef( void )
74 		{ mnRefCount++; }
75 
76 	void fillAutomationDecimal( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec );
77 
78 	void setChar( sal_Unicode val );
79 	void setByte( sal_uInt8 val );
80 	void setShort( sal_Int16 val );
81 	void setLong( sal_Int32 val );
82 	void setUShort( sal_uInt16 val );
83 	void setULong( sal_uInt32 val );
84 	bool setSingle( float val );
85 	bool setDouble( double val );
86 	void setInt( int val );
87 	void setUInt( unsigned int val );
88 	bool setString( ::rtl::OUString* pOUString );
89 	void setDecimal( SbxDecimal* pDecimal )
90 	{
91 #ifdef WIN32
92 		if( pDecimal )
93 			maDec = pDecimal->maDec;
94 #else
95         (void)pDecimal;
96 #endif
97 	}
98 
99 	bool getChar( sal_Unicode& rVal );
100 	bool getByte( sal_uInt8& rVal );
101 	bool getShort( sal_Int16& rVal );
102 	bool getLong( sal_Int32& rVal );
103 	bool getUShort( sal_uInt16& rVal );
104 	bool getULong( sal_uInt32& rVal );
105 	bool getSingle( float& rVal );
106 	bool getDouble( double& rVal );
107 	bool getInt( int& rVal );
108 	bool getUInt( unsigned int& rVal );
109 	bool getString( ::rtl::OUString& rString );
110 
111 	bool operator -= ( const SbxDecimal &r );
112 	bool operator += ( const SbxDecimal &r );
113 	bool operator /= ( const SbxDecimal &r );
114 	bool operator *= ( const SbxDecimal &r );
115 	bool neg( void );
116 
117 	bool isZero( void );
118 
119 	enum CmpResult { LT, EQ, GT };
120 	friend CmpResult compare( const SbxDecimal &rLeft, const SbxDecimal &rRight );
121 };
122 
123