User: hr      
Date: 2007-11-01 15:37:38+0000
Modified:
   dba/dbaccess/source/ui/relationdesign/RelationController.cxx

Log:
 INTEGRATION: CWS dba24b (1.47.28); FILE MERGED
 2007/09/28 12:00:55 oj 1.47.28.2: RESYNC: (1.47-1.48); FILE MERGED
 2007/08/16 06:14:45 oj 1.47.28.1: #i56898# clean up of the class structure

File Changes:

Directory: /dba/dbaccess/source/ui/relationdesign/
==================================================

File [changed]: RelationController.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/relationdesign/RelationController.cxx?r1=1.48&r2=1.49
Delta lines:  +23 -24
---------------------
--- RelationController.cxx      2007-09-26 14:53:22+0000        1.48
+++ RelationController.cxx      2007-11-01 15:37:35+0000        1.49
@@ -137,9 +137,7 @@
 #ifndef _SV_MSGBOX_HXX 
 #include <vcl/msgbox.hxx>
 #endif
-#ifndef DBAUI_TABLEWINDOWDATA_HXX
 #include "TableWindowData.hxx"
-#endif
 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
 #include "dbustrings.hrc"
 #endif
@@ -438,14 +436,14 @@
 void ORelationController::loadTableData(const Any& _aTable)
 {
        Reference<XIndexAccess> xKeys;
-       Reference<XKeysSupplier> xKeySup;
-       _aTable >>= xKeySup;
+    Reference<XKeysSupplier> xKeySup(_aTable,UNO_QUERY);
        
        if ( xKeySup.is() )
        {
                xKeys = xKeySup->getKeys();
                if ( xKeys.is() )
                {
+            Reference<XPropertySet> xTableProp(xKeySup,UNO_QUERY);
                        Reference<XPropertySet> xKey;
                        for(sal_Int32 i=0;i< xKeys->getCount();++i)
                        {
@@ -455,32 +453,39 @@
                                if ( KeyType::FOREIGN == nKeyType )
                                {
                                        ::rtl::OUString 
sSourceName,sReferencedTable;
-                                       Reference<XPropertySet> 
xTableProp(xKeySup,UNO_QUERY);
 
                                        sSourceName = 
::dbtools::composeTableName( getConnection()->getMetaData(), xTableProp, 
::dbtools::eInTableDefinitions, false, false, false );
                                        
xKey->getPropertyValue(PROPERTY_REFERENCEDTABLE) >>= sReferencedTable;
                                        
//////////////////////////////////////////////////////////////////////
                                        // insert windows
-                                       if ( !existsTable(sSourceName) )
+                    TTableWindowData::value_type pReferencingTable = 
existsTable(sSourceName);
+                                       if ( !pReferencingTable )
                                        {
-                                               OTableWindowData* pData = new 
OTableWindowData(sSourceName, sSourceName);
-                                               pData->ShowAll(FALSE);
-                                               m_vTableData.push_back(pData);
+                                               pReferencingTable.reset(new 
OTableWindowData(xTableProp,sSourceName, sSourceName));
+                                               
pReferencingTable->ShowAll(FALSE);
+                                               
m_vTableData.push_back(pReferencingTable);
                                        }
 
-                                       if ( !existsTable(sReferencedTable) )
+                    TTableWindowData::value_type pReferencedTable = 
existsTable(sReferencedTable);
+                                       if ( !pReferencedTable )
                                        {
-                                               OTableWindowData* pData = new 
OTableWindowData(sReferencedTable, sReferencedTable);
-                                               pData->ShowAll(FALSE);
-                                               m_vTableData.push_back(pData);
+                        if ( m_xTables->hasByName(sReferencedTable) )
+                        {
+                            Reference<XPropertySet>  
xReferencedTable(m_xTables->getByName(sReferencedTable),UNO_QUERY);
+                                                   pReferencedTable.reset(new 
OTableWindowData(xReferencedTable,sReferencedTable, sReferencedTable));
+                                                   
pReferencedTable->ShowAll(FALSE);
+                                                   
m_vTableData.push_back(pReferencedTable);
+                        }
+                        else
+                            continue; // table name could not be found so we 
do not show this table releation
                                        }
 
                                        ::rtl::OUString sKeyName;
                                        xKey->getPropertyValue(PROPERTY_NAME) 
>>= sKeyName;
                                        
//////////////////////////////////////////////////////////////////////
                                        // insert connection
-                                       ORelationTableConnectionData* 
pTabConnData = new ORelationTableConnectionData( m_xTables, sSourceName, 
sReferencedTable, sKeyName );
-                                       
m_vTableConnectionData.push_back(pTabConnData);
+                    ORelationTableConnectionData* pTabConnData = new 
ORelationTableConnectionData( pReferencingTable, pReferencedTable, sKeyName );
+                    
m_vTableConnectionData.push_back(TTableConnectionData::value_type(pTabConnData));
                                        
//////////////////////////////////////////////////////////////////////
                                        // insert columns
                                        Reference<XColumnsSupplier> 
xColsSup(xKey,UNO_QUERY);
@@ -521,23 +526,17 @@
        }
 }
 // 
-----------------------------------------------------------------------------
-sal_Bool ORelationController::existsTable(const ::rtl::OUString& 
_rComposedTableName)  const
+TTableWindowData::value_type ORelationController::existsTable(const 
::rtl::OUString& _rComposedTableName)  const
 {
        Reference<XDatabaseMetaData> xMeta = getConnection()->getMetaData();
        ::comphelper::UStringMixEqual bCase(xMeta.is() && 
xMeta->supportsMixedCaseQuotedIdentifiers());
-       ::std::vector<OTableWindowData*>::const_iterator aIter = 
m_vTableData.begin();
+       TTableWindowData::const_iterator aIter = m_vTableData.begin();
        for(;aIter != m_vTableData.end();++aIter)
        {
                if(bCase((*aIter)->GetComposedName(),_rComposedTableName))
                        break;
        }
-       return aIter != m_vTableData.end();
-}
-
-// 
-----------------------------------------------------------------------------
-OTableWindowData* ORelationController::createTableWindowData()
-{
-       return new OTableWindowData();
+    return ( aIter != m_vTableData.end()) ? *aIter : 
TTableWindowData::value_type();
 }
 // 
-----------------------------------------------------------------------------
 void ORelationController::loadLayoutInformation()




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to