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 #ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_
29 #define _CONNECTIVITY_JAVA_TOOLS_HXX_
30 
31 #include <com/sun/star/beans/PropertyValue.hpp>
32 #include <com/sun/star/uno/Sequence.h>
33 
34 #ifndef JNI_H
35 #include <jni.h>
36 #endif
37 #include "java/sql/SQLException.hxx"
38 #include <comphelper/uno3.hxx>
39 
40 #include <com/sun/star/container/XNameAccess.hpp>
41 #include <com/sun/star/io/XInputStream.hpp>
42 #include <com/sun/star/util/Time.hpp>
43 #include <com/sun/star/util/Date.hpp>
44 #include <com/sun/star/util/DateTime.hpp>
45 
46 
47 namespace connectivity
48 {
49 
50 	jstring convertwchar_tToJavaString(JNIEnv *pEnv,const ::rtl::OUString& _Temp);
51 	::rtl::OUString JavaString2String(JNIEnv *pEnv,jstring _Str);
52 	class java_util_Properties;
53 
54 	java_util_Properties* createStringPropertyArray(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
55 
56     template<class T,class JT> ::com::sun::star::uno::Sequence< T > copyArrayAndDelete(JNIEnv *pEnv,jobjectArray _Array, const T*, const JT* )
57 	{
58                 ::com::sun::star::uno::Sequence< T > xOut;
59 		if(_Array)
60 		{
61 			jsize  nLen = pEnv->GetArrayLength(_Array);
62 			xOut.realloc(nLen);
63 			for(jsize i=0;i<nLen;++i)
64 			{
65 				JT xInfo(pEnv,pEnv->GetObjectArrayElement(_Array,i));
66 				java_lang_Object::ThrowSQLException(pEnv,NULL);
67 				xOut.getArray()[i] = xInfo;
68 			}
69 			pEnv->DeleteLocalRef(_Array);
70 		}
71 		return xOut;
72 	}
73 
74     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > Map2XNameAccess(JNIEnv *pEnv,jobject _pMap);
75     jobject convertTypeMapToJavaMap(JNIEnv *pEnv,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > & _rMap);
76 
77 	/** return if a exception occured
78 		@param	pEnv
79 			The native java env
80 		@param	_bClear
81 			<TRUE/> if the execption should be cleared
82 		@return
83 			<TRUE/> if an exception is occured
84 	*/
85 	sal_Bool isExceptionOccured(JNIEnv *pEnv,sal_Bool _bClear);
86 
87     jobject createByteInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length);
88     jobject createCharArrayReader(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length);
89 }
90 
91 #endif // _CONNECTIVITY_JAVA_TOOLS_HXX_
92 
93