calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / dbaccess / source / core / api / WrappedResultSet.cxx
blob09d70826bdfb207dadae2f34261ba6d7e4fc8077
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "WrappedResultSet.hxx"
21 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
23 using namespace dbaccess;
24 using namespace ::connectivity;
25 using namespace ::com::sun::star::uno;
26 using namespace ::com::sun::star::beans;
27 using namespace ::com::sun::star::sdbc;
28 using namespace ::com::sun::star::sdbcx;
29 using namespace ::com::sun::star::container;
30 using namespace ::com::sun::star::lang;
31 using namespace ::osl;
33 void WrappedResultSet::construct(const Reference< XResultSet>& _xDriverSet,const OUString& i_sRowSetFilter)
35 OCacheSet::construct(_xDriverSet,i_sRowSetFilter);
36 m_xUpd.set(_xDriverSet,UNO_QUERY_THROW);
37 m_xRowLocate.set(_xDriverSet,UNO_QUERY_THROW);
38 m_xUpdRow.set(_xDriverSet,UNO_QUERY_THROW);
41 void WrappedResultSet::reset(const Reference< XResultSet>& _xDriverSet)
43 construct(_xDriverSet, m_sRowSetFilter);
46 Any WrappedResultSet::getBookmark()
48 if ( m_xRowLocate.is() )
50 return m_xRowLocate->getBookmark( );
52 return Any(m_xDriverSet->getRow());
55 bool WrappedResultSet::moveToBookmark( const Any& bookmark )
57 return m_xRowLocate->moveToBookmark( bookmark );
60 sal_Int32 WrappedResultSet::compareBookmarks( const Any& _first, const Any& _second )
62 return m_xRowLocate->compareBookmarks( _first,_second );
65 bool WrappedResultSet::hasOrderedBookmarks( )
67 return m_xRowLocate->hasOrderedBookmarks();
70 sal_Int32 WrappedResultSet::hashBookmark( const Any& bookmark )
72 return m_xRowLocate->hashBookmark(bookmark);
75 void WrappedResultSet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& /*_xTable*/ )
77 m_xUpd->moveToInsertRow();
78 sal_Int32 i = 1;
79 connectivity::ORowVector< ORowSetValue > ::Vector::const_iterator aEnd = _rInsertRow->end();
80 for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->begin()+1;aIter != aEnd;++aIter,++i)
82 aIter->setSigned(m_aSignedFlags[i-1]);
83 updateColumn(i,m_xUpdRow,*aIter);
85 m_xUpd->insertRow();
86 (*_rInsertRow->begin()) = getBookmark();
89 void WrappedResultSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOriginalRow,const connectivity::OSQLTable& /*_xTable*/ )
91 sal_Int32 i = 1;
92 connectivity::ORowVector< ORowSetValue > ::Vector::const_iterator aOrgIter = _rOriginalRow->begin()+1;
93 connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->end();
94 for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->begin()+1;aIter != aEnd;++aIter,++i,++aOrgIter)
96 aIter->setSigned(aOrgIter->isSigned());
97 updateColumn(i,m_xUpdRow,*aIter);
99 m_xUpd->updateRow();
102 void WrappedResultSet::deleteRow(const ORowSetRow& /*_rDeleteRow*/ ,const connectivity::OSQLTable& /*_xTable*/ )
104 m_xUpd->deleteRow();
107 void WrappedResultSet::updateColumn(sal_Int32 nPos, const Reference< XRowUpdate >& _xParameter, const ORowSetValue& _rValue)
109 if(!(_rValue.isBound() && _rValue.isModified()))
110 return;
112 if(_rValue.isNull())
113 _xParameter->updateNull(nPos);
114 else
117 switch(_rValue.getTypeKind())
119 case DataType::DECIMAL:
120 case DataType::NUMERIC:
121 _xParameter->updateNumericObject(nPos,_rValue.makeAny(),m_xSetMetaData->getScale(nPos));
122 break;
123 case DataType::CHAR:
124 case DataType::VARCHAR:
125 _xParameter->updateString(nPos,_rValue.getString());
126 break;
127 case DataType::BIGINT:
128 if ( _rValue.isSigned() )
129 _xParameter->updateLong(nPos,_rValue.getLong());
130 else
131 _xParameter->updateString(nPos,_rValue.getString());
132 break;
133 case DataType::BIT:
134 case DataType::BOOLEAN:
135 _xParameter->updateBoolean(nPos,_rValue.getBool());
136 break;
137 case DataType::TINYINT:
138 if ( _rValue.isSigned() )
139 _xParameter->updateByte(nPos,_rValue.getInt8());
140 else
141 _xParameter->updateShort(nPos,_rValue.getInt16());
142 break;
143 case DataType::SMALLINT:
144 if ( _rValue.isSigned() )
145 _xParameter->updateShort(nPos,_rValue.getInt16());
146 else
147 _xParameter->updateInt(nPos,_rValue.getInt32());
148 break;
149 case DataType::INTEGER:
150 if ( _rValue.isSigned() )
151 _xParameter->updateInt(nPos,_rValue.getInt32());
152 else
153 _xParameter->updateLong(nPos,_rValue.getLong());
154 break;
155 case DataType::FLOAT:
156 _xParameter->updateFloat(nPos,_rValue.getFloat());
157 break;
158 case DataType::DOUBLE:
159 case DataType::REAL:
160 _xParameter->updateDouble(nPos,_rValue.getDouble());
161 break;
162 case DataType::DATE:
163 _xParameter->updateDate(nPos,_rValue.getDate());
164 break;
165 case DataType::TIME:
166 _xParameter->updateTime(nPos,_rValue.getTime());
167 break;
168 case DataType::TIMESTAMP:
169 _xParameter->updateTimestamp(nPos,_rValue.getDateTime());
170 break;
171 case DataType::BINARY:
172 case DataType::VARBINARY:
173 case DataType::LONGVARBINARY:
174 _xParameter->updateBytes(nPos,_rValue.getSequence());
175 break;
176 case DataType::BLOB:
177 case DataType::CLOB:
178 _xParameter->updateObject(nPos,_rValue.getAny());
179 break;
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */