1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: RelationController.cxx,v $
10 * $Revision: 1.56.24.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef _DBAU_REGHELPER_HXX_
34 #include "dbu_reghelper.hxx"
37 #include <sfx2/sfxsids.hrc>
40 #include "dbu_rel.hrc"
43 #include <vcl/svapp.hxx>
45 #ifndef DBACCESS_UI_BROWSER_ID_HXX
46 #include "browserids.hxx"
48 #ifndef _COMPHELPER_TYPES_HXX_
49 #include <comphelper/types.hxx>
51 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
52 #include "dbustrings.hrc"
54 #ifndef _CONNECTIVITY_DBTOOLS_HXX_
55 #include <connectivity/dbtools.hxx>
57 #ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
58 #include <com/sun/star/frame/FrameSearchFlag.hpp>
60 #ifndef _COMPHELPER_EXTRACT_HXX_
61 #include <comphelper/extract.hxx>
63 #ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
64 #include <com/sun/star/container/XChild.hpp>
66 #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
67 #include <com/sun/star/container/XNameContainer.hpp>
69 #ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
70 #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
72 #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
73 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
75 #ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_
76 #include <com/sun/star/sdbcx/KeyType.hpp>
78 #ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_
79 #include <com/sun/star/sdbcx/XDrop.hpp>
81 #ifndef _COM_SUN_STAR_SDBCX_XALTERTABLE_HPP_
82 #include <com/sun/star/sdbcx/XAlterTable.hpp>
84 #ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
85 #include <com/sun/star/sdbcx/XAppend.hpp>
87 #ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
88 #include <com/sun/star/sdbcx/XKeysSupplier.hpp>
90 #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
91 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
93 #ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
94 #include <com/sun/star/sdb/SQLContext.hpp>
96 #ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_
97 #include <com/sun/star/sdbc/SQLWarning.hpp>
99 #ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
100 #include <com/sun/star/sdbc/ColumnValue.hpp>
102 #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
103 #include <com/sun/star/sdbc/XRow.hpp>
105 #ifndef _DBHELPER_DBEXCEPTION_HXX_
106 #include <connectivity/dbexception.hxx>
108 #ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_
109 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
111 #ifndef _COMPHELPER_STREAMSECTION_HXX_
112 #include <comphelper/streamsection.hxx>
114 #ifndef _COMPHELPER_BASIC_IO_HXX_
115 #include <comphelper/basicio.hxx>
117 #ifndef _COMPHELPER_SEQSTREAM_HXX
118 #include <comphelper/seqstream.hxx>
120 #ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_
121 #include <com/sun/star/io/XActiveDataSource.hpp>
123 #ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_
124 #include <com/sun/star/io/XActiveDataSink.hpp>
126 #ifndef _DBAUI_SQLMESSAGE_HXX_
127 #include "sqlmessage.hxx"
129 #ifndef DBAUI_RELATIONCONTROLLER_HXX
130 #include "RelationController.hxx"
132 #ifndef _SV_MSGBOX_HXX
133 #include <vcl/msgbox.hxx>
135 #include "TableWindowData.hxx"
136 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
137 #include "dbustrings.hrc"
139 #ifndef DBAUI_TOOLS_HXX
140 #include "UITools.hxx"
142 #ifndef DBAUI_RTABLECONNECTIONDATA_HXX
143 #include "RTableConnectionData.hxx"
145 #ifndef DBAUI_RELATION_TABLEVIEW_HXX
146 #include "RelationTableView.hxx"
148 #ifndef DBAUI_RELATIONDESIGNVIEW_HXX
149 #include "RelationDesignView.hxx"
151 #ifndef _TOOLS_DEBUG_HXX
152 #include <tools/debug.hxx>
154 #ifndef TOOLS_DIAGNOSE_EX_H
155 #include <tools/diagnose_ex.h>
157 #ifndef _SV_WAITOBJ_HXX
158 #include <vcl/waitobj.hxx>
160 #include <osl/thread.hxx>
161 #include <vos/mutex.hxx>
164 #define MAX_THREADS 10
166 extern "C" void SAL_CALL
createRegistryInfo_ORelationControl()
168 static ::dbaui::OMultiInstanceAutoRegistration
< ::dbaui::ORelationController
> aAutoRegistration
;
172 using namespace ::com::sun::star::uno
;
173 using namespace ::com::sun::star::io
;
174 using namespace ::com::sun::star::beans
;
175 using namespace ::com::sun::star::frame
;
176 using namespace ::com::sun::star::util
;
177 using namespace ::com::sun::star::lang
;
178 using namespace ::com::sun::star::container
;
179 using namespace ::com::sun::star::sdbcx
;
180 using namespace ::com::sun::star::sdbc
;
181 using namespace ::com::sun::star::sdb
;
182 using namespace ::com::sun::star::ui::dialogs
;
183 using namespace ::com::sun::star::util
;
184 // using namespace ::com::sun::star::sdbcx;
185 // using namespace ::connectivity;
186 using namespace ::dbtools
;
187 using namespace ::dbaui
;
188 using namespace ::comphelper
;
189 using namespace ::osl
;
191 //------------------------------------------------------------------------------
192 ::rtl::OUString SAL_CALL
ORelationController::getImplementationName() throw( RuntimeException
)
194 return getImplementationName_Static();
197 //------------------------------------------------------------------------------
198 ::rtl::OUString
ORelationController::getImplementationName_Static() throw( RuntimeException
)
200 return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.ORelationDesign");
202 //------------------------------------------------------------------------------
203 Sequence
< ::rtl::OUString
> ORelationController::getSupportedServiceNames_Static(void) throw( RuntimeException
)
205 Sequence
< ::rtl::OUString
> aSupported(1);
206 aSupported
.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.RelationDesign");
209 //-------------------------------------------------------------------------
210 Sequence
< ::rtl::OUString
> SAL_CALL
ORelationController::getSupportedServiceNames() throw(RuntimeException
)
212 return getSupportedServiceNames_Static();
214 // -------------------------------------------------------------------------
215 Reference
< XInterface
> SAL_CALL
ORelationController::Create(const Reference
<XMultiServiceFactory
>& _rxFactory
)
217 return *(new ORelationController(_rxFactory
));
219 DBG_NAME(ORelationController
);
220 // -----------------------------------------------------------------------------
221 ORelationController::ORelationController(const Reference
< XMultiServiceFactory
>& _rM
)
222 : OJoinController(_rM
)
224 ,m_bRelationsPossible(sal_True
)
226 DBG_CTOR(ORelationController
,NULL
);
229 // -----------------------------------------------------------------------------
230 ORelationController::~ORelationController()
232 DBG_DTOR(ORelationController
,NULL
);
234 // -----------------------------------------------------------------------------
235 FeatureState
ORelationController::GetState(sal_uInt16 _nId
) const
237 FeatureState aReturn
;
238 aReturn
.bEnabled
= m_bRelationsPossible
;
241 case SID_RELATION_ADD_RELATION
:
242 aReturn
.bEnabled
= !m_vTableData
.empty() && isConnected() && isEditable();
243 aReturn
.bChecked
= false;
245 case ID_BROWSER_SAVEDOC
:
246 aReturn
.bEnabled
= haveDataSource() && isModified();
249 aReturn
= OJoinController::GetState(_nId
);
254 // -----------------------------------------------------------------------------
255 void ORelationController::Execute(sal_uInt16 _nId
, const Sequence
< PropertyValue
>& aArgs
)
259 case ID_BROWSER_SAVEDOC
:
261 OSL_ENSURE(isEditable(),"Slot ID_BROWSER_SAVEDOC should not be enabled!");
262 if(!::dbaui::checkDataSourceAvailable(::comphelper::getString(getDataSource()->getPropertyValue(PROPERTY_NAME
)),getORB()))
264 String
aMessage(ModuleRes(STR_DATASOURCE_DELETED
));
265 OSQLWarningBox( getView(), aMessage
).Execute();
269 // now we save the layout information
270 // create the output stream
273 if ( haveDataSource() && getDataSource()->getPropertySetInfo()->hasPropertyByName(PROPERTY_LAYOUTINFORMATION
) )
275 Sequence
<PropertyValue
> aWindows
;
276 saveTableWindows(aWindows
);
277 getDataSource()->setPropertyValue(PROPERTY_LAYOUTINFORMATION
,makeAny(aWindows
));
278 setModified(sal_False
);
287 case SID_RELATION_ADD_RELATION
:
288 static_cast<ORelationTableView
*>(static_cast<ORelationDesignView
*>(m_pView
)->getTableView())->AddNewRelation();
291 OJoinController::Execute(_nId
,aArgs
);
294 InvalidateFeature(_nId
);
296 // -----------------------------------------------------------------------------
297 void ORelationController::impl_initialize()
299 OJoinController::impl_initialize();
301 if( !getSdbMetaData().supportsRelations() )
302 {// check if this database supports relations
304 setEditable(sal_False
);
305 m_bRelationsPossible
= sal_False
;
307 String
sTitle(ModuleRes(STR_RELATIONDESIGN
));
309 OSQLMessageBox
aDlg(NULL
,sTitle
,ModuleRes(STR_RELATIONDESIGN_NOT_AVAILABLE
));
313 throw SQLException();
316 if(!m_bRelationsPossible
)
319 // we need a datasource
320 OSL_ENSURE(haveDataSource(),"ORelationController::initialize: need a datasource!");
322 Reference
<XTablesSupplier
> xSup(getConnection(),UNO_QUERY
);
323 OSL_ENSURE(xSup
.is(),"Connection isn't a XTablesSupplier!");
325 m_xTables
= xSup
->getTables();
326 // load the layoutInformation
327 loadLayoutInformation();
331 if ( !m_nThreadEvent
)
332 Application::PostUserEvent(LINK(this, ORelationController
, OnThreadFinished
));
334 catch( const Exception
& )
336 DBG_UNHANDLED_EXCEPTION();
340 // -----------------------------------------------------------------------------
341 ::rtl::OUString
ORelationController::getPrivateTitle( ) const
343 ::rtl::OUString sName
= getDataSourceName();
344 return ::dbaui::getStrippedDatabaseName(getDataSource(),sName
);
346 // -----------------------------------------------------------------------------
347 sal_Bool
ORelationController::Construct(Window
* pParent
)
349 m_pView
= new ORelationDesignView( pParent
, *this, getORB() );
350 OJoinController::Construct(pParent
);
351 // m_pView->Construct();
355 // -----------------------------------------------------------------------------
356 short ORelationController::saveModified()
358 short nSaved
= RET_YES
;
359 if(haveDataSource() && isModified())
361 QueryBox
aQry(getView(), ModuleRes(RELATION_DESIGN_SAVEMODIFIED
));
362 nSaved
= aQry
.Execute();
363 if(nSaved
== RET_YES
)
364 Execute(ID_BROWSER_SAVEDOC
,Sequence
<PropertyValue
>());
368 // -----------------------------------------------------------------------------
369 void ORelationController::describeSupportedFeatures()
371 OJoinController::describeSupportedFeatures();
372 implDescribeSupportedFeature( ".uno:DBAddRelation", SID_RELATION_ADD_RELATION
, CommandGroup::EDIT
);
376 class RelationLoader
: public ::osl::Thread
378 DECLARE_STL_MAP(::rtl::OUString
,::boost::shared_ptr
<OTableWindowData
>,::comphelper::UStringMixLess
,TTableDataHelper
);
379 TTableDataHelper m_aTableData
;
380 TTableConnectionData m_vTableConnectionData
;
381 const Sequence
< ::rtl::OUString
> m_aTableList
;
382 ORelationController
* m_pParent
;
383 const Reference
< XDatabaseMetaData
> m_xMetaData
;
384 const Reference
< XNameAccess
> m_xTables
;
385 const sal_Int32 m_nStartIndex
;
386 const sal_Int32 m_nEndIndex
;
389 RelationLoader(ORelationController
* _pParent
390 ,const Reference
< XDatabaseMetaData
>& _xMetaData
391 ,const Reference
< XNameAccess
>& _xTables
392 ,const Sequence
< ::rtl::OUString
>& _aTableList
393 ,const sal_Int32 _nStartIndex
394 ,const sal_Int32 _nEndIndex
)
395 :m_aTableData(_xMetaData
.is() && _xMetaData
->supportsMixedCaseQuotedIdentifiers())
396 ,m_aTableList(_aTableList
)
398 ,m_xMetaData(_xMetaData
)
400 ,m_nStartIndex(_nStartIndex
)
401 ,m_nEndIndex(_nEndIndex
)
406 virtual ~RelationLoader(){}
408 /// Working method which should be overridden.
409 virtual void SAL_CALL
run();
410 virtual void SAL_CALL
onTerminated();
411 void loadTableData(const Any
& _aTable
);
414 void SAL_CALL
RelationLoader::run()
416 const ::rtl::OUString
* pIter
= m_aTableList
.getConstArray() + m_nStartIndex
;
417 for(sal_Int32 i
= m_nStartIndex
; i
< m_nEndIndex
;++i
,++pIter
)
419 ::rtl::OUString sCatalog
,sSchema
,sTable
;
420 ::dbtools::qualifiedNameComponents(m_xMetaData
,
425 ::dbtools::eInDataManipulation
);
427 if ( sCatalog
.getLength() )
428 aCatalog
<<= sCatalog
;
432 Reference
< XResultSet
> xResult
= m_xMetaData
->getImportedKeys(aCatalog
, sSchema
,sTable
);
433 if ( xResult
.is() && xResult
->next() )
435 ::comphelper::disposeComponent(xResult
);
436 loadTableData(m_xTables
->getByName(*pIter
));
437 } // if ( xResult.is() && xResult->next() )
439 catch( const Exception
& )
441 DBG_UNHANDLED_EXCEPTION();
445 void SAL_CALL
RelationLoader::onTerminated()
447 m_pParent
->mergeData(m_vTableConnectionData
);
451 void RelationLoader::loadTableData(const Any
& _aTable
)
453 Reference
<XPropertySet
> xTableProp(_aTable
,UNO_QUERY
);
454 const ::rtl::OUString sSourceName
= ::dbtools::composeTableName( m_xMetaData
, xTableProp
, ::dbtools::eInTableDefinitions
, false, false, false );
455 TTableDataHelper::iterator aFind
= m_aTableData
.find(sSourceName
);
456 bool bNotFound
= true, bAdded
= false;
457 if ( aFind
== m_aTableData
.end() )
459 aFind
= m_aTableData
.insert(TTableDataHelper::value_type(sSourceName
,::boost::shared_ptr
<OTableWindowData
>(new OTableWindowData(xTableProp
,sSourceName
, sSourceName
)))).first
;
460 aFind
->second
->ShowAll(FALSE
);
463 TTableWindowData::value_type pReferencingTable
= aFind
->second
;
464 Reference
<XIndexAccess
> xKeys
= pReferencingTable
->getKeys();
465 const Reference
<XKeysSupplier
> xKeySup(xTableProp
,UNO_QUERY
);
467 if ( !xKeys
.is() && xKeySup
.is() )
469 xKeys
= xKeySup
->getKeys();
474 Reference
<XPropertySet
> xKey
;
475 const sal_Int32 nCount
= xKeys
->getCount();
476 for(sal_Int32 i
= 0 ; i
< nCount
; ++i
)
478 xKeys
->getByIndex(i
) >>= xKey
;
479 sal_Int32 nKeyType
= 0;
480 xKey
->getPropertyValue(PROPERTY_TYPE
) >>= nKeyType
;
481 if ( KeyType::FOREIGN
== nKeyType
)
484 ::rtl::OUString sReferencedTable
;
485 xKey
->getPropertyValue(PROPERTY_REFERENCEDTABLE
) >>= sReferencedTable
;
486 //////////////////////////////////////////////////////////////////////
488 TTableDataHelper::iterator aRefFind
= m_aTableData
.find(sReferencedTable
);
489 if ( aRefFind
== m_aTableData
.end() )
491 if ( m_xTables
->hasByName(sReferencedTable
) )
493 Reference
<XPropertySet
> xReferencedTable(m_xTables
->getByName(sReferencedTable
),UNO_QUERY
);
494 aRefFind
= m_aTableData
.insert(TTableDataHelper::value_type(sReferencedTable
,::boost::shared_ptr
<OTableWindowData
>(new OTableWindowData(xReferencedTable
,sReferencedTable
, sReferencedTable
)))).first
;
495 aRefFind
->second
->ShowAll(FALSE
);
498 continue; // table name could not be found so we do not show this table releation
499 } // if ( aFind == m_aTableData.end() )
500 TTableWindowData::value_type pReferencedTable
= aRefFind
->second
;
502 ::rtl::OUString sKeyName
;
503 xKey
->getPropertyValue(PROPERTY_NAME
) >>= sKeyName
;
504 //////////////////////////////////////////////////////////////////////
506 ORelationTableConnectionData
* pTabConnData
= new ORelationTableConnectionData( pReferencingTable
, pReferencedTable
, sKeyName
);
507 m_vTableConnectionData
.push_back(TTableConnectionData::value_type(pTabConnData
));
508 //////////////////////////////////////////////////////////////////////
510 const Reference
<XColumnsSupplier
> xColsSup(xKey
,UNO_QUERY
);
511 OSL_ENSURE(xColsSup
.is(),"Key is no XColumnsSupplier!");
512 const Reference
<XNameAccess
> xColumns
= xColsSup
->getColumns();
513 const Sequence
< ::rtl::OUString
> aNames
= xColumns
->getElementNames();
514 const ::rtl::OUString
* pIter
= aNames
.getConstArray();
515 const ::rtl::OUString
* pEnd
= pIter
+ aNames
.getLength();
516 ::rtl::OUString sColumnName
,sRelatedName
;
517 for(sal_uInt16 j
=0;pIter
!= pEnd
;++pIter
,++j
)
519 const Reference
<XPropertySet
> xPropSet(xColumns
->getByName(*pIter
),UNO_QUERY
);
520 OSL_ENSURE(xPropSet
.is(),"Invalid column found in KeyColumns!");
523 xPropSet
->getPropertyValue(PROPERTY_NAME
) >>= sColumnName
;
524 xPropSet
->getPropertyValue(PROPERTY_RELATEDCOLUMN
) >>= sRelatedName
;
526 pTabConnData
->SetConnLine( j
, sColumnName
, sRelatedName
);
528 //////////////////////////////////////////////////////////////////////
529 // Update/Del-Flags setzen
530 sal_Int32 nUpdateRule
= 0;
531 sal_Int32 nDeleteRule
= 0;
532 xKey
->getPropertyValue(PROPERTY_UPDATERULE
) >>= nUpdateRule
;
533 xKey
->getPropertyValue(PROPERTY_DELETERULE
) >>= nDeleteRule
;
535 pTabConnData
->SetUpdateRules( nUpdateRule
);
536 pTabConnData
->SetDeleteRules( nDeleteRule
);
538 //////////////////////////////////////////////////////////////////////
539 // Kardinalitaet setzen
540 pTabConnData
->SetCardinality();
543 } // if ( xKeys.is() )
547 void ORelationController::mergeData(const TTableConnectionData
& _aConnectionData
)
549 ::osl::MutexGuard
aGuard( getMutex() );
551 ::std::copy( _aConnectionData
.begin(), _aConnectionData
.end(), ::std::back_inserter( m_vTableConnectionData
));
552 //const Reference< XDatabaseMetaData> xMetaData = getConnection()->getMetaData();
553 const sal_Bool bCase
= sal_True
;//xMetaData.is() && xMetaData->supportsMixedCaseQuotedIdentifiers();
554 // here we are finished, so we can collect the table from connection data
555 TTableConnectionData::iterator aConnDataIter
= m_vTableConnectionData
.begin();
556 TTableConnectionData::iterator aConnDataEnd
= m_vTableConnectionData
.end();
557 for(;aConnDataIter
!= aConnDataEnd
;++aConnDataIter
)
559 if ( !existsTable((*aConnDataIter
)->getReferencingTable()->GetComposedName(),bCase
) )
561 m_vTableData
.push_back((*aConnDataIter
)->getReferencingTable());
563 if ( !existsTable((*aConnDataIter
)->getReferencedTable()->GetComposedName(),bCase
) )
565 m_vTableData
.push_back((*aConnDataIter
)->getReferencedTable());
567 } // for(;aConnDataIter != aConnDataEnd;++aConnDataIter)
569 if ( !m_nThreadEvent
)
570 Application::PostUserEvent(LINK(this, ORelationController
, OnThreadFinished
));
572 // -----------------------------------------------------------------------------
573 IMPL_LINK( ORelationController
, OnThreadFinished
, void*, /*NOTINTERESTEDIN*/ )
575 vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
576 ::osl::MutexGuard
aGuard( getMutex() );
579 getView()->initialize(); // show the windows and fill with our informations
580 getView()->Invalidate(INVALIDATE_NOERASE
);
581 getUndoMgr()->Clear(); // clear all undo redo things
582 setModified(sal_False
); // and we are not modified yet
584 if(m_vTableData
.empty())
585 Execute(ID_BROWSER_ADDTABLE
,Sequence
<PropertyValue
>());
587 catch( const Exception
& )
589 DBG_UNHANDLED_EXCEPTION();
591 m_pWaitObject
.reset();
594 // -----------------------------------------------------------------------------
595 void ORelationController::loadData()
597 m_pWaitObject
.reset( new WaitObject(getView()) );
600 if ( !m_xTables
.is() )
602 // this may take some time
603 const Reference
< XDatabaseMetaData
> xMetaData
= getConnection()->getMetaData();
604 const Sequence
< ::rtl::OUString
> aNames
= m_xTables
->getElementNames();
605 const sal_Int32 nCount
= aNames
.getLength();
606 const sal_Int32 nMaxElements
= (nCount
/ MAX_THREADS
) +1;
608 sal_Int32 nStart
= 0,nEnd
= ::std::min(nMaxElements
,nCount
);
609 while(nStart
!= nEnd
)
612 RelationLoader
* pThread
= new RelationLoader(this,xMetaData
,m_xTables
,aNames
,nStart
,nEnd
);
613 pThread
->createSuspended();
614 pThread
->setPriority(osl_Thread_PriorityBelowNormal
);
617 nEnd
+= nMaxElements
;
618 nEnd
= ::std::min(nEnd
,nCount
);
619 } // for(;pIter != pEnd;++pIter)
621 catch(SQLException
& e
)
623 showError(SQLExceptionInfo(e
));
625 catch(const Exception
&)
627 DBG_UNHANDLED_EXCEPTION();
630 // -----------------------------------------------------------------------------
631 TTableWindowData::value_type
ORelationController::existsTable(const ::rtl::OUString
& _rComposedTableName
,sal_Bool _bCase
) const
633 ::comphelper::UStringMixEqual
bCase(_bCase
);
634 TTableWindowData::const_iterator aIter
= m_vTableData
.begin();
635 TTableWindowData::const_iterator aEnd
= m_vTableData
.end();
636 for(;aIter
!= aEnd
;++aIter
)
638 if(bCase((*aIter
)->GetComposedName(),_rComposedTableName
))
641 return ( aIter
!= aEnd
) ? *aIter
: TTableWindowData::value_type();
643 // -----------------------------------------------------------------------------
644 void ORelationController::loadLayoutInformation()
648 OSL_ENSURE(haveDataSource(),"We need a datasource from our connection!");
649 if ( haveDataSource() )
651 if ( getDataSource()->getPropertySetInfo()->hasPropertyByName(PROPERTY_LAYOUTINFORMATION
) )
653 Sequence
<PropertyValue
> aWindows
;
654 getDataSource()->getPropertyValue(PROPERTY_LAYOUTINFORMATION
) >>= aWindows
;
655 loadTableWindows(aWindows
);
663 // -----------------------------------------------------------------------------
664 void ORelationController::reset()
666 loadLayoutInformation();
667 ODataView
* pView
= getView();
668 OSL_ENSURE(pView
,"No current view!");
672 pView
->Invalidate(INVALIDATE_NOERASE
);
676 // -----------------------------------------------------------------------------
677 bool ORelationController::allowViews() const
682 // -----------------------------------------------------------------------------
683 bool ORelationController::allowQueries() const
688 // -----------------------------------------------------------------------------