diff options
Diffstat (limited to 'dbaccess/source/ui/relationdesign/RelationController.cxx')
-rw-r--r-- | dbaccess/source/ui/relationdesign/RelationController.cxx | 135 |
1 files changed, 32 insertions, 103 deletions
diff --git a/dbaccess/source/ui/relationdesign/RelationController.cxx b/dbaccess/source/ui/relationdesign/RelationController.cxx index 14653343bd4d..3bd2aa12a8ae 100644 --- a/dbaccess/source/ui/relationdesign/RelationController.cxx +++ b/dbaccess/source/ui/relationdesign/RelationController.cxx @@ -30,133 +30,50 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef _DBAU_REGHELPER_HXX_ #include "dbu_reghelper.hxx" -#endif -#ifndef _SFXSIDS_HRC #include <sfx2/sfxsids.hrc> -#endif -#ifndef _DBU_REL_HRC_ #include "dbu_rel.hrc" -#endif -#ifndef _SV_SVAPP_HXX #include <vcl/svapp.hxx> -#endif -#ifndef DBACCESS_UI_BROWSER_ID_HXX #include "browserids.hxx" -#endif -#ifndef _COMPHELPER_TYPES_HXX_ #include <comphelper/types.hxx> -#endif -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" -#endif -#ifndef _CONNECTIVITY_DBTOOLS_HXX_ #include <connectivity/dbtools.hxx> -#endif -#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_ #include <com/sun/star/frame/FrameSearchFlag.hpp> -#endif -#ifndef _COMPHELPER_EXTRACT_HXX_ #include <comphelper/extract.hxx> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ #include <com/sun/star/container/XChild.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ #include <com/sun/star/container/XNameContainer.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XTablesSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ #include <com/sun/star/sdbcx/KeyType.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_ #include <com/sun/star/sdbcx/XDrop.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XALTERTABLE_HPP_ #include <com/sun/star/sdbcx/XAlterTable.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_ #include <com/sun/star/sdbcx/XAppend.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XKeysSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ #include <com/sun/star/sdb/SQLContext.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_ #include <com/sun/star/sdbc/SQLWarning.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ #include <com/sun/star/sdbc/ColumnValue.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ #include <com/sun/star/sdbc/XRow.hpp> -#endif -#ifndef _DBHELPER_DBEXCEPTION_HXX_ #include <connectivity/dbexception.hxx> -#endif -#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_ +#include <connectivity/dbmetadata.hxx> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> -#endif -#ifndef _COMPHELPER_STREAMSECTION_HXX_ #include <comphelper/streamsection.hxx> -#endif -#ifndef _COMPHELPER_BASIC_IO_HXX_ #include <comphelper/basicio.hxx> -#endif -#ifndef _COMPHELPER_SEQSTREAM_HXX #include <comphelper/seqstream.hxx> -#endif -#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_ #include <com/sun/star/io/XActiveDataSource.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_ #include <com/sun/star/io/XActiveDataSink.hpp> -#endif -#ifndef _DBAUI_SQLMESSAGE_HXX_ #include "sqlmessage.hxx" -#endif -#ifndef DBAUI_RELATIONCONTROLLER_HXX #include "RelationController.hxx" -#endif -#ifndef _SV_MSGBOX_HXX #include <vcl/msgbox.hxx> -#endif #include "TableWindowData.hxx" -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" -#endif -#ifndef DBAUI_TOOLS_HXX #include "UITools.hxx" -#endif -#ifndef DBAUI_RTABLECONNECTIONDATA_HXX #include "RTableConnectionData.hxx" -#endif -#ifndef DBAUI_RELATION_TABLEVIEW_HXX #include "RelationTableView.hxx" -#endif -#ifndef DBAUI_RELATIONDESIGNVIEW_HXX #include "RelationDesignView.hxx" -#endif -#ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> -#endif -#ifndef TOOLS_DIAGNOSE_EX_H #include <tools/diagnose_ex.h> -#endif -#ifndef _SV_WAITOBJ_HXX #include <vcl/waitobj.hxx> -#endif #include <osl/thread.hxx> #include <vos/mutex.hxx> @@ -402,12 +319,12 @@ namespace { } - protected: - virtual ~RelationLoader(){} - /// Working method which should be overridden. virtual void SAL_CALL run(); virtual void SAL_CALL onTerminated(); + protected: + virtual ~RelationLoader(){} + void loadTableData(const Any& _aTable); }; @@ -565,9 +482,12 @@ void ORelationController::mergeData(const TTableConnectionData& _aConnectionData m_vTableData.push_back((*aConnDataIter)->getReferencedTable()); } } // for(;aConnDataIter != aConnDataEnd;++aConnDataIter) - --m_nThreadEvent; - if ( !m_nThreadEvent ) - Application::PostUserEvent(LINK(this, ORelationController, OnThreadFinished)); + if ( m_nThreadEvent ) + { + --m_nThreadEvent; + if ( !m_nThreadEvent ) + Application::PostUserEvent(LINK(this, ORelationController, OnThreadFinished)); + } } // ----------------------------------------------------------------------------- IMPL_LINK( ORelationController, OnThreadFinished, void*, /*NOTINTERESTEDIN*/ ) @@ -599,24 +519,33 @@ void ORelationController::loadData() { if ( !m_xTables.is() ) return; + DatabaseMetaData aMeta(getConnection()); // this may take some time const Reference< XDatabaseMetaData> xMetaData = getConnection()->getMetaData(); const Sequence< ::rtl::OUString> aNames = m_xTables->getElementNames(); const sal_Int32 nCount = aNames.getLength(); - const sal_Int32 nMaxElements = (nCount / MAX_THREADS) +1; - - sal_Int32 nStart = 0,nEnd = ::std::min(nMaxElements,nCount); - while(nStart != nEnd) + if ( aMeta.supportsThreads() ) { - ++m_nThreadEvent; - RelationLoader* pThread = new RelationLoader(this,xMetaData,m_xTables,aNames,nStart,nEnd); - pThread->createSuspended(); - pThread->setPriority(osl_Thread_PriorityBelowNormal); - pThread->resume(); - nStart = nEnd; - nEnd += nMaxElements; - nEnd = ::std::min(nEnd,nCount); - } // for(;pIter != pEnd;++pIter) + const sal_Int32 nMaxElements = (nCount / MAX_THREADS) +1; + sal_Int32 nStart = 0,nEnd = ::std::min(nMaxElements,nCount); + while(nStart != nEnd) + { + ++m_nThreadEvent; + RelationLoader* pThread = new RelationLoader(this,xMetaData,m_xTables,aNames,nStart,nEnd); + pThread->createSuspended(); + pThread->setPriority(osl_Thread_PriorityBelowNormal); + pThread->resume(); + nStart = nEnd; + nEnd += nMaxElements; + nEnd = ::std::min(nEnd,nCount); + } // for(;pIter != pEnd;++pIter) + } // if ( aMeta.supportsThreads() ) + else + { + RelationLoader* pThread = new RelationLoader(this,xMetaData,m_xTables,aNames,0,nCount); + pThread->run(); + pThread->onTerminated(); + } } catch(SQLException& e) { |