xref: /aoo41x/main/dbaccess/source/core/api/query.cxx (revision 96de5490)
1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*96de5490SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*96de5490SAndrew Rist  * distributed with this work for additional information
6*96de5490SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*96de5490SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist  * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*96de5490SAndrew Rist  *
11*96de5490SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*96de5490SAndrew Rist  *
13*96de5490SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist  * software distributed under the License is distributed on an
15*96de5490SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist  * KIND, either express or implied.  See the License for the
17*96de5490SAndrew Rist  * specific language governing permissions and limitations
18*96de5490SAndrew Rist  * under the License.
19*96de5490SAndrew Rist  *
20*96de5490SAndrew Rist  *************************************************************/
21*96de5490SAndrew Rist 
22*96de5490SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _DBA_COREAPI_QUERY_HXX_
28cdf0e10cSrcweir #include "query.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
31cdf0e10cSrcweir #include "dbastrings.hrc"
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef DBTOOLS_WARNINGSCONTAINER_HXX
34cdf0e10cSrcweir #include <connectivity/warningscontainer.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef DBA_HELPERCOLLECTIONS_HXX
37cdf0e10cSrcweir #include "HelperCollections.hxx"
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #ifndef _DBA_CORE_RESOURCE_HXX_
40cdf0e10cSrcweir #include "core_resource.hxx"
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #ifndef _DBA_CORE_RESOURCE_HRC_
43cdf0e10cSrcweir #include "core_resource.hrc"
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
47cdf0e10cSrcweir #include <cppuhelper/queryinterface.hxx>
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX
50cdf0e10cSrcweir #include <tools/debug.hxx>
51cdf0e10cSrcweir #endif
52cdf0e10cSrcweir #ifndef TOOLS_DIAGNOSE_EX_H
53cdf0e10cSrcweir #include <tools/diagnose_ex.h>
54cdf0e10cSrcweir #endif
55cdf0e10cSrcweir #ifndef _COMPHELPER_PROPERTY_AGGREGATION_HXX_
56cdf0e10cSrcweir #include <comphelper/propagg.hxx>
57cdf0e10cSrcweir #endif
58cdf0e10cSrcweir #ifndef _COMPHELPER_SEQUENCE_HXX_
59cdf0e10cSrcweir #include <comphelper/sequence.hxx>
60cdf0e10cSrcweir #endif
61cdf0e10cSrcweir 
62cdf0e10cSrcweir /** === begin UNO includes === **/
63cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
64cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp>
65cdf0e10cSrcweir #endif
66cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
67cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
68cdf0e10cSrcweir #endif
69cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
70cdf0e10cSrcweir #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
71cdf0e10cSrcweir #endif
72cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
73cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
74cdf0e10cSrcweir #endif
75cdf0e10cSrcweir /** === end UNO includes === **/
76cdf0e10cSrcweir 
77cdf0e10cSrcweir #ifndef _COMPHELPER_TYPES_HXX_
78cdf0e10cSrcweir #include <comphelper/types.hxx>
79cdf0e10cSrcweir #endif
80cdf0e10cSrcweir #ifndef _COMPHELPER_PROPERTY_HXX_
81cdf0e10cSrcweir #include <comphelper/property.hxx>
82cdf0e10cSrcweir #endif
83cdf0e10cSrcweir #ifndef UNOTOOLS_INC_SHAREDUNOCOMPONENT_HXX
84cdf0e10cSrcweir #include <unotools/sharedunocomponent.hxx>
85cdf0e10cSrcweir #endif
86cdf0e10cSrcweir #ifndef _DBACORE_DEFINITIONCOLUMN_HXX_
87cdf0e10cSrcweir #include "definitioncolumn.hxx"
88cdf0e10cSrcweir #endif
89cdf0e10cSrcweir 
90cdf0e10cSrcweir #include <functional>
91cdf0e10cSrcweir 
92cdf0e10cSrcweir #ifndef DBACORE_SDBCORETOOLS_HXX
93cdf0e10cSrcweir #include "sdbcoretools.hxx"
94cdf0e10cSrcweir #endif
95cdf0e10cSrcweir #ifndef DBACCESS_CORE_API_QUERYCOMPOSER_HXX
96cdf0e10cSrcweir #include "querycomposer.hxx"
97cdf0e10cSrcweir #endif
98cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
99cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
100cdf0e10cSrcweir #endif
101cdf0e10cSrcweir #ifndef DBA_CONTAINERMEDIATOR_HXX
102cdf0e10cSrcweir #include "ContainerMediator.hxx"
103cdf0e10cSrcweir #endif
104cdf0e10cSrcweir 
105cdf0e10cSrcweir using namespace dbaccess;
106cdf0e10cSrcweir using namespace ::com::sun::star::uno;
107cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
108cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
109cdf0e10cSrcweir using namespace ::com::sun::star::sdb;
110cdf0e10cSrcweir using namespace ::com::sun::star::lang;
111cdf0e10cSrcweir using namespace ::com::sun::star::util;
112cdf0e10cSrcweir using namespace ::com::sun::star::beans;
113cdf0e10cSrcweir using namespace ::com::sun::star::container;
114cdf0e10cSrcweir using namespace ::comphelper;
115cdf0e10cSrcweir using namespace ::osl;
116cdf0e10cSrcweir using namespace ::cppu;
117cdf0e10cSrcweir using namespace ::utl;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir //........................................................................
120cdf0e10cSrcweir namespace dbaccess
121cdf0e10cSrcweir {
122cdf0e10cSrcweir //........................................................................
123cdf0e10cSrcweir 
124cdf0e10cSrcweir //==========================================================================
125cdf0e10cSrcweir //= OQuery
126cdf0e10cSrcweir //==========================================================================
DBG_NAME(OQuery)127cdf0e10cSrcweir DBG_NAME(OQuery)
128cdf0e10cSrcweir //--------------------------------------------------------------------------
129cdf0e10cSrcweir OQuery::OQuery( const Reference< XPropertySet >& _rxCommandDefinition
130cdf0e10cSrcweir 			   ,const Reference< XConnection >& _rxConn
131cdf0e10cSrcweir 			   ,const Reference< XMultiServiceFactory >& _xORB)
132cdf0e10cSrcweir 	:OContentHelper(_xORB,NULL,TContentPtr(new OContentHelper_Impl))
133cdf0e10cSrcweir 	,OQueryDescriptor_Base(m_aMutex,*this)
134cdf0e10cSrcweir     ,ODataSettings(OContentHelper::rBHelper,sal_True)
135cdf0e10cSrcweir 	,m_xCommandDefinition(_rxCommandDefinition)
136cdf0e10cSrcweir 	,m_xConnection(_rxConn)
137cdf0e10cSrcweir 	,m_pColumnMediator( NULL )
138cdf0e10cSrcweir 	,m_pWarnings( NULL )
139cdf0e10cSrcweir 	,m_bCaseSensitiv(sal_True)
140cdf0e10cSrcweir 	,m_eDoingCurrently(NONE)
141cdf0e10cSrcweir {
142cdf0e10cSrcweir 	DBG_CTOR(OQuery, NULL);
143cdf0e10cSrcweir 	registerProperties();
144cdf0e10cSrcweir 	ODataSettings::registerPropertiesFor(this);
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	osl_incrementInterlockedCount(&m_refCount);
147cdf0e10cSrcweir 	DBG_ASSERT(m_xCommandDefinition.is(), "OQuery::OQuery : invalid CommandDefinition object !");
148cdf0e10cSrcweir 	if ( m_xCommandDefinition.is() )
149cdf0e10cSrcweir 	{
150cdf0e10cSrcweir 		try
151cdf0e10cSrcweir 		{
152cdf0e10cSrcweir 			::comphelper::copyProperties(_rxCommandDefinition,this);
153cdf0e10cSrcweir 		}
154cdf0e10cSrcweir 		catch(Exception&)
155cdf0e10cSrcweir 		{
156cdf0e10cSrcweir 			OSL_ENSURE(sal_False, "OQueryDescriptor_Base::OQueryDescriptor_Base: caught an exception!");
157cdf0e10cSrcweir 		}
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 		m_xCommandDefinition->addPropertyChangeListener(::rtl::OUString(), this);
160cdf0e10cSrcweir 		//	m_xCommandDefinition->addPropertyChangeListener(PROPERTY_NAME, this);
161cdf0e10cSrcweir 		m_xCommandPropInfo = m_xCommandDefinition->getPropertySetInfo();
162cdf0e10cSrcweir 	}
163cdf0e10cSrcweir 	DBG_ASSERT(m_xConnection.is(), "OQuery::OQuery : invalid connection !");
164cdf0e10cSrcweir 	osl_decrementInterlockedCount(&m_refCount);
165cdf0e10cSrcweir }
166cdf0e10cSrcweir 
167cdf0e10cSrcweir //--------------------------------------------------------------------------
~OQuery()168cdf0e10cSrcweir OQuery::~OQuery()
169cdf0e10cSrcweir {
170cdf0e10cSrcweir 	DBG_DTOR(OQuery, NULL);
171cdf0e10cSrcweir }
172cdf0e10cSrcweir // -----------------------------------------------------------------------------
173cdf0e10cSrcweir IMPLEMENT_IMPLEMENTATION_ID(OQuery);
174cdf0e10cSrcweir IMPLEMENT_GETTYPES3(OQuery,OQueryDescriptor_Base,ODataSettings,OContentHelper);
IMPLEMENT_FORWARD_XINTERFACE3(OQuery,OContentHelper,OQueryDescriptor_Base,ODataSettings)175cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE3( OQuery,OContentHelper,OQueryDescriptor_Base,ODataSettings)
176cdf0e10cSrcweir //--------------------------------------------------------------------------
177cdf0e10cSrcweir void OQuery::rebuildColumns()
178cdf0e10cSrcweir {
179cdf0e10cSrcweir     OSL_PRECOND( getColumnCount() == 0, "OQuery::rebuildColumns: column container should be empty!" );
180cdf0e10cSrcweir         // the base class' definition of rebuildColumns promised that clearColumns is called before rebuildColumns
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 	try
183cdf0e10cSrcweir 	{
184cdf0e10cSrcweir 		m_pColumnMediator = NULL;
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 		Reference<XColumnsSupplier> xColSup(m_xCommandDefinition,UNO_QUERY);
187cdf0e10cSrcweir         Reference< XNameAccess > xColumnDefinitions;
188cdf0e10cSrcweir 		if ( xColSup.is() )
189cdf0e10cSrcweir 		{
190cdf0e10cSrcweir 			xColumnDefinitions = xColSup->getColumns();
191cdf0e10cSrcweir 			if ( xColumnDefinitions.is() )
192cdf0e10cSrcweir 				m_pColumnMediator = new OContainerMediator( m_pColumns, xColumnDefinitions, m_xConnection, OContainerMediator::eColumns );
193cdf0e10cSrcweir 		}
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 		// fill the columns with columns from the statement
196cdf0e10cSrcweir 		Reference< XMultiServiceFactory > xFactory( m_xConnection, UNO_QUERY_THROW );
197cdf0e10cSrcweir         SharedUNOComponent< XSingleSelectQueryComposer, DisposableComponent > xComposer(
198cdf0e10cSrcweir             Reference< XSingleSelectQueryComposer >( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW ) );
199cdf0e10cSrcweir 
200cdf0e10cSrcweir         Reference< XNameAccess > xColumns;
201cdf0e10cSrcweir         Reference< XIndexAccess > xColumnsIndexed;
202cdf0e10cSrcweir         try
203cdf0e10cSrcweir         {
204cdf0e10cSrcweir 			xComposer->setQuery( m_sCommand );
205cdf0e10cSrcweir 		    Reference< XColumnsSupplier > xCols( xComposer, UNO_QUERY_THROW );
206cdf0e10cSrcweir 		    xColumns.set( xCols->getColumns(), UNO_QUERY_THROW );
207cdf0e10cSrcweir             xColumnsIndexed.set( xColumns, UNO_QUERY_THROW );
208cdf0e10cSrcweir         }
209cdf0e10cSrcweir         catch( const SQLException& ) { }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir         SharedUNOComponent< XPreparedStatement, DisposableComponent > xPreparedStatement;
212cdf0e10cSrcweir         if ( !xColumns.is() || ( xColumnsIndexed->getCount() == 0 ) )
213cdf0e10cSrcweir         {   // the QueryComposer could not parse it. Try a lean version.
214cdf0e10cSrcweir             xPreparedStatement.set( m_xConnection->prepareStatement( m_sCommand ), UNO_QUERY_THROW );
215cdf0e10cSrcweir 		    Reference< XResultSetMetaDataSupplier > xResMetaDataSup( xPreparedStatement, UNO_QUERY_THROW );
216cdf0e10cSrcweir             Reference< XResultSetMetaData > xResultSetMeta( xResMetaDataSup->getMetaData() );
217cdf0e10cSrcweir             if ( !xResultSetMeta.is() )
218cdf0e10cSrcweir             {
219cdf0e10cSrcweir                 ::rtl::OUString sError( DBA_RES( RID_STR_STATEMENT_WITHOUT_RESULT_SET ) );
220cdf0e10cSrcweir                 ::dbtools::throwSQLException( sError, SQL_GENERAL_ERROR, *this );
221cdf0e10cSrcweir             }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir             Reference< XDatabaseMetaData > xDBMeta( m_xConnection->getMetaData(), UNO_QUERY_THROW );
224cdf0e10cSrcweir             ::vos::ORef< OSQLColumns > aParseColumns(
225cdf0e10cSrcweir                 ::connectivity::parse::OParseColumn::createColumnsForResultSet( xResultSetMeta, xDBMeta,xColumnDefinitions ) );
226cdf0e10cSrcweir             xColumns = OPrivateColumns::createWithIntrinsicNames(
227cdf0e10cSrcweir                 aParseColumns, xDBMeta->supportsMixedCaseQuotedIdentifiers(), *this, m_aMutex );
228cdf0e10cSrcweir             if ( !xColumns.is() )
229cdf0e10cSrcweir                 throw RuntimeException();
230cdf0e10cSrcweir         }
231cdf0e10cSrcweir 
232cdf0e10cSrcweir         Sequence< ::rtl::OUString> aNames = xColumns->getElementNames();
233cdf0e10cSrcweir 		const ::rtl::OUString* pIter = aNames.getConstArray();
234cdf0e10cSrcweir 		const ::rtl::OUString* pEnd  = pIter + aNames.getLength();
235cdf0e10cSrcweir 		for ( sal_Int32 i = 0;pIter != pEnd; ++pIter,++i)
236cdf0e10cSrcweir 		{
237cdf0e10cSrcweir 			Reference<XPropertySet> xSource(xColumns->getByName( *pIter ),UNO_QUERY);
238cdf0e10cSrcweir             ::rtl::OUString sLabel = *pIter;
239cdf0e10cSrcweir             if ( xColumnDefinitions.is() && xColumnDefinitions->hasByName(*pIter) )
240cdf0e10cSrcweir             {
241cdf0e10cSrcweir                 Reference<XPropertySet> xCommandColumn(xColumnDefinitions->getByName( *pIter ),UNO_QUERY);
242cdf0e10cSrcweir                 xCommandColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
243cdf0e10cSrcweir             }
244cdf0e10cSrcweir             OQueryColumn* pColumn = new OQueryColumn( xSource, m_xConnection, sLabel);
245cdf0e10cSrcweir 			Reference< XChild > xChild( *pColumn, UNO_QUERY_THROW );
246cdf0e10cSrcweir 			xChild->setParent( *this );
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 			implAppendColumn( *pIter, pColumn );
249cdf0e10cSrcweir 			Reference< XPropertySet > xDest( *pColumn, UNO_QUERY_THROW );
250cdf0e10cSrcweir 			if ( m_pColumnMediator.is() )
251cdf0e10cSrcweir 				m_pColumnMediator->notifyElementCreated( *pIter, xDest );
252cdf0e10cSrcweir 		}
253cdf0e10cSrcweir 	}
254cdf0e10cSrcweir 	catch( const SQLContext& e )
255cdf0e10cSrcweir 	{
256cdf0e10cSrcweir 		if ( m_pWarnings )
257cdf0e10cSrcweir 			m_pWarnings->appendWarning( e );
258cdf0e10cSrcweir 	}
259cdf0e10cSrcweir 	catch( const SQLWarning& e )
260cdf0e10cSrcweir 	{
261cdf0e10cSrcweir 		if ( m_pWarnings )
262cdf0e10cSrcweir 			m_pWarnings->appendWarning( e );
263cdf0e10cSrcweir 	}
264cdf0e10cSrcweir 	catch( const SQLException& e )
265cdf0e10cSrcweir 	{
266cdf0e10cSrcweir 		if ( m_pWarnings )
267cdf0e10cSrcweir 			m_pWarnings->appendWarning( e );
268cdf0e10cSrcweir 	}
269cdf0e10cSrcweir 	catch( const Exception& )
270cdf0e10cSrcweir 	{
271cdf0e10cSrcweir 		DBG_UNHANDLED_EXCEPTION();
272cdf0e10cSrcweir 	}
273cdf0e10cSrcweir }
274cdf0e10cSrcweir 
275cdf0e10cSrcweir // XServiceInfo
276cdf0e10cSrcweir //--------------------------------------------------------------------------
277cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO3(OQuery, "com.sun.star.sdb.dbaccess.OQuery", SERVICE_SDB_DATASETTINGS, SERVICE_SDB_QUERY, SERVICE_SDB_QUERYDEFINITION)
278cdf0e10cSrcweir 
279cdf0e10cSrcweir // ::com::sun::star::beans::XPropertyChangeListener
280cdf0e10cSrcweir //--------------------------------------------------------------------------
propertyChange(const PropertyChangeEvent & _rSource)281cdf0e10cSrcweir void SAL_CALL OQuery::propertyChange( const PropertyChangeEvent& _rSource ) throw(RuntimeException)
282cdf0e10cSrcweir {
283cdf0e10cSrcweir 	sal_Int32 nOwnHandle = -1;
284cdf0e10cSrcweir 	{
285cdf0e10cSrcweir 		MutexGuard aGuard(m_aMutex);
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 		DBG_ASSERT(_rSource.Source.get() == Reference< XInterface >(m_xCommandDefinition, UNO_QUERY).get(),
288cdf0e10cSrcweir 			"OQuery::propertyChange : where did this call come from ?");
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 		if (m_eDoingCurrently == SETTING_PROPERTIES)
291cdf0e10cSrcweir 			// we're setting the property ourself, so we will do the neccessary notifications later
292cdf0e10cSrcweir 			return;
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 		// forward this to our own member holding a copy of the property value
295cdf0e10cSrcweir 		if (getArrayHelper()->hasPropertyByName(_rSource.PropertyName))
296cdf0e10cSrcweir 		{
297cdf0e10cSrcweir 			Property aOwnProp = getArrayHelper()->getPropertyByName(_rSource.PropertyName);
298cdf0e10cSrcweir 			nOwnHandle = aOwnProp.Handle;
299cdf0e10cSrcweir 			ODataSettings::setFastPropertyValue_NoBroadcast(nOwnHandle, _rSource.NewValue);
300cdf0e10cSrcweir 				// don't use our own setFastPropertyValue_NoBroadcast, this would forward it to the CommandSettings,
301cdf0e10cSrcweir 				// again
302cdf0e10cSrcweir 				// and don't use the "real" setPropertyValue, this is to expensive and not sure to succeed
303cdf0e10cSrcweir 		}
304cdf0e10cSrcweir 		else
305cdf0e10cSrcweir 		{
306cdf0e10cSrcweir 			DBG_ERROR("OQuery::propertyChange : my CommandDefinition has more properties than I do !");
307cdf0e10cSrcweir 		}
308cdf0e10cSrcweir 	}
309cdf0e10cSrcweir 
310cdf0e10cSrcweir 	fire(&nOwnHandle, &_rSource.NewValue, &_rSource.OldValue, 1, sal_False);
311cdf0e10cSrcweir }
312cdf0e10cSrcweir 
313cdf0e10cSrcweir //--------------------------------------------------------------------------
disposing(const EventObject & _rSource)314cdf0e10cSrcweir void SAL_CALL OQuery::disposing( const EventObject& _rSource ) throw (RuntimeException)
315cdf0e10cSrcweir {
316cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
317cdf0e10cSrcweir 
318cdf0e10cSrcweir     (void)_rSource;
319cdf0e10cSrcweir 	DBG_ASSERT(_rSource.Source.get() == Reference< XInterface >(m_xCommandDefinition, UNO_QUERY).get(),
320cdf0e10cSrcweir 		"OQuery::disposing : where did this call come from ?");
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 	m_xCommandDefinition->removePropertyChangeListener(::rtl::OUString(), this);
323cdf0e10cSrcweir 	m_xCommandDefinition = NULL;
324cdf0e10cSrcweir }
325cdf0e10cSrcweir 
326cdf0e10cSrcweir // XDataDescriptorFactory
327cdf0e10cSrcweir //--------------------------------------------------------------------------
createDataDescriptor()328cdf0e10cSrcweir Reference< XPropertySet > SAL_CALL OQuery::createDataDescriptor(  ) throw(RuntimeException)
329cdf0e10cSrcweir {
330cdf0e10cSrcweir 	return new OQueryDescriptor(*this);
331cdf0e10cSrcweir }
332cdf0e10cSrcweir 
333cdf0e10cSrcweir // pseudo-XComponent
334cdf0e10cSrcweir //--------------------------------------------------------------------------
disposing()335cdf0e10cSrcweir void SAL_CALL OQuery::disposing()
336cdf0e10cSrcweir {
337cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
338cdf0e10cSrcweir 	if (m_xCommandDefinition.is())
339cdf0e10cSrcweir 	{
340cdf0e10cSrcweir 		m_xCommandDefinition->removePropertyChangeListener(::rtl::OUString(), this);
341cdf0e10cSrcweir 		m_xCommandDefinition = NULL;
342cdf0e10cSrcweir 	}
343cdf0e10cSrcweir 	disposeColumns();
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 	m_pWarnings = NULL;
346cdf0e10cSrcweir }
347cdf0e10cSrcweir 
348cdf0e10cSrcweir //--------------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle,const Any & _rValue)349cdf0e10cSrcweir void OQuery::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw (Exception)
350cdf0e10cSrcweir {
351cdf0e10cSrcweir 	ODataSettings::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
352cdf0e10cSrcweir 	::rtl::OUString sAggPropName;
353cdf0e10cSrcweir 	sal_Int16 nAttr = 0;
354cdf0e10cSrcweir 	if (getInfoHelper().fillPropertyMembersByHandle(&sAggPropName,&nAttr,_nHandle) &&
355cdf0e10cSrcweir 		m_xCommandPropInfo.is() &&
356cdf0e10cSrcweir 		m_xCommandPropInfo->hasPropertyByName(sAggPropName))
357cdf0e10cSrcweir 	{	// the base class holds the property values itself, but we have to forward this to our CommandDefinition
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 		m_eDoingCurrently = SETTING_PROPERTIES;
360cdf0e10cSrcweir 		OAutoActionReset aActionResetter(this);
361cdf0e10cSrcweir 		m_xCommandDefinition->setPropertyValue(sAggPropName, _rValue);
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 		if ( PROPERTY_ID_COMMAND == _nHandle )
364cdf0e10cSrcweir 			// the columns are out of date if we are based on a new statement ....
365cdf0e10cSrcweir 			// 90573 - 16.08.2001 - frank.schoenheit@sun.com
366cdf0e10cSrcweir 			setColumnsOutOfDate();
367cdf0e10cSrcweir 	}
368cdf0e10cSrcweir }
369cdf0e10cSrcweir 
370cdf0e10cSrcweir //--------------------------------------------------------------------------
getPropertySetInfo()371cdf0e10cSrcweir Reference< XPropertySetInfo > SAL_CALL OQuery::getPropertySetInfo(	) throw(RuntimeException)
372cdf0e10cSrcweir {
373cdf0e10cSrcweir 	return createPropertySetInfo( getInfoHelper() ) ;
374cdf0e10cSrcweir }
375cdf0e10cSrcweir 
376cdf0e10cSrcweir //------------------------------------------------------------------------------
getInfoHelper()377cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& OQuery::getInfoHelper()
378cdf0e10cSrcweir {
379cdf0e10cSrcweir 	return *getArrayHelper();
380cdf0e10cSrcweir }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir //--------------------------------------------------------------------------
createArrayHelper() const383cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* OQuery::createArrayHelper( ) const
384cdf0e10cSrcweir {
385cdf0e10cSrcweir 	Sequence< Property > aProps;
386cdf0e10cSrcweir 	// our own props
387cdf0e10cSrcweir 	describeProperties(aProps);
388cdf0e10cSrcweir 	return new ::cppu::OPropertyArrayHelper(aProps);
389cdf0e10cSrcweir }
390cdf0e10cSrcweir // -----------------------------------------------------------------------------
createColumn(const::rtl::OUString &) const391cdf0e10cSrcweir OColumn* OQuery::createColumn(const ::rtl::OUString& /*_rName*/) const
392cdf0e10cSrcweir {
393cdf0e10cSrcweir 	return NULL;
394cdf0e10cSrcweir }
395cdf0e10cSrcweir // -----------------------------------------------------------------------------
rename(const::rtl::OUString & newName)396cdf0e10cSrcweir void SAL_CALL OQuery::rename( const ::rtl::OUString& newName ) throw (SQLException, ElementExistException, RuntimeException)
397cdf0e10cSrcweir {
398cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
399cdf0e10cSrcweir 	Reference<XRename> xRename(m_xCommandDefinition,UNO_QUERY);
400cdf0e10cSrcweir 	OSL_ENSURE(xRename.is(),"No XRename interface!");
401cdf0e10cSrcweir 	if(xRename.is())
402cdf0e10cSrcweir 		xRename->rename(newName);
403cdf0e10cSrcweir }
404cdf0e10cSrcweir // -----------------------------------------------------------------------------
registerProperties()405cdf0e10cSrcweir void OQuery::registerProperties()
406cdf0e10cSrcweir {
407cdf0e10cSrcweir 	// the properties which OCommandBase supplies (it has no own registration, as it's not derived from
408cdf0e10cSrcweir 	// a OPropertyStateContainer)
409cdf0e10cSrcweir 	registerProperty(PROPERTY_NAME, PROPERTY_ID_NAME, PropertyAttribute::BOUND|PropertyAttribute::CONSTRAINED,
410cdf0e10cSrcweir 					&m_sElementName, ::getCppuType(&m_sElementName));
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 	registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND,
413cdf0e10cSrcweir 					&m_sCommand, ::getCppuType(&m_sCommand));
414cdf0e10cSrcweir 
415cdf0e10cSrcweir 	registerProperty(PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::BOUND,
416cdf0e10cSrcweir 					&m_bEscapeProcessing, ::getBooleanCppuType());
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 	registerProperty(PROPERTY_UPDATE_TABLENAME, PROPERTY_ID_UPDATE_TABLENAME, PropertyAttribute::BOUND,
419cdf0e10cSrcweir 					&m_sUpdateTableName, ::getCppuType(&m_sUpdateTableName));
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 	registerProperty(PROPERTY_UPDATE_SCHEMANAME, PROPERTY_ID_UPDATE_SCHEMANAME, PropertyAttribute::BOUND,
422cdf0e10cSrcweir 					&m_sUpdateSchemaName, ::getCppuType(&m_sUpdateSchemaName));
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 	registerProperty(PROPERTY_UPDATE_CATALOGNAME, PROPERTY_ID_UPDATE_CATALOGNAME, PropertyAttribute::BOUND,
425cdf0e10cSrcweir 					&m_sUpdateCatalogName, ::getCppuType(&m_sUpdateCatalogName));
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 	registerProperty(PROPERTY_LAYOUTINFORMATION, PROPERTY_ID_LAYOUTINFORMATION, PropertyAttribute::BOUND,
428cdf0e10cSrcweir 					&m_aLayoutInformation, ::getCppuType(&m_aLayoutInformation));
429cdf0e10cSrcweir }
430cdf0e10cSrcweir 
431cdf0e10cSrcweir // -----------------------------------------------------------------------------
determineContentType() const432cdf0e10cSrcweir ::rtl::OUString OQuery::determineContentType() const
433cdf0e10cSrcweir {
434cdf0e10cSrcweir     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.org.openoffice.DatabaseQuery" ) );
435cdf0e10cSrcweir }
436cdf0e10cSrcweir 
437cdf0e10cSrcweir // -----------------------------------------------------------------------------
438cdf0e10cSrcweir //........................................................................
439cdf0e10cSrcweir }	// namespace dbaccess
440cdf0e10cSrcweir //........................................................................
441cdf0e10cSrcweir 
442