Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / dbaccess / source / ui / misc / UpdateHelperImpl.hxx
blobcff3c9f11a72162e9eecb45ae6f0412a2d520b82
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef DBAUI_UPDATEHELPERIMPL_HXX
29 #define DBAUI_UPDATEHELPERIMPL_HXX
31 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
32 #include <com/sun/star/sdbc/XRowUpdate.hpp>
33 #include <com/sun/star/sdbc/XParameters.hpp>
34 #include <com/sun/star/sdbc/XPreparedStatement.hpp>
35 #include <com/sun/star/sdbc/XRowSet.hpp>
36 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
37 #include "IUpdateHelper.hxx"
38 #include <rtl/logfile.hxx>
40 namespace dbaui
42 class ORowUpdateHelper : public IUpdateHelper
44 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate > m_xRowUpdate;
45 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > m_xResultSetUpdate; //
46 public:
47 ORowUpdateHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _xRowSet)
48 :m_xRowUpdate(_xRowSet,::com::sun::star::uno::UNO_QUERY)
49 ,m_xResultSetUpdate(_xRowSet,::com::sun::star::uno::UNO_QUERY)
52 virtual ~ORowUpdateHelper() {}
53 virtual void updateString(sal_Int32 _nPos, const ::rtl::OUString& _sValue)
55 m_xRowUpdate->updateString(_nPos, _sValue);
57 virtual void updateDouble(sal_Int32 _nPos,const double& _nValue)
59 m_xRowUpdate->updateDouble(_nPos, _nValue);
61 virtual void updateDate(sal_Int32 _nPos,const ::com::sun::star::util::Date& _nValue)
63 m_xRowUpdate->updateDate(_nPos, _nValue);
65 virtual void updateTime(sal_Int32 _nPos,const ::com::sun::star::util::Time& _nValue)
67 m_xRowUpdate->updateTime(_nPos, _nValue);
69 virtual void updateTimestamp(sal_Int32 _nPos,const ::com::sun::star::util::DateTime& _nValue)
71 m_xRowUpdate->updateTimestamp(_nPos, _nValue);
73 virtual void updateInt(sal_Int32 _nPos,const sal_Int32& _nValue)
75 m_xRowUpdate->updateInt(_nPos, _nValue);
77 virtual void updateNull(sal_Int32 _nPos, ::sal_Int32)
79 m_xRowUpdate->updateNull(_nPos);
81 virtual void moveToInsertRow()
83 m_xResultSetUpdate->moveToInsertRow();
85 virtual void insertRow()
87 m_xResultSetUpdate->insertRow();
91 class OParameterUpdateHelper : public IUpdateHelper
93 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > m_xPrepared;
94 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters > m_xParameters;
96 public:
97 OParameterUpdateHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement >& _xPrepared)
98 :m_xPrepared(_xPrepared)
99 ,m_xParameters(_xPrepared,::com::sun::star::uno::UNO_QUERY)
102 virtual ~OParameterUpdateHelper() {}
103 virtual void updateString(sal_Int32 _nPos, const ::rtl::OUString& _sValue)
105 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateString" );
106 m_xParameters->setString(_nPos, _sValue);
108 virtual void updateDouble(sal_Int32 _nPos,const double& _nValue)
110 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
111 m_xParameters->setDouble(_nPos, _nValue);
113 virtual void updateDate(sal_Int32 _nPos,const ::com::sun::star::util::Date& _nValue)
115 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
116 m_xParameters->setDate(_nPos, _nValue);
118 virtual void updateTime(sal_Int32 _nPos,const ::com::sun::star::util::Time& _nValue)
120 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
121 m_xParameters->setTime(_nPos, _nValue);
123 virtual void updateTimestamp(sal_Int32 _nPos,const ::com::sun::star::util::DateTime& _nValue)
125 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
126 m_xParameters->setTimestamp(_nPos, _nValue);
128 virtual void updateInt(sal_Int32 _nPos,const sal_Int32& _nValue)
130 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateInt" );
131 m_xParameters->setInt(_nPos, _nValue);
133 virtual void updateNull(sal_Int32 _nPos, ::sal_Int32 sqlType)
135 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateNull" );
136 m_xParameters->setNull(_nPos,sqlType);
138 virtual void moveToInsertRow()
141 virtual void insertRow()
143 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::insertRow" );
144 m_xPrepared->executeUpdate();
149 #endif // DBAUI_UPDATEHELPERIMPL_HXX
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */