tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / connectivity / source / sdbcx / VTable.cxx
blobafa70c87b7453dee77bc4ddbd8fc3488cde2f266
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 <connectivity/sdbcx/VTable.hxx>
21 #include <com/sun/star/beans/PropertyAttribute.hpp>
22 #include <comphelper/sequence.hxx>
23 #include <connectivity/sdbcx/VCollection.hxx>
24 #include <TConnection.hxx>
25 #include <connectivity/dbtools.hxx>
26 #include <connectivity/dbexception.hxx>
27 #include <cppuhelper/supportsservice.hxx>
28 #include <utility>
30 using namespace ::connectivity;
31 using namespace ::connectivity::sdbcx;
32 using namespace ::dbtools;
33 using namespace ::com::sun::star::beans;
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::sdbc;
36 using namespace ::com::sun::star::sdbcx;
37 using namespace ::com::sun::star::container;
38 using namespace ::com::sun::star::lang;
41 OUString SAL_CALL OTable::getImplementationName( )
43 if(isNew())
44 return u"com.sun.star.sdbcx.VTableDescriptor"_ustr;
45 return u"com.sun.star.sdbcx.Table"_ustr;
49 css::uno::Sequence< OUString > SAL_CALL OTable::getSupportedServiceNames( )
51 return { isNew()?u"com.sun.star.sdbcx.TableDescriptor"_ustr:u"com.sun.star.sdbcx.Table"_ustr };
54 sal_Bool SAL_CALL OTable::supportsService( const OUString& _rServiceName )
56 return cppu::supportsService(this, _rServiceName);
59 OTable::OTable(OCollection* _pTables,
60 bool _bCase)
61 : OTableDescriptor_BASE(m_aMutex)
62 ,ODescriptor(OTableDescriptor_BASE::rBHelper,_bCase,true)
63 ,m_pTables(_pTables)
67 OTable::OTable( OCollection* _pTables,
68 bool _bCase,
69 const OUString& Name, OUString Type,
70 OUString Description, OUString SchemaName,
71 OUString CatalogName) : OTableDescriptor_BASE(m_aMutex)
72 ,ODescriptor(OTableDescriptor_BASE::rBHelper,_bCase)
73 ,m_CatalogName(std::move(CatalogName))
74 ,m_SchemaName(std::move(SchemaName))
75 ,m_Description(std::move(Description))
76 ,m_Type(std::move(Type))
77 ,m_pTables(_pTables)
79 m_Name = Name;
82 OTable::~OTable()
86 void OTable::construct()
88 ODescriptor::construct();
90 sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
92 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME), PROPERTY_ID_CATALOGNAME,nAttrib,&m_CatalogName, ::cppu::UnoType<OUString>::get());
93 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME), PROPERTY_ID_SCHEMANAME, nAttrib,&m_SchemaName, ::cppu::UnoType<OUString>::get());
94 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION), PROPERTY_ID_DESCRIPTION,nAttrib,&m_Description, ::cppu::UnoType<OUString>::get());
95 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE), PROPERTY_ID_TYPE, nAttrib,&m_Type, ::cppu::UnoType<OUString>::get());
98 void SAL_CALL OTable::acquire() noexcept
100 OTableDescriptor_BASE::acquire();
103 void SAL_CALL OTable::release() noexcept
105 OTableDescriptor_BASE::release();
109 Any SAL_CALL OTable::queryInterface( const Type & rType )
111 Any aRet = ODescriptor::queryInterface( rType);
112 if(!aRet.hasValue())
114 if(!isNew())
115 aRet = OTable_BASE::queryInterface( rType);
116 if(isNew() && (rType == cppu::UnoType<XIndexesSupplier>::get()))
117 return Any();
118 if(!aRet.hasValue())
119 aRet = OTableDescriptor_BASE::queryInterface( rType);
121 return aRet;
124 Sequence< Type > SAL_CALL OTable::getTypes( )
126 if(isNew())
127 return ::comphelper::concatSequences(ODescriptor::getTypes(),OTableDescriptor_BASE::getTypes());
128 return ::comphelper::concatSequences(ODescriptor::getTypes(),OTableDescriptor_BASE::getTypes(),OTable_BASE::getTypes());
131 void SAL_CALL OTable::disposing()
133 ODescriptor::disposing();
135 ::osl::MutexGuard aGuard(m_aMutex);
137 if(m_xKeys)
138 m_xKeys->disposing();
139 if(m_xColumns)
140 m_xColumns->disposing();
141 if(m_xIndexes)
142 m_xIndexes->disposing();
144 m_pTables = nullptr;
147 // XColumnsSupplier
148 Reference< XNameAccess > SAL_CALL OTable::getColumns( )
150 ::osl::MutexGuard aGuard(m_aMutex);
151 checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
155 if ( !m_xColumns )
156 refreshColumns();
158 catch( const RuntimeException& )
160 // allowed to leave this method
161 throw;
163 catch( const Exception& )
165 // allowed
168 return m_xColumns.get();
172 // XKeysSupplier
173 Reference< XIndexAccess > SAL_CALL OTable::getKeys( )
175 ::osl::MutexGuard aGuard(m_aMutex);
176 checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
178 Reference< XIndexAccess > xKeys;
182 if ( !m_xKeys )
183 refreshKeys();
184 xKeys = m_xKeys.get();
186 catch( const RuntimeException& )
188 // allowed to leave this method
189 throw;
191 catch( const Exception& )
193 // allowed
196 return xKeys;
199 cppu::IPropertyArrayHelper* OTable::createArrayHelper( sal_Int32 /*_nId*/ ) const
201 return doCreateArrayHelper();
204 cppu::IPropertyArrayHelper & OTable::getInfoHelper()
206 return *getArrayHelper(isNew() ? 1 : 0);
209 Reference< XPropertySet > SAL_CALL OTable::createDataDescriptor( )
211 ::osl::MutexGuard aGuard(m_aMutex);
212 checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
214 rtl::Reference<OTable> pTable = new OTable(m_pTables,isCaseSensitive(),m_Name,m_Type,m_Description,m_SchemaName,m_CatalogName);
215 pTable->setNew(true);
216 return pTable;
219 // XIndexesSupplier
220 Reference< XNameAccess > SAL_CALL OTable::getIndexes( )
222 ::osl::MutexGuard aGuard(m_aMutex);
223 checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
227 if ( !m_xIndexes )
228 refreshIndexes();
230 catch( const RuntimeException& )
232 // allowed to leave this method
233 throw;
235 catch( const Exception& )
237 // allowed
240 return m_xIndexes.get();
243 // XRename
244 void SAL_CALL OTable::rename( const OUString& newName )
246 ::osl::MutexGuard aGuard(m_aMutex);
247 checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
249 const OUString sOldComposedName = getName();
250 const Reference< XDatabaseMetaData> xMetaData = getMetaData();
251 if ( xMetaData.is() )
252 ::dbtools::qualifiedNameComponents(xMetaData,newName,m_CatalogName,m_SchemaName,m_Name,::dbtools::EComposeRule::InDataManipulation);
253 else
254 m_Name = newName;
256 m_pTables->renameObject(sOldComposedName,newName);
259 Reference< XDatabaseMetaData> OTable::getMetaData() const
261 return nullptr;
264 // XAlterTable
265 void SAL_CALL OTable::alterColumnByName( const OUString& /*colName*/, const Reference< XPropertySet >& /*descriptor*/ )
267 throwFeatureNotImplementedSQLException( u"XAlterTable::alterColumnByName"_ustr, *this );
270 void SAL_CALL OTable::alterColumnByIndex( sal_Int32 /*index*/, const Reference< XPropertySet >& /*descriptor*/ )
272 throwFeatureNotImplementedSQLException( u"XAlterTable::alterColumnByIndex"_ustr, *this );
275 css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OTable::getPropertySetInfo( )
277 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
280 OUString SAL_CALL OTable::getName()
282 // this is only correct for tables who haven't a schema or catalog name
283 OSL_ENSURE(m_CatalogName.isEmpty(),"getName(): forgot to override getName()!");
284 OSL_ENSURE(m_SchemaName.isEmpty(),"getName(): forgot to override getName()!");
285 return m_Name;
288 void SAL_CALL OTable::setName( const OUString& /*aName*/ )
292 void OTable::refreshColumns()
296 void OTable::refreshKeys()
300 void OTable::refreshIndexes()
305 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */