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 .
22 #include <cppuhelper/implbase5.hxx>
23 #include <connectivity/CommonTools.hxx>
24 #include <rtl/ref.hxx>
26 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <com/sun/star/container/XContainerListener.hpp>
28 #include <com/sun/star/container/XNameContainer.hpp>
29 #include <com/sun/star/uno/Sequence.hxx>
30 #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
31 #include <com/sun/star/sdbcx/XAppend.hpp>
32 #include <com/sun/star/sdbcx/XDrop.hpp>
33 #include <com/sun/star/sdbc/XConnection.hpp>
34 #include <com/sun/star/container/XContainerApproveListener.hpp>
36 #include "definitioncontainer.hxx"
40 class WarningsContainer
;
46 typedef ::cppu::ImplHelper5
< css::container::XContainerListener
47 , css::container::XContainerApproveListener
48 , css::sdbcx::XDataDescriptorFactory
51 > OQueryContainer_Base
;
54 class OQueryContainer
: public ODefinitionContainer
55 , public OQueryContainer_Base
58 ::dbtools::WarningsContainer
* m_pWarnings
;
59 css::uno::Reference
< css::container::XNameContainer
>
60 m_xCommandDefinitions
;
61 css::uno::Reference
< css::sdbc::XConnection
>
63 // possible actions on our "aggregate"
64 enum class AggregateAction
{ NONE
, Inserting
};
65 AggregateAction m_eDoingCurrently
;
67 /** a class which automatically resets m_eDoingCurrently in its destructor
69 class OAutoActionReset
; // just for the following friend declaration
70 friend class OAutoActionReset
;
71 class OAutoActionReset
73 OQueryContainer
& m_rActor
;
75 OAutoActionReset(OQueryContainer
& _rActor
) : m_rActor(_rActor
) { }
76 ~OAutoActionReset() { m_rActor
.m_eDoingCurrently
= AggregateAction::NONE
; }
79 // ODefinitionContainer
80 virtual css::uno::Reference
< css::ucb::XContent
> createObject( const OUString
& _rName
) override
;
81 virtual bool checkExistence(const OUString
& _rName
) override
;
84 virtual void SAL_CALL
disposing() override
;
85 virtual ~OQueryContainer() override
;
87 /** ctor of the container. The parent has to support the <type scope="css::sdbc">XConnection</type>
91 specifies a warnings container (May be <NULL/>)
93 Any errors which occur during the lifetime of the query container,
94 which cannot be reported as exceptions (for instance in methods where throwing an SQLException is
95 not allowed) will be appended to this container.</p>
96 <p>The caller is responsible for ensuring the lifetime of the object pointed to by this parameter.
99 const css::uno::Reference
< css::container::XNameContainer
>& _rxCommandDefinitions
,
100 const css::uno::Reference
< css::sdbc::XConnection
>& _rxConn
,
101 const css::uno::Reference
< css::uno::XComponentContext
>& _rxORB
,
102 ::dbtools::WarningsContainer
* _pWarnings
108 static rtl::Reference
<OQueryContainer
> create(
109 const css::uno::Reference
< css::container::XNameContainer
>& _rxCommandDefinitions
,
110 const css::uno::Reference
< css::sdbc::XConnection
>& _rxConn
,
111 const css::uno::Reference
< css::uno::XComponentContext
>& _rxORB
,
112 ::dbtools::WarningsContainer
* _pWarnings
115 DECLARE_XINTERFACE( )
116 DECLARE_XTYPEPROVIDER( )
117 DECLARE_SERVICE_INFO();
119 // css::container::XContainerListener
120 virtual void SAL_CALL
elementInserted( const css::container::ContainerEvent
& Event
) override
;
121 virtual void SAL_CALL
elementRemoved( const css::container::ContainerEvent
& Event
) override
;
122 virtual void SAL_CALL
elementReplaced( const css::container::ContainerEvent
& Event
) override
;
124 // XContainerApproveListener
125 virtual css::uno::Reference
< css::util::XVeto
> SAL_CALL
approveInsertElement( const css::container::ContainerEvent
& Event
) override
;
126 virtual css::uno::Reference
< css::util::XVeto
> SAL_CALL
approveReplaceElement( const css::container::ContainerEvent
& Event
) override
;
127 virtual css::uno::Reference
< css::util::XVeto
> SAL_CALL
approveRemoveElement( const css::container::ContainerEvent
& Event
) override
;
129 // css::lang::XEventListener
130 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
132 // css::sdbcx::XDataDescriptorFactory
133 virtual css::uno::Reference
< css::beans::XPropertySet
> SAL_CALL
createDataDescriptor( ) override
;
135 // css::sdbcx::XAppend
136 virtual void SAL_CALL
appendByDescriptor( const css::uno::Reference
< css::beans::XPropertySet
>& descriptor
) override
;
139 virtual void SAL_CALL
dropByName( const OUString
& elementName
) override
;
140 virtual void SAL_CALL
dropByIndex( sal_Int32 index
) override
;
142 // css::container::XElementAccess
143 virtual sal_Bool SAL_CALL
hasElements( ) override
;
144 // css::container::XIndexAccess
145 virtual sal_Int32 SAL_CALL
getCount( ) override
;
146 // css::container::XNameAccess
147 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) override
;
150 // OContentHelper overridables
151 virtual OUString
determineContentType() const override
;
154 /** create a query object wrapping a CommandDefinition given by name. To retrieve the object, the CommandDescription
155 container will be asked for the given name.<BR>
156 The returned object is acquired once.
158 css::uno::Reference
< css::ucb::XContent
> implCreateWrapper(const OUString
& _rName
);
159 /// create a query object wrapping a CommandDefinition. The returned object is acquired once.
160 css::uno::Reference
< css::ucb::XContent
> implCreateWrapper(const css::uno::Reference
< css::ucb::XContent
>& _rxCommandDesc
);
163 } // namespace dbaccess
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */