Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <sal/config.h>
21 :
22 : #include <map>
23 :
24 : #include "dbu_reghelper.hxx"
25 : #include "uiservices.hxx"
26 : #include <sfx2/sfxsids.hrc>
27 : #include "dbu_rel.hrc"
28 : #include <vcl/svapp.hxx>
29 : #include "browserids.hxx"
30 : #include <comphelper/types.hxx>
31 : #include "dbustrings.hrc"
32 : #include <connectivity/dbtools.hxx>
33 : #include <com/sun/star/frame/FrameSearchFlag.hpp>
34 : #include <comphelper/extract.hxx>
35 : #include <comphelper/processfactory.hxx>
36 : #include <com/sun/star/container/XChild.hpp>
37 : #include <com/sun/star/container/XNameContainer.hpp>
38 : #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
39 : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
40 : #include <com/sun/star/sdbcx/KeyType.hpp>
41 : #include <com/sun/star/sdbcx/XDrop.hpp>
42 : #include <com/sun/star/sdbcx/XAlterTable.hpp>
43 : #include <com/sun/star/sdbcx/XAppend.hpp>
44 : #include <com/sun/star/sdbcx/XKeysSupplier.hpp>
45 : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
46 : #include <com/sun/star/sdb/SQLContext.hpp>
47 : #include <com/sun/star/sdbc/SQLWarning.hpp>
48 : #include <com/sun/star/sdbc/ColumnValue.hpp>
49 : #include <com/sun/star/sdbc/XRow.hpp>
50 : #include <connectivity/dbexception.hxx>
51 : #include <connectivity/dbmetadata.hxx>
52 : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
53 : #include <comphelper/streamsection.hxx>
54 : #include <comphelper/seqstream.hxx>
55 : #include <com/sun/star/io/XActiveDataSource.hpp>
56 : #include <com/sun/star/io/XActiveDataSink.hpp>
57 : #include "sqlmessage.hxx"
58 : #include "RelationController.hxx"
59 : #include <vcl/layout.hxx>
60 : #include "TableWindowData.hxx"
61 : #include "UITools.hxx"
62 : #include "RTableConnectionData.hxx"
63 : #include "RelationTableView.hxx"
64 : #include "RelationDesignView.hxx"
65 : #include <tools/debug.hxx>
66 : #include <tools/diagnose_ex.h>
67 : #include <vcl/waitobj.hxx>
68 : #include <osl/thread.hxx>
69 : #include <osl/mutex.hxx>
70 :
71 : #define MAX_THREADS 10
72 :
73 12 : extern "C" void SAL_CALL createRegistryInfo_ORelationControl()
74 : {
75 12 : static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::ORelationController > aAutoRegistration;
76 12 : }
77 :
78 : using namespace ::com::sun::star::uno;
79 : using namespace ::com::sun::star::io;
80 : using namespace ::com::sun::star::beans;
81 : using namespace ::com::sun::star::frame;
82 : using namespace ::com::sun::star::lang;
83 : using namespace ::com::sun::star::container;
84 : using namespace ::com::sun::star::sdbcx;
85 : using namespace ::com::sun::star::sdbc;
86 : using namespace ::com::sun::star::sdb;
87 : using namespace ::com::sun::star::ui::dialogs;
88 : using namespace ::com::sun::star::util;
89 : using namespace ::dbtools;
90 : using namespace ::dbaui;
91 : using namespace ::comphelper;
92 : using namespace ::osl;
93 :
94 1 : OUString SAL_CALL ORelationController::getImplementationName() throw( RuntimeException, std::exception )
95 : {
96 1 : return getImplementationName_Static();
97 : }
98 :
99 25 : OUString ORelationController::getImplementationName_Static() throw( RuntimeException )
100 : {
101 25 : return OUString("org.openoffice.comp.dbu.ORelationDesign");
102 : }
103 :
104 13 : Sequence< OUString> ORelationController::getSupportedServiceNames_Static() throw( RuntimeException )
105 : {
106 13 : Sequence< OUString> aSupported(1);
107 13 : aSupported[0] = "com.sun.star.sdb.RelationDesign";
108 13 : return aSupported;
109 : }
110 :
111 1 : Sequence< OUString> SAL_CALL ORelationController::getSupportedServiceNames() throw(RuntimeException, std::exception)
112 : {
113 1 : return getSupportedServiceNames_Static();
114 : }
115 :
116 1 : Reference< XInterface > SAL_CALL ORelationController::Create(const Reference<XMultiServiceFactory >& _rxFactory)
117 : {
118 1 : return *(new ORelationController(comphelper::getComponentContext(_rxFactory)));
119 : }
120 :
121 1 : ORelationController::ORelationController(const Reference< XComponentContext >& _rM)
122 : : OJoinController(_rM)
123 : ,m_nThreadEvent(0)
124 1 : ,m_bRelationsPossible(true)
125 : {
126 1 : InvalidateAll();
127 1 : }
128 :
129 2 : ORelationController::~ORelationController()
130 : {
131 2 : }
132 :
133 0 : FeatureState ORelationController::GetState(sal_uInt16 _nId) const
134 : {
135 0 : FeatureState aReturn;
136 0 : aReturn.bEnabled = m_bRelationsPossible;
137 0 : switch (_nId)
138 : {
139 : case SID_RELATION_ADD_RELATION:
140 0 : aReturn.bEnabled = !m_vTableData.empty() && isConnected() && isEditable();
141 0 : aReturn.bChecked = false;
142 0 : break;
143 : case ID_BROWSER_SAVEDOC:
144 0 : aReturn.bEnabled = haveDataSource() && impl_isModified();
145 0 : break;
146 : default:
147 0 : aReturn = OJoinController::GetState(_nId);
148 0 : break;
149 : }
150 0 : return aReturn;
151 : }
152 :
153 0 : void ORelationController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
154 : {
155 0 : switch(_nId)
156 : {
157 : case ID_BROWSER_SAVEDOC:
158 : {
159 : OSL_ENSURE(isEditable(),"Slot ID_BROWSER_SAVEDOC should not be enabled!");
160 0 : if(!::dbaui::checkDataSourceAvailable(::comphelper::getString(getDataSource()->getPropertyValue(PROPERTY_NAME)), getORB()))
161 : {
162 0 : OUString aMessage(ModuleRes(STR_DATASOURCE_DELETED));
163 0 : ScopedVclPtr<OSQLWarningBox>::Create( getView(), aMessage )->Execute();
164 : }
165 : else
166 : {
167 : // now we save the layout information
168 : // create the output stream
169 : try
170 : {
171 0 : if ( haveDataSource() && getDataSource()->getPropertySetInfo()->hasPropertyByName(PROPERTY_LAYOUTINFORMATION) )
172 : {
173 0 : ::comphelper::NamedValueCollection aWindowsData;
174 0 : saveTableWindows( aWindowsData );
175 0 : getDataSource()->setPropertyValue( PROPERTY_LAYOUTINFORMATION, makeAny( aWindowsData.getPropertyValues() ) );
176 0 : setModified(sal_False);
177 : }
178 : }
179 0 : catch ( const Exception& )
180 : {
181 : DBG_UNHANDLED_EXCEPTION();
182 : }
183 : }
184 : }
185 0 : break;
186 : case SID_RELATION_ADD_RELATION:
187 0 : static_cast<ORelationTableView*>(static_cast<ORelationDesignView*>( getView() )->getTableView())->AddNewRelation();
188 0 : break;
189 : default:
190 0 : OJoinController::Execute(_nId,aArgs);
191 0 : return;
192 : }
193 0 : InvalidateFeature(_nId);
194 : }
195 :
196 0 : void ORelationController::impl_initialize()
197 : {
198 0 : OJoinController::impl_initialize();
199 :
200 0 : if( !getSdbMetaData().supportsRelations() )
201 : {// check if this database supports relations
202 :
203 0 : setEditable(false);
204 0 : m_bRelationsPossible = false;
205 : {
206 0 : OUString sTitle(ModuleRes(STR_RELATIONDESIGN));
207 0 : sTitle = sTitle.copy(3);
208 0 : ScopedVclPtrInstance< OSQLMessageBox > aDlg(nullptr,sTitle,ModuleRes(STR_RELATIONDESIGN_NOT_AVAILABLE));
209 0 : aDlg->Execute();
210 : }
211 0 : disconnect();
212 0 : throw SQLException();
213 : }
214 :
215 0 : if(!m_bRelationsPossible)
216 0 : InvalidateAll();
217 :
218 : // we need a datasource
219 : OSL_ENSURE(haveDataSource(),"ORelationController::initialize: need a datasource!");
220 :
221 0 : Reference<XTablesSupplier> xSup(getConnection(),UNO_QUERY);
222 : OSL_ENSURE(xSup.is(),"Connection isn't a XTablesSupplier!");
223 0 : if(xSup.is())
224 0 : m_xTables = xSup->getTables();
225 : // load the layoutInformation
226 0 : loadLayoutInformation();
227 : try
228 : {
229 0 : loadData();
230 0 : if ( !m_nThreadEvent )
231 0 : Application::PostUserEvent(LINK(this, ORelationController, OnThreadFinished));
232 : }
233 0 : catch( const Exception& )
234 : {
235 : DBG_UNHANDLED_EXCEPTION();
236 0 : }
237 :
238 0 : }
239 :
240 0 : OUString ORelationController::getPrivateTitle( ) const
241 : {
242 0 : OUString sName = getDataSourceName();
243 0 : return ::dbaui::getStrippedDatabaseName(getDataSource(),sName);
244 : }
245 :
246 0 : bool ORelationController::Construct(vcl::Window* pParent)
247 : {
248 0 : setView( VclPtr<ORelationDesignView>::Create( pParent, *this, getORB() ) );
249 0 : OJoinController::Construct(pParent);
250 0 : return true;
251 : }
252 :
253 0 : short ORelationController::saveModified()
254 : {
255 0 : short nSaved = RET_YES;
256 0 : if(haveDataSource() && isModified())
257 : {
258 0 : ScopedVclPtrInstance<MessageDialog> aQry(getView(), "DesignSaveModifiedDialog",
259 0 : "dbaccess/ui/designsavemodifieddialog.ui");
260 0 : nSaved = aQry->Execute();
261 0 : if(nSaved == RET_YES)
262 0 : Execute(ID_BROWSER_SAVEDOC,Sequence<PropertyValue>());
263 : }
264 0 : return nSaved;
265 : }
266 :
267 0 : void ORelationController::describeSupportedFeatures()
268 : {
269 0 : OJoinController::describeSupportedFeatures();
270 0 : implDescribeSupportedFeature( ".uno:DBAddRelation", SID_RELATION_ADD_RELATION, CommandGroup::EDIT );
271 0 : }
272 :
273 : namespace
274 : {
275 : class RelationLoader : public ::osl::Thread
276 : {
277 : typedef std::map<OUString, ::boost::shared_ptr<OTableWindowData>, ::comphelper::UStringMixLess> TTableDataHelper;
278 : TTableDataHelper m_aTableData;
279 : TTableConnectionData m_vTableConnectionData;
280 : const Sequence< OUString> m_aTableList;
281 : ORelationController* m_pParent;
282 : const Reference< XDatabaseMetaData> m_xMetaData;
283 : const Reference< XNameAccess > m_xTables;
284 : const sal_Int32 m_nStartIndex;
285 : const sal_Int32 m_nEndIndex;
286 :
287 : public:
288 0 : RelationLoader(ORelationController* _pParent
289 : ,const Reference< XDatabaseMetaData>& _xMetaData
290 : ,const Reference< XNameAccess >& _xTables
291 : ,const Sequence< OUString>& _aTableList
292 : ,const sal_Int32 _nStartIndex
293 : ,const sal_Int32 _nEndIndex)
294 0 : :m_aTableData(_xMetaData.is() && _xMetaData->supportsMixedCaseQuotedIdentifiers())
295 : ,m_aTableList(_aTableList)
296 : ,m_pParent(_pParent)
297 : ,m_xMetaData(_xMetaData)
298 : ,m_xTables(_xTables)
299 : ,m_nStartIndex(_nStartIndex)
300 0 : ,m_nEndIndex(_nEndIndex)
301 : {
302 0 : }
303 :
304 : /// Working method which should be overridden.
305 : virtual void SAL_CALL run() SAL_OVERRIDE;
306 : virtual void SAL_CALL onTerminated() SAL_OVERRIDE;
307 : protected:
308 0 : virtual ~RelationLoader(){}
309 :
310 : void loadTableData(const Any& _aTable);
311 : };
312 :
313 0 : void SAL_CALL RelationLoader::run()
314 : {
315 0 : osl_setThreadName("RelationLoader");
316 :
317 0 : const OUString* pIter = m_aTableList.getConstArray() + m_nStartIndex;
318 0 : for(sal_Int32 i = m_nStartIndex; i < m_nEndIndex;++i,++pIter)
319 : {
320 0 : OUString sCatalog,sSchema,sTable;
321 : ::dbtools::qualifiedNameComponents(m_xMetaData,
322 : *pIter,
323 : sCatalog,
324 : sSchema,
325 : sTable,
326 0 : ::dbtools::eInDataManipulation);
327 0 : Any aCatalog;
328 0 : if ( !sCatalog.isEmpty() )
329 0 : aCatalog <<= sCatalog;
330 :
331 : try
332 : {
333 0 : Reference< XResultSet > xResult = m_xMetaData->getImportedKeys(aCatalog, sSchema,sTable);
334 0 : if ( xResult.is() && xResult->next() )
335 : {
336 0 : ::comphelper::disposeComponent(xResult);
337 0 : loadTableData(m_xTables->getByName(*pIter));
338 0 : }
339 : }
340 0 : catch( const Exception& )
341 : {
342 : DBG_UNHANDLED_EXCEPTION();
343 : }
344 0 : }
345 0 : }
346 0 : void SAL_CALL RelationLoader::onTerminated()
347 : {
348 0 : m_pParent->mergeData(m_vTableConnectionData);
349 0 : delete this;
350 0 : }
351 :
352 0 : void RelationLoader::loadTableData(const Any& _aTable)
353 : {
354 0 : Reference<XPropertySet> xTableProp(_aTable,UNO_QUERY);
355 0 : const OUString sSourceName = ::dbtools::composeTableName( m_xMetaData, xTableProp, ::dbtools::eInTableDefinitions, false, false, false );
356 0 : TTableDataHelper::iterator aFind = m_aTableData.find(sSourceName);
357 0 : if ( aFind == m_aTableData.end() )
358 : {
359 0 : aFind = m_aTableData.insert(TTableDataHelper::value_type(sSourceName,::boost::shared_ptr<OTableWindowData>(new OTableWindowData(xTableProp,sSourceName, sSourceName)))).first;
360 0 : aFind->second->ShowAll(false);
361 : }
362 0 : TTableWindowData::value_type pReferencingTable = aFind->second;
363 0 : Reference<XIndexAccess> xKeys = pReferencingTable->getKeys();
364 0 : const Reference<XKeysSupplier> xKeySup(xTableProp,UNO_QUERY);
365 :
366 0 : if ( !xKeys.is() && xKeySup.is() )
367 : {
368 0 : xKeys = xKeySup->getKeys();
369 : }
370 :
371 0 : if ( xKeys.is() )
372 : {
373 0 : Reference<XPropertySet> xKey;
374 0 : const sal_Int32 nCount = xKeys->getCount();
375 0 : for(sal_Int32 i = 0 ; i < nCount ; ++i)
376 : {
377 0 : xKeys->getByIndex(i) >>= xKey;
378 0 : sal_Int32 nKeyType = 0;
379 0 : xKey->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
380 0 : if ( KeyType::FOREIGN == nKeyType )
381 : {
382 0 : OUString sReferencedTable;
383 0 : xKey->getPropertyValue(PROPERTY_REFERENCEDTABLE) >>= sReferencedTable;
384 :
385 : // insert windows
386 0 : TTableDataHelper::iterator aRefFind = m_aTableData.find(sReferencedTable);
387 0 : if ( aRefFind == m_aTableData.end() )
388 : {
389 0 : if ( m_xTables->hasByName(sReferencedTable) )
390 : {
391 0 : Reference<XPropertySet> xReferencedTable(m_xTables->getByName(sReferencedTable),UNO_QUERY);
392 0 : aRefFind = m_aTableData.insert(TTableDataHelper::value_type(sReferencedTable,::boost::shared_ptr<OTableWindowData>(new OTableWindowData(xReferencedTable,sReferencedTable, sReferencedTable)))).first;
393 0 : aRefFind->second->ShowAll(false);
394 : }
395 : else
396 0 : continue; // table name could not be found so we do not show this table releation
397 : }
398 0 : TTableWindowData::value_type pReferencedTable = aRefFind->second;
399 :
400 0 : OUString sKeyName;
401 0 : xKey->getPropertyValue(PROPERTY_NAME) >>= sKeyName;
402 : // insert connection
403 0 : ORelationTableConnectionData* pTabConnData = new ORelationTableConnectionData( pReferencingTable, pReferencedTable, sKeyName );
404 0 : m_vTableConnectionData.push_back(TTableConnectionData::value_type(pTabConnData));
405 : // insert columns
406 0 : const Reference<XColumnsSupplier> xColsSup(xKey,UNO_QUERY);
407 : OSL_ENSURE(xColsSup.is(),"Key is no XColumnsSupplier!");
408 0 : const Reference<XNameAccess> xColumns = xColsSup->getColumns();
409 0 : const Sequence< OUString> aNames = xColumns->getElementNames();
410 0 : const OUString* pIter = aNames.getConstArray();
411 0 : const OUString* pEnd = pIter + aNames.getLength();
412 0 : OUString sColumnName,sRelatedName;
413 0 : for(sal_uInt16 j=0;pIter != pEnd;++pIter,++j)
414 : {
415 0 : const Reference<XPropertySet> xPropSet(xColumns->getByName(*pIter),UNO_QUERY);
416 : OSL_ENSURE(xPropSet.is(),"Invalid column found in KeyColumns!");
417 0 : if ( xPropSet.is() )
418 : {
419 0 : xPropSet->getPropertyValue(PROPERTY_NAME) >>= sColumnName;
420 0 : xPropSet->getPropertyValue(PROPERTY_RELATEDCOLUMN) >>= sRelatedName;
421 : }
422 0 : pTabConnData->SetConnLine( j, sColumnName, sRelatedName );
423 0 : }
424 : // Update/Del-Flags setzen
425 0 : sal_Int32 nUpdateRule = 0;
426 0 : sal_Int32 nDeleteRule = 0;
427 0 : xKey->getPropertyValue(PROPERTY_UPDATERULE) >>= nUpdateRule;
428 0 : xKey->getPropertyValue(PROPERTY_DELETERULE) >>= nDeleteRule;
429 :
430 0 : pTabConnData->SetUpdateRules( nUpdateRule );
431 0 : pTabConnData->SetDeleteRules( nDeleteRule );
432 :
433 : // Kardinalitaet setzen
434 0 : pTabConnData->SetCardinality();
435 : }
436 0 : }
437 0 : }
438 0 : }
439 : }
440 :
441 0 : void ORelationController::mergeData(const TTableConnectionData& _aConnectionData)
442 : {
443 0 : ::osl::MutexGuard aGuard( getMutex() );
444 :
445 0 : ::std::copy( _aConnectionData.begin(), _aConnectionData.end(), ::std::back_inserter( m_vTableConnectionData ));
446 : //const Reference< XDatabaseMetaData> xMetaData = getConnection()->getMetaData();
447 0 : const bool bCase = true;//xMetaData.is() && xMetaData->supportsMixedCaseQuotedIdentifiers();
448 : // here we are finished, so we can collect the table from connection data
449 0 : TTableConnectionData::iterator aConnDataIter = m_vTableConnectionData.begin();
450 0 : TTableConnectionData::iterator aConnDataEnd = m_vTableConnectionData.end();
451 0 : for(;aConnDataIter != aConnDataEnd;++aConnDataIter)
452 : {
453 0 : if ( !existsTable((*aConnDataIter)->getReferencingTable()->GetComposedName(),bCase) )
454 : {
455 0 : m_vTableData.push_back((*aConnDataIter)->getReferencingTable());
456 : }
457 0 : if ( !existsTable((*aConnDataIter)->getReferencedTable()->GetComposedName(),bCase) )
458 : {
459 0 : m_vTableData.push_back((*aConnDataIter)->getReferencedTable());
460 : }
461 : }
462 0 : if ( m_nThreadEvent )
463 : {
464 0 : --m_nThreadEvent;
465 0 : if ( !m_nThreadEvent )
466 0 : Application::PostUserEvent(LINK(this, ORelationController, OnThreadFinished));
467 0 : }
468 0 : }
469 :
470 0 : IMPL_LINK_NOARG( ORelationController, OnThreadFinished )
471 : {
472 0 : ::SolarMutexGuard aSolarGuard;
473 0 : ::osl::MutexGuard aGuard( getMutex() );
474 : try
475 : {
476 0 : getView()->initialize(); // show the windows and fill with our information
477 0 : getView()->Invalidate(InvalidateFlags::NoErase);
478 0 : ClearUndoManager();
479 0 : setModified(sal_False); // and we are not modified yet
480 :
481 0 : if(m_vTableData.empty())
482 0 : Execute(ID_BROWSER_ADDTABLE,Sequence<PropertyValue>());
483 : }
484 0 : catch( const Exception& )
485 : {
486 : DBG_UNHANDLED_EXCEPTION();
487 : }
488 0 : m_pWaitObject.reset();
489 0 : return 0L;
490 : }
491 :
492 0 : void ORelationController::loadData()
493 : {
494 0 : m_pWaitObject.reset( new WaitObject(getView()) );
495 : try
496 : {
497 0 : if ( !m_xTables.is() )
498 0 : return;
499 0 : DatabaseMetaData aMeta(getConnection());
500 : // this may take some time
501 0 : const Reference< XDatabaseMetaData> xMetaData = getConnection()->getMetaData();
502 0 : const Sequence< OUString> aNames = m_xTables->getElementNames();
503 0 : const sal_Int32 nCount = aNames.getLength();
504 0 : if ( aMeta.supportsThreads() )
505 : {
506 0 : const sal_Int32 nMaxElements = (nCount / MAX_THREADS) +1;
507 0 : sal_Int32 nStart = 0,nEnd = ::std::min(nMaxElements,nCount);
508 0 : while(nStart != nEnd)
509 : {
510 0 : ++m_nThreadEvent;
511 0 : RelationLoader* pThread = new RelationLoader(this,xMetaData,m_xTables,aNames,nStart,nEnd);
512 0 : pThread->createSuspended();
513 0 : pThread->setPriority(osl_Thread_PriorityBelowNormal);
514 0 : pThread->resume();
515 0 : nStart = nEnd;
516 0 : nEnd += nMaxElements;
517 0 : nEnd = ::std::min(nEnd,nCount);
518 : }
519 : }
520 : else
521 : {
522 0 : RelationLoader* pThread = new RelationLoader(this,xMetaData,m_xTables,aNames,0,nCount);
523 0 : pThread->run();
524 0 : pThread->onTerminated();
525 0 : }
526 : }
527 0 : catch(SQLException& e)
528 : {
529 0 : showError(SQLExceptionInfo(e));
530 : }
531 0 : catch(const Exception&)
532 : {
533 : DBG_UNHANDLED_EXCEPTION();
534 : }
535 : }
536 :
537 0 : TTableWindowData::value_type ORelationController::existsTable(const OUString& _rComposedTableName,bool _bCase) const
538 : {
539 0 : ::comphelper::UStringMixEqual bCase(_bCase);
540 0 : TTableWindowData::const_iterator aIter = m_vTableData.begin();
541 0 : TTableWindowData::const_iterator aEnd = m_vTableData.end();
542 0 : for(;aIter != aEnd;++aIter)
543 : {
544 0 : if(bCase((*aIter)->GetComposedName(),_rComposedTableName))
545 0 : break;
546 : }
547 0 : return ( aIter != aEnd) ? *aIter : TTableWindowData::value_type();
548 : }
549 :
550 0 : void ORelationController::loadLayoutInformation()
551 : {
552 : try
553 : {
554 : OSL_ENSURE(haveDataSource(),"We need a datasource from our connection!");
555 0 : if ( haveDataSource() )
556 : {
557 0 : if ( getDataSource()->getPropertySetInfo()->hasPropertyByName(PROPERTY_LAYOUTINFORMATION) )
558 : {
559 0 : Sequence<PropertyValue> aWindows;
560 0 : getDataSource()->getPropertyValue(PROPERTY_LAYOUTINFORMATION) >>= aWindows;
561 0 : loadTableWindows(aWindows);
562 : }
563 : }
564 : }
565 0 : catch(Exception&)
566 : {
567 : }
568 0 : }
569 :
570 0 : void ORelationController::reset()
571 : {
572 0 : loadLayoutInformation();
573 0 : ODataView* pView = getView();
574 : OSL_ENSURE(pView,"No current view!");
575 0 : if(pView)
576 : {
577 0 : pView->initialize();
578 0 : pView->Invalidate(InvalidateFlags::NoErase);
579 : }
580 0 : }
581 :
582 0 : bool ORelationController::allowViews() const
583 : {
584 0 : return false;
585 : }
586 :
587 0 : bool ORelationController::allowQueries() const
588 : {
589 0 : return false;
590 36 : }
591 :
592 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|