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 INCLUDED_DBACCESS_SOURCE_CORE_INC_QUERYCONTAINER_HXX
21 #define INCLUDED_DBACCESS_SOURCE_CORE_INC_QUERYCONTAINER_HXX
23 #include <cppuhelper/implbase5.hxx>
24 #include <cppuhelper/interfacecontainer.hxx>
26 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <com/sun/star/container/XEnumerationAccess.hpp>
28 #include <com/sun/star/container/XContainerListener.hpp>
29 #include <com/sun/star/container/XNameContainer.hpp>
30 #include <com/sun/star/container/XNameAccess.hpp>
31 #include <com/sun/star/container/XIndexAccess.hpp>
32 #include <com/sun/star/container/XContainer.hpp>
33 #include <com/sun/star/util/XRefreshable.hpp>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/uno/Sequence.hxx>
36 #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
37 #include <com/sun/star/sdbcx/XAppend.hpp>
38 #include <com/sun/star/sdbcx/XDrop.hpp>
39 #include <com/sun/star/sdbc/XConnection.hpp>
40 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
41 #include <com/sun/star/container/XContainerApproveListener.hpp>
43 #include "definitioncontainer.hxx"
44 #include "apitools.hxx"
48 class WarningsContainer
;
54 typedef ::cppu::ImplHelper5
< css::container::XContainerListener
55 , css::container::XContainerApproveListener
56 , css::sdbcx::XDataDescriptorFactory
59 > OQueryContainer_Base
;
62 class OQueryContainer
: public ODefinitionContainer
63 , public OQueryContainer_Base
66 ::dbtools::WarningsContainer
* m_pWarnings
;
67 css::uno::Reference
< css::container::XNameContainer
>
68 m_xCommandDefinitions
;
69 css::uno::Reference
< css::sdbc::XConnection
>
71 // possible actions on our "aggregate"
72 enum AGGREGATE_ACTION
{ NONE
, INSERTING
, FLUSHING
};
73 AGGREGATE_ACTION m_eDoingCurrently
;
75 /** a class which automatically resets m_eDoingCurrently in its destructor
77 class OAutoActionReset
; // just for the following friend declaration
78 friend class OAutoActionReset
;
79 class OAutoActionReset
81 OQueryContainer
* m_pActor
;
83 OAutoActionReset(OQueryContainer
* _pActor
) : m_pActor(_pActor
) { }
84 ~OAutoActionReset() { m_pActor
->m_eDoingCurrently
= NONE
; }
87 // ODefinitionContainer
88 virtual css::uno::Reference
< css::ucb::XContent
> createObject( const OUString
& _rName
) override
;
89 virtual bool checkExistence(const OUString
& _rName
) override
;
92 virtual void SAL_CALL
disposing() override
;
93 virtual ~OQueryContainer() override
;
95 /** ctor of the container. The parent has to support the <type scope="css::sdbc">XConnection</type>
99 specifies a warnings container (May be <NULL/>)
101 Any errors which occur during the lifetime of the query container,
102 which cannot be reported as exceptions (for instance in methods where throwing an SQLException is
103 not allowed) will be appended to this container.</p>
104 <p>The caller is responsible for ensuring the lifetime of the object pointed to by this parameter.
107 const css::uno::Reference
< css::container::XNameContainer
>& _rxCommandDefinitions
,
108 const css::uno::Reference
< css::sdbc::XConnection
>& _rxConn
,
109 const css::uno::Reference
< css::uno::XComponentContext
>& _rxORB
,
110 ::dbtools::WarningsContainer
* _pWarnings
116 static rtl::Reference
<OQueryContainer
> create(
117 const css::uno::Reference
< css::container::XNameContainer
>& _rxCommandDefinitions
,
118 const css::uno::Reference
< css::sdbc::XConnection
>& _rxConn
,
119 const css::uno::Reference
< css::uno::XComponentContext
>& _rxORB
,
120 ::dbtools::WarningsContainer
* _pWarnings
123 DECLARE_XINTERFACE( )
124 DECLARE_XTYPEPROVIDER( )
125 DECLARE_SERVICE_INFO();
127 // css::container::XContainerListener
128 virtual void SAL_CALL
elementInserted( const css::container::ContainerEvent
& Event
) throw(css::uno::RuntimeException
, std::exception
) override
;
129 virtual void SAL_CALL
elementRemoved( const css::container::ContainerEvent
& Event
) throw(css::uno::RuntimeException
, std::exception
) override
;
130 virtual void SAL_CALL
elementReplaced( const css::container::ContainerEvent
& Event
) throw(css::uno::RuntimeException
, std::exception
) override
;
132 // XContainerApproveListener
133 virtual css::uno::Reference
< css::util::XVeto
> SAL_CALL
approveInsertElement( const css::container::ContainerEvent
& Event
) throw (css::lang::WrappedTargetException
, css::uno::RuntimeException
, std::exception
) override
;
134 virtual css::uno::Reference
< css::util::XVeto
> SAL_CALL
approveReplaceElement( const css::container::ContainerEvent
& Event
) throw (css::lang::WrappedTargetException
, css::uno::RuntimeException
, std::exception
) override
;
135 virtual css::uno::Reference
< css::util::XVeto
> SAL_CALL
approveRemoveElement( const css::container::ContainerEvent
& Event
) throw (css::lang::WrappedTargetException
, css::uno::RuntimeException
, std::exception
) override
;
137 // css::lang::XEventListener
138 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) throw(css::uno::RuntimeException
, std::exception
) override
;
140 // css::sdbcx::XDataDescriptorFactory
141 virtual css::uno::Reference
< css::beans::XPropertySet
> SAL_CALL
createDataDescriptor( ) throw(css::uno::RuntimeException
, std::exception
) override
;
143 // css::sdbcx::XAppend
144 virtual void SAL_CALL
appendByDescriptor( const css::uno::Reference
< css::beans::XPropertySet
>& descriptor
) throw(css::sdbc::SQLException
, css::container::ElementExistException
, css::uno::RuntimeException
, std::exception
) override
;
147 virtual void SAL_CALL
dropByName( const OUString
& elementName
) throw(css::sdbc::SQLException
, css::container::NoSuchElementException
, css::uno::RuntimeException
, std::exception
) override
;
148 virtual void SAL_CALL
dropByIndex( sal_Int32 index
) throw(css::sdbc::SQLException
, css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
150 // css::container::XElementAccess
151 virtual sal_Bool SAL_CALL
hasElements( ) throw(css::uno::RuntimeException
, std::exception
) override
;
152 // css::container::XIndexAccess
153 virtual sal_Int32 SAL_CALL
getCount( ) throw(css::uno::RuntimeException
, std::exception
) override
;
154 // css::container::XNameAccess
155 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) throw(css::uno::RuntimeException
, std::exception
) override
;
158 // OContentHelper overridables
159 virtual OUString
determineContentType() const override
;
162 /** create a query object wrapping a CommandDefinition given by name. To retrieve the object, the CommandDescription
163 container will be asked for the given name.<BR>
164 The returned object is acquired once.
166 css::uno::Reference
< css::ucb::XContent
> implCreateWrapper(const OUString
& _rName
);
167 /// create a query object wrapping a CommandDefinition. The returned object is acquired once.
168 css::uno::Reference
< css::ucb::XContent
> implCreateWrapper(const css::uno::Reference
< css::ucb::XContent
>& _rxCommandDesc
);
171 } // namespace dbaccess
173 #endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_QUERYCONTAINER_HXX
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */