2010-10-12 15:59:03 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-14 17:39:53 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2006-09-17 05:35:02 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
#include "query.hxx"
|
2000-10-25 06:32:52 +00:00
|
|
|
#include "dbastrings.hrc"
|
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
|
|
|
#include <connectivity/warningscontainer.hxx>
|
2006-07-10 14:05:45 +00:00
|
|
|
#include "HelperCollections.hxx"
|
|
|
|
#include "core_resource.hxx"
|
|
|
|
#include "core_resource.hrc"
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
#include <cppuhelper/queryinterface.hxx>
|
|
|
|
#include <tools/debug.hxx>
|
2006-07-10 14:05:45 +00:00
|
|
|
#include <tools/diagnose_ex.h>
|
2011-02-03 00:33:36 +01:00
|
|
|
#include <osl/diagnose.h>
|
2000-10-11 10:21:40 +00:00
|
|
|
#include <comphelper/propagg.hxx>
|
|
|
|
#include <comphelper/sequence.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/sdbc/XConnection.hpp>
|
|
|
|
#include <com/sun/star/lang/DisposedException.hpp>
|
2006-07-10 14:05:45 +00:00
|
|
|
#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
|
|
|
|
|
2001-01-04 13:26:47 +00:00
|
|
|
#include <comphelper/types.hxx>
|
|
|
|
#include <comphelper/property.hxx>
|
2006-07-10 14:05:45 +00:00
|
|
|
#include <unotools/sharedunocomponent.hxx>
|
2001-02-23 14:22:32 +00:00
|
|
|
#include "definitioncolumn.hxx"
|
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
|
|
|
#include "sdbcoretools.hxx"
|
2001-11-23 10:28:26 +00:00
|
|
|
#include "querycomposer.hxx"
|
2004-08-02 14:03:01 +00:00
|
|
|
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
|
|
|
#include "ContainerMediator.hxx"
|
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)
|
2010-10-12 22:40:56 +02: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
|
|
|
|
2012-09-22 01:51:12 -05:00
|
|
|
osl_atomic_increment(&m_refCount);
|
2011-02-03 00:33:36 +01:00
|
|
|
OSL_ENSURE(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&)
|
|
|
|
{
|
2011-03-19 14:05:01 +01:00
|
|
|
OSL_FAIL("OQueryDescriptor_Base::OQueryDescriptor_Base: caught an exception!");
|
2004-08-02 14:03:01 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2011-02-03 00:33:36 +01:00
|
|
|
OSL_ENSURE(m_xConnection.is(), "OQuery::OQuery : invalid connection !");
|
2012-09-22 01:51:12 -05:00
|
|
|
osl_atomic_decrement(&m_refCount);
|
2001-08-30 07:07:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OQuery::~OQuery()
|
|
|
|
{
|
|
|
|
DBG_DTOR(OQuery, NULL);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2010-10-12 22:40:56 +02: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)
|
2010-10-12 22:40:56 +02: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);
|
2009-12-21 14:42:31 +01:00
|
|
|
Reference< XNameAccess > xColumnDefinitions;
|
2004-08-02 14:03:01 +00:00
|
|
|
if ( xColSup.is() )
|
|
|
|
{
|
2009-12-21 14:42:31 +01:00
|
|
|
xColumnDefinitions = xColSup->getColumns();
|
2004-08-02 14:03:01 +00:00
|
|
|
if ( xColumnDefinitions.is() )
|
2012-08-30 23:25:58 +02:00
|
|
|
m_pColumnMediator = new OContainerMediator( m_pColumns, xColumnDefinitions, m_xConnection );
|
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 );
|
2010-10-15 12:22:54 -05:00
|
|
|
::rtl::Reference< OSQLColumns > aParseColumns(
|
2010-01-22 10:31:43 +01:00
|
|
|
::connectivity::parse::OParseColumn::createColumnsForResultSet( xResultSetMeta, xDBMeta,xColumnDefinitions ) );
|
2006-07-10 14:05:45 +00:00
|
|
|
xColumns = OPrivateColumns::createWithIntrinsicNames(
|
2010-11-25 11:23:27 +01:00
|
|
|
aParseColumns, xDBMeta->supportsMixedCaseQuotedIdentifiers(), *this, m_aMutex );
|
2006-07-10 14:05:45 +00:00
|
|
|
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();
|
2009-12-21 14:42:31 +01:00
|
|
|
const ::rtl::OUString* pIter = aNames.getConstArray();
|
2010-01-22 08:14:22 +01:00
|
|
|
const ::rtl::OUString* pEnd = pIter + aNames.getLength();
|
2009-12-21 14:42:31 +01:00
|
|
|
for ( sal_Int32 i = 0;pIter != pEnd; ++pIter,++i)
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xSource(xColumns->getByName( *pIter ),UNO_QUERY);
|
2010-01-22 08:14:22 +01:00
|
|
|
::rtl::OUString sLabel = *pIter;
|
|
|
|
if ( xColumnDefinitions.is() && xColumnDefinitions->hasByName(*pIter) )
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xCommandColumn(xColumnDefinitions->getByName( *pIter ),UNO_QUERY);
|
|
|
|
xCommandColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
|
|
|
|
}
|
|
|
|
OQueryColumn* pColumn = new OQueryColumn( xSource, m_xConnection, sLabel);
|
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
|
|
|
|
2010-01-22 08:14:22 +01:00
|
|
|
implAppendColumn( *pIter, 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() )
|
2010-01-22 08:14:22 +01:00
|
|
|
m_pColumnMediator->notifyElementCreated( *pIter, 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
|
2012-05-17 14:00:15 +01:00
|
|
|
IMPLEMENT_SERVICE_INFO3(OQuery, "com.sun.star.sdb.dbaccess.OQuery", SERVICE_SDB_DATASETTINGS.ascii, SERVICE_SDB_QUERY.ascii, SERVICE_SDB_QUERYDEFINITION.ascii)
|
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);
|
|
|
|
|
2011-02-03 00:33:36 +01:00
|
|
|
OSL_ENSURE(_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
|
|
|
|
{
|
2011-02-25 17:47:41 +01:00
|
|
|
OSL_FAIL("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;
|
2011-02-03 00:33:36 +01:00
|
|
|
OSL_ENSURE(_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;
|
2011-01-17 12:33:02 +00:00
|
|
|
OAutoActionReset aAutoReset(this);
|
2000-09-18 23:16:46 +00:00
|
|
|
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 ....
|
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);
|
|
|
|
}
|
2010-10-12 22:40:56 +02: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
|
|
|
}
|
2010-10-12 22:40:56 +02: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);
|
|
|
|
}
|
2010-10-12 22:40:56 +02:00
|
|
|
|
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" ) );
|
|
|
|
}
|
|
|
|
|
2000-10-18 15:16:39 +00:00
|
|
|
} // namespace dbaccess
|
2010-10-12 15:59:03 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|