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_MORK_MSTATEMENT_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MSTATEMENT_HXX
23 #include <comphelper/proparrhlp.hxx>
24 #include <connectivity/sqliterator.hxx>
25 #include <connectivity/sqlparse.hxx>
26 #include "TSortIndex.hxx"
31 namespace connectivity
37 typedef ::cppu::WeakComponentImplHelper
< css::sdbc::XStatement
,
38 css::sdbc::XWarningsSupplier
,
39 css::sdbc::XCloseable
> OCommonStatement_IBASE
;
42 //************ Class: OCommonStatement
43 // is a base class for the normal statement and for the prepared statement
45 class OCommonStatement
;
46 typedef ::connectivity::OSubComponent
< OCommonStatement
, OCommonStatement_IBASE
> OCommonStatement_SBASE
;
48 class OCommonStatement
:public cppu::BaseMutex
49 ,public OCommonStatement_IBASE
50 ,public ::cppu::OPropertySetHelper
51 ,public ::comphelper::OPropertyArrayUsageHelper
< OCommonStatement
>
52 ,public OCommonStatement_SBASE
54 friend class ::connectivity::OSubComponent
< OCommonStatement
, OCommonStatement_IBASE
>;
57 css::sdbc::SQLWarning m_aLastWarning
;
60 css::uno::WeakReference
< css::sdbc::XResultSet
> m_xResultSet
;
61 css::uno::Reference
< css::sdbc::XDatabaseMetaData
> m_xDBMetaData
;
62 css::uno::Reference
< css::container::XNameAccess
> m_xColNames
; // table columns
67 rtl::Reference
<OConnection
> m_pConnection
; // The owning Connection object
71 connectivity::OSQLParser m_aParser
;
72 std::shared_ptr
< ::connectivity::OSQLParseTreeIterator
>
75 connectivity::OSQLParseNode
* m_pParseTree
;
77 ::std::vector
<sal_Int32
> m_aColMapping
;
78 ::std::vector
<sal_Int32
> m_aOrderbyColumnNumber
;
79 ::std::vector
<TAscendingOrder
> m_aOrderbyAscending
;
83 // OPropertyArrayUsageHelper
84 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const override
;
86 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
87 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
88 css::uno::Any
& rConvertedValue
,
89 css::uno::Any
& rOldValue
,
91 const css::uno::Any
& rValue
)
92 throw (css::lang::IllegalArgumentException
) override
;
93 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
95 const css::uno::Any
& rValue
) throw (css::uno::Exception
, std::exception
) override
;
96 virtual void SAL_CALL
getFastPropertyValue(
97 css::uno::Any
& rValue
,
98 sal_Int32 nHandle
) const override
;
99 virtual ~OCommonStatement() override
;
103 // Driver Internal Methods
105 enum StatementType
{ eSelect
, eCreateTable
};
106 /** called to do the parsing of a to-be-executed SQL statement, and set all members as needed
108 virtual StatementType
109 parseSql( const OUString
& sql
, bool bAdjusted
= false) throw ( css::sdbc::SQLException
, css::uno::RuntimeException
, std::exception
);
110 /** called to initialize a result set, according to a previously parsed SQL statement
112 virtual void initializeResultSet( OResultSet
* _pResult
);
113 /** called when a possible cached instance of our last result set should be cleared
115 virtual void clearCachedResultSet();
116 /** caches a result set which has just been created by an execution of an SQL statement
118 virtual void cacheResultSet( const ::rtl::Reference
< OResultSet
>& _pResult
);
121 /** executes the current query (the one which has been passed to the last parseSql call)
123 css::uno::Reference
< css::sdbc::XResultSet
>
124 impl_executeCurrentQuery();
126 void createColumnMapping();
128 void setOrderbyColumn( connectivity::OSQLParseNode
* pColumnRef
,
129 connectivity::OSQLParseNode
* pAscendingDescending
);
133 OConnection
* getOwnConnection() const { return m_pConnection
.get(); }
135 explicit OCommonStatement(OConnection
* _pConnection
);
136 using OCommonStatement_IBASE::operator css::uno::Reference
< css::uno::XInterface
>;
139 virtual void SAL_CALL
disposing() override
;
142 virtual void SAL_CALL
release() throw() override
;
143 virtual void SAL_CALL
acquire() throw() override
;
145 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) throw(css::uno::RuntimeException
, std::exception
) override
;
147 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) throw(css::uno::RuntimeException
, std::exception
) override
;
150 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(css::uno::RuntimeException
, std::exception
) override
;
152 virtual css::uno::Reference
< css::sdbc::XResultSet
> SAL_CALL
executeQuery( const OUString
& sql
) throw(css::sdbc::SQLException
, css::uno::RuntimeException
, std::exception
) override
;
153 virtual sal_Int32 SAL_CALL
executeUpdate( const OUString
& sql
) throw(css::sdbc::SQLException
, css::uno::RuntimeException
, std::exception
) override
;
154 virtual sal_Bool SAL_CALL
execute( const OUString
& sql
) throw(css::sdbc::SQLException
, css::uno::RuntimeException
, std::exception
) override
;
155 virtual css::uno::Reference
< css::sdbc::XConnection
> SAL_CALL
getConnection( ) throw(css::sdbc::SQLException
, css::uno::RuntimeException
, std::exception
) override
;
157 virtual css::uno::Any SAL_CALL
getWarnings( ) throw(css::sdbc::SQLException
, css::uno::RuntimeException
, std::exception
) override
;
158 virtual void SAL_CALL
clearWarnings( ) throw(css::sdbc::SQLException
, css::uno::RuntimeException
, std::exception
) override
;
160 virtual void SAL_CALL
close( ) throw(css::sdbc::SQLException
, css::uno::RuntimeException
, std::exception
) override
;
163 using OPropertySetHelper::getFastPropertyValue
;
166 class OStatement
: public OCommonStatement
,
167 public css::lang::XServiceInfo
170 virtual ~OStatement() override
{}
172 // a constructor, for when the object needs to be returned:
173 explicit OStatement( OConnection
* _pConnection
);
174 DECLARE_SERVICE_INFO();
176 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) throw(css::uno::RuntimeException
, std::exception
) override
;
177 virtual void SAL_CALL
acquire() throw() override
;
178 virtual void SAL_CALL
release() throw() override
;
183 #endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MSTATEMENT_HXX
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */