LibreOffice Module connectivity (master) 1
parameters.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#ifndef INCLUDED_CONNECTIVITY_PARAMETERS_HXX
20#define INCLUDED_CONNECTIVITY_PARAMETERS_HXX
21
22#include <map>
23#include <utility>
24#include <vector>
25
26#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
27
32
33namespace com::sun::star::beans { class XPropertySet; }
34namespace com::sun::star::container { class XIndexAccess; }
35namespace com::sun::star::form { class XDatabaseParameterListener; }
36namespace com::sun::star::io { class XInputStream; }
37namespace com::sun::star::sdbc { class XArray; }
38namespace com::sun::star::sdbc { class XBlob; }
39namespace com::sun::star::sdbc { class XClob; }
40namespace com::sun::star::sdbc { class XConnection; }
41namespace com::sun::star::sdbc { class XDatabaseMetaData; }
42namespace com::sun::star::sdbc { class XParameters; }
43namespace com::sun::star::sdbc { class XRef; }
45namespace com::sun::star::uno { class XAggregation; }
46namespace com::sun::star::uno { class XComponentContext; }
47
48namespace dbtools
49{
50
51
52 typedef ::utl::SharedUNOComponent< css::sdb::XSingleSelectQueryComposer, ::utl::DisposableComponent >
54
55
56 //= ParameterManager
57
58 class FilterManager;
60 {
61 public:
64 {
68 LinkedByParamName,
72 LinkedByColumnName,
75 FilledExternally
76 };
79 private:
81 {
85 css::uno::Reference< css::beans::XPropertySet >
88 ::std::vector< sal_Int32 > aInnerIndexes;
89
91 ParameterMetaData( css::uno::Reference< css::beans::XPropertySet > _xColumn )
92 :eType ( ParameterClassification::FilledExternally )
93 ,xComposerColumn (std::move( _xColumn ))
94 {
95 }
96 };
97
98 typedef ::std::map< OUString, ParameterMetaData > ParameterInformation;
99
100 private:
101 ::osl::Mutex& m_rMutex;
103
104 css::uno::Reference< css::uno::XComponentContext >
106
107 css::uno::WeakReference< css::beans::XPropertySet >
108 m_xComponent; // the database component whose parameters we're handling
109 css::uno::Reference< css::uno::XAggregation >
110 m_xAggregatedRowSet; // the aggregated row set - necessary for unwrapped access to some interfaces
111 css::uno::Reference< css::sdbc::XParameters >
112 m_xInnerParamUpdate; // write access to the inner parameters
113 SharedQueryComposer m_xComposer; // query composer wrapping the statement which the *aggregate* is based on
114 SharedQueryComposer m_xParentComposer; // query composer wrapping the statement of our parent database component
115 css::uno::Reference< css::container::XIndexAccess >
116 m_xInnerParamColumns; // index access to the parameter columns, as got from the query composer
117
119 m_pOuterParameters; // the container of parameters which still need to be filled in by
120 // external instances
121 sal_Int32 m_nInnerCount; // overall number of parameters as required by the database component's aggregate
122
124
125 std::vector< OUString > m_aMasterFields;
126 std::vector< OUString > m_aDetailFields;
127
130 css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xConnectionMetadata;
131
132 ::std::vector< bool > m_aParametersVisited;
133
135
136 public:
140 ::osl::Mutex& _rMutex,
141 const css::uno::Reference< css::uno::XComponentContext >& _rxContext
142 );
143
145 void initialize(
146 const css::uno::Reference< css::beans::XPropertySet >& _rxComponent,
147 const css::uno::Reference< css::uno::XAggregation >& _rxComponentAggregate
148 );
149
151 void dispose( );
152
154 void clearAllParameterInformation();
155
157 bool isUpToDate() const { return m_bUpToDate; }
158
161 void updateParameterInfo( FilterManager& _rFilterManager );
162
180 bool fillParameterValues(
181 const css::uno::Reference< css::task::XInteractionHandler >& _rxCompletionHandler,
182 ::osl::ResettableMutexGuard& _rClearForNotifies
183 );
184
190 void setAllParametersNull();
191
201 void resetParameterValues();
202
205 void addParameterListener(
206 const css::uno::Reference< css::form::XDatabaseParameterListener >& _rxListener
207 );
208
211 void removeParameterListener(
212 const css::uno::Reference< css::form::XDatabaseParameterListener >& _rxListener
213 );
214
215 // XParameters equivalents
216 void setNull ( sal_Int32 _nIndex, sal_Int32 sqlType);
217 void setObjectNull ( sal_Int32 _nIndex, sal_Int32 sqlType, const OUString& typeName);
218 void setBoolean ( sal_Int32 _nIndex, bool x);
219 void setByte ( sal_Int32 _nIndex, sal_Int8 x);
220 void setShort ( sal_Int32 _nIndex, sal_Int16 x);
221 void setInt ( sal_Int32 _nIndex, sal_Int32 x);
222 void setLong ( sal_Int32 _nIndex, sal_Int64 x);
223 void setFloat ( sal_Int32 _nIndex, float x);
224 void setDouble ( sal_Int32 _nIndex, double x);
225 void setString ( sal_Int32 _nIndex, const OUString& x);
226 void setBytes ( sal_Int32 _nIndex, const css::uno::Sequence< sal_Int8 >& x);
227 void setDate ( sal_Int32 _nIndex, const css::util::Date& x);
228 void setTime ( sal_Int32 _nIndex, const css::util::Time& x);
229 void setTimestamp ( sal_Int32 _nIndex, const css::util::DateTime& x);
230 void setBinaryStream ( sal_Int32 _nIndex, const css::uno::Reference< css::io::XInputStream>& x, sal_Int32 length);
231 void setCharacterStream ( sal_Int32 _nIndex, const css::uno::Reference< css::io::XInputStream>& x, sal_Int32 length);
232 void setObject ( sal_Int32 _nIndex, const css::uno::Any& x);
233 void setObjectWithInfo ( sal_Int32 _nIndex, const css::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale);
234 void setRef ( sal_Int32 _nIndex, const css::uno::Reference< css::sdbc::XRef>& x);
235 void setBlob ( sal_Int32 _nIndex, const css::uno::Reference< css::sdbc::XBlob>& x);
236 void setClob ( sal_Int32 _nIndex, const css::uno::Reference< css::sdbc::XClob>& x);
237 void setArray ( sal_Int32 _nIndex, const css::uno::Reference< css::sdbc::XArray>& x);
238 void clearParameters();
239
240 private:
242 bool isAlive() const { return m_xComponent.get().is() && m_xInnerParamUpdate.is(); }
243
246 OUString
247 createFilterConditionFromColumnLink(
248 const OUString& /* [in] */ _rMasterColumn,
249 const css::uno::Reference< css::beans::XPropertySet >& /* [in] */ xDetailColumn,
250 OUString& /* [out] */ _rNewParamName
251 );
252
264 bool initializeComposerByComponent(
265 const css::uno::Reference< css::beans::XPropertySet >& _rxComponent
266 );
267
278 void collectInnerParameters( bool _bSecondRun );
279
291 void analyzeFieldLinks( FilterManager& _rFilterManager, bool& /* [out] */ _rColumnsInLinkDetails );
292
314 void classifyLinks(
315 const css::uno::Reference< css::container::XNameAccess >& _rxParentColumns,
316 const css::uno::Reference< css::container::XNameAccess >& _rxColumns,
317 ::std::vector< OUString >& _out_rAdditionalFilterComponents,
318 ::std::vector< OUString >& _out_rAdditionalHavingComponents
319 );
320
329 void createOuterParameters();
330
339 void fillLinkedParameters(
340 const css::uno::Reference< css::container::XNameAccess >& _rxParentColumns
341 );
342
351 bool completeParameters(
352 const css::uno::Reference< css::task::XInteractionHandler >& _rxCompletionHandler,
353 const css::uno::Reference< css::sdbc::XConnection >& _rxConnection
354 );
355
364 bool consultParameterListeners( ::osl::ResettableMutexGuard& _rClearForNotifies );
365
368 void externalParameterVisited( sal_Int32 _nIndex );
369
370 private:
378 bool getParentColumns(
379 css::uno::Reference< css::container::XNameAccess >& /* [out] */ _out_rxParentColumns,
380 bool _bFromComposer
381 );
382
390 bool getColumns(
391 css::uno::Reference< css::container::XNameAccess >& /* [out] */ _rxColumns,
392 bool _bFromComposer
393 );
394
397 void getConnection(
398 css::uno::Reference< css::sdbc::XConnection >& /* [out] */ _rxConnection
399 );
400
403 void cacheConnectionInfo();
404
405 private:
408 };
409
410
411} // namespacefrm
412
413
414#endif // INCLUDED_CONNECTIVITY_PARAMETERS_HXX
415
416/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
manages the filter of a database component with filter properties
::std::vector< bool > m_aParametersVisited
Definition: parameters.hxx:132
::std::map< OUString, ParameterMetaData > ParameterInformation
Definition: parameters.hxx:98
ParameterInformation m_aParameterInformation
Definition: parameters.hxx:123
ParameterManager(::osl::Mutex &_rMutex, const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
ctor
css::uno::WeakReference< css::beans::XPropertySet > m_xComponent
Definition: parameters.hxx:108
SharedQueryComposer m_xComposer
Definition: parameters.hxx:113
::comphelper::OInterfaceContainerHelper3< css::form::XDatabaseParameterListener > m_aParameterListeners
Definition: parameters.hxx:102
css::uno::Reference< css::sdbc::XParameters > m_xInnerParamUpdate
Definition: parameters.hxx:112
bool isUpToDate() const
checks whether the parameter information is up-to-date
Definition: parameters.hxx:157
css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xConnectionMetadata
Definition: parameters.hxx:130
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: parameters.hxx:105
ParameterManager(const ParameterManager &)=delete
std::vector< OUString > m_aMasterFields
Definition: parameters.hxx:125
::dbtools::param::ParametersContainerRef m_pOuterParameters
Definition: parameters.hxx:119
std::vector< OUString > m_aDetailFields
Definition: parameters.hxx:126
bool isAlive() const
checks whether the object is already initialized, and not yet disposed
Definition: parameters.hxx:242
css::uno::Reference< css::uno::XAggregation > m_xAggregatedRowSet
Definition: parameters.hxx:110
ParameterManager & operator=(const ParameterManager &)=delete
css::uno::Reference< css::container::XIndexAccess > m_xInnerParamColumns
Definition: parameters.hxx:116
ParameterClassification
classifies the origin of the data to fill a parameter
Definition: parameters.hxx:64
SharedQueryComposer m_xParentComposer
Definition: parameters.hxx:114
#define OOO_DLLPUBLIC_DBTOOLS
DocumentType eType
class SAL_NO_VTABLE XPropertySet
Reference< XConnection > getConnection(const Reference< XRowSet > &_rxRowSet)
Definition: dbtools.cxx:348
void setObjectWithInfo(const Reference< XParameters > &_xParams, sal_Int32 parameterIndex, const Any &x, sal_Int32 sqlType, sal_Int32 scale)
Definition: dbtools.cxx:1765
::utl::SharedUNOComponent< css::sdb::XSingleSelectQueryComposer, ::utl::DisposableComponent > SharedQueryComposer
Definition: parameters.hxx:53
void dispose()
OUString typeName
sal_Int32 scale
Definition: pq_statics.cxx:62
meta data about an inner parameter
Definition: parameters.hxx:81
ParameterMetaData(css::uno::Reference< css::beans::XPropertySet > _xColumn)
ctor with composer column
Definition: parameters.hxx:91
::std::vector< sal_Int32 > aInnerIndexes
the indices of inner parameters which need to be filled when this concrete parameter is set
Definition: parameters.hxx:88
ParameterClassification eType
the type of the parameter
Definition: parameters.hxx:83
css::uno::Reference< css::beans::XPropertySet > xComposerColumn
the column object for this parameter, as returned by the query composer
Definition: parameters.hxx:86
signed char sal_Int8