2000-09-18 18:16:46 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 06:33:54 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 18:16:46 -05:00
|
|
|
*
|
2008-04-10 06:33:54 -05:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 18:16:46 -05:00
|
|
|
*
|
2008-04-10 06:33:54 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 18:16:46 -05:00
|
|
|
*
|
2008-04-10 06:33:54 -05:00
|
|
|
* $RCSfile: querycontainer.cxx,v $
|
|
|
|
* $Revision: 1.27 $
|
2000-09-18 18:16:46 -05:00
|
|
|
*
|
2008-04-10 06:33:54 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 18:16:46 -05:00
|
|
|
*
|
2008-04-10 06:33:54 -05: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 18:16:46 -05:00
|
|
|
*
|
2008-04-10 06:33:54 -05: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 18:16:46 -05:00
|
|
|
*
|
2008-04-10 06:33:54 -05: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 18:16:46 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 00:35:30 -05:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_dbaccess.hxx"
|
|
|
|
|
2000-09-18 18:16:46 -05:00
|
|
|
#ifndef _DBA_CORE_QUERYCONTAINER_HXX_
|
|
|
|
#include "querycontainer.hxx"
|
|
|
|
#endif
|
2000-10-25 01:32:52 -05:00
|
|
|
#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
|
|
|
|
#include "dbastrings.hrc"
|
2000-09-18 18:16:46 -05:00
|
|
|
#endif
|
|
|
|
#ifndef _DBA_COREAPI_QUERY_HXX_
|
|
|
|
#include "query.hxx"
|
|
|
|
#endif
|
2006-07-10 09:06:28 -05:00
|
|
|
#ifndef DBACCESS_OBJECTNAMEAPPROVAL_HXX
|
|
|
|
#include "objectnameapproval.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBA_CONTAINERLISTENER_HXX
|
|
|
|
#include "ContainerListener.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBACCESS_VETO_HXX
|
|
|
|
#include "veto.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** === begin UNO includes === **/
|
|
|
|
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
|
|
|
|
#include <com/sun/star/container/XContainer.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XConnection.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERAPPROVEBROADCASTER_HPP_
|
|
|
|
#include <com/sun/star/container/XContainerApproveBroadcaster.hpp>
|
|
|
|
#endif
|
|
|
|
/** === end UNO includes === **/
|
|
|
|
|
|
|
|
#ifndef _DBHELPER_DBEXCEPTION_HXX_
|
|
|
|
#include <connectivity/dbexception.hxx>
|
|
|
|
#endif
|
2000-09-18 18:16:46 -05:00
|
|
|
|
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
2000-10-11 05:21:40 -05:00
|
|
|
#ifndef _COMPHELPER_ENUMHELPER_HXX_
|
|
|
|
#include <comphelper/enumhelper.hxx>
|
2000-09-18 18:16:46 -05:00
|
|
|
#endif
|
2000-10-11 05:21:40 -05:00
|
|
|
#ifndef _COMPHELPER_UNO3_HXX_
|
|
|
|
#include <comphelper/uno3.hxx>
|
2000-09-18 18:16:46 -05:00
|
|
|
#endif
|
2000-10-11 05:21:40 -05:00
|
|
|
#ifndef _COMPHELPER_PROPERTY_HXX_
|
|
|
|
#include <comphelper/property.hxx>
|
2000-09-18 18:16:46 -05:00
|
|
|
#endif
|
2000-10-11 05:21:40 -05:00
|
|
|
#ifndef _COMPHELPER_SEQUENCE_HXX_
|
|
|
|
#include <comphelper/sequence.hxx>
|
2000-09-18 18:16:46 -05:00
|
|
|
#endif
|
2001-03-15 01:29:16 -06:00
|
|
|
#ifndef _COMPHELPER_EXTRACT_HXX_
|
|
|
|
#include <comphelper/extract.hxx>
|
2000-09-18 18:16:46 -05:00
|
|
|
#endif
|
2006-07-10 09:06:28 -05:00
|
|
|
#ifndef _CPPUHELPER_EXC_HLP_HXX_
|
|
|
|
#include <cppuhelper/exc_hlp.hxx>
|
2000-10-25 01:32:52 -05:00
|
|
|
#endif
|
2000-09-18 18:16:46 -05:00
|
|
|
|
2000-10-25 01:32:52 -05:00
|
|
|
using namespace dbtools;
|
2000-09-18 18:16:46 -05:00
|
|
|
using namespace ::com::sun::star::uno;
|
2004-08-02 09:03:38 -05:00
|
|
|
using namespace ::com::sun::star::ucb;
|
2000-09-18 18:16:46 -05:00
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::beans;
|
2006-07-10 09:06:28 -05:00
|
|
|
using namespace ::com::sun::star::sdb;
|
2000-09-18 18:16:46 -05:00
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::container;
|
2006-07-10 09:06:28 -05:00
|
|
|
using namespace ::com::sun::star::util;
|
2000-09-18 18:16:46 -05:00
|
|
|
using namespace ::osl;
|
2000-10-11 05:21:40 -05:00
|
|
|
using namespace ::comphelper;
|
2000-09-18 18:16:46 -05:00
|
|
|
using namespace ::cppu;
|
|
|
|
|
2000-10-18 10:16:39 -05:00
|
|
|
//........................................................................
|
|
|
|
namespace dbaccess
|
|
|
|
{
|
|
|
|
//........................................................................
|
|
|
|
|
2000-09-18 18:16:46 -05:00
|
|
|
//==========================================================================
|
|
|
|
//= OQueryContainer
|
|
|
|
//==========================================================================
|
|
|
|
DBG_NAME(OQueryContainer)
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
OQueryContainer::OQueryContainer(
|
2004-08-02 09:03:38 -05:00
|
|
|
const Reference< XNameContainer >& _rxCommandDefinitions
|
|
|
|
, const Reference< XConnection >& _rxConn
|
|
|
|
, const Reference< XMultiServiceFactory >& _rxORB,
|
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 07:31:05 -05:00
|
|
|
::dbtools::IWarningsContainer* _pWarnings)
|
2004-08-02 09:03:38 -05:00
|
|
|
:ODefinitionContainer(_rxORB,NULL,TContentPtr(new ODefinitionContainer_Impl))
|
2001-08-24 07:16:22 -05:00
|
|
|
,m_pWarnings( _pWarnings )
|
2000-09-18 18:16:46 -05:00
|
|
|
,m_xCommandDefinitions(_rxCommandDefinitions)
|
2004-08-02 09:03:38 -05:00
|
|
|
,m_xConnection(_rxConn)
|
2000-09-18 18:16:46 -05:00
|
|
|
{
|
|
|
|
DBG_CTOR(OQueryContainer, NULL);
|
|
|
|
|
2004-08-02 09:03:38 -05:00
|
|
|
increment(m_refCount);
|
2006-07-10 09:06:28 -05:00
|
|
|
{
|
|
|
|
m_pCommandsListener = new OContainerListener( *this, m_aMutex );
|
|
|
|
m_pCommandsListener->acquire();
|
2000-11-03 07:32:31 -06:00
|
|
|
|
2006-07-10 09:06:28 -05:00
|
|
|
Reference< XContainer > xContainer( m_xCommandDefinitions, UNO_QUERY_THROW );
|
|
|
|
xContainer->addContainerListener( m_pCommandsListener );
|
2000-11-03 07:32:31 -06:00
|
|
|
|
2006-07-10 09:06:28 -05:00
|
|
|
Reference< XContainerApproveBroadcaster > xContainerApprove( m_xCommandDefinitions, UNO_QUERY_THROW );
|
|
|
|
xContainerApprove->addContainerApproveListener( m_pCommandsListener );
|
2000-09-18 18:16:46 -05:00
|
|
|
|
2004-09-09 03:38:15 -05:00
|
|
|
// fill my structures
|
2006-07-10 09:06:28 -05:00
|
|
|
ODefinitionContainer_Impl& rDefinitions( getDefinitions() );
|
2004-09-09 03:38:15 -05:00
|
|
|
Sequence< ::rtl::OUString > sDefinitionNames = m_xCommandDefinitions->getElementNames();
|
2006-07-10 09:06:28 -05:00
|
|
|
const ::rtl::OUString* pDefinitionName = sDefinitionNames.getConstArray();
|
|
|
|
const ::rtl::OUString* pEnd = pDefinitionName + sDefinitionNames.getLength();
|
|
|
|
for ( ; pDefinitionName != pEnd; ++pDefinitionName )
|
2004-09-09 03:38:15 -05:00
|
|
|
{
|
2006-07-10 09:06:28 -05:00
|
|
|
rDefinitions.insert( *pDefinitionName, TContentPtr() );
|
|
|
|
m_aDocuments.push_back(m_aDocumentMap.insert(Documents::value_type(*pDefinitionName,Documents::mapped_type())).first);
|
2004-09-09 03:38:15 -05:00
|
|
|
}
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
|
|
|
decrement(m_refCount);
|
2006-07-10 09:06:28 -05:00
|
|
|
|
|
|
|
setElementApproval( PContainerApprove( new ObjectNameApproval( _rxConn, ObjectNameApproval::TypeQuery ) ) );
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
OQueryContainer::~OQueryContainer()
|
|
|
|
{
|
|
|
|
DBG_DTOR(OQueryContainer, NULL);
|
2000-11-03 07:32:31 -06:00
|
|
|
// dispose();
|
|
|
|
// maybe we're already disposed, but this should be uncritical
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
2004-08-02 09:03:38 -05:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
IMPLEMENT_FORWARD_XINTERFACE2( OQueryContainer,ODefinitionContainer,OQueryContainer_Base)
|
2009-11-03 03:43:12 -06:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
IMPLEMENT_FORWARD_XTYPEPROVIDER2( OQueryContainer,ODefinitionContainer,OQueryContainer_Base)
|
|
|
|
|
2000-09-18 18:16:46 -05:00
|
|
|
//------------------------------------------------------------------------------
|
2004-08-02 09:03:38 -05:00
|
|
|
void OQueryContainer::disposing()
|
2000-09-18 18:16:46 -05:00
|
|
|
{
|
2004-08-02 09:03:38 -05:00
|
|
|
ODefinitionContainer::disposing();
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
2006-07-10 09:06:28 -05:00
|
|
|
if ( !m_xCommandDefinitions.is() )
|
|
|
|
// already disposed
|
|
|
|
return;
|
2000-09-18 18:16:46 -05:00
|
|
|
|
2006-07-10 09:06:28 -05:00
|
|
|
if ( m_pCommandsListener )
|
|
|
|
{
|
|
|
|
Reference< XContainer > xContainer( m_xCommandDefinitions, UNO_QUERY );
|
|
|
|
xContainer->removeContainerListener( m_pCommandsListener );
|
|
|
|
Reference< XContainerApproveBroadcaster > xContainerApprove( m_xCommandDefinitions, UNO_QUERY );
|
|
|
|
xContainerApprove->removeContainerApproveListener( m_pCommandsListener );
|
|
|
|
|
|
|
|
m_pCommandsListener->dispose();
|
2000-11-14 06:28:20 -06:00
|
|
|
m_pCommandsListener->release();
|
2006-07-10 09:06:28 -05:00
|
|
|
m_pCommandsListener = NULL;
|
|
|
|
}
|
|
|
|
|
2000-11-14 06:28:20 -06:00
|
|
|
m_xCommandDefinitions = NULL;
|
2004-08-02 09:03:38 -05:00
|
|
|
m_xConnection = NULL;
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// XServiceInfo
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
IMPLEMENT_SERVICE_INFO2(OQueryContainer, "com.sun.star.sdb.dbaccess.OQueryContainer", SERVICE_SDBCX_CONTAINER, SERVICE_SDB_QUERIES)
|
|
|
|
|
|
|
|
// XDataDescriptorFactory
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
Reference< XPropertySet > SAL_CALL OQueryContainer::createDataDescriptor( ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
return new OQueryDescriptor();
|
|
|
|
}
|
|
|
|
|
|
|
|
// XAppend
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OQueryContainer::appendByDescriptor( const Reference< XPropertySet >& _rxDesc ) throw(SQLException, ElementExistException, RuntimeException)
|
|
|
|
{
|
2006-07-10 09:06:28 -05:00
|
|
|
ResettableMutexGuard aGuard(m_aMutex);
|
|
|
|
if ( !m_xCommandDefinitions.is() )
|
|
|
|
throw DisposedException( ::rtl::OUString(), *this );
|
2000-09-18 18:16:46 -05:00
|
|
|
|
2006-07-10 09:06:28 -05:00
|
|
|
// first clone this object's CommandDefinition part
|
2007-11-21 08:34:08 -06:00
|
|
|
Reference< XPropertySet > xCommandDefinitionPart( m_aContext.createComponent( (::rtl::OUString)SERVICE_SDB_QUERYDEFINITION ), UNO_QUERY_THROW );
|
2006-07-10 09:06:28 -05:00
|
|
|
::comphelper::copyProperties( _rxDesc, xCommandDefinitionPart );
|
|
|
|
// TODO : the columns part of the descriptor has to be copied
|
2000-09-18 18:16:46 -05:00
|
|
|
|
2006-07-10 09:06:28 -05:00
|
|
|
// create a wrapper for the object (*before* inserting into our command definition container)
|
|
|
|
Reference< XContent > xNewObject( implCreateWrapper( Reference< XContent>( xCommandDefinitionPart, UNO_QUERY_THROW ) ) );
|
2000-09-18 18:16:46 -05:00
|
|
|
|
2006-07-10 09:06:28 -05:00
|
|
|
::rtl::OUString sNewObjectName;
|
|
|
|
_rxDesc->getPropertyValue(PROPERTY_NAME) >>= sNewObjectName;
|
|
|
|
|
|
|
|
try
|
2006-05-04 02:36:19 -05:00
|
|
|
{
|
2006-07-10 09:06:28 -05:00
|
|
|
notifyByName( aGuard, sNewObjectName, xNewObject, NULL, E_INSERTED, ApproveListeners );
|
2006-05-04 02:36:19 -05:00
|
|
|
}
|
2006-07-10 09:06:28 -05:00
|
|
|
catch( const Exception& )
|
2006-05-04 02:36:19 -05:00
|
|
|
{
|
2006-07-10 09:06:28 -05:00
|
|
|
disposeComponent( xNewObject );
|
|
|
|
disposeComponent( xCommandDefinitionPart );
|
|
|
|
throw;
|
2006-05-04 02:36:19 -05:00
|
|
|
}
|
|
|
|
|
2006-07-10 09:06:28 -05:00
|
|
|
// insert the basic object into the definition container
|
2006-05-04 02:36:19 -05:00
|
|
|
{
|
|
|
|
m_eDoingCurrently = INSERTING;
|
|
|
|
OAutoActionReset aAutoReset(this);
|
|
|
|
m_xCommandDefinitions->insertByName(sNewObjectName, makeAny(xCommandDefinitionPart));
|
|
|
|
}
|
2000-09-18 18:16:46 -05:00
|
|
|
|
2006-07-10 09:06:28 -05:00
|
|
|
implAppend( sNewObjectName, xNewObject );
|
|
|
|
notifyByName( aGuard, sNewObjectName, xNewObject, NULL, E_INSERTED, ContainerListemers );
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// XDrop
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OQueryContainer::dropByName( const ::rtl::OUString& _rName ) throw(SQLException, NoSuchElementException, RuntimeException)
|
|
|
|
{
|
2004-08-02 09:03:38 -05:00
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
if ( !checkExistence(_rName) )
|
|
|
|
throw NoSuchElementException(_rName,*this);
|
2000-09-18 18:16:46 -05:00
|
|
|
|
2004-08-02 09:03:38 -05:00
|
|
|
if ( !m_xCommandDefinitions.is() )
|
2006-07-10 09:06:28 -05:00
|
|
|
throw DisposedException( ::rtl::OUString(), *this );
|
2000-09-18 18:16:46 -05:00
|
|
|
|
|
|
|
// now simply forward the remove request to the CommandDefinition container, we're a listener for the removal
|
|
|
|
// and thus we do everything neccessary in ::elementRemoved
|
2004-08-02 09:03:38 -05:00
|
|
|
m_xCommandDefinitions->removeByName(_rName);
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2004-08-02 09:03:38 -05:00
|
|
|
void SAL_CALL OQueryContainer::dropByIndex( sal_Int32 _nIndex ) throw(SQLException, IndexOutOfBoundsException, RuntimeException)
|
2000-09-18 18:16:46 -05:00
|
|
|
{
|
2004-08-02 09:03:38 -05:00
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
if ((_nIndex<0) || (_nIndex>getCount()))
|
2000-09-18 18:16:46 -05:00
|
|
|
throw IndexOutOfBoundsException();
|
|
|
|
|
2006-07-10 09:06:28 -05:00
|
|
|
if ( !m_xCommandDefinitions.is() )
|
|
|
|
throw DisposedException( ::rtl::OUString(), *this );
|
|
|
|
|
2004-08-02 09:03:38 -05:00
|
|
|
::rtl::OUString sName;
|
|
|
|
Reference<XPropertySet> xProp(Reference<XIndexAccess>(m_xCommandDefinitions,UNO_QUERY)->getByIndex(_nIndex),UNO_QUERY);
|
|
|
|
if ( xProp.is() )
|
|
|
|
xProp->getPropertyValue(PROPERTY_NAME) >>= sName;
|
2000-09-18 18:16:46 -05:00
|
|
|
|
2004-08-02 09:03:38 -05:00
|
|
|
dropByName(sName);
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OQueryContainer::elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2004-08-02 09:03:38 -05:00
|
|
|
Reference< XContent > xNewElement;
|
|
|
|
::rtl::OUString sElementName;
|
|
|
|
_rEvent.Accessor >>= sElementName;
|
2000-09-18 18:16:46 -05:00
|
|
|
{
|
2004-08-02 09:03:38 -05:00
|
|
|
MutexGuard aGuard(m_aMutex);
|
2000-09-18 18:16:46 -05:00
|
|
|
if (INSERTING == m_eDoingCurrently)
|
|
|
|
// nothing to do, we're inserting via an "appendByDescriptor"
|
|
|
|
return;
|
|
|
|
|
|
|
|
DBG_ASSERT(sElementName.getLength(), "OQueryContainer::elementInserted : invalid name !");
|
2004-10-22 02:57:07 -05:00
|
|
|
DBG_ASSERT(m_aDocumentMap.find(sElementName) == m_aDocumentMap.end(), "OQueryContainer::elementInserted : oops .... we're inconsistent with our master container !");
|
2000-09-18 18:16:46 -05:00
|
|
|
if (!sElementName.getLength() || hasByName(sElementName))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// insert an own new element
|
2004-08-02 09:03:38 -05:00
|
|
|
xNewElement = implCreateWrapper(sElementName);
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
2004-08-02 09:03:38 -05:00
|
|
|
insertByName(sElementName,makeAny(xNewElement));
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OQueryContainer::elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
::rtl::OUString sAccessor;
|
2004-08-02 09:03:38 -05:00
|
|
|
_rEvent.Accessor >>= sAccessor;
|
2000-09-18 18:16:46 -05:00
|
|
|
{
|
|
|
|
DBG_ASSERT(sAccessor.getLength(), "OQueryContainer::elementRemoved : invalid name !");
|
2004-10-22 02:57:07 -05:00
|
|
|
DBG_ASSERT(m_aDocumentMap.find(sAccessor) != m_aDocumentMap.end(), "OQueryContainer::elementRemoved : oops .... we're inconsistent with our master container !");
|
2004-08-02 09:03:38 -05:00
|
|
|
if ( !sAccessor.getLength() || !hasByName(sAccessor) )
|
2000-09-18 18:16:46 -05:00
|
|
|
return;
|
|
|
|
}
|
2004-08-02 09:03:38 -05:00
|
|
|
removeByName(sAccessor);
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OQueryContainer::elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
Reference< XPropertySet > xReplacedElement;
|
2004-08-02 09:03:38 -05:00
|
|
|
Reference< XContent > xNewElement;
|
2000-09-18 18:16:46 -05:00
|
|
|
::rtl::OUString sAccessor;
|
2004-08-02 09:03:38 -05:00
|
|
|
_rEvent.Accessor >>= sAccessor;
|
2000-09-18 18:16:46 -05:00
|
|
|
|
2004-08-02 09:03:38 -05:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
2000-09-18 18:16:46 -05:00
|
|
|
DBG_ASSERT(sAccessor.getLength(), "OQueryContainer::elementReplaced : invalid name !");
|
2004-10-22 02:57:07 -05:00
|
|
|
DBG_ASSERT(m_aDocumentMap.find(sAccessor) != m_aDocumentMap.end(), "OQueryContainer::elementReplaced : oops .... we're inconsistent with our master container !");
|
2000-09-18 18:16:46 -05:00
|
|
|
if (!sAccessor.getLength() || !hasByName(sAccessor))
|
|
|
|
return;
|
|
|
|
|
2004-08-02 09:03:38 -05:00
|
|
|
xNewElement = implCreateWrapper(sAccessor);
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
|
|
|
|
2004-08-02 09:03:38 -05:00
|
|
|
replaceByName(sAccessor,makeAny(xNewElement));
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
|
|
|
|
2006-07-10 09:06:28 -05:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Reference< XVeto > SAL_CALL OQueryContainer::approveInsertElement( const ContainerEvent& Event ) throw (WrappedTargetException, RuntimeException)
|
|
|
|
{
|
|
|
|
::rtl::OUString sName;
|
|
|
|
OSL_VERIFY( Event.Accessor >>= sName );
|
|
|
|
Reference< XContent > xElement( Event.Element, UNO_QUERY_THROW );
|
|
|
|
|
|
|
|
Reference< XVeto > xReturn;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
getElementApproval()->approveElement( sName, xElement.get() );
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
xReturn = new Veto( ::rtl::OUString(), ::cppu::getCaughtException() );
|
|
|
|
}
|
|
|
|
return xReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Reference< XVeto > SAL_CALL OQueryContainer::approveReplaceElement( const ContainerEvent& /*Event*/ ) throw (WrappedTargetException, RuntimeException)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Reference< XVeto > SAL_CALL OQueryContainer::approveRemoveElement( const ContainerEvent& /*Event*/ ) throw (WrappedTargetException, RuntimeException)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2000-09-18 18:16:46 -05:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OQueryContainer::disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
if (_rSource.Source.get() == Reference< XInterface >(m_xCommandDefinitions, UNO_QUERY).get())
|
|
|
|
{ // our "master container" (with the command definitions) is beeing disposed
|
|
|
|
DBG_ERROR("OQueryContainer::disposing : nobody should dispose the CommandDefinition container before disposing my connection !");
|
|
|
|
dispose();
|
|
|
|
}
|
2001-01-04 07:27:17 -06:00
|
|
|
else
|
|
|
|
{
|
2004-08-02 09:03:38 -05:00
|
|
|
Reference< XContent > xSource(_rSource.Source, UNO_QUERY);
|
|
|
|
// it's one of our documents ....
|
|
|
|
Documents::iterator aIter = m_aDocumentMap.begin();
|
|
|
|
Documents::iterator aEnd = m_aDocumentMap.end();
|
|
|
|
for (;aIter != aEnd;++aIter )
|
2001-01-04 07:27:17 -06:00
|
|
|
{
|
2004-08-02 09:03:38 -05:00
|
|
|
if ( xSource == aIter->second.get() )
|
2001-01-04 07:27:17 -06:00
|
|
|
{
|
2004-08-02 09:03:38 -05:00
|
|
|
m_xCommandDefinitions->removeByName(aIter->first);
|
2001-01-04 07:27:17 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-08-02 09:03:38 -05:00
|
|
|
ODefinitionContainer::disposing(_rSource);
|
2001-01-04 07:27:17 -06:00
|
|
|
}
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
2008-12-09 01:25:38 -06:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
::rtl::OUString OQueryContainer::determineContentType() const
|
|
|
|
{
|
|
|
|
return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.org.openoffice.DatabaseQueryContainer" ) );
|
|
|
|
}
|
|
|
|
|
2001-09-25 07:28:23 -05:00
|
|
|
// -----------------------------------------------------------------------------
|
2004-08-02 09:03:38 -05:00
|
|
|
Reference< XContent > OQueryContainer::implCreateWrapper(const ::rtl::OUString& _rName)
|
2001-09-25 07:28:23 -05:00
|
|
|
{
|
2004-08-02 09:03:38 -05:00
|
|
|
Reference< XContent > xObject(m_xCommandDefinitions->getByName(_rName),UNO_QUERY);
|
|
|
|
return implCreateWrapper(xObject);
|
2001-09-25 07:28:23 -05:00
|
|
|
}
|
2004-08-02 09:03:38 -05:00
|
|
|
|
2000-09-18 18:16:46 -05:00
|
|
|
//--------------------------------------------------------------------------
|
2004-08-02 09:03:38 -05:00
|
|
|
Reference< XContent > OQueryContainer::implCreateWrapper(const Reference< XContent >& _rxCommandDesc)
|
2000-09-18 18:16:46 -05:00
|
|
|
{
|
2004-08-02 09:03:38 -05:00
|
|
|
Reference<XNameContainer> xContainer(_rxCommandDesc,UNO_QUERY);
|
|
|
|
Reference< XContent > xReturn;
|
|
|
|
if ( xContainer .is() )
|
2000-09-18 18:16:46 -05:00
|
|
|
{
|
2007-11-21 08:34:08 -06:00
|
|
|
xReturn = new OQueryContainer( xContainer, m_xConnection, m_aContext.getLegacyServiceFactory(), m_pWarnings );
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
2004-08-02 09:03:38 -05:00
|
|
|
else
|
|
|
|
{
|
2007-11-21 08:34:08 -06:00
|
|
|
OQuery* pNewObject = new OQuery( Reference< XPropertySet >( _rxCommandDesc, UNO_QUERY ), m_xConnection, m_aContext.getLegacyServiceFactory() );
|
2004-08-02 09:03:38 -05:00
|
|
|
xReturn = pNewObject;
|
2001-08-24 07:16:22 -05:00
|
|
|
|
2004-08-02 09:03:38 -05:00
|
|
|
pNewObject->setWarningsContainer( m_pWarnings );
|
2006-07-10 09:06:28 -05:00
|
|
|
// pNewObject->getColumns();
|
|
|
|
// Why? This is expensive. If you comment this in 'cause you really need it, be sure to run the
|
|
|
|
// QueryInQuery test in dbaccess/qa/complex/dbaccess ...
|
2004-08-02 09:03:38 -05:00
|
|
|
}
|
2001-08-24 07:16:22 -05:00
|
|
|
|
2004-08-02 09:03:38 -05:00
|
|
|
return xReturn;
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------
|
2004-08-02 09:03:38 -05:00
|
|
|
Reference< XContent > OQueryContainer::createObject( const ::rtl::OUString& _rName)
|
2000-09-18 18:16:46 -05:00
|
|
|
{
|
2004-08-02 09:03:38 -05:00
|
|
|
return implCreateWrapper(_rName);
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
2004-08-02 09:03:38 -05:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool OQueryContainer::checkExistence(const ::rtl::OUString& _rName)
|
2000-09-18 18:16:46 -05:00
|
|
|
{
|
2004-08-02 09:03:38 -05:00
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
if ( !m_bInPropertyChange )
|
2000-10-18 10:16:39 -05:00
|
|
|
{
|
2004-08-02 09:03:38 -05:00
|
|
|
bRet = m_xCommandDefinitions->hasByName(_rName);
|
|
|
|
Documents::iterator aFind = m_aDocumentMap.find(_rName);
|
|
|
|
if ( !bRet && aFind != m_aDocumentMap.end() )
|
|
|
|
{
|
|
|
|
m_aDocuments.erase( ::std::find(m_aDocuments.begin(),m_aDocuments.end(),aFind));
|
|
|
|
m_aDocumentMap.erase(aFind);
|
|
|
|
}
|
|
|
|
else if ( bRet && aFind == m_aDocumentMap.end() )
|
|
|
|
{
|
|
|
|
implAppend(_rName,NULL);
|
|
|
|
}
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
2004-08-02 09:03:38 -05:00
|
|
|
return bRet;
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------
|
2004-08-02 09:03:38 -05:00
|
|
|
sal_Bool SAL_CALL OQueryContainer::hasElements( ) throw (RuntimeException)
|
2000-09-18 18:16:46 -05:00
|
|
|
{
|
2004-08-02 09:03:38 -05:00
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
return m_xCommandDefinitions->hasElements();
|
2000-09-18 18:16:46 -05:00
|
|
|
}
|
2001-07-18 02:45:32 -05:00
|
|
|
// -----------------------------------------------------------------------------
|
2004-08-02 09:03:38 -05:00
|
|
|
sal_Int32 SAL_CALL OQueryContainer::getCount( ) throw(RuntimeException)
|
2001-07-18 02:45:32 -05:00
|
|
|
{
|
2004-08-02 09:03:38 -05:00
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
return Reference<XIndexAccess>(m_xCommandDefinitions,UNO_QUERY)->getCount();
|
2001-07-18 02:45:32 -05:00
|
|
|
}
|
2004-08-02 09:03:38 -05:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Sequence< ::rtl::OUString > SAL_CALL OQueryContainer::getElementNames( ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
2000-09-18 18:16:46 -05:00
|
|
|
|
2004-08-02 09:03:38 -05:00
|
|
|
return m_xCommandDefinitions->getElementNames();
|
|
|
|
}
|
2006-07-10 09:06:28 -05:00
|
|
|
|
2000-10-18 10:16:39 -05:00
|
|
|
//........................................................................
|
|
|
|
} // namespace dbaccess
|
|
|
|
//........................................................................
|
2000-09-18 18:16:46 -05:00
|
|
|
|