1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MSTATEMENT_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MSTATEMENT_HXX
23 #include <com/sun/star/sdbc/XStatement.hpp>
24 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
25 #include <com/sun/star/sdbc/XBatchExecution.hpp>
26 #include <com/sun/star/sdbc/XCloseable.hpp>
27 #include <com/sun/star/sdbc/SQLWarning.hpp>
28 #include <comphelper/proparrhlp.hxx>
29 #include <cppuhelper/compbase3.hxx>
30 #include <comphelper/uno3.hxx>
31 #include <connectivity/CommonTools.hxx>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <comphelper/broadcasthelper.hxx>
35 #include <connectivity/sqliterator.hxx>
36 #include <connectivity/sqlparse.hxx>
37 #include <connectivity/FValue.hxx>
38 #include "TSortIndex.hxx"
39 #include "MConnection.hxx"
42 #include <boost/shared_ptr.hpp>
44 namespace connectivity
50 typedef ::cppu::WeakComponentImplHelper3
< ::com::sun::star::sdbc::XStatement
,
51 ::com::sun::star::sdbc::XWarningsSupplier
,
52 ::com::sun::star::sdbc::XCloseable
> OCommonStatement_IBASE
;
55 //************ Class: OCommonStatement
56 // is a base class for the normal statement and for the prepared statement
58 class OCommonStatement
;
59 typedef ::connectivity::OSubComponent
< OCommonStatement
, OCommonStatement_IBASE
> OCommonStatement_SBASE
;
61 class OCommonStatement
:public comphelper::OBaseMutex
62 ,public OCommonStatement_IBASE
63 ,public ::cppu::OPropertySetHelper
64 ,public ::comphelper::OPropertyArrayUsageHelper
< OCommonStatement
>
65 ,public OCommonStatement_SBASE
67 friend class ::connectivity::OSubComponent
< OCommonStatement
, OCommonStatement_IBASE
>;
70 ::com::sun::star::sdbc::SQLWarning m_aLastWarning
;
73 ::com::sun::star::uno::WeakReference
< ::com::sun::star::sdbc::XResultSet
> m_xResultSet
;
74 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDatabaseMetaData
> m_xDBMetaData
;
75 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> m_xColNames
; // table columns
79 ::std::list
< OUString
> m_aBatchList
;
82 OConnection
* m_pConnection
; // The owning Connection object
86 connectivity::OSQLParser m_aParser
;
87 ::boost::shared_ptr
< ::connectivity::OSQLParseTreeIterator
>
90 connectivity::OSQLParseNode
* m_pParseTree
;
92 ::std::vector
<sal_Int32
> m_aColMapping
;
93 ::std::vector
<sal_Int32
> m_aOrderbyColumnNumber
;
94 ::std::vector
<TAscendingOrder
> m_aOrderbyAscending
;
96 ::cppu::OBroadcastHelper
& rBHelper
;
100 // OPropertyArrayUsageHelper
101 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const;
102 // OPropertySetHelper
103 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
104 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
105 ::com::sun::star::uno::Any
& rConvertedValue
,
106 ::com::sun::star::uno::Any
& rOldValue
,
108 const ::com::sun::star::uno::Any
& rValue
)
109 throw (::com::sun::star::lang::IllegalArgumentException
);
110 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
112 const ::com::sun::star::uno::Any
& rValue
) throw (::com::sun::star::uno::Exception
);
113 virtual void SAL_CALL
getFastPropertyValue(
114 ::com::sun::star::uno::Any
& rValue
,
115 sal_Int32 nHandle
) const;
116 virtual ~OCommonStatement();
120 // Driver Internal Methods
122 enum StatementType
{ eSelect
, eCreateTable
};
123 /** called to do the parsing of a to-be-executed SQL statement, and set all members as needed
125 virtual StatementType
126 parseSql( const OUString
& sql
, sal_Bool bAdjusted
= sal_False
) throw ( ::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
127 /** called to initialize a result set, according to a previously parsed SQL statement
129 virtual void initializeResultSet( OResultSet
* _pResult
);
130 /** called when a possible cached instance of our last result set should be cleared
132 virtual void clearCachedResultSet();
133 /** caches a result set which has just been created by an execution of an SQL statement
135 virtual void cacheResultSet( const ::rtl::Reference
< OResultSet
>& _pResult
);
138 /** executes the current query (the one which has been passed to the last parseSql call)
140 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
>
141 impl_executeCurrentQuery();
143 void createColumnMapping();
145 void setOrderbyColumn( connectivity::OSQLParseNode
* pColumnRef
,
146 connectivity::OSQLParseNode
* pAscendingDescending
);
147 virtual void createTable( ) throw (
148 ::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
152 OConnection
* getOwnConnection() const { return m_pConnection
;}
154 OCommonStatement(OConnection
* _pConnection
);
155 using OCommonStatement_IBASE::operator ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>;
158 virtual void SAL_CALL
disposing();
161 virtual void SAL_CALL
release() throw();
162 virtual void SAL_CALL
acquire() throw();
164 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
);
166 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw(::com::sun::star::uno::RuntimeException
);
169 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
);
171 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
> SAL_CALL
executeQuery( const OUString
& sql
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
) ;
172 virtual sal_Int32 SAL_CALL
executeUpdate( const OUString
& sql
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
) ;
173 virtual sal_Bool SAL_CALL
execute( const OUString
& sql
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
) ;
174 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
) ;
176 virtual ::com::sun::star::uno::Any SAL_CALL
getWarnings( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
177 virtual void SAL_CALL
clearWarnings( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
179 virtual void SAL_CALL
close( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
182 using OPropertySetHelper::getFastPropertyValue
;
185 class OStatement
: public OCommonStatement
,
186 public ::com::sun::star::lang::XServiceInfo
191 // a constructor, for when the object needs to be returned:
192 OStatement( OConnection
* _pConnection
) : OCommonStatement( _pConnection
){}
193 DECLARE_SERVICE_INFO();
195 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
);
196 virtual void SAL_CALL
acquire() throw();
197 virtual void SAL_CALL
release() throw();
202 #endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MSTATEMENT_HXX
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */