2010-10-12 15:59:03 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 23:16:46 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 11:24:35 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2010-06-07 14:10:31 +02:00
|
|
|
* Copyright 2000, 2010 Oracle andor its affiliates.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 11:24:35 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 11:24:35 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 11:24:35 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 11:24:35 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 11:24:35 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 05:31:47 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
#include "KeySet.hxx"
|
2004-06-01 09:08:36 +00:00
|
|
|
#include "core_resource.hxx"
|
|
|
|
#include "core_resource.hrc"
|
2000-09-18 23:16:46 +00:00
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
|
2009-04-23 10:42:05 +00:00
|
|
|
#include <com/sun/star/sdbc/ColumnValue.hpp>
|
2000-09-18 23:16:46 +00:00
|
|
|
#include <com/sun/star/sdbc/XPreparedStatement.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XParameters.hpp>
|
2002-07-25 05:38:47 +00:00
|
|
|
#include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
|
2001-01-24 08:52:19 +00:00
|
|
|
#include <com/sun/star/sdbc/XColumnLocate.hpp>
|
2000-09-18 23:16:46 +00:00
|
|
|
#include <com/sun/star/container/XIndexAccess.hpp>
|
2000-10-25 06:32:52 +00:00
|
|
|
#include "dbastrings.hrc"
|
2000-09-18 23:16:46 +00:00
|
|
|
#include "apitools.hxx"
|
|
|
|
#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
|
2004-10-22 07:54:05 +00:00
|
|
|
#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
|
2001-02-01 13:23:57 +00:00
|
|
|
#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
|
2001-01-22 06:38:24 +00:00
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
2001-01-24 08:52:19 +00:00
|
|
|
#include <comphelper/types.hxx>
|
|
|
|
#include <com/sun/star/sdbcx/KeyType.hpp>
|
2001-01-31 11:35:35 +00:00
|
|
|
#include <connectivity/dbtools.hxx>
|
2006-07-10 14:02:45 +00:00
|
|
|
#include <connectivity/dbexception.hxx>
|
2001-02-01 13:23:57 +00:00
|
|
|
#include <list>
|
2002-07-25 05:38:47 +00:00
|
|
|
#include <algorithm>
|
2008-03-05 15:48:50 +00:00
|
|
|
#include <string.h>
|
2001-04-02 10:14:53 +00:00
|
|
|
#include <com/sun/star/io/XInputStream.hpp>
|
2001-07-19 08:29:22 +00:00
|
|
|
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
|
2004-03-15 14:45:30 +00:00
|
|
|
#include "querycomposer.hxx"
|
2005-01-05 11:26:22 +00:00
|
|
|
#include "composertools.hxx"
|
2005-09-23 11:02:11 +00:00
|
|
|
#include <tools/debug.hxx>
|
2009-04-23 10:42:05 +00:00
|
|
|
#include <rtl/logfile.hxx>
|
2010-07-08 12:21:55 +02:00
|
|
|
#include "PrivateRow.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
using namespace dbaccess;
|
2006-07-10 14:02:45 +00:00
|
|
|
using namespace ::connectivity;
|
|
|
|
using namespace ::dbtools;
|
2000-09-18 23:16:46 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
2001-01-24 08:52:19 +00:00
|
|
|
using namespace ::com::sun::star::sdb;
|
2000-09-18 23:16:46 +00:00
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::util;
|
2001-04-02 10:14:53 +00:00
|
|
|
using namespace ::com::sun::star::io;
|
2006-08-15 09:41:07 +00:00
|
|
|
using namespace ::com::sun::star;
|
2001-01-22 06:38:24 +00:00
|
|
|
using namespace ::cppu;
|
2000-09-18 23:16:46 +00:00
|
|
|
using namespace ::osl;
|
2001-01-22 06:38:24 +00:00
|
|
|
|
2004-08-02 14:00:09 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
void lcl_fillIndexColumns(const Reference<XIndexAccess>& _xIndexes, ::std::vector< Reference<XNameAccess> >& _rAllIndexColumns)
|
|
|
|
{
|
|
|
|
if ( _xIndexes.is() )
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xIndexColsSup;
|
|
|
|
sal_Int32 nCount = _xIndexes->getCount();
|
|
|
|
for(sal_Int32 j = 0 ; j < nCount ; ++j)
|
|
|
|
{
|
|
|
|
xIndexColsSup.set(_xIndexes->getByIndex(j),UNO_QUERY);
|
|
|
|
if( xIndexColsSup.is()
|
|
|
|
&& comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISUNIQUE))
|
|
|
|
&& !comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISPRIMARYKEYINDEX))
|
|
|
|
)
|
|
|
|
_rAllIndexColumns.push_back(Reference<XColumnsSupplier>(xIndexColsSup,UNO_QUERY)->getColumns());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-09-23 11:02:11 +00:00
|
|
|
DBG_NAME(OKeySet)
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-10-30 13:22:10 +00:00
|
|
|
OKeySet::OKeySet(const connectivity::OSQLTable& _xTable,
|
2008-06-06 12:58:16 +00:00
|
|
|
const Reference< XIndexAccess>& _xTableKeys,
|
2001-02-01 13:23:57 +00:00
|
|
|
const ::rtl::OUString& _rUpdateTableName, // this can be the alias or the full qualified name
|
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
|
|
|
const Reference< XSingleSelectQueryAnalyzer >& _xComposer,
|
2010-11-24 14:23:06 +01:00
|
|
|
const ORowSetValueVector& _aParameterValueForCache,
|
2011-01-06 12:32:17 +01:00
|
|
|
sal_Int32 i_nMaxRows,
|
|
|
|
sal_Int32& o_nRowCount)
|
2010-11-24 14:23:06 +01:00
|
|
|
:OCacheSet(i_nMaxRows)
|
|
|
|
,m_aParameterValueForCache(_aParameterValueForCache)
|
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
|
|
|
,m_pKeyColumnNames(NULL)
|
2006-06-20 01:35:08 +00:00
|
|
|
,m_pColumnNames(NULL)
|
2010-01-19 09:16:12 +00:00
|
|
|
,m_pParameterNames(NULL)
|
2006-08-15 09:41:07 +00:00
|
|
|
,m_pForeignColumnNames(NULL)
|
2006-06-20 01:35:08 +00:00
|
|
|
,m_xTable(_xTable)
|
2008-06-06 12:58:16 +00:00
|
|
|
,m_xTableKeys(_xTableKeys)
|
2001-02-01 13:23:57 +00:00
|
|
|
,m_xComposer(_xComposer)
|
|
|
|
,m_sUpdateTableName(_rUpdateTableName)
|
2011-01-06 12:32:17 +01:00
|
|
|
,m_rRowCount(o_nRowCount)
|
2006-06-20 01:35:08 +00:00
|
|
|
,m_bRowCountFinal(sal_False)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::OKeySet" );
|
2005-09-23 11:02:11 +00:00
|
|
|
DBG_CTOR(OKeySet,NULL);
|
|
|
|
|
2001-07-19 08:29:22 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-07-19 08:29:22 +00:00
|
|
|
OKeySet::~OKeySet()
|
|
|
|
{
|
2003-12-01 09:33:47 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
::comphelper::disposeComponent(m_xStatement);
|
|
|
|
}
|
2011-04-13 09:40:26 +01:00
|
|
|
catch(const Exception&)
|
2003-12-01 09:33:47 +00:00
|
|
|
{
|
|
|
|
m_xStatement = NULL;
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
2011-03-12 12:04:35 +01:00
|
|
|
OSL_FAIL("Unknown Exception occurred");
|
2003-12-01 09:33:47 +00:00
|
|
|
}
|
|
|
|
m_xComposer = NULL;
|
2005-09-23 11:02:11 +00:00
|
|
|
|
|
|
|
DBG_DTOR(OKeySet,NULL);
|
2001-07-19 08:29:22 +00:00
|
|
|
}
|
2010-07-08 12:21:55 +02:00
|
|
|
void OKeySet::initColumns()
|
2001-07-19 08:29:22 +00:00
|
|
|
{
|
2003-12-01 09:33:47 +00:00
|
|
|
Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
|
2010-11-25 11:23:27 +01:00
|
|
|
bool bCase = (xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers()) ? true : false;
|
2010-07-08 12:21:55 +02:00
|
|
|
m_pKeyColumnNames.reset( new SelectColumnsMetaData(bCase) );
|
|
|
|
m_pColumnNames.reset( new SelectColumnsMetaData(bCase) );
|
|
|
|
m_pParameterNames.reset( new SelectColumnsMetaData(bCase) );
|
|
|
|
m_pForeignColumnNames.reset( new SelectColumnsMetaData(bCase) );
|
|
|
|
}
|
2011-09-22 15:00:08 +01:00
|
|
|
|
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_PUSH
|
2010-09-22 11:08:30 +02:00
|
|
|
void OKeySet::findTableColumnsMatching_throw( const Any& i_aTable,
|
|
|
|
const ::rtl::OUString& i_rUpdateTableName,
|
|
|
|
const Reference<XDatabaseMetaData>& i_xMeta,
|
2010-10-18 12:38:57 +02:00
|
|
|
const Reference<XNameAccess>& i_xQueryColumns,
|
|
|
|
::std::auto_ptr<SelectColumnsMetaData>& o_pKeyColumnNames)
|
2010-07-08 12:21:55 +02:00
|
|
|
{
|
|
|
|
// first ask the database itself for the best columns which can be used
|
2009-11-11 14:16:42 +01:00
|
|
|
Sequence< ::rtl::OUString> aBestColumnNames;
|
2010-07-08 12:21:55 +02:00
|
|
|
Reference<XNameAccess> xKeyColumns = getPrimaryKeyColumns_throw(i_aTable);
|
|
|
|
if ( xKeyColumns.is() )
|
|
|
|
aBestColumnNames = xKeyColumns->getElementNames();
|
2010-07-06 15:20:20 +02:00
|
|
|
|
2010-07-08 12:21:55 +02:00
|
|
|
const Reference<XColumnsSupplier> xTblColSup(i_aTable,UNO_QUERY_THROW);
|
|
|
|
const Reference<XNameAccess> xTblColumns = xTblColSup->getColumns();
|
|
|
|
// locate parameter in select columns
|
|
|
|
Reference<XParametersSupplier> xParaSup(m_xComposer,UNO_QUERY);
|
|
|
|
Reference<XIndexAccess> xQueryParameters = xParaSup->getParameters();
|
|
|
|
const sal_Int32 nParaCount = xQueryParameters->getCount();
|
|
|
|
Sequence< ::rtl::OUString> aParameterColumns(nParaCount);
|
|
|
|
for(sal_Int32 i = 0; i< nParaCount;++i)
|
2010-04-19 11:50:35 +02:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
Reference<XPropertySet> xPara(xQueryParameters->getByIndex(i),UNO_QUERY_THROW);
|
|
|
|
xPara->getPropertyValue(PROPERTY_REALNAME) >>= aParameterColumns[i];
|
2010-04-19 11:50:35 +02:00
|
|
|
}
|
2010-09-01 13:09:46 +02:00
|
|
|
|
2010-09-22 11:08:30 +02:00
|
|
|
::rtl::OUString sUpdateTableName( i_rUpdateTableName );
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( sUpdateTableName.isEmpty() )
|
2010-09-01 13:09:46 +02:00
|
|
|
{
|
2011-03-12 11:27:59 +01:00
|
|
|
OSL_FAIL( "OKeySet::findTableColumnsMatching_throw: This is a fallback only - it won't work when the table has an alias name." );
|
2010-09-22 11:08:30 +02:00
|
|
|
// If i_aTable originates from a query composer, and is a table which appears with an alias in the SELECT statement,
|
|
|
|
// then the below code will not produce correct results.
|
|
|
|
// For instance, imagine a "SELECT alias.col FROM table AS alias". Now i_aTable would be the table named
|
|
|
|
// "table", so our sUpdateTableName would be "table" as well - not the information about the "alias" is
|
|
|
|
// already lost here.
|
|
|
|
// now getColumnPositions would travers the columns, and check which of them belong to the table denoted
|
|
|
|
// by sUpdateTableName. Since the latter is "table", but the columns only know that they belong to a table
|
|
|
|
// named "alias", there will be no matching - so getColumnPositions wouldn't find anything.
|
|
|
|
|
|
|
|
::rtl::OUString sCatalog, sSchema, sTable;
|
|
|
|
Reference<XPropertySet> xTableProp( i_aTable, UNO_QUERY_THROW );
|
|
|
|
xTableProp->getPropertyValue( PROPERTY_CATALOGNAME )>>= sCatalog;
|
|
|
|
xTableProp->getPropertyValue( PROPERTY_SCHEMANAME ) >>= sSchema;
|
|
|
|
xTableProp->getPropertyValue( PROPERTY_NAME ) >>= sTable;
|
|
|
|
sUpdateTableName = dbtools::composeTableName( i_xMeta, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation );
|
2010-09-01 13:09:46 +02:00
|
|
|
}
|
2010-09-22 11:08:30 +02:00
|
|
|
|
2010-10-18 12:38:57 +02:00
|
|
|
::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,sUpdateTableName,(*o_pKeyColumnNames),true);
|
2010-09-22 11:08:30 +02:00
|
|
|
::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),sUpdateTableName,(*m_pColumnNames),true);
|
|
|
|
::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,sUpdateTableName,(*m_pParameterNames),true);
|
|
|
|
|
2010-10-18 12:38:57 +02:00
|
|
|
if ( o_pKeyColumnNames->empty() )
|
2010-09-01 13:09:46 +02:00
|
|
|
{
|
2010-09-22 11:08:30 +02:00
|
|
|
::dbtools::throwGenericSQLException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not find any key column." ) ), *this );
|
2010-09-01 13:09:46 +02:00
|
|
|
}
|
2001-12-05 13:56:24 +00:00
|
|
|
|
2010-10-18 12:38:57 +02:00
|
|
|
for ( SelectColumnsMetaData::const_iterator keyColumn = o_pKeyColumnNames->begin();
|
|
|
|
keyColumn != o_pKeyColumnNames->end();
|
2010-09-22 11:08:30 +02:00
|
|
|
++keyColumn
|
|
|
|
)
|
2001-12-05 13:56:24 +00:00
|
|
|
{
|
2010-09-22 11:08:30 +02:00
|
|
|
if ( !xTblColumns->hasByName( keyColumn->second.sRealName ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Reference<XPropertySet> xProp( xTblColumns->getByName( keyColumn->second.sRealName ), UNO_QUERY );
|
|
|
|
sal_Bool bAuto = sal_False;
|
|
|
|
if ( ( xProp->getPropertyValue( PROPERTY_ISAUTOINCREMENT ) >>= bAuto ) && bAuto )
|
|
|
|
m_aAutoColumns.push_back( keyColumn->first );
|
2001-12-05 13:56:24 +00:00
|
|
|
}
|
2010-07-08 12:21:55 +02:00
|
|
|
}
|
2011-09-22 15:00:08 +01:00
|
|
|
SAL_WNODEPRECATED_DECLARATIONS_POP
|
|
|
|
|
2012-01-18 12:30:36 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
void appendOneKeyColumnClause( const ::rtl::OUString &tblName, const ::rtl::OUString &colName, ::rtl::OUStringBuffer &o_buf )
|
|
|
|
{
|
|
|
|
static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM("."));
|
2012-01-31 21:32:55 +01:00
|
|
|
static ::rtl::OUString s_sParam0(RTL_CONSTASCII_USTRINGPARAM(" ( 1 = ? AND "));
|
|
|
|
static ::rtl::OUString s_sParam1(RTL_CONSTASCII_USTRINGPARAM(" = ? OR 1 = ? AND "));
|
2012-01-18 12:30:36 +01:00
|
|
|
static ::rtl::OUString s_sParam2(RTL_CONSTASCII_USTRINGPARAM(" IS NULL ) "));
|
|
|
|
o_buf.append(s_sParam0);
|
|
|
|
o_buf.append(tblName);
|
|
|
|
o_buf.append(s_sDot);
|
|
|
|
o_buf.append(colName);
|
|
|
|
o_buf.append(s_sParam1);
|
|
|
|
o_buf.append(tblName);
|
|
|
|
o_buf.append(s_sDot);
|
|
|
|
o_buf.append(colName);
|
|
|
|
o_buf.append(s_sParam2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OKeySet::setOneKeyColumnParameter( sal_Int32 &nPos, const Reference< XParameters > &_xParameter, const connectivity::ORowSetValue &_rValue, sal_Int32 _nType, sal_Int32 _nScale ) const
|
|
|
|
{
|
|
|
|
if ( _rValue.isNull() )
|
|
|
|
{
|
2012-01-31 21:32:55 +01:00
|
|
|
_xParameter->setByte( nPos++, 0 );
|
2012-01-18 12:30:36 +01:00
|
|
|
// We do the full call so that the right sqlType is passed to setNull
|
|
|
|
setParameter( nPos++, _xParameter, _rValue, _nType, _nScale );
|
2012-01-31 21:32:55 +01:00
|
|
|
_xParameter->setByte( nPos++, 1 );
|
2012-01-18 12:30:36 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-31 21:32:55 +01:00
|
|
|
_xParameter->setByte( nPos++, 1 );
|
2012-01-18 12:30:36 +01:00
|
|
|
setParameter( nPos++, _xParameter, _rValue, _nType, _nScale );
|
2012-01-31 21:32:55 +01:00
|
|
|
_xParameter->setByte( nPos++, 0 );
|
2012-01-18 12:30:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-08 12:21:55 +02:00
|
|
|
::rtl::OUStringBuffer OKeySet::createKeyFilter()
|
|
|
|
{
|
2010-10-30 21:44:13 +01:00
|
|
|
static ::rtl::OUString aAnd(RTL_CONSTASCII_USTRINGPARAM(" AND "));
|
2009-11-11 14:16:42 +01:00
|
|
|
const ::rtl::OUString aQuote = getIdentifierQuoteString();
|
|
|
|
::rtl::OUStringBuffer aFilter;
|
2001-07-19 08:29:22 +00:00
|
|
|
// create the where clause
|
2010-07-20 10:45:17 +02:00
|
|
|
Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
|
2010-07-08 12:21:55 +02:00
|
|
|
SelectColumnsMetaData::iterator aPosEnd = m_pKeyColumnNames->end();
|
|
|
|
for(SelectColumnsMetaData::iterator aPosIter = m_pKeyColumnNames->begin();aPosIter != aPosEnd;)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2012-01-18 12:30:36 +01:00
|
|
|
appendOneKeyColumnClause(::dbtools::quoteTableName( xMeta,aPosIter->second.sTableName,::dbtools::eInDataManipulation),
|
|
|
|
::dbtools::quoteName( aQuote,aPosIter->second.sRealName),
|
|
|
|
aFilter);
|
2009-07-03 12:24:35 +00:00
|
|
|
++aPosIter;
|
|
|
|
if(aPosIter != aPosEnd)
|
|
|
|
aFilter.append(aAnd);
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
2010-07-08 12:21:55 +02:00
|
|
|
return aFilter;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-07-08 12:21:55 +02:00
|
|
|
void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter)
|
|
|
|
{
|
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::construct" );
|
|
|
|
OCacheSet::construct(_xDriverSet,i_sRowSetFilter);
|
|
|
|
initColumns();
|
|
|
|
|
|
|
|
Reference<XNameAccess> xKeyColumns = getKeyColumns();
|
|
|
|
Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
|
|
|
|
Reference<XColumnsSupplier> xQueryColSup(m_xComposer,UNO_QUERY);
|
|
|
|
const Reference<XNameAccess> xQueryColumns = xQueryColSup->getColumns();
|
2010-10-18 12:38:57 +02:00
|
|
|
findTableColumnsMatching_throw(makeAny(m_xTable),m_sUpdateTableName,xMeta,xQueryColumns,m_pKeyColumnNames);
|
2010-07-08 12:21:55 +02:00
|
|
|
|
|
|
|
// the first row is empty because it's now easier for us to distinguish when we are beforefirst or first
|
2012-05-28 14:50:51 +02:00
|
|
|
// without extra variable to be set
|
2010-07-08 12:21:55 +02:00
|
|
|
m_aKeyMap.insert(OKeySetMatrix::value_type(0,OKeySetValue(NULL,::std::pair<sal_Int32,Reference<XRow> >(0,NULL))));
|
|
|
|
m_aKeyIter = m_aKeyMap.begin();
|
|
|
|
|
|
|
|
::rtl::OUStringBuffer aFilter = createKeyFilter();
|
2004-11-17 13:41:21 +00:00
|
|
|
|
2010-03-17 09:11:06 +00:00
|
|
|
Reference< XSingleSelectQueryComposer> xSourceComposer(m_xComposer,UNO_QUERY);
|
2005-03-10 15:30:40 +00:00
|
|
|
Reference< XMultiServiceFactory > xFactory(m_xConnection, UNO_QUERY_THROW);
|
|
|
|
Reference<XSingleSelectQueryComposer> xAnalyzer(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY);
|
2010-03-17 09:11:06 +00:00
|
|
|
xAnalyzer->setElementaryQuery(xSourceComposer->getElementaryQuery());
|
2006-08-15 09:41:07 +00:00
|
|
|
Reference<XTablesSupplier> xTabSup(xAnalyzer,uno::UNO_QUERY);
|
2007-11-21 14:31:36 +00:00
|
|
|
Reference<XNameAccess> xSelectTables(xTabSup->getTables(),uno::UNO_QUERY);
|
|
|
|
const Sequence< ::rtl::OUString> aSeq = xSelectTables->getElementNames();
|
|
|
|
if ( aSeq.getLength() > 1 ) // special handling for join
|
2006-08-15 09:41:07 +00:00
|
|
|
{
|
2010-10-30 21:44:13 +01:00
|
|
|
static ::rtl::OUString aAnd(RTL_CONSTASCII_USTRINGPARAM(" AND "));
|
2010-07-08 12:21:55 +02:00
|
|
|
const ::rtl::OUString aQuote = getIdentifierQuoteString();
|
2007-11-21 14:31:36 +00:00
|
|
|
const ::rtl::OUString* pIter = aSeq.getConstArray();
|
|
|
|
const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
|
|
|
|
for(;pIter != pEnd;++pIter)
|
2006-08-15 09:41:07 +00:00
|
|
|
{
|
2007-11-21 14:31:36 +00:00
|
|
|
if ( *pIter != m_sUpdateTableName )
|
2006-08-15 09:41:07 +00:00
|
|
|
{
|
2007-11-21 14:31:36 +00:00
|
|
|
connectivity::OSQLTable xSelColSup(xSelectTables->getByName(*pIter),uno::UNO_QUERY);
|
|
|
|
Reference<XPropertySet> xProp(xSelColSup,uno::UNO_QUERY);
|
2010-07-08 12:21:55 +02:00
|
|
|
::rtl::OUString sSelectTableName = ::dbtools::composeTableName( xMeta, xProp, ::dbtools::eInDataManipulation, false, false, false );
|
2007-11-21 14:31:36 +00:00
|
|
|
|
2010-07-08 12:21:55 +02:00
|
|
|
::dbaccess::getColumnPositions(xQueryColumns,xSelColSup->getColumns()->getElementNames(),sSelectTableName,(*m_pForeignColumnNames));
|
2006-08-15 09:41:07 +00:00
|
|
|
|
2012-01-17 09:26:41 +01:00
|
|
|
const SelectColumnsMetaData::iterator aPosEnd = (*m_pForeignColumnNames).end();
|
2010-07-08 12:21:55 +02:00
|
|
|
for(SelectColumnsMetaData::iterator aPosIter = (*m_pForeignColumnNames).begin();aPosIter != aPosEnd;++aPosIter)
|
2006-08-15 09:41:07 +00:00
|
|
|
{
|
|
|
|
// look for columns not in the source columns to use them as filter as well
|
2012-01-17 09:26:41 +01:00
|
|
|
if ( aFilter.getLength() )
|
|
|
|
aFilter.append(aAnd);
|
2012-01-18 12:30:36 +01:00
|
|
|
appendOneKeyColumnClause(::dbtools::quoteName( aQuote,sSelectTableName),
|
|
|
|
::dbtools::quoteName( aQuote,aPosIter->second.sRealName),
|
|
|
|
aFilter);
|
2006-08-15 09:41:07 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
}
|
2010-07-08 12:21:55 +02:00
|
|
|
executeStatement(aFilter,i_sRowSetFilter,xAnalyzer);
|
|
|
|
}
|
|
|
|
void OKeySet::executeStatement(::rtl::OUStringBuffer& io_aFilter,const ::rtl::OUString& i_sRowSetFilter,Reference<XSingleSelectQueryComposer>& io_xAnalyzer)
|
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
bool bFilterSet = !i_sRowSetFilter.isEmpty();
|
2010-07-08 12:21:55 +02:00
|
|
|
if ( bFilterSet )
|
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
|
|
|
{
|
2009-12-07 11:22:08 +00:00
|
|
|
FilterCreator aFilterCreator;
|
2010-01-19 09:16:12 +00:00
|
|
|
aFilterCreator.append( i_sRowSetFilter );
|
2010-07-08 12:21:55 +02:00
|
|
|
aFilterCreator.append( io_aFilter.makeStringAndClear() );
|
|
|
|
io_aFilter = aFilterCreator.getComposedAndClear();
|
2006-08-15 09:41:07 +00:00
|
|
|
}
|
2010-07-08 12:21:55 +02:00
|
|
|
io_xAnalyzer->setFilter(io_aFilter.makeStringAndClear());
|
|
|
|
if ( bFilterSet )
|
|
|
|
{
|
|
|
|
Sequence< Sequence< PropertyValue > > aFilter2 = io_xAnalyzer->getStructuredFilter();
|
|
|
|
const Sequence< PropertyValue >* pOr = aFilter2.getConstArray();
|
|
|
|
const Sequence< PropertyValue >* pOrEnd = pOr + aFilter2.getLength();
|
|
|
|
for(;pOr != pOrEnd;++pOr)
|
|
|
|
{
|
|
|
|
const PropertyValue* pAnd = pOr->getConstArray();
|
|
|
|
const PropertyValue* pAndEnd = pAnd + pOr->getLength();
|
|
|
|
for(;pAnd != pAndEnd;++pAnd)
|
|
|
|
{
|
|
|
|
::rtl::OUString sValue;
|
2012-04-06 19:49:53 +02:00
|
|
|
if ( !(pAnd->Value >>= sValue) || !( sValue == "?" || sValue.matchAsciiL( ":",1,0 ) ) )
|
2010-07-08 12:21:55 +02:00
|
|
|
{ // we have a criteria which has to be taken into account for updates
|
|
|
|
m_aFilterColumns.push_back(pAnd->Name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_xStatement = m_xConnection->prepareStatement(io_xAnalyzer->getQueryWithSubstitution());
|
|
|
|
::comphelper::disposeComponent(io_xAnalyzer);
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2006-06-20 01:35:08 +00:00
|
|
|
Any SAL_CALL OKeySet::getBookmark() throw(SQLException, RuntimeException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getBookmark" );
|
2001-01-24 08:52:19 +00:00
|
|
|
OSL_ENSURE(m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(),
|
|
|
|
"getBookmark is only possible when we stand on a valid row!");
|
|
|
|
return makeAny(m_aKeyIter->first);
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
sal_Bool SAL_CALL OKeySet::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::moveToBookmark" );
|
2001-01-22 06:38:24 +00:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = sal_False;
|
2001-01-24 08:52:19 +00:00
|
|
|
m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32(bookmark));
|
|
|
|
return m_aKeyIter != m_aKeyMap.end();
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
sal_Bool SAL_CALL OKeySet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::moveRelativeToBookmark" );
|
2001-01-22 06:38:24 +00:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = sal_False;
|
2001-01-24 08:52:19 +00:00
|
|
|
m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32(bookmark));
|
|
|
|
if(m_aKeyIter != m_aKeyMap.end())
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2001-01-24 08:52:19 +00:00
|
|
|
relative(rows);
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
|
|
|
|
return !isBeforeFirst() && !isAfterLast();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2006-06-20 01:35:08 +00:00
|
|
|
sal_Int32 SAL_CALL OKeySet::compareBookmarks( const Any& _first, const Any& _second ) throw(SQLException, RuntimeException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::compareBookmarks" );
|
2006-11-21 16:15:22 +00:00
|
|
|
sal_Int32 nFirst = 0, nSecond = 0;
|
2006-06-20 01:35:08 +00:00
|
|
|
_first >>= nFirst;
|
|
|
|
_second >>= nSecond;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
return (nFirst != nSecond) ? CompareBookmark::NOT_EQUAL : CompareBookmark::EQUAL;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
sal_Bool SAL_CALL OKeySet::hasOrderedBookmarks( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::hasOrderedBookmarks" );
|
2000-09-18 23:16:46 +00:00
|
|
|
return sal_True;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
sal_Int32 SAL_CALL OKeySet::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::hashBookmark" );
|
2001-01-24 08:52:19 +00:00
|
|
|
return ::comphelper::getINT32(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
|
|
|
// ::com::sun::star::sdbcx::XDeleteRows
|
|
|
|
Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows ,const connectivity::OSQLTable& _xTable) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::deleteRows" );
|
2000-09-18 23:16:46 +00:00
|
|
|
Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
|
|
|
|
fillTableName(xSet);
|
|
|
|
|
2010-10-30 21:46:00 +01:00
|
|
|
::rtl::OUStringBuffer aSql = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DELETE FROM "));
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(m_aComposedTableName);
|
2010-10-30 21:44:13 +01:00
|
|
|
aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE ")));
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-11-08 02:50:53 -06:00
|
|
|
// list all cloumns that should be set
|
2009-07-03 12:24:35 +00:00
|
|
|
const ::rtl::OUString aQuote = getIdentifierQuoteString();
|
2010-10-30 21:44:13 +01:00
|
|
|
static ::rtl::OUString aAnd(RTL_CONSTASCII_USTRINGPARAM(" AND "));
|
|
|
|
static ::rtl::OUString aOr(RTL_CONSTASCII_USTRINGPARAM(" OR "));
|
|
|
|
static ::rtl::OUString aEqual(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
// use keys and indexes for excat postioning
|
|
|
|
// first the keys
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference<XNameAccess> xKeyColumns = getKeyColumns();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-10-30 21:44:13 +01:00
|
|
|
::rtl::OUStringBuffer aCondition = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("( "));
|
2004-03-15 14:45:30 +00:00
|
|
|
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aIter = (*m_pKeyColumnNames).begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
|
|
|
|
for(;aIter != aPosEnd;++aIter)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
aCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
|
2009-07-03 12:24:35 +00:00
|
|
|
aCondition.append(aEqual);
|
|
|
|
aCondition.append(aAnd);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
aCondition.setLength(aCondition.getLength()-5);
|
|
|
|
const ::rtl::OUString sCon( aCondition.makeStringAndClear() );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
const Any* pBegin = rows.getConstArray();
|
|
|
|
const Any* pEnd = pBegin + rows.getLength();
|
|
|
|
|
|
|
|
Sequence< Any > aKeys;
|
|
|
|
for(;pBegin != pEnd;++pBegin)
|
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(sCon);
|
|
|
|
aSql.append(aOr);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.setLength(aSql.getLength()-3);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-11-08 02:50:53 -06:00
|
|
|
// now create end execute the prepared statement
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear()));
|
2000-09-18 23:16:46 +00:00
|
|
|
Reference< XParameters > xParameter(xPrep,UNO_QUERY);
|
|
|
|
|
|
|
|
pBegin = rows.getConstArray();
|
2001-01-24 08:52:19 +00:00
|
|
|
sal_Int32 i=1;
|
2000-09-18 23:16:46 +00:00
|
|
|
for(;pBegin != pEnd;++pBegin)
|
|
|
|
{
|
2001-02-01 13:23:57 +00:00
|
|
|
m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32(*pBegin));
|
|
|
|
if(m_aKeyIter != m_aKeyMap.end())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::iterator aKeyIter = m_aKeyIter->second.first->get().begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::iterator aKeyEnd = m_aKeyIter->second.first->get().end();
|
2008-01-30 07:28:36 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
for(sal_uInt16 j = 0;aKeyIter != aKeyEnd;++aKeyIter,++j,++aPosIter)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2008-01-30 07:28:36 +00:00
|
|
|
setParameter(i++,xParameter,*aKeyIter,aPosIter->second.nType,aPosIter->second.nScale);
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool bOk = xPrep->executeUpdate() > 0;
|
|
|
|
Sequence< sal_Int32 > aRet(rows.getLength());
|
|
|
|
memset(aRet.getArray(),bOk,sizeof(sal_Int32)*aRet.getLength());
|
2001-01-22 06:38:24 +00:00
|
|
|
if(bOk)
|
|
|
|
{
|
2006-06-20 01:35:08 +00:00
|
|
|
pBegin = rows.getConstArray();
|
|
|
|
pEnd = pBegin + rows.getLength();
|
2001-01-22 06:38:24 +00:00
|
|
|
|
|
|
|
for(;pBegin != pEnd;++pBegin)
|
|
|
|
{
|
2006-11-21 16:15:22 +00:00
|
|
|
sal_Int32 nPos = 0;
|
2001-01-24 08:52:19 +00:00
|
|
|
*pBegin >>= nPos;
|
2001-06-22 12:07:17 +00:00
|
|
|
if(m_aKeyIter == m_aKeyMap.find(nPos) && m_aKeyIter != m_aKeyMap.end())
|
|
|
|
++m_aKeyIter;
|
2001-01-24 08:52:19 +00:00
|
|
|
m_aKeyMap.erase(nPos);
|
2001-06-22 12:07:17 +00:00
|
|
|
m_bDeleted = sal_True;
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
return aRet;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::updateRow" );
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
|
|
|
|
fillTableName(xSet);
|
|
|
|
|
2010-10-30 21:44:13 +01:00
|
|
|
::rtl::OUStringBuffer aSql = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UPDATE "));
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(m_aComposedTableName);
|
2010-10-30 21:44:13 +01:00
|
|
|
aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" SET ")));
|
2001-02-01 13:23:57 +00:00
|
|
|
// list all cloumns that should be set
|
2010-10-30 21:44:13 +01:00
|
|
|
static ::rtl::OUString aPara(RTL_CONSTASCII_USTRINGPARAM(" = ?,"));
|
2003-12-01 09:33:47 +00:00
|
|
|
::rtl::OUString aQuote = getIdentifierQuoteString();
|
2010-10-30 21:44:13 +01:00
|
|
|
static ::rtl::OUString aAnd(RTL_CONSTASCII_USTRINGPARAM(" AND "));
|
2009-07-03 12:24:35 +00:00
|
|
|
::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL"));
|
|
|
|
::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
|
2001-02-01 13:23:57 +00:00
|
|
|
|
|
|
|
// use keys and indexes for excat postioning
|
|
|
|
// first the keys
|
|
|
|
Reference<XNameAccess> xKeyColumns = getKeyColumns();
|
|
|
|
|
|
|
|
// second the indexes
|
|
|
|
Reference<XIndexesSupplier> xIndexSup(_xTable,UNO_QUERY);
|
|
|
|
Reference<XIndexAccess> xIndexes;
|
2004-08-02 14:00:09 +00:00
|
|
|
if ( xIndexSup.is() )
|
|
|
|
xIndexes.set(xIndexSup->getIndexes(),UNO_QUERY);
|
|
|
|
|
2001-02-01 13:23:57 +00:00
|
|
|
|
|
|
|
::std::vector< Reference<XNameAccess> > aAllIndexColumns;
|
2004-08-02 14:00:09 +00:00
|
|
|
lcl_fillIndexColumns(xIndexes,aAllIndexColumns);
|
2001-02-01 13:23:57 +00:00
|
|
|
|
|
|
|
::rtl::OUString aColumnName;
|
2009-07-03 12:24:35 +00:00
|
|
|
::rtl::OUStringBuffer sKeyCondition,sIndexCondition;
|
2001-08-14 10:51:34 +00:00
|
|
|
::std::vector<sal_Int32> aIndexColumnPositions;
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
const sal_Int32 nOldLength = aSql.getLength();
|
2004-03-15 14:45:30 +00:00
|
|
|
sal_Int32 i = 1;
|
2001-02-01 13:23:57 +00:00
|
|
|
// here we build the condition part for the update statement
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
|
|
|
|
for(;aIter != aEnd;++aIter,++i)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2009-11-11 14:16:42 +01:00
|
|
|
if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() )
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
sKeyCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
|
2008-12-30 13:32:01 +00:00
|
|
|
if((_rOrginalRow->get())[aIter->second.nPosition].isNull())
|
2009-07-03 12:24:35 +00:00
|
|
|
sKeyCondition.append(sIsNull);
|
2001-02-01 13:23:57 +00:00
|
|
|
else
|
2009-07-03 12:24:35 +00:00
|
|
|
sKeyCondition.append(sParam);
|
|
|
|
sKeyCondition.append(aAnd);
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
2001-08-14 10:51:34 +00:00
|
|
|
else
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
::std::vector< Reference<XNameAccess> >::const_iterator aIndexEnd = aAllIndexColumns.end();
|
2001-08-14 10:51:34 +00:00
|
|
|
for( ::std::vector< Reference<XNameAccess> >::const_iterator aIndexIter = aAllIndexColumns.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
aIndexIter != aIndexEnd;++aIndexIter)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2001-08-14 10:51:34 +00:00
|
|
|
if((*aIndexIter)->hasByName(aIter->first))
|
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
sIndexCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
|
2008-12-30 13:32:01 +00:00
|
|
|
if((_rOrginalRow->get())[aIter->second.nPosition].isNull())
|
2009-07-03 12:24:35 +00:00
|
|
|
sIndexCondition.append(sIsNull);
|
2001-08-14 10:51:34 +00:00
|
|
|
else
|
2002-03-18 12:59:43 +00:00
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
sIndexCondition.append(sParam);
|
2006-07-10 14:02:45 +00:00
|
|
|
aIndexColumnPositions.push_back(aIter->second.nPosition);
|
2002-03-18 12:59:43 +00:00
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
sIndexCondition.append(aAnd);
|
2001-08-14 10:51:34 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-30 13:32:01 +00:00
|
|
|
if((_rInsertRow->get())[aIter->second.nPosition].isModified())
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
aSql.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(aPara);
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
if( aSql.getLength() != nOldLength )
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.setLength(aSql.getLength()-1);
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
else
|
2006-07-10 14:02:45 +00:00
|
|
|
::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_VALUE_CHANGED ), SQL_GENERAL_ERROR, m_xConnection );
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2001-08-14 10:51:34 +00:00
|
|
|
if(sKeyCondition.getLength() || sIndexCondition.getLength())
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2010-10-30 21:44:13 +01:00
|
|
|
aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE ")));
|
2001-08-14 10:51:34 +00:00
|
|
|
if(sKeyCondition.getLength() && sIndexCondition.getLength())
|
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(sKeyCondition.makeStringAndClear());
|
|
|
|
aSql.append(sIndexCondition.makeStringAndClear());
|
2001-08-14 10:51:34 +00:00
|
|
|
}
|
|
|
|
else if(sKeyCondition.getLength())
|
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(sKeyCondition.makeStringAndClear());
|
2001-08-14 10:51:34 +00:00
|
|
|
}
|
|
|
|
else if(sIndexCondition.getLength())
|
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(sIndexCondition.makeStringAndClear());
|
2001-08-14 10:51:34 +00:00
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.setLength(aSql.getLength()-5); // remove the last AND
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
else
|
2006-07-10 14:02:45 +00:00
|
|
|
::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_CONDITION_FOR_PK ), SQL_GENERAL_ERROR, m_xConnection );
|
2001-02-01 13:23:57 +00:00
|
|
|
|
|
|
|
// now create end execute the prepared statement
|
2010-07-08 12:21:55 +02:00
|
|
|
::rtl::OUString sEmpty;
|
|
|
|
executeUpdate(_rInsertRow ,_rOrginalRow,aSql.makeStringAndClear(),sEmpty,aIndexColumnPositions);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-07-08 12:21:55 +02:00
|
|
|
void OKeySet::executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName,const ::std::vector<sal_Int32>& _aIndexColumnPositions)
|
|
|
|
{
|
|
|
|
// now create end execute the prepared statement
|
|
|
|
Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(i_sSQL));
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference< XParameters > xParameter(xPrep,UNO_QUERY);
|
|
|
|
|
2010-03-24 10:16:28 +00:00
|
|
|
bool bRefetch = true;
|
|
|
|
Reference<XRow> xRow;
|
2010-07-08 12:21:55 +02:00
|
|
|
sal_Int32 i = 1;
|
|
|
|
// first the set values
|
|
|
|
SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
|
|
|
|
SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
|
|
|
|
sal_uInt16 j = 0;
|
2009-07-03 12:24:35 +00:00
|
|
|
for(;aIter != aEnd;++aIter,++j)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( i_sTableName.isEmpty() || aIter->second.sTableName == i_sTableName )
|
2004-03-02 11:41:09 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
sal_Int32 nPos = aIter->second.nPosition;
|
|
|
|
if((_rInsertRow->get())[nPos].isModified())
|
2010-03-24 10:16:28 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
if ( bRefetch )
|
2010-03-24 10:16:28 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
bRefetch = ::std::find(m_aFilterColumns.begin(),m_aFilterColumns.end(),aIter->second.sRealName) == m_aFilterColumns.end();
|
2010-03-24 10:16:28 +00:00
|
|
|
}
|
2010-07-08 12:21:55 +02:00
|
|
|
impl_convertValue_throw(_rInsertRow,aIter->second);
|
|
|
|
(_rInsertRow->get())[nPos].setSigned((_rOrginalRow->get())[nPos].isSigned());
|
|
|
|
setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale);
|
2010-03-24 10:16:28 +00:00
|
|
|
}
|
2004-03-02 11:41:09 +00:00
|
|
|
}
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
// and then the values of the where condition
|
2010-07-08 12:21:55 +02:00
|
|
|
aIter = m_pKeyColumnNames->begin();
|
|
|
|
aEnd = m_pKeyColumnNames->end();
|
2004-03-15 14:45:30 +00:00
|
|
|
j = 0;
|
2010-07-08 12:21:55 +02:00
|
|
|
for(;aIter != aEnd;++aIter,++j)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( i_sTableName.isEmpty() || aIter->second.sTableName == i_sTableName )
|
2010-07-08 12:21:55 +02:00
|
|
|
{
|
|
|
|
setParameter(i++,xParameter,(_rOrginalRow->get())[aIter->second.nPosition],aIter->second.nType,aIter->second.nScale);
|
|
|
|
}
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
2010-07-08 12:21:55 +02:00
|
|
|
if ( !_aIndexColumnPositions.empty() )
|
2001-08-14 10:51:34 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
// now we have to set the index values
|
|
|
|
::std::vector<sal_Int32>::const_iterator aIdxColIter = _aIndexColumnPositions.begin();
|
|
|
|
::std::vector<sal_Int32>::const_iterator aIdxColEnd = _aIndexColumnPositions.end();
|
|
|
|
j = 0;
|
|
|
|
aIter = m_pColumnNames->begin();
|
|
|
|
for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++j,++aIter)
|
|
|
|
{
|
|
|
|
setParameter(i,xParameter,(_rOrginalRow->get())[*aIdxColIter],(_rOrginalRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale);
|
|
|
|
}
|
2001-08-14 10:51:34 +00:00
|
|
|
}
|
2010-07-08 12:21:55 +02:00
|
|
|
const sal_Int32 nRowsUpdated = xPrep->executeUpdate();
|
|
|
|
m_bUpdated = nRowsUpdated > 0;
|
2001-02-01 13:23:57 +00:00
|
|
|
if(m_bUpdated)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2010-01-19 09:16:12 +00:00
|
|
|
const sal_Int32 nBookmark = ::comphelper::getINT32((_rInsertRow->get())[0].getAny());
|
|
|
|
m_aKeyIter = m_aKeyMap.find(nBookmark);
|
2010-04-20 13:33:34 +02:00
|
|
|
m_aKeyIter->second.second.first = 2;
|
|
|
|
m_aKeyIter->second.second.second = xRow;
|
2010-01-19 09:16:12 +00:00
|
|
|
copyRowValue(_rInsertRow,m_aKeyIter->second.first,nBookmark);
|
2010-07-08 12:21:55 +02:00
|
|
|
tryRefetch(_rInsertRow,bRefetch);
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::insertRow" );
|
2010-10-30 21:44:13 +01:00
|
|
|
::rtl::OUStringBuffer aSql(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INSERT INTO ")));
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
|
|
|
|
fillTableName(xSet);
|
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(m_aComposedTableName);
|
2010-10-30 21:44:13 +01:00
|
|
|
aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ( ")));
|
2001-02-01 13:23:57 +00:00
|
|
|
// set values and column names
|
2009-07-03 12:24:35 +00:00
|
|
|
::rtl::OUStringBuffer aValues(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" VALUES ( ")));
|
2005-03-18 09:04:30 +00:00
|
|
|
static ::rtl::OUString aPara(RTL_CONSTASCII_USTRINGPARAM("?,"));
|
2003-12-01 09:33:47 +00:00
|
|
|
::rtl::OUString aQuote = getIdentifierQuoteString();
|
2005-03-18 09:04:30 +00:00
|
|
|
static ::rtl::OUString aComma(RTL_CONSTASCII_USTRINGPARAM(","));
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
|
2004-03-15 14:45:30 +00:00
|
|
|
sal_Int32 j = 1;
|
2010-07-08 12:21:55 +02:00
|
|
|
bool bRefetch = true;
|
2005-03-18 09:04:30 +00:00
|
|
|
sal_Bool bModified = sal_False;
|
2009-07-03 12:24:35 +00:00
|
|
|
for(;aIter != aEnd;++aIter,++j)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
if((_rInsertRow->get())[aIter->second.nPosition].isModified())
|
2001-07-03 09:58:28 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
if ( bRefetch )
|
|
|
|
{
|
|
|
|
bRefetch = ::std::find(m_aFilterColumns.begin(),m_aFilterColumns.end(),aIter->second.sRealName) == m_aFilterColumns.end();
|
|
|
|
}
|
|
|
|
aSql.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(aComma);
|
|
|
|
aValues.append(aPara);
|
2005-03-18 09:04:30 +00:00
|
|
|
bModified = sal_True;
|
2001-07-03 09:58:28 +00:00
|
|
|
}
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
2005-03-18 09:04:30 +00:00
|
|
|
if ( !bModified )
|
2006-07-10 14:02:45 +00:00
|
|
|
::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_VALUE_CHANGED ), SQL_GENERAL_ERROR, m_xConnection );
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2011-11-26 00:48:17 -05:00
|
|
|
aSql[aSql.getLength() - 1] = ')';
|
|
|
|
aValues[aValues.getLength() - 1] = ')';
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(aValues.makeStringAndClear());
|
2001-02-01 13:23:57 +00:00
|
|
|
// now create,fill and execute the prepared statement
|
2010-07-08 12:21:55 +02:00
|
|
|
::rtl::OUString sEmpty;
|
|
|
|
executeInsert(_rInsertRow,aSql.makeStringAndClear(),sEmpty,bRefetch);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-07-08 12:21:55 +02:00
|
|
|
void OKeySet::executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName,bool bRefetch )
|
|
|
|
{
|
|
|
|
// now create,fill and execute the prepared statement
|
|
|
|
Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(i_sSQL));
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference< XParameters > xParameter(xPrep,UNO_QUERY);
|
|
|
|
|
2010-07-08 12:21:55 +02:00
|
|
|
SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
|
|
|
|
SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
|
2009-07-03 12:24:35 +00:00
|
|
|
for(sal_Int32 i = 1;aIter != aEnd;++aIter)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( i_sTableName.isEmpty() || aIter->second.sTableName == i_sTableName )
|
2001-07-03 09:58:28 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
const sal_Int32 nPos = aIter->second.nPosition;
|
|
|
|
if((_rInsertRow->get())[nPos].isModified())
|
2004-03-02 11:41:09 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
if((_rInsertRow->get())[nPos].isNull())
|
|
|
|
xParameter->setNull(i++,(_rInsertRow->get())[nPos].getTypeKind());
|
|
|
|
else
|
|
|
|
{
|
|
|
|
impl_convertValue_throw(_rInsertRow,aIter->second);
|
|
|
|
(_rInsertRow->get())[nPos].setSigned(m_aSignedFlags[nPos-1]);
|
|
|
|
setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale);
|
|
|
|
}
|
2004-03-02 11:41:09 +00:00
|
|
|
}
|
2001-07-03 09:58:28 +00:00
|
|
|
}
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_bInserted = xPrep->executeUpdate() > 0;
|
2002-07-25 05:38:47 +00:00
|
|
|
sal_Bool bAutoValuesFetched = sal_False;
|
|
|
|
if ( m_bInserted )
|
|
|
|
{
|
2005-03-18 09:04:30 +00:00
|
|
|
// first insert the default values into the insertrow
|
2009-07-03 12:24:35 +00:00
|
|
|
aIter = m_pColumnNames->begin();
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2005-03-18 09:04:30 +00:00
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
if ( !(_rInsertRow->get())[aIter->second.nPosition].isModified() )
|
|
|
|
(_rInsertRow->get())[aIter->second.nPosition] = aIter->second.sDefaultValue;
|
2005-03-18 09:04:30 +00:00
|
|
|
}
|
2002-07-25 05:38:47 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XGeneratedResultSet > xGRes(xPrep, UNO_QUERY);
|
|
|
|
if ( xGRes.is() )
|
|
|
|
{
|
|
|
|
Reference< XResultSet > xRes = xGRes->getGeneratedValues();
|
|
|
|
Reference< XRow > xRow(xRes,UNO_QUERY);
|
|
|
|
if ( xRow.is() && xRes->next() )
|
|
|
|
{
|
|
|
|
Reference< XResultSetMetaDataSupplier > xMdSup(xRes,UNO_QUERY);
|
|
|
|
Reference< XResultSetMetaData > xMd = xMdSup->getMetaData();
|
|
|
|
sal_Int32 nColumnCount = xMd->getColumnCount();
|
|
|
|
::std::vector< ::rtl::OUString >::iterator aAutoIter = m_aAutoColumns.begin();
|
|
|
|
::std::vector< ::rtl::OUString >::iterator aAutoEnd = m_aAutoColumns.end();
|
|
|
|
for (sal_Int32 i = 1;aAutoIter != aAutoEnd && i <= nColumnCount; ++aAutoIter,++i)
|
|
|
|
{
|
2005-02-16 14:57:55 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2002-07-25 05:38:47 +00:00
|
|
|
::rtl::OUString sColumnName( xMd->getColumnName(i) );
|
|
|
|
#endif
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::iterator aFind = m_pKeyColumnNames->find(*aAutoIter);
|
2005-09-23 11:02:11 +00:00
|
|
|
if ( aFind != m_pKeyColumnNames->end() )
|
2012-01-16 19:38:01 +01:00
|
|
|
(_rInsertRow->get())[aFind->second.nPosition].fill(i, aFind->second.nType, xRow);
|
2002-07-25 05:38:47 +00:00
|
|
|
}
|
|
|
|
bAutoValuesFetched = sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-13 09:40:26 +01:00
|
|
|
catch(const Exception&)
|
2002-07-25 05:38:47 +00:00
|
|
|
{
|
2011-03-12 12:04:35 +01:00
|
|
|
OSL_FAIL("Could not execute GeneratedKeys() stmt");
|
2002-07-25 05:38:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-29 15:35:26 +00:00
|
|
|
::comphelper::disposeComponent(xPrep);
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2011-12-19 18:10:37 -02:00
|
|
|
if ( i_sTableName.isEmpty() && !bAutoValuesFetched && m_bInserted )
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2001-11-29 15:35:26 +00:00
|
|
|
// first check if all key column values were set
|
2009-07-03 12:24:35 +00:00
|
|
|
const ::rtl::OUString sMax(RTL_CONSTASCII_USTRINGPARAM(" MAX("));
|
|
|
|
const ::rtl::OUString sMaxEnd(RTL_CONSTASCII_USTRINGPARAM("),"));
|
|
|
|
const ::rtl::OUString sQuote = getIdentifierQuoteString();
|
2001-12-05 13:56:24 +00:00
|
|
|
::rtl::OUString sMaxStmt;
|
2009-07-03 12:24:35 +00:00
|
|
|
aEnd = m_pKeyColumnNames->end();
|
2001-12-05 13:56:24 +00:00
|
|
|
::std::vector< ::rtl::OUString >::iterator aAutoIter = m_aAutoColumns.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
::std::vector< ::rtl::OUString >::iterator aAutoEnd = m_aAutoColumns.end();
|
|
|
|
for (;aAutoIter != aAutoEnd; ++aAutoIter)
|
2001-12-05 13:56:24 +00:00
|
|
|
{
|
|
|
|
// we will only fetch values which are keycolumns
|
2010-08-31 13:42:47 +02:00
|
|
|
SelectColumnsMetaData::iterator aFind = m_pKeyColumnNames->find(*aAutoIter);
|
|
|
|
if ( aFind != aEnd )
|
2001-12-05 13:56:24 +00:00
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
sMaxStmt += sMax;
|
2010-08-31 13:42:47 +02:00
|
|
|
sMaxStmt += ::dbtools::quoteName( sQuote,aFind->second.sRealName
|
|
|
|
);
|
2009-07-03 12:24:35 +00:00
|
|
|
sMaxStmt += sMaxEnd;
|
2001-12-05 13:56:24 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-22 09:07:04 +00:00
|
|
|
|
2011-12-19 18:10:37 -02:00
|
|
|
if(!sMaxStmt.isEmpty())
|
2001-12-05 13:56:24 +00:00
|
|
|
{
|
2010-10-30 21:44:13 +01:00
|
|
|
sMaxStmt = sMaxStmt.replaceAt(sMaxStmt.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ")));
|
|
|
|
::rtl::OUString sStmt = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT "));
|
2001-12-05 13:56:24 +00:00
|
|
|
sStmt += sMaxStmt;
|
2010-10-30 21:44:13 +01:00
|
|
|
sStmt += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FROM "));
|
2010-09-01 13:09:46 +02:00
|
|
|
::rtl::OUString sCatalog,sSchema,sTable;
|
|
|
|
::dbtools::qualifiedNameComponents(m_xConnection->getMetaData(),m_sUpdateTableName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
|
|
|
|
sStmt += ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable );
|
2001-12-05 13:56:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
// now fetch the autoincrement values
|
|
|
|
Reference<XStatement> xStatement = m_xConnection->createStatement();
|
|
|
|
Reference<XResultSet> xRes = xStatement->executeQuery(sStmt);
|
|
|
|
Reference<XRow> xRow(xRes,UNO_QUERY);
|
|
|
|
if(xRow.is() && xRes->next())
|
|
|
|
{
|
|
|
|
aAutoIter = m_aAutoColumns.begin();
|
2005-03-18 09:04:30 +00:00
|
|
|
for (sal_Int32 i=1;aAutoIter != aAutoEnd; ++aAutoIter,++i)
|
2001-12-05 13:56:24 +00:00
|
|
|
{
|
|
|
|
// we will only fetch values which are keycolumns
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::iterator aFind = m_pKeyColumnNames->find(*aAutoIter);
|
2009-07-03 12:24:35 +00:00
|
|
|
if ( aFind != aEnd )
|
2012-01-16 19:38:01 +01:00
|
|
|
(_rInsertRow->get())[aFind->second.nPosition].fill(i, aFind->second.nType, xRow);
|
2001-12-05 13:56:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
::comphelper::disposeComponent(xStatement);
|
|
|
|
}
|
|
|
|
catch(SQLException&)
|
|
|
|
{
|
2011-03-12 12:04:35 +01:00
|
|
|
OSL_FAIL("Could not fetch with MAX() ");
|
2001-12-05 13:56:24 +00:00
|
|
|
}
|
|
|
|
}
|
2002-07-25 05:38:47 +00:00
|
|
|
}
|
2002-08-22 09:07:04 +00:00
|
|
|
if ( m_bInserted )
|
2002-07-25 05:38:47 +00:00
|
|
|
{
|
2001-01-24 08:52:19 +00:00
|
|
|
OKeySetMatrix::iterator aKeyIter = m_aKeyMap.end();
|
|
|
|
--aKeyIter;
|
2010-07-08 12:21:55 +02:00
|
|
|
ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >(m_pKeyColumnNames->size());
|
2010-01-19 09:16:12 +00:00
|
|
|
copyRowValue(_rInsertRow,aKeyRow,aKeyIter->first + 1);
|
|
|
|
|
2010-04-20 13:33:34 +02:00
|
|
|
m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(aKeyIter->first + 1,OKeySetValue(aKeyRow,::std::pair<sal_Int32,Reference<XRow> >(1,NULL)))).first;
|
2001-01-24 08:52:19 +00:00
|
|
|
// now we set the bookmark for this row
|
2008-12-30 13:32:01 +00:00
|
|
|
(_rInsertRow->get())[0] = makeAny((sal_Int32)m_aKeyIter->first);
|
2010-07-08 12:21:55 +02:00
|
|
|
tryRefetch(_rInsertRow,bRefetch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void OKeySet::tryRefetch(const ORowSetRow& _rInsertRow,bool bRefetch)
|
|
|
|
{
|
|
|
|
if ( bRefetch )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2012-01-18 13:10:12 +01:00
|
|
|
bRefetch = doTryRefetch_throw();
|
2010-07-08 12:21:55 +02:00
|
|
|
}
|
2011-04-13 09:40:26 +01:00
|
|
|
catch(const Exception&)
|
2010-07-08 12:21:55 +02:00
|
|
|
{
|
|
|
|
bRefetch = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !bRefetch )
|
|
|
|
{
|
|
|
|
m_aKeyIter->second.second.second = new OPrivateRow(_rInsertRow->get());
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-01-19 09:16:12 +00:00
|
|
|
void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sal_Int32 i_nBookmark)
|
2006-05-04 07:35:48 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::copyRowValue" );
|
2008-12-30 13:32:01 +00:00
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::iterator aIter = _rKeyRow->get().begin();
|
2010-01-19 09:16:12 +00:00
|
|
|
|
|
|
|
// check the if the parameter values have been changed
|
|
|
|
OSL_ENSURE((m_aParameterValueForCache.get().size()-1) == m_pParameterNames->size(),"OKeySet::copyRowValue: Parameter values and names differ!");
|
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaValuesIter = m_aParameterValueForCache.get().begin() +1;
|
|
|
|
|
|
|
|
bool bChanged = false;
|
|
|
|
SelectColumnsMetaData::const_iterator aParaIter = (*m_pParameterNames).begin();
|
|
|
|
SelectColumnsMetaData::const_iterator aParaEnd = (*m_pParameterNames).end();
|
|
|
|
for(sal_Int32 i = 1;aParaIter != aParaEnd;++aParaIter,++aParaValuesIter,++i)
|
|
|
|
{
|
|
|
|
ORowSetValue aValue(*aParaValuesIter);
|
|
|
|
aValue.setSigned(m_aSignedFlags[aParaIter->second.nPosition]);
|
|
|
|
if ( (_rInsertRow->get())[aParaIter->second.nPosition] != aValue )
|
|
|
|
{
|
|
|
|
ORowSetValueVector aCopy(m_aParameterValueForCache);
|
|
|
|
(aCopy.get())[i] = (_rInsertRow->get())[aParaIter->second.nPosition];
|
|
|
|
m_aUpdatedParameter[i_nBookmark] = aCopy;
|
|
|
|
bChanged = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !bChanged )
|
|
|
|
{
|
|
|
|
m_aUpdatedParameter.erase(i_nBookmark);
|
|
|
|
}
|
|
|
|
|
|
|
|
// update the key values
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
|
|
|
|
SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
|
2006-05-04 07:35:48 +00:00
|
|
|
for(;aPosIter != aPosEnd;++aPosIter,++aIter)
|
|
|
|
{
|
2010-10-28 14:15:54 +02:00
|
|
|
impl_convertValue_throw(_rInsertRow,aPosIter->second);
|
2008-12-30 13:32:01 +00:00
|
|
|
*aIter = (_rInsertRow->get())[aPosIter->second.nPosition];
|
2006-07-10 14:02:45 +00:00
|
|
|
aIter->setTypeKind(aPosIter->second.nType);
|
2006-05-04 07:35:48 +00:00
|
|
|
}
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::deleteRow" );
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
|
|
|
|
fillTableName(xSet);
|
|
|
|
|
2010-10-30 21:44:13 +01:00
|
|
|
::rtl::OUStringBuffer aSql = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DELETE FROM "));
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(m_aComposedTableName);
|
2010-10-30 21:44:13 +01:00
|
|
|
aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE ")));
|
2001-02-01 13:23:57 +00:00
|
|
|
|
|
|
|
// list all cloumns that should be set
|
2003-12-01 09:33:47 +00:00
|
|
|
::rtl::OUString aQuote = getIdentifierQuoteString();
|
2010-10-30 21:44:13 +01:00
|
|
|
static ::rtl::OUString aAnd(RTL_CONSTASCII_USTRINGPARAM(" AND "));
|
2001-02-01 13:23:57 +00:00
|
|
|
|
|
|
|
// use keys and indexes for excat postioning
|
|
|
|
Reference<XNameAccess> xKeyColumns = getKeyColumns();
|
|
|
|
// second the indexes
|
|
|
|
Reference<XIndexesSupplier> xIndexSup(_xTable,UNO_QUERY);
|
|
|
|
Reference<XIndexAccess> xIndexes;
|
2004-08-02 14:00:09 +00:00
|
|
|
if ( xIndexSup.is() )
|
|
|
|
xIndexes.set(xIndexSup->getIndexes(),UNO_QUERY);
|
2001-02-01 13:23:57 +00:00
|
|
|
|
|
|
|
// Reference<XColumnsSupplier>
|
|
|
|
::std::vector< Reference<XNameAccess> > aAllIndexColumns;
|
2004-08-02 14:00:09 +00:00
|
|
|
lcl_fillIndexColumns(xIndexes,aAllIndexColumns);
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2009-07-03 12:24:35 +00:00
|
|
|
::rtl::OUString aColumnName;
|
|
|
|
::rtl::OUStringBuffer sIndexCondition;
|
2004-08-02 14:00:09 +00:00
|
|
|
::std::vector<sal_Int32> aIndexColumnPositions;
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
|
2004-03-15 14:45:30 +00:00
|
|
|
|
|
|
|
sal_Int32 i = 1;
|
2009-07-03 12:24:35 +00:00
|
|
|
for(i = 1;aIter != aEnd;++aIter,++i)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2009-11-11 14:16:42 +01:00
|
|
|
if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() )
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
aSql.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
|
2008-12-30 13:32:01 +00:00
|
|
|
if((_rDeleteRow->get())[aIter->second.nPosition].isNull())
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2011-03-12 12:04:35 +01:00
|
|
|
OSL_FAIL("can a primary key be null");
|
2010-10-30 21:44:13 +01:00
|
|
|
aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")));
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
else
|
2010-10-30 21:44:13 +01:00
|
|
|
aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" = ?")));
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(aAnd);
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
2004-08-02 14:00:09 +00:00
|
|
|
else
|
|
|
|
{
|
2009-07-03 12:24:35 +00:00
|
|
|
::std::vector< Reference<XNameAccess> >::const_iterator aIndexEnd = aAllIndexColumns.end();
|
2004-08-02 14:00:09 +00:00
|
|
|
for( ::std::vector< Reference<XNameAccess> >::const_iterator aIndexIter = aAllIndexColumns.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
aIndexIter != aIndexEnd;++aIndexIter)
|
2004-08-02 14:00:09 +00:00
|
|
|
{
|
|
|
|
if((*aIndexIter)->hasByName(aIter->first))
|
|
|
|
{
|
2010-07-08 12:21:55 +02:00
|
|
|
sIndexCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
|
2008-12-30 13:32:01 +00:00
|
|
|
if((_rDeleteRow->get())[aIter->second.nPosition].isNull())
|
2010-10-30 21:44:13 +01:00
|
|
|
sIndexCondition.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")));
|
2004-08-02 14:00:09 +00:00
|
|
|
else
|
|
|
|
{
|
2010-10-30 21:44:13 +01:00
|
|
|
sIndexCondition.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" = ?")));
|
2006-07-10 14:02:45 +00:00
|
|
|
aIndexColumnPositions.push_back(aIter->second.nPosition);
|
2004-08-02 14:00:09 +00:00
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
sIndexCondition.append(aAnd);
|
2004-08-02 14:00:09 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
2009-07-03 12:24:35 +00:00
|
|
|
aSql.append(sIndexCondition.makeStringAndClear());
|
|
|
|
aSql.setLength(aSql.getLength()-5);
|
2001-02-01 13:23:57 +00:00
|
|
|
|
|
|
|
// now create end execute the prepared statement
|
2009-07-03 12:24:35 +00:00
|
|
|
Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear()));
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference< XParameters > xParameter(xPrep,UNO_QUERY);
|
|
|
|
|
2001-10-30 13:22:10 +00:00
|
|
|
aIter = (*m_pKeyColumnNames).begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
aEnd = (*m_pKeyColumnNames).end();
|
2004-08-02 14:00:09 +00:00
|
|
|
i = 1;
|
2009-07-03 12:24:35 +00:00
|
|
|
for(;aIter != aEnd;++aIter,++i)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
setParameter(i,xParameter,(_rDeleteRow->get())[aIter->second.nPosition],aIter->second.nType,aIter->second.nScale);
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
|
2004-08-02 14:00:09 +00:00
|
|
|
// now we have to set the index values
|
|
|
|
::std::vector<sal_Int32>::iterator aIdxColIter = aIndexColumnPositions.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
::std::vector<sal_Int32>::iterator aIdxColEnd = aIndexColumnPositions.end();
|
2009-11-11 14:16:42 +01:00
|
|
|
aIter = m_pColumnNames->begin();
|
|
|
|
for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++aIter)
|
2004-08-02 14:00:09 +00:00
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
setParameter(i,xParameter,(_rDeleteRow->get())[*aIdxColIter],(_rDeleteRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale);
|
2004-08-02 14:00:09 +00:00
|
|
|
}
|
|
|
|
|
2001-02-01 13:23:57 +00:00
|
|
|
m_bDeleted = xPrep->executeUpdate() > 0;
|
|
|
|
|
|
|
|
if(m_bDeleted)
|
2001-01-22 06:38:24 +00:00
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
sal_Int32 nBookmark = ::comphelper::getINT32((_rDeleteRow->get())[0].getAny());
|
2003-06-25 10:02:13 +00:00
|
|
|
if(m_aKeyIter == m_aKeyMap.find(nBookmark) && m_aKeyIter != m_aKeyMap.end())
|
2001-06-22 12:07:17 +00:00
|
|
|
++m_aKeyIter;
|
2003-06-25 10:02:13 +00:00
|
|
|
m_aKeyMap.erase(nBookmark);
|
2001-06-22 12:07:17 +00:00
|
|
|
m_bDeleted = sal_True;
|
2001-01-22 06:38:24 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
void SAL_CALL OKeySet::cancelRowUpdates( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::cancelRowUpdates" );
|
2001-01-22 06:38:24 +00:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = sal_False;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
void SAL_CALL OKeySet::moveToInsertRow( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::moveToInsertRow" );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
void SAL_CALL OKeySet::moveToCurrentRow( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::moveToCurrentRow" );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-02-01 13:23:57 +00:00
|
|
|
Reference<XNameAccess> OKeySet::getKeyColumns() const
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getKeyColumns" );
|
2010-11-08 02:50:53 -06:00
|
|
|
// use keys and indexes for excat postioning
|
2001-01-24 08:52:19 +00:00
|
|
|
// first the keys
|
2008-06-06 12:58:16 +00:00
|
|
|
|
|
|
|
Reference<XIndexAccess> xKeys = m_xTableKeys;
|
|
|
|
if ( !xKeys.is() )
|
|
|
|
{
|
2010-02-15 09:53:53 +01:00
|
|
|
Reference<XPropertySet> xSet(m_xTable,UNO_QUERY);
|
|
|
|
const Reference<XNameAccess> xPrimaryKeyColumns = getPrimaryKeyColumns_throw(xSet);
|
|
|
|
return xPrimaryKeyColumns;
|
2008-06-06 12:58:16 +00:00
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
|
|
|
|
Reference<XColumnsSupplier> xKeyColsSup;
|
|
|
|
Reference<XNameAccess> xKeyColumns;
|
|
|
|
if(xKeys.is())
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xProp;
|
2004-08-02 14:00:09 +00:00
|
|
|
sal_Int32 nCount = xKeys->getCount();
|
|
|
|
for(sal_Int32 i = 0;i< nCount;++i)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2004-08-02 14:00:09 +00:00
|
|
|
xProp.set(xKeys->getByIndex(i),UNO_QUERY);
|
|
|
|
if ( xProp.is() )
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2004-08-02 14:00:09 +00:00
|
|
|
sal_Int32 nKeyType = 0;
|
|
|
|
xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
|
|
|
|
if(KeyType::PRIMARY == nKeyType)
|
|
|
|
{
|
|
|
|
xKeyColsSup.set(xProp,UNO_QUERY);
|
|
|
|
OSL_ENSURE(xKeyColsSup.is(),"Columnsupplier is null!");
|
|
|
|
xKeyColumns = xKeyColsSup->getColumns();
|
|
|
|
break;
|
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-01 13:23:57 +00:00
|
|
|
return xKeyColumns;
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
sal_Bool SAL_CALL OKeySet::next( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::next" );
|
2001-01-24 08:52:19 +00:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = sal_False;
|
|
|
|
|
|
|
|
if(isAfterLast())
|
|
|
|
return sal_False;
|
2012-05-15 18:37:43 +02:00
|
|
|
++m_aKeyIter;
|
2012-06-01 14:52:46 +02:00
|
|
|
if(!m_bRowCountFinal && m_aKeyIter == m_aKeyMap.end())
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2012-06-01 14:52:46 +02:00
|
|
|
// not yet all records fetched, but we reached the end of those we fetched
|
|
|
|
// try to fetch one more row
|
|
|
|
if (!fetchRow())
|
|
|
|
{
|
|
|
|
// nope, we arrived at end of data
|
2001-01-24 08:52:19 +00:00
|
|
|
m_aKeyIter = m_aKeyMap.end();
|
2012-06-01 14:52:46 +02:00
|
|
|
OSL_ENSURE(isAfterLast(), "fetchRow failed, but not end of data");
|
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
refreshRow();
|
|
|
|
return !isAfterLast();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
sal_Bool SAL_CALL OKeySet::isBeforeFirst( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::isBeforeFirst" );
|
2001-01-24 08:52:19 +00:00
|
|
|
return m_aKeyIter == m_aKeyMap.begin();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
sal_Bool SAL_CALL OKeySet::isAfterLast( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::isAfterLast" );
|
2001-01-24 08:52:19 +00:00
|
|
|
return m_bRowCountFinal && m_aKeyIter == m_aKeyMap.end();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
sal_Bool SAL_CALL OKeySet::isFirst( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::isFirst" );
|
2001-01-24 08:52:19 +00:00
|
|
|
OKeySetMatrix::iterator aTemp = m_aKeyMap.begin();
|
|
|
|
++aTemp;
|
|
|
|
return m_aKeyIter == aTemp && m_aKeyIter != m_aKeyMap.end();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
sal_Bool SAL_CALL OKeySet::isLast( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::isLast" );
|
2001-01-24 08:52:19 +00:00
|
|
|
if(!m_bRowCountFinal)
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
OKeySetMatrix::iterator aTemp = m_aKeyMap.end();
|
|
|
|
--aTemp;
|
|
|
|
return m_aKeyIter == aTemp;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
void SAL_CALL OKeySet::beforeFirst( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::beforeFirst" );
|
2001-01-24 08:52:19 +00:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = sal_False;
|
|
|
|
m_aKeyIter = m_aKeyMap.begin();
|
2010-07-08 12:21:55 +02:00
|
|
|
m_xRow = NULL;
|
|
|
|
::comphelper::disposeComponent(m_xSet);
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
void SAL_CALL OKeySet::afterLast( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::afterLast" );
|
2001-01-24 08:52:19 +00:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = sal_False;
|
|
|
|
fillAllRows();
|
|
|
|
m_aKeyIter = m_aKeyMap.end();
|
2010-07-08 12:21:55 +02:00
|
|
|
m_xRow = NULL;
|
|
|
|
::comphelper::disposeComponent(m_xSet);
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
sal_Bool SAL_CALL OKeySet::first( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::first" );
|
2001-01-24 08:52:19 +00:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = sal_False;
|
|
|
|
m_aKeyIter = m_aKeyMap.begin();
|
|
|
|
++m_aKeyIter;
|
|
|
|
if(m_aKeyIter == m_aKeyMap.end() && !fetchRow())
|
|
|
|
m_aKeyIter = m_aKeyMap.end();
|
2011-01-06 12:32:17 +01:00
|
|
|
else
|
|
|
|
refreshRow();
|
2001-01-24 08:52:19 +00:00
|
|
|
return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
sal_Bool SAL_CALL OKeySet::last( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2010-12-02 13:16:48 +01:00
|
|
|
return last_checked(sal_True);
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool OKeySet::last_checked( sal_Bool i_bFetchRow)
|
|
|
|
{
|
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::last_checked" );
|
2001-01-24 08:52:19 +00:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = sal_False;
|
|
|
|
fillAllRows();
|
|
|
|
|
|
|
|
m_aKeyIter = m_aKeyMap.end();
|
|
|
|
--m_aKeyIter;
|
2010-12-02 13:16:48 +01:00
|
|
|
if ( i_bFetchRow )
|
|
|
|
refreshRow();
|
2001-01-24 08:52:19 +00:00
|
|
|
return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
sal_Int32 SAL_CALL OKeySet::getRow( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getRow" );
|
2001-01-24 08:52:19 +00:00
|
|
|
OSL_ENSURE(!isAfterLast(),"getRow is not allowed when afterlast record!");
|
|
|
|
OSL_ENSURE(!isBeforeFirst(),"getRow is not allowed when beforefirst record!");
|
|
|
|
|
2002-10-01 08:03:59 +00:00
|
|
|
return ::std::distance(m_aKeyMap.begin(),m_aKeyIter);
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
sal_Bool SAL_CALL OKeySet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
|
2010-12-02 13:16:48 +01:00
|
|
|
{
|
|
|
|
return absolute_checked(row,sal_True);
|
|
|
|
}
|
|
|
|
sal_Bool OKeySet::absolute_checked( sal_Int32 row,sal_Bool i_bFetchRow )
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::absolute" );
|
2001-01-24 08:52:19 +00:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = sal_False;
|
|
|
|
OSL_ENSURE(row,"absolute(0) isn't allowed!");
|
|
|
|
if(row < 0)
|
|
|
|
{
|
|
|
|
if(!m_bRowCountFinal)
|
|
|
|
fillAllRows();
|
|
|
|
|
|
|
|
for(;row < 0 && m_aKeyIter != m_aKeyMap.begin();++row)
|
2012-04-29 16:34:25 +02:00
|
|
|
--m_aKeyIter;
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-04-02 10:14:53 +00:00
|
|
|
if(row >= (sal_Int32)m_aKeyMap.size())
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
|
|
|
if(!m_bRowCountFinal)
|
|
|
|
{
|
|
|
|
sal_Bool bNext = sal_True;
|
|
|
|
for(sal_Int32 i=m_aKeyMap.size()-1;i < row && bNext;++i)
|
|
|
|
bNext = fetchRow();
|
2010-12-02 13:16:48 +01:00
|
|
|
if ( bNext )
|
|
|
|
{
|
2012-06-01 16:40:41 +02:00
|
|
|
i_bFetchRow = true;
|
2010-12-02 13:16:48 +01:00
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
m_aKeyIter = m_aKeyMap.end();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_aKeyIter = m_aKeyMap.begin();
|
|
|
|
for(;row > 0 && m_aKeyIter != m_aKeyMap.end();--row)
|
|
|
|
++m_aKeyIter;
|
|
|
|
}
|
|
|
|
}
|
2010-12-02 13:16:48 +01:00
|
|
|
if ( i_bFetchRow )
|
|
|
|
refreshRow();
|
2001-01-24 08:52:19 +00:00
|
|
|
|
|
|
|
return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
sal_Bool SAL_CALL OKeySet::relative( sal_Int32 rows ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::relative" );
|
2001-01-24 08:52:19 +00:00
|
|
|
if(!rows)
|
|
|
|
{
|
|
|
|
refreshRow();
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return absolute(getRow()+rows);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-12-02 13:16:48 +01:00
|
|
|
sal_Bool OKeySet::previous_checked( sal_Bool i_bFetchRow )
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::previous" );
|
2001-01-24 08:52:19 +00:00
|
|
|
m_bInserted = m_bUpdated = m_bDeleted = sal_False;
|
|
|
|
if(m_aKeyIter != m_aKeyMap.begin())
|
|
|
|
{
|
|
|
|
--m_aKeyIter;
|
2010-12-02 13:16:48 +01:00
|
|
|
if ( i_bFetchRow )
|
|
|
|
refreshRow();
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
return m_aKeyIter != m_aKeyMap.begin();
|
|
|
|
}
|
2010-12-02 13:16:48 +01:00
|
|
|
sal_Bool SAL_CALL OKeySet::previous( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
return previous_checked(sal_True);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2012-01-18 13:10:12 +01:00
|
|
|
bool OKeySet::doTryRefetch_throw() throw(SQLException, RuntimeException)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2012-01-18 13:10:12 +01:00
|
|
|
// we just reassign the base members
|
2001-01-24 08:52:19 +00:00
|
|
|
Reference< XParameters > xParameter(m_xStatement,UNO_QUERY);
|
2001-12-05 13:56:24 +00:00
|
|
|
OSL_ENSURE(xParameter.is(),"No Parameter interface!");
|
|
|
|
xParameter->clearParameters();
|
2010-01-19 09:16:12 +00:00
|
|
|
|
2001-07-09 06:00:18 +00:00
|
|
|
sal_Int32 nPos=1;
|
2010-01-19 09:16:12 +00:00
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaIter;
|
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaEnd;
|
|
|
|
OUpdatedParameter::iterator aUpdateFind = m_aUpdatedParameter.find(m_aKeyIter->first);
|
|
|
|
if ( aUpdateFind == m_aUpdatedParameter.end() )
|
|
|
|
{
|
|
|
|
aParaIter = m_aParameterValueForCache.get().begin();
|
|
|
|
aParaEnd = m_aParameterValueForCache.get().end();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aParaIter = aUpdateFind->second.get().begin();
|
|
|
|
aParaEnd = aUpdateFind->second.get().end();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
for(++aParaIter;aParaIter != aParaEnd;++aParaIter,++nPos)
|
|
|
|
{
|
|
|
|
::dbtools::setObjectWithInfo( xParameter, nPos, aParaIter->makeAny(), aParaIter->getTypeKind() );
|
|
|
|
}
|
2010-07-08 12:21:55 +02:00
|
|
|
|
|
|
|
// now set the primary key column values
|
2008-12-30 13:32:01 +00:00
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter = m_aKeyIter->second.first->get().begin();
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
|
2012-01-18 12:30:36 +01:00
|
|
|
for(;aPosIter != aPosEnd;++aPosIter,++aIter)
|
|
|
|
setOneKeyColumnParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale);
|
2006-08-15 09:41:07 +00:00
|
|
|
aPosIter = (*m_pForeignColumnNames).begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
aPosEnd = (*m_pForeignColumnNames).end();
|
2012-01-18 12:30:36 +01:00
|
|
|
for(;aPosIter != aPosEnd;++aPosIter,++aIter)
|
|
|
|
setOneKeyColumnParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale);
|
2001-01-24 08:52:19 +00:00
|
|
|
|
|
|
|
m_xSet = m_xStatement->executeQuery();
|
2012-01-18 13:10:12 +01:00
|
|
|
OSL_ENSURE(m_xSet.is(),"No resultset from statement!");
|
2012-01-18 13:51:14 +01:00
|
|
|
return m_xSet->next();
|
2012-01-18 13:10:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException)
|
|
|
|
{
|
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::refreshRow" );
|
|
|
|
|
|
|
|
m_xRow = NULL;
|
|
|
|
::comphelper::disposeComponent(m_xSet);
|
|
|
|
|
2012-06-01 15:42:27 +02:00
|
|
|
if(isBeforeFirst() || isAfterLast() || !m_xStatement.is())
|
|
|
|
return;
|
|
|
|
|
2012-01-18 13:10:12 +01:00
|
|
|
if ( m_aKeyIter->second.second.second.is() )
|
|
|
|
{
|
|
|
|
m_xRow = m_aKeyIter->second.second.second;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool bOK = doTryRefetch_throw();
|
2009-11-27 10:17:16 +01:00
|
|
|
if ( !bOK )
|
2011-01-06 12:32:17 +01:00
|
|
|
{
|
2012-06-01 11:42:53 +02:00
|
|
|
// This row has disappeared; remove it.
|
2011-01-06 12:32:17 +01:00
|
|
|
OKeySetMatrix::iterator aTemp = m_aKeyIter;
|
2012-06-01 11:42:53 +02:00
|
|
|
// use *next* row
|
2011-01-06 12:32:17 +01:00
|
|
|
++m_aKeyIter;
|
|
|
|
m_aKeyMap.erase(aTemp);
|
2012-06-01 11:42:53 +02:00
|
|
|
|
|
|
|
// adjust RowCount for the row we have removed
|
|
|
|
if (m_rRowCount > 0)
|
|
|
|
--m_rRowCount;
|
|
|
|
else
|
|
|
|
OSL_FAIL("m_rRowCount got out of sync: non-empty m_aKeyMap, but m_rRowCount <= 0");
|
|
|
|
|
|
|
|
if (!isAfterLast())
|
|
|
|
{
|
|
|
|
// it was the last row, but there may be another one to fetch
|
|
|
|
fetchRow();
|
|
|
|
}
|
2011-01-06 12:32:17 +01:00
|
|
|
refreshRow();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_xRow.set(m_xSet,UNO_QUERY);
|
2012-01-18 13:10:12 +01:00
|
|
|
OSL_ENSURE(m_xRow.is(),"No row from statement!");
|
2011-01-06 12:32:17 +01:00
|
|
|
}
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
sal_Bool OKeySet::fetchRow()
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::fetchRow" );
|
2001-06-22 12:07:17 +00:00
|
|
|
// fetch the next row and append on the keyset
|
2001-11-29 15:35:26 +00:00
|
|
|
sal_Bool bRet = sal_False;
|
2010-11-24 14:23:06 +01:00
|
|
|
if ( !m_bRowCountFinal && (!m_nMaxRows || sal_Int32(m_aKeyMap.size()) < m_nMaxRows) )
|
2006-07-10 14:02:45 +00:00
|
|
|
bRet = m_xDriverSet->next();
|
|
|
|
if ( bRet )
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2006-08-15 09:41:07 +00:00
|
|
|
ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >((*m_pKeyColumnNames).size() + m_pForeignColumnNames->size());
|
2008-12-30 13:32:01 +00:00
|
|
|
connectivity::ORowVector< ORowSetValue >::Vector::iterator aIter = aKeyRow->get().begin();
|
2012-01-16 19:38:01 +01:00
|
|
|
// first fetch the values needed for the key columns
|
2006-07-10 14:02:45 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
|
2009-04-23 10:42:05 +00:00
|
|
|
SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
|
|
|
|
for(;aPosIter != aPosEnd;++aPosIter,++aIter)
|
2006-08-15 09:41:07 +00:00
|
|
|
{
|
|
|
|
const SelectColumnDescription& rColDesc = aPosIter->second;
|
2012-01-16 19:38:01 +01:00
|
|
|
aIter->fill(rColDesc.nPosition, rColDesc.nType, m_xDriverRow);
|
2006-08-15 09:41:07 +00:00
|
|
|
}
|
|
|
|
// now fetch the values from the missing columns from other tables
|
|
|
|
aPosIter = (*m_pForeignColumnNames).begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
aPosEnd = (*m_pForeignColumnNames).end();
|
2009-04-23 10:42:05 +00:00
|
|
|
for(;aPosIter != aPosEnd;++aPosIter,++aIter)
|
2001-01-24 08:52:19 +00:00
|
|
|
{
|
2006-07-10 14:02:45 +00:00
|
|
|
const SelectColumnDescription& rColDesc = aPosIter->second;
|
2012-01-16 19:38:01 +01:00
|
|
|
aIter->fill(rColDesc.nPosition, rColDesc.nType, m_xDriverRow);
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
2010-04-20 13:33:34 +02:00
|
|
|
m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(m_aKeyMap.rbegin()->first+1,OKeySetValue(aKeyRow,::std::pair<sal_Int32,Reference<XRow> >(0,NULL)))).first;
|
2001-01-24 08:52:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
m_bRowCountFinal = sal_True;
|
|
|
|
return bRet;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-01-24 08:52:19 +00:00
|
|
|
void OKeySet::fillAllRows()
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::fillAllRows" );
|
2001-01-24 08:52:19 +00:00
|
|
|
if(!m_bRowCountFinal)
|
|
|
|
{
|
|
|
|
while(fetchRow())
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
2001-06-22 12:07:17 +00:00
|
|
|
// XRow
|
|
|
|
sal_Bool SAL_CALL OKeySet::wasNull( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::wasNull" );
|
2012-06-01 11:38:59 +02:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
2001-06-22 12:07:17 +00:00
|
|
|
return m_xRow->wasNull();
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
::rtl::OUString SAL_CALL OKeySet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getString" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getString(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
sal_Bool SAL_CALL OKeySet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getBoolean" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getBoolean(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
sal_Int8 SAL_CALL OKeySet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getByte" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getByte(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
sal_Int16 SAL_CALL OKeySet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getShort" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getShort(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
sal_Int32 SAL_CALL OKeySet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getInt" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getInt(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
sal_Int64 SAL_CALL OKeySet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getLong" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getLong(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
float SAL_CALL OKeySet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getFloat" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getFloat(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
double SAL_CALL OKeySet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getDouble" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getDouble(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
Sequence< sal_Int8 > SAL_CALL OKeySet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getBytes" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getBytes(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
::com::sun::star::util::Date SAL_CALL OKeySet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getDate" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getDate(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
::com::sun::star::util::Time SAL_CALL OKeySet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getTime" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getTime(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
::com::sun::star::util::DateTime SAL_CALL OKeySet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getTimestamp" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getTimestamp(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
Reference< ::com::sun::star::io::XInputStream > SAL_CALL OKeySet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getBinaryStream" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getBinaryStream(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
Reference< ::com::sun::star::io::XInputStream > SAL_CALL OKeySet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getCharacterStream" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getCharacterStream(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
Any SAL_CALL OKeySet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getObject" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getObject(columnIndex,typeMap);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
Reference< XRef > SAL_CALL OKeySet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getRef" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getRef(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
Reference< XBlob > SAL_CALL OKeySet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getBlob" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getBlob(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
Reference< XClob > SAL_CALL OKeySet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getClob" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getClob(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
Reference< XArray > SAL_CALL OKeySet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getArray" );
|
2001-06-22 12:07:17 +00:00
|
|
|
OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
|
|
|
|
return m_xRow->getArray(columnIndex);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
sal_Bool SAL_CALL OKeySet::rowUpdated( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::rowUpdated" );
|
2010-04-20 13:33:34 +02:00
|
|
|
return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second.first == 2;
|
2001-06-22 12:07:17 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
sal_Bool SAL_CALL OKeySet::rowInserted( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::rowInserted" );
|
2010-04-20 13:33:34 +02:00
|
|
|
return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second.first == 1;
|
2001-06-22 12:07:17 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-06-22 12:07:17 +00:00
|
|
|
sal_Bool SAL_CALL OKeySet::rowDeleted( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::rowDeleted" );
|
2001-06-22 12:07:17 +00:00
|
|
|
sal_Bool bDeleted = m_bDeleted;
|
|
|
|
m_bDeleted = sal_False;
|
|
|
|
return bDeleted;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-12-05 13:56:24 +00:00
|
|
|
::rtl::OUString OKeySet::getComposedTableName(const ::rtl::OUString& _sCatalog,
|
|
|
|
const ::rtl::OUString& _sSchema,
|
|
|
|
const ::rtl::OUString& _sTable)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getComposedTableName" );
|
2001-12-05 13:56:24 +00:00
|
|
|
::rtl::OUString aComposedName;
|
|
|
|
Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData();
|
|
|
|
|
2003-12-01 09:33:47 +00:00
|
|
|
if( xMetaData.is() && xMetaData->supportsTableCorrelationNames() )
|
2001-12-05 13:56:24 +00:00
|
|
|
{
|
2006-07-10 14:02:45 +00:00
|
|
|
aComposedName = ::dbtools::composeTableName( xMetaData, _sCatalog, _sSchema, _sTable, sal_False, ::dbtools::eInDataManipulation );
|
2001-12-05 13:56:24 +00:00
|
|
|
// first we have to check if the composed tablename is in the select clause or if an alias is used
|
|
|
|
Reference<XTablesSupplier> xTabSup(m_xComposer,UNO_QUERY);
|
|
|
|
Reference<XNameAccess> xSelectTables = xTabSup->getTables();
|
|
|
|
OSL_ENSURE(xSelectTables.is(),"No Select tables!");
|
|
|
|
if(xSelectTables.is())
|
|
|
|
{
|
|
|
|
if(!xSelectTables->hasByName(aComposedName))
|
|
|
|
{ // the composed name isn't used in the select clause so we have to find out which name is used instead
|
|
|
|
::rtl::OUString sCatalog,sSchema,sTable;
|
2002-10-08 11:46:28 +00:00
|
|
|
::dbtools::qualifiedNameComponents(xMetaData,m_sUpdateTableName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
|
2006-07-10 14:02:45 +00:00
|
|
|
aComposedName = ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable );
|
2001-12-05 13:56:24 +00:00
|
|
|
}
|
|
|
|
else
|
2006-07-10 14:02:45 +00:00
|
|
|
aComposedName = ::dbtools::composeTableNameForSelect( m_xConnection, _sCatalog, _sSchema, _sTable );
|
2001-12-05 13:56:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2006-07-10 14:02:45 +00:00
|
|
|
aComposedName = ::dbtools::composeTableNameForSelect( m_xConnection, _sCatalog, _sSchema, _sTable );
|
2001-12-05 13:56:24 +00:00
|
|
|
|
|
|
|
return aComposedName;
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2001-02-01 13:23:57 +00:00
|
|
|
namespace dbaccess
|
|
|
|
{
|
2010-01-20 20:09:04 +00:00
|
|
|
|
|
|
|
void getColumnPositions(const Reference<XNameAccess>& _rxQueryColumns,
|
2010-06-04 14:23:34 +02:00
|
|
|
const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _aColumnNames,
|
2010-01-20 20:09:04 +00:00
|
|
|
const ::rtl::OUString& _rsUpdateTableName,
|
2010-02-15 09:53:53 +01:00
|
|
|
SelectColumnsMetaData& o_rColumnNames,
|
|
|
|
bool i_bAppendTableName)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
|
|
|
// get the real name of the columns
|
|
|
|
Sequence< ::rtl::OUString> aSelNames(_rxQueryColumns->getElementNames());
|
2010-02-15 09:53:53 +01:00
|
|
|
const ::rtl::OUString* pSelIter = aSelNames.getConstArray();
|
|
|
|
const ::rtl::OUString* pSelEnd = pSelIter + aSelNames.getLength();
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
const ::rtl::OUString* pTblColumnIter = _aColumnNames.getConstArray();
|
|
|
|
const ::rtl::OUString* pTblColumnEnd = pTblColumnIter + _aColumnNames.getLength();
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2010-06-04 14:23:34 +02:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
::comphelper::UStringMixLess aTmp(o_rColumnNames.key_comp());
|
2001-09-13 09:38:45 +00:00
|
|
|
::comphelper::UStringMixEqual bCase(static_cast< ::comphelper::UStringMixLess*>(&aTmp)->isCaseSensitive());
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
for(sal_Int32 nPos = 1;pSelIter != pSelEnd;++pSelIter,++nPos)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2010-02-15 09:53:53 +01:00
|
|
|
Reference<XPropertySet> xQueryColumnProp(_rxQueryColumns->getByName(*pSelIter),UNO_QUERY_THROW);
|
2001-02-01 13:23:57 +00:00
|
|
|
::rtl::OUString sRealName,sTableName;
|
2010-02-15 09:53:53 +01:00
|
|
|
OSL_ENSURE(xQueryColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME),"Property REALNAME not available!");
|
|
|
|
OSL_ENSURE(xQueryColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_TABLENAME),"Property TABLENAME not available!");
|
|
|
|
xQueryColumnProp->getPropertyValue(PROPERTY_REALNAME) >>= sRealName;
|
|
|
|
xQueryColumnProp->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName;
|
2001-02-01 13:23:57 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
for(;pTblColumnIter != pTblColumnEnd;++pTblColumnIter)
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2010-02-15 09:53:53 +01:00
|
|
|
if(bCase(sRealName,*pTblColumnIter) && bCase(_rsUpdateTableName,sTableName) && o_rColumnNames.find(*pTblColumnIter) == o_rColumnNames.end())
|
2001-02-01 13:23:57 +00:00
|
|
|
{
|
2006-11-21 16:15:22 +00:00
|
|
|
sal_Int32 nType = 0;
|
2010-02-15 09:53:53 +01:00
|
|
|
xQueryColumnProp->getPropertyValue(PROPERTY_TYPE) >>= nType;
|
2008-01-30 07:28:36 +00:00
|
|
|
sal_Int32 nScale = 0;
|
2010-02-15 09:53:53 +01:00
|
|
|
xQueryColumnProp->getPropertyValue(PROPERTY_SCALE) >>= nScale;
|
2005-03-18 09:04:30 +00:00
|
|
|
::rtl::OUString sColumnDefault;
|
2010-02-15 09:53:53 +01:00
|
|
|
if ( xQueryColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_DEFAULTVALUE) )
|
|
|
|
xQueryColumnProp->getPropertyValue(PROPERTY_DEFAULTVALUE) >>= sColumnDefault;
|
2005-03-18 09:04:30 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
sal_Int32 nNullable = ColumnValue::NULLABLE_UNKNOWN;
|
|
|
|
OSL_VERIFY( xQueryColumnProp->getPropertyValue( PROPERTY_ISNULLABLE ) >>= nNullable );
|
2009-04-23 10:42:05 +00:00
|
|
|
|
2010-02-15 09:53:53 +01:00
|
|
|
if ( i_bAppendTableName )
|
|
|
|
{
|
|
|
|
::rtl::OUStringBuffer sName;
|
|
|
|
sName.append(sTableName);
|
|
|
|
sName.appendAscii(".");
|
|
|
|
sName.append(sRealName);
|
|
|
|
SelectColumnDescription aColDesc( nPos, nType,nScale,nNullable != sdbc::ColumnValue::NO_NULLS, sColumnDefault );
|
|
|
|
aColDesc.sRealName = sRealName;
|
|
|
|
aColDesc.sTableName = sTableName;
|
|
|
|
o_rColumnNames[sName.makeStringAndClear()] = aColDesc;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
o_rColumnNames[sRealName] = SelectColumnDescription( nPos, nType,nScale,nNullable != sdbc::ColumnValue::NO_NULLS, sColumnDefault );
|
2009-04-23 10:42:05 +00:00
|
|
|
|
2001-02-01 13:23:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-02-15 09:53:53 +01:00
|
|
|
pTblColumnIter = _aColumnNames.getConstArray();
|
2001-02-01 13:23:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
2010-01-20 14:49:00 +01:00
|
|
|
void OKeySet::impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData)
|
|
|
|
{
|
|
|
|
ORowSetValue& aValue((_rInsertRow->get())[i_aMetaData.nPosition]);
|
|
|
|
switch(i_aMetaData.nType)
|
|
|
|
{
|
|
|
|
case DataType::DECIMAL:
|
|
|
|
case DataType::NUMERIC:
|
|
|
|
{
|
|
|
|
::rtl::OUString sValue = aValue.getString();
|
|
|
|
sal_Int32 nIndex = sValue.indexOf('.');
|
|
|
|
if ( nIndex != -1 )
|
|
|
|
{
|
2010-08-24 15:00:36 +02:00
|
|
|
aValue = sValue.copy(0,::std::min(sValue.getLength(),nIndex + (i_aMetaData.nScale > 0 ? i_aMetaData.nScale + 1 : 0)));
|
2010-01-20 14:49:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-10-12 15:59:03 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|