nss: upgrade to release 3.73
[LibreOffice.git] / dbaccess / source / core / api / querydescriptor.cxx
blobc52febb5db6ce9943b4a16191d2753c8df874cd4
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 #include "querydescriptor.hxx"
21 #include <apitools.hxx>
22 #include <stringconstants.hxx>
23 #include <comphelper/servicehelper.hxx>
24 #include <cppuhelper/supportsservice.hxx>
25 #include <cppuhelper/typeprovider.hxx>
26 #include <com/sun/star/beans/PropertyAttribute.hpp>
28 using namespace ::com::sun::star::uno;
29 using namespace ::com::sun::star::awt;
30 using namespace ::com::sun::star::lang;
31 using namespace ::com::sun::star::beans;
32 using namespace ::com::sun::star::container;
33 using namespace ::com::sun::star::util;
34 using namespace ::osl;
35 using namespace ::cppu;
37 namespace dbaccess
40 // OQueryDescriptor
42 OQueryDescriptor::OQueryDescriptor()
43 :OQueryDescriptor_Base(m_aMutex,*this)
44 ,ODataSettings(m_aBHelper,true)
46 registerProperties();
47 ODataSettings::registerPropertiesFor(this);
50 OQueryDescriptor::OQueryDescriptor(const OQueryDescriptor_Base& _rSource)
51 :OQueryDescriptor_Base(_rSource,*this)
52 ,ODataSettings(m_aBHelper,true)
54 registerProperties();
55 ODataSettings::registerPropertiesFor(this);
58 OQueryDescriptor::~OQueryDescriptor()
62 css::uno::Sequence<sal_Int8> OQueryDescriptor::getImplementationId()
64 return css::uno::Sequence<sal_Int8>();
67 IMPLEMENT_GETTYPES2(OQueryDescriptor,OQueryDescriptor_Base,ODataSettings);
68 IMPLEMENT_FORWARD_XINTERFACE3( OQueryDescriptor,OWeakObject,OQueryDescriptor_Base,ODataSettings)
70 void OQueryDescriptor::registerProperties()
72 // the properties which OCommandBase supplies (it has no own registration, as it's not derived from
73 // an OPropertyStateContainer)
74 registerProperty(PROPERTY_NAME, PROPERTY_ID_NAME, PropertyAttribute::BOUND|PropertyAttribute::CONSTRAINED,
75 &m_sElementName, cppu::UnoType<decltype(m_sElementName)>::get());
77 registerProperty(PROPERTY_COMMAND, PROPERTY_ID_COMMAND, PropertyAttribute::BOUND,
78 &m_sCommand, cppu::UnoType<decltype(m_sCommand)>::get());
80 registerProperty(PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::BOUND,
81 &m_bEscapeProcessing, cppu::UnoType<bool>::get());
83 registerProperty(PROPERTY_UPDATE_TABLENAME, PROPERTY_ID_UPDATE_TABLENAME, PropertyAttribute::BOUND,
84 &m_sUpdateTableName, cppu::UnoType<decltype(m_sUpdateTableName)>::get());
86 registerProperty(PROPERTY_UPDATE_SCHEMANAME, PROPERTY_ID_UPDATE_SCHEMANAME, PropertyAttribute::BOUND,
87 &m_sUpdateSchemaName, cppu::UnoType<decltype(m_sUpdateSchemaName)>::get());
89 registerProperty(PROPERTY_UPDATE_CATALOGNAME, PROPERTY_ID_UPDATE_CATALOGNAME, PropertyAttribute::BOUND,
90 &m_sUpdateCatalogName, cppu::UnoType<decltype(m_sUpdateCatalogName)>::get());
92 registerProperty(PROPERTY_LAYOUTINFORMATION, PROPERTY_ID_LAYOUTINFORMATION, PropertyAttribute::BOUND,
93 &m_aLayoutInformation, cppu::UnoType<decltype(m_aLayoutInformation)>::get());
96 Reference< XPropertySetInfo > SAL_CALL OQueryDescriptor::getPropertySetInfo( )
98 return createPropertySetInfo( getInfoHelper() ) ;
101 ::cppu::IPropertyArrayHelper& OQueryDescriptor::getInfoHelper()
103 return *getArrayHelper();
106 ::cppu::IPropertyArrayHelper* OQueryDescriptor::createArrayHelper( ) const
108 Sequence< Property > aProps;
109 describeProperties(aProps);
110 return new ::cppu::OPropertyArrayHelper(aProps);
114 OQueryDescriptor_Base::OQueryDescriptor_Base(::osl::Mutex& _rMutex,::cppu::OWeakObject& _rMySelf)
115 :m_bColumnsOutOfDate(true)
116 ,m_rMutex(_rMutex)
118 m_pColumns.reset( new OColumns(_rMySelf, m_rMutex, true,std::vector< OUString>(), this,this) );
121 OQueryDescriptor_Base::OQueryDescriptor_Base(const OQueryDescriptor_Base& _rSource,::cppu::OWeakObject& _rMySelf)
122 :m_bColumnsOutOfDate(true)
123 ,m_rMutex(_rSource.m_rMutex)
125 m_pColumns.reset( new OColumns(_rMySelf, m_rMutex, true,std::vector< OUString>(), this,this) );
127 m_sCommand = _rSource.m_sCommand;
128 m_bEscapeProcessing = _rSource.m_bEscapeProcessing;
129 m_sUpdateTableName = _rSource.m_sUpdateTableName;
130 m_sUpdateSchemaName = _rSource.m_sUpdateSchemaName;
131 m_sUpdateCatalogName = _rSource.m_sUpdateCatalogName;
132 m_aLayoutInformation = _rSource.m_aLayoutInformation;
135 OQueryDescriptor_Base::~OQueryDescriptor_Base()
137 m_pColumns->acquire();
138 m_pColumns->disposing();
141 sal_Int64 SAL_CALL OQueryDescriptor_Base::getSomething( const Sequence< sal_Int8 >& _rIdentifier )
143 if (isUnoTunnelId<OQueryDescriptor_Base>(_rIdentifier))
144 return reinterpret_cast<sal_Int64>(this);
146 return 0;
149 css::uno::Sequence<sal_Int8> OQueryDescriptor_Base::getUnoTunnelId()
151 static cppu::OImplementationId aId;
152 return aId.getImplementationId();
155 css::uno::Sequence<sal_Int8> OQueryDescriptor_Base::getImplementationId()
157 return css::uno::Sequence<sal_Int8>();
160 void OQueryDescriptor_Base::setColumnsOutOfDate( bool _bOutOfDate )
162 m_bColumnsOutOfDate = _bOutOfDate;
163 if ( !m_bColumnsOutOfDate )
164 m_pColumns->setInitialized();
167 void OQueryDescriptor_Base::implAppendColumn( const OUString& _rName, OColumn* _pColumn )
169 m_pColumns->append( _rName, _pColumn );
172 void OQueryDescriptor_Base::clearColumns( )
174 m_pColumns->clearColumns();
176 setColumnsOutOfDate();
179 Reference< XNameAccess > SAL_CALL OQueryDescriptor_Base::getColumns( )
181 MutexGuard aGuard(m_rMutex);
183 if ( m_bColumnsOutOfDate )
185 // clear the current columns
186 clearColumns();
188 // do this before rebuildColumns. This prevents recursion, e.g. in the case where we
189 // have queries with cyclic references:
190 // foo := SELECT * FROM bar
191 // bar := SELECT * FROM foo
192 setColumnsOutOfDate( false );
194 // rebuild them
197 rebuildColumns();
199 catch ( const Exception& )
201 setColumnsOutOfDate();
202 throw;
206 return m_pColumns.get();
209 OUString SAL_CALL OQueryDescriptor_Base::getImplementationName( )
211 return "com.sun.star.sdb.OQueryDescriptor";
214 sal_Bool SAL_CALL OQueryDescriptor_Base::supportsService( const OUString& _rServiceName )
216 return cppu::supportsService(this, _rServiceName);
219 Sequence< OUString > SAL_CALL OQueryDescriptor_Base::getSupportedServiceNames( )
221 return { SERVICE_SDB_DATASETTINGS, SERVICE_SDB_QUERYDESCRIPTOR };
224 void OQueryDescriptor_Base::disposeColumns()
226 m_pColumns->disposing();
229 void OQueryDescriptor_Base::columnAppended( const Reference< XPropertySet >& /*_rxSourceDescriptor*/ )
231 // not interested in
234 void OQueryDescriptor_Base::columnDropped(const OUString& /*_sName*/)
236 // not interested in
239 Reference< XPropertySet > OQueryDescriptor_Base::createColumnDescriptor()
241 OSL_FAIL( "OQueryDescriptor_Base::createColumnDescriptor: called why?" );
242 return nullptr;
245 void OQueryDescriptor_Base::rebuildColumns( )
249 // IRefreshableColumns
250 void OQueryDescriptor_Base::refreshColumns()
252 MutexGuard aGuard( m_rMutex );
254 clearColumns();
255 rebuildColumns();
258 OColumn* OQueryDescriptor_Base::createColumn( const OUString& /*_rName*/ ) const
260 // creating a column/descriptor for a query/descriptor does not make sense at all
261 return nullptr;
266 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */