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