Tag: cws_dev300_dba30c
User: oj      
Date: 2008-05-05 11:13:47+0000
Modified:
   dba/dbaccess/source/ui/inc/RTableConnectionData.hxx
   dba/dbaccess/source/ui/inc/TableWindowData.hxx
   dba/dbaccess/source/ui/inc/UITools.hxx
   dba/dbaccess/source/ui/misc/UITools.cxx
   dba/dbaccess/source/ui/misc/WCopyTable.cxx
   dba/dbaccess/source/ui/querydesign/JoinController.cxx
   dba/dbaccess/source/ui/querydesign/JoinTableView.cxx
   dba/dbaccess/source/ui/querydesign/QueryTableView.cxx
   dba/dbaccess/source/ui/querydesign/TableWindow.cxx
   dba/dbaccess/source/ui/querydesign/TableWindowData.cxx
   dba/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
   dba/dbaccess/source/ui/relationdesign/RelationController.cxx
   dba/dbaccess/source/ui/relationdesign/RelationTableView.cxx

Log:
 #i87131# collect keys only once, getKeys always refetch keys

File Changes:

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

File [changed]: RTableConnectionData.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/inc/RTableConnectionData.hxx?r1=1.8&r2=1.8.8.1
Delta lines:  +5 -5
-------------------
--- RTableConnectionData.hxx    2008-04-10 15:12:53+0000        1.8
+++ RTableConnectionData.hxx    2008-05-05 11:13:36+0000        1.8.8.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: RTableConnectionData.hxx,v $
- * $Revision: 1.8 $
+ * $Revision: 1.8.8.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -65,9 +65,9 @@
                sal_Int32 m_nDeleteRules;
                sal_Int32 m_nCardinality;
 
-               BOOL checkPrimaryKey(const ::com::sun::star::uno::Reference< 
::com::sun::star::beans::XPropertySet>& _xTable,EConnectionSide 
_eEConnectionSide) const;
-               BOOL IsSourcePrimKey()  const { return 
checkPrimaryKey(getReferencingTable()->getTable(),JTCS_FROM);    }
-               BOOL IsDestPrimKey()    const { return 
checkPrimaryKey(getReferencedTable()->getTable(),JTCS_TO);               }
+               BOOL checkPrimaryKey(const ::com::sun::star::uno::Reference< 
::com::sun::star::container::XIndexAccess>& _xKeys,EConnectionSide 
_eEConnectionSide) const;
+               BOOL IsSourcePrimKey()  const { return 
checkPrimaryKey(getReferencingTable()->getKeys(),JTCS_FROM);     }
+               BOOL IsDestPrimKey()    const { return 
checkPrimaryKey(getReferencedTable()->getKeys(),JTCS_TO);                }
 
        protected:
                virtual OConnectionLineDataRef CreateLineDataObj();

File [changed]: TableWindowData.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/inc/TableWindowData.hxx?r1=1.4&r2=1.4.8.1
Delta lines:  +7 -2
-------------------
--- TableWindowData.hxx 2008-04-10 15:19:56+0000        1.4
+++ TableWindowData.hxx 2008-05-05 11:13:36+0000        1.4.8.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: TableWindowData.hxx,v $
- * $Revision: 1.4 $
+ * $Revision: 1.4.8.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -35,6 +35,7 @@
 #endif
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
 #include <com/sun/star/sdbc/XConnection.hpp>
 #include <unotools/eventlisteneradapter.hxx>
 #include <boost/shared_ptr.hpp>
@@ -50,6 +51,7 @@
        protected:
         // the columns of the table
                ::com::sun::star::uno::Reference< 
::com::sun::star::beans::XPropertySet >       m_xTable; // can either be a 
table or a query
+        ::com::sun::star::uno::Reference< 
::com::sun::star::container::XIndexAccess>    m_xKeys;
                ::com::sun::star::uno::Reference< 
::com::sun::star::container::XNameAccess >    m_xColumns;
 
                ::rtl::OUString m_aTableName;
@@ -59,6 +61,7 @@
                Size                    m_aSize;
                sal_Bool                m_bShowAll;
         bool            m_bIsQuery;
