merge the formfield patch from ooo-build
[ooovba.git] / odk / examples / DevelopersGuide / Database / DriverSkeleton / SStatement.hxx
blob6d6ac004bffb4ea86001c1168add6ec5ebb03344
1 /*************************************************************************
3 * $RCSfile: SStatement.hxx,v $
5 * $Revision: 1.4 $
7 * last change: $Author: rt $ $Date: 2008-04-10 16:37:41 $
9 * The Contents of this file are made available subject to the terms of
10 * the BSD license.
12 * Copyright (c) 2003 by Sun Microsystems, Inc.
13 * All rights reserved.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
34 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *************************************************************************/
41 #ifndef CONNECTIVITY_SSTATEMENT_HXX
42 #define CONNECTIVITY_SSTATEMENT_HXX
44 #include <com/sun/star/sdbc/XStatement.hpp>
45 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
46 #include <com/sun/star/sdbc/XMultipleResults.hpp>
47 #include <com/sun/star/sdbc/XBatchExecution.hpp>
48 #include <com/sun/star/sdbc/XCloseable.hpp>
49 #include <com/sun/star/sdbc/SQLWarning.hpp>
50 #include <com/sun/star/util/XCancellable.hpp>
51 #include <cppuhelper/compbase5.hxx>
52 #include "SConnection.hxx"
53 #include <list>
54 #include "OSubComponent.hxx"
55 #include <com/sun/star/lang/XServiceInfo.hpp>
57 namespace connectivity
59 namespace skeleton
62 typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbc::XStatement,
63 ::com::sun::star::sdbc::XWarningsSupplier,
64 ::com::sun::star::util::XCancellable,
65 ::com::sun::star::sdbc::XCloseable,
66 ::com::sun::star::sdbc::XMultipleResults> OStatement_BASE;
68 //**************************************************************
69 //************ Class: OStatement_Base
70 // is a base class for the normal statement and for the prepared statement
71 //**************************************************************
72 class OStatement_Base : public OBase_Mutex,
73 public OStatement_BASE,
74 public ::cppu::OPropertySetHelper,
75 public OPropertyArrayUsageHelper<OStatement_Base>
78 ::com::sun::star::sdbc::SQLWarning m_aLastWarning;
79 protected:
80 ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
81 // for this Statement
83 ::std::list< ::rtl::OUString> m_aBatchList;
85 OConnection* m_pConnection; // The owning Connection object
86 protected:
88 void disposeResultSet();
90 // OPropertyArrayUsageHelper
91 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
92 // OPropertySetHelper
93 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
94 virtual sal_Bool SAL_CALL convertFastPropertyValue(
95 ::com::sun::star::uno::Any & rConvertedValue,
96 ::com::sun::star::uno::Any & rOldValue,
97 sal_Int32 nHandle,
98 const ::com::sun::star::uno::Any& rValue )
99 throw (::com::sun::star::lang::IllegalArgumentException);
100 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
101 sal_Int32 nHandle,
102 const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
103 virtual void SAL_CALL getFastPropertyValue(
104 ::com::sun::star::uno::Any& rValue,
105 sal_Int32 nHandle) const;
106 virtual ~OStatement_Base();
108 public:
109 ::cppu::OBroadcastHelper& rBHelper;
110 OStatement_Base(OConnection* _pConnection );
111 using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
113 // OComponentHelper
114 virtual void SAL_CALL disposing(void){OStatement_BASE::disposing();}
115 // XInterface
116 virtual void SAL_CALL release() throw();
117 virtual void SAL_CALL acquire() throw();
118 // XInterface
119 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
120 //XTypeProvider
121 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
123 // XPropertySet
124 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
125 // XStatement
126 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
127 virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
128 virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
129 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
130 // XWarningsSupplier
131 virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
132 virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
133 // XCancellable
134 virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException);
135 // XCloseable
136 virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
137 // XMultipleResults
138 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
139 virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
140 virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
142 // other methods
143 OConnection* getOwnConnection() const { return m_pConnection;}
146 class OStatement_BASE2 :public OStatement_Base
147 ,public OSubComponent<OStatement_BASE2, OStatement_BASE>
150 friend class OSubComponent<OStatement_BASE2, OStatement_BASE>;
151 public:
152 OStatement_BASE2(OConnection* _pConnection ) : OStatement_Base(_pConnection ),
153 OSubComponent<OStatement_BASE2, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this){}
154 // OComponentHelper
155 virtual void SAL_CALL disposing(void);
156 // XInterface
157 virtual void SAL_CALL release() throw();
160 class OStatement : public OStatement_BASE2,
161 public ::com::sun::star::sdbc::XBatchExecution,
162 public ::com::sun::star::lang::XServiceInfo
164 protected:
165 virtual ~OStatement(){}
166 public:
167 // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
168 OStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection){}
169 DECLARE_SERVICE_INFO();
171 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
172 virtual void SAL_CALL acquire() throw();
173 virtual void SAL_CALL release() throw();
174 // XBatchExecution
175 virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
176 virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
177 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
181 #endif // CONNECTIVITY_SSTATEMENT_HXX