QueryTableView.cxx (b63233d8) QueryTableView.cxx (1636bfc2)
1/**************************************************************
1/**************************************************************
2 *
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
19 *
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_dbui.hxx"
26
27#ifndef DBAUI_QUERYTABLEVIEW_HXX

--- 95 unchanged lines hidden (view full) ---

123using namespace ::com::sun::star::uno;
124using namespace ::com::sun::star::sdbc;
125using namespace ::com::sun::star::sdbcx;
126using namespace ::com::sun::star::beans;
127using namespace ::com::sun::star::container;
128using namespace ::com::sun::star::accessibility;
129
130//------------------------------------------------------------------------------
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_dbui.hxx"
26
27#ifndef DBAUI_QUERYTABLEVIEW_HXX

--- 95 unchanged lines hidden (view full) ---

123using namespace ::com::sun::star::uno;
124using namespace ::com::sun::star::sdbc;
125using namespace ::com::sun::star::sdbcx;
126using namespace ::com::sun::star::beans;
127using namespace ::com::sun::star::container;
128using namespace ::com::sun::star::accessibility;
129
130//------------------------------------------------------------------------------
131namespace
131namespace
132{
133 // -----------------------------------------------------------------------------
134 sal_Bool isColumnInKeyType(const Reference<XIndexAccess>& _rxKeys,const ::rtl::OUString& _rColumnName,sal_Int32 _nKeyType)
135 {
136 sal_Bool bReturn = sal_False;
137 if(_rxKeys.is())
138 {
139 Reference<XColumnsSupplier> xColumnsSupplier;
140 // search the one and only primary key
132{
133 // -----------------------------------------------------------------------------
134 sal_Bool isColumnInKeyType(const Reference<XIndexAccess>& _rxKeys,const ::rtl::OUString& _rColumnName,sal_Int32 _nKeyType)
135 {
136 sal_Bool bReturn = sal_False;
137 if(_rxKeys.is())
138 {
139 Reference<XColumnsSupplier> xColumnsSupplier;
140 // search the one and only primary key
141 const sal_Int32 nCount = _rxKeys->getCount();
141 const sal_Int32 nCount = _rxKeys->getCount();
142 for(sal_Int32 i=0;i< nCount;++i)
143 {
144 Reference<XPropertySet> xProp(_rxKeys->getByIndex(i),UNO_QUERY);
145 if(xProp.is())
146 {
147 sal_Int32 nKeyType = 0;
148 xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
149 if(_nKeyType == nKeyType)

--- 33 unchanged lines hidden (view full) ---

183 }
184 // -----------------------------------------------------------------------------
185 /** openJoinDialog opens the join dialog with this connection data
186 @param _pView the view which we use
187 @param _pConnectionData the connection data
188
189 @return true when OK was pressed otherwise false
190 */
142 for(sal_Int32 i=0;i< nCount;++i)
143 {
144 Reference<XPropertySet> xProp(_rxKeys->getByIndex(i),UNO_QUERY);
145 if(xProp.is())
146 {
147 sal_Int32 nKeyType = 0;
148 xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
149 if(_nKeyType == nKeyType)

--- 33 unchanged lines hidden (view full) ---

183 }
184 // -----------------------------------------------------------------------------
185 /** openJoinDialog opens the join dialog with this connection data
186 @param _pView the view which we use
187 @param _pConnectionData the connection data
188
189 @return true when OK was pressed otherwise false
190 */
191 sal_Bool openJoinDialog(OQueryTableView* _pView,const TTableConnectionData::value_type& _pConnectionData,sal_Bool _bSelectableTables)
191 sal_Bool openJoinDialog(OQueryTableView* _pView,const TTableConnectionData::value_type& _pConnectionData,sal_Bool _bSelectableTables)
192 {
193 OQueryTableConnectionData* pData = static_cast< OQueryTableConnectionData*>(_pConnectionData.get());
194
195 DlgQryJoin aDlg(_pView,_pConnectionData,_pView->GetTabWinMap(),_pView->getDesignView()->getController().getConnection(),_bSelectableTables);
196 sal_Bool bOk = aDlg.Execute() == RET_OK;
197 if( bOk )
198 {
199 pData->SetJoinType(aDlg.GetJoinType());

--- 32 unchanged lines hidden (view full) ---

232 const OQueryTableWindow& _rSource,
233 const OQueryTableWindow& _rDest,
234 const Reference<XNameAccess>& _rxSourceForeignKeyColumns)
235 {
236 if ( _rSource.GetData()->isQuery() || _rDest.GetData()->isQuery() )
237 // nothing to do if one of both denotes a query
238 return;
239
192 {
193 OQueryTableConnectionData* pData = static_cast< OQueryTableConnectionData*>(_pConnectionData.get());
194
195 DlgQryJoin aDlg(_pView,_pConnectionData,_pView->GetTabWinMap(),_pView->getDesignView()->getController().getConnection(),_bSelectableTables);
196 sal_Bool bOk = aDlg.Execute() == RET_OK;
197 if( bOk )
198 {
199 pData->SetJoinType(aDlg.GetJoinType());

--- 32 unchanged lines hidden (view full) ---

232 const OQueryTableWindow& _rSource,
233 const OQueryTableWindow& _rDest,
234 const Reference<XNameAccess>& _rxSourceForeignKeyColumns)
235 {
236 if ( _rSource.GetData()->isQuery() || _rDest.GetData()->isQuery() )
237 // nothing to do if one of both denotes a query
238 return;
239
240 // we found a table in our view where we can insert some connections
240 // we found a table in our view where we can insert some connections
241 // the key columns have a property called RelatedColumn
242 // OQueryTableConnectionData aufbauen
243 OQueryTableConnectionData* pNewConnData = new OQueryTableConnectionData( _rSource.GetData(), _rDest.GetData() );
244 TTableConnectionData::value_type aNewConnData(pNewConnData);
245
246 Reference<XIndexAccess> xReferencedKeys( _rDest.GetData()->getKeys());
247 ::rtl::OUString sRelatedColumn;
248

--- 17 unchanged lines hidden (view full) ---

266
267 {
268 Sequence< sal_Int16> aFind(::comphelper::findValue(_rSource.GetOriginalColumns()->getElementNames(),*pIter,sal_True));
269 if(aFind.getLength())
270 pNewConnData->SetFieldIndex(JTCS_FROM,aFind[0]+1);
271 else
272 OSL_ENSURE(0,"Column not found!");
273 }
241 // the key columns have a property called RelatedColumn
242 // OQueryTableConnectionData aufbauen
243 OQueryTableConnectionData* pNewConnData = new OQueryTableConnectionData( _rSource.GetData(), _rDest.GetData() );
244 TTableConnectionData::value_type aNewConnData(pNewConnData);
245
246 Reference<XIndexAccess> xReferencedKeys( _rDest.GetData()->getKeys());
247 ::rtl::OUString sRelatedColumn;
248

--- 17 unchanged lines hidden (view full) ---

266
267 {
268 Sequence< sal_Int16> aFind(::comphelper::findValue(_rSource.GetOriginalColumns()->getElementNames(),*pIter,sal_True));
269 if(aFind.getLength())
270 pNewConnData->SetFieldIndex(JTCS_FROM,aFind[0]+1);
271 else
272 OSL_ENSURE(0,"Column not found!");
273 }
274 // get the position inside the tabe
274 // get the position inside the table
275 Reference<XNameAccess> xRefColumns = _rDest.GetOriginalColumns();
276 if(xRefColumns.is())
277 {
278 Sequence< sal_Int16> aFind(::comphelper::findValue(xRefColumns->getElementNames(),sRelatedColumn,sal_True));
279 if(aFind.getLength())
280 pNewConnData->SetFieldIndex(JTCS_TO,aFind[0]+1);
281 else
282 OSL_ENSURE(0,"Column not found!");

--- 62 unchanged lines hidden (view full) ---

345 "vor OQueryTableView::ReSync() bitte ClearAll aufrufen !");
346
347 // ich brauche eine Sammlung aller Fensternamen, deren Anlegen schief geht, damit ich die entsprechenden Connections
348 // gar nicht erst anlege
349 ::std::vector<String> arrInvalidTables;
350
351 TTableWindowData::reverse_iterator aIter = pTabWinDataList->rbegin();
352 // Fenster kreieren und einfuegen
275 Reference<XNameAccess> xRefColumns = _rDest.GetOriginalColumns();
276 if(xRefColumns.is())
277 {
278 Sequence< sal_Int16> aFind(::comphelper::findValue(xRefColumns->getElementNames(),sRelatedColumn,sal_True));
279 if(aFind.getLength())
280 pNewConnData->SetFieldIndex(JTCS_TO,aFind[0]+1);
281 else
282 OSL_ENSURE(0,"Column not found!");

--- 62 unchanged lines hidden (view full) ---

345 "vor OQueryTableView::ReSync() bitte ClearAll aufrufen !");
346
347 // ich brauche eine Sammlung aller Fensternamen, deren Anlegen schief geht, damit ich die entsprechenden Connections
348 // gar nicht erst anlege
349 ::std::vector<String> arrInvalidTables;
350
351 TTableWindowData::reverse_iterator aIter = pTabWinDataList->rbegin();
352 // Fenster kreieren und einfuegen
353
353
354 for(;aIter != pTabWinDataList->rend();++aIter)
355 {
356 OQueryTableWindowData* pData = static_cast<OQueryTableWindowData*>(aIter->get());
357 OTableWindow* pTabWin = createWindow(*aIter);
358
359 // ich gehe jetzt NICHT ueber ShowTabWin, da dieses die Daten des Fensters in die Liste des Docs einfuegt, was
360 // schlecht waere, denn genau von dort hole ich sie ja gerade
361 // also Schritt fuer Schritt

--- 15 unchanged lines hidden (view full) ---

377 SetDefaultTabWinPosSize(pTabWin);
378
379 pTabWin->Show();
380 }
381
382 // Verbindungen einfuegen
383 TTableConnectionData* pTabConnDataList = m_pView->getController().getTableConnectionData();
384 TTableConnectionData::reverse_iterator aConIter = pTabConnDataList->rbegin();
354 for(;aIter != pTabWinDataList->rend();++aIter)
355 {
356 OQueryTableWindowData* pData = static_cast<OQueryTableWindowData*>(aIter->get());
357 OTableWindow* pTabWin = createWindow(*aIter);
358
359 // ich gehe jetzt NICHT ueber ShowTabWin, da dieses die Daten des Fensters in die Liste des Docs einfuegt, was
360 // schlecht waere, denn genau von dort hole ich sie ja gerade
361 // also Schritt fuer Schritt

--- 15 unchanged lines hidden (view full) ---

377 SetDefaultTabWinPosSize(pTabWin);
378
379 pTabWin->Show();
380 }
381
382 // Verbindungen einfuegen
383 TTableConnectionData* pTabConnDataList = m_pView->getController().getTableConnectionData();
384 TTableConnectionData::reverse_iterator aConIter = pTabConnDataList->rbegin();
385
385
386 for(;aConIter != pTabConnDataList->rend();++aConIter)
387 {
388 OQueryTableConnectionData* pTabConnData = static_cast<OQueryTableConnectionData*>(aConIter->get());
389
390 // gibt es die beiden Tabellen zur Connection ?
391 String strTabExistenceTest = pTabConnData->getReferencingTable()->GetWinName();
392 sal_Bool bInvalid = ::std::find(arrInvalidTables.begin(),arrInvalidTables.end(),strTabExistenceTest) != arrInvalidTables.end();
393 strTabExistenceTest = pTabConnData->getReferencedTable()->GetWinName();
394 bInvalid = bInvalid && ::std::find(arrInvalidTables.begin(),arrInvalidTables.end(),strTabExistenceTest) != arrInvalidTables.end();
395
396 if (bInvalid)
397 { // nein -> Pech gehabt, die Connection faellt weg
398 pTabConnDataList->erase( ::std::remove(pTabConnDataList->begin(),pTabConnDataList->end(),*aConIter) ,pTabConnDataList->end());
399 continue;
400 }
401
386 for(;aConIter != pTabConnDataList->rend();++aConIter)
387 {
388 OQueryTableConnectionData* pTabConnData = static_cast<OQueryTableConnectionData*>(aConIter->get());
389
390 // gibt es die beiden Tabellen zur Connection ?
391 String strTabExistenceTest = pTabConnData->getReferencingTable()->GetWinName();
392 sal_Bool bInvalid = ::std::find(arrInvalidTables.begin(),arrInvalidTables.end(),strTabExistenceTest) != arrInvalidTables.end();
393 strTabExistenceTest = pTabConnData->getReferencedTable()->GetWinName();
394 bInvalid = bInvalid && ::std::find(arrInvalidTables.begin(),arrInvalidTables.end(),strTabExistenceTest) != arrInvalidTables.end();
395
396 if (bInvalid)
397 { // nein -> Pech gehabt, die Connection faellt weg
398 pTabConnDataList->erase( ::std::remove(pTabConnDataList->begin(),pTabConnDataList->end(),*aConIter) ,pTabConnDataList->end());
399 continue;
400 }
401
402 // adds a new connection to join view and notifies our accessible and invaldates the controller
402 // adds a new connection to join view and notifies our accessible and invalidates the controller
403 addConnection(new OQueryTableConnection(this, *aConIter));
404 }
405}
406
407//------------------------------------------------------------------------
408void OQueryTableView::ClearAll()
409{
410 DBG_CHKTHIS(OQueryTableView,NULL);

--- 11 unchanged lines hidden (view full) ---

422
423//------------------------------------------------------------------------------
424void OQueryTableView::NotifyTabConnection(const OQueryTableConnection& rNewConn, sal_Bool _bCreateUndoAction)
425{
426 DBG_CHKTHIS(OQueryTableView,NULL);
427 // erst mal schauen, ob ich diese Connection schon habe
428 OQueryTableConnection* pTabConn = NULL;
429 const ::std::vector<OTableConnection*>* pConnections = getTableConnections();
403 addConnection(new OQueryTableConnection(this, *aConIter));
404 }
405}
406
407//------------------------------------------------------------------------
408void OQueryTableView::ClearAll()
409{
410 DBG_CHKTHIS(OQueryTableView,NULL);

--- 11 unchanged lines hidden (view full) ---

422
423//------------------------------------------------------------------------------
424void OQueryTableView::NotifyTabConnection(const OQueryTableConnection& rNewConn, sal_Bool _bCreateUndoAction)
425{
426 DBG_CHKTHIS(OQueryTableView,NULL);
427 // erst mal schauen, ob ich diese Connection schon habe
428 OQueryTableConnection* pTabConn = NULL;
429 const ::std::vector<OTableConnection*>* pConnections = getTableConnections();
430 ::std::vector<OTableConnection*>::const_iterator aEnd = pConnections->end();
430 ::std::vector<OTableConnection*>::const_iterator aEnd = pConnections->end();
431 ::std::vector<OTableConnection*>::const_iterator aIter = ::std::find( pConnections->begin(),
432 aEnd,
433 static_cast<const OTableConnection*>(&rNewConn)
434 );
435 if(aIter == aEnd )
436 {
437 aIter = pConnections->begin();
438 for(;aIter != aEnd;++aIter)

--- 8 unchanged lines hidden (view full) ---

447 else
448 pTabConn = static_cast<OQueryTableConnection*>(*aIter);
449 // nein -> einfuegen
450 if (pTabConn == NULL)
451 {
452 // die neuen Daten ...
453 OQueryTableConnectionData* pNewData = static_cast< OQueryTableConnectionData*>(rNewConn.GetData()->NewInstance());
454 pNewData->CopyFrom(*rNewConn.GetData());
431 ::std::vector<OTableConnection*>::const_iterator aIter = ::std::find( pConnections->begin(),
432 aEnd,
433 static_cast<const OTableConnection*>(&rNewConn)
434 );
435 if(aIter == aEnd )
436 {
437 aIter = pConnections->begin();
438 for(;aIter != aEnd;++aIter)

--- 8 unchanged lines hidden (view full) ---

447 else
448 pTabConn = static_cast<OQueryTableConnection*>(*aIter);
449 // nein -> einfuegen
450 if (pTabConn == NULL)
451 {
452 // die neuen Daten ...
453 OQueryTableConnectionData* pNewData = static_cast< OQueryTableConnectionData*>(rNewConn.GetData()->NewInstance());
454 pNewData->CopyFrom(*rNewConn.GetData());
455 TTableConnectionData::value_type aData(pNewData);
455 TTableConnectionData::value_type aData(pNewData);
456 OQueryTableConnection* pNewConn = new OQueryTableConnection(this, aData);
457 GetConnection(pNewConn);
458
459 connectionModified(this,pNewConn,_bCreateUndoAction);
460 }
461}
462// -----------------------------------------------------------------------------
463OTableWindowData* OQueryTableView::CreateImpl(const ::rtl::OUString& _rComposedName

--- 15 unchanged lines hidden (view full) ---

479 if(!xConnection.is())
480 return;
481 try
482 {
483 Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
484 ::rtl::OUString sCatalog, sSchema, sTable;
485 ::dbtools::qualifiedNameComponents(xMetaData,
486 _rTableName,
456 OQueryTableConnection* pNewConn = new OQueryTableConnection(this, aData);
457 GetConnection(pNewConn);
458
459 connectionModified(this,pNewConn,_bCreateUndoAction);
460 }
461}
462// -----------------------------------------------------------------------------
463OTableWindowData* OQueryTableView::CreateImpl(const ::rtl::OUString& _rComposedName

--- 15 unchanged lines hidden (view full) ---

479 if(!xConnection.is())
480 return;
481 try
482 {
483 Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
484 ::rtl::OUString sCatalog, sSchema, sTable;
485 ::dbtools::qualifiedNameComponents(xMetaData,
486 _rTableName,
487 sCatalog,
488 sSchema,
487 sCatalog,
488 sSchema,
489 sTable,
490 ::dbtools::eInDataManipulation);
491 ::rtl::OUString sRealName(sSchema);
492 if (sRealName.getLength())
493 sRealName+= ::rtl::OUString('.');
494 sRealName += sTable;
495
496 AddTabWin(_rTableName, sRealName, _rAliasName, bNewTable);
497 }
498 catch(SQLException&)
499 {
500 OSL_ASSERT(!"qualifiedNameComponents");
501 }
502}
503// -----------------------------------------------------------------------------
489 sTable,
490 ::dbtools::eInDataManipulation);
491 ::rtl::OUString sRealName(sSchema);
492 if (sRealName.getLength())
493 sRealName+= ::rtl::OUString('.');
494 sRealName += sTable;
495
496 AddTabWin(_rTableName, sRealName, _rAliasName, bNewTable);
497 }
498 catch(SQLException&)
499 {
500 OSL_ASSERT(!"qualifiedNameComponents");
501 }
502}
503// -----------------------------------------------------------------------------
504// find the table which has a foreign key with this referencedTable name
504// find the table which has a foreign key with this referencedTable name
505Reference<XPropertySet> getKeyReferencedTo(const Reference<XIndexAccess>& _rxKeys,const ::rtl::OUString& _rReferencedTable)
506{
507 if(!_rxKeys.is())
508 return Reference<XPropertySet>();
509
510 if ( !_rxKeys.is() )
511 return Reference<XPropertySet>();
512 // search the one and only primary key
505Reference<XPropertySet> getKeyReferencedTo(const Reference<XIndexAccess>& _rxKeys,const ::rtl::OUString& _rReferencedTable)
506{
507 if(!_rxKeys.is())
508 return Reference<XPropertySet>();
509
510 if ( !_rxKeys.is() )
511 return Reference<XPropertySet>();
512 // search the one and only primary key
513 const sal_Int32 nCount = _rxKeys->getCount();
513 const sal_Int32 nCount = _rxKeys->getCount();
514 for(sal_Int32 i=0;i<nCount ;++i)
515 {
516 Reference<XPropertySet> xKey(_rxKeys->getByIndex(i),UNO_QUERY);
517 if(xKey.is())
518 {
519 sal_Int32 nKeyType = 0;
520 xKey->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
521 if(KeyType::FOREIGN == nKeyType)

--- 11 unchanged lines hidden (view full) ---

533//------------------------------------------------------------------------------
534void OQueryTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::rtl::OUString& _rTableName, const ::rtl::OUString& strAlias, sal_Bool bNewTable)
535{
536 DBG_CHKTHIS(OQueryTableView,NULL);
537 DBG_ASSERT(_rTableName.getLength() || strAlias.getLength(), "OQueryTableView::AddTabWin : kein Tabellen- und kein Aliasname !");
538 // wenn der Tabellenname nicht gesetzt ist, steht das fuer ein Dummy-Fenster, das braucht aber wenigstens einen Alias-Namen
539
540 // neue Datenstruktur erzeugen
514 for(sal_Int32 i=0;i<nCount ;++i)
515 {
516 Reference<XPropertySet> xKey(_rxKeys->getByIndex(i),UNO_QUERY);
517 if(xKey.is())
518 {
519 sal_Int32 nKeyType = 0;
520 xKey->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
521 if(KeyType::FOREIGN == nKeyType)

--- 11 unchanged lines hidden (view full) ---

533//------------------------------------------------------------------------------
534void OQueryTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::rtl::OUString& _rTableName, const ::rtl::OUString& strAlias, sal_Bool bNewTable)
535{
536 DBG_CHKTHIS(OQueryTableView,NULL);
537 DBG_ASSERT(_rTableName.getLength() || strAlias.getLength(), "OQueryTableView::AddTabWin : kein Tabellen- und kein Aliasname !");
538 // wenn der Tabellenname nicht gesetzt ist, steht das fuer ein Dummy-Fenster, das braucht aber wenigstens einen Alias-Namen
539
540 // neue Datenstruktur erzeugen
541 // first check if this already hav it's data
541 // first check if this already have its data
542 sal_Bool bAppend = bNewTable;
543 TTableWindowData::value_type pNewTabWinData;
544 TTableWindowData* pWindowData = getDesignView()->getController().getTableWindowData();
545 TTableWindowData::iterator aWinIter = pWindowData->begin();
542 sal_Bool bAppend = bNewTable;
543 TTableWindowData::value_type pNewTabWinData;
544 TTableWindowData* pWindowData = getDesignView()->getController().getTableWindowData();
545 TTableWindowData::iterator aWinIter = pWindowData->begin();
546 TTableWindowData::iterator aWinEnd = pWindowData->end();
546 TTableWindowData::iterator aWinEnd = pWindowData->end();
547 for(;aWinIter != aWinEnd;++aWinIter)
548 {
549 pNewTabWinData = *aWinIter;
550 if (pNewTabWinData && pNewTabWinData->GetWinName() == strAlias && pNewTabWinData->GetComposedName() == _rComposedName && pNewTabWinData->GetTableName() == _rTableName)
551 break;
552 }
547 for(;aWinIter != aWinEnd;++aWinIter)
548 {
549 pNewTabWinData = *aWinIter;
550 if (pNewTabWinData && pNewTabWinData->GetWinName() == strAlias && pNewTabWinData->GetComposedName() == _rComposedName && pNewTabWinData->GetTableName() == _rTableName)
551 break;
552 }
553 if ( !bAppend )
554 bAppend = ( aWinIter == aWinEnd );
553 if ( !bAppend )
554 bAppend = ( aWinIter == aWinEnd );
555 if ( bAppend )
556 pNewTabWinData = createTableWindowData(_rComposedName, _rTableName, strAlias);
557 // die TabWinData brauche ich nicht in die entsprechende Liste der DocShell eintragen, das macht ShowTabWin
558
559 // neues Fenster erzeugen
560 OQueryTableWindow* pNewTabWin = static_cast<OQueryTableWindow*>(createWindow(pNewTabWinData));
561 // das Init kann ich hier weglassen, da das in ShowTabWin passiert
562
563 // Neue UndoAction
564 OQueryTabWinShowUndoAct* pUndoAction = new OQueryTabWinShowUndoAct(this);
565 pUndoAction->SetTabWin(pNewTabWin); // Fenster
566 sal_Bool bSuccess = ShowTabWin(pNewTabWin, pUndoAction,bAppend);
567 if(!bSuccess)
568 {
569 // reset table window
555 if ( bAppend )
556 pNewTabWinData = createTableWindowData(_rComposedName, _rTableName, strAlias);
557 // die TabWinData brauche ich nicht in die entsprechende Liste der DocShell eintragen, das macht ShowTabWin
558
559 // neues Fenster erzeugen
560 OQueryTableWindow* pNewTabWin = static_cast<OQueryTableWindow*>(createWindow(pNewTabWinData));
561 // das Init kann ich hier weglassen, da das in ShowTabWin passiert
562
563 // Neue UndoAction
564 OQueryTabWinShowUndoAct* pUndoAction = new OQueryTabWinShowUndoAct(this);
565 pUndoAction->SetTabWin(pNewTabWin); // Fenster
566 sal_Bool bSuccess = ShowTabWin(pNewTabWin, pUndoAction,bAppend);
567 if(!bSuccess)
568 {
569 // reset table window
570 pUndoAction->SetTabWin(NULL);
570 pUndoAction->SetTabWin(NULL);
571 pUndoAction->SetOwnership(sal_False);
572
573 delete pUndoAction;
574 return;
575 }
576
577 // Relationen zwischen den einzelnen Tabellen anzeigen
578 OTableWindowMap* pTabWins = GetTabWinMap();

--- 173 unchanged lines hidden (view full) ---

752 {
753 connectionModified(this,pConnection,sal_False);
754 SelectConn( pConnection );
755 }
756}
757// -----------------------------------------------------------------------------
758void OQueryTableView::createNewConnection()
759{
571 pUndoAction->SetOwnership(sal_False);
572
573 delete pUndoAction;
574 return;
575 }
576
577 // Relationen zwischen den einzelnen Tabellen anzeigen
578 OTableWindowMap* pTabWins = GetTabWinMap();

--- 173 unchanged lines hidden (view full) ---

752 {
753 connectionModified(this,pConnection,sal_False);
754 SelectConn( pConnection );
755 }
756}
757// -----------------------------------------------------------------------------
758void OQueryTableView::createNewConnection()
759{
760 TTableConnectionData::value_type pData(new OQueryTableConnectionData());
760 TTableConnectionData::value_type pData(new OQueryTableConnectionData());
761 if( openJoinDialog(this,pData,sal_True) )
762 {
763 OTableWindowMap* pMap = GetTabWinMap();
764 OQueryTableWindow* pSourceWin = static_cast< OQueryTableWindow*>((*pMap)[pData->getReferencingTable()->GetWinName()]);
765 OQueryTableWindow* pDestWin = static_cast< OQueryTableWindow*>((*pMap)[pData->getReferencedTable()->GetWinName()]);
766 // first we have to look if the this connection already exists
767 OTableConnection* pConn = GetTabConn(pSourceWin,pDestWin,true);
768 sal_Bool bNew = sal_True;
769 if ( pConn )
770 {
771 pConn->GetData()->CopyFrom( *pData );
772 bNew = sal_False;
773 }
774 else
775 {
761 if( openJoinDialog(this,pData,sal_True) )
762 {
763 OTableWindowMap* pMap = GetTabWinMap();
764 OQueryTableWindow* pSourceWin = static_cast< OQueryTableWindow*>((*pMap)[pData->getReferencingTable()->GetWinName()]);
765 OQueryTableWindow* pDestWin = static_cast< OQueryTableWindow*>((*pMap)[pData->getReferencedTable()->GetWinName()]);
766 // first we have to look if the this connection already exists
767 OTableConnection* pConn = GetTabConn(pSourceWin,pDestWin,true);
768 sal_Bool bNew = sal_True;
769 if ( pConn )
770 {
771 pConn->GetData()->CopyFrom( *pData );
772 bNew = sal_False;
773 }
774 else
775 {
776 // create a new conenction and append it
776 // create a new connection and append it
777 OQueryTableConnection* pQConn = new OQueryTableConnection(this, pData);
778 GetConnection(pQConn);
779 pConn = pQConn;
780 }
781 connectionModified(this,pConn,bNew);
782 if ( !bNew && pConn == GetSelectedConn() ) // our connection was selected before so we have to reselect it
783 SelectConn( pConn );
784 }

--- 34 unchanged lines hidden (view full) ---

819}
820
821//------------------------------------------------------------------------------
822sal_Bool OQueryTableView::FindTableFromField(const String& rFieldName, OTableFieldDescRef& rInfo, sal_uInt16& rCnt)
823{
824 DBG_CHKTHIS(OQueryTableView,NULL);
825 rCnt = 0;
826 OTableWindowMap::const_iterator aIter = GetTabWinMap()->begin();
777 OQueryTableConnection* pQConn = new OQueryTableConnection(this, pData);
778 GetConnection(pQConn);
779 pConn = pQConn;
780 }
781 connectionModified(this,pConn,bNew);
782 if ( !bNew && pConn == GetSelectedConn() ) // our connection was selected before so we have to reselect it
783 SelectConn( pConn );
784 }

--- 34 unchanged lines hidden (view full) ---

819}
820
821//------------------------------------------------------------------------------
822sal_Bool OQueryTableView::FindTableFromField(const String& rFieldName, OTableFieldDescRef& rInfo, sal_uInt16& rCnt)
823{
824 DBG_CHKTHIS(OQueryTableView,NULL);
825 rCnt = 0;
826 OTableWindowMap::const_iterator aIter = GetTabWinMap()->begin();
827 OTableWindowMap::const_iterator aEnd = GetTabWinMap()->end();
827 OTableWindowMap::const_iterator aEnd = GetTabWinMap()->end();
828 for(;aIter != aEnd;++aIter)
829 {
830 if(static_cast<OQueryTableWindow*>(aIter->second)->ExistsField(rFieldName, rInfo))
831 ++rCnt;
832 }
833
834 return rCnt == 1;
835}

--- 50 unchanged lines hidden (view full) ---

886 TabWinsChangeNotification aHint(TabWinsChangeNotification::AT_REMOVED_WIN, static_cast< OQueryTableWindow*>(pTabWin)->GetAliasName());
887 m_lnkTabWinsChangeHandler.Call(&aHint);
888 }
889
890 modified();
891 if ( m_pAccessible )
892 m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
893 makeAny(pTabWin->GetAccessible()),
828 for(;aIter != aEnd;++aIter)
829 {
830 if(static_cast<OQueryTableWindow*>(aIter->second)->ExistsField(rFieldName, rInfo))
831 ++rCnt;
832 }
833
834 return rCnt == 1;
835}

--- 50 unchanged lines hidden (view full) ---

886 TabWinsChangeNotification aHint(TabWinsChangeNotification::AT_REMOVED_WIN, static_cast< OQueryTableWindow*>(pTabWin)->GetAliasName());
887 m_lnkTabWinsChangeHandler.Call(&aHint);
888 }
889
890 modified();
891 if ( m_pAccessible )
892 m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
893 makeAny(pTabWin->GetAccessible()),
894 Any()
894 Any()
895 );
895 );
896 }
896 }
897}
898
899//------------------------------------------------------------------------
900void OQueryTableView::EnsureVisible(const OTableWindow* pWin)
901{
902 DBG_CHKTHIS(OQueryTableView,NULL);
897}
898
899//------------------------------------------------------------------------
900void OQueryTableView::EnsureVisible(const OTableWindow* pWin)
901{
902 DBG_CHKTHIS(OQueryTableView,NULL);
903
903
904 Invalidate(INVALIDATE_NOCHILDREN);
905 OJoinTableView::EnsureVisible(pWin);
906}
907
908//------------------------------------------------------------------------
909void OQueryTableView::GetConnection(OQueryTableConnection* pConn)
910{
911 DBG_CHKTHIS(OQueryTableView,NULL);
912 // bei mir und dem Dokument einfuegen
904 Invalidate(INVALIDATE_NOCHILDREN);
905 OJoinTableView::EnsureVisible(pWin);
906}
907
908//------------------------------------------------------------------------
909void OQueryTableView::GetConnection(OQueryTableConnection* pConn)
910{
911 DBG_CHKTHIS(OQueryTableView,NULL);
912 // bei mir und dem Dokument einfuegen
913
913
914 addConnection( pConn );
915 // invalidieren (damit es neu gezeichnet wird)
916 // pConn->Invalidate();
917}
918
919//------------------------------------------------------------------------
920void OQueryTableView::DropConnection(OQueryTableConnection* pConn)
921{

--- 111 unchanged lines hidden (view full) ---

1033 // Das Update ist notwendig, damit die Connections an dem Fenster richtig gezeichnet werden. Klingt absurd,
1034 // ich weiss. Aber die Listbox haelt sich intern ein Member, was bei ersten Zeichnen (nachdem die Listbox im Init
1035 // gerade neu gefuellt wurde) initialisiert wird, und genau dieses Member wird irgendwann benoetigt fuer
1036 // GetEntryPos, und dieses wiederum von der Connection, wenn sie ihren Ansatzpunkt am Fenster feststellen will.
1037
1038 // die Connections
1039 ::std::vector<OTableConnection*>* pTableCon = pUndoAction->GetTabConnList();
1040 ::std::vector<OTableConnection*>::iterator aIter = pTableCon->begin();
914 addConnection( pConn );
915 // invalidieren (damit es neu gezeichnet wird)
916 // pConn->Invalidate();
917}
918
919//------------------------------------------------------------------------
920void OQueryTableView::DropConnection(OQueryTableConnection* pConn)
921{

--- 111 unchanged lines hidden (view full) ---

1033 // Das Update ist notwendig, damit die Connections an dem Fenster richtig gezeichnet werden. Klingt absurd,
1034 // ich weiss. Aber die Listbox haelt sich intern ein Member, was bei ersten Zeichnen (nachdem die Listbox im Init
1035 // gerade neu gefuellt wurde) initialisiert wird, und genau dieses Member wird irgendwann benoetigt fuer
1036 // GetEntryPos, und dieses wiederum von der Connection, wenn sie ihren Ansatzpunkt am Fenster feststellen will.
1037
1038 // die Connections
1039 ::std::vector<OTableConnection*>* pTableCon = pUndoAction->GetTabConnList();
1040 ::std::vector<OTableConnection*>::iterator aIter = pTableCon->begin();
1041 ::std::vector<OTableConnection*>::iterator aEnd = pTableCon->end();
1041 ::std::vector<OTableConnection*>::iterator aEnd = pTableCon->end();
1042
1043 for(;aIter != aEnd;++aIter)
1044 addConnection(*aIter); // add all connections from the undo action
1045
1046 // each connection should invalidated inside addConnection so we don't need this here any longer
1047// if ( !pOwnList->empty() )
1048// InvalidateConnections();
1049 pTableCon->clear();

--- 17 unchanged lines hidden (view full) ---

1067 pTabWin->clearListBox();
1068 delete pTabWin;
1069 }
1070 }
1071
1072 // damit habe ich das Doc natuerlich modifiziert
1073 if(!m_pView->getController().isReadOnly())
1074 m_pView->getController().setModified( sal_True );
1042
1043 for(;aIter != aEnd;++aIter)
1044 addConnection(*aIter); // add all connections from the undo action
1045
1046 // each connection should invalidated inside addConnection so we don't need this here any longer
1047// if ( !pOwnList->empty() )
1048// InvalidateConnections();
1049 pTableCon->clear();

--- 17 unchanged lines hidden (view full) ---

1067 pTabWin->clearListBox();
1068 delete pTabWin;
1069 }
1070 }
1071
1072 // damit habe ich das Doc natuerlich modifiziert
1073 if(!m_pView->getController().isReadOnly())
1074 m_pView->getController().setModified( sal_True );
1075
1075
1076 m_pView->getController().InvalidateFeature(SID_BROWSER_CLEAR_QUERY);
1077
1078 return bSuccess;
1079}
1080//------------------------------------------------------------------------
1081void OQueryTableView::InsertField(const OTableFieldDescRef& rInfo)
1082{
1083 DBG_CHKTHIS(OQueryTableView,NULL);
1084 DBG_ASSERT(getDesignView() != NULL, "OQueryTableView::InsertField : habe kein Parent !");
1085 static_cast<OQueryDesignView*>(getDesignView())->InsertField(rInfo);
1086}
1087//------------------------------------------------------------------------------
1088sal_Bool OQueryTableView::ExistsAVisitedConn(const OQueryTableWindow* pFrom) const
1089{
1090 DBG_CHKTHIS(OQueryTableView,NULL);
1091 const ::std::vector<OTableConnection*>* pList = getTableConnections();
1092 if (pList)
1093 {
1094 ::std::vector<OTableConnection*>::const_iterator aIter = pList->begin();
1076 m_pView->getController().InvalidateFeature(SID_BROWSER_CLEAR_QUERY);
1077
1078 return bSuccess;
1079}
1080//------------------------------------------------------------------------
1081void OQueryTableView::InsertField(const OTableFieldDescRef& rInfo)
1082{
1083 DBG_CHKTHIS(OQueryTableView,NULL);
1084 DBG_ASSERT(getDesignView() != NULL, "OQueryTableView::InsertField : habe kein Parent !");
1085 static_cast<OQueryDesignView*>(getDesignView())->InsertField(rInfo);
1086}
1087//------------------------------------------------------------------------------
1088sal_Bool OQueryTableView::ExistsAVisitedConn(const OQueryTableWindow* pFrom) const
1089{
1090 DBG_CHKTHIS(OQueryTableView,NULL);
1091 const ::std::vector<OTableConnection*>* pList = getTableConnections();
1092 if (pList)
1093 {
1094 ::std::vector<OTableConnection*>::const_iterator aIter = pList->begin();
1095 ::std::vector<OTableConnection*>::const_iterator aEnd = pList->end();
1095 ::std::vector<OTableConnection*>::const_iterator aEnd = pList->end();
1096 for(;aIter != aEnd;++aIter)
1097 {
1098 OQueryTableConnection* pTemp = static_cast<OQueryTableConnection*>(*aIter);
1099 if (pTemp->IsVisited() &&
1100 (pFrom == static_cast< OQueryTableWindow*>(pTemp->GetSourceWin()) || pFrom == static_cast< OQueryTableWindow*>(pTemp->GetDestWin())))
1101 return pTemp != NULL;
1102 }
1103 }
1104
1105 return sal_False;
1106}
1107// -----------------------------------------------------------------------------
1108void OQueryTableView::onNoColumns_throw()
1109{
1096 for(;aIter != aEnd;++aIter)
1097 {
1098 OQueryTableConnection* pTemp = static_cast<OQueryTableConnection*>(*aIter);
1099 if (pTemp->IsVisited() &&
1100 (pFrom == static_cast< OQueryTableWindow*>(pTemp->GetSourceWin()) || pFrom == static_cast< OQueryTableWindow*>(pTemp->GetDestWin())))
1101 return pTemp != NULL;
1102 }
1103 }
1104
1105 return sal_False;
1106}
1107// -----------------------------------------------------------------------------
1108void OQueryTableView::onNoColumns_throw()
1109{
1110 String sError( ModuleRes( STR_STATEMENT_WITHOUT_RESULT_SET ) );
1111 ::dbtools::throwSQLException( sError, ::dbtools::SQL_GENERAL_ERROR, NULL );
1110 String sError( ModuleRes( STR_STATEMENT_WITHOUT_RESULT_SET ) );
1111 ::dbtools::throwSQLException( sError, ::dbtools::SQL_GENERAL_ERROR, NULL );
1112}
1113//------------------------------------------------------------------------------
1114bool OQueryTableView::supressCrossNaturalJoin(const TTableConnectionData::value_type& _pData) const
1115{
1112}
1113//------------------------------------------------------------------------------
1114bool OQueryTableView::supressCrossNaturalJoin(const TTableConnectionData::value_type& _pData) const
1115{
1116 OQueryTableConnectionData* pQueryData = static_cast<OQueryTableConnectionData*>(_pData.get());
1117 return pQueryData && (pQueryData->GetJoinType() == CROSS_JOIN);
1116 OQueryTableConnectionData* pQueryData = static_cast<OQueryTableConnectionData*>(_pData.get());
1117 return pQueryData && (pQueryData->GetJoinType() == CROSS_JOIN);
1118}
1119// -----------------------------------------------------------------------------
1118}
1119// -----------------------------------------------------------------------------
1120
1121/* vim: set noet sw=4 ts=4: */