1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_dbtools.hxx" 26 #include <iterator> 27 #include "connectivity/TTableHelper.hxx" 28 #include <com/sun/star/sdbc/XRow.hpp> 29 #include <com/sun/star/sdbc/XResultSet.hpp> 30 #include <com/sun/star/sdbcx/KeyType.hpp> 31 #include <com/sun/star/sdbc/KeyRule.hpp> 32 #include <cppuhelper/typeprovider.hxx> 33 #include <com/sun/star/lang/DisposedException.hpp> 34 #include <com/sun/star/sdbc/ColumnValue.hpp> 35 #include <comphelper/implementationreference.hxx> 36 #include <comphelper/sequence.hxx> 37 #include <comphelper/extract.hxx> 38 #include <comphelper/types.hxx> 39 #include "connectivity/dbtools.hxx" 40 #include "connectivity/sdbcx/VCollection.hxx" 41 #include <unotools/sharedunocomponent.hxx> 42 #include "TConnection.hxx" 43 44 using namespace ::comphelper; 45 using namespace connectivity; 46 using namespace ::com::sun::star::uno; 47 using namespace ::com::sun::star::beans; 48 using namespace ::com::sun::star::sdbcx; 49 using namespace ::com::sun::star::sdbc; 50 using namespace ::com::sun::star::container; 51 using namespace ::com::sun::star::lang; 52 namespace 53 { 54 /// helper class for column property change events which holds the OComponentDefinition weak 55 typedef ::cppu::WeakImplHelper1 < XContainerListener > OTableContainerListener_BASE; 56 class OTableContainerListener : public OTableContainerListener_BASE 57 { 58 OTableHelper* m_pComponent; 59 ::std::map< ::rtl::OUString,bool> m_aRefNames; 60 61 OTableContainerListener(const OTableContainerListener&); 62 void operator =(const OTableContainerListener&); 63 protected: 64 virtual ~OTableContainerListener(){} 65 public: 66 OTableContainerListener(OTableHelper* _pComponent) : m_pComponent(_pComponent){} 67 virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& /*Event*/ ) 68 { 69 } 70 virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) 71 { 72 ::rtl::OUString sName; 73 Event.Accessor >>= sName; 74 if ( m_aRefNames.find(sName) != m_aRefNames.end() ) 75 m_pComponent->refreshKeys(); 76 } 77 virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) 78 { 79 ::rtl::OUString sOldComposedName,sNewComposedName; 80 Event.ReplacedElement >>= sOldComposedName; 81 Event.Accessor >>= sNewComposedName; 82 if ( sOldComposedName != sNewComposedName && m_aRefNames.find(sOldComposedName) != m_aRefNames.end() ) 83 m_pComponent->refreshKeys(); 84 } 85 // XEventListener 86 virtual void SAL_CALL disposing( const EventObject& /*_rSource*/ ) 87 { 88 } 89 void clear() { m_pComponent = NULL; } 90 inline void add(const ::rtl::OUString& _sRefName) { m_aRefNames.insert(::std::map< ::rtl::OUString,bool>::value_type(_sRefName,true)); } 91 }; 92 } 93 namespace connectivity 94 { 95 ::rtl::OUString lcl_getServiceNameForSetting(const Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,const ::rtl::OUString& i_sSetting) 96 { 97 ::rtl::OUString sSupportService; 98 Any aValue; 99 if ( ::dbtools::getDataSourceSetting(_xConnection,i_sSetting,aValue) ) 100 { 101 aValue >>= sSupportService; 102 } 103 return sSupportService; 104 } 105 struct OTableHelperImpl 106 { 107 TKeyMap m_aKeys; 108 // helper services which can be provided by extensions 109 Reference< ::com::sun::star::sdb::tools::XTableRename> m_xRename; 110 Reference< ::com::sun::star::sdb::tools::XTableAlteration> m_xAlter; 111 Reference< ::com::sun::star::sdb::tools::XKeyAlteration> m_xKeyAlter; 112 Reference< ::com::sun::star::sdb::tools::XIndexAlteration> m_xIndexAlter; 113 114 Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; 115 Reference< ::com::sun::star::sdbc::XConnection > m_xConnection; 116 ::comphelper::ImplementationReference< OTableContainerListener,XContainerListener> 117 m_xTablePropertyListener; 118 ::std::vector< ColumnDesc > m_aColumnDesc; 119 OTableHelperImpl(const Reference< ::com::sun::star::sdbc::XConnection >& _xConnection) 120 : m_xConnection(_xConnection) 121 { 122 try 123 { 124 m_xMetaData = m_xConnection->getMetaData(); 125 Reference<XMultiServiceFactory> xFac(_xConnection,UNO_QUERY); 126 if ( xFac.is() ) 127 { 128 static const ::rtl::OUString s_sTableRename(RTL_CONSTASCII_USTRINGPARAM("TableRenameServiceName")); 129 m_xRename.set(xFac->createInstance(lcl_getServiceNameForSetting(m_xConnection,s_sTableRename)),UNO_QUERY); 130 static const ::rtl::OUString s_sTableAlteration(RTL_CONSTASCII_USTRINGPARAM("TableAlterationServiceName")); 131 m_xAlter.set(xFac->createInstance(lcl_getServiceNameForSetting(m_xConnection,s_sTableAlteration)),UNO_QUERY); 132 static const ::rtl::OUString s_sKeyAlteration(RTL_CONSTASCII_USTRINGPARAM("KeyAlterationServiceName")); 133 m_xKeyAlter.set(xFac->createInstance(lcl_getServiceNameForSetting(m_xConnection,s_sKeyAlteration)),UNO_QUERY); 134 static const ::rtl::OUString s_sIndexAlteration(RTL_CONSTASCII_USTRINGPARAM("IndexAlterationServiceName")); 135 m_xIndexAlter.set(xFac->createInstance(lcl_getServiceNameForSetting(m_xConnection,s_sIndexAlteration)),UNO_QUERY); 136 } 137 } 138 catch(const Exception&) 139 { 140 } 141 } 142 }; 143 } 144 145 OTableHelper::OTableHelper( sdbcx::OCollection* _pTables, 146 const Reference< XConnection >& _xConnection, 147 sal_Bool _bCase) 148 :OTable_TYPEDEF(_pTables,_bCase) 149 ,m_pImpl(new OTableHelperImpl(_xConnection)) 150 { 151 } 152 // ------------------------------------------------------------------------- 153 OTableHelper::OTableHelper( sdbcx::OCollection* _pTables, 154 const Reference< XConnection >& _xConnection, 155 sal_Bool _bCase, 156 const ::rtl::OUString& _Name, 157 const ::rtl::OUString& _Type, 158 const ::rtl::OUString& _Description , 159 const ::rtl::OUString& _SchemaName, 160 const ::rtl::OUString& _CatalogName 161 ) : OTable_TYPEDEF(_pTables, 162 _bCase, 163 _Name, 164 _Type, 165 _Description, 166 _SchemaName, 167 _CatalogName) 168 ,m_pImpl(new OTableHelperImpl(_xConnection)) 169 { 170 } 171 // ----------------------------------------------------------------------------- 172 OTableHelper::~OTableHelper() 173 { 174 } 175 // ----------------------------------------------------------------------------- 176 void SAL_CALL OTableHelper::disposing() 177 { 178 ::osl::MutexGuard aGuard(m_aMutex); 179 if ( m_pImpl->m_xTablePropertyListener.is() ) 180 { 181 m_pTables->removeContainerListener(m_pImpl->m_xTablePropertyListener.getRef()); 182 m_pImpl->m_xTablePropertyListener->clear(); 183 m_pImpl->m_xTablePropertyListener.dispose(); 184 } 185 OTable_TYPEDEF::disposing(); 186 187 m_pImpl->m_xConnection = NULL; 188 m_pImpl->m_xMetaData = NULL; 189 190 } 191 192 // ------------------------------------------------------------------------- 193 namespace 194 { 195 /** collects ColumnDesc's from a resultset produced by XDatabaseMetaData::getColumns 196 */ 197 void lcl_collectColumnDescs_throw( const Reference< XResultSet >& _rxResult, ::std::vector< ColumnDesc >& _out_rColumns ) 198 { 199 Reference< XRow > xRow( _rxResult, UNO_QUERY_THROW ); 200 ::rtl::OUString sName; 201 OrdinalPosition nOrdinalPosition( 0 ); 202 while ( _rxResult->next() ) 203 { 204 sName = xRow->getString( 4 ); // COLUMN_NAME 205 sal_Int32 nField5 = xRow->getInt(5); 206 ::rtl::OUString aField6 = xRow->getString(6); 207 sal_Int32 nField7 = xRow->getInt(7) 208 , nField9 = xRow->getInt(9) 209 , nField11= xRow->getInt(11); 210 ::rtl::OUString sField12 = xRow->getString(12) 211 ,sField13 = xRow->getString(13); 212 nOrdinalPosition = xRow->getInt( 17 ); // ORDINAL_POSITION 213 _out_rColumns.push_back( ColumnDesc( sName,nField5,aField6,nField7,nField9,nField11,sField12,sField13, nOrdinalPosition ) ); 214 } 215 } 216 217 /** checks a given array of ColumnDesc's whether it has reasonable ordinal positions. If not, 218 they will be normalized to be the array index. 219 */ 220 void lcl_sanitizeColumnDescs( ::std::vector< ColumnDesc >& _rColumns ) 221 { 222 if ( _rColumns.empty() ) 223 return; 224 225 // collect all used ordinals 226 ::std::set< OrdinalPosition > aUsedOrdinals; 227 for ( ::std::vector< ColumnDesc >::iterator collect = _rColumns.begin(); 228 collect != _rColumns.end(); 229 ++collect 230 ) 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_ENSURE( false, "lcl_sanitizeColumnDescs: database did provide invalid ORDINAL_POSITION values!" ); 243 244 OrdinalPosition nNormalizedPosition = 1; 245 for ( ::std::vector< ColumnDesc >::iterator normalize = _rColumns.begin(); 246 normalize != _rColumns.end(); 247 ++normalize 248 ) 249 normalize->nOrdinalPosition = nNormalizedPosition++; 250 return; 251 } 252 253 // what's left is that the range might not be from 1 to <column count>, but for instance 254 // 0 to <column count>-1. 255 size_t nOffset = *aUsedOrdinals.begin() - 1; 256 for ( ::std::vector< ColumnDesc >::iterator offset = _rColumns.begin(); 257 offset != _rColumns.end(); 258 ++offset 259 ) 260 offset->nOrdinalPosition -= nOffset; 261 } 262 } 263 264 // ------------------------------------------------------------------------- 265 void OTableHelper::refreshColumns() 266 { 267 TStringVector aVector; 268 if(!isNew()) 269 { 270 Any aCatalog; 271 if ( m_CatalogName.getLength() ) 272 aCatalog <<= m_CatalogName; 273 274 ::utl::SharedUNOComponent< XResultSet > xResult( getMetaData()->getColumns( 275 aCatalog, 276 m_SchemaName, 277 m_Name, 278 ::rtl::OUString::createFromAscii("%") 279 ) ); 280 281 // collect the column names, together with their ordinal position 282 m_pImpl->m_aColumnDesc.clear(); 283 lcl_collectColumnDescs_throw( xResult, m_pImpl->m_aColumnDesc ); 284 285 // ensure that the ordinal positions as obtained from the meta data do make sense 286 lcl_sanitizeColumnDescs( m_pImpl->m_aColumnDesc ); 287 288 // sort by ordinal position 289 ::std::map< OrdinalPosition, ::rtl::OUString > aSortedColumns; 290 for ( ::std::vector< ColumnDesc >::const_iterator copy = m_pImpl->m_aColumnDesc.begin(); 291 copy != m_pImpl->m_aColumnDesc.end(); 292 ++copy 293 ) 294 aSortedColumns[ copy->nOrdinalPosition ] = copy->sName; 295 296 // copy them to aVector, now that we have the proper ordering 297 ::std::transform( 298 aSortedColumns.begin(), 299 aSortedColumns.end(), 300 ::std::insert_iterator< TStringVector >( aVector, aVector.begin() ), 301 ::std::select2nd< ::std::map< OrdinalPosition, ::rtl::OUString >::value_type >() 302 ); 303 } 304 305 if(m_pColumns) 306 m_pColumns->reFill(aVector); 307 else 308 m_pColumns = createColumns(aVector); 309 } 310 // ----------------------------------------------------------------------------- 311 const ColumnDesc* OTableHelper::getColumnDescription(const ::rtl::OUString& _sName) const 312 { 313 const ColumnDesc* pRet = NULL; 314 ::std::vector< ColumnDesc >::const_iterator aEnd = m_pImpl->m_aColumnDesc.end(); 315 for (::std::vector< ColumnDesc >::const_iterator aIter = m_pImpl->m_aColumnDesc.begin();aIter != aEnd;++aIter) 316 { 317 if ( aIter->sName == _sName ) 318 { 319 pRet = &*aIter; 320 break; 321 } 322 } // for (::std::vector< ColumnDesc >::const_iterator aIter = m_pImpl->m_aColumnDesc.begin();aIter != aEnd;++aIter) 323 return pRet; 324 } 325 // ------------------------------------------------------------------------- 326 void OTableHelper::refreshPrimaryKeys(TStringVector& _rNames) 327 { 328 Any aCatalog; 329 if ( m_CatalogName.getLength() ) 330 aCatalog <<= m_CatalogName; 331 Reference< XResultSet > xResult = getMetaData()->getPrimaryKeys(aCatalog,m_SchemaName,m_Name); 332 333 if ( xResult.is() ) 334 { 335 sdbcx::TKeyProperties pKeyProps(new sdbcx::KeyProperties(::rtl::OUString(),KeyType::PRIMARY,0,0)); 336 ::rtl::OUString aPkName; 337 bool bAlreadyFetched = false; 338 const Reference< XRow > xRow(xResult,UNO_QUERY); 339 while ( xResult->next() ) 340 { 341 pKeyProps->m_aKeyColumnNames.push_back(xRow->getString(4)); 342 if ( !bAlreadyFetched ) 343 { 344 aPkName = xRow->getString(6); 345 bAlreadyFetched = true; 346 } 347 } 348 349 m_pImpl->m_aKeys.insert(TKeyMap::value_type(aPkName,pKeyProps)); 350 _rNames.push_back(aPkName); 351 } // if ( xResult.is() && xResult->next() ) 352 ::comphelper::disposeComponent(xResult); 353 } 354 // ------------------------------------------------------------------------- 355 void OTableHelper::refreshForgeinKeys(TStringVector& _rNames) 356 { 357 Any aCatalog; 358 if ( m_CatalogName.getLength() ) 359 aCatalog <<= m_CatalogName; 360 Reference< XResultSet > xResult = getMetaData()->getImportedKeys(aCatalog,m_SchemaName,m_Name); 361 Reference< XRow > xRow(xResult,UNO_QUERY); 362 363 if ( xRow.is() ) 364 { 365 sdbcx::TKeyProperties pKeyProps; 366 ::rtl::OUString aName,sCatalog,aSchema,sOldFKName; 367 while( xResult->next() ) 368 { 369 // this must be outsid the "if" because we have to call in a right order 370 sCatalog = xRow->getString(1); 371 if ( xRow->wasNull() ) 372 sCatalog = ::rtl::OUString(); 373 aSchema = xRow->getString(2); 374 aName = xRow->getString(3); 375 376 const ::rtl::OUString sForeignKeyColumn = xRow->getString(8); 377 const sal_Int32 nUpdateRule = xRow->getInt(10); 378 const sal_Int32 nDeleteRule = xRow->getInt(11); 379 const ::rtl::OUString sFkName = xRow->getString(12); 380 381 if ( pKeyProps.get() ) 382 { 383 } 384 385 386 if ( sFkName.getLength() && !xRow->wasNull() ) 387 { 388 if ( sOldFKName != sFkName ) 389 { 390 if ( pKeyProps.get() ) 391 m_pImpl->m_aKeys.insert(TKeyMap::value_type(sOldFKName,pKeyProps)); 392 393 const ::rtl::OUString sReferencedName = ::dbtools::composeTableName(getMetaData(),sCatalog,aSchema,aName,sal_False,::dbtools::eInDataManipulation); 394 pKeyProps.reset(new sdbcx::KeyProperties(sReferencedName,KeyType::FOREIGN,nUpdateRule,nDeleteRule)); 395 pKeyProps->m_aKeyColumnNames.push_back(sForeignKeyColumn); 396 _rNames.push_back(sFkName); 397 if ( m_pTables->hasByName(sReferencedName) ) 398 { 399 if ( !m_pImpl->m_xTablePropertyListener.is() ) 400 m_pImpl->m_xTablePropertyListener = ::comphelper::ImplementationReference< OTableContainerListener,XContainerListener>( new OTableContainerListener(this) ); 401 m_pTables->addContainerListener(m_pImpl->m_xTablePropertyListener.getRef()); 402 m_pImpl->m_xTablePropertyListener->add(sReferencedName); 403 } // if ( m_pTables->hasByName(sReferencedName) ) 404 sOldFKName = sFkName; 405 } // if ( sOldFKName != sFkName ) 406 else if ( pKeyProps.get() ) 407 { 408 pKeyProps->m_aKeyColumnNames.push_back(sForeignKeyColumn); 409 } 410 } 411 } // while( xResult->next() ) 412 if ( pKeyProps.get() ) 413 m_pImpl->m_aKeys.insert(TKeyMap::value_type(sOldFKName,pKeyProps)); 414 ::comphelper::disposeComponent(xResult); 415 } 416 } 417 // ------------------------------------------------------------------------- 418 void OTableHelper::refreshKeys() 419 { 420 m_pImpl->m_aKeys.clear(); 421 422 TStringVector aNames; 423 424 if(!isNew()) 425 { 426 refreshPrimaryKeys(aNames); 427 refreshForgeinKeys(aNames); 428 m_pKeys = createKeys(aNames); 429 } // if(!isNew()) 430 else if (!m_pKeys ) 431 m_pKeys = createKeys(aNames); 432 /*if(m_pKeys) 433 m_pKeys->reFill(aVector); 434 else*/ 435 436 } 437 // ------------------------------------------------------------------------- 438 void OTableHelper::refreshIndexes() 439 { 440 TStringVector aVector; 441 if(!isNew()) 442 { 443 // fill indexes 444 Any aCatalog; 445 if ( m_CatalogName.getLength() ) 446 aCatalog <<= m_CatalogName; 447 Reference< XResultSet > xResult = getMetaData()->getIndexInfo(aCatalog,m_SchemaName,m_Name,sal_False,sal_False); 448 449 if(xResult.is()) 450 { 451 Reference< XRow > xRow(xResult,UNO_QUERY); 452 ::rtl::OUString aName; 453 ::rtl::OUString sCatalogSep = getMetaData()->getCatalogSeparator(); 454 ::rtl::OUString sPreviousRoundName; 455 while( xResult->next() ) 456 { 457 aName = xRow->getString(5); 458 if(aName.getLength()) 459 aName += sCatalogSep; 460 aName += xRow->getString(6); 461 if ( aName.getLength() ) 462 { 463 // don't insert the name if the last one we inserted was the same 464 if (sPreviousRoundName != aName) 465 aVector.push_back(aName); 466 } 467 sPreviousRoundName = aName; 468 } 469 ::comphelper::disposeComponent(xResult); 470 } 471 } 472 473 if(m_pIndexes) 474 m_pIndexes->reFill(aVector); 475 else 476 m_pIndexes = createIndexes(aVector); 477 } 478 // ----------------------------------------------------------------------------- 479 ::rtl::OUString OTableHelper::getRenameStart() const 480 { 481 ::rtl::OUString sSql(RTL_CONSTASCII_USTRINGPARAM("RENAME ")); 482 if ( m_Type == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW")) ) 483 sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" VIEW ")); 484 else 485 sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" TABLE ")); 486 487 return sSql; 488 } 489 // ------------------------------------------------------------------------- 490 // XRename 491 void SAL_CALL OTableHelper::rename( const ::rtl::OUString& newName ) 492 { 493 ::osl::MutexGuard aGuard(m_aMutex); 494 checkDisposed( 495 #ifdef GCC 496 ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed 497 #else 498 rBHelper.bDisposed 499 #endif 500 ); 501 502 if(!isNew()) 503 { 504 if ( m_pImpl->m_xRename.is() ) 505 { 506 m_pImpl->m_xRename->rename(this,newName); 507 } 508 else 509 { 510 ::rtl::OUString sSql = getRenameStart(); 511 ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( ); 512 513 ::rtl::OUString sCatalog,sSchema,sTable; 514 ::dbtools::qualifiedNameComponents(getMetaData(),newName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation); 515 516 ::rtl::OUString sComposedName; 517 sComposedName = ::dbtools::composeTableName(getMetaData(),m_CatalogName,m_SchemaName,m_Name,sal_True,::dbtools::eInDataManipulation); 518 sSql += sComposedName 519 + ::rtl::OUString::createFromAscii(" TO "); 520 sComposedName = ::dbtools::composeTableName(getMetaData(),sCatalog,sSchema,sTable,sal_True,::dbtools::eInDataManipulation); 521 sSql += sComposedName; 522 523 Reference< XStatement > xStmt = m_pImpl->m_xConnection->createStatement( ); 524 if ( xStmt.is() ) 525 { 526 xStmt->execute(sSql); 527 ::comphelper::disposeComponent(xStmt); 528 } 529 } 530 531 OTable_TYPEDEF::rename(newName); 532 } 533 else 534 ::dbtools::qualifiedNameComponents(getMetaData(),newName,m_CatalogName,m_SchemaName,m_Name,::dbtools::eInTableDefinitions); 535 } 536 // ----------------------------------------------------------------------------- 537 Reference< XDatabaseMetaData> OTableHelper::getMetaData() const 538 { 539 return m_pImpl->m_xMetaData; 540 } 541 // ------------------------------------------------------------------------- 542 void SAL_CALL OTableHelper::alterColumnByIndex( sal_Int32 index, const Reference< XPropertySet >& descriptor ) 543 { 544 ::osl::MutexGuard aGuard(m_aMutex); 545 checkDisposed( 546 #ifdef GCC 547 ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed 548 #else 549 rBHelper.bDisposed 550 #endif 551 ); 552 553 Reference< XPropertySet > xOld; 554 if(::cppu::extractInterface(xOld,m_pColumns->getByIndex(index)) && xOld.is()) 555 alterColumnByName(getString(xOld->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))),descriptor); 556 } 557 558 // ------------------------------------------------------------------------- 559 ::rtl::OUString SAL_CALL OTableHelper::getName() 560 { 561 ::rtl::OUString sComposedName; 562 sComposedName = ::dbtools::composeTableName(getMetaData(),m_CatalogName,m_SchemaName,m_Name,sal_False,::dbtools::eInDataManipulation); 563 return sComposedName; 564 } 565 // ----------------------------------------------------------------------------- 566 void SAL_CALL OTableHelper::acquire() throw() 567 { 568 OTable_TYPEDEF::acquire(); 569 } 570 // ----------------------------------------------------------------------------- 571 void SAL_CALL OTableHelper::release() throw() 572 { 573 OTable_TYPEDEF::release(); 574 } 575 // ----------------------------------------------------------------------------- 576 sdbcx::TKeyProperties OTableHelper::getKeyProperties(const ::rtl::OUString& _sName) const 577 { 578 sdbcx::TKeyProperties pKeyProps; 579 TKeyMap::const_iterator aFind = m_pImpl->m_aKeys.find(_sName); 580 if ( aFind != m_pImpl->m_aKeys.end() ) 581 { 582 pKeyProps = aFind->second; 583 } 584 else // only a fall back 585 { 586 OSL_ENSURE(0,"No key with the given name found"); 587 pKeyProps.reset(new sdbcx::KeyProperties()); 588 } 589 590 return pKeyProps; 591 } 592 // ----------------------------------------------------------------------------- 593 void OTableHelper::addKey(const ::rtl::OUString& _sName,const sdbcx::TKeyProperties& _aKeyProperties) 594 { 595 m_pImpl->m_aKeys.insert(TKeyMap::value_type(_sName,_aKeyProperties)); 596 } 597 // ----------------------------------------------------------------------------- 598 ::rtl::OUString OTableHelper::getTypeCreatePattern() const 599 { 600 return ::rtl::OUString(); 601 } 602 // ----------------------------------------------------------------------------- 603 Reference< XConnection> OTableHelper::getConnection() const 604 { 605 return m_pImpl->m_xConnection; 606 } 607 // ----------------------------------------------------------------------------- 608 Reference< ::com::sun::star::sdb::tools::XTableRename> OTableHelper::getRenameService() const 609 { 610 return m_pImpl->m_xRename; 611 } 612 // ----------------------------------------------------------------------------- 613 Reference< ::com::sun::star::sdb::tools::XTableAlteration> OTableHelper::getAlterService() const 614 { 615 return m_pImpl->m_xAlter; 616 } 617 // ----------------------------------------------------------------------------- 618 Reference< ::com::sun::star::sdb::tools::XKeyAlteration> OTableHelper::getKeyService() const 619 { 620 return m_pImpl->m_xKeyAlter; 621 } 622 // ----------------------------------------------------------------------------- 623 Reference< ::com::sun::star::sdb::tools::XIndexAlteration> OTableHelper::getIndexService() const 624 { 625 return m_pImpl->m_xIndexAlter; 626 } 627 // ----------------------------------------------------------------------------- 628