1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _DBA_CORE_QUERYCONTAINER_HXX_
21 #define _DBA_CORE_QUERYCONTAINER_HXX_
23 #include <cppuhelper/implbase5.hxx>
24 #include <comphelper/stl_types.hxx>
25 #include <cppuhelper/interfacecontainer.hxx>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/container/XEnumerationAccess.hpp>
29 #include <com/sun/star/container/XContainerListener.hpp>
30 #include <com/sun/star/container/XNameContainer.hpp>
31 #include <com/sun/star/container/XNameAccess.hpp>
32 #include <com/sun/star/container/XIndexAccess.hpp>
33 #include <com/sun/star/container/XContainer.hpp>
34 #include <com/sun/star/util/XRefreshable.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/uno/Sequence.hxx>
37 #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
38 #include <com/sun/star/sdbcx/XAppend.hpp>
39 #include <com/sun/star/sdbcx/XDrop.hpp>
40 #include <com/sun/star/sdbc/XConnection.hpp>
41 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
42 #include <com/sun/star/container/XContainerApproveListener.hpp>
44 #include "definitioncontainer.hxx"
45 #include "apitools.hxx"
49 class IWarningsContainer
;
55 typedef ::cppu::ImplHelper5
< ::com::sun::star::container::XContainerListener
56 , ::com::sun::star::container::XContainerApproveListener
57 , ::com::sun::star::sdbcx::XDataDescriptorFactory
58 , ::com::sun::star::sdbcx::XAppend
59 , ::com::sun::star::sdbcx::XDrop
60 > OQueryContainer_Base
;
62 //==========================================================================
64 //==========================================================================
65 class OContainerListener
;
66 class OQueryContainer
: public ODefinitionContainer
67 , public OQueryContainer_Base
70 ::dbtools::IWarningsContainer
* m_pWarnings
;
71 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
>
72 m_xCommandDefinitions
;
73 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>
75 // possible actions on our "aggregate"
76 enum AGGREGATE_ACTION
{ NONE
, INSERTING
, FLUSHING
};
77 AGGREGATE_ACTION m_eDoingCurrently
;
79 OContainerListener
* m_pCommandsListener
;
81 /** a class which automatically resets m_eDoingCurrently in it's destructor
83 class OAutoActionReset
; // just for the following friend declaration
84 friend class OAutoActionReset
;
85 class OAutoActionReset
87 OQueryContainer
* m_pActor
;
89 OAutoActionReset(OQueryContainer
* _pActor
) : m_pActor(_pActor
) { }
90 ~OAutoActionReset() { m_pActor
->m_eDoingCurrently
= NONE
; }
93 // ODefinitionContainer
94 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XContent
> createObject( const ::rtl::OUString
& _rName
);
95 virtual sal_Bool
checkExistence(const ::rtl::OUString
& _rName
);
98 virtual void SAL_CALL
disposing();
99 virtual ~OQueryContainer();
101 /** ctor of the container. The parent has to support the <type scope="com::sun::star::sdbc">XConnection</type>
105 specifies a warnings container (May be <NULL/>)
107 Any errors which occur during the lifetime of the query container,
108 which cannot be reported as exceptionts (for instance in methods where throwing an SQLException is
109 not allowed) will be appended to this container.</p>
110 <p>The caller is responsible for ensuring the lifetime of the object pointed to by this parameter.
113 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
>& _rxCommandDefinitions
,
114 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConn
,
115 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxORB
,
116 ::dbtools::IWarningsContainer
* _pWarnings
119 DECLARE_XINTERFACE( )
120 DECLARE_XTYPEPROVIDER( )
121 DECLARE_SERVICE_INFO();
123 // ::com::sun::star::container::XContainerListener
124 virtual void SAL_CALL
elementInserted( const ::com::sun::star::container::ContainerEvent
& Event
) throw(::com::sun::star::uno::RuntimeException
);
125 virtual void SAL_CALL
elementRemoved( const ::com::sun::star::container::ContainerEvent
& Event
) throw(::com::sun::star::uno::RuntimeException
);
126 virtual void SAL_CALL
elementReplaced( const ::com::sun::star::container::ContainerEvent
& Event
) throw(::com::sun::star::uno::RuntimeException
);
128 // XContainerApproveListener
129 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
);
130 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
);
131 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
);
133 // ::com::sun::star::lang::XEventListener
134 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw(::com::sun::star::uno::RuntimeException
);
136 // ::com::sun::star::sdbcx::XDataDescriptorFactory
137 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> SAL_CALL
createDataDescriptor( ) throw(::com::sun::star::uno::RuntimeException
);
139 // ::com::sun::star::sdbcx::XAppend
140 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
);
142 // ::com::sun::star::sdbcx::XDrop
143 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
);
144 virtual void SAL_CALL
dropByIndex( sal_Int32 index
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
146 // ::com::sun::star::container::XElementAccess
147 virtual sal_Bool SAL_CALL
hasElements( ) throw(::com::sun::star::uno::RuntimeException
);
148 // ::com::sun::star::container::XIndexAccess
149 virtual sal_Int32 SAL_CALL
getCount( ) throw(::com::sun::star::uno::RuntimeException
);
150 // ::com::sun::star::container::XNameAccess
151 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames( ) throw(::com::sun::star::uno::RuntimeException
);
154 // OContentHelper overridables
155 virtual ::rtl::OUString
determineContentType() const;
159 /** create a query object wrapping a CommandDefinition given by name. To retrieve the object, the CommandDescription
160 container will be asked for the given name.<BR>
161 The returned object is acquired once.
163 ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XContent
> implCreateWrapper(const ::rtl::OUString
& _rName
);
164 /// create a query object wrapping a CommandDefinition. The returned object is acquired once.
165 ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XContent
> implCreateWrapper(const ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XContent
>& _rxCommandDesc
);
168 } // namespace dbaccess
170 #endif // _DBA_CORE_QUERYCONTAINER_HXX_
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */