1*2e2212a7SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2e2212a7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2e2212a7SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2e2212a7SAndrew Rist * distributed with this work for additional information 6*2e2212a7SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2e2212a7SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2e2212a7SAndrew Rist * "License"); you may not use this file except in compliance 9*2e2212a7SAndrew Rist * with the License. You may obtain a copy of the License at 10*2e2212a7SAndrew Rist * 11*2e2212a7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2e2212a7SAndrew Rist * 13*2e2212a7SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2e2212a7SAndrew Rist * software distributed under the License is distributed on an 15*2e2212a7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2e2212a7SAndrew Rist * KIND, either express or implied. See the License for the 17*2e2212a7SAndrew Rist * specific language governing permissions and limitations 18*2e2212a7SAndrew Rist * under the License. 19*2e2212a7SAndrew Rist * 20*2e2212a7SAndrew Rist *************************************************************/ 21*2e2212a7SAndrew Rist 22*2e2212a7SAndrew Rist 23cdf0e10cSrcweir #ifndef DBAUI_UPDATEHELPERIMPL_HXX 24cdf0e10cSrcweir #define DBAUI_UPDATEHELPERIMPL_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetUpdate.hpp> 27cdf0e10cSrcweir #include <com/sun/star/sdbc/XRowUpdate.hpp> 28cdf0e10cSrcweir #include <com/sun/star/sdbc/XParameters.hpp> 29cdf0e10cSrcweir #include <com/sun/star/sdbc/XPreparedStatement.hpp> 30cdf0e10cSrcweir #include <com/sun/star/sdbc/XRowSet.hpp> 31cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetMetaData.hpp> 32cdf0e10cSrcweir #include "IUpdateHelper.hxx" 33cdf0e10cSrcweir #include <rtl/logfile.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir namespace dbaui 36cdf0e10cSrcweir { 37cdf0e10cSrcweir class ORowUpdateHelper : public IUpdateHelper 38cdf0e10cSrcweir { 39cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate > m_xRowUpdate; 40cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > m_xResultSetUpdate; // 41cdf0e10cSrcweir public: ORowUpdateHelper(const::com::sun::star::uno::Reference<::com::sun::star::sdbc::XRowSet> & _xRowSet)42cdf0e10cSrcweir ORowUpdateHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _xRowSet) 43cdf0e10cSrcweir :m_xRowUpdate(_xRowSet,::com::sun::star::uno::UNO_QUERY) 44cdf0e10cSrcweir ,m_xResultSetUpdate(_xRowSet,::com::sun::star::uno::UNO_QUERY) 45cdf0e10cSrcweir { 46cdf0e10cSrcweir } ~ORowUpdateHelper()47cdf0e10cSrcweir virtual ~ORowUpdateHelper() {} updateString(sal_Int32 _nPos,const::rtl::OUString & _sValue)48cdf0e10cSrcweir virtual void updateString(sal_Int32 _nPos, const ::rtl::OUString& _sValue) 49cdf0e10cSrcweir { 50cdf0e10cSrcweir m_xRowUpdate->updateString(_nPos, _sValue); 51cdf0e10cSrcweir } updateDouble(sal_Int32 _nPos,const double & _nValue)52cdf0e10cSrcweir virtual void updateDouble(sal_Int32 _nPos,const double& _nValue) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir m_xRowUpdate->updateDouble(_nPos, _nValue); 55cdf0e10cSrcweir } updateDate(sal_Int32 _nPos,const::com::sun::star::util::Date & _nValue)56cdf0e10cSrcweir virtual void updateDate(sal_Int32 _nPos,const ::com::sun::star::util::Date& _nValue) 57cdf0e10cSrcweir { 58cdf0e10cSrcweir m_xRowUpdate->updateDate(_nPos, _nValue); 59cdf0e10cSrcweir } updateTime(sal_Int32 _nPos,const::com::sun::star::util::Time & _nValue)60cdf0e10cSrcweir virtual void updateTime(sal_Int32 _nPos,const ::com::sun::star::util::Time& _nValue) 61cdf0e10cSrcweir { 62cdf0e10cSrcweir m_xRowUpdate->updateTime(_nPos, _nValue); 63cdf0e10cSrcweir } updateTimestamp(sal_Int32 _nPos,const::com::sun::star::util::DateTime & _nValue)64cdf0e10cSrcweir virtual void updateTimestamp(sal_Int32 _nPos,const ::com::sun::star::util::DateTime& _nValue) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir m_xRowUpdate->updateTimestamp(_nPos, _nValue); 67cdf0e10cSrcweir } updateInt(sal_Int32 _nPos,const sal_Int32 & _nValue)68cdf0e10cSrcweir virtual void updateInt(sal_Int32 _nPos,const sal_Int32& _nValue) 69cdf0e10cSrcweir { 70cdf0e10cSrcweir m_xRowUpdate->updateInt(_nPos, _nValue); 71cdf0e10cSrcweir } updateNull(sal_Int32 _nPos,::sal_Int32)72cdf0e10cSrcweir virtual void updateNull(sal_Int32 _nPos, ::sal_Int32) 73cdf0e10cSrcweir { 74cdf0e10cSrcweir m_xRowUpdate->updateNull(_nPos); 75cdf0e10cSrcweir } moveToInsertRow()76cdf0e10cSrcweir virtual void moveToInsertRow() 77cdf0e10cSrcweir { 78cdf0e10cSrcweir m_xResultSetUpdate->moveToInsertRow(); 79cdf0e10cSrcweir } insertRow()80cdf0e10cSrcweir virtual void insertRow() 81cdf0e10cSrcweir { 82cdf0e10cSrcweir m_xResultSetUpdate->insertRow(); 83cdf0e10cSrcweir } 84cdf0e10cSrcweir }; 85cdf0e10cSrcweir 86cdf0e10cSrcweir class OParameterUpdateHelper : public IUpdateHelper 87cdf0e10cSrcweir { 88cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > m_xPrepared; 89cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters > m_xParameters; 90cdf0e10cSrcweir 91cdf0e10cSrcweir public: OParameterUpdateHelper(const::com::sun::star::uno::Reference<::com::sun::star::sdbc::XPreparedStatement> & _xPrepared)92cdf0e10cSrcweir OParameterUpdateHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement >& _xPrepared) 93cdf0e10cSrcweir :m_xPrepared(_xPrepared) 94cdf0e10cSrcweir ,m_xParameters(_xPrepared,::com::sun::star::uno::UNO_QUERY) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir } ~OParameterUpdateHelper()97cdf0e10cSrcweir virtual ~OParameterUpdateHelper() {} updateString(sal_Int32 _nPos,const::rtl::OUString & _sValue)98cdf0e10cSrcweir virtual void updateString(sal_Int32 _nPos, const ::rtl::OUString& _sValue) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateString" ); 101cdf0e10cSrcweir m_xParameters->setString(_nPos, _sValue); 102cdf0e10cSrcweir } updateDouble(sal_Int32 _nPos,const double & _nValue)103cdf0e10cSrcweir virtual void updateDouble(sal_Int32 _nPos,const double& _nValue) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" ); 106cdf0e10cSrcweir m_xParameters->setDouble(_nPos, _nValue); 107cdf0e10cSrcweir } updateDate(sal_Int32 _nPos,const::com::sun::star::util::Date & _nValue)108cdf0e10cSrcweir virtual void updateDate(sal_Int32 _nPos,const ::com::sun::star::util::Date& _nValue) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" ); 111cdf0e10cSrcweir m_xParameters->setDate(_nPos, _nValue); 112cdf0e10cSrcweir } updateTime(sal_Int32 _nPos,const::com::sun::star::util::Time & _nValue)113cdf0e10cSrcweir virtual void updateTime(sal_Int32 _nPos,const ::com::sun::star::util::Time& _nValue) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" ); 116cdf0e10cSrcweir m_xParameters->setTime(_nPos, _nValue); 117cdf0e10cSrcweir } updateTimestamp(sal_Int32 _nPos,const::com::sun::star::util::DateTime & _nValue)118cdf0e10cSrcweir virtual void updateTimestamp(sal_Int32 _nPos,const ::com::sun::star::util::DateTime& _nValue) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" ); 121cdf0e10cSrcweir m_xParameters->setTimestamp(_nPos, _nValue); 122cdf0e10cSrcweir } updateInt(sal_Int32 _nPos,const sal_Int32 & _nValue)123cdf0e10cSrcweir virtual void updateInt(sal_Int32 _nPos,const sal_Int32& _nValue) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateInt" ); 126cdf0e10cSrcweir m_xParameters->setInt(_nPos, _nValue); 127cdf0e10cSrcweir } updateNull(sal_Int32 _nPos,::sal_Int32 sqlType)128cdf0e10cSrcweir virtual void updateNull(sal_Int32 _nPos, ::sal_Int32 sqlType) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateNull" ); 131cdf0e10cSrcweir m_xParameters->setNull(_nPos,sqlType); 132cdf0e10cSrcweir } moveToInsertRow()133cdf0e10cSrcweir virtual void moveToInsertRow() 134cdf0e10cSrcweir { 135cdf0e10cSrcweir } insertRow()136cdf0e10cSrcweir virtual void insertRow() 137cdf0e10cSrcweir { 138cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::insertRow" ); 139cdf0e10cSrcweir m_xPrepared->executeUpdate(); 140cdf0e10cSrcweir } 141cdf0e10cSrcweir }; 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir #endif // DBAUI_UPDATEHELPERIMPL_HXX 145cdf0e10cSrcweir 146