xref: /trunk/main/basic/source/sbx/sbxdec.hxx (revision 234bd5c5)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 
25 #ifndef __SBX_SBX_DEC_HXX
26 #define __SBX_SBX_DEC_HXX
27 
28 #ifdef WIN32
29 
30 #undef WB_LEFT
31 #undef WB_RIGHT
32 #include <tools/prewin.h>
33 }	// close extern "C" {
34 
35 #ifndef __MINGW32__
36 #include <comutil.h>
37 #endif
38 #include <oleauto.h>
39 
40 extern "C" {	// reopen extern "C" {
41 #include <tools/postwin.h>
42 
43 #endif
44 #endif
45 #include <basic/sbx.hxx>
46 
47 #include <com/sun/star/bridge/oleautomation/Decimal.hpp>
48 
49 
50 // Decimal support
51 // Implementation only for windows
52 
53 class SbxDecimal
54 {
55 	friend void releaseDecimalPtr( SbxDecimal*& rpDecimal );
56 
57 #ifdef WIN32
58 	DECIMAL		maDec;
59 #endif
60 	sal_Int32		mnRefCount;
61 
62 public:
63 	SbxDecimal( void );
64 	SbxDecimal( const SbxDecimal& rDec );
65 	SbxDecimal( const com::sun::star::bridge::oleautomation::Decimal& rAutomationDec );
66 
67 	~SbxDecimal();
68 
69 	void addRef( void )
70 		{ mnRefCount++; }
71 
72 	void fillAutomationDecimal( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec );
73 
74 	void setChar( sal_Unicode val );
75 	void setByte( sal_uInt8 val );
76 	void setShort( sal_Int16 val );
77 	void setLong( sal_Int32 val );
78 	void setUShort( sal_uInt16 val );
79 	void setULong( sal_uInt32 val );
80 	bool setSingle( float val );
81 	bool setDouble( double val );
82 	void setInt( int val );
83 	void setUInt( unsigned int val );
84 	bool setString( ::rtl::OUString* pOUString );
85 	void setDecimal( SbxDecimal* pDecimal )
86 	{
87 #ifdef WIN32
88 		if( pDecimal )
89 			maDec = pDecimal->maDec;
90 #else
91         (void)pDecimal;
92 #endif
93 	}
94 
95 	bool getChar( sal_Unicode& rVal );
96 	bool getByte( sal_uInt8& rVal );
97 	bool getShort( sal_Int16& rVal );
98 	bool getLong( sal_Int32& rVal );
99 	bool getUShort( sal_uInt16& rVal );
100 	bool getULong( sal_uInt32& rVal );
101 	bool getSingle( float& rVal );
102 	bool getDouble( double& rVal );
103 	bool getInt( int& rVal );
104 	bool getUInt( unsigned int& rVal );
105 	bool getString( ::rtl::OUString& rString );
106 
107 	bool operator -= ( const SbxDecimal &r );
108 	bool operator += ( const SbxDecimal &r );
109 	bool operator /= ( const SbxDecimal &r );
110 	bool operator *= ( const SbxDecimal &r );
111 	bool neg( void );
112 
113 	bool isZero( void );
114 
115 	enum CmpResult { LT, EQ, GT };
116 	friend CmpResult compare( const SbxDecimal &rLeft, const SbxDecimal &rRight );
117 };
118 
119