bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / connectivity / paramwrapper.hxx
blob4a68c61dd6789dfd5216e71fc6cacd12bb9b2217
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 #ifndef INCLUDED_CONNECTIVITY_PARAMWRAPPER_HXX
21 #define INCLUDED_CONNECTIVITY_PARAMWRAPPER_HXX
23 #include <connectivity/dbtoolsdllapi.hxx>
24 #include <connectivity/FValue.hxx>
26 #include <com/sun/star/container/XIndexAccess.hpp>
27 #include <com/sun/star/container/XEnumerationAccess.hpp>
29 #include <comphelper/uno3.hxx>
30 #include <comphelper/broadcasthelper.hxx>
31 #include <cppuhelper/weak.hxx>
32 #include <cppuhelper/propshlp.hxx>
33 #include <cppuhelper/compbase.hxx>
35 #include <memory>
36 #include <vector>
38 namespace com::sun::star::sdbc { class XParameters; }
39 namespace com::sun::star::sdb { class XSingleSelectQueryAnalyzer; }
42 namespace dbtools
44 namespace param
48 //= ParameterWrapper
50 /** wraps a parameter column as got from an SQLQueryComposer, so that it has an additional
51 property "Value", which is forwarded to an XParameters interface
53 class OOO_DLLPUBLIC_DBTOOLS ParameterWrapper :public ::cppu::OWeakObject
54 ,public css::lang::XTypeProvider
55 ,public ::comphelper::OMutexAndBroadcastHelper
56 ,public ::cppu::OPropertySetHelper
58 private:
59 typedef ::cppu::OWeakObject UnoBase;
60 typedef ::cppu::OPropertySetHelper PropertyBase;
62 private:
63 /// the most recently set value of the parameter
64 ::connectivity::ORowSetValue m_aValue;
65 /// the positions (in our m_xValueDestination) at which the value should be set (0-based!)
66 ::std::vector< sal_Int32 > m_aIndexes;
68 /// the "delegator" column to which standard property requests are forwarded
69 css::uno::Reference< css::beans::XPropertySet > m_xDelegator;
70 /// the property set info for our delegator
71 css::uno::Reference< css::beans::XPropertySetInfo > m_xDelegatorPSI;
72 /// the component taking the value
73 css::uno::Reference< css::sdbc::XParameters > m_xValueDestination;
74 /// helper for implementing XPropertySetInfo
75 ::std::unique_ptr< ::cppu::OPropertyArrayHelper > m_pInfoHelper;
78 public:
79 const ::connectivity::ORowSetValue& Value() const { return m_aValue; }
80 ::connectivity::ORowSetValue& Value() { return m_aValue; }
82 public:
83 ParameterWrapper(
84 const css::uno::Reference< css::beans::XPropertySet >& _rxColumn
87 ParameterWrapper(
88 const css::uno::Reference< css::beans::XPropertySet >& _rxColumn,
89 const css::uno::Reference< css::sdbc::XParameters >& _rxAllParameters,
90 const ::std::vector< sal_Int32 >& _rIndexes
93 DECLARE_XINTERFACE()
95 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
96 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
98 // XPropertySet
99 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
100 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
102 // OPropertySetHelper
103 virtual sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any& rConvertedValue, css::uno::Any& rOldValue, sal_Int32 nHandle, const css::uno::Any& rValue) override;
104 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override;
105 virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override;
107 // pseudo-XComponent
108 void dispose();
110 protected:
111 virtual ~ParameterWrapper() override;
113 // disambiguations
114 using ::cppu::OPropertySetHelper::getFastPropertyValue;
116 private:
117 OUString impl_getPseudoAggregatePropertyName( sal_Int32 _nHandle ) const;
121 //= ParameterWrapper
123 typedef ::std::vector< ::rtl::Reference< ParameterWrapper > > Parameters;
126 //= ParameterWrapperContainer
128 typedef ::cppu::WeakComponentImplHelper < css::container::XIndexAccess
129 , css::container::XEnumerationAccess
130 > ParameterWrapperContainer_Base;
132 /// class for the parameter event @see approveParameter
133 class OOO_DLLPUBLIC_DBTOOLS ParameterWrapperContainer :
134 public ParameterWrapperContainer_Base
136 private:
137 ::osl::Mutex m_aMutex;
138 Parameters m_aParameters;
140 protected:
141 virtual ~ParameterWrapperContainer() override;
143 public:
144 /** creates an empty container
146 ParameterWrapperContainer();
148 /** creates a container from a SingleSelectQuerAnalyzer's parameter columns
150 Note that here, the simple constructor of the ParameterWrapper will be used, which does not
151 use a XParameters instance to forward values to, but only remembers the values itself.
153 ParameterWrapperContainer( const css::uno::Reference< css::sdb::XSingleSelectQueryAnalyzer >& _rxComposer );
155 // css::container::XElementAccess
156 virtual css::uno::Type SAL_CALL getElementType() override;
157 virtual sal_Bool SAL_CALL hasElements() override;
159 // css::container::XEnumerationAccess
160 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
162 // css::container::XIndexAccess
163 virtual sal_Int32 SAL_CALL getCount() override;
164 virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 _rIndex) override;
166 public:
167 const Parameters& getParameters() { return m_aParameters; }
169 const ::connectivity::ORowSetValue& operator[]( size_t _index ) const { return m_aParameters[ _index ]->Value(); }
170 ::connectivity::ORowSetValue& operator[]( size_t _index ) { return m_aParameters[ _index ]->Value(); }
172 /** adds an ParameterWrapper to the end of the array
174 void push_back( ParameterWrapper* _pParameter )
176 m_aParameters.push_back( _pParameter );
179 size_t size() const { return m_aParameters.size(); }
181 protected:
182 // XComponent
183 virtual void SAL_CALL disposing() override;
185 private:
186 void impl_checkDisposed_throw();
190 //= ParametersContainer
192 typedef ::rtl::Reference< ParameterWrapperContainer > ParametersContainerRef;
195 } } // namespace dbtools::param
198 #endif // INCLUDED_CONNECTIVITY_PARAMWRAPPER_HXX
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */