1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2e2212a7SAndrew Rist  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2e2212a7SAndrew Rist  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19*2e2212a7SAndrew Rist  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _DBA_CORE_QUERYCONTAINER_HXX_
25cdf0e10cSrcweir #define _DBA_CORE_QUERYCONTAINER_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _CPPUHELPER_IMPLBASE5_HXX_
28cdf0e10cSrcweir #include <cppuhelper/implbase5.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _COMPHELPER_STLTYPES_HXX_
31cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
34cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir 
37cdf0e10cSrcweir /** === begin UNO includes == **/
38cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
39cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_
42cdf0e10cSrcweir #include <com/sun/star/container/XEnumerationAccess.hpp>
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_
45cdf0e10cSrcweir #include <com/sun/star/container/XContainerListener.hpp>
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
48cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
51cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
54cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
57cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp>
58cdf0e10cSrcweir #endif
59cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XREFRESHABLE_HPP_
60cdf0e10cSrcweir #include <com/sun/star/util/XRefreshable.hpp>
61cdf0e10cSrcweir #endif
62cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
63cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
64cdf0e10cSrcweir #endif
65cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
66cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
67cdf0e10cSrcweir #endif
68cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
69cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
70cdf0e10cSrcweir #endif
71cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
72cdf0e10cSrcweir #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
73cdf0e10cSrcweir #endif
74cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
75cdf0e10cSrcweir #include <com/sun/star/sdbcx/XAppend.hpp>
76cdf0e10cSrcweir #endif
77cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_
78cdf0e10cSrcweir #include <com/sun/star/sdbcx/XDrop.hpp>
79cdf0e10cSrcweir #endif
80cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
81cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp>
82cdf0e10cSrcweir #endif
83cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_
84cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyChangeListener.hpp>
85cdf0e10cSrcweir #endif
86cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERAPPROVELISTENER_HPP_
87cdf0e10cSrcweir #include <com/sun/star/container/XContainerApproveListener.hpp>
88cdf0e10cSrcweir #endif
89cdf0e10cSrcweir /** === end UNO includes === **/
90cdf0e10cSrcweir 
91cdf0e10cSrcweir #ifndef _DBA_CORE_DEFINITIONCONTAINER_HXX_
92cdf0e10cSrcweir #include "definitioncontainer.hxx"
93cdf0e10cSrcweir #endif
94cdf0e10cSrcweir #ifndef _DBASHARED_APITOOLS_HXX_
95cdf0e10cSrcweir #include "apitools.hxx"
96cdf0e10cSrcweir #endif
97cdf0e10cSrcweir 
98cdf0e10cSrcweir namespace dbtools
99cdf0e10cSrcweir {
100cdf0e10cSrcweir 	class IWarningsContainer;
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir //........................................................................
104cdf0e10cSrcweir namespace dbaccess
105cdf0e10cSrcweir {
106cdf0e10cSrcweir //........................................................................
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	typedef ::cppu::ImplHelper5 <   ::com::sun::star::container::XContainerListener
109cdf0e10cSrcweir                                 ,   ::com::sun::star::container::XContainerApproveListener
110cdf0e10cSrcweir                                 ,   ::com::sun::star::sdbcx::XDataDescriptorFactory
111cdf0e10cSrcweir                                 ,   ::com::sun::star::sdbcx::XAppend
112cdf0e10cSrcweir                                 ,   ::com::sun::star::sdbcx::XDrop
113cdf0e10cSrcweir                                 >   OQueryContainer_Base;
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 	//==========================================================================
116cdf0e10cSrcweir 	//= OQueryContainer
117cdf0e10cSrcweir 	//==========================================================================
118cdf0e10cSrcweir 	class OQueryContainer;
119cdf0e10cSrcweir     class OContainerListener;
120cdf0e10cSrcweir 	class OQuery;
121cdf0e10cSrcweir 	class OQueryContainer	: public ODefinitionContainer
122cdf0e10cSrcweir 							, public OQueryContainer_Base
123cdf0e10cSrcweir 	{
124cdf0e10cSrcweir 	protected:
125cdf0e10cSrcweir         ::dbtools::IWarningsContainer*  m_pWarnings;
126cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
127cdf0e10cSrcweir                                         m_xCommandDefinitions;
128cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
129cdf0e10cSrcweir                                         m_xConnection;
130cdf0e10cSrcweir 		// possible actions on our "aggregate"
131cdf0e10cSrcweir 		enum AGGREGATE_ACTION { NONE, INSERTING, FLUSHING };
132cdf0e10cSrcweir 		AGGREGATE_ACTION		m_eDoingCurrently;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 		OContainerListener*     m_pCommandsListener;
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 		// ------------------------------------------------------------------------
137cdf0e10cSrcweir 		/** a class which automatically resets m_eDoingCurrently in it's destructor
138cdf0e10cSrcweir 		*/
139cdf0e10cSrcweir 		class OAutoActionReset;	// just for the following friend declaration
140cdf0e10cSrcweir 		friend class OAutoActionReset;
141cdf0e10cSrcweir 		class OAutoActionReset
142cdf0e10cSrcweir 		{
143cdf0e10cSrcweir 			OQueryContainer*		m_pActor;
144cdf0e10cSrcweir 		public:
OAutoActionReset(OQueryContainer * _pActor)145cdf0e10cSrcweir 			OAutoActionReset(OQueryContainer* _pActor) : m_pActor(_pActor) { }
~OAutoActionReset()146cdf0e10cSrcweir 			~OAutoActionReset() { m_pActor->m_eDoingCurrently = NONE; }
147cdf0e10cSrcweir 		};
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 		// ODefinitionContainer
150cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > createObject( const ::rtl::OUString& _rName);
151cdf0e10cSrcweir 		virtual	sal_Bool checkExistence(const ::rtl::OUString& _rName);
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 		// helper
154cdf0e10cSrcweir 		virtual void SAL_CALL disposing();
155cdf0e10cSrcweir 		virtual ~OQueryContainer();
156cdf0e10cSrcweir 	public:
157cdf0e10cSrcweir 		/** ctor of the container. The parent has to support the <type scope="com::sun::star::sdbc">XConnection</type>
158cdf0e10cSrcweir 			interface.<BR>
159cdf0e10cSrcweir 
160cdf0e10cSrcweir             @param _pWarnings
161cdf0e10cSrcweir 				specifies a warnings container (May be <NULL/>)
162cdf0e10cSrcweir 
163cdf0e10cSrcweir                 Any errors which occur during the lifetime of the query container,
164cdf0e10cSrcweir 				which cannot be reported as exceptionts (for instance in methods where throwing an SQLException is
165cdf0e10cSrcweir 				not allowed) will be appended to this container.</p>
166cdf0e10cSrcweir 				<p>The caller is responsible for ensuring the lifetime of the object pointed to by this parameter.
167cdf0e10cSrcweir 		*/
168cdf0e10cSrcweir 		OQueryContainer(
169cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxCommandDefinitions,
170cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn,
171cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
172cdf0e10cSrcweir 			::dbtools::IWarningsContainer* _pWarnings
173cdf0e10cSrcweir 			);
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 		DECLARE_XINTERFACE( )
176cdf0e10cSrcweir 		DECLARE_XTYPEPROVIDER( )
177cdf0e10cSrcweir 		DECLARE_SERVICE_INFO();
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	// ::com::sun::star::container::XContainerListener
180cdf0e10cSrcweir 		virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
181cdf0e10cSrcweir 		virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
182cdf0e10cSrcweir 		virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
183cdf0e10cSrcweir 
184cdf0e10cSrcweir         // XContainerApproveListener
185cdf0e10cSrcweir         virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveInsertElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
186cdf0e10cSrcweir         virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveReplaceElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
187cdf0e10cSrcweir         virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveRemoveElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 	// ::com::sun::star::lang::XEventListener
190cdf0e10cSrcweir 		virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 	// ::com::sun::star::sdbcx::XDataDescriptorFactory
193cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor(  ) throw(::com::sun::star::uno::RuntimeException);
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 	// ::com::sun::star::sdbcx::XAppend
196cdf0e10cSrcweir 		virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 	// ::com::sun::star::sdbcx::XDrop
199cdf0e10cSrcweir 		virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
200cdf0e10cSrcweir 		virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 	// ::com::sun::star::container::XElementAccess
203cdf0e10cSrcweir 		virtual sal_Bool SAL_CALL hasElements(  ) throw(::com::sun::star::uno::RuntimeException);
204cdf0e10cSrcweir 	// ::com::sun::star::container::XIndexAccess
205cdf0e10cSrcweir 		virtual sal_Int32 SAL_CALL getCount(  ) throw(::com::sun::star::uno::RuntimeException);
206cdf0e10cSrcweir 	// ::com::sun::star::container::XNameAccess
207cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw(::com::sun::star::uno::RuntimeException);
208cdf0e10cSrcweir 
209cdf0e10cSrcweir     protected:
210cdf0e10cSrcweir         // OContentHelper overridables
211cdf0e10cSrcweir         virtual ::rtl::OUString determineContentType() const;
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 	private:
214cdf0e10cSrcweir 		// helper
215cdf0e10cSrcweir 		/** create a query object wrapping a CommandDefinition given by name. To retrieve the object, the CommandDescription
216cdf0e10cSrcweir 			container will be asked for the given name.<BR>
217cdf0e10cSrcweir 			The returned object is acquired once.
218cdf0e10cSrcweir 		*/
219cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > implCreateWrapper(const ::rtl::OUString& _rName);
220cdf0e10cSrcweir 		/// create a query object wrapping a CommandDefinition. The returned object is acquired once.
221cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > implCreateWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _rxCommandDesc);
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 	};
224cdf0e10cSrcweir //........................................................................
225cdf0e10cSrcweir }	// namespace dbaccess
226cdf0e10cSrcweir //........................................................................
227cdf0e10cSrcweir 
228cdf0e10cSrcweir #endif // _DBA_CORE_QUERYCONTAINER_HXX_
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 
231