Files
libreoffice/dbaccess/source/ui/control/tabletree.cxx

636 lines
22 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-06-14 17:39:53 +01:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-10-05 09:09:48 +00:00
#include "tabletree.hxx"
#include "imageprovider.hxx"
2000-10-05 09:09:48 +00:00
#include "moduledbu.hxx"
2002-08-19 07:01:32 +00:00
#include "dbu_control.hrc"
#include <vcl/layout.hxx>
2000-10-05 09:09:48 +00:00
#include <vcl/menu.hxx>
#include <vcl/builderfactory.hxx>
2000-10-05 09:09:48 +00:00
#include <connectivity/dbtools.hxx>
#include <comphelper/types.hxx>
2000-10-26 13:55:04 +00:00
#include "dbustrings.hrc"
#include <com/sun/star/sdb/application/DatabaseObject.hpp>
#include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
2000-10-05 09:09:48 +00:00
#include <com/sun/star/sdbc/XDriverAccess.hpp>
#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
2000-10-26 13:55:04 +00:00
#include <com/sun/star/sdb/SQLContext.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include "commontypes.hxx"
2001-01-30 07:29:43 +00:00
#include "listviewitems.hxx"
#include <tools/diagnose_ex.h>
2011-02-03 00:33:36 +01:00
#include <osl/diagnose.h>
#include <rtl/ustrbuf.hxx>
#include <connectivity/dbmetadata.hxx>
#include "svtools/treelistentry.hxx"
#include <o3tl/make_unique.hxx>
#include <algorithm>
2000-10-05 09:09:48 +00:00
namespace dbaui
{
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::sdb::application;
2000-10-05 09:09:48 +00:00
using namespace ::dbtools;
using namespace ::comphelper;
2000-10-05 09:09:48 +00:00
namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
namespace DatabaseObjectContainer = ::com::sun::star::sdb::application::DatabaseObjectContainer;
// OTableTreeListBox
OTableTreeListBox::OTableTreeListBox(vcl::Window* pParent, WinBits nWinStyle)
:OMarkableTreeListBox(pParent, nWinStyle)
,m_xImageProvider( new ImageProvider )
,m_bVirtualRoot(false)
,m_bNoEmptyFolders( false )
2000-10-05 09:09:48 +00:00
{
implSetDefaultImages();
2000-10-05 09:09:48 +00:00
}
VCL_BUILDER_FACTORY_CONSTRUCTOR(OTableTreeListBox, 0)
void OTableTreeListBox::implSetDefaultImages()
2002-04-29 07:49:48 +00:00
{
ImageProvider aImageProvider;
SetDefaultExpandedEntryBmp( ImageProvider::getFolderImage( DatabaseObject::TABLE ) );
SetDefaultCollapsedEntryBmp( ImageProvider::getFolderImage( DatabaseObject::TABLE ) );
}
2002-04-29 07:49:48 +00:00
bool OTableTreeListBox::isFolderEntry( const SvTreeListEntry* _pEntry )
{
sal_Int32 nEntryType = reinterpret_cast< sal_IntPtr >( _pEntry->GetUserData() );
return ( nEntryType == DatabaseObjectContainer::TABLES )
|| ( nEntryType == DatabaseObjectContainer::CATALOG )
|| ( nEntryType == DatabaseObjectContainer::SCHEMA );
}
void OTableTreeListBox::notifyHiContrastChanged()
{
implSetDefaultImages();
2002-04-29 07:49:48 +00:00
SvTreeListEntry* pEntryLoop = First();
2002-04-29 07:49:48 +00:00
while (pEntryLoop)
{
size_t nCount = pEntryLoop->ItemCount();
for (size_t i=0;i<nCount;++i)
2002-04-29 07:49:48 +00:00
{
SvLBoxItem& rItem = pEntryLoop->GetItem(i);
if (rItem.GetType() == SvLBoxItemType::ContextBmp)
2002-04-29 07:49:48 +00:00
{
SvLBoxContextBmp& rContextBitmapItem = static_cast< SvLBoxContextBmp& >( rItem );
2010-11-16 20:42:52 +00:00
Image aImage;
if ( isFolderEntry( pEntryLoop ) )
{
aImage = ImageProvider::getFolderImage( DatabaseObject::TABLE );
}
else
2002-04-29 07:49:48 +00:00
{
OUString sCompleteName( getQualifiedTableName( pEntryLoop ) );
m_xImageProvider->getImages( sCompleteName, DatabaseObject::TABLE, aImage );
2002-04-29 07:49:48 +00:00
}
rContextBitmapItem.SetBitmap1( aImage );
rContextBitmapItem.SetBitmap2( aImage );
break;
2002-04-29 07:49:48 +00:00
}
}
pEntryLoop = Next(pEntryLoop);
}
2000-10-05 09:09:48 +00:00
}
void OTableTreeListBox::implOnNewConnection( const Reference< XConnection >& _rxConnection )
2000-10-05 09:09:48 +00:00
{
m_xConnection = _rxConnection;
m_xImageProvider.reset( new ImageProvider( m_xConnection ) );
}
2000-10-05 09:09:48 +00:00
void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConnection )
{
Sequence< OUString > sTables, sViews;
2000-10-05 09:09:48 +00:00
OUString sCurrentActionError;
2000-10-05 09:09:48 +00:00
try
{
Reference< XTablesSupplier > xTableSupp( _rxConnection, UNO_QUERY_THROW );
sCurrentActionError = ModuleRes(STR_NOTABLEINFO);
2000-10-05 09:09:48 +00:00
Reference< XNameAccess > xTables,xViews;
Reference< XViewsSupplier > xViewSupp( _rxConnection, UNO_QUERY );
if ( xViewSupp.is() )
{
xViews = xViewSupp->getViews();
if (xViews.is())
sViews = xViews->getElementNames();
2000-10-05 09:09:48 +00:00
}
xTables = xTableSupp->getTables();
if (xTables.is())
sTables = xTables->getElementNames();
2000-10-05 09:09:48 +00:00
}
catch(RuntimeException&)
{
2011-02-25 17:47:41 +01:00
OSL_FAIL("OTableTreeListBox::UpdateTableList : caught an RuntimeException!");
2000-10-05 09:09:48 +00:00
}
catch ( const SQLException& )
{
throw;
}
2000-10-05 09:09:48 +00:00
catch(Exception&)
{
2010-12-04 12:33:49 +09:00
// a non-SQLException exception occurred ... simply throw an SQLException
SQLException aInfo;
aInfo.Message = sCurrentActionError;
throw aInfo;
2000-10-05 09:09:48 +00:00
}
UpdateTableList( _rxConnection, sTables, sViews );
2000-10-05 09:09:48 +00:00
}
namespace
{
struct OViewSetter
{
const Sequence< OUString> m_aViews;
::comphelper::UStringMixEqual m_aEqualFunctor;
2000-10-05 09:09:48 +00:00
OViewSetter(const Sequence< OUString>& _rViews,bool _bCase) : m_aViews(_rViews),m_aEqualFunctor(_bCase){}
OTableTreeListBox::TNames::value_type operator() (const OUString& name)
{
OTableTreeListBox::TNames::value_type aRet;
aRet.first = name;
const OUString* pIter = m_aViews.getConstArray();
const OUString* pEnd = m_aViews.getConstArray() + m_aViews.getLength();
aRet.second = std::any_of(pIter, pEnd,
[this, &name](const OUString& lhs)
{ return m_aEqualFunctor(lhs, name); } );
return aRet;
}
};
}
void OTableTreeListBox::UpdateTableList(
const Reference< XConnection >& _rxConnection,
const Sequence< OUString>& _rTables,
const Sequence< OUString>& _rViews
)
{
TNames aTables;
aTables.resize(_rTables.getLength());
const OUString* pIter = _rTables.getConstArray();
const OUString* pEnd = _rTables.getConstArray() + _rTables.getLength();
try
{
Reference< XDatabaseMetaData > xMeta( _rxConnection->getMetaData(), UNO_QUERY_THROW );
std::transform( pIter, pEnd,
aTables.begin(), OViewSetter( _rViews, xMeta->supportsMixedCaseQuotedIdentifiers() ) );
}
catch(Exception&)
{
DBG_UNHANDLED_EXCEPTION();
}
UpdateTableList( _rxConnection, aTables );
}
namespace
{
std::vector< OUString > lcl_getMetaDataStrings_throw( const Reference< XResultSet >& _rxMetaDataResult, sal_Int32 _nColumnIndex )
{
std::vector< OUString > aStrings;
Reference< XRow > xRow( _rxMetaDataResult, UNO_QUERY_THROW );
while ( _rxMetaDataResult->next() )
aStrings.push_back( xRow->getString( _nColumnIndex ) );
return aStrings;
}
bool lcl_shouldDisplayEmptySchemasAndCatalogs( const Reference< XConnection >& _rxConnection )
{
::dbtools::DatabaseMetaData aMetaData( _rxConnection );
return aMetaData.displayEmptyTableFolders();
}
}
void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConnection, const TNames& _rTables )
2000-10-05 09:09:48 +00:00
{
implOnNewConnection( _rxConnection );
2000-10-05 09:09:48 +00:00
// throw away all the old stuff
Clear();
try
{
2001-08-14 11:13:53 +00:00
if (haveVirtualRoot())
2001-02-05 13:45:04 +00:00
{
OUString sRootEntryText;
if ( std::none_of(_rTables.begin(),_rTables.end(),
[] (const TNames::value_type& name) { return !name.second; }) )
sRootEntryText = ModuleRes(STR_ALL_TABLES);
else if ( std::none_of(_rTables.begin(),_rTables.end(),
[] (const TNames::value_type& name) { return name.second; }) )
sRootEntryText = ModuleRes(STR_ALL_VIEWS);
2001-02-05 13:45:04 +00:00
else
sRootEntryText = ModuleRes(STR_ALL_TABLES_AND_VIEWS);
InsertEntry( sRootEntryText, nullptr, false, TREELIST_APPEND, reinterpret_cast< void* >( DatabaseObjectContainer::TABLES ) );
2001-02-05 13:45:04 +00:00
}
2001-01-30 07:29:43 +00:00
if ( _rTables.empty() )
// nothing to do (besides inserting the root entry)
return;
2000-10-05 09:09:48 +00:00
// get the table/view names
TNames::const_iterator aIter = _rTables.begin();
TNames::const_iterator aEnd = _rTables.end();
Reference< XDatabaseMetaData > xMeta( _rxConnection->getMetaData(), UNO_QUERY_THROW );
for ( ; aIter != aEnd; ++aIter )
2000-10-05 09:09:48 +00:00
{
2001-08-14 11:13:53 +00:00
// add the entry
implAddEntry(
xMeta,
aIter->first,
false
2001-08-14 11:13:53 +00:00
);
2000-10-05 09:09:48 +00:00
}
if ( !m_bNoEmptyFolders && lcl_shouldDisplayEmptySchemasAndCatalogs( _rxConnection ) )
{
bool bSupportsCatalogs = xMeta->supportsCatalogsInDataManipulation();
bool bSupportsSchemas = xMeta->supportsSchemasInDataManipulation();
if ( bSupportsCatalogs || bSupportsSchemas )
{
// we display empty catalogs if the DB supports catalogs, and they're noted at the beginning of a
// composed name. Otherwise, we display empty schematas. (also see the tree structure explained in
// implAddEntry)
bool bCatalogs = bSupportsCatalogs && xMeta->isCatalogAtStart();
std::vector< OUString > aFolderNames( lcl_getMetaDataStrings_throw(
bCatalogs ? xMeta->getCatalogs() : xMeta->getSchemas(), 1 ) );
sal_Int32 nFolderType = bCatalogs ? DatabaseObjectContainer::CATALOG : DatabaseObjectContainer::SCHEMA;
SvTreeListEntry* pRootEntry = getAllObjectsEntry();
for ( std::vector< OUString >::const_iterator folder = aFolderNames.begin();
folder != aFolderNames.end();
++folder
)
{
SvTreeListEntry* pFolder = GetEntryPosByName( *folder, pRootEntry );
if ( !pFolder )
InsertEntry( *folder, pRootEntry, false, TREELIST_APPEND, reinterpret_cast< void* >( nFolderType ) );
}
}
}
2000-10-05 09:09:48 +00:00
}
catch ( const Exception& )
2000-10-05 09:09:48 +00:00
{
DBG_UNHANDLED_EXCEPTION();
2000-10-05 09:09:48 +00:00
}
}
bool OTableTreeListBox::isWildcardChecked(SvTreeListEntry* _pEntry)
2001-01-30 07:29:43 +00:00
{
if (_pEntry)
{
OBoldListboxString* pTextItem = static_cast<OBoldListboxString*>(_pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING));
if (pTextItem)
return pTextItem->isEmphasized();
}
return false;
2001-01-30 07:29:43 +00:00
}
void OTableTreeListBox::checkWildcard(SvTreeListEntry* _pEntry)
2001-01-30 07:29:43 +00:00
{
SetCheckButtonState(_pEntry, SvButtonState::Checked);
2001-01-30 07:29:43 +00:00
checkedButton_noBroadcast(_pEntry);
}
SvTreeListEntry* OTableTreeListBox::getAllObjectsEntry() const
2001-01-30 07:29:43 +00:00
{
return haveVirtualRoot() ? First() : nullptr;
2001-01-30 07:29:43 +00:00
}
void OTableTreeListBox::checkedButton_noBroadcast(SvTreeListEntry* _pEntry)
2001-01-30 07:29:43 +00:00
{
OMarkableTreeListBox::checkedButton_noBroadcast(_pEntry);
// if an entry has children, it makes a difference if the entry is checked
// because all children are checked or if the user checked it explicitly.
2001-01-30 07:29:43 +00:00
// So we track explicit (un)checking
SvButtonState eState = GetCheckButtonState(_pEntry);
OSL_ENSURE(SvButtonState::Tristate != eState, "OTableTreeListBox::CheckButtonHdl: user action which lead to TRISTATE?");
implEmphasize(_pEntry, SvButtonState::Checked == eState);
2001-01-30 07:29:43 +00:00
}
void OTableTreeListBox::implEmphasize(SvTreeListEntry* _pEntry, bool _bChecked, bool _bUpdateDescendants, bool _bUpdateAncestors)
2001-01-30 07:29:43 +00:00
{
2011-02-03 00:33:36 +01:00
OSL_ENSURE(_pEntry, "OTableTreeListBox::implEmphasize: invalid entry (NULL)!");
// special emphasizing handling for the "all objects" entry
bool bAllObjectsEntryAffected = haveVirtualRoot() && (getAllObjectsEntry() == _pEntry);
2011-12-07 02:33:51 -08:00
if ( GetModel()->HasChildren(_pEntry) // the entry has children
|| bAllObjectsEntryAffected // or it is the "all objects" entry
)
2001-01-30 07:29:43 +00:00
{
OBoldListboxString* pTextItem = static_cast<OBoldListboxString*>(_pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING));
if (pTextItem)
pTextItem->emphasize(_bChecked);
if (bAllObjectsEntryAffected)
InvalidateEntry(_pEntry);
2001-01-30 07:29:43 +00:00
}
if (_bUpdateDescendants)
2001-01-30 07:29:43 +00:00
{
// remove the mark for all children of the checked entry
SvTreeListEntry* pChildLoop = FirstChild(_pEntry);
2001-01-30 07:29:43 +00:00
while (pChildLoop)
{
2011-12-07 02:33:51 -08:00
if (GetModel()->HasChildren(pChildLoop))
implEmphasize(pChildLoop, false, true, false);
2001-01-30 07:29:43 +00:00
pChildLoop = NextSibling(pChildLoop);
}
}
if (_bUpdateAncestors)
{
2001-01-30 07:29:43 +00:00
// remove the mark for all ancestors of the entry
if (GetModel()->HasParent(_pEntry))
implEmphasize(GetParent(_pEntry), false, false);
2001-01-30 07:29:43 +00:00
}
}
void OTableTreeListBox::InitEntry(SvTreeListEntry* _pEntry, const OUString& _rString, const Image& _rCollapsedBitmap, const Image& _rExpandedBitmap, SvLBoxButtonKind _eButtonKind)
2001-01-30 07:29:43 +00:00
{
OMarkableTreeListBox::InitEntry(_pEntry, _rString, _rCollapsedBitmap, _rExpandedBitmap, _eButtonKind);
2001-01-30 07:29:43 +00:00
// replace the text item with our own one
SvLBoxItem* pTextItem = _pEntry->GetFirstItem(SvLBoxItemType::String);
2011-02-03 00:33:36 +01:00
OSL_ENSURE(pTextItem, "OTableTreeListBox::InitEntry: no text item!?");
size_t nTextPos = _pEntry->GetPos(pTextItem);
OSL_ENSURE(SvTreeListEntry::ITEM_NOT_FOUND != nTextPos, "OTableTreeListBox::InitEntry: no text item pos!");
2001-01-30 07:29:43 +00:00
_pEntry->ReplaceItem(o3tl::make_unique<OBoldListboxString>(_rString), nTextPos);
2001-01-30 07:29:43 +00:00
}
SvTreeListEntry* OTableTreeListBox::implAddEntry(
const Reference< XDatabaseMetaData >& _rxMeta,
const OUString& _rTableName,
bool _bCheckName
2001-08-14 11:13:53 +00:00
)
{
OSL_PRECOND( _rxMeta.is(), "OTableTreeListBox::implAddEntry: invalid meta data!" );
if ( !_rxMeta.is() )
return nullptr;
// split the complete name into its components
OUString sCatalog, sSchema, sName;
qualifiedNameComponents( _rxMeta, _rTableName, sCatalog, sSchema, sName, ::dbtools::EComposeRule::InDataManipulation );
SvTreeListEntry* pParentEntry = getAllObjectsEntry();
2001-08-14 11:13:53 +00:00
// if the DB uses catalog at the start of identifiers, then our hierarchy is
// catalog
// +- schema
// +- table
// else it is
// schema
// +- catalog
// +- table
bool bCatalogAtStart = _rxMeta->isCatalogAtStart();
const OUString& rFirstName = bCatalogAtStart ? sCatalog : sSchema;
const sal_Int32 nFirstFolderType = bCatalogAtStart ? DatabaseObjectContainer::CATALOG : DatabaseObjectContainer::SCHEMA;
const OUString& rSecondName = bCatalogAtStart ? sSchema : sCatalog;
const sal_Int32 nSecondFolderType = bCatalogAtStart ? DatabaseObjectContainer::SCHEMA : DatabaseObjectContainer::CATALOG;
if ( !rFirstName.isEmpty() )
2001-08-14 11:13:53 +00:00
{
SvTreeListEntry* pFolder = GetEntryPosByName( rFirstName, pParentEntry );
if ( !pFolder )
pFolder = InsertEntry( rFirstName, pParentEntry, false, TREELIST_APPEND, reinterpret_cast< void* >( nFirstFolderType ) );
pParentEntry = pFolder;
2001-08-14 11:13:53 +00:00
}
if ( !rSecondName.isEmpty() )
2001-08-14 11:13:53 +00:00
{
SvTreeListEntry* pFolder = GetEntryPosByName( rSecondName, pParentEntry );
if ( !pFolder )
pFolder = InsertEntry( rSecondName, pParentEntry, false, TREELIST_APPEND, reinterpret_cast< void* >( nSecondFolderType ) );
pParentEntry = pFolder;
2001-08-14 11:13:53 +00:00
}
SvTreeListEntry* pRet = nullptr;
if ( !_bCheckName || !GetEntryPosByName( sName, pParentEntry ) )
{
pRet = InsertEntry( sName, pParentEntry );
2010-11-16 20:42:52 +00:00
Image aImage;
m_xImageProvider->getImages( _rTableName, DatabaseObject::TABLE, aImage );
SetExpandedEntryBmp( pRet, aImage );
SetCollapsedEntryBmp( pRet, aImage );
}
return pRet;
2001-08-14 11:13:53 +00:00
}
NamedDatabaseObject OTableTreeListBox::describeObject( SvTreeListEntry* _pEntry )
{
NamedDatabaseObject aObject;
sal_Int32 nEntryType = reinterpret_cast< sal_IntPtr >( _pEntry->GetUserData() );
if ( nEntryType == DatabaseObjectContainer::TABLES )
{
aObject.Type = DatabaseObjectContainer::TABLES;
}
else if ( ( nEntryType == DatabaseObjectContainer::CATALOG )
|| ( nEntryType == DatabaseObjectContainer::SCHEMA )
)
{
SvTreeListEntry* pParent = GetParent( _pEntry );
sal_Int32 nParentEntryType = pParent ? reinterpret_cast< sal_IntPtr >( pParent->GetUserData() ) : -1;
OUStringBuffer buffer;
if ( nEntryType == DatabaseObjectContainer::CATALOG )
{
if ( nParentEntryType == DatabaseObjectContainer::SCHEMA )
{
buffer.append( GetEntryText( pParent ) );
buffer.append( '.' );
}
buffer.append( GetEntryText( _pEntry ) );
}
else if ( nEntryType == DatabaseObjectContainer::SCHEMA )
{
if ( nParentEntryType == DatabaseObjectContainer::CATALOG )
{
buffer.append( GetEntryText( pParent ) );
buffer.append( '.' );
}
buffer.append( GetEntryText( _pEntry ) );
}
}
else
{
aObject.Type = DatabaseObject::TABLE;
aObject.Name = getQualifiedTableName( _pEntry );
}
return aObject;
}
SvTreeListEntry* OTableTreeListBox::addedTable( const OUString& _rName )
2001-08-14 11:13:53 +00:00
{
try
{
Reference< XDatabaseMetaData > xMeta;
if ( impl_getAndAssertMetaData( xMeta ) )
return implAddEntry( xMeta, _rName );
2001-08-14 11:13:53 +00:00
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
2001-08-14 11:13:53 +00:00
}
return nullptr;
2001-08-14 11:13:53 +00:00
}
bool OTableTreeListBox::impl_getAndAssertMetaData( Reference< XDatabaseMetaData >& _out_rMetaData ) const
{
if ( m_xConnection.is() )
_out_rMetaData = m_xConnection->getMetaData();
OSL_PRECOND( _out_rMetaData.is(), "OTableTreeListBox::impl_getAndAssertMetaData: invalid current connection!" );
return _out_rMetaData.is();
}
OUString OTableTreeListBox::getQualifiedTableName( SvTreeListEntry* _pEntry ) const
{
OSL_PRECOND( !isFolderEntry( _pEntry ), "OTableTreeListBox::getQualifiedTableName: folder entries not allowed here!" );
try
{
Reference< XDatabaseMetaData > xMeta;
if ( !impl_getAndAssertMetaData( xMeta ) )
return OUString();
OUString sCatalog;
OUString sSchema;
OUString sTable;
SvTreeListEntry* pSchema = GetParent( _pEntry );
if ( pSchema )
{
SvTreeListEntry* pCatalog = GetParent( pSchema );
if ( pCatalog
|| ( xMeta->supportsCatalogsInDataManipulation()
&& !xMeta->supportsSchemasInDataManipulation()
) // here we support catalog but no schema
)
{
if ( pCatalog == nullptr )
{
pCatalog = pSchema;
pSchema = nullptr;
}
sCatalog = GetEntryText( pCatalog );
}
if ( pSchema )
sSchema = GetEntryText(pSchema);
}
sTable = GetEntryText( _pEntry );
return ::dbtools::composeTableName( xMeta, sCatalog, sSchema, sTable, false, ::dbtools::EComposeRule::InDataManipulation );
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
return OUString();
}
SvTreeListEntry* OTableTreeListBox::getEntryByQualifiedName( const OUString& _rName )
2001-08-14 11:13:53 +00:00
{
try
{
Reference< XDatabaseMetaData > xMeta;
if ( !impl_getAndAssertMetaData( xMeta ) )
return nullptr;
// split the complete name into its components
OUString sCatalog, sSchema, sName;
qualifiedNameComponents(xMeta, _rName, sCatalog, sSchema, sName,::dbtools::EComposeRule::InDataManipulation);
SvTreeListEntry* pParent = getAllObjectsEntry();
SvTreeListEntry* pCat = nullptr;
SvTreeListEntry* pSchema = nullptr;
if ( !sCatalog.isEmpty() )
{
pCat = GetEntryPosByName(sCatalog, pParent);
if ( pCat )
pParent = pCat;
}
if ( !sSchema.isEmpty() )
{
pSchema = GetEntryPosByName(sSchema, pParent);
if ( pSchema )
pParent = pSchema;
2001-08-14 11:13:53 +00:00
}
return GetEntryPosByName(sName, pParent);
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
return nullptr;
}
void OTableTreeListBox::removedTable( const OUString& _rName )
{
try
{
SvTreeListEntry* pEntry = getEntryByQualifiedName( _rName );
if ( pEntry )
GetModel()->Remove( pEntry );
2001-08-14 11:13:53 +00:00
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
2001-08-14 11:13:53 +00:00
}
}
2000-10-05 09:09:48 +00:00
} // namespace dbaui
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */