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 .
22 #include "MacabConnection.hxx"
23 #include "MacabHeader.hxx"
24 #include <connectivity/sqliterator.hxx>
25 #include <connectivity/sqlparse.hxx>
26 #include <com/sun/star/sdbc/XStatement.hpp>
27 #include <com/sun/star/util/XCancellable.hpp>
28 #include <cppuhelper/compbase.hxx>
29 #include <cppuhelper/implbase.hxx>
30 #include <cppuhelper/basemutex.hxx>
31 #include <comphelper/proparrhlp.hxx>
33 namespace connectivity::macab
35 typedef ::cppu::WeakComponentImplHelper
< css::sdbc::XStatement
,
36 css::sdbc::XWarningsSupplier
,
37 css::util::XCancellable
,
38 css::sdbc::XCloseable
> MacabCommonStatement_BASE
;
41 // Class MacabCommonStatement
42 // is a base class for the normal statement and for the prepared statement
44 class MacabCommonStatement
: public cppu::BaseMutex
,
45 public MacabCommonStatement_BASE
,
46 public ::cppu::OPropertySetHelper
,
47 public comphelper::OPropertyArrayUsageHelper
<MacabCommonStatement
>
50 css::sdbc::SQLWarning m_aLastWarning
;
53 connectivity::OSQLParser m_aParser
;
54 connectivity::OSQLParseTreeIterator m_aSQLIterator
;
55 connectivity::OSQLParseNode
* m_pParseTree
;
56 MacabConnection
* m_pConnection
; // The owning Connection object
57 MacabHeader
* m_pHeader
; // The header of the address book on which to run queries (provided by m_pConnection)
58 css::uno::WeakReference
< css::sdbc::XResultSet
> m_xResultSet
; // The last ResultSet created
62 /// @throws css::sdbc::SQLException
63 class MacabCondition
*analyseWhereClause(
64 const OSQLParseNode
*pParseNode
) const;
65 /// @throws css::sdbc::SQLException
66 class MacabOrder
*analyseOrderByClause(
67 const OSQLParseNode
*pParseNode
) const;
68 OUString
getTableName( ) const;
69 /// @throws css::sdbc::SQLException
70 void setMacabFields(class MacabResultSet
*pResult
) const;
71 /// @throws css::sdbc::SQLException
72 void selectRecords(MacabResultSet
*pResult
) const;
73 /// @throws css::sdbc::SQLException
74 void sortRecords(MacabResultSet
*pResult
) const;
76 // OPropertyArrayUsageHelper
77 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper() const override
;
80 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
81 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
82 css::uno::Any
& rConvertedValue
,
83 css::uno::Any
& rOldValue
,
85 const css::uno::Any
& rValue
) override
;
86 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
88 const css::uno::Any
& rValue
) override
;
89 virtual void SAL_CALL
getFastPropertyValue(
90 css::uno::Any
& rValue
,
91 sal_Int32 nHandle
) const override
;
93 /// @throws css::sdbc::SQLException
94 virtual void resetParameters() const;
95 /// @throws css::sdbc::SQLException
96 virtual void getNextParameter(OUString
&rParameter
) const;
97 virtual ~MacabCommonStatement() override
;
100 using MacabCommonStatement_BASE::rBHelper
;
102 explicit MacabCommonStatement(MacabConnection
*_pConnection
);
103 using MacabCommonStatement_BASE::operator css::uno::Reference
< css::uno::XInterface
>;
106 using MacabCommonStatement_BASE::disposing
;
109 virtual void SAL_CALL
release() noexcept override
;
110 virtual void SAL_CALL
acquire() noexcept override
;
111 virtual css::uno::Any SAL_CALL
queryInterface(
112 const css::uno::Type
& rType
116 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes(
120 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo(
124 virtual css::uno::Reference
< css::sdbc::XResultSet
> SAL_CALL
executeQuery(
125 const OUString
& sql
) override
;
126 virtual sal_Int32 SAL_CALL
executeUpdate(
127 const OUString
& sql
) override
;
128 virtual sal_Bool SAL_CALL
execute(
129 const OUString
& sql
) override
;
130 virtual css::uno::Reference
< css::sdbc::XConnection
> SAL_CALL
getConnection(
134 virtual css::uno::Any SAL_CALL
getWarnings(
136 virtual void SAL_CALL
clearWarnings(
140 virtual void SAL_CALL
cancel(
144 virtual void SAL_CALL
close(
148 MacabConnection
* getOwnConnection() const { return m_pConnection
; }
152 // Class MacabStatement
154 typedef ::cppu::ImplInheritanceHelper
<
155 MacabCommonStatement
, css::lang::XServiceInfo
> MacabStatement_BASE
;
157 class MacabStatement
: public MacabStatement_BASE
160 virtual ~MacabStatement() override
{ }
163 explicit MacabStatement(MacabConnection
* _pConnection
);
164 DECLARE_SERVICE_INFO();
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */