merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / misc / UpdateHelperImpl.hxx
blobfacd40212f92b3dc5df3f47dd82b631e6e19a4fd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: UpdateHelperImpl.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef DBAUI_UPDATEHELPERIMPL_HXX
31 #define DBAUI_UPDATEHELPERIMPL_HXX
33 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
34 #include <com/sun/star/sdbc/XRowUpdate.hpp>
35 #include <com/sun/star/sdbc/XParameters.hpp>
36 #include <com/sun/star/sdbc/XPreparedStatement.hpp>
37 #include <com/sun/star/sdbc/XRowSet.hpp>
38 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
39 #include "IUpdateHelper.hxx"
40 #include <rtl/logfile.hxx>
42 namespace dbaui
44 class ORowUpdateHelper : public IUpdateHelper
46 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate > m_xRowUpdate;
47 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > m_xResultSetUpdate; //
48 public:
49 ORowUpdateHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _xRowSet)
50 :m_xRowUpdate(_xRowSet,::com::sun::star::uno::UNO_QUERY)
51 ,m_xResultSetUpdate(_xRowSet,::com::sun::star::uno::UNO_QUERY)
54 virtual ~ORowUpdateHelper() {}
55 virtual void updateString(sal_Int32 _nPos, const ::rtl::OUString& _sValue)
57 m_xRowUpdate->updateString(_nPos, _sValue);
59 virtual void updateDouble(sal_Int32 _nPos,const double& _nValue)
61 m_xRowUpdate->updateDouble(_nPos, _nValue);
63 virtual void updateDate(sal_Int32 _nPos,const ::com::sun::star::util::Date& _nValue)
65 m_xRowUpdate->updateDate(_nPos, _nValue);
67 virtual void updateTime(sal_Int32 _nPos,const ::com::sun::star::util::Time& _nValue)
69 m_xRowUpdate->updateTime(_nPos, _nValue);
71 virtual void updateTimestamp(sal_Int32 _nPos,const ::com::sun::star::util::DateTime& _nValue)
73 m_xRowUpdate->updateTimestamp(_nPos, _nValue);
75 virtual void updateInt(sal_Int32 _nPos,const sal_Int32& _nValue)
77 m_xRowUpdate->updateInt(_nPos, _nValue);
79 virtual void updateNull(sal_Int32 _nPos, ::sal_Int32)
81 m_xRowUpdate->updateNull(_nPos);
83 virtual void moveToInsertRow()
85 m_xResultSetUpdate->moveToInsertRow();
87 virtual void insertRow()
89 m_xResultSetUpdate->insertRow();
93 class OParameterUpdateHelper : public IUpdateHelper
95 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > m_xPrepared;
96 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters > m_xParameters;
98 public:
99 OParameterUpdateHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement >& _xPrepared)
100 :m_xPrepared(_xPrepared)
101 ,m_xParameters(_xPrepared,::com::sun::star::uno::UNO_QUERY)
104 virtual ~OParameterUpdateHelper() {}
105 virtual void updateString(sal_Int32 _nPos, const ::rtl::OUString& _sValue)
107 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateString" );
108 m_xParameters->setString(_nPos, _sValue);
110 virtual void updateDouble(sal_Int32 _nPos,const double& _nValue)
112 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
113 m_xParameters->setDouble(_nPos, _nValue);
115 virtual void updateDate(sal_Int32 _nPos,const ::com::sun::star::util::Date& _nValue)
117 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
118 m_xParameters->setDate(_nPos, _nValue);
120 virtual void updateTime(sal_Int32 _nPos,const ::com::sun::star::util::Time& _nValue)
122 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
123 m_xParameters->setTime(_nPos, _nValue);
125 virtual void updateTimestamp(sal_Int32 _nPos,const ::com::sun::star::util::DateTime& _nValue)
127 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
128 m_xParameters->setTimestamp(_nPos, _nValue);
130 virtual void updateInt(sal_Int32 _nPos,const sal_Int32& _nValue)
132 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateInt" );
133 m_xParameters->setInt(_nPos, _nValue);
135 virtual void updateNull(sal_Int32 _nPos, ::sal_Int32 sqlType)
137 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateNull" );
138 m_xParameters->setNull(_nPos,sqlType);
140 virtual void moveToInsertRow()
143 virtual void insertRow()
145 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::insertRow" );
146 m_xPrepared->executeUpdate();
151 #endif // DBAUI_UPDATEHELPERIMPL_HXX