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 .
24 #include <connectivity/sqlparse.hxx>
25 #include <connectivity/sqliterator.hxx>
27 #include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp>
31 // is used when the source supports keys
32 class OptimisticSet
: public OKeySet
34 ::connectivity::OSQLParser m_aSqlParser
;
35 ::connectivity::OSQLParseTreeIterator m_aSqlIterator
;
37 std::map
<sal_Int32
,sal_Int32
> m_aJoinedColumns
;
38 std::map
<sal_Int32
,sal_Int32
> m_aJoinedKeyColumns
;
40 mutable bool m_bResultSetChanged
;
42 void executeDelete(const ORowSetRow
& _rDeleteRow
,const OUString
& i_sSQL
,const OUString
& i_sTableName
);
43 void fillJoinedColumns_throw(const std::vector
< ::connectivity::TNodePair
>& i_aJoinColumns
);
44 void fillJoinedColumns_throw(const OUString
& i_sLeftColumn
,const OUString
& i_sRightColumn
);
46 virtual void makeNewStatement( ) override
;
47 virtual ~OptimisticSet() override
;
49 OptimisticSet(const css::uno::Reference
< css::uno::XComponentContext
>& _rContext
,
50 const css::uno::Reference
< css::sdbc::XConnection
>& i_xConnection
,
51 const css::uno::Reference
< css::sdb::XSingleSelectQueryAnalyzer
>& _xComposer
,
52 const ORowSetValueVector
& _aParameterValueForCache
,
54 sal_Int32
& o_nRowCount
);
56 // late ctor which can throw exceptions
57 virtual void construct(const css::uno::Reference
< css::sdbc::XResultSet
>& _xDriverSet
,const OUString
& i_sRowSetFilter
) override
;
59 // css::sdbc::XResultSetUpdate
60 virtual void updateRow(const ORowSetRow
& _rInsertRow
,const ORowSetRow
& _rOriginalRow
,const connectivity::OSQLTable
& _xTable
) override
;
61 virtual void deleteRow(const ORowSetRow
& _rInsertRow
,const connectivity::OSQLTable
& _xTable
) override
;
62 virtual void insertRow( const ORowSetRow
& _rInsertRow
,const connectivity::OSQLTable
& _xTable
) override
;
65 virtual bool isResultSetChanged() const override
;
66 virtual void mergeColumnValues(sal_Int32 i_nColumnIndex
,ORowSetValueVector::Vector
& io_aInsertRow
,ORowSetValueVector::Vector
& io_aRow
,std::vector
<sal_Int32
>& o_aChangedColumns
) override
;
67 virtual bool columnValuesUpdated(ORowSetValueVector::Vector
& o_aCachedRow
,const ORowSetValueVector::Vector
& i_aRow
) override
;
68 virtual bool updateColumnValues(const ORowSetValueVector::Vector
& io_aCachedRow
,ORowSetValueVector::Vector
& io_aRow
,const std::vector
<sal_Int32
>& i_aChangedColumns
) override
;
69 virtual void fillMissingValues(ORowSetValueVector::Vector
& io_aRow
) const override
;
71 bool isReadOnly() const { return m_aJoinedKeyColumns
.empty(); }
72 const std::map
<sal_Int32
,sal_Int32
>& getJoinedKeyColumns() const { return m_aJoinedKeyColumns
; }
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */