LibreOffice Module dbaccess (master) 1
querydescriptor.cxx
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#include "querydescriptor.hxx"
21#include <stringconstants.hxx>
22#include <strings.hxx>
25#include <com/sun/star/beans/PropertyAttribute.hpp>
26
27using namespace ::com::sun::star::uno;
28using namespace ::com::sun::star::awt;
29using namespace ::com::sun::star::lang;
30using namespace ::com::sun::star::beans;
31using namespace ::com::sun::star::container;
32using namespace ::com::sun::star::util;
33using namespace ::osl;
34using namespace ::cppu;
35
36namespace dbaccess
37{
38
39// OQueryDescriptor
40
43 ,ODataSettings(m_aBHelper,true)
44{
47}
48
50 :OQueryDescriptor_Base(_rSource,*this)
51 ,ODataSettings(m_aBHelper,true)
52{
55}
56
58{
59}
60
61css::uno::Sequence<sal_Int8> OQueryDescriptor::getImplementationId()
62{
63 return css::uno::Sequence<sal_Int8>();
64}
65
66css::uno::Sequence< css::uno::Type > OQueryDescriptor::getTypes()
67{
68 return ::comphelper::concatSequences(
70 ODataSettings::getTypes( )
71 );
72}
73
75
76void OQueryDescriptor::registerProperties()
77{
78 // the properties which OCommandBase supplies (it has no own registration, as it's not derived from
79 // an OPropertyStateContainer)
80 registerProperty(PROPERTY_NAME, PROPERTY_ID_NAME, PropertyAttribute::BOUND|PropertyAttribute::CONSTRAINED,
81 &m_sElementName, cppu::UnoType<decltype(m_sElementName)>::get());
82
83 registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND,
84 &m_sCommand, cppu::UnoType<decltype(m_sCommand)>::get());
85
86 registerProperty(PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::BOUND,
87 &m_bEscapeProcessing, cppu::UnoType<bool>::get());
88
89 registerProperty(PROPERTY_UPDATE_TABLENAME, PROPERTY_ID_UPDATE_TABLENAME, PropertyAttribute::BOUND,
90 &m_sUpdateTableName, cppu::UnoType<decltype(m_sUpdateTableName)>::get());
91
92 registerProperty(PROPERTY_UPDATE_SCHEMANAME, PROPERTY_ID_UPDATE_SCHEMANAME, PropertyAttribute::BOUND,
93 &m_sUpdateSchemaName, cppu::UnoType<decltype(m_sUpdateSchemaName)>::get());
94
95 registerProperty(PROPERTY_UPDATE_CATALOGNAME, PROPERTY_ID_UPDATE_CATALOGNAME, PropertyAttribute::BOUND,
96 &m_sUpdateCatalogName, cppu::UnoType<decltype(m_sUpdateCatalogName)>::get());
97
98 registerProperty(PROPERTY_LAYOUTINFORMATION, PROPERTY_ID_LAYOUTINFORMATION, PropertyAttribute::BOUND,
99 &m_aLayoutInformation, cppu::UnoType<decltype(m_aLayoutInformation)>::get());
100}
101
102Reference< XPropertySetInfo > SAL_CALL OQueryDescriptor::getPropertySetInfo( )
103{
104 return createPropertySetInfo( getInfoHelper() ) ;
105}
106
108{
109 return *getArrayHelper();
110}
111
113{
114 Sequence< Property > aProps;
115 describeProperties(aProps);
116 return new ::cppu::OPropertyArrayHelper(aProps);
117}
118
119
121 :m_bColumnsOutOfDate(true)
122 ,m_rMutex(_rMutex)
123{
124 m_pColumns.reset( new OColumns(_rMySelf, m_rMutex, true,std::vector< OUString>(), this,this) );
125}
126
128 :m_bColumnsOutOfDate(true)
129 ,m_rMutex(_rSource.m_rMutex)
130{
131 m_pColumns.reset( new OColumns(_rMySelf, m_rMutex, true,std::vector< OUString>(), this,this) );
132
133 m_sCommand = _rSource.m_sCommand;
139}
140
142{
143 m_pColumns->acquire();
144 m_pColumns->disposing();
145}
146
148{
149 m_bColumnsOutOfDate = _bOutOfDate;
150 if ( !m_bColumnsOutOfDate )
151 m_pColumns->setInitialized();
152}
153
154void OQueryDescriptor_Base::implAppendColumn( const OUString& _rName, OColumn* _pColumn )
155{
156 m_pColumns->append( _rName, _pColumn );
157}
158
160{
161 m_pColumns->clearColumns();
162
164}
165
166Reference< XNameAccess > SAL_CALL OQueryDescriptor_Base::getColumns( )
167{
168 MutexGuard aGuard(m_rMutex);
169
171 {
172 // clear the current columns
173 clearColumns();
174
175 // do this before rebuildColumns. This prevents recursion, e.g. in the case where we
176 // have queries with cyclic references:
177 // foo := SELECT * FROM bar
178 // bar := SELECT * FROM foo
179 setColumnsOutOfDate( false );
180
181 // rebuild them
182 try
183 {
185 }
186 catch ( const Exception& )
187 {
189 throw;
190 }
191 }
192
193 return m_pColumns.get();
194}
195
197{
198 return "com.sun.star.sdb.OQueryDescriptor";
199}
200
201sal_Bool SAL_CALL OQueryDescriptor_Base::supportsService( const OUString& _rServiceName )
202{
203 return cppu::supportsService(this, _rServiceName);
204}
205
207{
209}
210
212{
213 m_pColumns->disposing();
214}
215
216void OQueryDescriptor_Base::columnAppended( const Reference< XPropertySet >& /*_rxSourceDescriptor*/ )
217{
218 // not interested in
219}
220
221void OQueryDescriptor_Base::columnDropped(const OUString& /*_sName*/)
222{
223 // not interested in
224}
225
227{
228 OSL_FAIL( "OQueryDescriptor_Base::createColumnDescriptor: called why?" );
229 return nullptr;
230}
231
233{
234}
235
236// IRefreshableColumns
238{
239 MutexGuard aGuard( m_rMutex );
240
241 clearColumns();
243}
244
246{
247 // creating a column/descriptor for a query/descriptor does not make sense at all
248 return nullptr;
249}
250
251}
252
253/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void describeProperties(css::uno::Sequence< css::beans::Property > &_rProps) const
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
css::uno::Sequence< css::beans::PropertyValue > m_aLayoutInformation
Definition: commandbase.hxx:35
void registerPropertiesFor(ODataSettings_Base *_pItem)
register the properties from the param given.
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
OQueryDescriptor_Base(::osl::Mutex &_rMutex,::cppu::OWeakObject &_rMySelf)
virtual void refreshColumns() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
void setColumnsOutOfDate(bool _bOutOfDate=true)
virtual rtl::Reference< OColumn > createColumn(const OUString &_rName) const override
creates an OColumn object which should represent the column with a given name
virtual void rebuildColumns()
rebuild our columns set
void implAppendColumn(const OUString &_rName, OColumn *_pColumn)
virtual void columnAppended(const css::uno::Reference< css::beans::XPropertySet > &_rxSourceDescriptor) override
notifies that a column, created from a column descriptor, has been appended
virtual css::uno::Reference< css::beans::XPropertySet > createColumnDescriptor() override
creates a column descriptor object.
virtual OUString SAL_CALL getImplementationName() override
virtual void columnDropped(const OUString &_sName) override
notifies that a column with a given name has been dropped
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns() override
std::unique_ptr< OColumns > m_pColumns
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual ~OQueryDescriptor() override
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
::osl::Mutex & m_rMutex
std::mutex m_aMutex
@ Exception
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
#define PROPERTY_ID_NAME
#define PROPERTY_ID_ESCAPE_PROCESSING
#define PROPERTY_ID_UPDATE_CATALOGNAME
#define PROPERTY_ID_UPDATE_SCHEMANAME
#define PROPERTY_ID_COMMAND
#define PROPERTY_ID_UPDATE_TABLENAME
#define PROPERTY_ID_LAYOUTINFORMATION
constexpr OUStringLiteral PROPERTY_COMMAND(u"Command")
constexpr OUStringLiteral PROPERTY_UPDATE_TABLENAME(u"UpdateTableName")
constexpr OUStringLiteral SERVICE_SDB_QUERYDESCRIPTOR
Definition: strings.hxx:191
constexpr OUStringLiteral PROPERTY_UPDATE_SCHEMANAME(u"UpdateSchemaName")
constexpr OUStringLiteral PROPERTY_ESCAPE_PROCESSING(u"EscapeProcessing")
constexpr OUStringLiteral SERVICE_SDB_DATASETTINGS
Definition: strings.hxx:190
constexpr OUStringLiteral PROPERTY_NAME(u"Name")
constexpr OUStringLiteral PROPERTY_UPDATE_CATALOGNAME(u"UpdateCatalogName")
constexpr OUStringLiteral PROPERTY_LAYOUTINFORMATION(u"LayoutInformation")
unsigned char sal_Bool
#define IMPLEMENT_FORWARD_XINTERFACE3(classname, refcountbase, baseclass2, baseclass3)