2001-02-28 03:09:17 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 10:37:01 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-02-28 03:09:17 -06:00
|
|
|
*
|
2005-09-08 10:37:01 -05:00
|
|
|
* $RCSfile: RelationTableView.cxx,v $
|
2001-02-28 03:09:17 -06:00
|
|
|
*
|
2007-11-01 09:37:50 -05:00
|
|
|
* $Revision: 1.26 $
|
2001-02-28 03:09:17 -06:00
|
|
|
*
|
2007-11-01 09:37:50 -05:00
|
|
|
* last change: $Author: hr $ $Date: 2007-11-01 15:37:50 $
|
2001-02-28 03:09:17 -06:00
|
|
|
*
|
2005-09-08 10:37:01 -05:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2001-02-28 03:09:17 -06:00
|
|
|
*
|
|
|
|
*
|
2005-09-08 10:37:01 -05:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2001-02-28 03:09:17 -06:00
|
|
|
*
|
2005-09-08 10:37:01 -05:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2001-02-28 03:09:17 -06:00
|
|
|
*
|
2005-09-08 10:37:01 -05:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2001-02-28 03:09:17 -06:00
|
|
|
*
|
2005-09-08 10:37:01 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2001-02-28 03:09:17 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 01:28:33 -05:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_dbaccess.hxx"
|
2001-02-28 03:09:17 -06:00
|
|
|
#ifndef DBAUI_RELATION_TABLEVIEW_HXX
|
|
|
|
#include "RelationTableView.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_JOINEXCHANGE_HXX
|
|
|
|
#include "JoinExchange.hxx"
|
|
|
|
#endif
|
2001-03-15 01:29:16 -06:00
|
|
|
#ifndef _COMPHELPER_EXTRACT_HXX_
|
|
|
|
#include <comphelper/extract.hxx>
|
2001-02-28 03:09:17 -06:00
|
|
|
#endif
|
|
|
|
#ifndef DBACCESS_UI_BROWSER_ID_HXX
|
|
|
|
#include "browserids.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XConnection.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_SDBCX_KEYTYPE_HPP_
|
|
|
|
#include <com/sun/star/sdbcx/KeyType.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
|
|
|
|
#include <com/sun/star/container/XIndexAccess.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
|
|
|
|
#include <com/sun/star/container/XNameAccess.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
|
|
|
|
#include "dbustrings.hrc"
|
|
|
|
#endif
|
|
|
|
#ifndef _CONNECTIVITY_DBTOOLS_HXX_
|
|
|
|
#include <connectivity/dbtools.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _COMPHELPER_SEQUENCE_HXX_
|
|
|
|
#include <comphelper/sequence.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DBA_DBACCESS_HELPID_HRC_
|
|
|
|
#include "dbaccess_helpid.hrc"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_RELATIONDESIGNVIEW_HXX
|
|
|
|
#include "RelationDesignView.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_JOINCONTROLLER_HXX
|
|
|
|
#include "JoinController.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_TABLEWINDOW_HXX
|
|
|
|
#include "TableWindow.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_TABLEWINDOWDATA_HXX
|
|
|
|
#include "TableWindowData.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_RTABLECONNECTION_HXX
|
|
|
|
#include "RTableConnection.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_RTABLECONNECTIONDATA_HXX
|
|
|
|
#include "RTableConnectionData.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_RELATIONDIALOG_HXX
|
|
|
|
#include "RelationDlg.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _DBAUI_SQLMESSAGE_HXX_
|
|
|
|
#include "sqlmessage.hxx"
|
|
|
|
#endif
|
2002-08-19 02:01:32 -05:00
|
|
|
#ifndef _DBU_REL_HRC_
|
|
|
|
#include "dbu_rel.hrc"
|
2001-02-28 03:09:17 -06:00
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_TOOLS_HXX
|
|
|
|
#include "UITools.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _DBHELPER_DBEXCEPTION_HXX_
|
|
|
|
#include <connectivity/dbexception.hxx>
|
|
|
|
#endif
|
2002-11-08 02:27:59 -06:00
|
|
|
#ifndef DBAUI_RELTABLEWINDOW_HXX
|
|
|
|
#include "RTableWindow.hxx"
|
|
|
|
#endif
|
2002-11-26 00:46:13 -06:00
|
|
|
#ifndef DBACCESS_JACCESS_HXX
|
|
|
|
#include "JAccess.hxx"
|
|
|
|
#endif
|
2006-04-19 07:24:26 -05:00
|
|
|
#ifndef _UNDO_HXX
|
|
|
|
#include <svtools/undo.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_
|
2003-04-24 11:23:10 -05:00
|
|
|
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
|
2006-04-19 07:24:26 -05:00
|
|
|
#endif
|
2001-10-11 02:38:14 -05:00
|
|
|
|
2001-02-28 03:09:17 -06:00
|
|
|
using namespace dbaui;
|
|
|
|
using namespace ::dbtools;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::container;
|
2003-04-24 11:23:10 -05:00
|
|
|
using namespace ::com::sun::star::accessibility;
|
2001-02-28 03:09:17 -06:00
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
// class ORelationTableView
|
|
|
|
//==================================================================
|
|
|
|
DBG_NAME(ORelationTableView);
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
ORelationTableView::ORelationTableView( Window* pParent, ORelationDesignView* pView )
|
|
|
|
: OJoinTableView( pParent, pView )
|
2001-07-09 00:56:49 -05:00
|
|
|
,m_pExistingConnection(NULL)
|
2001-02-28 03:09:17 -06:00
|
|
|
{
|
|
|
|
DBG_CTOR(ORelationTableView,NULL);
|
|
|
|
SetHelpId(HID_CTL_RELATIONTAB);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
ORelationTableView::~ORelationTableView()
|
|
|
|
{
|
|
|
|
DBG_DTOR(ORelationTableView,NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
void ORelationTableView::ReSync()
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS(ORelationTableView,NULL);
|
|
|
|
// Es kann sein, dass in der DB Tabellen ausgeblendet wurden, die eigentlich Bestandteil einer Relation sind. Oder eine Tabelle
|
|
|
|
// befand sich im Layout (durchaus ohne Relation), existiert aber nicht mehr. In beiden Faellen wird das Anlegen des TabWins schief
|
|
|
|
// gehen, und alle solchen TabWinDatas oder darauf bezogenen ConnDatas muss ich dann loeschen.
|
|
|
|
::std::vector< ::rtl::OUString> arrInvalidTables;
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// create and insert windows
|
2007-11-01 09:37:50 -05:00
|
|
|
TTableWindowData* pTabWinDataList = m_pView->getController()->getTableWindowData();
|
|
|
|
TTableWindowData::reverse_iterator aIter = pTabWinDataList->rbegin();
|
2001-02-28 03:09:17 -06:00
|
|
|
for(;aIter != pTabWinDataList->rend();++aIter)
|
|
|
|
{
|
2007-11-01 09:37:50 -05:00
|
|
|
TTableWindowData::value_type pData = *aIter;
|
2002-11-08 02:27:59 -06:00
|
|
|
OTableWindow* pTabWin = createWindow(pData);
|
2001-02-28 03:09:17 -06:00
|
|
|
|
|
|
|
if (!pTabWin->Init())
|
|
|
|
{
|
|
|
|
// das Initialisieren ging schief, dass heisst, dieses TabWin steht nicht zur Verfuegung, also muss ich es inklusive
|
|
|
|
// seiner Daten am Dokument aufraeumen
|
2002-06-27 02:23:50 -05:00
|
|
|
pTabWin->clearListBox();
|
2001-02-28 03:09:17 -06:00
|
|
|
delete pTabWin;
|
|
|
|
arrInvalidTables.push_back(pData->GetTableName());
|
|
|
|
|
2005-09-23 06:45:21 -05:00
|
|
|
pTabWinDataList->erase( ::std::remove(pTabWinDataList->begin(),pTabWinDataList->end(),*aIter) ,pTabWinDataList->end());
|
2001-02-28 03:09:17 -06:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*GetTabWinMap())[pData->GetComposedName()] = pTabWin; // am Anfang einfuegen, da ich die DataList ja rueckwaerts durchlaufe
|
|
|
|
// wenn in den Daten keine Position oder Groesse steht -> Default
|
|
|
|
if (!pData->HasPosition() && !pData->HasSize())
|
|
|
|
SetDefaultTabWinPosSize(pTabWin);
|
|
|
|
|
|
|
|
pTabWin->Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verbindungen einfuegen
|
2007-11-01 09:37:50 -05:00
|
|
|
TTableConnectionData* pTabConnDataList = m_pView->getController()->getTableConnectionData();
|
|
|
|
TTableConnectionData::reverse_iterator aConIter = pTabConnDataList->rbegin();
|
2001-02-28 03:09:17 -06:00
|
|
|
|
|
|
|
for(;aConIter != pTabConnDataList->rend();++aConIter)
|
|
|
|
{
|
2007-11-01 09:37:50 -05:00
|
|
|
ORelationTableConnectionData* pTabConnData = static_cast<ORelationTableConnectionData*>(aConIter->get());
|
2002-03-26 00:58:38 -06:00
|
|
|
if ( !arrInvalidTables.empty() )
|
|
|
|
{
|
|
|
|
// gibt es die beiden Tabellen zur Connection ?
|
2007-11-01 09:37:50 -05:00
|
|
|
::rtl::OUString strTabExistenceTest = pTabConnData->getReferencingTable()->GetTableName();
|
2002-03-26 00:58:38 -06:00
|
|
|
sal_Bool bInvalid = ::std::find(arrInvalidTables.begin(),arrInvalidTables.end(),strTabExistenceTest) != arrInvalidTables.end();
|
2007-11-01 09:37:50 -05:00
|
|
|
strTabExistenceTest = pTabConnData->getReferencedTable()->GetTableName();
|
2006-04-19 07:24:26 -05:00
|
|
|
bInvalid = bInvalid || ::std::find(arrInvalidTables.begin(),arrInvalidTables.end(),strTabExistenceTest) != arrInvalidTables.end();
|
2001-02-28 03:09:17 -06:00
|
|
|
|
2002-03-26 00:58:38 -06:00
|
|
|
if (bInvalid)
|
|
|
|
{ // nein -> Pech gehabt, die Connection faellt weg
|
2005-09-23 06:45:21 -05:00
|
|
|
pTabConnDataList->erase( ::std::remove(pTabConnDataList->begin(),pTabConnDataList->end(),*aConIter),pTabConnDataList->end() );
|
2002-03-26 00:58:38 -06:00
|
|
|
continue;
|
|
|
|
}
|
2001-02-28 03:09:17 -06:00
|
|
|
}
|
|
|
|
|
2007-11-01 09:37:50 -05:00
|
|
|
addConnection( new ORelationTableConnection(this, *aConIter), sal_False ); // don't add the data again
|
2001-02-28 03:09:17 -06:00
|
|
|
}
|
2001-10-26 01:49:36 -05:00
|
|
|
|
2002-03-26 00:58:38 -06:00
|
|
|
if ( !GetTabWinMap()->empty() )
|
2001-10-26 01:49:36 -05:00
|
|
|
GetTabWinMap()->begin()->second->GrabFocus();
|
2001-02-28 03:09:17 -06:00
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
BOOL ORelationTableView::IsAddAllowed()
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS(ORelationTableView,NULL);
|
|
|
|
|
2007-09-26 08:53:34 -05:00
|
|
|
return !m_pView->getController()->isReadOnly();
|
2001-02-28 03:09:17 -06:00
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
void ORelationTableView::AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest)
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS(ORelationTableView,NULL);
|
|
|
|
// Aus selektierten Feldnamen LineDataObject setzen
|
|
|
|
// check if relation already exists
|
2007-11-01 09:37:50 -05:00
|
|
|
OTableWindow* pSourceWin = jxdSource.pListBox->GetTabWin();
|
|
|
|
OTableWindow* pDestWin = jxdDest.pListBox->GetTabWin();
|
2001-02-28 03:09:17 -06:00
|
|
|
|
2002-02-08 02:24:02 -06:00
|
|
|
::std::vector<OTableConnection*>::const_iterator aIter = getTableConnections()->begin();
|
|
|
|
for(;aIter != getTableConnections()->end();++aIter)
|
2001-02-28 03:09:17 -06:00
|
|
|
{
|
|
|
|
OTableConnection* pFirst = *aIter;
|
|
|
|
if((pFirst->GetSourceWin() == pSourceWin && pFirst->GetDestWin() == pDestWin) ||
|
|
|
|
(pFirst->GetSourceWin() == pDestWin && pFirst->GetDestWin() == pSourceWin))
|
|
|
|
{
|
2001-07-09 00:56:49 -05:00
|
|
|
m_pExistingConnection = pFirst;
|
2007-11-01 09:37:50 -05:00
|
|
|
break;
|
2001-02-28 03:09:17 -06:00
|
|
|
}
|
|
|
|
}
|
2001-06-28 08:26:45 -05:00
|
|
|
// insert table connection into view
|
2001-10-11 02:38:14 -05:00
|
|
|
|
2007-11-01 09:37:50 -05:00
|
|
|
TTableConnectionData::value_type pTabConnData(new ORelationTableConnectionData(pSourceWin->GetData(),
|
|
|
|
pDestWin->GetData()));
|
2001-02-28 03:09:17 -06:00
|
|
|
|
|
|
|
// die Namen der betroffenen Felder
|
2007-11-01 09:37:50 -05:00
|
|
|
::rtl::OUString sSourceFieldName = jxdSource.pListBox->GetEntryText(jxdSource.pEntry);
|
|
|
|
::rtl::OUString sDestFieldName = jxdDest.pListBox->GetEntryText(jxdDest.pEntry);
|
2001-02-28 03:09:17 -06:00
|
|
|
|
|
|
|
// die Anzahl der PKey-Felder in der Quelle
|
|
|
|
|
|
|
|
::std::vector< Reference< XNameAccess> > aPkeys = ::dbaui::getKeyColumns(pSourceWin->GetTable(),KeyType::PRIMARY);
|
2007-11-01 09:37:50 -05:00
|
|
|
bool bAskUser = aPkeys.size() == 1 && Reference< XIndexAccess>(aPkeys[0],UNO_QUERY)->getCount() > 1;
|
2001-02-28 03:09:17 -06:00
|
|
|
|
2007-11-01 09:37:50 -05:00
|
|
|
pTabConnData->SetConnLine( 0, sSourceFieldName, sDestFieldName );
|
|
|
|
|
|
|
|
if ( bAskUser || m_pExistingConnection )
|
|
|
|
m_pCurrentlyTabConnData = pTabConnData; // this implies that we ask the user what to do
|
2001-02-28 03:09:17 -06:00
|
|
|
else
|
|
|
|
{
|
2001-07-09 00:56:49 -05:00
|
|
|
try
|
2001-02-28 03:09:17 -06:00
|
|
|
{
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2001-07-09 00:56:49 -05:00
|
|
|
// Daten der Datenbank uebergeben
|
|
|
|
if( pTabConnData->Update() )
|
|
|
|
{
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// UI-Object in ConnListe eintragen
|
2002-02-08 02:24:02 -06:00
|
|
|
addConnection( new ORelationTableConnection( this, pTabConnData ) );
|
2001-07-09 00:56:49 -05:00
|
|
|
}
|
2001-02-28 03:09:17 -06:00
|
|
|
}
|
2001-07-09 00:56:49 -05:00
|
|
|
catch(const SQLException&)
|
|
|
|
{
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
catch(const Exception&)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0,"ORelationTableView::AddConnection: Exception oocured!");
|
|
|
|
}
|
2001-02-28 03:09:17 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
void ORelationTableView::ConnDoubleClicked( OTableConnection* pConnection )
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS(ORelationTableView,NULL);
|
2007-11-01 09:37:50 -05:00
|
|
|
ORelationDialog aRelDlg( this, pConnection->GetData() );
|
|
|
|
switch (aRelDlg.Execute())
|
2001-02-28 03:09:17 -06:00
|
|
|
{
|
2007-11-01 09:37:50 -05:00
|
|
|
case RET_OK:
|
|
|
|
// successfully updated
|
|
|
|
pConnection->UpdateLineList();
|
|
|
|
// The connection references 1 ConnData and n ConnLines, each ConnData references n LineDatas, each Line exactly 1 LineData
|
|
|
|
// As the Dialog and the ConnData->Update may have changed the LineDatas we have to restore the consistent state
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RET_NO:
|
|
|
|
// tried at least one update, but did not succeed -> the original connection is lost
|
|
|
|
RemoveConnection( pConnection ,sal_True);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RET_CANCEL:
|
|
|
|
// no break, as nothing happened and we don't need the code below
|
|
|
|
return;
|
2001-02-28 03:09:17 -06:00
|
|
|
|
2001-06-28 08:26:45 -05:00
|
|
|
}
|
2007-11-01 09:37:50 -05:00
|
|
|
|
|
|
|
Invalidate(INVALIDATE_NOCHILDREN);
|
2001-02-28 03:09:17 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void ORelationTableView::AddNewRelation()
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS(ORelationTableView,NULL);
|
|
|
|
|
2007-11-01 09:37:50 -05:00
|
|
|
TTableConnectionData::value_type pNewConnData( new ORelationTableConnectionData() );
|
|
|
|
ORelationDialog aRelDlg(this, pNewConnData, TRUE);
|
2001-02-28 03:09:17 -06:00
|
|
|
|
2007-11-01 09:37:50 -05:00
|
|
|
BOOL bSuccess = (aRelDlg.Execute() == RET_OK);
|
|
|
|
if (bSuccess)
|
|
|
|
{
|
|
|
|
// already updated by the dialog
|
|
|
|
// dem Dokument bekanntgeben
|
|
|
|
addConnection( new ORelationTableConnection(this, pNewConnData) );
|
2001-02-28 03:09:17 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2006-06-19 21:31:32 -05:00
|
|
|
::std::vector<OTableConnection*>::const_iterator ORelationTableView::RemoveConnection( OTableConnection* pConn ,sal_Bool /*_bDelete*/)
|
2001-02-28 03:09:17 -06:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS(ORelationTableView,NULL);
|
2002-02-08 02:24:02 -06:00
|
|
|
::std::vector<OTableConnection*>::const_iterator aNextPos = getTableConnections()->end();
|
2007-11-01 09:37:50 -05:00
|
|
|
ORelationTableConnectionData* pTabConnData = (ORelationTableConnectionData*)pConn->GetData().get();
|
2001-02-28 03:09:17 -06:00
|
|
|
try
|
|
|
|
{
|
2002-02-08 02:24:02 -06:00
|
|
|
if (pTabConnData->DropRelation())
|
|
|
|
aNextPos = OJoinTableView::RemoveConnection( pConn ,sal_True);
|
2001-02-28 03:09:17 -06:00
|
|
|
}
|
|
|
|
catch(SQLException& e)
|
|
|
|
{
|
|
|
|
getDesignView()->getController()->showError(SQLExceptionInfo(e));
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
2001-06-28 08:26:45 -05:00
|
|
|
OSL_ENSURE(0,"ORelationTableView::RemoveConnection: Something other than SQLException occured!");
|
2001-02-28 03:09:17 -06:00
|
|
|
}
|
2002-02-08 02:24:02 -06:00
|
|
|
return aNextPos;
|
2001-02-28 03:09:17 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2006-06-19 21:31:32 -05:00
|
|
|
void ORelationTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::rtl::OUString& rWinName, BOOL /*bNewTable*/)
|
2001-02-28 03:09:17 -06:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS(ORelationTableView,NULL);
|
|
|
|
OSL_ENSURE(_rComposedName.getLength(),"There must be a table name supplied!");
|
|
|
|
OJoinTableView::OTableWindowMap::iterator aIter = GetTabWinMap()->find(_rComposedName);
|
|
|
|
|
|
|
|
if(aIter != GetTabWinMap()->end())
|
|
|
|
{
|
|
|
|
aIter->second->SetZOrder(NULL, WINDOW_ZORDER_FIRST);
|
|
|
|
aIter->second->GrabFocus();
|
|
|
|
EnsureVisible(aIter->second);
|
|
|
|
// no new one
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
// Neue Datenstruktur in DocShell eintragen
|
2007-11-01 09:37:50 -05:00
|
|
|
TTableWindowData::value_type pNewTabWinData(createTableWindowData( _rComposedName, rWinName,rWinName ));
|
2001-02-28 03:09:17 -06:00
|
|
|
pNewTabWinData->ShowAll(FALSE);
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
// Neues Fenster in Fensterliste eintragen
|
2002-11-08 02:27:59 -06:00
|
|
|
OTableWindow* pNewTabWin = createWindow( pNewTabWinData );
|
2001-02-28 03:09:17 -06:00
|
|
|
if(pNewTabWin->Init())
|
|
|
|
{
|
|
|
|
m_pView->getController()->getTableWindowData()->push_back( pNewTabWinData);
|
|
|
|
// when we already have a table with this name insert the full qualified one instead
|
|
|
|
(*GetTabWinMap())[_rComposedName] = pNewTabWin;
|
|
|
|
|
|
|
|
SetDefaultTabWinPosSize( pNewTabWin );
|
|
|
|
pNewTabWin->Show();
|
|
|
|
|
2002-11-26 00:46:13 -06:00
|
|
|
modified();
|
|
|
|
|
|
|
|
if ( m_pAccessible )
|
2003-04-24 11:23:10 -05:00
|
|
|
m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
|
2002-11-26 00:46:13 -06:00
|
|
|
Any(),
|
|
|
|
makeAny(pNewTabWin->GetAccessible()));
|
2001-02-28 03:09:17 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-06-27 02:23:50 -05:00
|
|
|
pNewTabWin->clearListBox();
|
2001-02-28 03:09:17 -06:00
|
|
|
delete pNewTabWin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-03-23 02:09:24 -06:00
|
|
|
void ORelationTableView::RemoveTabWin( OTableWindow* pTabWin )
|
|
|
|
{
|
2001-07-09 00:56:49 -05:00
|
|
|
OSQLMessageBox aDlg(this,ModuleRes(STR_QUERY_REL_DELETE_WINDOW),String(),WB_YES_NO|WB_DEF_YES,OSQLMessageBox::Warning);
|
|
|
|
if(aDlg.Execute() == RET_YES)
|
|
|
|
{
|
2006-04-19 07:24:26 -05:00
|
|
|
m_pView->getController()->getUndoMgr()->Clear();
|
2001-07-09 00:56:49 -05:00
|
|
|
OJoinTableView::RemoveTabWin( pTabWin );
|
2006-04-19 07:24:26 -05:00
|
|
|
|
2004-09-09 03:50:41 -05:00
|
|
|
m_pView->getController()->InvalidateFeature(SID_RELATION_ADD_RELATION);
|
2006-04-19 07:24:26 -05:00
|
|
|
m_pView->getController()->InvalidateFeature(ID_BROWSER_UNDO);
|
|
|
|
m_pView->getController()->InvalidateFeature(ID_BROWSER_REDO);
|
2001-07-09 00:56:49 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2007-11-01 09:37:50 -05:00
|
|
|
//namespace
|
|
|
|
//{
|
|
|
|
// class OReleationAskDialog : public ButtonDialog
|
|
|
|
// {
|
|
|
|
// FixedImage m_aInfoImage;
|
|
|
|
// FixedText m_aTitle;
|
|
|
|
// FixedText m_aMessage;
|
|
|
|
// public:
|
|
|
|
// OReleationDialog(Window* _pParent) : ButtonDialog(_pParent,WB_HORZ | WB_STDDIALOG)
|
|
|
|
// ,m_aInfoImage(this)
|
|
|
|
// ,m_aTitle(this,WB_WORDBREAK | WB_LEFT)
|
|
|
|
// ,m_aMessage(this,WB_WORDBREAK | WB_LEFT)
|
|
|
|
// {
|
|
|
|
// m_aMessage.SetText(ModuleRes(STR_QUERY_REL_EDIT_RELATION));
|
|
|
|
// m_aMessage.Show();
|
|
|
|
//
|
|
|
|
// // Changed as per BugID 79541 Branding/Configuration
|
|
|
|
// String sDialogTitle( lcl_getProductName() );
|
|
|
|
// SetText( sDialogTitle.AppendAscii( " Base" ) );
|
|
|
|
// m_aTitle.Show();
|
|
|
|
// }
|
|
|
|
// };
|
|
|
|
//}
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-07-09 00:56:49 -05:00
|
|
|
void ORelationTableView::lookForUiActivities()
|
|
|
|
{
|
|
|
|
if(m_pExistingConnection)
|
|
|
|
{
|
2007-11-01 09:37:50 -05:00
|
|
|
String sTitle(ModuleRes(STR_RELATIONDESIGN));
|
|
|
|
sTitle.Erase(0,3);
|
|
|
|
OSQLMessageBox aDlg(this,ModuleRes(STR_QUERY_REL_EDIT_RELATION),String(),0);
|
|
|
|
aDlg.SetText(sTitle);
|
|
|
|
aDlg.RemoveButton(aDlg.GetButtonId(0));
|
|
|
|
aDlg.AddButton( ModuleRes(STR_QUERY_REL_EDIT), BUTTONID_OK, BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON);
|
|
|
|
aDlg.AddButton( ModuleRes(STR_QUERY_REL_CREATE), BUTTONID_YES, 0);
|
|
|
|
aDlg.AddButton(BUTTON_CANCEL,BUTTONID_CANCEL,0);
|
|
|
|
UINT16 nRet = aDlg.Execute();
|
|
|
|
if( nRet == RET_CANCEL)
|
|
|
|
{
|
|
|
|
m_pCurrentlyTabConnData.reset();
|
|
|
|
}
|
|
|
|
else if ( nRet == RET_OK ) // EDIT
|
|
|
|
{
|
2001-07-09 00:56:49 -05:00
|
|
|
ConnDoubleClicked(m_pExistingConnection);
|
2007-11-01 09:37:50 -05:00
|
|
|
m_pCurrentlyTabConnData.reset();
|
|
|
|
}
|
2001-07-09 00:56:49 -05:00
|
|
|
m_pExistingConnection = NULL;
|
|
|
|
}
|
2007-11-01 09:37:50 -05:00
|
|
|
if(m_pCurrentlyTabConnData)
|
2001-07-09 00:56:49 -05:00
|
|
|
{
|
|
|
|
ORelationDialog aRelDlg( this, m_pCurrentlyTabConnData );
|
|
|
|
if (aRelDlg.Execute() == RET_OK)
|
|
|
|
{
|
|
|
|
// already updated by the dialog
|
2002-02-08 02:24:02 -06:00
|
|
|
addConnection( new ORelationTableConnection( this, m_pCurrentlyTabConnData ) );
|
2001-07-09 00:56:49 -05:00
|
|
|
}
|
2007-11-01 09:37:50 -05:00
|
|
|
m_pCurrentlyTabConnData.reset();
|
2001-07-09 00:56:49 -05:00
|
|
|
}
|
2001-03-23 02:09:24 -06:00
|
|
|
}
|
2006-07-10 09:46:10 -05:00
|
|
|
|
2001-03-23 02:09:24 -06:00
|
|
|
// -----------------------------------------------------------------------------
|
2007-11-01 09:37:50 -05:00
|
|
|
OTableWindow* ORelationTableView::createWindow(const TTableWindowData::value_type& _pData)
|
2002-11-08 02:27:59 -06:00
|
|
|
{
|
|
|
|
return new ORelationTableWindow(this,_pData);
|
|
|
|
}
|
2006-07-10 09:46:10 -05:00
|
|
|
// -----------------------------------------------------------------------------
|
2007-11-01 09:37:50 -05:00
|
|
|
bool ORelationTableView::allowQueries() const
|
2006-07-10 09:46:10 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2007-11-01 09:37:50 -05:00
|
|
|
|