1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _CONNECTIVITY_FILE_OCONNECTION_HXX_
28*cdf0e10cSrcweir #define _CONNECTIVITY_FILE_OCONNECTION_HXX_
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <com/sun/star/ucb/XContent.hpp>
31*cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLWarning.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
33*cdf0e10cSrcweir #include "OSubComponent.hxx"
34*cdf0e10cSrcweir #ifndef _MAP_
35*cdf0e10cSrcweir #include <map>
36*cdf0e10cSrcweir #endif
37*cdf0e10cSrcweir #include "connectivity/CommonTools.hxx"
38*cdf0e10cSrcweir #include "OTypeInfo.hxx"
39*cdf0e10cSrcweir #include <tools/string.hxx>
40*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/ucb/XDynamicResultSet.hpp>
42*cdf0e10cSrcweir #include "connectivity/sqlparse.hxx"
43*cdf0e10cSrcweir #include "connectivity/sqliterator.hxx"
44*cdf0e10cSrcweir #include "TConnection.hxx"
45*cdf0e10cSrcweir #include "file/filedllapi.hxx"
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir namespace connectivity
48*cdf0e10cSrcweir {
49*cdf0e10cSrcweir 	namespace file
50*cdf0e10cSrcweir 	{
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir 		class OStatement_Base;
53*cdf0e10cSrcweir 		class ODatabaseMetaData;
54*cdf0e10cSrcweir 		class OFileDriver;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir 		class OOO_DLLPUBLIC_FILE OConnection :
57*cdf0e10cSrcweir                             public connectivity::OMetaConnection,
58*cdf0e10cSrcweir 							public connectivity::OSubComponent<OConnection, connectivity::OMetaConnection>
59*cdf0e10cSrcweir 		{
60*cdf0e10cSrcweir 			friend class connectivity::OSubComponent<OConnection, connectivity::OMetaConnection>;
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir 		protected:
63*cdf0e10cSrcweir 			//====================================================================
64*cdf0e10cSrcweir 			// Data attributes
65*cdf0e10cSrcweir 			//====================================================================
66*cdf0e10cSrcweir             ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier>			m_xCatalog;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 			::com::sun::star::sdbc::SQLWarning            m_aLastWarning; //      Last SQLWarning generated by
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 			String						m_aFilenameExtension;
71*cdf0e10cSrcweir 			OFileDriver*				m_pDriver;		//	Pointer to the owning
72*cdf0e10cSrcweir 														//  driver object
73*cdf0e10cSrcweir 			::com::sun::star::uno::Reference< ::com::sun::star::ucb::XDynamicResultSet >	m_xDir; // directory
74*cdf0e10cSrcweir 			::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent>				m_xContent;
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 			sal_Bool					m_bClosed;
77*cdf0e10cSrcweir 			sal_Bool					m_bAutoCommit;
78*cdf0e10cSrcweir 			sal_Bool					m_bReadOnly;
79*cdf0e10cSrcweir 			sal_Bool					m_bShowDeleted;
80*cdf0e10cSrcweir 			sal_Bool					m_bCaseSensitiveExtension;
81*cdf0e10cSrcweir 			sal_Bool					m_bCheckSQL92;
82*cdf0e10cSrcweir             bool                        m_bDefaultTextEncoding;
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 			void throwUrlNotValid(const ::rtl::OUString & _rsUrl,const ::rtl::OUString & _rsMessage);
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir 			virtual ~OConnection();
88*cdf0e10cSrcweir 		public:
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 			OConnection(OFileDriver*	_pDriver);
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir             virtual void construct(const ::rtl::OUString& _rUrl,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo ) throw( ::com::sun::star::sdbc::SQLException);
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir             void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 			// OComponentHelper
97*cdf0e10cSrcweir 			virtual void SAL_CALL disposing(void);
98*cdf0e10cSrcweir 			// XInterface
99*cdf0e10cSrcweir 			virtual void SAL_CALL release() throw();
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 			// XServiceInfo
102*cdf0e10cSrcweir 			DECLARE_SERVICE_INFO();
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 			// XConnection
105*cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
106*cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
107*cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
108*cdf0e10cSrcweir             virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
109*cdf0e10cSrcweir             virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
110*cdf0e10cSrcweir             virtual sal_Bool SAL_CALL getAutoCommit(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
111*cdf0e10cSrcweir             virtual void SAL_CALL commit(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
112*cdf0e10cSrcweir             virtual void SAL_CALL rollback(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
113*cdf0e10cSrcweir             virtual sal_Bool SAL_CALL isClosed(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
114*cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
115*cdf0e10cSrcweir             virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
116*cdf0e10cSrcweir             virtual sal_Bool SAL_CALL isReadOnly(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
117*cdf0e10cSrcweir             virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
118*cdf0e10cSrcweir             virtual ::rtl::OUString SAL_CALL getCatalog(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
119*cdf0e10cSrcweir             virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
120*cdf0e10cSrcweir             virtual sal_Int32 SAL_CALL getTransactionIsolation(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
121*cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
122*cdf0e10cSrcweir             virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
123*cdf0e10cSrcweir 			// XCloseable
124*cdf0e10cSrcweir 			virtual void SAL_CALL close(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
125*cdf0e10cSrcweir 			// XWarningsSupplier
126*cdf0e10cSrcweir 			virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
127*cdf0e10cSrcweir 			virtual void SAL_CALL clearWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
128*cdf0e10cSrcweir 			//XUnoTunnel
129*cdf0e10cSrcweir 			virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw (::com::sun::star::uno::RuntimeException);
130*cdf0e10cSrcweir 			static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 			// no interface methods
133*cdf0e10cSrcweir 			::com::sun::star::uno::Reference< ::com::sun::star::ucb::XDynamicResultSet > getDir() const;
134*cdf0e10cSrcweir 			::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent>	getContent() const { return m_xContent; }
135*cdf0e10cSrcweir 			// create a catalog or return the catalog already created
136*cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog();
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir 			sal_Bool				matchesExtension( const String& _rExt ) const;
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 			inline const String&	getExtension()				const { return m_aFilenameExtension; }
141*cdf0e10cSrcweir 			inline sal_Bool			isCaseSensitveExtension()	const { return m_bCaseSensitiveExtension; }
142*cdf0e10cSrcweir 			inline OFileDriver*		getDriver()					const { return m_pDriver; }
143*cdf0e10cSrcweir 			inline sal_Bool			showDeleted()				const { return m_bShowDeleted; }
144*cdf0e10cSrcweir 			inline sal_Bool			isCheckEnabled()			const { return m_bCheckSQL92; }
145*cdf0e10cSrcweir             inline bool             isTextEncodingDefaulted()   const { return m_bDefaultTextEncoding; }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 		public:
148*cdf0e10cSrcweir 			struct GrantAccess
149*cdf0e10cSrcweir 			{
150*cdf0e10cSrcweir 				friend class ODatabaseMetaData;
151*cdf0e10cSrcweir 			private:
152*cdf0e10cSrcweir 				GrantAccess() { }
153*cdf0e10cSrcweir 			};
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 			void	setCaseSensitiveExtension( sal_Bool _bIsCS, GrantAccess ) { m_bCaseSensitiveExtension = _bIsCS; }
156*cdf0e10cSrcweir 		};
157*cdf0e10cSrcweir 	}
158*cdf0e10cSrcweir }
159*cdf0e10cSrcweir #endif // _CONNECTIVITY_FILE_OCONNECTION_HXX_
160*cdf0e10cSrcweir 
161