summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/relationdesign
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2008-06-06 13:14:00 +0000
committerRüdiger Timm <rt@openoffice.org>2008-06-06 13:14:00 +0000
commit376222422742020b9aa9a0be1b4b966982ba0d69 (patch)
tree8605ed8d2979c476caa48977cd0a80f9af7d5a8a /dbaccess/source/ui/relationdesign
parent9753d33d43e1542874a65a30ff07706ddb557a64 (diff)
INTEGRATION: CWS dba30c (1.15.8); FILE MERGED
2008/05/05 11:13:38 oj 1.15.8.1: #i87131# collect keys only once, getKeys always refetch keys
Diffstat (limited to 'dbaccess/source/ui/relationdesign')
-rw-r--r--dbaccess/source/ui/relationdesign/RTableConnectionData.cxx40
1 files changed, 12 insertions, 28 deletions
diff --git a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
index d25e9681e4f2..6e81b8b15088 100644
--- a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
+++ b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: RTableConnectionData.cxx,v $
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
* This file is part of OpenOffice.org.
*
@@ -124,13 +124,7 @@ BOOL ORelationTableConnectionData::DropRelation()
::osl::MutexGuard aGuard( m_aMutex );
////////////////////////////////////////////////////////////
// Relation loeschen
- Reference<XKeysSupplier> xSup(getReferencingTable()->getTable(),UNO_QUERY);
- Reference< XIndexAccess> xKeys;
- if(xSup.is() )
- xKeys = xSup->getKeys();
- else
- return FALSE;
-
+ Reference< XIndexAccess> xKeys = getReferencingTable()->getKeys();
if( m_aConnName.Len() && xKeys.is() )
{
const sal_Int32 nCount = xKeys->getCount();
@@ -201,12 +195,12 @@ void ORelationTableConnectionData::SetCardinality()
}
// -----------------------------------------------------------------------------
-BOOL ORelationTableConnectionData::checkPrimaryKey(const Reference< XPropertySet>& _xTable,EConnectionSide _eEConnectionSide) const
+BOOL ORelationTableConnectionData::checkPrimaryKey(const Reference< XIndexAccess>& _xKeys,EConnectionSide _eEConnectionSide) const
{
// check if Table has the primary key column dependig on _eEConnectionSide
USHORT nPrimKeysCount = 0,
nValidLinesCount = 0;
- ::std::vector<Reference<XNameAccess> > vKeyColumns = ::dbaui::getKeyColumns(_xTable,KeyType::PRIMARY);
+ ::std::vector<Reference<XNameAccess> > vKeyColumns = ::dbaui::getKeyColumns(_xKeys,KeyType::PRIMARY);
if ( vKeyColumns.size() == 1 )
{
// OSL_ENSURE(vKeyColumns.size()==1,"There can be only one primary key in a table!");
@@ -215,16 +209,16 @@ BOOL ORelationTableConnectionData::checkPrimaryKey(const Reference< XPropertySet
if ( xKeyColumns.is() )
{
aKeyColumns = xKeyColumns->getElementNames();
- const ::rtl::OUString* pKeyBegin = aKeyColumns.getConstArray();
- const ::rtl::OUString* pKeyEnd = pKeyBegin + aKeyColumns.getLength();
+ const ::rtl::OUString* pKeyIter = aKeyColumns.getConstArray();
+ const ::rtl::OUString* pKeyEnd = pKeyIter + aKeyColumns.getLength();
- for(;pKeyBegin != pKeyEnd;++pKeyBegin)
+ for(;pKeyIter != pKeyEnd;++pKeyIter)
{
OConnectionLineDataVec::const_iterator aIter = m_vConnLineData.begin();
for(;aIter != m_vConnLineData.end();++aIter)
{
++nValidLinesCount;
- if ( (*aIter)->GetFieldName(_eEConnectionSide) == *pKeyBegin )
+ if ( (*aIter)->GetFieldName(_eEConnectionSide) == *pKeyIter )
{
++nPrimKeysCount;
break;
@@ -320,23 +314,14 @@ BOOL ORelationTableConnectionData::Update()
////////////////////////////////////////////////////////////
// Alte Relation loeschen
{
- Reference<XKeysSupplier> xSup(getReferencingTable()->getTable(),UNO_QUERY);
- Reference< XIndexAccess> xKeys;
- if ( xSup.is() )
- xKeys = xSup->getKeys();
- else
- return FALSE;
-
DropRelation();
if( !IsConnectionPossible() )
return FALSE;
}
// reassign the keys because the orientaion could be changed
- Reference<XKeysSupplier> xSup(getReferencingTable()->getTable(),UNO_QUERY);
- Reference< XIndexAccess> xKeys;
- if ( xSup.is() )
- xKeys = xSup->getKeys();
+ Reference<XPropertySet> xTableProp(getReferencingTable()->getTable());
+ Reference< XIndexAccess> xKeys ( getReferencingTable()->getKeys());
if ( !xKeys.is() )
return FALSE;
@@ -349,12 +334,11 @@ BOOL ORelationTableConnectionData::Update()
Reference<XPropertySet> xKey = xKeyFactory->createDataDescriptor();
OSL_ENSURE(xKey.is(),"Key is null!");
- if ( xKey.is() )
+ if ( xKey.is() && xTableProp.is() )
{
// build a foreign key name
::rtl::OUString sSourceName;
- Reference<XPropertySet> xProp(xSup,UNO_QUERY_THROW);
- xProp->getPropertyValue(PROPERTY_NAME) >>= sSourceName;
+ xTableProp->getPropertyValue(PROPERTY_NAME) >>= sSourceName;
::rtl::OUString sKeyName = sSourceName;
sKeyName += getReferencedTable()->GetTableName();