xref: /aoo41x/main/dbaccess/source/core/api/query.hxx (revision 2e2212a7)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _DBA_COREAPI_QUERY_HXX_
25 #define _DBA_COREAPI_QUERY_HXX_
26 
27 #ifndef _DBA_COREAPI_QUERYDESCRIPTOR_HXX_
28 #include "querydescriptor.hxx"
29 #endif
30 #ifndef _CPPUHELPER_IMPLBASE3_HXX_
31 #include <cppuhelper/implbase3.hxx>
32 #endif
33 #ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
34 #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
35 #endif
36 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_
37 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
40 #include <com/sun/star/sdbc/XConnection.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_
43 #include <com/sun/star/sdbcx/XRename.hpp>
44 #endif
45 #ifndef DBA_CONTENTHELPER_HXX
46 #include "ContentHelper.hxx"
47 #endif
48 
49 #include <map>
50 
51 namespace dbtools
52 {
53 	class IWarningsContainer;
54 }
55 
56 //........................................................................
57 namespace dbaccess
58 {
59 //........................................................................
60 
61 //==========================================================================
62 //= OQuery - an object implementing the sdb.Query service
63 //==========================================================================
64 typedef	::cppu::ImplHelper3	<	::com::sun::star::sdbcx::XDataDescriptorFactory,
65 								::com::sun::star::beans::XPropertyChangeListener,
66 								::com::sun::star::sdbcx::XRename
67 							>	OQuery_Base;
68 class OQuery;
69 class OColumn;
70 typedef ::comphelper::OPropertyArrayUsageHelper< OQuery >	OQuery_ArrayHelperBase;
71 
72 
73 class OQuery	:public OContentHelper
74 				,public OQueryDescriptor_Base
75 				,public OQuery_Base
76 				,public OQuery_ArrayHelperBase
77 				,public ODataSettings
78 {
79 	friend struct TRelease;
80 
81 public:
82 	typedef ::std::map< ::rtl::OUString,OColumn*,::comphelper::UStringMixLess> TNameColumnMap;
83 
84 protected:
85 //	TNameColumnMap		m_aColumnMap; // contains all columnnames to columns
86 	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >           m_xCommandDefinition;
87 	::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >             m_xConnection;
88 	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >       m_xCommandPropInfo;
89     ::rtl::Reference< OContainerMediator >                                              m_pColumnMediator;
90     ::dbtools::IWarningsContainer*                                                      m_pWarnings;
91 	sal_Bool			                                                                m_bCaseSensitiv : 1;		// assume case sensitivity of the column names ?
92 
93 	// possible actions on our "aggregate"
94 	enum AGGREGATE_ACTION { NONE, SETTING_PROPERTIES, FLUSHING };
95 	AGGREGATE_ACTION	m_eDoingCurrently;
96 
97 	// ------------------------------------------------------------------------
98 	/** a class which automatically resets m_eDoingCurrently in it's destructor
99 	*/
100 	class OAutoActionReset;	// just for the following friend declaration
101 	friend class OAutoActionReset;
102 	class OAutoActionReset
103 	{
104 		OQuery*				m_pActor;
105 	public:
OAutoActionReset(OQuery * _pActor)106 		OAutoActionReset(OQuery* _pActor) : m_pActor(_pActor) { }
~OAutoActionReset()107 		~OAutoActionReset() { m_pActor->m_eDoingCurrently = NONE; }
108 	};
109 
110 protected:
111 	virtual ~OQuery();
112 
113 // OPropertyArrayUsageHelper
114 	virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
getArrayHelper()115 	::cppu::IPropertyArrayHelper*	getArrayHelper() { return OQuery_ArrayHelperBase::getArrayHelper(); }
116 
117 public:
118 	OQuery(
119 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxCommandDefinition,
120 			const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn,
121 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
122 		);
123 
124 // com::sun::star::lang::XTypeProvider
125 	DECLARE_TYPEPROVIDER( );
126 
127 // ::com::sun::star::uno::XInterface
128 	DECLARE_XINTERFACE( )
129 
130 // ::com::sun::star::beans::XPropertySet
131 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
132 
133 // OPropertySetHelper
134 	virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
135 
136 // ::com::sun::star::lang::XServiceInfo
137 	DECLARE_SERVICE_INFO();
138 
139 // ::com::sun::star::sdbcx::XDataDescriptorFactory
140 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor(  ) throw(::com::sun::star::uno::RuntimeException);
141 
142 // ::com::sun::star::beans::XPropertyChangeListener
143     virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
144 
145 // ::com::sun::star::lang::XEventListener
146         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException);
147 
148 // OPropertySetHelper
149 	virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
150 					sal_Int32 nHandle,
151 					const ::com::sun::star::uno::Any& rValue )
152 			throw (::com::sun::star::uno::Exception);
153 
154 public:
155 	// the caller is responsible for the lifetime!
setWarningsContainer(::dbtools::IWarningsContainer * _pWarnings)156     void				            setWarningsContainer( ::dbtools::IWarningsContainer* _pWarnings )	{ m_pWarnings = _pWarnings; }
getWarningsContainer() const157     ::dbtools::IWarningsContainer*  getWarningsContainer( )	const                                       { return m_pWarnings; }
158 
159 	// XRename
160 	virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
161 
162 protected:
163 	virtual void SAL_CALL disposing();
164 
165 	virtual OColumn* createColumn(const ::rtl::OUString& _rName) const;
166 
167 	virtual void rebuildColumns( );
168 
169     // OContentHelper overridables
170     virtual ::rtl::OUString determineContentType() const;
171 
172 private:
173 	void registerProperties();
174 };
175 
176 //........................................................................
177 }	// namespace dbaccess
178 //........................................................................
179 
180 #endif // _DBA_COREAPI_QUERY_HXX_
181 
182 
183