1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
7 * Copyright 2000, 2010 Oracle and/or its affiliates.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
29 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
31 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
32 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *************************************************************************/
36 #ifndef INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SSTATEMENT_HXX
37 #define INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SSTATEMENT_HXX
39 #include <com/sun/star/sdbc/XStatement.hpp>
40 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
41 #include <com/sun/star/sdbc/XMultipleResults.hpp>
42 #include <com/sun/star/sdbc/XBatchExecution.hpp>
43 #include <com/sun/star/sdbc/XCloseable.hpp>
44 #include <com/sun/star/sdbc/SQLWarning.hpp>
45 #include <com/sun/star/util/XCancellable.hpp>
46 #include <cppuhelper/compbase5.hxx>
47 #include "SConnection.hxx"
49 #include "OSubComponent.hxx"
50 #include <com/sun/star/lang/XServiceInfo.hpp>
52 namespace connectivity
57 typedef ::cppu::WeakComponentImplHelper5
< ::com::sun::star::sdbc::XStatement
,
58 ::com::sun::star::sdbc::XWarningsSupplier
,
59 ::com::sun::star::util::XCancellable
,
60 ::com::sun::star::sdbc::XCloseable
,
61 ::com::sun::star::sdbc::XMultipleResults
> OStatement_BASE
;
63 // A base class for the normal statement and for the prepared statement
64 class OStatement_Base
: public OBase_Mutex
,
65 public OStatement_BASE
,
66 public ::cppu::OPropertySetHelper
,
67 public OPropertyArrayUsageHelper
<OStatement_Base
>
70 ::com::sun::star::sdbc::SQLWarning m_aLastWarning
;
72 ::com::sun::star::uno::WeakReference
< ::com::sun::star::sdbc::XResultSet
> m_xResultSet
; // The last ResultSet created
75 ::std::vector
< ::rtl::OUString
> m_aBatchVector
;
77 OConnection
* m_pConnection
; // The owning Connection object
80 void disposeResultSet();
82 // OPropertyArrayUsageHelper
83 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const;
85 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
86 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
87 ::com::sun::star::uno::Any
& rConvertedValue
,
88 ::com::sun::star::uno::Any
& rOldValue
,
90 const ::com::sun::star::uno::Any
& rValue
);
91 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
93 const ::com::sun::star::uno::Any
& rValue
);
94 virtual void SAL_CALL
getFastPropertyValue(
95 ::com::sun::star::uno::Any
& rValue
,
96 sal_Int32 nHandle
) const;
97 virtual ~OStatement_Base();
100 ::cppu::OBroadcastHelper
& rBHelper
;
101 OStatement_Base(OConnection
* _pConnection
);
102 using OStatement_BASE::operator ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>;
105 virtual void SAL_CALL
disposing(){OStatement_BASE::disposing();}
107 virtual void SAL_CALL
release() SAL_NOEXCEPT
;
108 virtual void SAL_CALL
acquire() SAL_NOEXCEPT
;
110 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
);
112 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( );
115 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( );
117 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
> SAL_CALL
executeQuery( const ::rtl::OUString
& sql
) ;
118 virtual sal_Int32 SAL_CALL
executeUpdate( const ::rtl::OUString
& sql
) ;
119 virtual sal_Bool SAL_CALL
execute( const ::rtl::OUString
& sql
) ;
120 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> SAL_CALL
getConnection( ) ;
122 virtual ::com::sun::star::uno::Any SAL_CALL
getWarnings( );
123 virtual void SAL_CALL
clearWarnings( );
125 virtual void SAL_CALL
cancel( );
127 virtual void SAL_CALL
close( );
129 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
> SAL_CALL
getResultSet( );
130 virtual sal_Int32 SAL_CALL
getUpdateCount( );
131 virtual sal_Bool SAL_CALL
getMoreResults( );
134 OConnection
* getOwnConnection() const { return m_pConnection
;}
137 class OStatement_BASE2
:public OStatement_Base
138 ,public OSubComponent
<OStatement_BASE2
, OStatement_BASE
>
141 friend class OSubComponent
<OStatement_BASE2
, OStatement_BASE
>;
143 OStatement_BASE2(OConnection
* _pConnection
) : OStatement_Base(_pConnection
),
144 OSubComponent
<OStatement_BASE2
, OStatement_BASE
>((::cppu::OWeakObject
*)_pConnection
, this){}
146 virtual void SAL_CALL
disposing();
148 virtual void SAL_CALL
release() SAL_NOEXCEPT
;
151 class OStatement
: public OStatement_BASE2
,
152 public ::com::sun::star::sdbc::XBatchExecution
,
153 public ::com::sun::star::lang::XServiceInfo
156 virtual ~OStatement(){}
158 // a constructor, which is required for returning objects:
159 OStatement( OConnection
* _pConnection
) : OStatement_BASE2( _pConnection
){}
160 DECLARE_SERVICE_INFO();
162 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
);
163 virtual void SAL_CALL
acquire() SAL_NOEXCEPT
;
164 virtual void SAL_CALL
release() SAL_NOEXCEPT
;
166 virtual void SAL_CALL
addBatch( const ::rtl::OUString
& sql
);
167 virtual void SAL_CALL
clearBatch( );
168 virtual ::com::sun::star::uno::Sequence
< sal_Int32
> SAL_CALL
executeBatch( );
173 #endif // INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SSTATEMENT_HXX
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */