xref: /AOO41X/main/dbaccess/source/core/api/querycomposer.cxx (revision 96de54900b79e13b861fbc62cbf36018b54e21b7)
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
10cdf0e10cSrcweir  *
11*96de5490SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
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 _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
28cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
31cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatter.hpp>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_COLUMNSEARCH_HPP_
34cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnSearch.hpp>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
37cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
40cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_
43cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_SERVICENOTREGISTEREDEXCEPTION_HPP_
46cdf0e10cSrcweir #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir #ifndef _COMPHELPER_SEQUENCE_HXX_
49cdf0e10cSrcweir #include <comphelper/sequence.hxx>
50cdf0e10cSrcweir #endif
51cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UNO_XAGGREGATION_HPP_
52cdf0e10cSrcweir #include <com/sun/star/uno/XAggregation.hpp>
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir #ifndef _COMPHELPER_SEQUENCE_HXX_
55cdf0e10cSrcweir #include <comphelper/sequence.hxx>
56cdf0e10cSrcweir #endif
57cdf0e10cSrcweir #ifndef _COMPHELPER_PROCESSFACTORY_HXX_
58cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
59cdf0e10cSrcweir #endif
60cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
61cdf0e10cSrcweir #include "dbastrings.hrc"
62cdf0e10cSrcweir #endif
63cdf0e10cSrcweir #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
64cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
65cdf0e10cSrcweir #endif
66cdf0e10cSrcweir #ifndef _UTL_CONFIGMGR_HXX_
67cdf0e10cSrcweir #include <unotools/configmgr.hxx>
68cdf0e10cSrcweir #endif
69cdf0e10cSrcweir #ifndef _COMPHELPER_TYPES_HXX_
70cdf0e10cSrcweir #include <comphelper/types.hxx>
71cdf0e10cSrcweir #endif
72cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX
73cdf0e10cSrcweir #include <tools/debug.hxx>
74cdf0e10cSrcweir #endif
75cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
76cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
77cdf0e10cSrcweir #endif
78cdf0e10cSrcweir #ifndef _COM_SUN_STAR_I18N_XLOCALEDATA_HPP_
79cdf0e10cSrcweir #include <com/sun/star/i18n/XLocaleData.hpp>
80cdf0e10cSrcweir #endif
81cdf0e10cSrcweir #ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX
82cdf0e10cSrcweir #include <unotools/syslocale.hxx>
83cdf0e10cSrcweir #endif
84cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
85cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
86cdf0e10cSrcweir #endif
87cdf0e10cSrcweir #include <com/sun/star/sdb/SQLFilterOperator.hpp>
88cdf0e10cSrcweir #ifndef DBACCESS_CORE_API_QUERYCOMPOSER_HXX
89cdf0e10cSrcweir #include "querycomposer.hxx"
90cdf0e10cSrcweir #endif
91cdf0e10cSrcweir #ifndef DBA_HELPERCOLLECTIONS_HXX
92cdf0e10cSrcweir #include "HelperCollections.hxx"
93cdf0e10cSrcweir #endif
94cdf0e10cSrcweir #ifndef DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX
95cdf0e10cSrcweir #include "composertools.hxx"
96cdf0e10cSrcweir #endif
97cdf0e10cSrcweir #include <algorithm>
98cdf0e10cSrcweir #include <rtl/logfile.hxx>
99cdf0e10cSrcweir 
100cdf0e10cSrcweir using namespace dbaccess;
101cdf0e10cSrcweir using namespace dbtools;
102cdf0e10cSrcweir using namespace comphelper;
103cdf0e10cSrcweir using namespace connectivity;
104cdf0e10cSrcweir using namespace ::com::sun::star::uno;
105cdf0e10cSrcweir using namespace ::com::sun::star::beans;
106cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
107cdf0e10cSrcweir using namespace ::com::sun::star::sdb;
108cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
109cdf0e10cSrcweir using namespace ::com::sun::star::container;
110cdf0e10cSrcweir using namespace ::com::sun::star::i18n;
111cdf0e10cSrcweir using namespace ::com::sun::star::lang;
112cdf0e10cSrcweir using namespace ::com::sun::star::script;
113cdf0e10cSrcweir using namespace ::cppu;
114cdf0e10cSrcweir using namespace ::osl;
115cdf0e10cSrcweir using namespace ::utl;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 
DBG_NAME(OQueryComposer)118cdf0e10cSrcweir DBG_NAME(OQueryComposer)
119cdf0e10cSrcweir // -------------------------------------------------------------------------
120cdf0e10cSrcweir OQueryComposer::OQueryComposer(const Reference< XConnection>& _xConnection)
121cdf0e10cSrcweir  : OSubComponent(m_aMutex,_xConnection)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::OQueryComposer" );
124cdf0e10cSrcweir 	DBG_CTOR(OQueryComposer,NULL);
125cdf0e10cSrcweir 	OSL_ENSURE(_xConnection.is()," Connection cant be null!");
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	Reference<XMultiServiceFactory> xFac( _xConnection, UNO_QUERY_THROW );
128cdf0e10cSrcweir 	m_xComposer.set( xFac->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW );
129cdf0e10cSrcweir 	m_xComposerHelper.set( xFac->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW );
130cdf0e10cSrcweir }
131cdf0e10cSrcweir // -------------------------------------------------------------------------
~OQueryComposer()132cdf0e10cSrcweir OQueryComposer::~OQueryComposer()
133cdf0e10cSrcweir {
134cdf0e10cSrcweir 	DBG_DTOR(OQueryComposer,NULL);
135cdf0e10cSrcweir }
136cdf0e10cSrcweir // -----------------------------------------------------------------------------
disposing()137cdf0e10cSrcweir void SAL_CALL OQueryComposer::disposing()
138cdf0e10cSrcweir {
139cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::disposing" );
140cdf0e10cSrcweir 	::comphelper::disposeComponent(m_xComposerHelper);
141cdf0e10cSrcweir 	::comphelper::disposeComponent(m_xComposer);
142cdf0e10cSrcweir }
143cdf0e10cSrcweir // -------------------------------------------------------------------------
144cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider
getTypes()145cdf0e10cSrcweir Sequence< Type > SAL_CALL OQueryComposer::getTypes() throw (RuntimeException)
146cdf0e10cSrcweir {
147cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getTypes" );
148cdf0e10cSrcweir 	return ::comphelper::concatSequences(OSubComponent::getTypes(),OQueryComposer_BASE::getTypes());
149cdf0e10cSrcweir }
150cdf0e10cSrcweir // -------------------------------------------------------------------------
getImplementationId()151cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL OQueryComposer::getImplementationId() throw (RuntimeException)
152cdf0e10cSrcweir {
153cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getImplementationId" );
154cdf0e10cSrcweir 	static OImplementationId * pId = 0;
155cdf0e10cSrcweir 	if (! pId)
156cdf0e10cSrcweir 	{
157cdf0e10cSrcweir 		MutexGuard aGuard( Mutex::getGlobalMutex() );
158cdf0e10cSrcweir 		if (! pId)
159cdf0e10cSrcweir 		{
160cdf0e10cSrcweir 			static OImplementationId aId;
161cdf0e10cSrcweir 			pId = &aId;
162cdf0e10cSrcweir 		}
163cdf0e10cSrcweir 	}
164cdf0e10cSrcweir 	return pId->getImplementationId();
165cdf0e10cSrcweir }
166cdf0e10cSrcweir // -------------------------------------------------------------------------
167cdf0e10cSrcweir // com::sun::star::lang::XUnoTunnel
getSomething(const Sequence<sal_Int8> & rId)168cdf0e10cSrcweir sal_Int64 SAL_CALL OQueryComposer::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
169cdf0e10cSrcweir {
170cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getSomething" );
171cdf0e10cSrcweir 	if (rId.getLength() == 16 && 0 == rtl_compareMemory(getImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
172cdf0e10cSrcweir 		return reinterpret_cast<sal_Int64>(this);
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 	return 0;
175cdf0e10cSrcweir }
176cdf0e10cSrcweir // -------------------------------------------------------------------------
queryInterface(const Type & rType)177cdf0e10cSrcweir Any SAL_CALL OQueryComposer::queryInterface( const Type & rType ) throw(RuntimeException)
178cdf0e10cSrcweir {
179cdf0e10cSrcweir     //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::queryInterface" );
180cdf0e10cSrcweir 	Any aRet = OSubComponent::queryInterface(rType);
181cdf0e10cSrcweir 	if(!aRet.hasValue())
182cdf0e10cSrcweir 		aRet = OQueryComposer_BASE::queryInterface(rType);
183cdf0e10cSrcweir 	return aRet;
184cdf0e10cSrcweir }
185cdf0e10cSrcweir // -------------------------------------------------------------------------
186cdf0e10cSrcweir // XServiceInfo
187cdf0e10cSrcweir //------------------------------------------------------------------------------
getImplementationName()188cdf0e10cSrcweir rtl::OUString OQueryComposer::getImplementationName(  ) throw(RuntimeException)
189cdf0e10cSrcweir {
190cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getImplementationName" );
191cdf0e10cSrcweir 	return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.dbaccess.OQueryComposer"));
192cdf0e10cSrcweir }
193cdf0e10cSrcweir //------------------------------------------------------------------------------
supportsService(const::rtl::OUString & _rServiceName)194cdf0e10cSrcweir sal_Bool OQueryComposer::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
195cdf0e10cSrcweir {
196cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::supportsService" );
197cdf0e10cSrcweir 	return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
198cdf0e10cSrcweir }
199cdf0e10cSrcweir //------------------------------------------------------------------------------
getSupportedServiceNames()200cdf0e10cSrcweir Sequence< ::rtl::OUString > OQueryComposer::getSupportedServiceNames(  ) throw (RuntimeException)
201cdf0e10cSrcweir {
202cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getSupportedServiceNames" );
203cdf0e10cSrcweir 	Sequence< rtl::OUString > aSNS( 1 );
204cdf0e10cSrcweir 	aSNS[0] = SERVICE_SDB_SQLQUERYCOMPOSER;
205cdf0e10cSrcweir 	return aSNS;
206cdf0e10cSrcweir }
207cdf0e10cSrcweir // -------------------------------------------------------------------------
208cdf0e10cSrcweir // XSQLQueryComposer
getQuery()209cdf0e10cSrcweir ::rtl::OUString SAL_CALL OQueryComposer::getQuery(  ) throw(RuntimeException)
210cdf0e10cSrcweir {
211cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getQuery" );
212cdf0e10cSrcweir 	::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
215cdf0e10cSrcweir 	Reference<XPropertySet> xProp(m_xComposer,UNO_QUERY);
216cdf0e10cSrcweir 	::rtl::OUString sQuery;
217cdf0e10cSrcweir     if ( xProp.is() )
218cdf0e10cSrcweir 	    xProp->getPropertyValue(PROPERTY_ORIGINAL) >>= sQuery;
219cdf0e10cSrcweir 	return sQuery;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir // -------------------------------------------------------------------------
setQuery(const::rtl::OUString & command)222cdf0e10cSrcweir void SAL_CALL OQueryComposer::setQuery( const ::rtl::OUString& command ) throw(SQLException, RuntimeException)
223cdf0e10cSrcweir {
224cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::setQuery" );
225cdf0e10cSrcweir 	::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
228cdf0e10cSrcweir 	m_aFilters.clear();
229cdf0e10cSrcweir 	m_xComposer->setQuery(command);
230cdf0e10cSrcweir 	m_sOrgFilter = m_xComposer->getFilter();
231cdf0e10cSrcweir 	m_sOrgOrder = m_xComposer->getOrder();
232cdf0e10cSrcweir }
233cdf0e10cSrcweir // -------------------------------------------------------------------------
getComposedQuery()234cdf0e10cSrcweir ::rtl::OUString SAL_CALL OQueryComposer::getComposedQuery(  ) throw(RuntimeException)
235cdf0e10cSrcweir {
236cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getComposedQuery" );
237cdf0e10cSrcweir 	::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 	return m_xComposer->getQuery();
242cdf0e10cSrcweir }
243cdf0e10cSrcweir // -------------------------------------------------------------------------
getFilter()244cdf0e10cSrcweir ::rtl::OUString SAL_CALL OQueryComposer::getFilter(  ) throw(RuntimeException)
245cdf0e10cSrcweir {
246cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getFilter" );
247cdf0e10cSrcweir 	::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
248cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
249cdf0e10cSrcweir 	FilterCreator aFilterCreator;
250cdf0e10cSrcweir 	aFilterCreator = ::std::for_each(m_aFilters.begin(),m_aFilters.end(),aFilterCreator);
251cdf0e10cSrcweir 	return aFilterCreator.getComposedAndClear();
252cdf0e10cSrcweir }
253cdf0e10cSrcweir // -------------------------------------------------------------------------
getStructuredFilter()254cdf0e10cSrcweir Sequence< Sequence< PropertyValue > > SAL_CALL OQueryComposer::getStructuredFilter(  ) throw(RuntimeException)
255cdf0e10cSrcweir {
256cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getStructuredFilter" );
257cdf0e10cSrcweir 	::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
260cdf0e10cSrcweir 	return m_xComposer->getStructuredFilter();
261cdf0e10cSrcweir }
262cdf0e10cSrcweir // -------------------------------------------------------------------------
getOrder()263cdf0e10cSrcweir ::rtl::OUString SAL_CALL OQueryComposer::getOrder(  ) throw(RuntimeException)
264cdf0e10cSrcweir {
265cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getOrder" );
266cdf0e10cSrcweir 	::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
267cdf0e10cSrcweir 
268cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
269cdf0e10cSrcweir 	OrderCreator aOrderCreator;
270cdf0e10cSrcweir 	aOrderCreator = ::std::for_each(m_aOrders.begin(),m_aOrders.end(),aOrderCreator);
271cdf0e10cSrcweir 	return aOrderCreator.getComposedAndClear();
272cdf0e10cSrcweir }
273cdf0e10cSrcweir // -----------------------------------------------------------------------------
appendFilterByColumn(const Reference<XPropertySet> & column)274cdf0e10cSrcweir void SAL_CALL OQueryComposer::appendFilterByColumn( const Reference< XPropertySet >& column ) throw(SQLException, RuntimeException)
275cdf0e10cSrcweir {
276cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::appendFilterByColumn" );
277cdf0e10cSrcweir 	::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
278cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 	m_xComposerHelper->setQuery(getQuery());
281cdf0e10cSrcweir 	m_xComposerHelper->setFilter(::rtl::OUString());
282cdf0e10cSrcweir     sal_Int32 nOp = SQLFilterOperator::EQUAL;
283cdf0e10cSrcweir     if ( column.is() )
284cdf0e10cSrcweir     {
285cdf0e10cSrcweir         sal_Int32 nType = 0;
286cdf0e10cSrcweir 	    column->getPropertyValue(PROPERTY_TYPE) >>= nType;
287cdf0e10cSrcweir         switch(nType)
288cdf0e10cSrcweir         {
289cdf0e10cSrcweir             case DataType::VARCHAR:
290cdf0e10cSrcweir 			case DataType::CHAR:
291cdf0e10cSrcweir 			case DataType::LONGVARCHAR:
292cdf0e10cSrcweir                 nOp = SQLFilterOperator::LIKE;
293cdf0e10cSrcweir                 break;
294cdf0e10cSrcweir             default:
295cdf0e10cSrcweir                 nOp = SQLFilterOperator::EQUAL;
296cdf0e10cSrcweir         }
297cdf0e10cSrcweir     }
298cdf0e10cSrcweir     m_xComposerHelper->appendFilterByColumn(column,sal_True,nOp);
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 	FilterCreator aFilterCreator;
301cdf0e10cSrcweir 	aFilterCreator.append(getFilter());
302cdf0e10cSrcweir 	aFilterCreator.append(m_xComposerHelper->getFilter());
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 	setFilter( aFilterCreator.getComposedAndClear() );
305cdf0e10cSrcweir }
306cdf0e10cSrcweir // -------------------------------------------------------------------------
appendOrderByColumn(const Reference<XPropertySet> & column,sal_Bool ascending)307cdf0e10cSrcweir void SAL_CALL OQueryComposer::appendOrderByColumn( const Reference< XPropertySet >& column, sal_Bool ascending ) throw(SQLException, RuntimeException)
308cdf0e10cSrcweir {
309cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::appendOrderByColumn" );
310cdf0e10cSrcweir 	::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
311cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 	m_xComposerHelper->setQuery(getQuery());
314cdf0e10cSrcweir 	m_xComposerHelper->setOrder(::rtl::OUString());
315cdf0e10cSrcweir 	m_xComposerHelper->appendOrderByColumn(column,ascending);
316cdf0e10cSrcweir 
317cdf0e10cSrcweir 	OrderCreator aOrderCreator;
318cdf0e10cSrcweir 	aOrderCreator.append(getOrder());
319cdf0e10cSrcweir 	aOrderCreator.append(m_xComposerHelper->getOrder());
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 	setOrder(aOrderCreator.getComposedAndClear());
322cdf0e10cSrcweir }
323cdf0e10cSrcweir // -------------------------------------------------------------------------
setFilter(const::rtl::OUString & filter)324cdf0e10cSrcweir void SAL_CALL OQueryComposer::setFilter( const ::rtl::OUString& filter ) throw(SQLException, RuntimeException)
325cdf0e10cSrcweir {
326cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::setFilter" );
327cdf0e10cSrcweir 	::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
328cdf0e10cSrcweir 
329cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
330cdf0e10cSrcweir 	FilterCreator aFilterCreator;
331cdf0e10cSrcweir     aFilterCreator.append(m_sOrgFilter);
332cdf0e10cSrcweir 	aFilterCreator.append(filter);
333cdf0e10cSrcweir 
334cdf0e10cSrcweir 	m_aFilters.clear();
335cdf0e10cSrcweir 	if ( filter.getLength() )
336cdf0e10cSrcweir 		m_aFilters.push_back(filter);
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 	m_xComposer->setFilter( aFilterCreator.getComposedAndClear() );
339cdf0e10cSrcweir }
340cdf0e10cSrcweir // -------------------------------------------------------------------------
setOrder(const::rtl::OUString & order)341cdf0e10cSrcweir void SAL_CALL OQueryComposer::setOrder( const ::rtl::OUString& order ) throw(SQLException, RuntimeException)
342cdf0e10cSrcweir {
343cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::setOrder" );
344cdf0e10cSrcweir 	::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
345cdf0e10cSrcweir 
346cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 	OrderCreator aOrderCreator;
349cdf0e10cSrcweir 	aOrderCreator.append(m_sOrgOrder);
350cdf0e10cSrcweir 	aOrderCreator.append(order);
351cdf0e10cSrcweir 
352cdf0e10cSrcweir 	m_aOrders.clear();
353cdf0e10cSrcweir 	if ( order.getLength() )
354cdf0e10cSrcweir 		m_aOrders.push_back(order);
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 	m_xComposer->setOrder(aOrderCreator.getComposedAndClear());
357cdf0e10cSrcweir }
358cdf0e10cSrcweir // -------------------------------------------------------------------------
359cdf0e10cSrcweir // XTablesSupplier
getTables()360cdf0e10cSrcweir Reference< XNameAccess > SAL_CALL OQueryComposer::getTables(  ) throw(RuntimeException)
361cdf0e10cSrcweir {
362cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getTables" );
363cdf0e10cSrcweir 	::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
366cdf0e10cSrcweir 	return Reference<XTablesSupplier>(m_xComposer,UNO_QUERY)->getTables();
367cdf0e10cSrcweir }
368cdf0e10cSrcweir // -------------------------------------------------------------------------
369cdf0e10cSrcweir // XColumnsSupplier
getColumns()370cdf0e10cSrcweir Reference< XNameAccess > SAL_CALL OQueryComposer::getColumns(  ) throw(RuntimeException)
371cdf0e10cSrcweir {
372cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getColumns" );
373cdf0e10cSrcweir 	::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
376cdf0e10cSrcweir 	return Reference<XColumnsSupplier>(m_xComposer,UNO_QUERY)->getColumns();
377cdf0e10cSrcweir }
378cdf0e10cSrcweir // -------------------------------------------------------------------------
getParameters()379cdf0e10cSrcweir Reference< XIndexAccess > SAL_CALL OQueryComposer::getParameters(  ) throw(RuntimeException)
380cdf0e10cSrcweir {
381cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OQueryComposer::getParameters" );
382cdf0e10cSrcweir 	::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
383cdf0e10cSrcweir 
384cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
385cdf0e10cSrcweir 	return Reference<XParametersSupplier>(m_xComposer,UNO_QUERY)->getParameters();
386cdf0e10cSrcweir }
387cdf0e10cSrcweir // -----------------------------------------------------------------------------
acquire()388cdf0e10cSrcweir void SAL_CALL OQueryComposer::acquire() throw()
389cdf0e10cSrcweir {
390cdf0e10cSrcweir 	OSubComponent::acquire();
391cdf0e10cSrcweir }
392cdf0e10cSrcweir // -----------------------------------------------------------------------------
release()393cdf0e10cSrcweir void SAL_CALL OQueryComposer::release() throw()
394cdf0e10cSrcweir {
395cdf0e10cSrcweir 	OSubComponent::release();
396cdf0e10cSrcweir }
397cdf0e10cSrcweir // -----------------------------------------------------------------------------
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 
403