LibreOffice Module connectivity (master) 1
FStatement.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <com/sun/star/sdbc/XStatement.hpp>
23#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
24#include <com/sun/star/sdbc/XCloseable.hpp>
25#include <com/sun/star/sdbc/SQLWarning.hpp>
26#include <com/sun/star/util/XCancellable.hpp>
33#include <file/FConnection.hxx>
34#include <file/filedllapi.hxx>
35#include <com/sun/star/lang/XServiceInfo.hpp>
37#include <file/fanalyzer.hxx>
38#include <TSortIndex.hxx>
39
40namespace connectivity::file
41 {
42 class OResultSet;
43 class OFileTable;
44 typedef ::cppu::WeakComponentImplHelper< css::sdbc::XWarningsSupplier,
45 css::util::XCancellable,
46 css::sdbc::XCloseable> OStatement_BASE;
47
48
49 //************ Class: java.sql.Statement
50
52 public cppu::BaseMutex,
53 public OStatement_BASE,
55 public ::comphelper::OPropertyArrayUsageHelper<OStatement_Base>
56
57 {
58 protected:
59 std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 every time
60 std::vector<sal_Int32> m_aParameterIndexes; // maps the parameter index to column index
61 std::vector<sal_Int32> m_aOrderbyColumnNumber;
62 std::vector<TAscendingOrder> m_aOrderbyAscending;
63
64 css::sdbc::SQLWarning m_aLastWarning;
65 css::uno::WeakReference< css::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
66 css::uno::Reference< css::sdbc::XDatabaseMetaData> m_xDBMetaData;
67 css::uno::Reference< css::container::XNameAccess> m_xColNames; // table columns // for this Statement
68
69
72
73 rtl::Reference<OConnection> m_pConnection;// The owning Connection object
75 std::unique_ptr<OSQLAnalyzer> m_pSQLAnalyzer; //the sql analyzer used by the resultset
76
80 OValueRefRow m_aEvaluateRow; // contains all values of a row
81 ORefAssignValues m_aAssignValues; // needed for insert,update and parameters
82 // to compare with the restrictions
83
84 OUString m_aCursorName;
85 sal_Int32 m_nMaxFieldSize;
86 sal_Int32 m_nMaxRows;
87 sal_Int32 m_nQueryTimeOut;
88 sal_Int32 m_nFetchSize;
93
94 protected:
95 // initialize the column index map (mapping select columns to table columns)
96 void createColumnMapping();
97 // searches the statement for sort criteria
98 void analyzeSQL();
99 void setOrderbyColumn( connectivity::OSQLParseNode const * pColumnRef,
100 connectivity::OSQLParseNode const * pAscendingDescending);
101
102 virtual void initializeResultSet(OResultSet* _pResult);
103
106 void closeResultSet();
107
108 void disposeResultSet();
109 void GetAssignValues();
110 void SetAssignValue(const OUString& aColumnName,
111 const OUString& aValue,
112 bool bSetNull = false,
113 sal_uInt32 nParameter=SQL_NO_PARAMETER);
114 void ParseAssignValues( const std::vector< OUString>& aColumnNameList,
115 connectivity::OSQLParseNode* pRow_Value_Constructor_Elem, sal_Int32 nIndex);
116
117 virtual void parseParamterElem(const OUString& _sColumnName,OSQLParseNode* pRow_Value_Constructor_Elem);
118 // factory method for resultset's
120 // OPropertyArrayUsageHelper
121 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
122 // OPropertySetHelper
123 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
124 virtual ~OStatement_Base() override;
125 public:
126 connectivity::OSQLParseNode* getParseTree() const { return m_pParseTree;}
127
128 OStatement_Base(OConnection* _pConnection );
129
130 OConnection* getOwnConnection() const { return m_pConnection.get(); }
131
132 using OStatement_BASE::operator css::uno::Reference< css::uno::XInterface >;
133
136 virtual void construct(const OUString& sql);
137
138 // OComponentHelper
139 virtual void SAL_CALL disposing() override;
140 // XInterface
141 // virtual void SAL_CALL release() throw(css::uno::RuntimeException) = 0;
142 virtual void SAL_CALL acquire() noexcept override;
143 // XInterface
144 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
145 //XTypeProvider
146 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
147
148 // XPropertySet
149 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
150 // XWarningsSupplier
151 virtual css::uno::Any SAL_CALL getWarnings( ) override;
152 virtual void SAL_CALL clearWarnings( ) override;
153 // XCancellable
154 virtual void SAL_CALL cancel( ) override;
155 // XCloseable
156 virtual void SAL_CALL close( ) override;
157 };
158
160
161 {
162 public:
163 OStatement_BASE2(OConnection* _pConnection ) : OStatement_Base(_pConnection ) {}
164 // OComponentHelper
165 virtual void SAL_CALL disposing() override;
166 // XInterface
167 virtual void SAL_CALL release() noexcept override;
168 };
169
170 typedef ::cppu::ImplHelper2< css::sdbc::XStatement,css::lang::XServiceInfo > OStatement_XStatement;
172 public OStatement_BASE2,
174 {
175 protected:
176 // factory method for resultset's
177 virtual rtl::Reference<OResultSet> createResultSet() override;
178 public:
179 // a Constructor, that is needed for when Returning the Object is needed:
180 OStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection){}
182
183 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
184 virtual void SAL_CALL acquire() noexcept override;
185 virtual void SAL_CALL release() noexcept override;
186
187 // XStatement
188 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery( const OUString& sql ) override ;
189 virtual sal_Int32 SAL_CALL executeUpdate( const OUString& sql ) override ;
190 virtual sal_Bool SAL_CALL execute( const OUString& sql ) override ;
191 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) override ;
192 };
193
194}
195
196/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SQL_NO_PARAMETER
Definition: FValue.hxx:470
Parser for SQL92.
Definition: sqlparse.hxx:110
OStatement_BASE2(OConnection *_pConnection)
Definition: FStatement.hxx:163
std::unique_ptr< OSQLAnalyzer > m_pSQLAnalyzer
Definition: FStatement.hxx:75
std::vector< sal_Int32 > m_aColMapping
Definition: FStatement.hxx:59
connectivity::OSQLParseTreeIterator m_aSQLIterator
Definition: FStatement.hxx:71
css::uno::Reference< css::container::XNameAccess > m_xColNames
Definition: FStatement.hxx:67
css::sdbc::SQLWarning m_aLastWarning
Definition: FStatement.hxx:64
connectivity::OSQLParseNode * m_pParseTree
Definition: FStatement.hxx:74
std::vector< sal_Int32 > m_aOrderbyColumnNumber
Definition: FStatement.hxx:61
rtl::Reference< OConnection > m_pConnection
Definition: FStatement.hxx:73
connectivity::OSQLParseNode * getParseTree() const
Definition: FStatement.hxx:126
virtual rtl::Reference< OResultSet > createResultSet()=0
rtl::Reference< OFileTable > m_pTable
Definition: FStatement.hxx:77
connectivity::OSQLParser m_aParser
Definition: FStatement.hxx:70
css::uno::WeakReference< css::sdbc::XResultSet > m_xResultSet
Definition: FStatement.hxx:65
std::vector< TAscendingOrder > m_aOrderbyAscending
Definition: FStatement.hxx:62
std::vector< sal_Int32 > m_aParameterIndexes
Definition: FStatement.hxx:60
css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xDBMetaData
Definition: FStatement.hxx:66
OConnection * getOwnConnection() const
Definition: FStatement.hxx:130
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
OStatement(OConnection *_pConnection)
Definition: FStatement.hxx:180
#define OOO_DLLPUBLIC_FILE
Definition: filedllapi.hxx:29
Type
::cppu::WeakComponentImplHelper< css::sdbc::XWarningsSupplier, css::util::XCancellable, css::sdbc::XCloseable > OStatement_BASE
Definition: FStatement.hxx:43
::cppu::ImplHelper1< css::sdbc::XStatement > OStatement_Base
Definition: Statement.hxx:31
Reference< XConnection > getConnection(const Reference< XRowSet > &_rxRowSet)
Definition: dbtools.cxx:348
unsigned char sal_Bool