+        bool            m_bIsValid;
 
        public:
                explicit OTableWindowData(  const 
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& 
_xTable
@@ -83,6 +86,7 @@
                inline Size GetSize()                                           
const { return m_aSize; }
                inline BOOL IsShowAll()                                     
const { return m_bShowAll; }
         inline bool isQuery()                       const { return m_bIsQuery; 
}
+        inline bool isValid()                       const { return m_bIsValid; 
} // it is either a table or query but it is known
                BOOL HasPosition()      const;
                BOOL HasSize()          const;
 
@@ -92,6 +96,7 @@
                inline void ShowAll( BOOL bAll )                                
                                { m_bShowAll = bAll; }        
 
         inline ::com::sun::star::uno::Reference< 
::com::sun::star::beans::XPropertySet> getTable() const { ::osl::MutexGuard 
aGuard( m_aMutex  ); return m_xTable; }
+        inline ::com::sun::star::uno::Reference< 
::com::sun::star::container::XIndexAccess> getKeys() const { ::osl::MutexGuard 
aGuard( m_aMutex  ); return m_xKeys; }   
         inline ::com::sun::star::uno::Reference< 
::com::sun::star::container::XNameAccess > getColumns() const { 
::osl::MutexGuard aGuard( m_aMutex  ); return m_xColumns; }
 
         // OEventListenerAdapter

File [changed]: UITools.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/inc/UITools.hxx?r1=1.35&r2=1.35.8.1
Delta lines:  +4 -3
-------------------
--- UITools.hxx 2008-04-10 15:21:37+0000        1.35
+++ UITools.hxx 2008-05-05 11:13:36+0000        1.35.8.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: UITools.hxx,v $
- * $Revision: 1.35 $
+ * $Revision: 1.35.8.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -58,6 +58,7 @@
        namespace container
        {
                class XNameAccess;
+        class XIndexAccess;
                class XHierarchicalNameContainer;
                class XNameContainer;
        }
@@ -150,7 +151,7 @@
        */
 
        ::std::vector< ::com::sun::star::uno::Reference< 
::com::sun::star::container::XNameAccess> >
-               getKeyColumns(  const ::com::sun::star::uno::Reference< 
::com::sun::star::beans::XPropertySet >& _rxTable,
+               getKeyColumns(  const ::com::sun::star::uno::Reference< 
::com::sun::star::container::XIndexAccess >& _rxKeys,
                                                sal_Int32 _nKeyType);
 
        /** fills a map and a vector with localized type names

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

File [changed]: UITools.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/UITools.cxx?r1=1.78&r2=1.78.4.1
Delta lines:  +6 -12
--------------------
--- UITools.cxx 2008-04-10 15:58:45+0000        1.78
+++ UITools.cxx 2008-05-05 11:13:37+0000        1.78.4.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: UITools.cxx,v $
- * $Revision: 1.78 $
+ * $Revision: 1.78.4.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -487,24 +487,18 @@
 }
 
 // 
-----------------------------------------------------------------------------
-::std::vector< Reference<XNameAccess> > getKeyColumns(const 
Reference<XPropertySet >& _rxTable,
+::std::vector< Reference<XNameAccess> > getKeyColumns(const 
Reference<XIndexAccess >& _rxKeys,
                                                                                
                          sal_Int32 _nKeyType)
 {
        // use keys and indexes for excat postioning
        // first the keys
-       Reference<XKeysSupplier> xKeySup(_rxTable,UNO_QUERY);
-       Reference<XIndexAccess> xKeys;
-       if(xKeySup.is())
-               xKeys = xKeySup->getKeys();
-
        ::std::vector< Reference<XNameAccess> > vRet;
-
-       if(xKeys.is())
+       if(_rxKeys.is())
        {
                Reference<XPropertySet> xProp;
-               for(sal_Int32 i=0;i< xKeys->getCount();++i)
+               for(sal_Int32 i=0;i< _rxKeys->getCount();++i)
                {
-                       xKeys->getByIndex(i) >>= xProp;
+                       _rxKeys->getByIndex(i) >>= xProp;
                        sal_Int32 nKeyType = 0;
                        xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
                        if(_nKeyType == nKeyType)

File [changed]: WCopyTable.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/WCopyTable.cxx?r1=1.56.16.2&r2=1.56.16.3
Delta lines:  +8 -3
-------------------
--- WCopyTable.cxx      2008-04-16 06:51:41+0000        1.56.16.2
+++ WCopyTable.cxx      2008-05-05 11:13:37+0000        1.56.16.3
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: WCopyTable.cxx,v $
- * $Revision: 1.56.16.2 $
+ * $Revision: 1.56.16.3 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -225,7 +225,12 @@
 //------------------------------------------------------------------------
 Sequence< ::rtl::OUString > ObjectCopySource::getPrimaryKeyColumnNames() const
 {
-    ::std::vector< Reference< XNameAccess > > aPrimaryKeyColumns( 
::dbaui::getKeyColumns( m_xObject, KeyType::PRIMARY ) );
+    Reference<XKeysSupplier> xSup(m_xObject,UNO_QUERY);
+       Reference< XIndexAccess> xKeys;
+       if(xSup.is() )
+               xKeys = xSup->getKeys();
+
+    ::std::vector< Reference< XNameAccess > > aPrimaryKeyColumns( 
::dbaui::getKeyColumns( xKeys, KeyType::PRIMARY ) );
     OSL_ENSURE( ( aPrimaryKeyColumns.size() == 1 ) || 
aPrimaryKeyColumns.empty(),
         "ObjectCopySource::getPrimaryKeyColumnNames: more than one primary 
key?!" );
 

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

File [changed]: JoinController.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/querydesign/JoinController.cxx?r1=1.46&r2=1.46.8.1
Delta lines:  +13 -10
---------------------
--- JoinController.cxx  2008-04-10 16:15:45+0000        1.46
+++ JoinController.cxx  2008-05-05 11:13:37+0000        1.46.8.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: JoinController.cxx,v $
- * $Revision: 1.46 $
+ * $Revision: 1.46.8.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -525,6 +525,8 @@
                }
        }
     TTableWindowData::value_type pData = 
createTableWindowData(sComposedName,sTableName,sWindowName);
+    if ( pData )
+    {
        pData->SetPosition(Point(nX,nY));
        pData->SetSize( Size( nWidth, nHeight ) );
     pData->ShowAll(bShowAll);
@@ -533,6 +535,7 @@
         m_aMinimumTableViewSize.X() = (nX+nWidth);
     if ( m_aMinimumTableViewSize.Y() < (nY+nHeight) )
         m_aMinimumTableViewSize.Y() = (nY+nHeight);
+    }
 }
 // 
-----------------------------------------------------------------------------
 void OJoinController::saveTableWindows(Sequence<PropertyValue>& _rViewProps)

File [changed]: JoinTableView.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/querydesign/JoinTableView.cxx?r1=1.59&r2=1.59.8.1
Delta lines:  +8 -3
-------------------
--- JoinTableView.cxx   2008-04-10 16:16:47+0000        1.59
+++ JoinTableView.cxx   2008-05-05 11:13:37+0000        1.59.8.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: JoinTableView.cxx,v $
- * $Revision: 1.59 $
+ * $Revision: 1.59.8.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -350,7 +350,12 @@
     try
     {
         if ( 
!pData->init(pParent->getController()->getConnection(),allowQueries()) )
+        {
+            if ( pData->isValid() )
             onNoColumns_throw();
+            else
+                pData.reset();
+        }
     }
        catch ( const SQLException& )
        {

File [changed]: QueryTableView.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/querydesign/QueryTableView.cxx?r1=1.43&r2=1.43.8.1
Delta lines:  +21 -30
---------------------
--- QueryTableView.cxx  2008-04-10 16:22:55+0000        1.43
+++ QueryTableView.cxx  2008-05-05 11:13:37+0000        1.43.8.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: QueryTableView.cxx,v $
- * $Revision: 1.43 $
+ * $Revision: 1.43.8.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -138,20 +138,17 @@
 namespace 
 {
        // 
-----------------------------------------------------------------------------
-       sal_Bool isColumnInKeyType(const Reference<XKeysSupplier>& 
_rxKeys,const ::rtl::OUString& _rColumnName,sal_Int32 _nKeyType)
+       sal_Bool isColumnInKeyType(const Reference<XIndexAccess>& _rxKeys,const 
::rtl::OUString& _rColumnName,sal_Int32 _nKeyType)
        {
                sal_Bool bReturn = sal_False;
                if(_rxKeys.is())
                {
-                       Reference< XIndexAccess> xKeyIndex = _rxKeys->getKeys();
-                       if ( !xKeyIndex.is() )
-                               return sal_False;
                        Reference<XColumnsSupplier> xColumnsSupplier;
                        // search the one and only primary key
-                       for(sal_Int32 i=0;i< xKeyIndex->getCount();++i)
+            const sal_Int32 nCount = _rxKeys->getCount();
+                       for(sal_Int32 i=0;i< nCount;++i)
                        {
-                               Reference<XPropertySet> xProp;
-                               
::cppu::extractInterface(xProp,xKeyIndex->getByIndex(i));
+                               Reference<XPropertySet> 
xProp(_rxKeys->getByIndex(i),UNO_QUERY);
                                if(xProp.is())
                                {
                                        sal_Int32 nKeyType = 0;
@@ -253,17 +250,17 @@
         OQueryTableConnectionData* pNewConnData = new 
OQueryTableConnectionData( _rSource.GetData(), _rDest.GetData() );
         TTableConnectionData::value_type aNewConnData(pNewConnData);
 
-               Reference<XKeysSupplier> xReferencedKeys( _rDest.GetTable(), 
UNO_QUERY );
+               Reference<XIndexAccess> xReferencedKeys( 
_rDest.GetData()->getKeys());
                ::rtl::OUString sRelatedColumn;
 
                // iterate through all foreignkey columns to create the 
connections
                Sequence< ::rtl::OUString> 
aElements(_rxSourceForeignKeyColumns->getElementNames());
-               const ::rtl::OUString* pBegin = aElements.getConstArray();
-               const ::rtl::OUString* pEnd   = pBegin + aElements.getLength();
-               for(sal_Int32 i=0;pBegin != pEnd;++pBegin,++i)
+               const ::rtl::OUString* pIter = aElements.getConstArray();
+               const ::rtl::OUString* pEnd   = pIter + aElements.getLength();
+               for(sal_Int32 i=0;pIter != pEnd;++pIter,++i)
                {
                        Reference<XPropertySet> xColumn;
-            if ( !( _rxSourceForeignKeyColumns->getByName(*pBegin) >>= xColumn 
) )
+            if ( !( _rxSourceForeignKeyColumns->getByName(*pIter) >>= xColumn 
) )
             {
                 OSL_ENSURE( false, "addConnections: invalid foreign key 
column!" );
                 continue;
@@ -275,7 +272,7 @@
                        
pNewConnData->SetFieldType(JTCS_TO,isColumnInKeyType(xReferencedKeys,sRelatedColumn,KeyType::PRIMARY)
 ? TAB_PRIMARY_FIELD : TAB_NORMAL_FIELD);
 
                        {
-                               Sequence< sal_Int16> 
aFind(::comphelper::findValue(_rSource.GetOriginalColumns()->getElementNames(),*pBegin,sal_True));
+                               Sequence< sal_Int16> 
aFind(::comphelper::findValue(_rSource.GetOriginalColumns()->getElementNames(),*pIter,sal_True));
                                if(aFind.getLength())
                                        
pNewConnData->SetFieldIndex(JTCS_FROM,aFind[0]+1);
                                else
@@ -291,7 +288,7 @@
                                else
                                        OSL_ENSURE(0,"Column not found!");
                        }
-                       pNewConnData->AppendConnLine(*pBegin,sRelatedColumn);
+                       pNewConnData->AppendConnLine(*pIter,sRelatedColumn);
 
                        // dann die Conn selber dazu
                        OQueryTableConnection aNewConn(_pView, aNewConnData);
@@ -511,19 +508,18 @@
 }
 // 
-----------------------------------------------------------------------------
 // find the table which has a foreign key with this referencedTable name 
-Reference<XPropertySet> getKeyReferencedTo(const Reference<XKeysSupplier>& 
_rxKeys,const ::rtl::OUString& _rReferencedTable)
+Reference<XPropertySet> getKeyReferencedTo(const Reference<XIndexAccess>& 
_rxKeys,const ::rtl::OUString& _rReferencedTable)
 {
        if(!_rxKeys.is())
                return Reference<XPropertySet>();
 
-       Reference< XIndexAccess> xKeyIndex = _rxKeys->getKeys();
-       if ( !xKeyIndex.is() )
+       if ( !_rxKeys.is() )
                return Reference<XPropertySet>();
        // search the one and only primary key
-       for(sal_Int32 i=0;i< xKeyIndex->getCount();++i)
+    const sal_Int32 nCount = _rxKeys->getCount();
+       for(sal_Int32 i=0;i<nCount ;++i)
        {
-               Reference<XPropertySet> xKey;
-               ::cppu::extractInterface(xKey,xKeyIndex->getByIndex(i));
+               Reference<XPropertySet> xKey(_rxKeys->getByIndex(i),UNO_QUERY);
                if(xKey.is())
                {
                        sal_Int32 nKeyType = 0;
@@ -603,11 +599,7 @@
         {
             
//////////////////////////////////////////////////////////////////////
                        // find relations between the table an the tables 
already inserted
-            Reference< XPropertySet > xTable( pNewTabWin->GetTable(), 
UNO_QUERY_THROW );
-                       Reference< XKeysSupplier > xKeys( xTable, UNO_QUERY );
-            if ( !xKeys.is() )
-                break;
-                       Reference< XIndexAccess> xKeyIndex = xKeys->getKeys();
+                       Reference< XIndexAccess> xKeyIndex = 
pNewTabWin->GetData()->getKeys();
                        if ( !xKeyIndex.is() )
                 break;
 
@@ -615,7 +607,7 @@
                        ::rtl::OUString aReferencedTable;
                        Reference<XColumnsSupplier> xColumnsSupplier;
 
-            sal_Int32 nKeyCount = xKeyIndex->getCount();
+            const sal_Int32 nKeyCount = xKeyIndex->getCount();
             for ( sal_Int32 i=0; i<nKeyCount ; ++i )
                        {
                 Reference< XPropertySet > xProp( xKeyIndex->getByIndex(i), 
UNO_QUERY_THROW );
@@ -663,8 +655,7 @@
                             continue;
 
                         OSL_ENSURE(pTabWinTmp,"TableWindow is null!");
-                        Reference< XKeysSupplier > xSupKeys( 
pTabWinTmp->GetTable(), UNO_QUERY );
-                                               Reference< XPropertySet > 
xFKKey = getKeyReferencedTo( xSupKeys, pNewTabWin->GetComposedName() );
+                                               Reference< XPropertySet > 
xFKKey = getKeyReferencedTo( pTabWinTmp->GetData()->getKeys(), 
pNewTabWin->GetComposedName() );
                         if ( !xFKKey.is() )
                             continue;
 

File [changed]: TableWindow.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/querydesign/TableWindow.cxx?r1=1.39&r2=1.39.8.1
Delta lines:  +17 -21
---------------------
--- TableWindow.cxx     2008-04-10 16:25:50+0000        1.39
+++ TableWindow.cxx     2008-05-05 11:13:38+0000        1.39.8.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: TableWindow.cxx,v $
- * $Revision: 1.39 $
+ * $Revision: 1.39.8.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -242,14 +242,11 @@
        try
        {
                // first we need the keys from the table
-               Reference< XKeysSupplier > xKeys( m_pData->getTable(), 
UNO_QUERY );
-               if ( xKeys.is() )
-               {
-                       Reference< XIndexAccess> xKeyIndex = xKeys->getKeys();
-                       Reference<XColumnsSupplier> xColumnsSupplier;
+               Reference< XIndexAccess> xKeyIndex = m_pData->getKeys();
                        // search the one and only primary key
                        if ( xKeyIndex.is() )
                        {
+            Reference<XColumnsSupplier> xColumnsSupplier;
                                for(sal_Int32 i=0;i< xKeyIndex->getCount();++i)
                                {
                                        Reference<XPropertySet> xProp;
@@ -269,7 +266,6 @@
                                        xPKeyColumns = 
xColumnsSupplier->getColumns();
                        }
                }
-       }
        catch(Exception&)
        {
                OSL_ENSURE(0,"Exception occured!");

File [changed]: TableWindowData.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/querydesign/TableWindowData.cxx?r1=1.13&r2=1.13.8.1
Delta lines:  +13 -3
--------------------
--- TableWindowData.cxx 2008-04-10 16:26:28+0000        1.13
+++ TableWindowData.cxx 2008-05-05 11:13:38+0000        1.13.8.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: TableWindowData.cxx,v $
- * $Revision: 1.13 $
+ * $Revision: 1.13.8.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -39,6 +39,7 @@
 #include <com/sun/star/sdb/XQueriesSupplier.hpp>
 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/container/XIndexAccess.hpp>
 
@@ -68,6 +69,7 @@
        ,m_aSize( Size(-1,-1) )
        ,m_bShowAll( TRUE )
     ,m_bIsQuery(false)
+    ,m_bIsValid(true)
 {
        DBG_CTOR(OTableWindowData,NULL);
        if( !m_aWinName.getLength() )
@@ -83,6 +85,10 @@
     Reference<XComponent> xComponent( m_xTable, UNO_QUERY );
        if ( xComponent.is() )
                stopComponentListening( xComponent );
+    // obtain the columns
+    xComponent.set( m_xColumns, UNO_QUERY );
+    if ( xComponent.is() )
+           stopComponentListening( xComponent );
 }
 
 
//------------------------------------------------------------------------------
@@ -124,7 +130,7 @@
     else if ( bIsKnownTable )
         m_xTable.set( xTables->getByName( m_sComposedName ), UNO_QUERY_THROW );
     else
-        DBG_ERROR( "OTableWindow::Init: this is neither a query (or no queries 
are allowed) nor a table!" );
+        m_bIsValid = false;
 
     // if we survived so far, we know whether it's a query
     m_bIsQuery = bIsKnownQuery;
@@ -151,6 +157,10 @@
         xComponent.set( m_xColumns, UNO_QUERY );
            if ( xComponent.is() )
                    startComponentListening( xComponent );
+
+        Reference<XKeysSupplier> xKeySup(m_xTable,UNO_QUERY);
+           if ( xKeySup.is() )
+                   m_xKeys = xKeySup->getKeys();
     }
 }
 // 
-----------------------------------------------------------------------------

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

File [changed]: RTableConnectionData.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx?r1=1.15&r2=1.15.8.1
Delta lines:  +14 -30
---------------------
--- RTableConnectionData.cxx    2008-04-10 16:31:23+0000        1.15
+++ RTableConnectionData.cxx    2008-05-05 11:13:38+0000        1.15.8.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: RTableConnectionData.cxx,v $
- * $Revision: 1.15 $
+ * $Revision: 1.15.8.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -124,13 +124,7 @@
        ::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 @@
 
 }
 // 
-----------------------------------------------------------------------------
-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 @@
                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 @@
        ////////////////////////////////////////////////////////////
        // 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 @@
 
        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();
 

File [changed]: RelationController.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/relationdesign/RelationController.cxx?r1=1.53&r2=1.53.4.1
Delta lines:  +87 -81
---------------------
--- RelationController.cxx      2008-04-10 16:32:29+0000        1.53
+++ RelationController.cxx      2008-05-05 11:13:38+0000        1.53.4.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: RelationController.cxx,v $
- * $Revision: 1.53 $
+ * $Revision: 1.53.4.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -412,37 +412,42 @@
 // 
-----------------------------------------------------------------------------
 void ORelationController::loadTableData(const Any& _aTable)
 {
-       Reference<XIndexAccess> xKeys;
-    Reference<XKeysSupplier> xKeySup(_aTable,UNO_QUERY);
+    Reference<XPropertySet> xTableProp(_aTable,UNO_QUERY);
+    const ::rtl::OUString sSourceName = ::dbtools::composeTableName( 
getConnection()->getMetaData(), xTableProp, ::dbtools::eInTableDefinitions, 
false, false, false );
+    TTableWindowData::value_type pReferencingTable = existsTable(sSourceName);
+    bool bNotFound = true, bAdded = false;
+    if ( !pReferencingTable )
+       {
+               pReferencingTable.reset(new 
OTableWindowData(xTableProp,sSourceName, sSourceName));
+               pReferencingTable->ShowAll(FALSE);
+        bAdded = true;
+               m_vTableData.push_back(pReferencingTable);
+       }
+
+       Reference<XIndexAccess> xKeys = pReferencingTable->getKeys();
+    Reference<XKeysSupplier> xKeySup(xTableProp,UNO_QUERY);
        
-       if ( xKeySup.is() )
+       if ( !xKeys.is() && 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)
+        const sal_Int32 nCount = xKeys->getCount();
+               for(sal_Int32 i = 0 ; i < nCount ; ++i)
                        {
                                xKeys->getByIndex(i) >>= xKey;
                                sal_Int32 nKeyType = 0;
                                xKey->getPropertyValue(PROPERTY_TYPE) >>= 
nKeyType;
                                if ( KeyType::FOREIGN == nKeyType )
                                {
-                                       ::rtl::OUString 
sSourceName,sReferencedTable;
-
-                                       sSourceName = 
::dbtools::composeTableName( getConnection()->getMetaData(), xTableProp, 
::dbtools::eInTableDefinitions, false, false, false );
+                bNotFound = false;
+                               ::rtl::OUString sReferencedTable;
                                        
xKey->getPropertyValue(PROPERTY_REFERENCEDTABLE) >>= sReferencedTable;
                                        
//////////////////////////////////////////////////////////////////////
                                        // insert windows
-                    TTableWindowData::value_type pReferencingTable = 
existsTable(sSourceName);
-                                       if ( !pReferencingTable )
-                                       {
-                                               pReferencingTable.reset(new 
OTableWindowData(xTableProp,sSourceName, sSourceName));
-                                               
pReferencingTable->ShowAll(FALSE);
-                                               
m_vTableData.push_back(pReferencingTable);
-                                       }
-
                     TTableWindowData::value_type pReferencedTable = 
existsTable(sReferencedTable);
                                        if ( !pReferencedTable )
                                        {
@@ -499,8 +504,9 @@
                                        pTabConnData->SetCardinality();
                                }
                        }
-               }
-       }
+       } // if ( xKeys.is() )
+    if ( bNotFound && bAdded ) 
+        m_vTableData.pop_back();
 }
 // 
-----------------------------------------------------------------------------
 TTableWindowData::value_type ORelationController::existsTable(const 
::rtl::OUString& _rComposedTableName)  const

File [changed]: RelationTableView.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/relationdesign/RelationTableView.cxx?r1=1.28&r2=1.28.8.1
Delta lines:  +3 -3
-------------------
--- RelationTableView.cxx       2008-04-10 16:33:38+0000        1.28
+++ RelationTableView.cxx       2008-05-05 11:13:39+0000        1.28.8.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: RelationTableView.cxx,v $
- * $Revision: 1.28 $
+ * $Revision: 1.28.8.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -259,7 +259,7 @@
 
        // die Anzahl der PKey-Felder in der Quelle
 
-       ::std::vector< Reference< XNameAccess> > aPkeys = 
::dbaui::getKeyColumns(pSourceWin->GetTable(),KeyType::PRIMARY);
+       ::std::vector< Reference< XNameAccess> > aPkeys = 
::dbaui::getKeyColumns(pSourceWin->GetData()->getKeys(),KeyType::PRIMARY);
     bool bAskUser = aPkeys.size() == 1 && Reference< 
XIndexAccess>(aPkeys[0],UNO_QUERY)->getCount() > 1;
 
     pTabConnData->SetConnLine( 0, sSourceFieldName, sDestFieldName );




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

Reply via email to