2000-09-18 23:16:46 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 11:32:58 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 11:32:58 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 11:32:58 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 11:32:58 +00:00
|
|
|
* $RCSfile: query.cxx,v $
|
|
|
|
* $Revision: 1.35 $
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 11:32:58 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 11:32:58 +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:32:58 +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:32:58 +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:35:02 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_dbaccess.hxx"
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
#ifndef _DBA_COREAPI_QUERY_HXX_
|
|
|
|
#include "query.hxx"
|
|
|
|
#endif
|
2000-10-25 06:32:52 +00:00
|
|
|
#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
|
|
|
|
#include "dbastrings.hrc"
|
2000-09-18 23:16:46 +00:00
|
|
|
#endif
|
CWS-TOOLING: integrate CWS evoab2def
2009-05-28 16:00:19 +0200 fs r272412 : don't use createFalse - Evo 2.22 simply hangs when ask for all contacts without a first name. Instead, in the WHERE 0=1 case, simply create an empty result set
2009-05-22 14:25:51 +0200 fs r272193 : #i10000#
2009-05-22 14:25:37 +0200 fs r272192 : oops, ENABLE_EVOAB2 for some platforms only, not generically
2009-05-22 14:19:00 +0200 fs r272191 : #i10000#
2009-05-22 12:42:38 +0200 fs r272183 : when sorting, properly use a syslocale collator, instead of comparing the numerical values of the string's UTF-16 code points
2009-05-20 15:09:00 +0200 fs r272131 : clear/getWarnings: also allowed without cache
2009-05-20 14:11:19 +0200 fs r272128 : removed debug traces
2009-05-20 14:03:31 +0200 fs r272126 : #i55701# +STR_SORT_BY_COL_ONLY
2009-05-20 14:02:29 +0200 fs r272125 : implement sorting
2009-05-20 10:10:19 +0200 fs r272107 : #i10000#
2009-05-19 16:02:17 +0200 fs r272089 : #i10000#
2009-05-19 16:02:02 +0200 fs r272088 : #i55701# strings for new error condition DATA_CANNOT_SELECT_UNFILTERED
2009-05-19 16:01:31 +0200 fs r272087 : #i55701# use DATA_CANNOT_SELECT_UNFILTERED as standardized error code
2009-05-19 15:59:59 +0200 fs r272086 : #i55701# +DATA_CANNOT_SELECT_UNFILTERED
2009-05-19 15:46:12 +0200 fs r272084 : #i55701# recognize the DATA_CANNOT_SELECT_UNFILTERED error condition, and allow filtering in this case, even when the result set is empty
2009-05-19 09:06:50 +0200 fs r272059 : merging changes from CWS dba32b, to prevent future conflicts with upcoming local changes
2009-05-18 21:48:58 +0200 fs r272054 : accessing a non-local unfiltered address book now returns an empty result set, and reports a warning, instead of ungracefully failing
2009-05-18 21:48:42 +0200 fs r272053 : accessing a non-local unfiltered address book now returns an empty result set, and reports a warning, instead of ungracefully failing
2009-05-18 21:47:41 +0200 fs r272052 : +setExternalWarnings
2009-05-18 21:47:12 +0200 fs r272051 : #i55701# when re/loading the form, display any possible warnings
2009-05-18 21:43:26 +0200 fs r272050 : #i55701# implement XWarningsSupplier, exposing the warnings of our result set
2009-05-18 21:42:51 +0200 fs r272049 : #i55701# implement XWarningsSupplier, exposing the warnings of our aggregate RowSet
2009-05-18 17:53:59 +0200 fs r272041 : #i55701# moved the (I)WarningsContainer from dbaccess to connectivity, to be able to use it in the latter module, too
2009-05-18 17:24:10 +0200 fs r272040 : #i55701# properly enable the various Evolution types
2009-05-18 14:52:19 +0200 fs r272024 : #i55701# properly enable the Evolution types
2009-05-18 13:57:10 +0200 fs r272018 : fixed/extended whereAnalysis (column searching still not enabled, as neither LIKE nor = seem to work with my (somewhat older) Evolution version)
2009-05-18 13:56:08 +0200 fs r272017 : extended showParseTree
2009-05-18 13:55:25 +0200 fs r272016 : extended showParseTree
2009-05-18 11:40:16 +0200 fs r272008 : #i55701#
2009-05-18 11:39:02 +0200 fs r272006 : let the PreparedStatement return proper meta data, too
2009-05-18 10:05:37 +0200 fs r271999 : moved the XStatement interface to from OCommonStatement to OStatement - the former class is also the base for other classes which should not have this interface
2009-05-15 21:53:22 +0200 fs r271973 : collectColumnInformation: report invalid meta data as assertion
2009-05-15 21:51:40 +0200 fs r271972 : showParseTree should be const
2009-05-15 21:51:26 +0200 fs r271971 : showParseTree should be const
2009-05-15 21:51:03 +0200 fs r271970 : properly recognize the 'WHERE 0 = 1' clause, this way having proper statement meta data, this way saving much much calls from the DBA framework
2009-05-15 20:29:03 +0200 fs r271969 : cleaned up the mess with the statement classes
2009-05-15 15:51:11 +0200 fs r271944 : let the result set properly init its meta data
2009-05-15 15:29:54 +0200 fs r271939 : proper property implementations for the resultset class
2009-05-15 15:01:31 +0200 fs r271936 : proper property implementations for the statement class
2009-05-08 14:46:33 +0200 fs r271717 : component_foo must be PUBLIC
2009-05-06 09:20:05 +0200 fs r271565 : #i10000# (warnings on unxlngi6)
2009-05-06 09:01:30 +0200 fs r271564 : #i101493#
2009-05-05 23:08:12 +0200 fs r271560 : #i55701# merging the changes from the ancient (CVS-based) CWS evoab2default into this CWS here
2009-06-05 12:31:05 +00:00
|
|
|
#ifndef DBTOOLS_WARNINGSCONTAINER_HXX
|
|
|
|
#include <connectivity/warningscontainer.hxx>
|
2001-08-24 12:15:55 +00:00
|
|
|
#endif
|
2006-07-10 14:05:45 +00:00
|
|
|
#ifndef DBA_HELPERCOLLECTIONS_HXX
|
|
|
|
#include "HelperCollections.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _DBA_CORE_RESOURCE_HXX_
|
|
|
|
#include "core_resource.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _DBA_CORE_RESOURCE_HRC_
|
|
|
|
#include "core_resource.hrc"
|
|
|
|
#endif
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
|
|
|
|
#include <cppuhelper/queryinterface.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
2006-07-10 14:05:45 +00:00
|
|
|
#ifndef TOOLS_DIAGNOSE_EX_H
|
|
|
|
#include <tools/diagnose_ex.h>
|
|
|
|
#endif
|
2000-10-11 10:21:40 +00:00
|
|
|
#ifndef _COMPHELPER_PROPERTY_AGGREGATION_HXX_
|
|
|
|
#include <comphelper/propagg.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
#endif
|
2000-10-11 10:21:40 +00:00
|
|
|
#ifndef _COMPHELPER_SEQUENCE_HXX_
|
|
|
|
#include <comphelper/sequence.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
#endif
|
|
|
|
|
2006-07-10 14:05:45 +00:00
|
|
|
/** === begin UNO includes === **/
|
2000-09-18 23:16:46 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XConnection.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/lang/DisposedException.hpp>
|
|
|
|
#endif
|
2006-07-10 14:05:45 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
|
|
|
|
#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
|
|
|
|
#endif
|
|
|
|
/** === end UNO includes === **/
|
|
|
|
|
2001-01-04 13:26:47 +00:00
|
|
|
#ifndef _COMPHELPER_TYPES_HXX_
|
|
|
|
#include <comphelper/types.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _COMPHELPER_PROPERTY_HXX_
|
|
|
|
#include <comphelper/property.hxx>
|
|
|
|
#endif
|
2006-07-10 14:05:45 +00:00
|
|
|
#ifndef UNOTOOLS_INC_SHAREDUNOCOMPONENT_HXX
|
|
|
|
#include <unotools/sharedunocomponent.hxx>
|
|
|
|
#endif
|
2001-02-23 14:22:32 +00:00
|
|
|
#ifndef _DBACORE_DEFINITIONCOLUMN_HXX_
|
|
|
|
#include "definitioncolumn.hxx"
|
|
|
|
#endif
|
2001-08-30 07:07:36 +00:00
|
|
|
|
2001-08-15 12:05:15 +00:00
|
|
|
#include <functional>
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-08-30 07:07:36 +00:00
|
|
|
#ifndef DBACORE_SDBCORETOOLS_HXX
|
|
|
|
#include "sdbcoretools.hxx"
|
|
|
|
#endif
|
2001-11-23 10:28:26 +00:00
|
|
|
#ifndef DBACCESS_CORE_API_QUERYCOMPOSER_HXX
|
|
|
|
#include "querycomposer.hxx"
|
|
|
|
#endif
|
2004-08-02 14:03:01 +00:00
|
|
|
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
|
|
|
|
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef DBA_CONTAINERMEDIATOR_HXX
|
|
|
|
#include "ContainerMediator.hxx"
|
|
|
|
#endif
|
2001-08-30 07:07:36 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
using namespace dbaccess;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
2001-08-24 12:15:55 +00:00
|
|
|
using namespace ::com::sun::star::sdb;
|
2000-09-18 23:16:46 +00:00
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::util;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::container;
|
2000-10-11 10:21:40 +00:00
|
|
|
using namespace ::comphelper;
|
2000-09-18 23:16:46 +00:00
|
|
|
using namespace ::osl;
|
|
|
|
using namespace ::cppu;
|
2006-07-10 14:05:45 +00:00
|
|
|
using namespace ::utl;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2000-10-18 15:16:39 +00:00
|
|
|
//........................................................................
|
|
|
|
namespace dbaccess
|
|
|
|
{
|
|
|
|
//........................................................................
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
//==========================================================================
|
2001-08-30 07:07:36 +00:00
|
|
|
//= OQuery
|
2000-09-18 23:16:46 +00:00
|
|
|
//==========================================================================
|
2001-08-30 07:07:36 +00:00
|
|
|
DBG_NAME(OQuery)
|
2000-09-18 23:16:46 +00:00
|
|
|
//--------------------------------------------------------------------------
|
2004-08-02 14:03:01 +00:00
|
|
|
OQuery::OQuery( const Reference< XPropertySet >& _rxCommandDefinition
|
|
|
|
,const Reference< XConnection >& _rxConn
|
|
|
|
,const Reference< XMultiServiceFactory >& _xORB)
|
2006-06-20 01:39:43 +00:00
|
|
|
:OContentHelper(_xORB,NULL,TContentPtr(new OContentHelper_Impl))
|
|
|
|
,OQueryDescriptor_Base(m_aMutex,*this)
|
2008-12-01 12:31:27 +00:00
|
|
|
,ODataSettings(OContentHelper::rBHelper,sal_True)
|
2000-09-18 23:16:46 +00:00
|
|
|
,m_xCommandDefinition(_rxCommandDefinition)
|
|
|
|
,m_xConnection(_rxConn)
|
2006-10-18 12:26:59 +00:00
|
|
|
,m_pColumnMediator( NULL )
|
2006-06-20 01:39:43 +00:00
|
|
|
,m_pWarnings( NULL )
|
|
|
|
,m_bCaseSensitiv(sal_True)
|
|
|
|
,m_eDoingCurrently(NONE)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-08-30 07:07:36 +00:00
|
|
|
DBG_CTOR(OQuery, NULL);
|
2004-08-02 14:03:01 +00:00
|
|
|
registerProperties();
|
2006-06-20 01:39:43 +00:00
|
|
|
ODataSettings::registerPropertiesFor(this);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-08-02 14:03:01 +00:00
|
|
|
osl_incrementInterlockedCount(&m_refCount);
|
2001-08-30 07:07:36 +00:00
|
|
|
DBG_ASSERT(m_xCommandDefinition.is(), "OQuery::OQuery : invalid CommandDefinition object !");
|
2004-08-02 14:03:01 +00:00
|
|
|
if ( m_xCommandDefinition.is() )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-08-02 14:03:01 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
::comphelper::copyProperties(_rxCommandDefinition,this);
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(sal_False, "OQueryDescriptor_Base::OQueryDescriptor_Base: caught an exception!");
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
m_xCommandDefinition->addPropertyChangeListener(::rtl::OUString(), this);
|
2001-09-25 12:28:23 +00:00
|
|
|
// m_xCommandDefinition->addPropertyChangeListener(PROPERTY_NAME, this);
|
2001-03-02 09:24:52 +00:00
|
|
|
m_xCommandPropInfo = m_xCommandDefinition->getPropertySetInfo();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2001-08-30 07:07:36 +00:00
|
|
|
DBG_ASSERT(m_xConnection.is(), "OQuery::OQuery : invalid connection !");
|
2004-08-02 14:03:01 +00:00
|
|
|
osl_decrementInterlockedCount(&m_refCount);
|
2001-08-30 07:07:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
OQuery::~OQuery()
|
|
|
|
{
|
|
|
|
DBG_DTOR(OQuery, NULL);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2004-08-02 14:03:01 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
IMPLEMENT_IMPLEMENTATION_ID(OQuery);
|
|
|
|
IMPLEMENT_GETTYPES3(OQuery,OQueryDescriptor_Base,ODataSettings,OContentHelper);
|
|
|
|
IMPLEMENT_FORWARD_XINTERFACE3( OQuery,OContentHelper,OQueryDescriptor_Base,ODataSettings)
|
2000-09-18 23:16:46 +00:00
|
|
|
//--------------------------------------------------------------------------
|
2006-07-10 14:05:45 +00:00
|
|
|
void OQuery::rebuildColumns()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2006-07-10 14:05:45 +00:00
|
|
|
OSL_PRECOND( getColumnCount() == 0, "OQuery::rebuildColumns: column container should be empty!" );
|
|
|
|
// the base class' definition of rebuildColumns promised that clearColumns is called before rebuildColumns
|
|
|
|
|
2001-08-30 07:07:36 +00:00
|
|
|
try
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2006-10-18 12:26:59 +00:00
|
|
|
m_pColumnMediator = NULL;
|
2004-08-02 14:03:01 +00:00
|
|
|
|
|
|
|
Reference<XColumnsSupplier> xColSup(m_xCommandDefinition,UNO_QUERY);
|
|
|
|
if ( xColSup.is() )
|
|
|
|
{
|
|
|
|
Reference< XNameAccess > xColumnDefinitions = xColSup->getColumns();
|
|
|
|
if ( xColumnDefinitions.is() )
|
2006-10-18 12:26:59 +00:00
|
|
|
m_pColumnMediator = new OContainerMediator( m_pColumns, xColumnDefinitions, m_xConnection, OContainerMediator::eColumns );
|
2004-08-02 14:03:01 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-08-30 07:07:36 +00:00
|
|
|
// fill the columns with columns from the statement
|
2006-07-10 14:05:45 +00:00
|
|
|
Reference< XMultiServiceFactory > xFactory( m_xConnection, UNO_QUERY_THROW );
|
|
|
|
SharedUNOComponent< XSingleSelectQueryComposer, DisposableComponent > xComposer(
|
|
|
|
Reference< XSingleSelectQueryComposer >( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW ) );
|
|
|
|
|
|
|
|
Reference< XNameAccess > xColumns;
|
|
|
|
Reference< XIndexAccess > xColumnsIndexed;
|
|
|
|
try
|
2001-11-23 10:28:26 +00:00
|
|
|
{
|
2006-07-10 14:05:45 +00:00
|
|
|
xComposer->setQuery( m_sCommand );
|
|
|
|
Reference< XColumnsSupplier > xCols( xComposer, UNO_QUERY_THROW );
|
|
|
|
xColumns.set( xCols->getColumns(), UNO_QUERY_THROW );
|
|
|
|
xColumnsIndexed.set( xColumns, UNO_QUERY_THROW );
|
|
|
|
}
|
|
|
|
catch( const SQLException& ) { }
|
|
|
|
|
|
|
|
SharedUNOComponent< XPreparedStatement, DisposableComponent > xPreparedStatement;
|
|
|
|
if ( !xColumns.is() || ( xColumnsIndexed->getCount() == 0 ) )
|
|
|
|
{ // the QueryComposer could not parse it. Try a lean version.
|
|
|
|
xPreparedStatement.set( m_xConnection->prepareStatement( m_sCommand ), UNO_QUERY_THROW );
|
|
|
|
Reference< XResultSetMetaDataSupplier > xResMetaDataSup( xPreparedStatement, UNO_QUERY_THROW );
|
|
|
|
Reference< XResultSetMetaData > xResultSetMeta( xResMetaDataSup->getMetaData() );
|
|
|
|
if ( !xResultSetMeta.is() )
|
2001-11-23 10:28:26 +00:00
|
|
|
{
|
2006-07-10 14:05:45 +00:00
|
|
|
::rtl::OUString sError( DBA_RES( RID_STR_STATEMENT_WITHOUT_RESULT_SET ) );
|
|
|
|
::dbtools::throwSQLException( sError, SQL_GENERAL_ERROR, *this );
|
2001-11-23 10:28:26 +00:00
|
|
|
}
|
2006-07-10 14:05:45 +00:00
|
|
|
|
|
|
|
Reference< XDatabaseMetaData > xDBMeta( m_xConnection->getMetaData(), UNO_QUERY_THROW );
|
|
|
|
::vos::ORef< OSQLColumns > aParseColumns(
|
|
|
|
::connectivity::parse::OParseColumn::createColumnsForResultSet( xResultSetMeta, xDBMeta ) );
|
|
|
|
xColumns = OPrivateColumns::createWithIntrinsicNames(
|
|
|
|
aParseColumns, xDBMeta->storesMixedCaseQuotedIdentifiers(), *this, m_aMutex );
|
|
|
|
if ( !xColumns.is() )
|
|
|
|
throw RuntimeException();
|
2001-11-23 10:28:26 +00:00
|
|
|
}
|
|
|
|
|
2006-07-10 14:05:45 +00:00
|
|
|
Sequence< ::rtl::OUString> aNames = xColumns->getElementNames();
|
|
|
|
const ::rtl::OUString* pBegin = aNames.getConstArray();
|
|
|
|
const ::rtl::OUString* pEnd = pBegin + aNames.getLength();
|
|
|
|
for ( ;pBegin != pEnd; ++pBegin)
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xSource(xColumns->getByName( *pBegin ),UNO_QUERY);
|
2009-11-03 14:53:24 +01:00
|
|
|
OQueryColumn* pColumn = new OQueryColumn( xSource, m_xConnection );
|
2009-11-03 10:43:12 +01:00
|
|
|
Reference< XChild > xChild( *pColumn, UNO_QUERY_THROW );
|
|
|
|
xChild->setParent( *this );
|
2001-08-30 07:07:36 +00:00
|
|
|
|
2006-07-10 14:05:45 +00:00
|
|
|
implAppendColumn( *pBegin, pColumn );
|
2009-11-03 10:43:12 +01:00
|
|
|
Reference< XPropertySet > xDest( *pColumn, UNO_QUERY_THROW );
|
2006-10-18 12:26:59 +00:00
|
|
|
if ( m_pColumnMediator.is() )
|
|
|
|
m_pColumnMediator->notifyElementCreated( *pBegin, xDest );
|
2001-08-24 12:15:55 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2001-08-30 07:07:36 +00:00
|
|
|
catch( const SQLContext& e )
|
|
|
|
{
|
|
|
|
if ( m_pWarnings )
|
|
|
|
m_pWarnings->appendWarning( e );
|
|
|
|
}
|
|
|
|
catch( const SQLWarning& e )
|
|
|
|
{
|
|
|
|
if ( m_pWarnings )
|
|
|
|
m_pWarnings->appendWarning( e );
|
|
|
|
}
|
|
|
|
catch( const SQLException& e )
|
|
|
|
{
|
|
|
|
if ( m_pWarnings )
|
|
|
|
m_pWarnings->appendWarning( e );
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
2006-07-10 14:05:45 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2001-08-30 07:07:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
// XServiceInfo
|
|
|
|
//--------------------------------------------------------------------------
|
2001-08-30 07:07:36 +00:00
|
|
|
IMPLEMENT_SERVICE_INFO3(OQuery, "com.sun.star.sdb.dbaccess.OQuery", SERVICE_SDB_DATASETTINGS, SERVICE_SDB_QUERY, SERVICE_SDB_QUERYDEFINITION)
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
// ::com::sun::star::beans::XPropertyChangeListener
|
|
|
|
//--------------------------------------------------------------------------
|
2001-08-30 07:07:36 +00:00
|
|
|
void SAL_CALL OQuery::propertyChange( const PropertyChangeEvent& _rSource ) throw(RuntimeException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
sal_Int32 nOwnHandle = -1;
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
|
|
|
|
DBG_ASSERT(_rSource.Source.get() == Reference< XInterface >(m_xCommandDefinition, UNO_QUERY).get(),
|
2001-08-30 07:07:36 +00:00
|
|
|
"OQuery::propertyChange : where did this call come from ?");
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if (m_eDoingCurrently == SETTING_PROPERTIES)
|
|
|
|
// we're setting the property ourself, so we will do the neccessary notifications later
|
|
|
|
return;
|
|
|
|
|
|
|
|
// forward this to our own member holding a copy of the property value
|
|
|
|
if (getArrayHelper()->hasPropertyByName(_rSource.PropertyName))
|
|
|
|
{
|
|
|
|
Property aOwnProp = getArrayHelper()->getPropertyByName(_rSource.PropertyName);
|
|
|
|
nOwnHandle = aOwnProp.Handle;
|
2004-08-02 14:03:01 +00:00
|
|
|
ODataSettings::setFastPropertyValue_NoBroadcast(nOwnHandle, _rSource.NewValue);
|
2000-09-18 23:16:46 +00:00
|
|
|
// don't use our own setFastPropertyValue_NoBroadcast, this would forward it to the CommandSettings,
|
|
|
|
// again
|
|
|
|
// and don't use the "real" setPropertyValue, this is to expensive and not sure to succeed
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-30 07:07:36 +00:00
|
|
|
DBG_ERROR("OQuery::propertyChange : my CommandDefinition has more properties than I do !");
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fire(&nOwnHandle, &_rSource.NewValue, &_rSource.OldValue, 1, sal_False);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
2001-09-25 12:28:23 +00:00
|
|
|
void SAL_CALL OQuery::disposing( const EventObject& _rSource ) throw (RuntimeException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
|
2006-06-20 01:39:43 +00:00
|
|
|
(void)_rSource;
|
2000-09-18 23:16:46 +00:00
|
|
|
DBG_ASSERT(_rSource.Source.get() == Reference< XInterface >(m_xCommandDefinition, UNO_QUERY).get(),
|
2001-08-30 07:07:36 +00:00
|
|
|
"OQuery::disposing : where did this call come from ?");
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
m_xCommandDefinition->removePropertyChangeListener(::rtl::OUString(), this);
|
|
|
|
m_xCommandDefinition = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XDataDescriptorFactory
|
|
|
|
//--------------------------------------------------------------------------
|
2001-08-30 07:07:36 +00:00
|
|
|
Reference< XPropertySet > SAL_CALL OQuery::createDataDescriptor( ) throw(RuntimeException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return new OQueryDescriptor(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// pseudo-XComponent
|
|
|
|
//--------------------------------------------------------------------------
|
2004-08-02 14:03:01 +00:00
|
|
|
void SAL_CALL OQuery::disposing()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
if (m_xCommandDefinition.is())
|
|
|
|
{
|
|
|
|
m_xCommandDefinition->removePropertyChangeListener(::rtl::OUString(), this);
|
|
|
|
m_xCommandDefinition = NULL;
|
|
|
|
}
|
2004-08-02 14:03:01 +00:00
|
|
|
disposeColumns();
|
2001-08-24 12:15:55 +00:00
|
|
|
|
|
|
|
m_pWarnings = NULL;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
2001-08-30 07:07:36 +00:00
|
|
|
void OQuery::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw (Exception)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-08-02 14:03:01 +00:00
|
|
|
ODataSettings::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
|
2000-09-18 23:16:46 +00:00
|
|
|
::rtl::OUString sAggPropName;
|
2001-01-04 13:26:47 +00:00
|
|
|
sal_Int16 nAttr = 0;
|
2001-03-02 09:24:52 +00:00
|
|
|
if (getInfoHelper().fillPropertyMembersByHandle(&sAggPropName,&nAttr,_nHandle) &&
|
|
|
|
m_xCommandPropInfo.is() &&
|
|
|
|
m_xCommandPropInfo->hasPropertyByName(sAggPropName))
|
2000-09-18 23:16:46 +00:00
|
|
|
{ // the base class holds the property values itself, but we have to forward this to our CommandDefinition
|
2001-03-02 09:24:52 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
m_eDoingCurrently = SETTING_PROPERTIES;
|
|
|
|
OAutoActionReset(this);
|
|
|
|
m_xCommandDefinition->setPropertyValue(sAggPropName, _rValue);
|
2001-08-16 09:32:56 +00:00
|
|
|
|
|
|
|
if ( PROPERTY_ID_COMMAND == _nHandle )
|
|
|
|
// the columns are out of date if we are based on a new statement ....
|
|
|
|
// 90573 - 16.08.2001 - frank.schoenheit@sun.com
|
2001-08-30 07:07:36 +00:00
|
|
|
setColumnsOutOfDate();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
2001-08-30 07:07:36 +00:00
|
|
|
Reference< XPropertySetInfo > SAL_CALL OQuery::getPropertySetInfo( ) throw(RuntimeException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return createPropertySetInfo( getInfoHelper() ) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2001-08-30 07:07:36 +00:00
|
|
|
::cppu::IPropertyArrayHelper& OQuery::getInfoHelper()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return *getArrayHelper();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
::cppu::IPropertyArrayHelper* OQuery::createArrayHelper( ) const
|
|
|
|
{
|
|
|
|
Sequence< Property > aProps;
|
|
|
|
// our own props
|
|
|
|
describeProperties(aProps);
|
|
|
|
return new ::cppu::OPropertyArrayHelper(aProps);
|
|
|
|
}
|
2001-02-23 14:22:32 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2006-06-20 01:39:43 +00:00
|
|
|
OColumn* OQuery::createColumn(const ::rtl::OUString& /*_rName*/) const
|
2001-02-23 14:22:32 +00:00
|
|
|
{
|
2001-08-30 07:07:36 +00:00
|
|
|
return NULL;
|
2001-02-23 14:22:32 +00:00
|
|
|
}
|
2001-09-25 12:28:23 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OQuery::rename( const ::rtl::OUString& newName ) throw (SQLException, ElementExistException, RuntimeException)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
Reference<XRename> xRename(m_xCommandDefinition,UNO_QUERY);
|
|
|
|
OSL_ENSURE(xRename.is(),"No XRename interface!");
|
|
|
|
if(xRename.is())
|
|
|
|
xRename->rename(newName);
|
|
|
|
}
|
2004-08-02 14:03:01 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OQuery::registerProperties()
|
|
|
|
{
|
|
|
|
// the properties which OCommandBase supplies (it has no own registration, as it's not derived from
|
|
|
|
// a OPropertyStateContainer)
|
|
|
|
registerProperty(PROPERTY_NAME, PROPERTY_ID_NAME, PropertyAttribute::BOUND|PropertyAttribute::CONSTRAINED,
|
|
|
|
&m_sElementName, ::getCppuType(&m_sElementName));
|
|
|
|
|
|
|
|
registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND,
|
|
|
|
&m_sCommand, ::getCppuType(&m_sCommand));
|
|
|
|
|
2007-11-21 14:33:52 +00:00
|
|
|
registerProperty(PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::BOUND,
|
2004-08-02 14:03:01 +00:00
|
|
|
&m_bEscapeProcessing, ::getBooleanCppuType());
|
|
|
|
|
|
|
|
registerProperty(PROPERTY_UPDATE_TABLENAME, PROPERTY_ID_UPDATE_TABLENAME, PropertyAttribute::BOUND,
|
|
|
|
&m_sUpdateTableName, ::getCppuType(&m_sUpdateTableName));
|
|
|
|
|
|
|
|
registerProperty(PROPERTY_UPDATE_SCHEMANAME, PROPERTY_ID_UPDATE_SCHEMANAME, PropertyAttribute::BOUND,
|
|
|
|
&m_sUpdateSchemaName, ::getCppuType(&m_sUpdateSchemaName));
|
|
|
|
|
|
|
|
registerProperty(PROPERTY_UPDATE_CATALOGNAME, PROPERTY_ID_UPDATE_CATALOGNAME, PropertyAttribute::BOUND,
|
|
|
|
&m_sUpdateCatalogName, ::getCppuType(&m_sUpdateCatalogName));
|
|
|
|
|
|
|
|
registerProperty(PROPERTY_LAYOUTINFORMATION, PROPERTY_ID_LAYOUTINFORMATION, PropertyAttribute::BOUND,
|
|
|
|
&m_aLayoutInformation, ::getCppuType(&m_aLayoutInformation));
|
|
|
|
}
|
2001-08-30 07:07:36 +00:00
|
|
|
|
2008-12-09 07:25:38 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
::rtl::OUString OQuery::determineContentType() const
|
|
|
|
{
|
|
|
|
return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.org.openoffice.DatabaseQuery" ) );
|
|
|
|
}
|
|
|
|
|
2001-07-16 06:38:40 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2000-10-18 15:16:39 +00:00
|
|
|
//........................................................................
|
|
|
|
} // namespace dbaccess
|
|
|
|
//........................................................................
|
2000-09-18 23:16:46 +00:00
|
|
|
|