merge the formfield patch from ooo-build
[ooovba.git] / connectivity / source / inc / file / FStatement.hxx
bloba398225bd8901882730e1dc315a4c2bd45f684c3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FStatement.hxx,v $
10 * $Revision: 1.23 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CONNECTIVITY_FILE_OSTATEMENT_HXX_
32 #define _CONNECTIVITY_FILE_OSTATEMENT_HXX_
34 #include <com/sun/star/sdbc/XStatement.hpp>
35 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
36 #include <com/sun/star/sdbc/XMultipleResults.hpp>
37 #include <com/sun/star/sdbc/XBatchExecution.hpp>
38 #include <com/sun/star/sdbc/XCloseable.hpp>
39 #include <com/sun/star/sdbc/SQLWarning.hpp>
40 #include <com/sun/star/util/XCancellable.hpp>
41 #include <comphelper/proparrhlp.hxx>
42 #include <cppuhelper/compbase3.hxx>
43 #include <cppuhelper/implbase2.hxx>
44 #include <comphelper/uno3.hxx>
45 #include "connectivity/CommonTools.hxx"
46 #include "file/FConnection.hxx"
47 #include "file/filedllapi.hxx"
48 #ifndef _LIST_
49 #include <list>
50 #endif
51 #include <com/sun/star/lang/XServiceInfo.hpp>
52 #include <comphelper/propertycontainer.hxx>
53 #include "file/fanalyzer.hxx"
54 #include <comphelper/broadcasthelper.hxx>
55 #include "TSortIndex.hxx"
57 #define SQL_COLUMN_NOTFOUND STRING_NOTFOUND
59 namespace connectivity
61 namespace file
63 class OResultSet;
64 class OFileTable;
65 typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XWarningsSupplier,
66 ::com::sun::star::util::XCancellable,
67 ::com::sun::star::sdbc::XCloseable> OStatement_BASE;
69 //**************************************************************
70 //************ Class: java.sql.Statement
71 //**************************************************************
72 class OOO_DLLPUBLIC_FILE OStatement_Base :
73 public comphelper::OBaseMutex,
74 public OStatement_BASE,
75 public ::comphelper::OPropertyContainer,
76 public ::comphelper::OPropertyArrayUsageHelper<OStatement_Base>
79 protected:
80 ::std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 everytime
81 ::std::vector<sal_Int32> m_aParameterIndexes; // maps the parameter index to column index
82 ::std::vector<sal_Int32> m_aOrderbyColumnNumber;
83 ::std::vector<TAscendingOrder> m_aOrderbyAscending;
85 ::com::sun::star::sdbc::SQLWarning m_aLastWarning;
86 ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
87 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xDBMetaData;
88 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColNames; // table columns // for this Statement
91 connectivity::OSQLParser m_aParser;
92 connectivity::OSQLParseTreeIterator m_aSQLIterator;
94 OConnection* m_pConnection;// The owning Connection object
95 connectivity::OSQLParseNode* m_pParseTree;
96 OSQLAnalyzer* m_pSQLAnalyzer; //the sql analyzer used by the resultset
98 ::std::vector<sal_Int32>* m_pEvaluationKeySet;
100 OFileTable* m_pTable; // the current table
101 OValueRefRow m_aSelectRow;
102 OValueRefRow m_aRow;
103 OValueRefRow m_aEvaluateRow; // contains all values of a row
104 ORefAssignValues m_aAssignValues; // needed for insert,update and parameters
105 // to compare with the restrictions
107 ::rtl::OUString m_aCursorName;
108 sal_Int32 m_nMaxFieldSize;
109 sal_Int32 m_nMaxRows;
110 sal_Int32 m_nQueryTimeOut;
111 sal_Int32 m_nFetchSize;
112 sal_Int32 m_nResultSetType;
113 sal_Int32 m_nFetchDirection;
114 sal_Int32 m_nResultSetConcurrency;
115 sal_Bool m_bEscapeProcessing;
117 ::cppu::OBroadcastHelper& rBHelper;
119 protected:
120 // initialize the column index map (mapping select columns to table columns)
121 void createColumnMapping();
122 // searches the statement for sort criteria
123 void anylizeSQL();
124 void setOrderbyColumn( connectivity::OSQLParseNode* pColumnRef,
125 connectivity::OSQLParseNode* pAscendingDescending);
127 virtual void initializeResultSet(OResultSet* _pResult);
128 // create the analyzer
129 virtual OSQLAnalyzer* createAnalyzer();
131 void reset () throw( ::com::sun::star::sdbc::SQLException);
132 void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException);
133 void setWarning (const ::com::sun::star::sdbc::SQLWarning &ex) throw( ::com::sun::star::sdbc::SQLException);
134 sal_Int32 getPrecision ( sal_Int32 sqlType);
136 void disposeResultSet();
137 void GetAssignValues();
138 void SetAssignValue(const String& aColumnName,
139 const String& aValue,
140 BOOL bSetNull = FALSE,
141 UINT32 nParameter=SQL_NO_PARAMETER);
142 void ParseAssignValues( const ::std::vector< String>& aColumnNameList,
143 connectivity::OSQLParseNode* pRow_Value_Constructor_Elem,xub_StrLen nIndex);
145 virtual void parseParamterElem(const String& _sColumnName,OSQLParseNode* pRow_Value_Constructor_Elem);
146 // factory method for resultset's
147 virtual OResultSet* createResultSet() = 0;
148 // OPropertyArrayUsageHelper
149 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
150 // OPropertySetHelper
151 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
152 virtual ~OStatement_Base();
153 public:
154 connectivity::OSQLParseNode* getParseTree() const { return m_pParseTree;}
156 OStatement_Base(OConnection* _pConnection );
158 OConnection* getOwnConnection() const { return m_pConnection;}
160 using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
162 virtual void construct(const ::rtl::OUString& sql) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
164 // OComponentHelper
165 virtual void SAL_CALL disposing(void);
166 // XInterface
167 // virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException) = 0;
168 virtual void SAL_CALL acquire() throw();
169 // XInterface
170 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
171 //XTypeProvider
172 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
174 // XPropertySet
175 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
176 // XWarningsSupplier
177 virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
178 virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
179 // XCancellable
180 virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException);
181 // XCloseable
182 virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
185 class OOO_DLLPUBLIC_FILE OStatement_BASE2 :
186 public OStatement_Base,
187 public connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>
190 friend class connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>;
191 public:
192 OStatement_BASE2(OConnection* _pConnection ) : OStatement_Base(_pConnection ),
193 connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this){}
194 // OComponentHelper
195 virtual void SAL_CALL disposing(void);
196 // XInterface
197 virtual void SAL_CALL release() throw();
200 typedef ::cppu::ImplHelper2< ::com::sun::star::sdbc::XStatement,::com::sun::star::lang::XServiceInfo > OStatement_XStatement;
201 class OOO_DLLPUBLIC_FILE OStatement :
202 public OStatement_BASE2,
203 public OStatement_XStatement
205 protected:
206 // factory method for resultset's
207 virtual OResultSet* createResultSet();
208 public:
209 // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
210 OStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection){}
211 DECLARE_SERVICE_INFO();
213 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
214 virtual void SAL_CALL acquire() throw();
215 virtual void SAL_CALL release() throw();
217 // XStatement
218 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) ;
219 virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
220 virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
221 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) ;
225 #endif // _CONNECTIVITY_FILE_OSTATEMENT_HXX_