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 #ifndef _CONNECTIVITY_ADO_AOLEVARIANT_HXX_
28 #define _CONNECTIVITY_ADO_AOLEVARIANT_HXX_
29 
30 #include <sal/types.h>
31 #ifdef __MINGW32__
32 #include <windows.h>
33 #endif
34 #include <rtl/ustring.hxx>
35 #include <com/sun/star/uno/Sequence.hxx>
36 
37 #include "ado_pre_sys_include.h"
38 #include <oaidl.h>
39 #include "ado_post_sys_include.h"
40 
41 namespace com
42 {
43 	namespace sun
44 	{
45 		namespace star
46 		{
47 			namespace util
48 			{
49 				struct Date;
50 				struct Time;
51 				struct DateTime;
52 			}
53 		}
54 	}
55 }
56 namespace connectivity
57 {
58 	namespace ado
59 	{
60 		class OLEString
61 		{
62 			BSTR m_sStr;
63 		public:
64 			OLEString();
65 			OLEString(const BSTR& _sBStr);
66 			OLEString(const ::rtl::OUString& _sBStr);
67 			OLEString(const OLEString& _rRh)
68 			{
69 				OLEString::operator=(_rRh);
70 			}
71 			~OLEString();
72 			OLEString& operator=(const ::rtl::OUString& _rSrc);
73 			OLEString& operator=(const BSTR& _rSrc);
74 			OLEString& operator=(const OLEString& _rSrc);
75 			operator ::rtl::OUString() const;
76 			operator BSTR() const;
77 			BSTR* operator &();
78 			sal_Int32 length() const;
79 		};
80 
81 		class OLEVariant	:	public ::tagVARIANT
82 		{
83 		public:
84 			OLEVariant();
85 			OLEVariant(const VARIANT& varSrc);
86 			OLEVariant(const OLEVariant& varSrc)	;
87 			OLEVariant(sal_Bool x)	;
88 			OLEVariant(sal_Int8 n)	;
89 			OLEVariant(sal_Int16 n)	;
90 			OLEVariant(sal_Int32 n)	;
91 			OLEVariant(sal_Int64 x)	;
92 
93 			OLEVariant(const rtl::OUString& us)	;
94 			~OLEVariant()					;
95 			OLEVariant(const ::com::sun::star::util::Date& x );
96 			OLEVariant(const ::com::sun::star::util::Time& x );
97 			OLEVariant(const ::com::sun::star::util::DateTime& x );
98 			OLEVariant(const float &x);
99 			OLEVariant(const double &x);
100 			OLEVariant(IDispatch* pDispInterface);
101 			OLEVariant(const ::com::sun::star::uno::Sequence< sal_Int8 >& x);
102 			OLEVariant& operator=(const OLEVariant& varSrc);
103 			// Assign a const VARIANT& (::VariantCopy handles everything)
104 			//
105 			OLEVariant& operator=(const tagVARIANT& varSrc);
106 			// Assign a const VARIANT* (::VariantCopy handles everything)
107 			//
108 			OLEVariant& operator=(const VARIANT* pSrc);
109 			void setByte(sal_uInt8 n)				;
110 			void setInt16(sal_Int16 n)				;
111 			void setInt32(sal_Int32 n)				;
112 			void setFloat(float f)					;
113 			void setDouble(double d)				;
114 			void setDate(DATE d)					;
115 			void setChar(unsigned char a)			;
116 			void setCurrency(double aCur)			;
117 			void setBool(sal_Bool b)				;
118 			void setString(const rtl::OUString& us)	;
119 			void setNoArg()							;
120 
121 			void setIDispatch(IDispatch* pDispInterface);
122 			void setNull()	 ;
123 			void setEmpty()	 ;
124 
125 			void setUI1SAFEARRAYPtr(SAFEARRAY* pSafeAr);
126 			void setArray(SAFEARRAY* pSafeArray, VARTYPE vtType);
127 			sal_Bool isNull() const  ;
128 			sal_Bool isEmpty() const ;
129 
130 			VARTYPE getType() const ;
131 			void ChangeType(VARTYPE vartype, const OLEVariant* pSrc);
132 
133 
134 			operator ::rtl::OUString() const;
135 
136 			operator sal_Bool()		const {	return getBool();	}
137 			operator sal_Int8()		const {	return getInt8();	}
138 			operator sal_Int16()	const {	return getInt16();	}
139 			operator sal_Int32() 	const {	return getInt32();	}
140 			operator float()		const {	return getFloat();	}
141 			operator double()		const {	return getDouble();	}
142 
143 			operator ::com::sun::star::uno::Sequence< sal_Int8 >() const;
144 			operator ::com::sun::star::util::Date() const ;
145 			operator ::com::sun::star::util::Time()	const ;
146 			operator ::com::sun::star::util::DateTime()const ;
147 			::rtl::OUString getString()		const;
148 			sal_Bool		getBool()		const;
149 			IUnknown*		getIUnknown()	const;
150 			IDispatch*		getIDispatch()	const;
151 			sal_uInt8		getByte()		const;
152 			sal_Int16		getInt16()		const;
153 			sal_Int8		getInt8()		const;
154 			sal_Int32		getInt32()		const;
155 			sal_uInt32		getUInt32()		const;
156 			float			getFloat()		const;
157 			double			getDouble()		const;
158 			double			getDate()		const;
159 			CY				getCurrency()	const;
160 			SAFEARRAY*		getUI1SAFEARRAYPtr() const;
161             ::com::sun::star::uno::Any makeAny() const;
162 
163 			static VARIANT_BOOL VariantBool(sal_Bool bEinBoolean);
164 
165 		private:
166 			void CHS();
167 
168 			void set(double n);
169 
170 		};
171 	}
172 }
173 
174 #endif // _CONNECTIVITY_ADO_AOLEVARIANT_HXX_
175 
176