Fix GNU C++ version check
[LibreOffice.git] / dbaccess / source / core / inc / querycontainer.hxx
bloba04a1ddf3d31954e5cc2e1fc3888f31f97684338
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
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"
38 namespace dbtools
40 class WarningsContainer;
43 namespace dbaccess
46 typedef ::cppu::ImplHelper5 < css::container::XContainerListener
47 , css::container::XContainerApproveListener
48 , css::sdbcx::XDataDescriptorFactory
49 , css::sdbcx::XAppend
50 , css::sdbcx::XDrop
51 > OQueryContainer_Base;
53 // OQueryContainer
54 class OQueryContainer : public ODefinitionContainer
55 , public OQueryContainer_Base
57 private:
58 ::dbtools::WarningsContainer* m_pWarnings;
59 css::uno::Reference< css::container::XNameContainer >
60 m_xCommandDefinitions;
61 css::uno::Reference< css::sdbc::XConnection >
62 m_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;
74 public:
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;
83 // helper
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>
88 interface.<BR>
90 @param _pWarnings
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.
98 OQueryContainer(
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
105 void init();
107 public:
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;
138 // css::sdbcx::XDrop
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;
149 private:
150 // OContentHelper overridables
151 virtual OUString determineContentType() const override;
153 // helper
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: */