LibreOffice Module connectivity (master) 1
TTableHelper.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 <sal/config.h>
21#include <sal/log.hxx>
22
24#include <com/sun/star/sdb/tools/XTableRename.hpp>
25#include <com/sun/star/sdb/tools/XTableAlteration.hpp>
26#include <com/sun/star/sdb/tools/XKeyAlteration.hpp>
27#include <com/sun/star/sdb/tools/XIndexAlteration.hpp>
28#include <sdbcx/VKey.hxx>
29#include <com/sun/star/sdbc/XRow.hpp>
30#include <com/sun/star/sdbc/XResultSet.hpp>
31#include <com/sun/star/sdbcx/KeyType.hpp>
33#include <com/sun/star/lang/XMultiServiceFactory.hpp>
34#include <comphelper/types.hxx>
38#include <TConnection.hxx>
39
40#include <o3tl/functional.hxx>
41
42#include <iterator>
43#include <set>
44
45using namespace ::comphelper;
46using namespace connectivity;
47using namespace ::com::sun::star::uno;
48using namespace ::com::sun::star::beans;
49using namespace ::com::sun::star::sdbcx;
50using namespace ::com::sun::star::sdbc;
51using namespace ::com::sun::star::container;
52using namespace ::com::sun::star::lang;
53
54namespace
55{
57class OTableContainerListener:
58 public ::cppu::WeakImplHelper< XContainerListener >
59{
60 OTableHelper* m_pComponent;
61 std::map< OUString,bool> m_aRefNames;
62
63protected:
64 virtual ~OTableContainerListener() override {}
65public:
66 explicit OTableContainerListener(OTableHelper* _pComponent) : m_pComponent(_pComponent){}
67 // noncopyable
68 OTableContainerListener(const OTableContainerListener&) = delete;
69 const OTableContainerListener& operator=(const OTableContainerListener&) = delete;
70 virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& /*Event*/ ) override
71 {
72 }
73 virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override
74 {
75 // tdf#137745, perhaps connectivity::OTableHelper::disposing() has been called
76 // which called OTableContainerListener::clear(), so m_pComponent may be null
77 if (m_pComponent == nullptr)
78 return;
79
80 OUString sName;
81 Event.Accessor >>= sName;
82 if ( m_aRefNames.find(sName) != m_aRefNames.end() )
83 m_pComponent->refreshKeys();
84 }
85 virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override
86 {
87 OUString sOldComposedName,sNewComposedName;
88 Event.ReplacedElement >>= sOldComposedName;
89 Event.Accessor >>= sNewComposedName;
90 if ( sOldComposedName != sNewComposedName && m_aRefNames.find(sOldComposedName) != m_aRefNames.end() )
91 m_pComponent->refreshKeys();
92 }
93 // XEventListener
94 virtual void SAL_CALL disposing( const EventObject& /*_rSource*/ ) override
95 {
96 }
97 void clear() { m_pComponent = nullptr; }
98 void add(const OUString& _sRefName) { m_aRefNames.emplace(_sRefName,true); }
99};
100}
101namespace connectivity
102{
103 static OUString lcl_getServiceNameForSetting(const Reference< css::sdbc::XConnection >& _xConnection,const OUString& i_sSetting)
104 {
105 OUString sSupportService;
106 Any aValue;
107 if ( ::dbtools::getDataSourceSetting(_xConnection,i_sSetting,aValue) )
108 {
109 aValue >>= sSupportService;
110 }
111 return sSupportService;
112 }
114 {
116 // helper services which can be provided by extensions
117 Reference< css::sdb::tools::XTableRename> m_xRename;
118 Reference< css::sdb::tools::XTableAlteration> m_xAlter;
119 Reference< css::sdb::tools::XKeyAlteration> m_xKeyAlter;
120 Reference< css::sdb::tools::XIndexAlteration> m_xIndexAlter;
121
122 Reference< css::sdbc::XDatabaseMetaData > m_xMetaData;
123 Reference< css::sdbc::XConnection > m_xConnection;
125 std::vector< ColumnDesc > m_aColumnDesc;
126 explicit OTableHelperImpl(const Reference< css::sdbc::XConnection >& _xConnection)
127 : m_xConnection(_xConnection)
128 {
129 try
130 {
131 m_xMetaData = m_xConnection->getMetaData();
132 Reference<XMultiServiceFactory> xFac(_xConnection,UNO_QUERY);
133 if ( xFac.is() )
134 {
135 m_xRename.set(xFac->createInstance(lcl_getServiceNameForSetting(m_xConnection,"TableRenameServiceName")),UNO_QUERY);
136 m_xAlter.set(xFac->createInstance(lcl_getServiceNameForSetting(m_xConnection,"TableAlterationServiceName")),UNO_QUERY);
137 m_xKeyAlter.set(xFac->createInstance(lcl_getServiceNameForSetting(m_xConnection,"KeyAlterationServiceName")),UNO_QUERY);
138 m_xIndexAlter.set(xFac->createInstance(lcl_getServiceNameForSetting(m_xConnection,"IndexAlterationServiceName")),UNO_QUERY);
139 }
140 }
141 catch(const Exception&)
142 {
143 }
144 }
145 };
146}
147
148OTableHelper::OTableHelper( sdbcx::OCollection* _pTables,
149 const Reference< XConnection >& _xConnection,
150 bool _bCase)
151 :OTable_TYPEDEF(_pTables,_bCase)
152 ,m_pImpl(new OTableHelperImpl(_xConnection))
153{
154}
155
157 const Reference< XConnection >& _xConnection,
158 bool _bCase,
159 const OUString& Name,
160 const OUString& Type,
161 const OUString& Description ,
162 const OUString& SchemaName,
163 const OUString& CatalogName
164 ) : OTable_TYPEDEF(_pTables,
165 _bCase,
166 Name,
167 Type,
168 Description,
169 SchemaName,
170 CatalogName)
171 ,m_pImpl(new OTableHelperImpl(_xConnection))
172{
173}
174
176{
177}
178
180{
181 ::osl::MutexGuard aGuard(m_aMutex);
182 if ( m_pImpl->m_xTablePropertyListener.is() )
183 {
184 m_pTables->removeContainerListener(m_pImpl->m_xTablePropertyListener);
185 m_pImpl->m_xTablePropertyListener->clear();
186 m_pImpl->m_xTablePropertyListener.clear();
187 }
189
190 m_pImpl->m_xConnection = nullptr;
191 m_pImpl->m_xMetaData = nullptr;
192
193}
194
195
196namespace
197{
200 void lcl_collectColumnDescs_throw( const Reference< XResultSet >& _rxResult, std::vector< ColumnDesc >& _out_rColumns )
201 {
202 Reference< XRow > xRow( _rxResult, UNO_QUERY_THROW );
203 OUString sName;
204 OrdinalPosition nOrdinalPosition( 0 );
205 while ( _rxResult->next() )
206 {
207 sName = xRow->getString( 4 ); // COLUMN_NAME
208 sal_Int32 nField5 = xRow->getInt(5);
209 OUString aField6 = xRow->getString(6);
210 sal_Int32 nField7 = xRow->getInt(7)
211 , nField9 = xRow->getInt(9)
212 , nField11= xRow->getInt(11);
213 OUString sField12 = xRow->getString(12)
214 ,sField13 = xRow->getString(13);
215 nOrdinalPosition = xRow->getInt( 17 ); // ORDINAL_POSITION
216 _out_rColumns.push_back( ColumnDesc( sName,nField5,aField6,nField7,nField9,nField11,sField12,sField13, nOrdinalPosition ) );
217 }
218 }
219
223 void lcl_sanitizeColumnDescs( std::vector< ColumnDesc >& _rColumns )
224 {
225 if ( _rColumns.empty() )
226 return;
227
228 // collect all used ordinals
229 std::set< OrdinalPosition > aUsedOrdinals;
230 for ( const auto& collect : _rColumns )
231 aUsedOrdinals.insert( collect.nOrdinalPosition );
232
233 // we need to have as much different ordinals as we have different columns
234 bool bDuplicates = aUsedOrdinals.size() != _rColumns.size();
235 // and it needs to be a continuous range
236 size_t nOrdinalsRange = *aUsedOrdinals.rbegin() - *aUsedOrdinals.begin() + 1;
237 bool bGaps = nOrdinalsRange != _rColumns.size();
238
239 // if that's not the case, normalize it
240 if ( bGaps || bDuplicates )
241 {
242 OSL_FAIL( "lcl_sanitizeColumnDescs: database did provide invalid ORDINAL_POSITION values!" );
243
244 OrdinalPosition nNormalizedPosition = 1;
245 for ( auto& normalize : _rColumns )
246 normalize.nOrdinalPosition = nNormalizedPosition++;
247 return;
248 }
249
250 // what's left is that the range might not be from 1 to <column count>, but for instance
251 // 0 to <column count>-1.
252 size_t nOffset = *aUsedOrdinals.begin() - 1;
253 for ( auto& offset : _rColumns )
254 offset.nOrdinalPosition -= nOffset;
255 }
256}
257
258
260{
261 ::std::vector< OUString> aVector;
262 if(!isNew())
263 {
264 Any aCatalog;
265 if ( !m_CatalogName.isEmpty() )
266 aCatalog <<= m_CatalogName;
267
269 aCatalog,
271 m_Name,
272 "%"
273 ) );
274
275 // collect the column names, together with their ordinal position
276 m_pImpl->m_aColumnDesc.clear();
277 lcl_collectColumnDescs_throw( xResult, m_pImpl->m_aColumnDesc );
278
279 // ensure that the ordinal positions as obtained from the meta data do make sense
280 lcl_sanitizeColumnDescs( m_pImpl->m_aColumnDesc );
281
282 // sort by ordinal position
283 std::map< OrdinalPosition, OUString > aSortedColumns;
284 for (const auto& copy : m_pImpl->m_aColumnDesc)
285 aSortedColumns[ copy.nOrdinalPosition ] = copy.sName;
286
287 // copy them to aVector, now that we have the proper ordering
288 std::transform(
289 aSortedColumns.begin(),
290 aSortedColumns.end(),
291 std::insert_iterator< ::std::vector< OUString> >( aVector, aVector.begin() ),
292 ::o3tl::select2nd< std::map< OrdinalPosition, OUString >::value_type >()
293 );
294 }
295
296 if(m_xColumns)
297 m_xColumns->reFill(aVector);
298 else
299 m_xColumns.reset(createColumns(aVector));
300}
301
302const ColumnDesc* OTableHelper::getColumnDescription(const OUString& _sName) const
303{
304 const ColumnDesc* pRet = nullptr;
305 auto aIter = std::find_if(m_pImpl->m_aColumnDesc.begin(), m_pImpl->m_aColumnDesc.end(),
306 [&_sName](const ColumnDesc& rColumnDesc) { return rColumnDesc.sName == _sName; });
307 if (aIter != m_pImpl->m_aColumnDesc.end())
308 pRet = &*aIter;
309 return pRet;
310}
311
312void OTableHelper::refreshPrimaryKeys(::std::vector< OUString>& _rNames)
313{
314 Any aCatalog;
315 if ( !m_CatalogName.isEmpty() )
316 aCatalog <<= m_CatalogName;
317 Reference< XResultSet > xResult = getMetaData()->getPrimaryKeys(aCatalog,m_SchemaName,m_Name);
318
319 if ( xResult.is() )
320 {
321 auto pKeyProps = std::make_shared<sdbcx::KeyProperties>(OUString(),KeyType::PRIMARY,0,0);
322 OUString aPkName;
323 bool bAlreadyFetched = false;
324 const Reference< XRow > xRow(xResult,UNO_QUERY);
325 while ( xResult->next() )
326 {
327 pKeyProps->m_aKeyColumnNames.push_back(xRow->getString(4));
328 if ( !bAlreadyFetched )
329 {
330 aPkName = xRow->getString(6);
331 SAL_WARN_IF(xRow->wasNull(),"connectivity.commontools", "NULL Primary Key name");
332 SAL_WARN_IF(aPkName.isEmpty(),"connectivity.commontools", "empty Primary Key name");
333 bAlreadyFetched = true;
334 }
335 }
336
337 if(bAlreadyFetched)
338 {
339 SAL_WARN_IF(aPkName.isEmpty(),"connectivity.commontools", "empty Primary Key name");
340 SAL_WARN_IF(pKeyProps->m_aKeyColumnNames.empty(),"connectivity.commontools", "Primary Key has no columns");
341 m_pImpl->m_aKeys.emplace(aPkName,pKeyProps);
342 _rNames.push_back(aPkName);
343 }
344 } // if ( xResult.is() && xResult->next() )
345 ::comphelper::disposeComponent(xResult);
346}
347
348void OTableHelper::refreshForeignKeys(::std::vector< OUString>& _rNames)
349{
350 Any aCatalog;
351 if ( !m_CatalogName.isEmpty() )
352 aCatalog <<= m_CatalogName;
353 Reference< XResultSet > xResult = getMetaData()->getImportedKeys(aCatalog,m_SchemaName,m_Name);
354 Reference< XRow > xRow(xResult,UNO_QUERY);
355
356 if ( !xRow.is() )
357 return;
358
359 std::shared_ptr<sdbcx::KeyProperties> pKeyProps;
360 OUString aName,sCatalog,aSchema,sOldFKName;
361 while( xResult->next() )
362 {
363 // this must be outside the "if" because we have to call in a right order
364 sCatalog = xRow->getString(1);
365 if ( xRow->wasNull() )
366 sCatalog.clear();
367 aSchema = xRow->getString(2);
368 aName = xRow->getString(3);
369
370 const OUString sForeignKeyColumn = xRow->getString(8);
371 const sal_Int32 nUpdateRule = xRow->getInt(10);
372 const sal_Int32 nDeleteRule = xRow->getInt(11);
373 const OUString sFkName = xRow->getString(12);
374
375 if ( !sFkName.isEmpty() && !xRow->wasNull() )
376 {
377 if ( sOldFKName != sFkName )
378 {
379 if ( pKeyProps )
380 m_pImpl->m_aKeys.emplace(sOldFKName,pKeyProps);
381
382 const OUString sReferencedName = ::dbtools::composeTableName(getMetaData(),sCatalog,aSchema,aName,false,::dbtools::EComposeRule::InDataManipulation);
383 pKeyProps = std::make_shared<sdbcx::KeyProperties>(sReferencedName,KeyType::FOREIGN,nUpdateRule,nDeleteRule);
384 pKeyProps->m_aKeyColumnNames.push_back(sForeignKeyColumn);
385 _rNames.push_back(sFkName);
386 if ( m_pTables->hasByName(sReferencedName) )
387 {
388 if ( !m_pImpl->m_xTablePropertyListener.is() )
389 m_pImpl->m_xTablePropertyListener = new OTableContainerListener(this);
390 m_pTables->addContainerListener(m_pImpl->m_xTablePropertyListener);
391 m_pImpl->m_xTablePropertyListener->add(sReferencedName);
392 } // if ( m_pTables->hasByName(sReferencedName) )
393 sOldFKName = sFkName;
394 } // if ( sOldFKName != sFkName )
395 else if ( pKeyProps )
396 {
397 pKeyProps->m_aKeyColumnNames.push_back(sForeignKeyColumn);
398 }
399 }
400 } // while( xResult->next() )
401 if ( pKeyProps )
402 m_pImpl->m_aKeys.emplace(sOldFKName,pKeyProps);
403 ::comphelper::disposeComponent(xResult);
404}
405
407{
408 m_pImpl->m_aKeys.clear();
409
410 ::std::vector< OUString> aNames;
411
412 if(!isNew())
413 {
414 refreshPrimaryKeys(aNames);
415 refreshForeignKeys(aNames);
416 m_xKeys.reset(createKeys(aNames));
417 } // if(!isNew())
418 else if (!m_xKeys )
419 m_xKeys.reset(createKeys(aNames));
420 /*if(m_pKeys)
421 m_pKeys->reFill(aVector);
422 else*/
423
424}
425
427{
428 ::std::vector< OUString> aVector;
429 if(!isNew())
430 {
431 // fill indexes
432 Any aCatalog;
433 if ( !m_CatalogName.isEmpty() )
434 aCatalog <<= m_CatalogName;
435 Reference< XResultSet > xResult = getMetaData()->getIndexInfo(aCatalog,m_SchemaName,m_Name,false,false);
436
437 if(xResult.is())
438 {
439 Reference< XRow > xRow(xResult,UNO_QUERY);
440 OUString sCatalogSep = getMetaData()->getCatalogSeparator();
441 OUString sPreviousRoundName;
442 while( xResult->next() )
443 {
444 OUString aName = xRow->getString(5);
445 if(!aName.isEmpty())
446 aName += sCatalogSep;
447 aName += xRow->getString(6);
448 if ( !aName.isEmpty() )
449 {
450 // don't insert the name if the last one we inserted was the same
451 if (sPreviousRoundName != aName)
452 aVector.push_back(aName);
453 }
454 sPreviousRoundName = aName;
455 }
456 ::comphelper::disposeComponent(xResult);
457 }
458 }
459
460 if(m_xIndexes)
461 m_xIndexes->reFill(aVector);
462 else
463 m_xIndexes.reset(createIndexes(aVector));
464}
465
467{
468 OUString sSql("RENAME ");
469 if ( m_Type == "VIEW" )
470 sSql += " VIEW ";
471 else
472 sSql += " TABLE ";
473
474 return sSql;
475}
476
477// XRename
478void SAL_CALL OTableHelper::rename( const OUString& newName )
479{
480 ::osl::MutexGuard aGuard(m_aMutex);
482#ifdef __GNUC__
483 ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed
484#else
485 rBHelper.bDisposed
486#endif
487 );
488
489 if(!isNew())
490 {
491 if ( m_pImpl->m_xRename.is() )
492 {
493 m_pImpl->m_xRename->rename(this,newName);
494 }
495 else
496 {
497 OUString sSql = getRenameStart();
498
499 OUString sCatalog,sSchema,sTable;
500 ::dbtools::qualifiedNameComponents(getMetaData(),newName,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation);
501
502 OUString sComposedName;
503 sComposedName = ::dbtools::composeTableName(getMetaData(),m_CatalogName,m_SchemaName,m_Name,true,::dbtools::EComposeRule::InDataManipulation);
504 sSql += sComposedName
505 + " TO ";
506 sComposedName = ::dbtools::composeTableName(getMetaData(),sCatalog,sSchema,sTable,true,::dbtools::EComposeRule::InDataManipulation);
507 sSql += sComposedName;
508
509 Reference< XStatement > xStmt = m_pImpl->m_xConnection->createStatement( );
510 if ( xStmt.is() )
511 {
512 xStmt->execute(sSql);
513 ::comphelper::disposeComponent(xStmt);
514 }
515 }
516
518 }
519 else
520 ::dbtools::qualifiedNameComponents(getMetaData(),newName,m_CatalogName,m_SchemaName,m_Name,::dbtools::EComposeRule::InTableDefinitions);
521}
522
523Reference< XDatabaseMetaData> OTableHelper::getMetaData() const
524{
525 return m_pImpl->m_xMetaData;
526}
527
528void SAL_CALL OTableHelper::alterColumnByIndex( sal_Int32 index, const Reference< XPropertySet >& descriptor )
529{
530 ::osl::MutexGuard aGuard(m_aMutex);
532#ifdef __GNUC__
533 ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed
534#else
535 rBHelper.bDisposed
536#endif
537 );
538
539 Reference< XPropertySet > xOld(
540 m_xColumns->getByIndex(index), css::uno::UNO_QUERY);
541 if(xOld.is())
543}
544
545
546OUString SAL_CALL OTableHelper::getName()
547{
548 OUString sComposedName = ::dbtools::composeTableName(getMetaData(),m_CatalogName,m_SchemaName,m_Name,false,::dbtools::EComposeRule::InDataManipulation);
549 return sComposedName;
550}
551
553{
554 return m_Name;
555}
556
557std::shared_ptr<sdbcx::KeyProperties> OTableHelper::getKeyProperties(const OUString& _sName) const
558{
559 std::shared_ptr<sdbcx::KeyProperties> pKeyProps;
560 TKeyMap::const_iterator aFind = m_pImpl->m_aKeys.find(_sName);
561 if ( aFind != m_pImpl->m_aKeys.end() )
562 {
563 pKeyProps = aFind->second;
564 }
565 else // only a fall back
566 {
567 OSL_FAIL("No key with the given name found");
568 pKeyProps = std::make_shared<sdbcx::KeyProperties>();
569 }
570
571 return pKeyProps;
572}
573
574void OTableHelper::addKey(const OUString& _sName,const std::shared_ptr<sdbcx::KeyProperties>& _aKeyProperties)
575{
576 m_pImpl->m_aKeys.emplace(_sName,_aKeyProperties);
577}
578
580{
581 return OUString();
582}
583
584Reference< XConnection> const & OTableHelper::getConnection() const
585{
586 return m_pImpl->m_xConnection;
587}
588
589Reference< css::sdb::tools::XTableRename> const & OTableHelper::getRenameService() const
590{
591 return m_pImpl->m_xRename;
592}
593
594Reference< css::sdb::tools::XTableAlteration> const & OTableHelper::getAlterService() const
595{
596 return m_pImpl->m_xAlter;
597}
598
599Reference< css::sdb::tools::XKeyAlteration> const & OTableHelper::getKeyService() const
600{
601 return m_pImpl->m_xKeyAlter;
602}
603
604Reference< css::sdb::tools::XIndexAlteration> const & OTableHelper::getIndexService() const
605{
606 return m_pImpl->m_xIndexAlter;
607}
608
609
610/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OptionalString sSchema
OptionalString sCatalog
OptionalString sComposedName
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
::dbtools::OPropertyMap & getPropMap()
Definition: TConnection.cxx:68
::std::unique_ptr< OTableHelperImpl > m_pImpl
virtual sdbcx::OCollection * createIndexes(const ::std::vector< OUString > &_rNames)=0
creates the index collection for the table
virtual void refreshIndexes() override
virtual sdbcx::OCollection * createKeys(const ::std::vector< OUString > &_rNames)=0
creates the key collection for the table
css::uno::Reference< css::sdbc::XConnection > const & getConnection() const
OTableHelper(sdbcx::OCollection *_pTables, const css::uno::Reference< css::sdbc::XConnection > &_xConnection, bool _bCase)
const OUString & getTableName()
virtual void SAL_CALL alterColumnByIndex(sal_Int32 index, const css::uno::Reference< css::beans::XPropertySet > &descriptor) override
virtual void SAL_CALL disposing() override
this function is called upon disposing the component
virtual void SAL_CALL rename(const OUString &newName) override
const ColumnDesc * getColumnDescription(const OUString &_sName) const
void addKey(const OUString &_sName, const std::shared_ptr< sdbcx::KeyProperties > &_aKeyProperties)
css::uno::Reference< css::sdb::tools::XTableRename > const & getRenameService() const
virtual OUString getTypeCreatePattern() const
virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > getMetaData() const override
void refreshForeignKeys(::std::vector< OUString > &_rKeys)
css::uno::Reference< css::sdb::tools::XIndexAlteration > const & getIndexService() const
virtual void refreshColumns() override
virtual OUString getRenameStart() const
The default returns "RENAME TABLE " or "RENAME VIEW " depending on the type.
virtual OUString SAL_CALL getName() override
void refreshPrimaryKeys(::std::vector< OUString > &_rKeys)
virtual ~OTableHelper() override
virtual sdbcx::OCollection * createColumns(const ::std::vector< OUString > &_rNames)=0
creates the column collection for the table
std::shared_ptr< sdbcx::KeyProperties > getKeyProperties(const OUString &_sName) const
css::uno::Reference< css::sdb::tools::XKeyAlteration > const & getKeyService() const
virtual void refreshKeys() override
css::uno::Reference< css::sdb::tools::XTableAlteration > const & getAlterService() const
virtual void SAL_CALL removeContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
virtual void SAL_CALL addContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
std::unique_ptr< OCollection > m_xIndexes
Definition: VTable.hxx:78
virtual void SAL_CALL alterColumnByName(const OUString &colName, const css::uno::Reference< css::beans::XPropertySet > &descriptor) override
Definition: VTable.cxx:265
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns() override
Definition: VTable.cxx:148
std::unique_ptr< OCollection > m_xKeys
Definition: VTable.hxx:76
std::unique_ptr< OCollection > m_xColumns
Definition: VTable.hxx:77
virtual void SAL_CALL rename(const OUString &newName) override
Definition: VTable.cxx:244
virtual void SAL_CALL disposing() override
Definition: VTable.cxx:131
OCollection * m_pTables
Definition: VTable.hxx:79
mutable::osl::Mutex m_aMutex
const OUString & getNameByIndex(sal_Int32 _nIndex) const
Definition: propertyids.cxx:95
OUString sName
OUString aName
void SAL_CALL elementReplaced(const css::container::ContainerEvent &Event) override
void SAL_CALL elementRemoved(const css::container::ContainerEvent &Event) override
DECL_LISTENERMULTIPLEXER_END void SAL_CALL elementInserted(const css::container::ContainerEvent &Event) override
#define SAL_WARN_IF(condition, area, stream)
@ Exception
bool normalize(sal_uInt16 &rDay, sal_uInt16 &rMonth, sal_Int16 &rYear)
OUString getString(const Any &_rAny)
Type
sal_Int32 OrdinalPosition
static OUString lcl_getServiceNameForSetting(const Reference< css::sdbc::XConnection > &_xConnection, const OUString &i_sSetting)
std::map< OUString, std::shared_ptr< sdbcx::KeyProperties > > TKeyMap
void checkDisposed(bool _bThrow)
Definition: dbtools.cxx:1951
bool getDataSourceSetting(const Reference< XInterface > &_xChild, const OUString &_sAsciiSettingsName, Any &_rSettingsValue)
Definition: dbtools2.cxx:594
OUString composeTableName(const Reference< XDatabaseMetaData > &_rxMetaData, const OUString &_rCatalog, const OUString &_rSchema, const OUString &_rName, bool _bQuote, EComposeRule _eComposeRule)
Definition: dbtools.cxx:1286
void qualifiedNameComponents(const Reference< XDatabaseMetaData > &_rxConnMetaData, const OUString &_rQualifiedName, OUString &_rCatalog, OUString &_rSchema, OUString &_rName, EComposeRule _eComposeRule)
Definition: dbtools.cxx:862
OUString newName(std::u16string_view aNewPrefix, std::u16string_view aOldPrefix, std::u16string_view old_Name)
void copy(const fs::path &src, const fs::path &dest)
index
#define PROPERTY_ID_NAME
Definition: propertyids.hxx:50
std::vector< ColumnDesc > m_aColumnDesc
Reference< css::sdb::tools::XKeyAlteration > m_xKeyAlter
OTableHelperImpl(const Reference< css::sdbc::XConnection > &_xConnection)
Reference< css::sdb::tools::XIndexAlteration > m_xIndexAlter
Reference< css::sdb::tools::XTableRename > m_xRename
Reference< css::sdbc::XDatabaseMetaData > m_xMetaData
Reference< css::sdbc::XConnection > m_xConnection
rtl::Reference< OTableContainerListener > m_xTablePropertyListener
Reference< css::sdb::tools::XTableAlteration > m_xAlter
OUString Name