LibreOffice Module connectivity (master) 1
paramwrapper.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_CONNECTIVITY_PARAMWRAPPER_HXX
21#define INCLUDED_CONNECTIVITY_PARAMWRAPPER_HXX
22
23#include <config_options.h>
26
27#include <com/sun/star/container/XIndexAccess.hpp>
28#include <com/sun/star/container/XEnumerationAccess.hpp>
29
30#include <comphelper/uno3.hxx>
32#include <cppuhelper/weak.hxx>
35
36#include <memory>
37#include <vector>
38
39namespace com::sun::star::sdbc { class XParameters; }
40namespace com::sun::star::sdb { class XSingleSelectQueryAnalyzer; }
41
42
43namespace dbtools::param
44{
45
46
47 //= ParameterWrapper
48
53 ,public css::lang::XTypeProvider
56 {
57 private:
60
61 private:
65 ::std::vector< sal_Int32 > m_aIndexes;
66
68 css::uno::Reference< css::beans::XPropertySet > m_xDelegator;
70 css::uno::Reference< css::beans::XPropertySetInfo > m_xDelegatorPSI;
72 css::uno::Reference< css::sdbc::XParameters > m_xValueDestination;
74 ::std::unique_ptr< ::cppu::OPropertyArrayHelper > m_pInfoHelper;
75
76
77 public:
78 const ::connectivity::ORowSetValue& Value() const { return m_aValue; }
79 ::connectivity::ORowSetValue& Value() { return m_aValue; }
80
81 public:
83 const css::uno::Reference< css::beans::XPropertySet >& _rxColumn
84 );
85
87 const css::uno::Reference< css::beans::XPropertySet >& _rxColumn,
88 const css::uno::Reference< css::sdbc::XParameters >& _rxAllParameters,
89 std::vector< sal_Int32 >&& _rIndexes
90 );
91
93
94 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
95 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
96
97 // XPropertySet
98 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
99 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
100
101 // OPropertySetHelper
102 virtual sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any& rConvertedValue, css::uno::Any& rOldValue, sal_Int32 nHandle, const css::uno::Any& rValue) override;
103 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override;
104 virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override;
105
106 // pseudo-XComponent
107 void dispose();
108
109 private:
110 virtual ~ParameterWrapper() override;
111
112 // disambiguations
113 using ::cppu::OPropertySetHelper::getFastPropertyValue;
114
115 OUString impl_getPseudoAggregatePropertyName( sal_Int32 _nHandle ) const;
116 };
117
118
119 //= ParameterWrapper
120
121 typedef ::std::vector< ::rtl::Reference< ParameterWrapper > > Parameters;
122
123
124 //= ParameterWrapperContainer
125
126 typedef ::comphelper::WeakComponentImplHelper < css::container::XIndexAccess
127 , css::container::XEnumerationAccess
129
133 {
134 private:
136
137 virtual ~ParameterWrapperContainer() override;
138
139 public:
143
149 ParameterWrapperContainer( const css::uno::Reference< css::sdb::XSingleSelectQueryAnalyzer >& _rxComposer );
150
151 // css::container::XElementAccess
152 virtual css::uno::Type SAL_CALL getElementType() override;
153 virtual sal_Bool SAL_CALL hasElements() override;
154
155 // css::container::XEnumerationAccess
156 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
157
158 // css::container::XIndexAccess
159 virtual sal_Int32 SAL_CALL getCount() override;
160 virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 _rIndex) override;
161
162 public:
163 const Parameters& getParameters() const { return m_aParameters; }
164
165 const ::connectivity::ORowSetValue& operator[]( size_t _index ) const { return m_aParameters[ _index ]->Value(); }
166 ::connectivity::ORowSetValue& operator[]( size_t _index ) { return m_aParameters[ _index ]->Value(); }
167
170 void push_back( ParameterWrapper* _pParameter )
171 {
172 m_aParameters.push_back( _pParameter );
173 }
174
175 size_t size() const { return m_aParameters.size(); }
176
177 private:
178 // XComponent
179 virtual void disposing(std::unique_lock<std::mutex>& rGuard) override;
180
181 void impl_checkDisposed_throw();
182 };
183
184
185 //= ParametersContainer
186
187 typedef ::rtl::Reference< ParameterWrapperContainer > ParametersContainerRef;
188
189
190} // namespace dbtools::param
191
192
193#endif // INCLUDED_CONNECTIVITY_PARAMWRAPPER_HXX
194
195/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
class for the parameter event
ParameterWrapperContainer(const css::uno::Reference< css::sdb::XSingleSelectQueryAnalyzer > &_rxComposer)
creates a container from a SingleSelectQuerAnalyzer's parameter columns
const Parameters & getParameters() const
void push_back(ParameterWrapper *_pParameter)
adds a ParameterWrapper to the end of the array
::connectivity::ORowSetValue & operator[](size_t _index)
const ::connectivity::ORowSetValue & operator[](size_t _index) const
wraps a parameter column as got from an SQLQueryComposer, so that it has an additional property "Valu...
ParameterWrapper(const css::uno::Reference< css::beans::XPropertySet > &_rxColumn, const css::uno::Reference< css::sdbc::XParameters > &_rxAllParameters, std::vector< sal_Int32 > &&_rIndexes)
::std::unique_ptr< ::cppu::OPropertyArrayHelper > m_pInfoHelper
helper for implementing XPropertySetInfo
::std::vector< sal_Int32 > m_aIndexes
the positions (in our m_xValueDestination) at which the value should be set (0-based!...
::cppu::OPropertySetHelper PropertyBase
::connectivity::ORowSetValue m_aValue
the most recently set value of the parameter
css::uno::Reference< css::sdbc::XParameters > m_xValueDestination
the component taking the value
css::uno::Reference< css::beans::XPropertySetInfo > m_xDelegatorPSI
the property set info for our delegator
const ::connectivity::ORowSetValue & Value() const
ParameterWrapper(const css::uno::Reference< css::beans::XPropertySet > &_rxColumn)
::connectivity::ORowSetValue & Value()
css::uno::Reference< css::beans::XPropertySet > m_xDelegator
the "delegator" column to which standard property requests are forwarded
#define OOO_DLLPUBLIC_DBTOOLS
Type
::rtl::Reference< ParameterWrapperContainer > ParametersContainerRef
::std::vector< ::rtl::Reference< ParameterWrapper > > Parameters
unsigned char sal_Bool
signed char sal_Int8
#define DECLARE_XINTERFACE()