merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / core / inc / querycontainer.hxx
blob1e56c4420f627a898dff1609237806703ba1643d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: querycontainer.hxx,v $
10 * $Revision: 1.15 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DBA_CORE_QUERYCONTAINER_HXX_
32 #define _DBA_CORE_QUERYCONTAINER_HXX_
34 #ifndef _CPPUHELPER_IMPLBASE5_HXX_
35 #include <cppuhelper/implbase5.hxx>
36 #endif
37 #ifndef _COMPHELPER_STLTYPES_HXX_
38 #include <comphelper/stl_types.hxx>
39 #endif
40 #ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
41 #include <cppuhelper/interfacecontainer.hxx>
42 #endif
44 /** === begin UNO includes == **/
45 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
46 #include <com/sun/star/beans/XPropertySet.hpp>
47 #endif
48 #ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_
49 #include <com/sun/star/container/XEnumerationAccess.hpp>
50 #endif
51 #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_
52 #include <com/sun/star/container/XContainerListener.hpp>
53 #endif
54 #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
55 #include <com/sun/star/container/XNameContainer.hpp>
56 #endif
57 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
58 #include <com/sun/star/container/XNameAccess.hpp>
59 #endif
60 #ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
61 #include <com/sun/star/container/XIndexAccess.hpp>
62 #endif
63 #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
64 #include <com/sun/star/container/XContainer.hpp>
65 #endif
66 #ifndef _COM_SUN_STAR_UTIL_XREFRESHABLE_HPP_
67 #include <com/sun/star/util/XRefreshable.hpp>
68 #endif
69 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
70 #include <com/sun/star/lang/XServiceInfo.hpp>
71 #endif
72 #ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
73 #include <com/sun/star/uno/Sequence.hxx>
74 #endif
75 #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
76 #include <com/sun/star/container/XNameContainer.hpp>
77 #endif
78 #ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
79 #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
80 #endif
81 #ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
82 #include <com/sun/star/sdbcx/XAppend.hpp>
83 #endif
84 #ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_
85 #include <com/sun/star/sdbcx/XDrop.hpp>
86 #endif
87 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
88 #include <com/sun/star/sdbc/XConnection.hpp>
89 #endif
90 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_
91 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
92 #endif
93 #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERAPPROVELISTENER_HPP_
94 #include <com/sun/star/container/XContainerApproveListener.hpp>
95 #endif
96 /** === end UNO includes === **/
98 #ifndef _DBA_CORE_DEFINITIONCONTAINER_HXX_
99 #include "definitioncontainer.hxx"
100 #endif
101 #ifndef _DBASHARED_APITOOLS_HXX_
102 #include "apitools.hxx"
103 #endif
105 namespace dbtools
107 class IWarningsContainer;
110 //........................................................................
111 namespace dbaccess
113 //........................................................................
115 typedef ::cppu::ImplHelper5 < ::com::sun::star::container::XContainerListener
116 , ::com::sun::star::container::XContainerApproveListener
117 , ::com::sun::star::sdbcx::XDataDescriptorFactory
118 , ::com::sun::star::sdbcx::XAppend
119 , ::com::sun::star::sdbcx::XDrop
120 > OQueryContainer_Base;
122 //==========================================================================
123 //= OQueryContainer
124 //==========================================================================
125 class OQueryContainer;
126 class OContainerListener;
127 class OQuery;
128 class OQueryContainer : public ODefinitionContainer
129 , public OQueryContainer_Base
131 protected:
132 ::dbtools::IWarningsContainer* m_pWarnings;
133 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
134 m_xCommandDefinitions;
135 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
136 m_xConnection;
137 // possible actions on our "aggregate"
138 enum AGGREGATE_ACTION { NONE, INSERTING, FLUSHING };
139 AGGREGATE_ACTION m_eDoingCurrently;
141 OContainerListener* m_pCommandsListener;
143 // ------------------------------------------------------------------------
144 /** a class which automatically resets m_eDoingCurrently in it's destructor
146 class OAutoActionReset; // just for the following friend declaration
147 friend class OAutoActionReset;
148 class OAutoActionReset
150 OQueryContainer* m_pActor;
151 public:
152 OAutoActionReset(OQueryContainer* _pActor) : m_pActor(_pActor) { }
153 ~OAutoActionReset() { m_pActor->m_eDoingCurrently = NONE; }
156 // ODefinitionContainer
157 virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > createObject( const ::rtl::OUString& _rName);
158 virtual sal_Bool checkExistence(const ::rtl::OUString& _rName);
160 // helper
161 virtual void SAL_CALL disposing();
162 virtual ~OQueryContainer();
163 public:
164 /** ctor of the container. The parent has to support the <type scope="com::sun::star::sdbc">XConnection</type>
165 interface.<BR>
167 @param _pWarnings
168 specifies a warnings container (May be <NULL/>)
170 Any errors which occur during the lifetime of the query container,
171 which cannot be reported as exceptionts (for instance in methods where throwing an SQLException is
172 not allowed) will be appended to this container.</p>
173 <p>The caller is responsible for ensuring the lifetime of the object pointed to by this parameter.
175 OQueryContainer(
176 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxCommandDefinitions,
177 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn,
178 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
179 ::dbtools::IWarningsContainer* _pWarnings
182 DECLARE_XINTERFACE( )
183 // ::com::sun::star::lang::XServiceInfo
184 DECLARE_SERVICE_INFO();
186 // ::com::sun::star::container::XContainerListener
187 virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
188 virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
189 virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
191 // XContainerApproveListener
192 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);
193 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);
194 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);
196 // ::com::sun::star::lang::XEventListener
197 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
199 // ::com::sun::star::sdbcx::XDataDescriptorFactory
200 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ) throw(::com::sun::star::uno::RuntimeException);
202 // ::com::sun::star::sdbcx::XAppend
203 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);
205 // ::com::sun::star::sdbcx::XDrop
206 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);
207 virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
209 // ::com::sun::star::container::XElementAccess
210 virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException);
211 // ::com::sun::star::container::XIndexAccess
212 virtual sal_Int32 SAL_CALL getCount( ) throw(::com::sun::star::uno::RuntimeException);
213 // ::com::sun::star::container::XNameAccess
214 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw(::com::sun::star::uno::RuntimeException);
216 protected:
217 // OContentHelper overridables
218 virtual ::rtl::OUString determineContentType() const;
220 private:
221 // helper
222 /** create a query object wrapping a CommandDefinition given by name. To retrieve the object, the CommandDescription
223 container will be asked for the given name.<BR>
224 The returned object is acquired once.
226 ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > implCreateWrapper(const ::rtl::OUString& _rName);
227 /// create a query object wrapping a CommandDefinition. The returned object is acquired once.
228 ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > implCreateWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _rxCommandDesc);
231 //........................................................................
232 } // namespace dbaccess
233 //........................................................................
235 #endif // _DBA_CORE_QUERYCONTAINER_HXX_