2010-10-12 15:59:03 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-14 17:39:53 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2006-09-17 05:32:31 +00:00
|
|
|
|
2010-09-22 11:08:30 +02:00
|
|
|
#include "BookmarkSet.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
#include "CRowSetColumn.hxx"
|
2010-09-22 11:08:30 +02:00
|
|
|
#include "CRowSetDataColumn.hxx"
|
|
|
|
#include "KeySet.hxx"
|
|
|
|
#include "OptimisticSet.hxx"
|
2006-01-25 12:43:29 +00:00
|
|
|
#include "RowSetBase.hxx"
|
2010-09-22 11:08:30 +02:00
|
|
|
#include "RowSetCache.hxx"
|
|
|
|
#include "StaticSet.hxx"
|
|
|
|
#include "WrappedResultSet.hxx"
|
|
|
|
#include "core_resource.hrc"
|
|
|
|
#include "core_resource.hxx"
|
|
|
|
#include "dbastrings.hrc"
|
|
|
|
|
|
|
|
#include <com/sun/star/sdbc/ColumnValue.hpp>
|
|
|
|
#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/CompareBookmark.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/KeyType.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/Privilege.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
|
|
|
|
|
|
|
|
#include <comphelper/extract.hxx>
|
|
|
|
#include <comphelper/property.hxx>
|
|
|
|
#include <comphelper/seqstream.hxx>
|
|
|
|
#include <comphelper/uno3.hxx>
|
2000-10-25 06:32:52 +00:00
|
|
|
#include <connectivity/dbexception.hxx>
|
2010-02-15 09:53:53 +01:00
|
|
|
#include <connectivity/dbtools.hxx>
|
2006-08-15 09:42:22 +00:00
|
|
|
#include <connectivity/sqliterator.hxx>
|
2010-09-22 11:08:30 +02:00
|
|
|
#include <connectivity/sqlnode.hxx>
|
|
|
|
#include <connectivity/sqlparse.hxx>
|
2005-09-23 11:03:25 +00:00
|
|
|
#include <tools/debug.hxx>
|
2010-09-22 11:08:30 +02:00
|
|
|
#include <tools/diagnose_ex.h>
|
2011-02-03 00:33:36 +01:00
|
|
|
#include <osl/diagnose.h>
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-10-12 14:36:42 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
using namespace dbaccess;
|
2000-10-25 06:32:52 +00:00
|
|
|
using namespace dbtools;
|
2000-09-18 23:16:46 +00:00
|
|
|
using namespace connectivity;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdb;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::cppu;
|
|
|
|
using namespace ::osl;
|
|
|
|
|
2006-07-26 06:46:13 +00:00
|
|
|
#define CHECK_MATRIX_POS(M) OSL_ENSURE(((M) >= static_cast<ORowSetMatrix::difference_type>(0)) && ((M) < static_cast<sal_Int32>(m_pMatrix->size())),"Position is invalid!")
|
|
|
|
|
2012-06-04 17:31:25 +02:00
|
|
|
// This class calls m_pCacheSet->FOO_checked(..., sal_False)
|
|
|
|
// (where FOO is absolute, last, previous)
|
|
|
|
// when it does not immediately care about the values in the row's columns.
|
|
|
|
// As a corollary, m_pCacheSet may be left in an inconsistent state,
|
|
|
|
// and all ->fillFOO calls (and ->getFOO) may fail or give wrong results,
|
|
|
|
// until m_pCacheSet is moved (or refreshed) again.
|
|
|
|
// So always make sure m_pCacheSet is moved or refreshed before accessing column values.
|
|
|
|
|
2005-09-23 11:03:25 +00:00
|
|
|
DBG_NAME(ORowSetCache)
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
|
2004-11-17 13:42:39 +00:00
|
|
|
const Reference< XSingleSelectQueryAnalyzer >& _xAnalyzer,
|
2007-11-21 14:33:03 +00:00
|
|
|
const ::comphelper::ComponentContext& _rContext,
|
2000-10-17 09:19:03 +00:00
|
|
|
const ::rtl::OUString& _rUpdateTableName,
|
|
|
|
sal_Bool& _bModified,
|
CWS-TOOLING: integrate CWS dba32c
2009-06-29 20:53:25 +0200 fs r273484 : #i103138# Rectangle conversion
2009-06-29 20:51:50 +0200 fs r273483 : #i103138# yet more refactoring, now also setting the proper zoom level at the proper point in time
2009-06-29 13:40:26 +0200 fs r273470 : added svn:ignore to ignore output paths
2009-06-29 10:08:54 +0200 fs r273455 : #i103138#
refactored the code for positioning/zooming the control
Basically, we now allow adjustControlGeometry_throw (formerly known as positionControl_throw and setControlZoom) to
take an additional ViewTransformation parameter, describing the transformation to obtain the actual
control position/size. Consequently, positionControl itself also allows for a ViewTransformation parameter.
This has become necessary since during painting, the device which we created our control for might not necessarily
have a proper MapMode set. In this case, if we would use this map mode for calculating the control's position/size,
this would lead to wrong results.
Note that this problem was introduced by the fix for #i101398#: During the fix, we postponed the control creation
to a later time (when it is really needed). At this later time, the MapMode at the device is broken, at the earlier
time where we formerly crearted the control (createPrimitive2DSequence), it is not yet broken.
Whether or not the MapMode is defined as "broken" might depend on one's point of view, however ...
I consider it broken, since:
- we need the map mode to obtain the proper zoom level, which is to be forwarded to the control
- there are scenarios where the MapMode is *not* set to MAP_PIXEL (in those scenarios, everything works
fine), and there are scenarios where it *is* set to MAP_PIXEL (in those the bug 103138 appears).
It somehow feels wrong that one cannot rely on the device's map mode this way, but on the other hand
one has no possibility to obtain the current zoom by other means.
Note that one issue (still to be submitted) is left: In the page pane of a Draw/Impress document, controls
have a wrong text size. This is because in this pane, the above-mentioned "broken" map mode is used,
which means the controls have a zoom of "1:1" set, which is wrong here.
2009-06-25 13:41:35 +0200 msc r273380 : #100000# the tabs changed die to new properties
2009-06-24 12:42:40 +0200 msc r273330 : #102082# remove issue warning
2009-06-22 10:43:14 +0200 fs r273201 : createPrimitive2DSequence: care for being disposed
2009-06-18 12:35:13 +0200 oj r273109 : #i102305# make nooptfiles for gcc
2009-06-17 12:14:37 +0200 oj r273056 : #i102305# fix for linux
2009-06-17 07:20:22 +0200 oj r273046 : #i102305# move ValueTransfer into the for loop to avoid a crash under Linux
2009-06-17 07:17:28 +0200 oj r273045 : #i102305# use varchar
2009-06-15 14:11:27 +0200 fs r272983 : added since tag
2009-06-15 12:11:39 +0200 oj r272973 : #i102305# SAL_DLLPUBLIC_EXPORT inserted
2009-06-15 11:08:53 +0200 fs r272969 : #i10000#
2009-06-15 09:25:13 +0200 fs r272963 : merging fix for P1 issue #i102701#
2009-06-11 11:31:24 +0200 fs r272858 : #i10000# copied the fix which before the rebase was done in ../dialog/macropg.src
2009-06-11 09:38:14 +0200 fs r272846 : CWS-TOOLING: rebase CWS dba32c to trunk@272827 (milestone: DEV300:m50)
2009-06-02 09:53:10 +0200 fs r272483 : #i10000#
2009-05-29 15:55:03 +0200 fs r272465 : #i100818#
2009-05-29 12:58:43 +0200 fs r272452 : don't apply comphelper::getString on possibly VOID any
2009-05-29 10:38:35 +0200 oj r272437 : #i101519# handle where condition
2009-05-29 09:53:39 +0200 fs r272434 : #i100818# call into releaseStubs /without/ locked GlobalMutex
2009-05-28 07:53:44 +0200 oj r272375 : #i101369# parse tree changed
2009-05-27 14:53:36 +0200 fs r272347 : #i10000#
2009-05-27 09:29:15 +0200 oj r272327 : #i101626# check for double before hard cast
2009-05-27 09:13:58 +0200 oj r272326 : #i101626# handle void correctly
2009-05-27 08:04:39 +0200 oj r272321 : #i102256# wrong method signature used
2009-05-27 07:55:52 +0200 oj r272320 : #i101519# look up parameter typ if used in function
2009-05-27 06:49:07 +0200 oj r272319 : #i101519# set parameter from rowset as well
2009-05-26 13:30:56 +0200 oj r272297 : #i101987# impl XBatchExecution
2009-05-26 12:44:34 +0200 oj r272293 : #i101700# check if group is not set
2009-05-26 12:16:53 +0200 oj r272290 : #i101369# resolved some reduce7reduce problems with boolean_term and search_condition
2009-05-26 12:12:42 +0200 oj r272289 : #i101369# fix for or on one line criteria
2009-05-25 16:02:25 +0200 fs r272257 : #i999704# +PROPERTY_MOUSE_WHEEL_BEHAVIOR
2009-05-25 16:01:55 +0200 fs r272256 : merging the changes from CWS dba32b herein
2009-05-25 15:49:57 +0200 fs r272254 : #i999704#
2009-05-25 15:32:57 +0200 fs r272252 : #i99704# grid columns also to respect the MouseWheelBehavior property
2009-05-25 15:23:43 +0200 fs r272251 : don't pass empty Anys to ::comphelper::getString
2009-05-25 14:48:43 +0200 fs r272248 : merged changes from CWS dba32b herein
2009-05-25 14:44:40 +0200 fs r272247 : #i99704# support new MouseWheelBehavior property
2009-05-25 14:43:18 +0200 fs r272246 : #i99704# WheelWithoutFocus (peer property) superseded by MouseWheelBehavior (model property)
2009-05-25 14:41:03 +0200 fs r272245 : #i99704# no need to set the mouse wheel behavior at the peer, this is now a model property, having the right default
2009-05-25 14:39:31 +0200 fs r272243 : removed dead import
2009-05-25 14:35:36 +0200 fs r272242 : the new EnableVisible doesn't make sense for grid columns
2009-05-25 14:34:33 +0200 fs r272241 : #i99704# +MouseWheelBehavior - allow to enable/disable the mouse wheel for the control, or make it focus-dependent
2009-05-25 14:26:11 +0200 fs r272240 : #i99704# change MouseSettings wheel flag (NoWheelActionWithoutFocus) to a three-state option, allowing to completely ignore the mouse wheel
2009-05-23 21:35:59 +0200 fs r272213 : localize 'sub component opened/closed' event
2009-05-22 21:42:47 +0200 fs r272211 : #i102003#
2009-05-22 21:42:20 +0200 fs r272210 : grammar
2009-05-22 21:36:10 +0200 fs r272209 : #i102140# load only once, not twice, and show error messages during loading (and during any form action, that is) asynchronously
2009-05-22 21:35:11 +0200 fs r272208 : #i102140# +clear
2009-05-22 14:50:30 +0200 fs r272194 : #i102139# for newly created DB docs, set the MacroExecutionMode to USE_CONFIG
2009-05-22 12:03:42 +0200 fs r272180 : #i88878#
provided by noel.power@novell.com
implement a visibility property (EnableVisible) for toolkit controls, and usage in forms and UNO dialogs
2009-05-15 15:37:31 +0200 fs r271942 : #i100671# corrected some @since tags, so autodoc has better chances of correctly reading them
2009-05-15 15:33:11 +0200 fs r271940 : don't call comphelper::getFOO for VOID values
2009-05-15 15:08:31 +0200 fs r271937 : includes
2009-05-15 13:39:22 +0200 fs r271934 : #i101398# createPrimitive2DSequence: when we already have a control, use the old code. In particular, call positionControlForPaint
2009-05-15 12:33:48 +0200 fs r271933 : make the geometry a part of the ControlPrimitive2D's identity
2009-05-15 10:15:44 +0200 fs r271928 : #i10000#
2009-05-14 20:55:38 +0200 fs r271921 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:55:31 +0200 fs r271920 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:23:23 +0200 fs r271919 : #i101622#
2009-05-14 16:04:38 +0200 fs r271898 : don't use comphelper::getInt32 on voids
2009-05-14 16:04:12 +0200 fs r271897 : merge fix for issue whose number just slipped my memory ... (originally fixed in CWS dba32b)
2009-05-14 15:36:55 +0200 fs r271895 : merging changes from DEV300:m48
2009-05-07 14:43:19 +0200 fs r271670 : #i101477#
2009-05-07 14:37:30 +0200 fs r271668 : #i101477#
2009-05-07 09:27:30 +0200 oj r271628 : #i101343# remove pch
2009-05-06 09:36:02 +0200 fs r271568 : getFoo: diagnostics
2009-05-04 09:23:06 +0200 oj r271438 : CWS-TOOLING: rebase CWS dba32c to trunk@271427 (milestone: DEV300:m47)
2009-04-29 23:18:13 +0200 fs r271394 : #i101398# use a dedicated 2DPrimitive for UNO Controls, which is able to provide the B2DRange *without* actually creating the control
2009-04-29 13:52:25 +0200 fs r271366 : #i101308#
2009-07-03 14:21:50 +00:00
|
|
|
sal_Bool& _bNew,
|
2010-01-19 09:16:12 +00:00
|
|
|
const ORowSetValueVector& _aParameterValueForCache,
|
2010-11-24 14:23:06 +01:00
|
|
|
const ::rtl::OUString& i_sRowSetFilter,
|
|
|
|
sal_Int32 i_nMaxRows)
|
2006-06-20 01:36:29 +00:00
|
|
|
:m_xSet(_xRs)
|
|
|
|
,m_xMetaData(Reference< XResultSetMetaDataSupplier >(_xRs,UNO_QUERY)->getMetaData())
|
2007-11-21 14:33:03 +00:00
|
|
|
,m_aContext( _rContext )
|
2006-06-20 01:36:29 +00:00
|
|
|
,m_pCacheSet(NULL)
|
|
|
|
,m_pMatrix(NULL)
|
|
|
|
,m_pInsertMatrix(NULL)
|
|
|
|
,m_nLastColumnIndex(0)
|
|
|
|
,m_nFetchSize(0)
|
|
|
|
,m_nRowCount(0)
|
|
|
|
,m_nPrivileges( Privilege::SELECT )
|
|
|
|
,m_nPosition(0)
|
2000-09-18 23:16:46 +00:00
|
|
|
,m_nStartPos(0)
|
|
|
|
,m_nEndPos(0)
|
2006-06-20 01:36:29 +00:00
|
|
|
,m_bRowCountFinal(sal_False)
|
2000-09-18 23:16:46 +00:00
|
|
|
,m_bBeforeFirst(sal_True)
|
2006-01-03 15:13:57 +00:00
|
|
|
,m_bAfterLast( sal_False )
|
2000-09-18 23:16:46 +00:00
|
|
|
,m_bUpdated(sal_False)
|
2000-10-17 09:19:03 +00:00
|
|
|
,m_bModified(_bModified)
|
2006-06-20 01:36:29 +00:00
|
|
|
,m_bNew(_bNew)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2005-09-23 11:03:25 +00:00
|
|
|
DBG_CTOR(ORowSetCache,NULL);
|
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
// first try if the result can be used to do inserts and updates
|
2011-01-26 12:26:48 +01:00
|
|
|
Reference< XPropertySet> xProp(_xRs,UNO_QUERY);
|
|
|
|
Reference< XPropertySetInfo > xPropInfo = xProp->getPropertySetInfo();
|
2011-03-18 09:31:06 +01:00
|
|
|
sal_Bool bBookmarkable = sal_False;
|
2010-02-15 09:53:53 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XResultSetUpdate> xUp(_xRs,UNO_QUERY_THROW);
|
2011-03-18 09:31:06 +01:00
|
|
|
bBookmarkable = xPropInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE) &&
|
2010-07-09 14:49:18 +02:00
|
|
|
any2bool(xProp->getPropertyValue(PROPERTY_ISBOOKMARKABLE)) && Reference< XRowLocate >(_xRs, UNO_QUERY).is();
|
|
|
|
if ( bBookmarkable )
|
|
|
|
{
|
|
|
|
xUp->moveToInsertRow();
|
|
|
|
xUp->cancelRowUpdates();
|
|
|
|
_xRs->beforeFirst();
|
|
|
|
m_nPrivileges = Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE;
|
2010-11-24 14:23:06 +01:00
|
|
|
m_pCacheSet = new WrappedResultSet(i_nMaxRows);
|
2010-07-09 14:49:18 +02:00
|
|
|
m_xCacheSet = m_pCacheSet;
|
|
|
|
m_pCacheSet->construct(_xRs,i_sRowSetFilter);
|
|
|
|
return;
|
|
|
|
}
|
2010-02-15 09:53:53 +01:00
|
|
|
}
|
2010-07-06 15:20:20 +02:00
|
|
|
catch(const Exception& ex)
|
2010-02-15 09:53:53 +01:00
|
|
|
{
|
2010-07-06 15:20:20 +02:00
|
|
|
(void)ex;
|
2010-02-15 09:53:53 +01:00
|
|
|
}
|
2011-01-26 12:26:48 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if ( xPropInfo->hasPropertyByName(PROPERTY_RESULTSETTYPE) &&
|
|
|
|
::comphelper::getINT32(xProp->getPropertyValue(PROPERTY_RESULTSETTYPE)) != ResultSetType::FORWARD_ONLY)
|
|
|
|
_xRs->beforeFirst();
|
|
|
|
}
|
|
|
|
catch(const SQLException& e)
|
|
|
|
{
|
|
|
|
(void)e;
|
|
|
|
}
|
2010-02-15 09:53:53 +01:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
// check if all keys of the updateable table are fetched
|
|
|
|
sal_Bool bAllKeysFound = sal_False;
|
2001-07-19 08:29:22 +00:00
|
|
|
sal_Int32 nTablesCount = 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-03-18 09:31:06 +01:00
|
|
|
sal_Bool bNeedKeySet = !bBookmarkable || (xPropInfo->hasPropertyByName(PROPERTY_RESULTSETCONCURRENCY) &&
|
2010-02-15 09:53:53 +01:00
|
|
|
::comphelper::getINT32(xProp->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY)) == ResultSetConcurrency::READ_ONLY);
|
|
|
|
|
2008-06-06 12:59:08 +00:00
|
|
|
Reference< XIndexAccess> xUpdateTableKeys;
|
2001-02-01 13:23:57 +00:00
|
|
|
::rtl::OUString aUpdateTableName = _rUpdateTableName;
|
|
|
|
Reference< XConnection> xConnection;
|
2009-11-11 14:16:42 +01:00
|
|
|
// first we need a connection
|
|
|
|
Reference< XStatement> xStmt(_xRs->getStatement(),UNO_QUERY);
|
|
|
|
if(xStmt.is())
|
|
|
|
xConnection = xStmt->getConnection();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Reference< XPreparedStatement> xPrepStmt(_xRs->getStatement(),UNO_QUERY);
|
|
|
|
xConnection = xPrepStmt->getConnection();
|
|
|
|
}
|
|
|
|
OSL_ENSURE(xConnection.is(),"No connection!");
|
2004-11-17 13:42:39 +00:00
|
|
|
if(_xAnalyzer.is())
|
2001-01-04 13:30:37 +00:00
|
|
|
{
|
2001-11-29 15:35:26 +00:00
|
|
|
try
|
|
|
|
{
|
2004-11-17 13:42:39 +00:00
|
|
|
Reference<XTablesSupplier> xTabSup(_xAnalyzer,UNO_QUERY);
|
2001-11-29 15:35:26 +00:00
|
|
|
OSL_ENSURE(xTabSup.is(),"ORowSet::execute composer isn't a tablesupplier!");
|
|
|
|
Reference<XNameAccess> xTables = xTabSup->getTables();
|
2010-02-15 09:53:53 +01:00
|
|
|
Sequence< ::rtl::OUString> aTableNames = xTables->getElementNames();
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( aTableNames.getLength() > 1 && _rUpdateTableName.isEmpty() && bNeedKeySet )
|
2010-02-15 09:53:53 +01:00
|
|
|
{// here we have a join or union and nobody told us which table to update, so we update them all
|
|
|
|
m_nPrivileges = Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE;
|
2011-01-06 12:32:17 +01:00
|
|
|
OptimisticSet* pCursor = new OptimisticSet(m_aContext,xConnection,_xAnalyzer,_aParameterValueForCache,i_nMaxRows,m_nRowCount);
|
2010-02-15 09:53:53 +01:00
|
|
|
m_pCacheSet = pCursor;
|
|
|
|
m_xCacheSet = m_pCacheSet;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
m_pCacheSet->construct(_xRs,i_sRowSetFilter);
|
|
|
|
if ( pCursor->isReadOnly() )
|
|
|
|
m_nPrivileges = Privilege::SELECT;
|
|
|
|
m_aKeyColumns = pCursor->getJoinedKeyColumns();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
catch(const Exception&)
|
|
|
|
{
|
|
|
|
}
|
2010-09-22 11:08:30 +02:00
|
|
|
m_pCacheSet = NULL;
|
|
|
|
m_xCacheSet.clear();
|
2001-11-29 15:35:26 +00:00
|
|
|
}
|
|
|
|
else
|
2000-11-10 13:17:54 +00:00
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
if(!_rUpdateTableName.isEmpty() && xTables->hasByName(_rUpdateTableName))
|
2010-02-15 09:53:53 +01:00
|
|
|
xTables->getByName(_rUpdateTableName) >>= m_aUpdateTable;
|
|
|
|
else if(xTables->getElementNames().getLength())
|
2000-11-10 13:17:54 +00:00
|
|
|
{
|
2010-02-15 09:53:53 +01:00
|
|
|
aUpdateTableName = xTables->getElementNames()[0];
|
|
|
|
xTables->getByName(aUpdateTableName) >>= m_aUpdateTable;
|
|
|
|
}
|
|
|
|
Reference<XIndexAccess> xIndexAccess(xTables,UNO_QUERY);
|
|
|
|
if(xIndexAccess.is())
|
|
|
|
nTablesCount = xIndexAccess->getCount();
|
|
|
|
else
|
|
|
|
nTablesCount = xTables->getElementNames().getLength();
|
2000-11-10 13:17:54 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
if(m_aUpdateTable.is() && nTablesCount < 3) // for we can't handle more than 2 tables in our keyset
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xSet(m_aUpdateTable,UNO_QUERY);
|
|
|
|
const Reference<XNameAccess> xPrimaryKeyColumns = dbtools::getPrimaryKeyColumns_throw(xSet);
|
|
|
|
if ( xPrimaryKeyColumns.is() )
|
|
|
|
{
|
|
|
|
Reference<XColumnsSupplier> xColSup(_xAnalyzer,UNO_QUERY);
|
|
|
|
if ( xColSup.is() )
|
2001-11-29 15:35:26 +00:00
|
|
|
{
|
2010-02-15 09:53:53 +01:00
|
|
|
Reference<XNameAccess> xSelColumns = xColSup->getColumns();
|
|
|
|
Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
|
|
|
|
SelectColumnsMetaData aColumnNames(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers() ? true : false);
|
|
|
|
::dbaccess::getColumnPositions(xSelColumns,xPrimaryKeyColumns->getElementNames(),aUpdateTableName,aColumnNames);
|
|
|
|
bAllKeysFound = !aColumnNames.empty() && sal_Int32(aColumnNames.size()) == xPrimaryKeyColumns->getElementNames().getLength();
|
2003-07-21 11:27:44 +00:00
|
|
|
}
|
2001-11-29 15:35:26 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-11-29 15:35:26 +00:00
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2001-11-29 15:35:26 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
// first check if resultset is bookmarkable
|
2009-07-03 12:24:35 +00:00
|
|
|
if(!bNeedKeySet)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
try
|
|
|
|
{
|
2010-11-24 14:23:06 +01:00
|
|
|
m_pCacheSet = new OBookmarkSet(i_nMaxRows);
|
2009-07-03 12:24:35 +00:00
|
|
|
m_xCacheSet = m_pCacheSet;
|
2010-01-19 09:16:12 +00:00
|
|
|
m_pCacheSet->construct(_xRs,i_sRowSetFilter);
|
2009-07-03 12:24:35 +00:00
|
|
|
|
|
|
|
// check privileges
|
|
|
|
m_nPrivileges = Privilege::SELECT;
|
|
|
|
if(Reference<XResultSetUpdate>(_xRs,UNO_QUERY).is()) // this interface is optional so we have to check it
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xTable(m_aUpdateTable,UNO_QUERY);
|
|
|
|
if(xTable.is() && xTable->getPropertySetInfo()->hasPropertyByName(PROPERTY_PRIVILEGES))
|
|
|
|
{
|
|
|
|
m_nPrivileges = 0;
|
|
|
|
xTable->getPropertyValue(PROPERTY_PRIVILEGES) >>= m_nPrivileges;
|
|
|
|
if(!m_nPrivileges)
|
|
|
|
m_nPrivileges = Privilege::SELECT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(const SQLException&)
|
|
|
|
{
|
|
|
|
bNeedKeySet = sal_True;
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
if(bNeedKeySet)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-07-19 08:29:22 +00:00
|
|
|
// need to check if we could handle this select clause
|
2004-11-17 13:42:39 +00:00
|
|
|
bAllKeysFound = bAllKeysFound && (nTablesCount == 1 || checkJoin(xConnection,_xAnalyzer,aUpdateTableName));
|
2001-07-19 08:29:22 +00:00
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
if(!bAllKeysFound )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-03-18 09:31:06 +01:00
|
|
|
if ( bBookmarkable )
|
|
|
|
{
|
2012-02-11 12:37:03 +08:00
|
|
|
// here I know that we have a read only bookmarkable cursor
|
2011-03-18 09:31:06 +01:00
|
|
|
_xRs->beforeFirst();
|
|
|
|
m_nPrivileges = Privilege::SELECT;
|
|
|
|
m_pCacheSet = new WrappedResultSet(i_nMaxRows);
|
|
|
|
m_xCacheSet = m_pCacheSet;
|
|
|
|
m_pCacheSet->construct(_xRs,i_sRowSetFilter);
|
|
|
|
return;
|
|
|
|
}
|
2010-11-24 14:23:06 +01:00
|
|
|
m_pCacheSet = new OStaticSet(i_nMaxRows);
|
2009-07-03 12:24:35 +00:00
|
|
|
m_xCacheSet = m_pCacheSet;
|
2010-01-19 09:16:12 +00:00
|
|
|
m_pCacheSet->construct(_xRs,i_sRowSetFilter);
|
2001-07-19 08:29:22 +00:00
|
|
|
m_nPrivileges = Privilege::SELECT;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-12-01 09:18:56 +00:00
|
|
|
Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
|
2006-08-15 09:42:22 +00:00
|
|
|
SelectColumnsMetaData aColumnNames(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers() ? true : false);
|
2004-11-17 13:42:39 +00:00
|
|
|
Reference<XColumnsSupplier> xColSup(_xAnalyzer,UNO_QUERY);
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference<XNameAccess> xSelColumns = xColSup->getColumns();
|
|
|
|
Reference<XNameAccess> xColumns = m_aUpdateTable->getColumns();
|
2009-11-11 14:16:42 +01:00
|
|
|
::dbaccess::getColumnPositions(xSelColumns,xColumns->getElementNames(),aUpdateTableName,aColumnNames);
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2000-10-05 13:52:16 +00:00
|
|
|
// check privileges
|
|
|
|
m_nPrivileges = Privilege::SELECT;
|
2001-02-01 13:23:57 +00:00
|
|
|
sal_Bool bNoInsert = sal_False;
|
|
|
|
|
|
|
|
Sequence< ::rtl::OUString> aNames(xColumns->getElementNames());
|
2006-01-16 14:27:42 +00:00
|
|
|
const ::rtl::OUString* pIter = aNames.getConstArray();
|
|
|
|
const ::rtl::OUString* pEnd = pIter + aNames.getLength();
|
|
|
|
for(;pIter != pEnd;++pIter)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2010-02-15 09:53:53 +01:00
|
|
|
Reference<XPropertySet> xColumn(xColumns->getByName(*pIter),UNO_QUERY);
|
2001-02-01 13:23:57 +00:00
|
|
|
OSL_ENSURE(xColumn.is(),"Column in table is null!");
|
|
|
|
if(xColumn.is())
|
|
|
|
{
|
|
|
|
sal_Int32 nNullable = 0;
|
|
|
|
xColumn->getPropertyValue(PROPERTY_ISNULLABLE) >>= nNullable;
|
2006-01-16 14:27:42 +00:00
|
|
|
if(nNullable == ColumnValue::NO_NULLS && aColumnNames.find(*pIter) == aColumnNames.end())
|
2001-02-01 13:23:57 +00:00
|
|
|
{ // we found a column where null is not allowed so we can't insert new values
|
|
|
|
bNoInsert = sal_True;
|
|
|
|
break; // one column is enough
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-06 12:32:17 +01:00
|
|
|
OKeySet* pKeySet = new OKeySet(m_aUpdateTable,xUpdateTableKeys,aUpdateTableName ,_xAnalyzer,_aParameterValueForCache,i_nMaxRows,m_nRowCount);
|
2001-07-19 08:29:22 +00:00
|
|
|
try
|
2000-12-06 08:55:44 +00:00
|
|
|
{
|
2004-03-02 11:41:52 +00:00
|
|
|
m_pCacheSet = pKeySet;
|
|
|
|
m_xCacheSet = m_pCacheSet;
|
2010-01-19 09:16:12 +00:00
|
|
|
pKeySet->construct(_xRs,i_sRowSetFilter);
|
2001-07-19 08:29:22 +00:00
|
|
|
|
|
|
|
if(Reference<XResultSetUpdate>(_xRs,UNO_QUERY).is()) // this interface is optional so we have to check it
|
2000-12-06 08:55:44 +00:00
|
|
|
{
|
2001-07-19 08:29:22 +00:00
|
|
|
Reference<XPropertySet> xTable(m_aUpdateTable,UNO_QUERY);
|
|
|
|
if(xTable.is() && xTable->getPropertySetInfo()->hasPropertyByName(PROPERTY_PRIVILEGES))
|
|
|
|
{
|
|
|
|
m_nPrivileges = 0;
|
|
|
|
xTable->getPropertyValue(PROPERTY_PRIVILEGES) >>= m_nPrivileges;
|
|
|
|
if(!m_nPrivileges)
|
|
|
|
m_nPrivileges = Privilege::SELECT;
|
|
|
|
}
|
2000-12-06 08:55:44 +00:00
|
|
|
}
|
2001-07-19 08:29:22 +00:00
|
|
|
if(bNoInsert)
|
|
|
|
m_nPrivileges |= ~Privilege::INSERT; // remove the insert privilege
|
|
|
|
}
|
|
|
|
catch(const SQLException&)
|
|
|
|
{
|
|
|
|
// we couldn't create a keyset here so we have to create a static cache
|
2003-03-19 16:57:12 +00:00
|
|
|
if ( m_pCacheSet )
|
2004-03-02 11:41:52 +00:00
|
|
|
m_pCacheSet = NULL;
|
|
|
|
m_xCacheSet = NULL;
|
2010-11-24 14:23:06 +01:00
|
|
|
m_pCacheSet = new OStaticSet(i_nMaxRows);
|
2004-03-02 11:41:52 +00:00
|
|
|
m_xCacheSet = m_pCacheSet;
|
2010-01-19 09:16:12 +00:00
|
|
|
m_pCacheSet->construct(_xRs,i_sRowSetFilter);
|
2001-07-19 08:29:22 +00:00
|
|
|
m_nPrivileges = Privilege::SELECT;
|
2000-12-06 08:55:44 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2001-01-09 14:38:59 +00:00
|
|
|
// last check
|
2001-10-26 06:50:50 +00:00
|
|
|
if(!bAllKeysFound && xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_RESULTSETCONCURRENCY) &&
|
2001-01-09 14:38:59 +00:00
|
|
|
::comphelper::getINT32(xProp->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY)) == ResultSetConcurrency::READ_ONLY)
|
|
|
|
m_nPrivileges = Privilege::SELECT;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
ORowSetCache::~ORowSetCache()
|
|
|
|
{
|
2000-12-12 11:20:31 +00:00
|
|
|
m_pCacheSet = NULL;
|
2004-03-02 11:41:52 +00:00
|
|
|
m_xCacheSet = NULL;
|
2000-09-18 23:16:46 +00:00
|
|
|
if(m_pMatrix)
|
|
|
|
{
|
|
|
|
m_pMatrix->clear();
|
|
|
|
delete m_pMatrix;
|
|
|
|
}
|
2000-09-29 14:23:36 +00:00
|
|
|
|
|
|
|
if(m_pInsertMatrix)
|
|
|
|
{
|
|
|
|
m_pInsertMatrix->clear();
|
|
|
|
delete m_pInsertMatrix;
|
|
|
|
}
|
2001-02-01 13:23:57 +00:00
|
|
|
m_xSet = WeakReference< XResultSet>();
|
2000-11-03 13:42:50 +00:00
|
|
|
m_xMetaData = NULL;
|
|
|
|
m_aUpdateTable = NULL;
|
2005-09-23 11:03:25 +00:00
|
|
|
|
|
|
|
DBG_DTOR(ORowSetCache,NULL);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2002-04-16 06:48:57 +00:00
|
|
|
|
2010-11-24 14:23:06 +01:00
|
|
|
void ORowSetCache::setFetchSize(sal_Int32 _nSize)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-01-24 08:52:19 +00:00
|
|
|
if(_nSize == m_nFetchSize)
|
|
|
|
return;
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
m_nFetchSize = _nSize;
|
|
|
|
if(!m_pMatrix)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2000-09-18 23:16:46 +00:00
|
|
|
m_pMatrix = new ORowSetMatrix(_nSize);
|
2001-01-24 08:52:19 +00:00
|
|
|
m_aMatrixIter = m_pMatrix->end();
|
|
|
|
m_aMatrixEnd = m_pMatrix->end();
|
|
|
|
|
|
|
|
m_pInsertMatrix = new ORowSetMatrix(1); // a little bit overkill but ??? :-)
|
|
|
|
m_aInsertRow = m_pInsertMatrix->end();
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
else
|
|
|
|
{
|
2001-01-24 08:52:19 +00:00
|
|
|
// now correct the iterator in our iterator vector
|
|
|
|
::std::vector<sal_Int32> aPositions;
|
2001-04-05 13:14:41 +00:00
|
|
|
::std::map<sal_Int32,sal_Bool> aCacheIterToChange;
|
|
|
|
// first get the positions where they stand now
|
2001-01-24 08:52:19 +00:00
|
|
|
ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end();
|
|
|
|
for(;aCacheIter != aCacheEnd;++aCacheIter)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2001-04-05 13:14:41 +00:00
|
|
|
aCacheIterToChange[aCacheIter->first] = sal_False;
|
2006-01-25 14:10:43 +00:00
|
|
|
if ( !aCacheIter->second.pRowSet->isInsertRow()
|
2006-07-26 06:46:13 +00:00
|
|
|
/*&& aCacheIter->second.aIterator != m_pMatrix->end()*/ && !m_bModified )
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2006-07-10 14:03:49 +00:00
|
|
|
ptrdiff_t nDist = (aCacheIter->second.aIterator - m_pMatrix->begin());
|
2001-01-24 08:52:19 +00:00
|
|
|
aPositions.push_back(nDist);
|
2001-04-05 13:14:41 +00:00
|
|
|
aCacheIterToChange[aCacheIter->first] = sal_True;
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
sal_Int32 nKeyPos = (m_aMatrixIter - m_pMatrix->begin());
|
2000-09-18 23:16:46 +00:00
|
|
|
m_pMatrix->resize(_nSize);
|
2006-07-26 06:46:13 +00:00
|
|
|
|
2006-10-18 12:26:03 +00:00
|
|
|
if ( nKeyPos < _nSize )
|
|
|
|
m_aMatrixIter = m_pMatrix->begin() + nKeyPos;
|
|
|
|
else
|
|
|
|
m_aMatrixIter = m_pMatrix->end();
|
2001-01-24 08:52:19 +00:00
|
|
|
m_aMatrixEnd = m_pMatrix->end();
|
2001-04-05 13:14:41 +00:00
|
|
|
|
2010-11-09 22:15:21 +00:00
|
|
|
// now adjust their positions because a resize invalidates all iterators
|
2001-04-05 13:14:41 +00:00
|
|
|
::std::vector<sal_Int32>::const_iterator aIter = aPositions.begin();
|
|
|
|
::std::map<sal_Int32,sal_Bool>::const_iterator aPosChangeIter = aCacheIterToChange.begin();
|
|
|
|
for( aCacheIter = m_aCacheIterators.begin();
|
|
|
|
aPosChangeIter != aCacheIterToChange.end();
|
|
|
|
++aPosChangeIter,++aCacheIter)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2006-07-26 06:46:13 +00:00
|
|
|
if ( aPosChangeIter->second )
|
|
|
|
{
|
|
|
|
CHECK_MATRIX_POS(*aIter);
|
2006-10-18 12:26:03 +00:00
|
|
|
if ( *aIter < _nSize )
|
|
|
|
aCacheIter->second.aIterator = m_pMatrix->begin() + *aIter++;
|
|
|
|
else
|
|
|
|
aCacheIter->second.aIterator = m_pMatrix->end();
|
2006-07-26 06:46:13 +00:00
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!m_nPosition)
|
|
|
|
{
|
2012-01-19 20:20:06 +01:00
|
|
|
sal_Int32 nNewSt = 0;
|
|
|
|
fillMatrix(nNewSt,_nSize);
|
|
|
|
OSL_ENSURE(nNewSt == 0, "fillMatrix set new start to unexpected value");
|
2001-01-24 08:52:19 +00:00
|
|
|
m_nStartPos = 0;
|
|
|
|
m_nEndPos = _nSize;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2012-01-19 20:20:06 +01:00
|
|
|
else if (m_nStartPos < m_nPosition && m_nPosition <= m_nEndPos)
|
2010-12-02 13:16:48 +01:00
|
|
|
{
|
|
|
|
sal_Int32 nNewSt = -1;
|
2012-01-31 22:53:31 +01:00
|
|
|
_nSize += m_nStartPos;
|
|
|
|
fillMatrix(nNewSt, _nSize);
|
2012-01-19 20:20:06 +01:00
|
|
|
if (nNewSt >= 0)
|
|
|
|
{
|
|
|
|
m_nStartPos = nNewSt;
|
2012-01-31 22:53:31 +01:00
|
|
|
m_nEndPos = _nSize;
|
2012-01-19 20:20:06 +01:00
|
|
|
m_aMatrixIter = calcPosition();
|
|
|
|
}
|
2012-01-31 22:53:31 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_nEndPos = m_nStartPos + m_nFetchSize;
|
|
|
|
}
|
2012-01-19 20:20:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSL_FAIL("m_nPosition not between m_nStartPos and m_nEndpos");
|
|
|
|
// try to repair
|
|
|
|
moveWindow();
|
|
|
|
m_aMatrixIter = calcPosition();
|
2010-12-02 13:16:48 +01:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// XResultSetMetaDataSupplier
|
2002-12-05 13:10:11 +00:00
|
|
|
Reference< XResultSetMetaData > ORowSetCache::getMetaData( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return m_xMetaData;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
Any lcl_getBookmark(ORowSetValue& i_aValue,OCacheSet* i_pCacheSet)
|
|
|
|
{
|
|
|
|
switch ( i_aValue.getTypeKind() )
|
|
|
|
{
|
|
|
|
case DataType::TINYINT:
|
|
|
|
case DataType::SMALLINT:
|
|
|
|
case DataType::INTEGER:
|
|
|
|
return makeAny((sal_Int32)i_aValue);
|
|
|
|
default:
|
|
|
|
if ( i_pCacheSet && i_aValue.isNull())
|
|
|
|
i_aValue = i_pCacheSet->getBookmark();
|
|
|
|
return i_aValue.getAny();
|
|
|
|
}
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
// ::com::sun::star::sdbcx::XRowLocate
|
2002-12-05 13:10:11 +00:00
|
|
|
Any ORowSetCache::getBookmark( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if(m_bAfterLast)
|
2001-04-19 06:14:49 +00:00
|
|
|
throwFunctionSequenceException(m_xSet.get());
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-10-15 12:22:54 -05:00
|
|
|
if ( m_aMatrixIter >= m_pMatrix->end() || m_aMatrixIter < m_pMatrix->begin() || !(*m_aMatrixIter).is())
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2010-11-08 02:50:53 -06:00
|
|
|
return Any(); // this is allowed here because the rowset knowns what it is doing
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
2001-01-22 06:38:24 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
return lcl_getBookmark(((*m_aMatrixIter)->get())[0],m_pCacheSet);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Bool ORowSetCache::moveToBookmark( const Any& bookmark )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-08-08 06:07:42 +00:00
|
|
|
if ( m_pCacheSet->moveToBookmark(bookmark) )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2006-01-25 14:10:43 +00:00
|
|
|
m_bBeforeFirst = sal_False;
|
2000-09-18 23:16:46 +00:00
|
|
|
m_nPosition = m_pCacheSet->getRow();
|
2001-06-26 09:30:55 +00:00
|
|
|
|
|
|
|
checkPositionFlags();
|
|
|
|
|
2000-12-06 08:55:44 +00:00
|
|
|
if(!m_bAfterLast)
|
|
|
|
{
|
|
|
|
moveWindow();
|
2001-06-26 09:30:55 +00:00
|
|
|
checkPositionFlags();
|
2002-12-10 11:50:04 +00:00
|
|
|
if ( !m_bAfterLast )
|
|
|
|
{
|
2001-11-29 15:35:26 +00:00
|
|
|
m_aMatrixIter = calcPosition();
|
2010-10-15 12:22:54 -05:00
|
|
|
OSL_ENSURE(m_aMatrixIter->is(),"Iterator after moveToBookmark not valid");
|
2002-12-10 11:50:04 +00:00
|
|
|
}
|
2000-12-06 08:55:44 +00:00
|
|
|
else
|
|
|
|
m_aMatrixIter = m_pMatrix->end();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_aMatrixIter = m_pMatrix->end();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2001-06-22 12:08:06 +00:00
|
|
|
else
|
|
|
|
return sal_False;
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2010-10-15 12:22:54 -05:00
|
|
|
return m_aMatrixIter != m_pMatrix->end() && (*m_aMatrixIter).is();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Bool ORowSetCache::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2006-07-10 14:03:49 +00:00
|
|
|
sal_Bool bRet( moveToBookmark( bookmark ) );
|
|
|
|
if ( bRet )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
m_nPosition = m_pCacheSet->getRow() + rows;
|
|
|
|
absolute(m_nPosition);
|
|
|
|
|
2010-10-15 12:22:54 -05:00
|
|
|
bRet = m_aMatrixIter != m_pMatrix->end() && (*m_aMatrixIter).is();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2006-06-20 01:36:29 +00:00
|
|
|
sal_Int32 ORowSetCache::compareBookmarks( const Any& _first, const Any& _second )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2006-06-20 01:36:29 +00:00
|
|
|
return (!_first.hasValue() || !_second.hasValue()) ? CompareBookmark::NOT_COMPARABLE : m_pCacheSet->compareBookmarks(_first,_second);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Bool ORowSetCache::hasOrderedBookmarks( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return m_pCacheSet->hasOrderedBookmarks();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Int32 ORowSetCache::hashBookmark( const Any& bookmark )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-02-14 12:18:24 +00:00
|
|
|
return m_pCacheSet->hashBookmark(bookmark);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
// XRowUpdate
|
2010-02-15 09:53:53 +01:00
|
|
|
void ORowSetCache::updateNull(sal_Int32 columnIndex,ORowSetValueVector::Vector& io_aRow
|
|
|
|
,::std::vector<sal_Int32>& o_ChangedColumns
|
|
|
|
)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
checkUpdateConditions(columnIndex);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get());
|
2011-02-23 11:36:11 +01:00
|
|
|
if ( !rInsert[columnIndex].isNull() )
|
|
|
|
{
|
|
|
|
rInsert[columnIndex].setBound(sal_True);
|
|
|
|
rInsert[columnIndex].setNull();
|
|
|
|
rInsert[columnIndex].setModified();
|
|
|
|
io_aRow[columnIndex].setNull();
|
2006-02-06 15:54:31 +00:00
|
|
|
|
2011-02-23 11:36:11 +01:00
|
|
|
m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
|
|
|
|
impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns);
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x
|
|
|
|
,ORowSetValueVector::Vector& io_aRow
|
|
|
|
,::std::vector<sal_Int32>& o_ChangedColumns
|
|
|
|
)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
checkUpdateConditions(columnIndex);
|
2001-04-02 10:14:53 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get());
|
2011-02-23 11:36:11 +01:00
|
|
|
if ( rInsert[columnIndex] != x )
|
|
|
|
{
|
|
|
|
rInsert[columnIndex].setBound(sal_True);
|
|
|
|
rInsert[columnIndex] = x;
|
|
|
|
rInsert[columnIndex].setModified();
|
|
|
|
io_aRow[columnIndex] = rInsert[columnIndex];
|
2006-02-06 15:54:31 +00:00
|
|
|
|
2011-02-23 11:36:11 +01:00
|
|
|
m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
|
|
|
|
impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns);
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
void ORowSetCache::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x
|
|
|
|
, sal_Int32 length,ORowSetValueVector::Vector& io_aRow
|
|
|
|
,::std::vector<sal_Int32>& o_ChangedColumns
|
|
|
|
)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
checkUpdateConditions(columnIndex);
|
2001-04-02 10:14:53 +00:00
|
|
|
|
|
|
|
Sequence<sal_Int8> aSeq;
|
|
|
|
if(x.is())
|
2008-12-01 12:31:27 +00:00
|
|
|
x->readBytes(aSeq,length);
|
2001-04-02 10:14:53 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get());
|
|
|
|
rInsert[columnIndex].setBound(sal_True);
|
|
|
|
rInsert[columnIndex] = aSeq;
|
|
|
|
rInsert[columnIndex].setModified();
|
|
|
|
io_aRow[columnIndex] = makeAny(x);
|
|
|
|
|
|
|
|
m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
|
|
|
|
impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
void ORowSetCache::updateObject( sal_Int32 columnIndex, const Any& x
|
|
|
|
,ORowSetValueVector::Vector& io_aRow
|
|
|
|
,::std::vector<sal_Int32>& o_ChangedColumns
|
|
|
|
)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
checkUpdateConditions(columnIndex);
|
2001-04-02 10:14:53 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get());
|
2011-02-23 11:36:11 +01:00
|
|
|
ORowSetValue aTemp;
|
|
|
|
aTemp.fill(x);
|
|
|
|
if ( rInsert[columnIndex] != aTemp )
|
|
|
|
{
|
|
|
|
rInsert[columnIndex].setBound(sal_True);
|
|
|
|
rInsert[columnIndex] = aTemp;
|
|
|
|
rInsert[columnIndex].setModified();
|
|
|
|
io_aRow[columnIndex] = rInsert[columnIndex];
|
2006-02-06 15:54:31 +00:00
|
|
|
|
2011-02-23 11:36:11 +01:00
|
|
|
m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
|
|
|
|
impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns);
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
void ORowSetCache::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/
|
|
|
|
,ORowSetValueVector::Vector& io_aRow
|
|
|
|
,::std::vector<sal_Int32>& o_ChangedColumns
|
|
|
|
)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
checkUpdateConditions(columnIndex);
|
2001-04-02 10:14:53 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get());
|
2011-02-23 11:36:11 +01:00
|
|
|
ORowSetValue aTemp;
|
|
|
|
aTemp.fill(x);
|
|
|
|
if ( rInsert[columnIndex] != aTemp )
|
|
|
|
{
|
|
|
|
rInsert[columnIndex].setBound(sal_True);
|
|
|
|
rInsert[columnIndex] = aTemp;
|
|
|
|
rInsert[columnIndex].setModified();
|
|
|
|
io_aRow[columnIndex] = rInsert[columnIndex];
|
2006-02-06 15:54:31 +00:00
|
|
|
|
2011-02-23 11:36:11 +01:00
|
|
|
m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
|
|
|
|
impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns);
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
// XResultSet
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Bool ORowSetCache::next( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
if(!isAfterLast())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
m_bBeforeFirst = sal_False;
|
|
|
|
++m_nPosition;
|
2006-01-25 14:10:43 +00:00
|
|
|
|
2001-06-26 09:30:55 +00:00
|
|
|
// after we increment the position we have to check if we are already after the last row
|
|
|
|
checkPositionFlags();
|
|
|
|
if(!m_bAfterLast)
|
2001-01-26 14:18:17 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
moveWindow();
|
|
|
|
|
|
|
|
OSL_ENSURE(((m_nPosition - m_nStartPos) - 1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
|
2001-11-29 15:35:26 +00:00
|
|
|
m_aMatrixIter = calcPosition();
|
2001-06-26 09:30:55 +00:00
|
|
|
checkPositionFlags();
|
2001-01-26 14:18:17 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
return !m_bAfterLast;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Bool ORowSetCache::isBeforeFirst( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return m_bBeforeFirst;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Bool ORowSetCache::isAfterLast( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-01-22 06:38:24 +00:00
|
|
|
return m_bAfterLast;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Bool ORowSetCache::isFirst( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return m_nPosition == 1; // ask resultset for
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Bool ORowSetCache::isLast( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
return m_nPosition == m_nRowCount;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2006-01-25 14:10:43 +00:00
|
|
|
sal_Bool ORowSetCache::beforeFirst( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
if(!m_bBeforeFirst)
|
|
|
|
{
|
2001-07-12 06:56:32 +00:00
|
|
|
m_bAfterLast = sal_False;
|
2001-06-26 09:30:55 +00:00
|
|
|
m_nPosition = 0;
|
|
|
|
m_bBeforeFirst = sal_True;
|
|
|
|
m_pCacheSet->beforeFirst();
|
|
|
|
moveWindow();
|
|
|
|
m_aMatrixIter = m_pMatrix->end();
|
|
|
|
}
|
2006-01-25 14:10:43 +00:00
|
|
|
return sal_True;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2006-01-25 14:10:43 +00:00
|
|
|
sal_Bool ORowSetCache::afterLast( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
if(!m_bAfterLast)
|
|
|
|
{
|
2001-07-12 06:56:32 +00:00
|
|
|
m_bBeforeFirst = sal_False;
|
2001-06-26 09:30:55 +00:00
|
|
|
m_bAfterLast = sal_True;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-06-26 09:30:55 +00:00
|
|
|
if(!m_bRowCountFinal)
|
|
|
|
{
|
2010-12-02 13:16:48 +01:00
|
|
|
m_pCacheSet->last_checked(sal_False);
|
2001-06-26 09:30:55 +00:00
|
|
|
m_bRowCountFinal = sal_True;
|
|
|
|
m_nRowCount = m_pCacheSet->getRow();// + 1 removed
|
|
|
|
}
|
|
|
|
m_pCacheSet->afterLast();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-06-26 09:30:55 +00:00
|
|
|
m_nPosition = 0;
|
|
|
|
m_aMatrixIter = m_pMatrix->end();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2006-01-25 14:10:43 +00:00
|
|
|
return sal_True;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2012-01-31 22:53:31 +01:00
|
|
|
sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos, sal_Int32 &_nNewEndPos)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
OSL_ENSURE(_nNewStartPos != _nNewEndPos,"ORowSetCache::fillMatrix: StartPos and EndPos can not be equal!");
|
2012-01-19 20:20:06 +01:00
|
|
|
// If _nNewStartPos >= 0, then fill the whole window with new data
|
|
|
|
// Else if _nNewStartPos == -1, then fill only segment [m_nEndPos, _nNewEndPos)
|
|
|
|
// Else, undefined (invalid argument)
|
|
|
|
OSL_ENSURE( _nNewStartPos >= -1, "ORowSetCache::fillMatrix: invalid _nNewStartPos" );
|
|
|
|
|
2010-12-02 13:16:48 +01:00
|
|
|
ORowSetMatrix::iterator aIter;
|
|
|
|
sal_Int32 i;
|
|
|
|
sal_Bool bCheck;
|
2012-02-08 12:41:54 +01:00
|
|
|
sal_Int32 requestedStartPos;
|
2010-12-02 13:16:48 +01:00
|
|
|
if ( _nNewStartPos == -1 )
|
|
|
|
{
|
2012-01-19 20:20:06 +01:00
|
|
|
aIter = m_pMatrix->begin() + (m_nEndPos - m_nStartPos);
|
2012-01-22 01:35:58 +01:00
|
|
|
i = m_nEndPos + 1;
|
2012-02-08 12:41:54 +01:00
|
|
|
requestedStartPos = m_nStartPos;
|
2010-12-02 13:16:48 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aIter = m_pMatrix->begin();
|
2012-01-19 20:20:06 +01:00
|
|
|
i = _nNewStartPos + 1;
|
2012-02-08 12:41:54 +01:00
|
|
|
requestedStartPos = _nNewStartPos;
|
2010-12-02 13:16:48 +01:00
|
|
|
}
|
2012-01-19 20:20:06 +01:00
|
|
|
bCheck = m_pCacheSet->absolute(i);
|
2010-12-02 13:16:48 +01:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
|
2012-01-19 20:20:06 +01:00
|
|
|
for(; i <= _nNewEndPos; ++i,++aIter)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if(bCheck)
|
|
|
|
{
|
2010-10-15 12:22:54 -05:00
|
|
|
if(!aIter->is())
|
2009-07-03 12:24:35 +00:00
|
|
|
*aIter = new ORowSetValueVector(m_xMetaData->getColumnCount());
|
2000-12-14 10:41:19 +00:00
|
|
|
m_pCacheSet->fillValueRow(*aIter,i);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // there are no more rows found so we can fetch some before start
|
|
|
|
|
|
|
|
if(!m_bRowCountFinal)
|
|
|
|
{
|
2010-12-02 13:16:48 +01:00
|
|
|
if(m_pCacheSet->previous_checked(sal_False)) // because we stand after the last row
|
2001-01-24 08:52:19 +00:00
|
|
|
m_nRowCount = m_pCacheSet->getRow(); // here we have the row count
|
|
|
|
if(!m_nRowCount)
|
|
|
|
m_nRowCount = i-1; // it can be that getRow return zero
|
2000-09-18 23:16:46 +00:00
|
|
|
m_bRowCountFinal = sal_True;
|
|
|
|
}
|
2012-01-19 20:20:06 +01:00
|
|
|
const ORowSetMatrix::iterator aEnd = aIter;
|
|
|
|
ORowSetMatrix::iterator aRealEnd = m_pMatrix->end();
|
2012-01-31 22:53:31 +01:00
|
|
|
sal_Int32 nPos;
|
|
|
|
if (m_nRowCount >= m_nFetchSize)
|
|
|
|
{
|
|
|
|
nPos = m_nRowCount - m_nFetchSize;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nPos = 0;
|
|
|
|
}
|
2012-01-19 20:20:06 +01:00
|
|
|
_nNewStartPos = nPos;
|
2012-02-08 12:41:54 +01:00
|
|
|
_nNewEndPos = m_nRowCount;
|
2012-01-19 20:20:06 +01:00
|
|
|
++nPos;
|
|
|
|
bCheck = m_pCacheSet->absolute(nPos);
|
|
|
|
|
2012-02-08 12:41:54 +01:00
|
|
|
for(;bCheck && nPos <= requestedStartPos && aIter != aRealEnd; ++aIter, ++nPos)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-01-19 20:20:06 +01:00
|
|
|
if(!aIter->is())
|
|
|
|
*aIter = new ORowSetValueVector(m_xMetaData->getColumnCount());
|
2012-02-08 12:41:54 +01:00
|
|
|
m_pCacheSet->fillValueRow(*aIter, nPos);
|
2012-01-19 20:20:06 +01:00
|
|
|
bCheck = m_pCacheSet->next();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2012-01-19 20:20:06 +01:00
|
|
|
if(aIter != aEnd)
|
|
|
|
::std::rotate(m_pMatrix->begin(),aEnd,aIter);
|
2000-09-18 23:16:46 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-01-19 20:20:06 +01:00
|
|
|
bCheck = m_pCacheSet->next();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-12-02 13:16:48 +01:00
|
|
|
// we have to read one row forward to ensure that we know when we are on last row
|
2000-11-07 12:19:27 +00:00
|
|
|
// but only when we don't know it already
|
|
|
|
if(!m_bRowCountFinal)
|
|
|
|
{
|
|
|
|
if(!m_pCacheSet->next())
|
|
|
|
{
|
2010-12-02 13:16:48 +01:00
|
|
|
if(m_pCacheSet->previous_checked(sal_False)) // because we stand after the last row
|
2000-11-07 12:19:27 +00:00
|
|
|
m_nRowCount = m_pCacheSet->getRow(); // here we have the row count
|
|
|
|
m_bRowCountFinal = sal_True;
|
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
else
|
2001-10-12 14:36:42 +00:00
|
|
|
m_nRowCount = std::max(i,m_nRowCount);
|
2001-01-24 08:52:19 +00:00
|
|
|
|
2000-11-07 12:19:27 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
return bCheck;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2012-01-19 20:20:06 +01:00
|
|
|
// If m_nPosition is out of the current window,
|
|
|
|
// move it and update m_nStartPos and m_nEndPos
|
|
|
|
// Caller is responsible for updating m_aMatrixIter
|
2000-09-18 23:16:46 +00:00
|
|
|
sal_Bool ORowSetCache::moveWindow()
|
|
|
|
{
|
2012-02-08 12:41:54 +01:00
|
|
|
OSL_ENSURE(m_nStartPos >= 0,"ORowSetCache::moveWindow: m_nStartPos is less than 0!");
|
2012-08-21 14:43:52 +02:00
|
|
|
OSL_ENSURE(m_nEndPos >= m_nStartPos,"ORowSetCache::moveWindow: m_nStartPos not smaller than m_nEndPos");
|
2012-02-08 12:41:54 +01:00
|
|
|
OSL_ENSURE(m_nEndPos-m_nStartPos <= m_nFetchSize,"ORowSetCache::moveWindow: m_nStartPos and m_nEndPos too far apart");
|
2012-01-19 20:20:06 +01:00
|
|
|
|
|
|
|
if ( m_nStartPos < m_nPosition && m_nPosition <= m_nEndPos )
|
|
|
|
{
|
|
|
|
// just move inside the window
|
|
|
|
OSL_ENSURE((m_nPosition - m_nStartPos) <= (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
|
|
|
|
// make double plus sure that we have fetched that row
|
|
|
|
m_aMatrixIter = calcPosition();
|
|
|
|
OSL_ENSURE(m_aMatrixIter != m_pMatrix->end(), "New m_aMatrixIter is at end(), but should not.");
|
|
|
|
if(!m_aMatrixIter->is())
|
|
|
|
{
|
|
|
|
sal_Bool bOk( m_pCacheSet->absolute( m_nPosition ) );
|
|
|
|
if ( bOk )
|
|
|
|
{
|
|
|
|
*m_aMatrixIter = new ORowSetValueVector(m_xMetaData->getColumnCount());
|
|
|
|
m_pCacheSet->fillValueRow(*m_aMatrixIter,m_nPosition);
|
|
|
|
// we have to read one row forward to ensure that we know when we are on last row
|
|
|
|
// but only when we don't know it already
|
|
|
|
if ( !m_bRowCountFinal )
|
|
|
|
{
|
|
|
|
bOk = m_pCacheSet->absolute_checked( m_nPosition + 1,sal_False );
|
|
|
|
if ( bOk )
|
|
|
|
m_nRowCount = std::max(sal_Int32(m_nPosition+1),m_nRowCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!bOk && !m_bRowCountFinal)
|
|
|
|
{
|
|
|
|
// because we stand after the last row
|
|
|
|
m_nRowCount = m_pCacheSet->previous_checked(sal_False) ? m_pCacheSet->getRow() : 0;
|
|
|
|
m_bRowCountFinal = sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
sal_Bool bRet = sal_True;
|
|
|
|
|
2012-01-19 20:20:06 +01:00
|
|
|
sal_Int32 nDiff = (m_nFetchSize - 1) / 2;
|
|
|
|
sal_Int32 nNewStartPos = (m_nPosition - nDiff) - 1; //m_nPosition is 1-based, but m_nStartPos is 0-based
|
2000-09-18 23:16:46 +00:00
|
|
|
sal_Int32 nNewEndPos = nNewStartPos + m_nFetchSize;
|
|
|
|
|
2012-02-08 12:41:54 +01:00
|
|
|
if ( nNewStartPos < 0 )
|
|
|
|
{
|
|
|
|
// The computed new window crashes through the floor (begins before first row);
|
|
|
|
// nNew*Pos has to be shifted by -nNewStartPos
|
|
|
|
nNewEndPos -= nNewStartPos;
|
|
|
|
nNewStartPos = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( nNewStartPos < m_nStartPos )
|
|
|
|
{ // need to fill data *before* m_nStartPos
|
2003-03-19 16:57:12 +00:00
|
|
|
if ( nNewEndPos > m_nStartPos )
|
2012-01-19 20:20:06 +01:00
|
|
|
{ // The two regions are overlapping.
|
|
|
|
// We'll first rotate the contents of m_pMatrix so that the overlap area
|
|
|
|
// is positioned right; in the old window it is at the beginning,
|
|
|
|
// it has to go to the end.
|
|
|
|
// then we fill in the rows between new and old start pos.
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-02-08 12:41:54 +01:00
|
|
|
sal_Bool bCheck;
|
2012-02-09 13:03:24 +01:00
|
|
|
bCheck = m_pCacheSet->absolute(nNewStartPos + 1);
|
2012-02-08 12:41:54 +01:00
|
|
|
|
|
|
|
// m_nEndPos < nNewEndPos when window not filled (e.g. there are less rows in total than window size)
|
|
|
|
m_nEndPos = std::min(nNewEndPos, m_nEndPos);
|
|
|
|
const sal_Int32 nOverlapSize = m_nEndPos - m_nStartPos;
|
2012-02-08 19:08:20 +01:00
|
|
|
const sal_Int32 nStartPosOffset = m_nStartPos - nNewStartPos; // by how much m_nStartPos moves
|
2012-02-08 12:41:54 +01:00
|
|
|
m_nStartPos = nNewStartPos;
|
2012-01-19 20:20:06 +01:00
|
|
|
OSL_ENSURE( static_cast<ORowSetMatrix::size_type>(nOverlapSize) <= m_pMatrix->size(), "new window end is after end of cache matrix!" );
|
2012-02-09 13:04:34 +01:00
|
|
|
// the first position in m_pMatrix whose data we don't keep;
|
2012-01-19 20:20:06 +01:00
|
|
|
// content will be moved to m_pMatrix.begin()
|
|
|
|
ORowSetMatrix::iterator aEnd (m_pMatrix->begin() + nOverlapSize);
|
2012-02-08 12:41:54 +01:00
|
|
|
// the first unused position after we are done; it == m_pMatrix.end() if and only if the window is full
|
|
|
|
ORowSetMatrix::iterator aNewEnd (aEnd + nStartPosOffset);
|
|
|
|
// *m_pMatrix now looks like:
|
|
|
|
// [0; nOverlapSize) i.e. [begin(); aEnd): data kept
|
|
|
|
// [nOverlapSize; nOverlapSize + nStartPosOffet) i.e. [aEnd, aNewEnd): new data of positions < old m_nStartPos
|
|
|
|
// [nOverlapSize + nStartPosOffet; size()) i.e. [aNewEnd, end()): unused
|
|
|
|
// Note that nOverlapSize + nStartPosOffet == m_nEndPos - m_nStartPos (new values)
|
|
|
|
// When we are finished:
|
|
|
|
// [0; nStartPosOffset) i.e. [begin(); aEnd): new data of positions < old m_nStartPos
|
|
|
|
// [nStartPosOffset; nOverlapSize + nStartPosOffet) i.e. [aEnd, aNewEnd): kept
|
|
|
|
// [nOverlapSize + nStartPosOffet; size()) i.e. [aNewEnd, end()): unused
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2003-03-19 16:57:12 +00:00
|
|
|
if ( bCheck )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-01-19 20:20:06 +01:00
|
|
|
{
|
|
|
|
ORowSetMatrix::iterator aIter(aEnd);
|
|
|
|
sal_Int32 nPos = m_nStartPos + 1;
|
2012-02-08 12:41:54 +01:00
|
|
|
bCheck = fill(aIter, aNewEnd, nPos, bCheck);
|
2012-01-19 20:20:06 +01:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-02-09 02:14:05 +01:00
|
|
|
::std::rotate(m_pMatrix->begin(), aEnd, aNewEnd);
|
2001-01-22 06:38:24 +00:00
|
|
|
// now correct the iterator in our iterator vector
|
2001-06-26 09:30:55 +00:00
|
|
|
// rotateCacheIterator(aEnd-m_pMatrix->begin()); //can't be used because they decrement and here we need to increment
|
2001-01-24 08:52:19 +00:00
|
|
|
ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin();
|
2012-01-19 20:20:06 +01:00
|
|
|
const ORowSetCacheMap::const_iterator aCacheEnd = m_aCacheIterators.end();
|
2009-07-03 12:24:35 +00:00
|
|
|
for(;aCacheIter != aCacheEnd;++aCacheIter)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2006-01-25 14:10:43 +00:00
|
|
|
if ( !aCacheIter->second.pRowSet->isInsertRow()
|
2006-02-06 15:54:31 +00:00
|
|
|
&& aCacheIter->second.aIterator != m_pMatrix->end() && !m_bModified )
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2012-01-19 20:20:06 +01:00
|
|
|
const ptrdiff_t nDist = (aCacheIter->second.aIterator - m_pMatrix->begin());
|
2012-02-08 12:41:54 +01:00
|
|
|
if ( nDist >= nOverlapSize )
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2012-01-19 20:20:06 +01:00
|
|
|
// That's from outside the overlap area; invalidate iterator.
|
2005-09-05 07:57:54 +00:00
|
|
|
aCacheIter->second.aIterator = m_pMatrix->end();
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
else
|
2002-11-13 05:56:59 +00:00
|
|
|
{
|
2012-01-19 20:20:06 +01:00
|
|
|
// Inside overlap area: move to correct position
|
2012-02-08 12:41:54 +01:00
|
|
|
CHECK_MATRIX_POS( (nDist + nStartPosOffset) );
|
|
|
|
aCacheIter->second.aIterator += nStartPosOffset;
|
2002-11-13 05:56:59 +00:00
|
|
|
OSL_ENSURE(aCacheIter->second.aIterator >= m_pMatrix->begin()
|
2002-12-05 08:54:54 +00:00
|
|
|
&& aCacheIter->second.aIterator < m_pMatrix->end(),"Iterator out of area!");
|
2002-11-13 05:56:59 +00:00
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
2010-11-09 22:15:21 +00:00
|
|
|
{ // normally this should never happen
|
2011-03-12 12:04:35 +01:00
|
|
|
OSL_FAIL("What the hell is happen here!");
|
2000-09-18 23:16:46 +00:00
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{// no rows can be reused so fill again
|
2012-02-08 12:41:54 +01:00
|
|
|
bRet = reFillMatrix(nNewStartPos,nNewEndPos);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-08 12:41:54 +01:00
|
|
|
OSL_ENSURE(nNewStartPos >= m_nStartPos, "ORowSetCache::moveWindow internal error: new start pos before current start pos");
|
|
|
|
if ( m_nEndPos < nNewEndPos )
|
|
|
|
{ // need to fill data *after* m_nEndPos
|
|
|
|
if( nNewStartPos < m_nEndPos )
|
|
|
|
{ // The two regions are overlapping.
|
|
|
|
const sal_Int32 nRowsInCache = m_nEndPos - m_nStartPos;
|
|
|
|
if ( nRowsInCache < m_nFetchSize )
|
|
|
|
{
|
|
|
|
// There is some unused space in *m_pMatrix; fill it
|
|
|
|
CHECK_MATRIX_POS(nRowsInCache);
|
|
|
|
sal_Int32 nPos = m_nEndPos + 1;
|
|
|
|
sal_Bool bCheck = m_pCacheSet->absolute(nPos);
|
|
|
|
ORowSetMatrix::iterator aIter = m_pMatrix->begin() + nRowsInCache;
|
|
|
|
const sal_Int32 nRowsToFetch = std::min(nNewEndPos-m_nEndPos, m_nFetchSize-nRowsInCache);
|
|
|
|
const ORowSetMatrix::const_iterator aEnd = aIter + nRowsToFetch;
|
|
|
|
bCheck = fill(aIter, aEnd, nPos, bCheck);
|
|
|
|
m_nEndPos = nPos - 1;
|
|
|
|
OSL_ENSURE( (!bCheck && m_nEndPos <= nNewEndPos ) ||
|
|
|
|
( bCheck && m_nEndPos == nNewEndPos ),
|
|
|
|
"ORowSetCache::moveWindow opportunistic fetch-after-current-end went badly");
|
|
|
|
}
|
|
|
|
|
|
|
|
// À priori, the rows from begin() [inclusive] to (begin() + nNewStartPos - m_nStartPos) [exclusive]
|
2012-01-19 20:20:06 +01:00
|
|
|
// have to be refilled with new to-be-fetched rows.
|
|
|
|
// The rows behind this can be reused
|
2000-09-18 23:16:46 +00:00
|
|
|
ORowSetMatrix::iterator aIter = m_pMatrix->begin();
|
2012-01-19 20:20:06 +01:00
|
|
|
const sal_Int32 nNewStartPosInMatrix = nNewStartPos - m_nStartPos;
|
|
|
|
CHECK_MATRIX_POS( nNewStartPosInMatrix );
|
2012-02-08 12:41:54 +01:00
|
|
|
// first position we reuse
|
|
|
|
const ORowSetMatrix::const_iterator aEnd = m_pMatrix->begin() + nNewStartPosInMatrix;
|
|
|
|
// End of used portion of the matrix. Is < m_pMatrix->end() if less data than window size
|
|
|
|
ORowSetMatrix::iterator aDataEnd = m_pMatrix->begin() + (m_nEndPos - m_nStartPos);
|
2003-03-19 16:57:12 +00:00
|
|
|
|
2012-01-19 20:20:06 +01:00
|
|
|
sal_Int32 nPos = m_nEndPos + 1;
|
2003-03-19 16:57:12 +00:00
|
|
|
sal_Bool bCheck = m_pCacheSet->absolute(nPos);
|
2012-01-19 20:20:06 +01:00
|
|
|
bCheck = fill(aIter, aEnd, nPos, bCheck); // refill the region we don't need anymore
|
|
|
|
//aIter and nPos are now the position *after* last filled in one!
|
2003-03-19 16:57:12 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
// bind end to front
|
|
|
|
if(bCheck)
|
2012-01-19 20:20:06 +01:00
|
|
|
{
|
|
|
|
OSL_ENSURE(aIter == aEnd, "fill() said went till end, but did not.");
|
|
|
|
// rotate the end to the front
|
2012-02-08 12:41:54 +01:00
|
|
|
::std::rotate(m_pMatrix->begin(), aIter, aDataEnd);
|
2001-01-22 06:38:24 +00:00
|
|
|
// now correct the iterator in our iterator vector
|
2012-02-08 12:41:54 +01:00
|
|
|
rotateCacheIterator( nNewStartPosInMatrix );
|
2012-01-19 20:20:06 +01:00
|
|
|
m_nStartPos = nNewStartPos;
|
|
|
|
m_nEndPos = nNewEndPos;
|
2000-11-07 12:19:27 +00:00
|
|
|
// now I can say how many rows we have
|
2012-01-19 20:20:06 +01:00
|
|
|
// we have to read one row forward to ensure that we know when we are on last row
|
|
|
|
// but only when we don't know it already
|
|
|
|
sal_Bool bOk = sal_True;
|
|
|
|
if(!m_bRowCountFinal)
|
|
|
|
bOk = m_pCacheSet->next();
|
2000-11-07 12:19:27 +00:00
|
|
|
if(!bOk)
|
|
|
|
{
|
2010-12-02 13:16:48 +01:00
|
|
|
m_pCacheSet->previous_checked(sal_False); // because we stand after the last row
|
2000-11-14 12:28:20 +00:00
|
|
|
m_nRowCount = nPos; // here we have the row count
|
2012-01-19 20:20:06 +01:00
|
|
|
OSL_ENSURE(nPos == m_pCacheSet->getRow(),"nPos is not valid!");
|
2000-11-07 12:19:27 +00:00
|
|
|
m_bRowCountFinal = sal_True;
|
|
|
|
}
|
2001-07-24 13:20:28 +00:00
|
|
|
else if(!m_bRowCountFinal)
|
2012-01-19 20:20:06 +01:00
|
|
|
m_nRowCount = std::max(nPos+1, m_nRowCount); //+1 because we successfully moved to row after nPos
|
|
|
|
else
|
2012-08-02 11:58:55 +02:00
|
|
|
OSL_ENSURE(m_nRowCount >= nPos, "Final m_nRowCount is smaller than row I moved to!");
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
2012-01-19 20:20:06 +01:00
|
|
|
{ // the end was reached before or at end() so we can set the start before or at nNewStartPos
|
|
|
|
// and possibly keep more of m_pMatrix than planned.
|
2012-02-08 12:41:54 +01:00
|
|
|
const ORowSetMatrix::iterator::difference_type nFetchedRows = aIter - m_pMatrix->begin();
|
|
|
|
// *m_pMatrix now looks like:
|
|
|
|
// [0; nFetchedRows) i.e. [begin(); aIter): newly fetched data for positions m_nEndPos to m_nEndPos+nFetchedRows
|
|
|
|
// [nFetchedRows; ???) i.e. [aIter; aDataEnd]: data to be kept for positions m_nStartPos+nFetchedRows to ???
|
|
|
|
|
|
|
|
nPos -= 1;
|
|
|
|
m_nStartPos += nFetchedRows;
|
|
|
|
m_nEndPos = nPos;
|
|
|
|
::std::rotate(m_pMatrix->begin(), aIter, aDataEnd);
|
2001-01-22 06:38:24 +00:00
|
|
|
// now correct the iterator in our iterator vector
|
2012-02-08 12:41:54 +01:00
|
|
|
rotateCacheIterator( nFetchedRows );
|
2001-01-22 06:38:24 +00:00
|
|
|
|
2003-04-01 13:00:38 +00:00
|
|
|
if ( !m_bRowCountFinal )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-12-02 13:16:48 +01:00
|
|
|
m_pCacheSet->previous_checked(sal_False); // because we stand after the last row
|
2012-02-08 12:41:54 +01:00
|
|
|
m_nRowCount = std::max(m_nRowCount, nPos); // here we have the row count
|
2003-04-01 13:00:38 +00:00
|
|
|
OSL_ENSURE(nPos == m_pCacheSet->getRow(),"nPos isn't valid!");
|
2000-09-18 23:16:46 +00:00
|
|
|
m_bRowCountFinal = sal_True;
|
|
|
|
}
|
2012-01-19 20:20:06 +01:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2012-01-19 20:20:06 +01:00
|
|
|
// here we need only to check if the beginning row is valid. If not we have to fetch it.
|
2010-10-15 12:22:54 -05:00
|
|
|
if(!m_pMatrix->begin()->is())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
aIter = m_pMatrix->begin();
|
|
|
|
|
2012-02-09 13:06:27 +01:00
|
|
|
nPos = m_nStartPos + 1;
|
2012-06-04 17:31:25 +02:00
|
|
|
bCheck = m_pCacheSet->absolute_checked(nPos, sal_True);
|
2012-02-09 13:06:27 +01:00
|
|
|
for(; !aIter->is() && bCheck;++aIter, ++nPos)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2006-07-26 06:46:13 +00:00
|
|
|
OSL_ENSURE(aIter != m_pMatrix->end(),"Invalid iterator");
|
2012-06-04 23:28:18 +02:00
|
|
|
|
|
|
|
*aIter = new ORowSetValueVector(m_xMetaData->getColumnCount());
|
|
|
|
m_pCacheSet->fillValueRow(*aIter, nPos);
|
|
|
|
|
2012-02-09 13:06:27 +01:00
|
|
|
bCheck = m_pCacheSet->next();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // no rows can be reused so fill again
|
2003-03-19 16:57:12 +00:00
|
|
|
bRet = reFillMatrix(nNewStartPos,nNewEndPos);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!m_bRowCountFinal)
|
2001-10-12 14:36:42 +00:00
|
|
|
m_nRowCount = std::max(m_nPosition,m_nRowCount);
|
2001-01-22 06:38:24 +00:00
|
|
|
OSL_ENSURE(m_nStartPos >= 0,"ORowSetCache::moveWindow: m_nStartPos is less than 0!");
|
2012-02-08 12:41:54 +01:00
|
|
|
OSL_ENSURE(m_nEndPos > m_nStartPos,"ORowSetCache::moveWindow: m_nStartPos not smaller than m_nEndPos");
|
|
|
|
OSL_ENSURE(m_nEndPos-m_nStartPos <= m_nFetchSize,"ORowSetCache::moveWindow: m_nStartPos and m_nEndPos too far apart");
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Bool ORowSetCache::first( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-01-19 20:20:06 +01:00
|
|
|
// First move to the first row.
|
|
|
|
// Then check if the cache window is at the beginning.
|
|
|
|
// If not, then position the window and fill it with data.
|
|
|
|
// We move the window smartly, i.e. we clear only the rows that are out of range
|
2000-09-18 23:16:46 +00:00
|
|
|
sal_Bool bRet = m_pCacheSet->first();
|
|
|
|
if(bRet)
|
|
|
|
{
|
2001-07-12 06:56:32 +00:00
|
|
|
m_bBeforeFirst = m_bAfterLast = sal_False;
|
2000-11-14 12:28:20 +00:00
|
|
|
m_nPosition = 1;
|
2000-09-18 23:16:46 +00:00
|
|
|
moveWindow();
|
2000-11-14 12:28:20 +00:00
|
|
|
m_aMatrixIter = m_pMatrix->begin();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2000-11-14 12:28:20 +00:00
|
|
|
else
|
2001-06-26 09:30:55 +00:00
|
|
|
{
|
2003-06-25 10:02:47 +00:00
|
|
|
m_bRowCountFinal = m_bBeforeFirst = m_bAfterLast = sal_True;
|
|
|
|
m_nRowCount = m_nPosition = 0;
|
|
|
|
|
2006-02-06 15:54:31 +00:00
|
|
|
OSL_ENSURE(m_bBeforeFirst || m_bNew,"ORowSetCache::first return false and BeforeFirst isn't true");
|
2000-11-14 12:28:20 +00:00
|
|
|
m_aMatrixIter = m_pMatrix->end();
|
2001-06-26 09:30:55 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Bool ORowSetCache::last( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
sal_Bool bRet = m_pCacheSet->last();
|
|
|
|
if(bRet)
|
|
|
|
{
|
|
|
|
m_bBeforeFirst = m_bAfterLast = sal_False;
|
|
|
|
if(!m_bRowCountFinal)
|
|
|
|
{
|
|
|
|
m_bRowCountFinal = sal_True;
|
2012-01-19 20:20:06 +01:00
|
|
|
m_nRowCount = m_pCacheSet->getRow(); // not + 1
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2000-10-05 13:52:16 +00:00
|
|
|
m_nPosition = m_pCacheSet->getRow();
|
2000-09-18 23:16:46 +00:00
|
|
|
moveWindow();
|
|
|
|
// we have to repositioning because moveWindow can modify the cache
|
|
|
|
m_pCacheSet->last();
|
2001-08-24 05:40:35 +00:00
|
|
|
OSL_ENSURE(((m_nPosition - m_nStartPos) - 1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
|
2001-11-29 15:35:26 +00:00
|
|
|
m_aMatrixIter = calcPosition();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2000-11-14 12:28:20 +00:00
|
|
|
else
|
2001-06-26 09:30:55 +00:00
|
|
|
{
|
2003-06-25 10:02:47 +00:00
|
|
|
m_bRowCountFinal = m_bBeforeFirst = m_bAfterLast = sal_True;
|
|
|
|
m_nRowCount = m_nPosition = 0;
|
2001-06-26 09:30:55 +00:00
|
|
|
OSL_ENSURE(m_bBeforeFirst,"ORowSetCache::last return false and BeforeFirst isn't true");
|
2000-11-14 12:28:20 +00:00
|
|
|
m_aMatrixIter = m_pMatrix->end();
|
2001-06-26 09:30:55 +00:00
|
|
|
}
|
2003-04-15 15:02:45 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2000-09-18 23:16:46 +00:00
|
|
|
if(bRet)
|
|
|
|
{
|
2010-10-15 12:22:54 -05:00
|
|
|
OSL_ENSURE((*m_aMatrixIter).is(),"ORowSetCache::last: Row not valid!");
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
#endif
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Int32 ORowSetCache::getRow( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
return (isBeforeFirst() || isAfterLast()) ? 0 : m_nPosition;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Bool ORowSetCache::absolute( sal_Int32 row )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if(!row )
|
2004-06-01 09:09:25 +00:00
|
|
|
throw SQLException(DBACORE_RESSTRING(RID_STR_NO_ABS_ZERO),NULL,SQLSTATE_GENERAL,1000,Any() );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if(row < 0)
|
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
// here we have to scroll from the last row to backward so we have to go to last row and
|
|
|
|
// and two the previous
|
2000-09-18 23:16:46 +00:00
|
|
|
if(m_bRowCountFinal || last())
|
|
|
|
{
|
2001-04-05 13:14:41 +00:00
|
|
|
m_nPosition = m_nRowCount + row + 1; // + row because row is negative and +1 because row==-1 means last row
|
2000-09-18 23:16:46 +00:00
|
|
|
if(m_nPosition < 1)
|
|
|
|
{
|
|
|
|
m_bBeforeFirst = sal_True;
|
2001-07-12 06:56:32 +00:00
|
|
|
m_bAfterLast = sal_False;
|
2000-09-18 23:16:46 +00:00
|
|
|
m_aMatrixIter = m_pMatrix->end();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_bBeforeFirst = sal_False;
|
|
|
|
m_bAfterLast = m_nPosition > m_nRowCount;
|
|
|
|
moveWindow();
|
2001-04-02 10:14:53 +00:00
|
|
|
OSL_ENSURE(((m_nPosition - m_nStartPos) - 1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
|
2001-11-29 15:35:26 +00:00
|
|
|
m_aMatrixIter = calcPosition();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_aMatrixIter = m_pMatrix->end();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_nPosition = row;
|
|
|
|
// the position flags
|
|
|
|
m_bBeforeFirst = sal_False;
|
2001-06-26 09:30:55 +00:00
|
|
|
checkPositionFlags();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if(!m_bAfterLast)
|
|
|
|
{
|
|
|
|
moveWindow();
|
2001-06-26 09:30:55 +00:00
|
|
|
checkPositionFlags();
|
2000-10-25 06:32:52 +00:00
|
|
|
if(!m_bAfterLast)
|
2001-11-29 15:35:26 +00:00
|
|
|
m_aMatrixIter = calcPosition();
|
2000-10-25 06:32:52 +00:00
|
|
|
else
|
|
|
|
m_aMatrixIter = m_pMatrix->end();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
m_aMatrixIter = m_pMatrix->end();
|
|
|
|
}
|
2000-09-29 14:23:36 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
return !(m_bAfterLast || m_bBeforeFirst);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Bool ORowSetCache::relative( sal_Int32 rows )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
sal_Bool bErg = sal_True;
|
|
|
|
if(rows)
|
|
|
|
{
|
2006-01-25 14:10:43 +00:00
|
|
|
sal_Int32 nNewPosition = m_nPosition + rows;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2006-01-25 14:10:43 +00:00
|
|
|
if ( m_bBeforeFirst && rows > 0 )
|
|
|
|
nNewPosition = rows;
|
|
|
|
else if ( m_bRowCountFinal && m_bAfterLast && rows < 0 )
|
|
|
|
nNewPosition = m_nRowCount + 1 + rows;
|
|
|
|
else
|
|
|
|
if ( m_bBeforeFirst || ( m_bRowCountFinal && m_bAfterLast ) )
|
|
|
|
throw SQLException( DBACORE_RESSTRING( RID_STR_NO_RELATIVE ), NULL, SQLSTATE_GENERAL, 1000, Any() );
|
|
|
|
if ( nNewPosition )
|
|
|
|
{
|
|
|
|
bErg = absolute( nNewPosition );
|
2001-06-26 09:30:55 +00:00
|
|
|
bErg = bErg && !isAfterLast() && !isBeforeFirst();
|
|
|
|
}
|
|
|
|
else
|
2006-01-25 14:10:43 +00:00
|
|
|
{
|
|
|
|
m_bBeforeFirst = sal_True;
|
|
|
|
bErg = sal_False;
|
|
|
|
}
|
2001-06-26 09:30:55 +00:00
|
|
|
}
|
|
|
|
return bErg;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Bool ORowSetCache::previous( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
if(!isBeforeFirst())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
if(m_bAfterLast) // we stand after the last row so one before is the last row
|
|
|
|
bRet = last();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_bAfterLast = sal_False;
|
|
|
|
--m_nPosition;
|
|
|
|
moveWindow();
|
|
|
|
OSL_ENSURE(((m_nPosition - m_nStartPos) - 1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-06-26 09:30:55 +00:00
|
|
|
checkPositionFlags();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-06-26 09:30:55 +00:00
|
|
|
if(!m_nPosition)
|
|
|
|
{
|
|
|
|
m_bBeforeFirst = sal_True;
|
|
|
|
m_aMatrixIter = m_pMatrix->end();
|
|
|
|
}
|
|
|
|
else
|
2001-12-19 14:16:17 +00:00
|
|
|
{
|
|
|
|
m_aMatrixIter = calcPosition();
|
2010-10-15 12:22:54 -05:00
|
|
|
bRet = (*m_aMatrixIter).is();
|
2001-12-19 14:16:17 +00:00
|
|
|
}
|
2001-06-26 09:30:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return bRet;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
void ORowSetCache::refreshRow( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if(isAfterLast())
|
2004-06-01 09:09:25 +00:00
|
|
|
throw SQLException(DBACORE_RESSTRING(RID_STR_NO_REFESH_AFTERLAST),NULL,SQLSTATE_GENERAL,1000,Any() );
|
2001-01-22 06:38:24 +00:00
|
|
|
OSL_ENSURE(m_aMatrixIter != m_pMatrix->end(),"refreshRow() called for invalid row!");
|
|
|
|
m_pCacheSet->refreshRow();
|
2000-11-14 12:28:20 +00:00
|
|
|
m_pCacheSet->fillValueRow(*m_aMatrixIter,m_nPosition);
|
2006-02-06 15:54:31 +00:00
|
|
|
if ( m_bNew )
|
2002-07-11 06:02:27 +00:00
|
|
|
{
|
2002-12-05 08:54:54 +00:00
|
|
|
cancelRowModification();
|
2002-07-11 06:02:27 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Bool ORowSetCache::rowUpdated( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return m_pCacheSet->rowUpdated();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
sal_Bool ORowSetCache::rowInserted( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return m_pCacheSet->rowInserted();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
// XResultSetUpdate
|
2010-02-15 09:53:53 +01:00
|
|
|
sal_Bool ORowSetCache::insertRow(::std::vector< Any >& o_aBookmarks)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-10-15 12:22:54 -05:00
|
|
|
if ( !m_bNew || !m_aInsertRow->is() )
|
2004-06-01 09:09:25 +00:00
|
|
|
throw SQLException(DBACORE_RESSTRING(RID_STR_NO_MOVETOINSERTROW_CALLED),NULL,SQLSTATE_GENERAL,1000,Any() );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2000-09-29 14:23:36 +00:00
|
|
|
m_pCacheSet->insertRow(*m_aInsertRow,m_aUpdateTable);
|
2000-12-06 08:55:44 +00:00
|
|
|
|
2006-07-10 14:03:49 +00:00
|
|
|
sal_Bool bRet( rowInserted() );
|
|
|
|
if ( bRet )
|
2000-09-29 14:23:36 +00:00
|
|
|
{
|
|
|
|
++m_nRowCount;
|
2008-12-30 13:32:01 +00:00
|
|
|
Any aBookmark = ((*m_aInsertRow)->get())[0].makeAny();
|
2000-12-06 08:55:44 +00:00
|
|
|
m_bAfterLast = m_bBeforeFirst = sal_False;
|
2001-01-22 06:38:24 +00:00
|
|
|
if(aBookmark.hasValue())
|
2010-02-15 09:53:53 +01:00
|
|
|
{
|
2001-01-22 06:38:24 +00:00
|
|
|
moveToBookmark(aBookmark);
|
2010-02-15 09:53:53 +01:00
|
|
|
// update the cached values
|
|
|
|
ORowSetValueVector::Vector& rCurrentRow = ((*m_aMatrixIter))->get();
|
|
|
|
ORowSetMatrix::iterator aIter = m_pMatrix->begin();
|
|
|
|
for(;aIter != m_pMatrix->end();++aIter)
|
|
|
|
{
|
2010-10-15 12:22:54 -05:00
|
|
|
if ( m_aMatrixIter != aIter && aIter->is() && m_pCacheSet->columnValuesUpdated((*aIter)->get(),rCurrentRow) )
|
2010-02-15 09:53:53 +01:00
|
|
|
{
|
|
|
|
o_aBookmarks.push_back(lcl_getBookmark((*aIter)->get()[0],m_pCacheSet));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-01-22 06:38:24 +00:00
|
|
|
else
|
|
|
|
{
|
2011-03-12 12:04:35 +01:00
|
|
|
OSL_FAIL("There must be a bookmark after the row was inserted!");
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
2002-12-10 11:50:04 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-10 11:50:04 +00:00
|
|
|
void ORowSetCache::resetInsertRow(sal_Bool _bClearInsertRow)
|
|
|
|
{
|
|
|
|
if ( _bClearInsertRow )
|
|
|
|
clearInsertRow();
|
2000-09-29 14:23:36 +00:00
|
|
|
m_bNew = sal_False;
|
|
|
|
m_bModified = sal_False;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 08:54:54 +00:00
|
|
|
void ORowSetCache::cancelRowModification()
|
2000-09-29 14:23:36 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
// clear the insertrow references -> implies that the current row of the rowset changes as well
|
|
|
|
ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin();
|
2006-01-25 12:43:29 +00:00
|
|
|
ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end();
|
|
|
|
for(;aCacheIter != aCacheEnd;++aCacheIter)
|
2001-06-26 09:30:55 +00:00
|
|
|
{
|
2006-01-25 14:10:43 +00:00
|
|
|
if ( aCacheIter->second.pRowSet->isInsertRow() && aCacheIter->second.aIterator == m_aInsertRow )
|
2006-01-25 12:43:29 +00:00
|
|
|
aCacheIter->second.aIterator = m_pMatrix->end();
|
2010-11-09 22:15:21 +00:00
|
|
|
}
|
2006-01-25 12:43:29 +00:00
|
|
|
resetInsertRow(sal_False);
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
void ORowSetCache::updateRow( ORowSetMatrix::iterator& _rUpdateRow,::std::vector< Any >& o_aBookmarks )
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
|
|
|
if(isAfterLast() || isBeforeFirst())
|
2004-06-01 09:09:25 +00:00
|
|
|
throw SQLException(DBACORE_RESSTRING(RID_STR_NO_UPDATEROW),NULL,SQLSTATE_GENERAL,1000,Any() );
|
2001-01-22 06:38:24 +00:00
|
|
|
|
2008-12-30 13:32:01 +00:00
|
|
|
Any aBookmark = ((*_rUpdateRow)->get())[0].makeAny();
|
2001-07-24 12:25:26 +00:00
|
|
|
OSL_ENSURE(aBookmark.hasValue(),"Bookmark must have a value!");
|
2002-08-08 06:07:42 +00:00
|
|
|
// here we don't have to reposition our CacheSet, when we try to update a row,
|
|
|
|
// the row was already fetched
|
2001-07-23 06:54:41 +00:00
|
|
|
moveToBookmark(aBookmark);
|
2001-01-22 06:38:24 +00:00
|
|
|
m_pCacheSet->updateRow(*_rUpdateRow,*m_aMatrixIter,m_aUpdateTable);
|
2001-05-22 12:08:22 +00:00
|
|
|
// refetch the whole row
|
|
|
|
(*m_aMatrixIter) = NULL;
|
2009-11-27 10:17:16 +01:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
if ( moveToBookmark(aBookmark) )
|
|
|
|
{
|
|
|
|
// update the cached values
|
|
|
|
ORowSetValueVector::Vector& rCurrentRow = ((*m_aMatrixIter))->get();
|
|
|
|
ORowSetMatrix::iterator aIter = m_pMatrix->begin();
|
|
|
|
for(;aIter != m_pMatrix->end();++aIter)
|
|
|
|
{
|
2010-10-15 12:22:54 -05:00
|
|
|
if ( m_aMatrixIter != aIter && aIter->is() && m_pCacheSet->columnValuesUpdated((*aIter)->get(),rCurrentRow) )
|
2010-02-15 09:53:53 +01:00
|
|
|
{
|
|
|
|
o_aBookmarks.push_back(lcl_getBookmark((*aIter)->get()[0],m_pCacheSet));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-05-11 05:14:11 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
m_bModified = sal_False;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2006-01-25 14:10:43 +00:00
|
|
|
bool ORowSetCache::deleteRow( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if(isAfterLast() || isBeforeFirst())
|
2004-06-01 09:09:25 +00:00
|
|
|
throw SQLException(DBACORE_RESSTRING(RID_STR_NO_DELETEROW),NULL,SQLSTATE_GENERAL,1000,Any() );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
m_pCacheSet->deleteRow(*m_aMatrixIter,m_aUpdateTable);
|
2006-01-25 14:10:43 +00:00
|
|
|
if ( !m_pCacheSet->rowDeleted() )
|
|
|
|
return false;
|
2000-12-06 08:55:44 +00:00
|
|
|
|
2006-01-25 14:10:43 +00:00
|
|
|
--m_nRowCount;
|
|
|
|
OSL_ENSURE(((m_nPosition - m_nStartPos) - 1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
|
|
|
|
ORowSetMatrix::iterator aPos = calcPosition();
|
|
|
|
(*aPos) = NULL;
|
2000-12-06 08:55:44 +00:00
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
ORowSetMatrix::iterator aEnd = m_pMatrix->end();
|
2010-10-15 12:22:54 -05:00
|
|
|
for(++aPos;aPos != aEnd && aPos->is();++aPos)
|
2006-01-25 14:10:43 +00:00
|
|
|
{
|
|
|
|
*(aPos-1) = *aPos;
|
|
|
|
(*aPos) = NULL;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2006-01-25 14:10:43 +00:00
|
|
|
m_aMatrixIter = m_pMatrix->end();
|
|
|
|
|
|
|
|
--m_nPosition;
|
|
|
|
return true;
|
2006-01-25 12:43:29 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
void ORowSetCache::cancelRowUpdates( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2006-02-06 15:54:31 +00:00
|
|
|
m_bNew = m_bModified = sal_False;
|
2001-04-05 06:51:27 +00:00
|
|
|
if(!m_nPosition)
|
|
|
|
{
|
2011-03-12 12:04:35 +01:00
|
|
|
OSL_FAIL("cancelRowUpdates:Invalid positions pos == 0");
|
2001-04-19 06:14:49 +00:00
|
|
|
::dbtools::throwFunctionSequenceException(NULL);
|
2001-04-05 06:51:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(m_pCacheSet->absolute(m_nPosition))
|
|
|
|
m_pCacheSet->fillValueRow(*m_aMatrixIter,m_nPosition);
|
|
|
|
else
|
|
|
|
{
|
2011-03-12 12:04:35 +01:00
|
|
|
OSL_FAIL("cancelRowUpdates couldn't position right with absolute");
|
2001-04-19 06:14:49 +00:00
|
|
|
::dbtools::throwFunctionSequenceException(NULL);
|
2001-04-05 06:51:27 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2002-12-05 13:10:11 +00:00
|
|
|
void ORowSetCache::moveToInsertRow( )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
m_bNew = sal_True;
|
2006-01-25 14:10:43 +00:00
|
|
|
m_bUpdated = m_bAfterLast = sal_False;
|
2000-09-29 14:23:36 +00:00
|
|
|
|
|
|
|
m_aInsertRow = m_pInsertMatrix->begin();
|
2010-10-15 12:22:54 -05:00
|
|
|
if(!m_aInsertRow->is())
|
2003-03-19 16:57:12 +00:00
|
|
|
*m_aInsertRow = new ORowSetValueVector(m_xMetaData->getColumnCount());
|
2000-09-29 14:23:36 +00:00
|
|
|
|
|
|
|
// we don't unbound the bookmark column
|
2008-12-30 13:32:01 +00:00
|
|
|
ORowSetValueVector::Vector::iterator aIter = (*m_aInsertRow)->get().begin()+1;
|
2009-07-03 12:24:35 +00:00
|
|
|
ORowSetValueVector::Vector::iterator aEnd = (*m_aInsertRow)->get().end();
|
2009-11-13 13:30:51 +01:00
|
|
|
for(sal_Int32 i = 1;aIter != aEnd;++aIter,++i)
|
2000-09-29 14:23:36 +00:00
|
|
|
{
|
|
|
|
aIter->setBound(sal_False);
|
2000-12-06 08:55:44 +00:00
|
|
|
aIter->setModified(sal_False);
|
2000-09-29 14:23:36 +00:00
|
|
|
aIter->setNull();
|
2009-11-13 13:30:51 +01:00
|
|
|
aIter->setTypeKind(m_xMetaData->getColumnType(i));
|
2000-09-29 14:23:36 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2006-01-25 12:43:29 +00:00
|
|
|
ORowSetCacheIterator ORowSetCache::createIterator(ORowSetBase* _pRowSet)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
|
|
|
ORowSetCacheIterator_Helper aHelper;
|
|
|
|
aHelper.aIterator = m_pMatrix->end();
|
2006-01-25 12:43:29 +00:00
|
|
|
aHelper.pRowSet = _pRowSet;
|
|
|
|
return ORowSetCacheIterator(m_aCacheIterators.insert(m_aCacheIterators.begin(),ORowSetCacheMap::value_type(m_aCacheIterators.size()+1,aHelper)),this,_pRowSet);
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
CWS-TOOLING: integrate CWS dba32e
2009-08-10 13:16:25 +0200 fs r274805 : #i84390# typo corrected
2009-08-10 13:04:28 +0200 fs r274804 : #i103741# properly terminate the last token in a string with a 0 byte
2009-07-24 08:54:05 +0200 msc r274286 : #103219# changed long name
2009-07-24 08:42:28 +0200 msc r274285 : #i79649# changed behaviour of the wizard
2009-07-22 14:17:49 +0200 oj r274238 : GrabFocus
2009-07-22 13:38:01 +0200 oj r274232 : #i102934# mixed up
2009-07-22 13:37:16 +0200 oj r274231 : #i102934# mixed up
2009-07-21 12:30:36 +0200 oj r274176 : crash when using distinct
2009-07-21 10:03:44 +0200 oj r274163 : set last char to 0
2009-07-21 09:31:22 +0200 oj r274161 : mediatype corrected
2009-07-20 11:45:33 +0200 fs r274118 : typo in formatting string
2009-07-20 11:40:39 +0200 fs r274117 : removed unused include
2009-07-20 11:40:01 +0200 fs r274116 : class name corrected
2009-07-16 13:41:45 +0200 oj r274046 : i101587 wrong check for embeddeddatabase url in confguration, have to check path
2009-07-16 13:12:05 +0200 tbo r274044 : #i103219# adjust declarion to new hid.lst
2009-07-16 12:43:48 +0200 oj r274041 : #i102497# check also fot longvarchar
2009-07-16 12:15:41 +0200 oj r274039 : #i103030# handle type description and exceptions as well
2009-07-16 11:14:26 +0200 fs r274035 : let SVN ignore output paths
2009-07-16 09:23:43 +0200 fs r274030 : TransforFormComponentProperties: no need to check for attribute equality
2009-07-10 14:16:23 +0200 oj r273892 : CWS-TOOLING: rebase CWS dba32e to trunk@273858 (milestone: DEV300:m52)
2009-07-01 21:41:50 +0200 fs r273614 : #i10000#
2009-07-01 15:01:10 +0200 fs r273589 : Input required doesn't make sense at all in XML form documents
2009-07-01 12:10:31 +0200 fs r273562 : updated
2009-07-01 11:46:12 +0200 fs r273560 : #i103219# add about 100 missing long names
2009-07-01 10:11:41 +0200 fs r273551 : moved from socket/port usage to pipe/name usage, which is more common nowadays
2009-07-01 09:50:03 +0200 fs r273549 : removed obsolete (empty) folder
2009-07-01 09:47:35 +0200 fs r273548 : copied the code for the Accessibility Workbench herein, formerly located in the old CVS repository, at gsl/awb
2009-06-30 10:07:47 +0200 fs r273493 : merging latest changes from CWS dba32d
2009-06-29 20:46:31 +0200 fs r273482 : #i103138# Rectangle conversions
2009-06-29 10:01:13 +0200 fs r273453 : #i103138#
refactored the code for positioning/zooming the control
Basically, we now allow adjustControlGeometry_throw (formerly known as positionControl_throw and setControlZoom) to
take an additional ViewTransformation parameter, describing the transformation to obtain the actual
control position/size. Consequently, positionControl itself also allows for a ViewTransformation parameter.
This has become necessary since during painting, the device which we created our control for might not necessarily
have a proper MapMode set. In this case, if we would use this map mode for calculating the control's position/size,
this would lead to wrong results.
Note that this problem was introduced by the fix for #i101398#: During the fix, we postponed the control creation
to a later time (when it is really needed). At this later time, the MapMode at the device is broken, at the earlier
time where we formerly crearted the control (createPrimitive2DSequence), it is not yet broken.
Whether or not the MapMode is defined as "broken" might depend on one's point of view, however ...
I consider it broken, since:
- we need the map mode to obtain the proper zoom level, which is to be forwarded to the control
- there are scenarios where the MapMode is *not* set to MAP_PIXEL (in those scenarios, everything works
fine), and there are scenarios where it *is* set to MAP_PIXEL (in those the bug 103138 appears).
It somehow feels wrong that one cannot rely on the device's map mode this way, but on the other hand
one has no possibility to obtain the current zoom by other means.
Note that one issue (still to be submitted) is left: In the page pane of a Draw/Impress document, controls
have a wrong text size. This is because in this pane, the above-mentioned "broken" map mode is used,
which means the controls have a zoom of "1:1" set, which is wrong here.
2009-06-29 09:52:13 +0200 fs r273452 : during #i103138#: belongsToDevice is unused nowadays
2009-06-24 12:40:06 +0200 fs r273329 : #i102888# #i102899#
2009-06-24 12:10:29 +0200 oj r273327 : #i103030# some code changes
2009-06-24 09:44:14 +0200 oj r273311 : #i103030# some code changes
2009-06-24 09:24:42 +0200 oj r273309 : #i103030# add log
2009-06-24 09:03:29 +0200 fs r273308 : if a col's table name is schema.table, properly quote all parts
2009-06-24 08:56:06 +0200 oj r273307 : #i102691# changed string
2009-06-23 13:31:43 +0200 oj r273280 : #i102479# fix date, time and datetime
2009-06-23 12:51:28 +0200 oj r273277 : #i103020# clear old expression when updating to avoid dead pointers in treelist userdata
2009-06-23 12:17:16 +0200 oj r273275 : #i103030# add LogBridge
2009-06-23 11:53:10 +0200 oj r273272 : shawdowed var resolved
2009-06-23 11:48:49 +0200 oj r273270 : #i103030# add :log to uno env if var UNO_ENV_LOG is set
2009-06-23 11:47:47 +0200 oj r273269 : #i103030# add LogBridge
2009-06-23 11:47:11 +0200 oj r273268 : #i103030# add LogBridge
2009-06-23 08:05:08 +0200 oj r273253 : #i102934# add key for collapsing
2009-06-22 13:21:33 +0200 fs r273225 : merging latest changes from CWS dba32d
2009-06-22 13:15:22 +0200 fs r273221 : why restrict to 12 entries?
2009-06-22 08:12:21 +0200 oj r273196 : #i102655# choosen > chosen typo fixed
2009-06-22 08:08:04 +0200 oj r273195 : #i102657# typo fix
2009-06-22 08:06:28 +0200 oj r273194 : #i102934# expanding and collasping of section
2009-06-22 08:05:52 +0200 oj r273193 : #i102930# set focus in treelistbox
2009-06-22 08:04:56 +0200 oj r273192 : #i102929# enable tabstop
2009-06-19 13:18:26 +0200 oj r273157 : remove unused param
2009-06-19 10:07:05 +0200 oj r273149 : CWS-TOOLING: rebase CWS dba32e to trunk@272827 (milestone: DEV300:m50)
2009-06-19 07:32:40 +0200 oj r273146 : merge from dba32d to dba32e
2009-06-19 07:22:56 +0200 oj r273145 : merge from dba32d to dba32e
2009-06-19 07:22:33 +0200 oj r273144 : merge from dba32d to dba32e
2009-06-18 14:09:34 +0200 fs r273116 : merging the latest changes from CWS dba32d (up to revision 273108) herein, which effectively is a rebase to DEV300.m50
2009-06-18 08:50:35 +0200 oj r273098 : #i102894# fix for new line in text
2009-06-18 08:28:48 +0200 oj r273097 : #i102892# check any
2009-06-18 08:21:34 +0200 oj r273096 : check if error is valid
2009-06-16 13:49:28 +0200 fs r273019 : why make a drop down control by default? The form control factory in SVX does this better those days ...
2009-06-10 09:53:20 +0200 oj r272797 : add lic text
2009-06-10 09:48:55 +0200 oj r272796 : test added for i101618
2009-06-09 14:57:39 +0200 oj r272771 : #i101618# access database document only when script container is needed
2009-06-09 12:42:25 +0200 oj r272765 : #i102497# check type property
2009-06-09 12:32:49 +0200 oj r272764 : adjust test cases
2009-06-09 12:31:58 +0200 oj r272763 : adjust test cases
2009-06-09 12:31:22 +0200 oj r272762 : adjust test cases
2009-06-09 11:35:42 +0200 oj r272761 : check if error is valid
2009-06-09 11:29:42 +0200 oj r272760 : #i102497# longvarchar was missing
2009-06-08 14:52:49 +0200 fs r272733 : #i102564# when setting a new field, also set m_nFieldType
2009-06-08 13:51:20 +0200 oj r272730 : add tests
2009-06-05 14:38:01 +0200 oj r272686 : add dep
2009-06-05 14:35:00 +0200 oj r272684 : add new tests
2009-06-05 13:41:18 +0200 oj r272681 : code clean ups
2009-06-05 12:40:51 +0200 oj r272678 : code cleanup
2009-06-05 12:02:57 +0200 oj r272677 : code cleanup
2009-06-05 10:42:38 +0200 oj r272670 : #i49320# impl export of single rows and as RTF and HTML
2009-06-03 14:30:37 +0200 oj r272576 : #i79649# check if file matches filter wildcard
2009-06-03 13:41:57 +0200 oj r272560 : #i102470# impl not b like 'c'
2009-08-26 10:09:17 +00:00
|
|
|
void ORowSetCache::deleteIterator(const ORowSetBase* _pRowSet)
|
|
|
|
{
|
|
|
|
ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin();
|
|
|
|
for(;aCacheIter != m_aCacheIterators.end();)
|
|
|
|
{
|
|
|
|
if ( aCacheIter->second.pRowSet == _pRowSet )
|
|
|
|
{
|
|
|
|
m_aCacheIterators.erase(aCacheIter);
|
|
|
|
aCacheIter = m_aCacheIterators.begin();
|
2010-11-09 22:15:21 +00:00
|
|
|
}
|
CWS-TOOLING: integrate CWS dba32e
2009-08-10 13:16:25 +0200 fs r274805 : #i84390# typo corrected
2009-08-10 13:04:28 +0200 fs r274804 : #i103741# properly terminate the last token in a string with a 0 byte
2009-07-24 08:54:05 +0200 msc r274286 : #103219# changed long name
2009-07-24 08:42:28 +0200 msc r274285 : #i79649# changed behaviour of the wizard
2009-07-22 14:17:49 +0200 oj r274238 : GrabFocus
2009-07-22 13:38:01 +0200 oj r274232 : #i102934# mixed up
2009-07-22 13:37:16 +0200 oj r274231 : #i102934# mixed up
2009-07-21 12:30:36 +0200 oj r274176 : crash when using distinct
2009-07-21 10:03:44 +0200 oj r274163 : set last char to 0
2009-07-21 09:31:22 +0200 oj r274161 : mediatype corrected
2009-07-20 11:45:33 +0200 fs r274118 : typo in formatting string
2009-07-20 11:40:39 +0200 fs r274117 : removed unused include
2009-07-20 11:40:01 +0200 fs r274116 : class name corrected
2009-07-16 13:41:45 +0200 oj r274046 : i101587 wrong check for embeddeddatabase url in confguration, have to check path
2009-07-16 13:12:05 +0200 tbo r274044 : #i103219# adjust declarion to new hid.lst
2009-07-16 12:43:48 +0200 oj r274041 : #i102497# check also fot longvarchar
2009-07-16 12:15:41 +0200 oj r274039 : #i103030# handle type description and exceptions as well
2009-07-16 11:14:26 +0200 fs r274035 : let SVN ignore output paths
2009-07-16 09:23:43 +0200 fs r274030 : TransforFormComponentProperties: no need to check for attribute equality
2009-07-10 14:16:23 +0200 oj r273892 : CWS-TOOLING: rebase CWS dba32e to trunk@273858 (milestone: DEV300:m52)
2009-07-01 21:41:50 +0200 fs r273614 : #i10000#
2009-07-01 15:01:10 +0200 fs r273589 : Input required doesn't make sense at all in XML form documents
2009-07-01 12:10:31 +0200 fs r273562 : updated
2009-07-01 11:46:12 +0200 fs r273560 : #i103219# add about 100 missing long names
2009-07-01 10:11:41 +0200 fs r273551 : moved from socket/port usage to pipe/name usage, which is more common nowadays
2009-07-01 09:50:03 +0200 fs r273549 : removed obsolete (empty) folder
2009-07-01 09:47:35 +0200 fs r273548 : copied the code for the Accessibility Workbench herein, formerly located in the old CVS repository, at gsl/awb
2009-06-30 10:07:47 +0200 fs r273493 : merging latest changes from CWS dba32d
2009-06-29 20:46:31 +0200 fs r273482 : #i103138# Rectangle conversions
2009-06-29 10:01:13 +0200 fs r273453 : #i103138#
refactored the code for positioning/zooming the control
Basically, we now allow adjustControlGeometry_throw (formerly known as positionControl_throw and setControlZoom) to
take an additional ViewTransformation parameter, describing the transformation to obtain the actual
control position/size. Consequently, positionControl itself also allows for a ViewTransformation parameter.
This has become necessary since during painting, the device which we created our control for might not necessarily
have a proper MapMode set. In this case, if we would use this map mode for calculating the control's position/size,
this would lead to wrong results.
Note that this problem was introduced by the fix for #i101398#: During the fix, we postponed the control creation
to a later time (when it is really needed). At this later time, the MapMode at the device is broken, at the earlier
time where we formerly crearted the control (createPrimitive2DSequence), it is not yet broken.
Whether or not the MapMode is defined as "broken" might depend on one's point of view, however ...
I consider it broken, since:
- we need the map mode to obtain the proper zoom level, which is to be forwarded to the control
- there are scenarios where the MapMode is *not* set to MAP_PIXEL (in those scenarios, everything works
fine), and there are scenarios where it *is* set to MAP_PIXEL (in those the bug 103138 appears).
It somehow feels wrong that one cannot rely on the device's map mode this way, but on the other hand
one has no possibility to obtain the current zoom by other means.
Note that one issue (still to be submitted) is left: In the page pane of a Draw/Impress document, controls
have a wrong text size. This is because in this pane, the above-mentioned "broken" map mode is used,
which means the controls have a zoom of "1:1" set, which is wrong here.
2009-06-29 09:52:13 +0200 fs r273452 : during #i103138#: belongsToDevice is unused nowadays
2009-06-24 12:40:06 +0200 fs r273329 : #i102888# #i102899#
2009-06-24 12:10:29 +0200 oj r273327 : #i103030# some code changes
2009-06-24 09:44:14 +0200 oj r273311 : #i103030# some code changes
2009-06-24 09:24:42 +0200 oj r273309 : #i103030# add log
2009-06-24 09:03:29 +0200 fs r273308 : if a col's table name is schema.table, properly quote all parts
2009-06-24 08:56:06 +0200 oj r273307 : #i102691# changed string
2009-06-23 13:31:43 +0200 oj r273280 : #i102479# fix date, time and datetime
2009-06-23 12:51:28 +0200 oj r273277 : #i103020# clear old expression when updating to avoid dead pointers in treelist userdata
2009-06-23 12:17:16 +0200 oj r273275 : #i103030# add LogBridge
2009-06-23 11:53:10 +0200 oj r273272 : shawdowed var resolved
2009-06-23 11:48:49 +0200 oj r273270 : #i103030# add :log to uno env if var UNO_ENV_LOG is set
2009-06-23 11:47:47 +0200 oj r273269 : #i103030# add LogBridge
2009-06-23 11:47:11 +0200 oj r273268 : #i103030# add LogBridge
2009-06-23 08:05:08 +0200 oj r273253 : #i102934# add key for collapsing
2009-06-22 13:21:33 +0200 fs r273225 : merging latest changes from CWS dba32d
2009-06-22 13:15:22 +0200 fs r273221 : why restrict to 12 entries?
2009-06-22 08:12:21 +0200 oj r273196 : #i102655# choosen > chosen typo fixed
2009-06-22 08:08:04 +0200 oj r273195 : #i102657# typo fix
2009-06-22 08:06:28 +0200 oj r273194 : #i102934# expanding and collasping of section
2009-06-22 08:05:52 +0200 oj r273193 : #i102930# set focus in treelistbox
2009-06-22 08:04:56 +0200 oj r273192 : #i102929# enable tabstop
2009-06-19 13:18:26 +0200 oj r273157 : remove unused param
2009-06-19 10:07:05 +0200 oj r273149 : CWS-TOOLING: rebase CWS dba32e to trunk@272827 (milestone: DEV300:m50)
2009-06-19 07:32:40 +0200 oj r273146 : merge from dba32d to dba32e
2009-06-19 07:22:56 +0200 oj r273145 : merge from dba32d to dba32e
2009-06-19 07:22:33 +0200 oj r273144 : merge from dba32d to dba32e
2009-06-18 14:09:34 +0200 fs r273116 : merging the latest changes from CWS dba32d (up to revision 273108) herein, which effectively is a rebase to DEV300.m50
2009-06-18 08:50:35 +0200 oj r273098 : #i102894# fix for new line in text
2009-06-18 08:28:48 +0200 oj r273097 : #i102892# check any
2009-06-18 08:21:34 +0200 oj r273096 : check if error is valid
2009-06-16 13:49:28 +0200 fs r273019 : why make a drop down control by default? The form control factory in SVX does this better those days ...
2009-06-10 09:53:20 +0200 oj r272797 : add lic text
2009-06-10 09:48:55 +0200 oj r272796 : test added for i101618
2009-06-09 14:57:39 +0200 oj r272771 : #i101618# access database document only when script container is needed
2009-06-09 12:42:25 +0200 oj r272765 : #i102497# check type property
2009-06-09 12:32:49 +0200 oj r272764 : adjust test cases
2009-06-09 12:31:58 +0200 oj r272763 : adjust test cases
2009-06-09 12:31:22 +0200 oj r272762 : adjust test cases
2009-06-09 11:35:42 +0200 oj r272761 : check if error is valid
2009-06-09 11:29:42 +0200 oj r272760 : #i102497# longvarchar was missing
2009-06-08 14:52:49 +0200 fs r272733 : #i102564# when setting a new field, also set m_nFieldType
2009-06-08 13:51:20 +0200 oj r272730 : add tests
2009-06-05 14:38:01 +0200 oj r272686 : add dep
2009-06-05 14:35:00 +0200 oj r272684 : add new tests
2009-06-05 13:41:18 +0200 oj r272681 : code clean ups
2009-06-05 12:40:51 +0200 oj r272678 : code cleanup
2009-06-05 12:02:57 +0200 oj r272677 : code cleanup
2009-06-05 10:42:38 +0200 oj r272670 : #i49320# impl export of single rows and as RTF and HTML
2009-06-03 14:30:37 +0200 oj r272576 : #i79649# check if file matches filter wildcard
2009-06-03 13:41:57 +0200 oj r272560 : #i102470# impl not b like 'c'
2009-08-26 10:09:17 +00:00
|
|
|
else
|
|
|
|
++aCacheIter;
|
|
|
|
}
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2006-07-26 06:46:13 +00:00
|
|
|
void ORowSetCache::rotateCacheIterator(ORowSetMatrix::difference_type _nDist)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
if(_nDist)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2001-06-26 09:30:55 +00:00
|
|
|
// now correct the iterator in our iterator vector
|
|
|
|
ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end();
|
|
|
|
for(;aCacheIter != aCacheEnd;++aCacheIter)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2006-01-25 14:10:43 +00:00
|
|
|
if ( !aCacheIter->second.pRowSet->isInsertRow()
|
2006-02-06 15:54:31 +00:00
|
|
|
&& aCacheIter->second.aIterator != m_pMatrix->end() && !m_bModified )
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2006-07-10 14:03:49 +00:00
|
|
|
ptrdiff_t nDist = (aCacheIter->second.aIterator - m_pMatrix->begin());
|
2001-06-26 09:30:55 +00:00
|
|
|
if(nDist < _nDist)
|
|
|
|
{
|
2005-09-05 07:57:54 +00:00
|
|
|
aCacheIter->second.aIterator = m_pMatrix->end();
|
2001-06-26 09:30:55 +00:00
|
|
|
}
|
|
|
|
else
|
2002-11-13 05:56:59 +00:00
|
|
|
{
|
2006-07-26 06:46:13 +00:00
|
|
|
OSL_ENSURE((aCacheIter->second.aIterator - m_pMatrix->begin()) >= _nDist,"Invalid Dist value!");
|
2001-06-26 09:30:55 +00:00
|
|
|
aCacheIter->second.aIterator -= _nDist;
|
2002-11-13 05:56:59 +00:00
|
|
|
OSL_ENSURE(aCacheIter->second.aIterator >= m_pMatrix->begin()
|
2002-12-05 08:54:54 +00:00
|
|
|
&& aCacheIter->second.aIterator < m_pMatrix->end(),"Iterator out of area!");
|
2002-11-13 05:56:59 +00:00
|
|
|
}
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-22 06:38:24 +00:00
|
|
|
void ORowSetCache::setUpdateIterator(const ORowSetMatrix::iterator& _rOriginalRow)
|
|
|
|
{
|
|
|
|
m_aInsertRow = m_pInsertMatrix->begin();
|
2010-10-15 12:22:54 -05:00
|
|
|
if(!m_aInsertRow->is())
|
2003-03-19 16:57:12 +00:00
|
|
|
*m_aInsertRow = new ORowSetValueVector(m_xMetaData->getColumnCount());
|
2001-01-22 06:38:24 +00:00
|
|
|
|
|
|
|
(*(*m_aInsertRow)) = (*(*_rOriginalRow));
|
|
|
|
// we don't unbound the bookmark column
|
2008-12-30 13:32:01 +00:00
|
|
|
ORowSetValueVector::Vector::iterator aIter = (*m_aInsertRow)->get().begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
ORowSetValueVector::Vector::iterator aEnd = (*m_aInsertRow)->get().end();
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-01-22 06:38:24 +00:00
|
|
|
aIter->setModified(sal_False);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-26 09:30:55 +00:00
|
|
|
void ORowSetCache::checkPositionFlags()
|
|
|
|
{
|
|
|
|
if(m_bRowCountFinal)
|
|
|
|
{
|
|
|
|
m_bAfterLast = m_nPosition > m_nRowCount;
|
|
|
|
if(m_bAfterLast)
|
|
|
|
m_nPosition = 0;//m_nRowCount;
|
|
|
|
}
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-26 09:30:55 +00:00
|
|
|
void ORowSetCache::checkUpdateConditions(sal_Int32 columnIndex)
|
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
if(m_bAfterLast || columnIndex >= (sal_Int32)(*m_aInsertRow)->get().size())
|
2001-06-26 09:30:55 +00:00
|
|
|
throwFunctionSequenceException(m_xSet.get());
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2006-08-15 09:42:22 +00:00
|
|
|
sal_Bool ORowSetCache::checkInnerJoin(const ::connectivity::OSQLParseNode *pNode,const Reference< XConnection>& _xConnection,const ::rtl::OUString& _sUpdateTableName)
|
|
|
|
{
|
|
|
|
sal_Bool bOk = sal_False;
|
2010-11-08 02:50:53 -06:00
|
|
|
if (pNode->count() == 3 && // Ausdruck is geklammert
|
2006-08-15 09:42:22 +00:00
|
|
|
SQL_ISPUNCTUATION(pNode->getChild(0),"(") &&
|
|
|
|
SQL_ISPUNCTUATION(pNode->getChild(2),")"))
|
|
|
|
{
|
|
|
|
bOk = checkInnerJoin(pNode->getChild(1),_xConnection,_sUpdateTableName);
|
|
|
|
}
|
2010-11-09 22:15:21 +00:00
|
|
|
else if ((SQL_ISRULE(pNode,search_condition) || SQL_ISRULE(pNode,boolean_term)) && // AND/OR link
|
2006-08-15 09:42:22 +00:00
|
|
|
pNode->count() == 3)
|
|
|
|
{
|
2010-11-09 22:15:21 +00:00
|
|
|
// only allow an AND link
|
2006-10-12 12:32:14 +00:00
|
|
|
if ( SQL_ISTOKEN(pNode->getChild(1),AND) )
|
|
|
|
bOk = checkInnerJoin(pNode->getChild(0),_xConnection,_sUpdateTableName)
|
|
|
|
&& checkInnerJoin(pNode->getChild(2),_xConnection,_sUpdateTableName);
|
2006-08-15 09:42:22 +00:00
|
|
|
}
|
|
|
|
else if (SQL_ISRULE(pNode,comparison_predicate))
|
|
|
|
{
|
|
|
|
// only the comparison of columns is allowed
|
2011-02-03 00:33:36 +01:00
|
|
|
OSL_ENSURE(pNode->count() == 3,"checkInnerJoin: Fehler im Parse Tree");
|
2006-08-15 09:42:22 +00:00
|
|
|
if (!(SQL_ISRULE(pNode->getChild(0),column_ref) &&
|
|
|
|
SQL_ISRULE(pNode->getChild(2),column_ref) &&
|
|
|
|
pNode->getChild(1)->getNodeType() == SQL_NODE_EQUAL))
|
|
|
|
{
|
|
|
|
bOk = sal_False;
|
|
|
|
}
|
|
|
|
::rtl::OUString sColumnName,sTableRange;
|
2006-12-13 15:44:26 +00:00
|
|
|
OSQLParseTreeIterator::getColumnRange( pNode->getChild(0), _xConnection, sColumnName, sTableRange );
|
2006-10-12 12:32:14 +00:00
|
|
|
bOk = sTableRange == _sUpdateTableName;
|
|
|
|
if ( !bOk )
|
2006-08-15 09:42:22 +00:00
|
|
|
{
|
2006-12-13 15:44:26 +00:00
|
|
|
OSQLParseTreeIterator::getColumnRange( pNode->getChild(2), _xConnection, sColumnName, sTableRange );
|
2006-08-15 09:42:22 +00:00
|
|
|
bOk = sTableRange == _sUpdateTableName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bOk;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-07-19 08:29:22 +00:00
|
|
|
sal_Bool ORowSetCache::checkJoin(const Reference< XConnection>& _xConnection,
|
2004-11-17 13:42:39 +00:00
|
|
|
const Reference< XSingleSelectQueryAnalyzer >& _xAnalyzer,
|
2001-07-19 08:29:22 +00:00
|
|
|
const ::rtl::OUString& _sUpdateTableName )
|
|
|
|
{
|
2001-12-07 08:58:12 +00:00
|
|
|
sal_Bool bOk = sal_False;
|
2004-11-17 13:42:39 +00:00
|
|
|
::rtl::OUString sSql = _xAnalyzer->getQuery();
|
2001-07-19 08:29:22 +00:00
|
|
|
::rtl::OUString sErrorMsg;
|
2007-11-21 14:33:03 +00:00
|
|
|
::connectivity::OSQLParser aSqlParser( m_aContext.getLegacyServiceFactory() );
|
2011-09-22 15:00:08 +01:00
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_PUSH
|
2006-08-15 09:42:22 +00:00
|
|
|
::std::auto_ptr< ::connectivity::OSQLParseNode> pSqlParseNode( aSqlParser.parseTree(sErrorMsg,sSql));
|
2011-09-22 15:00:08 +01:00
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_POP
|
2006-08-15 09:42:22 +00:00
|
|
|
if ( pSqlParseNode.get() && SQL_ISRULE(pSqlParseNode, select_statement) )
|
2001-07-19 08:29:22 +00:00
|
|
|
{
|
|
|
|
OSQLParseNode* pTableRefCommalist = pSqlParseNode->getByRule(::connectivity::OSQLParseNode::table_ref_commalist);
|
|
|
|
OSL_ENSURE(pTableRefCommalist,"NO tables why!?");
|
|
|
|
if(pTableRefCommalist && pTableRefCommalist->count() == 1)
|
|
|
|
{
|
|
|
|
// we found only one element so it must some kind of join here
|
|
|
|
OSQLParseNode* pJoin = pTableRefCommalist->getByRule(::connectivity::OSQLParseNode::qualified_join);
|
|
|
|
if(pJoin)
|
2010-11-08 02:50:53 -06:00
|
|
|
{ // we are only intereseted in qualified joins like RIGHT or LEFT
|
2001-07-19 08:29:22 +00:00
|
|
|
OSQLParseNode* pJoinType = pJoin->getChild(1);
|
|
|
|
OSQLParseNode* pOuterType = NULL;
|
|
|
|
if(SQL_ISRULE(pJoinType,join_type) && pJoinType->count() == 2)
|
|
|
|
pOuterType = pJoinType->getChild(0);
|
|
|
|
else if(SQL_ISRULE(pJoinType,outer_join_type))
|
|
|
|
pOuterType = pJoinType;
|
|
|
|
|
|
|
|
sal_Bool bCheck = sal_False;
|
|
|
|
sal_Bool bLeftSide = sal_False;
|
|
|
|
if(pOuterType)
|
|
|
|
{ // found outer join
|
|
|
|
bLeftSide = SQL_ISTOKEN(pOuterType->getChild(0),LEFT);
|
|
|
|
bCheck = bLeftSide || SQL_ISTOKEN(pOuterType->getChild(0),RIGHT);
|
|
|
|
}
|
2001-12-07 08:27:32 +00:00
|
|
|
|
2001-07-19 08:29:22 +00:00
|
|
|
if(bCheck)
|
|
|
|
{ // here we know that we have to check on which side our table resides
|
2008-06-16 11:30:34 +00:00
|
|
|
const OSQLParseNode* pTableRef = pJoin->getByRule(::connectivity::OSQLParseNode::qualified_join);
|
2001-07-19 08:29:22 +00:00
|
|
|
if(bLeftSide)
|
|
|
|
pTableRef = pJoin->getChild(0);
|
|
|
|
else
|
|
|
|
pTableRef = pJoin->getChild(3);
|
|
|
|
OSL_ENSURE(SQL_ISRULE(pTableRef,table_ref),"Must be a tableref here!");
|
|
|
|
|
2008-06-16 11:30:34 +00:00
|
|
|
::rtl::OUString sTableRange = OSQLParseNode::getTableRange(pTableRef);
|
2011-12-19 18:10:37 -02:00
|
|
|
if(sTableRange.isEmpty())
|
2006-12-13 15:44:26 +00:00
|
|
|
pTableRef->getChild(0)->parseNodeToStr( sTableRange, _xConnection, NULL, sal_False, sal_False );
|
2001-07-19 08:29:22 +00:00
|
|
|
bOk = sTableRange == _sUpdateTableName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-08-15 09:42:22 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
OSQLParseNode* pWhereOpt = pSqlParseNode->getChild(3)->getChild(1);
|
|
|
|
if ( pWhereOpt && !pWhereOpt->isLeaf() )
|
|
|
|
bOk = checkInnerJoin(pWhereOpt->getChild(1),_xConnection,_sUpdateTableName);
|
|
|
|
}
|
2001-07-19 08:29:22 +00:00
|
|
|
}
|
|
|
|
return bOk;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-08-09 12:12:51 +00:00
|
|
|
void ORowSetCache::clearInsertRow()
|
|
|
|
{
|
|
|
|
// we don't unbound the bookmark column
|
2010-10-15 12:22:54 -05:00
|
|
|
if ( m_aInsertRow != m_pInsertMatrix->end() && m_aInsertRow->is() )
|
2001-08-09 12:12:51 +00:00
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
ORowSetValueVector::Vector::iterator aIter = (*m_aInsertRow)->get().begin()+1;
|
|
|
|
ORowSetValueVector::Vector::iterator aEnd = (*m_aInsertRow)->get().end();
|
2006-01-25 12:43:29 +00:00
|
|
|
for(;aIter != aEnd;++aIter)
|
|
|
|
{
|
|
|
|
aIter->setBound(sal_False);
|
|
|
|
aIter->setModified(sal_False);
|
|
|
|
aIter->setNull();
|
2010-11-09 22:15:21 +00:00
|
|
|
}
|
2001-08-09 12:12:51 +00:00
|
|
|
}
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-11-29 15:35:26 +00:00
|
|
|
ORowSetMatrix::iterator ORowSetCache::calcPosition() const
|
|
|
|
{
|
|
|
|
sal_Int32 nValue = (m_nPosition - m_nStartPos) - 1;
|
2006-07-26 06:46:13 +00:00
|
|
|
CHECK_MATRIX_POS(nValue);
|
2005-03-18 09:05:15 +00:00
|
|
|
return ( nValue < 0 || nValue >= static_cast<sal_Int32>(m_pMatrix->size()) ) ? m_pMatrix->end() : (m_pMatrix->begin() + nValue);
|
2001-11-29 15:35:26 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2003-03-19 16:57:12 +00:00
|
|
|
TORowSetOldRowHelperRef ORowSetCache::registerOldRow()
|
|
|
|
{
|
|
|
|
TORowSetOldRowHelperRef pRef = new ORowSetOldRowHelper(ORowSetRow());
|
|
|
|
m_aOldRows.push_back(pRef);
|
|
|
|
return pRef;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2003-03-19 16:57:12 +00:00
|
|
|
void ORowSetCache::deregisterOldRow(const TORowSetOldRowHelperRef& _rRow)
|
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
TOldRowSetRows::iterator aOldRowEnd = m_aOldRows.end();
|
|
|
|
for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != aOldRowEnd; ++aOldRowIter)
|
2003-03-19 16:57:12 +00:00
|
|
|
{
|
2010-10-15 12:22:54 -05:00
|
|
|
if ( aOldRowIter->get() == _rRow.get() )
|
2003-03-19 16:57:12 +00:00
|
|
|
{
|
|
|
|
m_aOldRows.erase(aOldRowIter);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2003-03-19 16:57:12 +00:00
|
|
|
sal_Bool ORowSetCache::reFillMatrix(sal_Int32 _nNewStartPos,sal_Int32 _nNewEndPos)
|
|
|
|
{
|
2012-01-31 22:53:31 +01:00
|
|
|
OSL_ENSURE( _nNewEndPos - _nNewStartPos == m_nFetchSize, "reFillMatrix called with Start/EndPos not m_nFetchSize apart");
|
2012-01-19 20:20:06 +01:00
|
|
|
const TOldRowSetRows::const_iterator aOldRowEnd = m_aOldRows.end();
|
2009-07-03 12:24:35 +00:00
|
|
|
for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != aOldRowEnd; ++aOldRowIter)
|
2003-03-19 16:57:12 +00:00
|
|
|
{
|
2010-10-15 12:22:54 -05:00
|
|
|
if ( aOldRowIter->is() && (*aOldRowIter)->getRow().is() )
|
|
|
|
(*aOldRowIter)->setRow(new ORowSetValueVector( *((*aOldRowIter)->getRow()) ) );
|
2003-03-19 16:57:12 +00:00
|
|
|
}
|
|
|
|
sal_Int32 nNewSt = _nNewStartPos;
|
|
|
|
sal_Bool bRet = fillMatrix(nNewSt,_nNewEndPos);
|
2012-01-19 20:20:06 +01:00
|
|
|
m_nStartPos = nNewSt;
|
2012-01-31 22:53:31 +01:00
|
|
|
m_nEndPos = _nNewEndPos;
|
2012-01-19 20:20:06 +01:00
|
|
|
rotateCacheIterator(static_cast<ORowSetMatrix::difference_type>(m_nFetchSize+1)); // invalidate every iterator
|
2003-03-19 16:57:12 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2012-01-19 20:20:06 +01:00
|
|
|
sal_Bool ORowSetCache::fill(ORowSetMatrix::iterator& _aIter,const ORowSetMatrix::const_iterator& _aEnd,sal_Int32& _nPos,sal_Bool _bCheck)
|
2003-03-19 16:57:12 +00:00
|
|
|
{
|
2012-01-19 20:20:06 +01:00
|
|
|
const sal_Int32 nColumnCount = m_xMetaData->getColumnCount();
|
|
|
|
for(; _bCheck && _aIter != _aEnd; _aIter++, _nPos++)
|
2003-03-19 16:57:12 +00:00
|
|
|
{
|
2010-10-15 12:22:54 -05:00
|
|
|
if ( !_aIter->is() )
|
2003-03-19 16:57:12 +00:00
|
|
|
*_aIter = new ORowSetValueVector(nColumnCount);
|
|
|
|
else
|
|
|
|
{
|
2012-01-19 20:20:06 +01:00
|
|
|
const TOldRowSetRows::const_iterator aOldRowEnd = m_aOldRows.end();
|
2009-07-03 12:24:35 +00:00
|
|
|
for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != aOldRowEnd; ++aOldRowIter)
|
2003-03-19 16:57:12 +00:00
|
|
|
{
|
2010-10-21 15:39:43 -05:00
|
|
|
if ( (*aOldRowIter)->getRow() == *_aIter )
|
2003-03-19 16:57:12 +00:00
|
|
|
*_aIter = new ORowSetValueVector(nColumnCount);
|
|
|
|
}
|
|
|
|
}
|
2012-01-19 20:20:06 +01:00
|
|
|
m_pCacheSet->fillValueRow(*_aIter, _nPos);
|
2003-03-19 16:57:12 +00:00
|
|
|
_bCheck = m_pCacheSet->next();
|
|
|
|
}
|
|
|
|
return _bCheck;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
bool ORowSetCache::isResultSetChanged() const
|
|
|
|
{
|
|
|
|
return m_pCacheSet->isResultSetChanged();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
void ORowSetCache::reset(const Reference< XResultSet>& _xDriverSet)
|
|
|
|
{
|
|
|
|
m_xMetaData.set(Reference< XResultSetMetaDataSupplier >(_xDriverSet,UNO_QUERY)->getMetaData());
|
|
|
|
m_pCacheSet->reset(_xDriverSet);
|
2008-06-24 15:44:35 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
m_bRowCountFinal = sal_False;
|
|
|
|
m_nRowCount = 0;
|
2012-01-19 20:20:06 +01:00
|
|
|
reFillMatrix(m_nStartPos,m_nEndPos);
|
2010-02-15 09:53:53 +01:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
void ORowSetCache::impl_updateRowFromCache_throw(ORowSetValueVector::Vector& io_aRow
|
|
|
|
,::std::vector<sal_Int32>& o_ChangedColumns)
|
|
|
|
{
|
|
|
|
if ( o_ChangedColumns.size() > 1 )
|
|
|
|
{
|
|
|
|
ORowSetMatrix::iterator aIter = m_pMatrix->begin();
|
|
|
|
for(;aIter != m_pMatrix->end();++aIter)
|
|
|
|
{
|
2010-10-15 12:22:54 -05:00
|
|
|
if ( aIter->is() && m_pCacheSet->updateColumnValues((*aIter)->get(),io_aRow,o_ChangedColumns))
|
2010-02-15 09:53:53 +01:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-06-24 15:44:35 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
if ( aIter == m_pMatrix->end() )
|
|
|
|
{
|
|
|
|
m_pCacheSet->fillMissingValues(io_aRow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-10-12 15:59:03 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|