Line data Source code
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 : #ifndef INCLUDED_DBACCESS_SOURCE_UI_MISC_UPDATEHELPERIMPL_HXX
20 : #define INCLUDED_DBACCESS_SOURCE_UI_MISC_UPDATEHELPERIMPL_HXX
21 :
22 : #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
23 : #include <com/sun/star/sdbc/XRowUpdate.hpp>
24 : #include <com/sun/star/sdbc/XParameters.hpp>
25 : #include <com/sun/star/sdbc/XPreparedStatement.hpp>
26 : #include <com/sun/star/sdbc/XRowSet.hpp>
27 : #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
28 : #include "IUpdateHelper.hxx"
29 :
30 : namespace dbaui
31 : {
32 : class ORowUpdateHelper : public IUpdateHelper
33 : {
34 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate > m_xRowUpdate;
35 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > m_xResultSetUpdate;
36 : public:
37 : ORowUpdateHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _xRowSet)
38 : :m_xRowUpdate(_xRowSet,::com::sun::star::uno::UNO_QUERY)
39 : ,m_xResultSetUpdate(_xRowSet,::com::sun::star::uno::UNO_QUERY)
40 : {
41 : }
42 : virtual ~ORowUpdateHelper() {}
43 : virtual void updateString(sal_Int32 _nPos, const OUString& _sValue) SAL_OVERRIDE
44 : {
45 : m_xRowUpdate->updateString(_nPos, _sValue);
46 : }
47 : virtual void updateDouble(sal_Int32 _nPos,const double& _nValue) SAL_OVERRIDE
48 : {
49 : m_xRowUpdate->updateDouble(_nPos, _nValue);
50 : }
51 : virtual void updateDate(sal_Int32 _nPos,const ::com::sun::star::util::Date& _nValue) SAL_OVERRIDE
52 : {
53 : m_xRowUpdate->updateDate(_nPos, _nValue);
54 : }
55 : virtual void updateTime(sal_Int32 _nPos,const ::com::sun::star::util::Time& _nValue) SAL_OVERRIDE
56 : {
57 : m_xRowUpdate->updateTime(_nPos, _nValue);
58 : }
59 : virtual void updateTimestamp(sal_Int32 _nPos,const ::com::sun::star::util::DateTime& _nValue) SAL_OVERRIDE
60 : {
61 : m_xRowUpdate->updateTimestamp(_nPos, _nValue);
62 : }
63 : virtual void updateInt(sal_Int32 _nPos,const sal_Int32& _nValue) SAL_OVERRIDE
64 : {
65 : m_xRowUpdate->updateInt(_nPos, _nValue);
66 : }
67 : virtual void updateNull(sal_Int32 _nPos, ::sal_Int32) SAL_OVERRIDE
68 : {
69 : m_xRowUpdate->updateNull(_nPos);
70 : }
71 : virtual void moveToInsertRow() SAL_OVERRIDE
72 : {
73 : m_xResultSetUpdate->moveToInsertRow();
74 : }
75 : virtual void insertRow() SAL_OVERRIDE
76 : {
77 : m_xResultSetUpdate->insertRow();
78 : }
79 : };
80 :
81 : class OParameterUpdateHelper : public IUpdateHelper
82 : {
83 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > m_xPrepared;
84 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters > m_xParameters;
85 :
86 : public:
87 0 : OParameterUpdateHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement >& _xPrepared)
88 : :m_xPrepared(_xPrepared)
89 0 : ,m_xParameters(_xPrepared,::com::sun::star::uno::UNO_QUERY)
90 : {
91 0 : }
92 0 : virtual ~OParameterUpdateHelper() {}
93 0 : virtual void updateString(sal_Int32 _nPos, const OUString& _sValue) SAL_OVERRIDE
94 : {
95 0 : m_xParameters->setString(_nPos, _sValue);
96 0 : }
97 0 : virtual void updateDouble(sal_Int32 _nPos,const double& _nValue) SAL_OVERRIDE
98 : {
99 0 : m_xParameters->setDouble(_nPos, _nValue);
100 0 : }
101 0 : virtual void updateDate(sal_Int32 _nPos,const ::com::sun::star::util::Date& _nValue) SAL_OVERRIDE
102 : {
103 0 : m_xParameters->setDate(_nPos, _nValue);
104 0 : }
105 0 : virtual void updateTime(sal_Int32 _nPos,const ::com::sun::star::util::Time& _nValue) SAL_OVERRIDE
106 : {
107 0 : m_xParameters->setTime(_nPos, _nValue);
108 0 : }
109 0 : virtual void updateTimestamp(sal_Int32 _nPos,const ::com::sun::star::util::DateTime& _nValue) SAL_OVERRIDE
110 : {
111 0 : m_xParameters->setTimestamp(_nPos, _nValue);
112 0 : }
113 0 : virtual void updateInt(sal_Int32 _nPos,const sal_Int32& _nValue) SAL_OVERRIDE
114 : {
115 0 : m_xParameters->setInt(_nPos, _nValue);
116 0 : }
117 0 : virtual void updateNull(sal_Int32 _nPos, ::sal_Int32 sqlType) SAL_OVERRIDE
118 : {
119 0 : m_xParameters->setNull(_nPos,sqlType);
120 0 : }
121 0 : virtual void moveToInsertRow() SAL_OVERRIDE
122 : {
123 0 : }
124 0 : virtual void insertRow() SAL_OVERRIDE
125 : {
126 0 : m_xPrepared->executeUpdate();
127 0 : }
128 : };
129 : }
130 :
131 : #endif // INCLUDED_DBACCESS_SOURCE_UI_MISC_UPDATEHELPERIMPL_HXX
132 :
133 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|