2001-02-05 02:35:57 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 10:24:39 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-02-05 02:35:57 -06:00
|
|
|
*
|
2008-04-10 10:24:39 -05:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2001-02-05 02:35:57 -06:00
|
|
|
*
|
2008-04-10 10:24:39 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-02-05 02:35:57 -06:00
|
|
|
*
|
2008-04-10 10:24:39 -05:00
|
|
|
* $RCSfile: TableConnectionData.cxx,v $
|
|
|
|
* $Revision: 1.11 $
|
2001-02-05 02:35:57 -06:00
|
|
|
*
|
2008-04-10 10:24:39 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-02-05 02:35:57 -06:00
|
|
|
*
|
2008-04-10 10:24:39 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2001-02-05 02:35:57 -06:00
|
|
|
*
|
2008-04-10 10:24:39 -05:00
|
|
|
* OpenOffice.org 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 version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2001-02-05 02:35:57 -06:00
|
|
|
*
|
2008-04-10 10:24:39 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2001-02-05 02:35:57 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 01:24:33 -05:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_dbaccess.hxx"
|
2001-02-05 02:35:57 -06:00
|
|
|
#ifndef DBAUI_TABLECONNECTIONDATA_HXX
|
|
|
|
#include "TableConnectionData.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _COMPHELPER_STLTYPES_HXX_
|
|
|
|
#include <comphelper/stl_types.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
using namespace dbaui;
|
|
|
|
using namespace comphelper;
|
|
|
|
//==================================================================
|
|
|
|
// class OTableConnectionData
|
|
|
|
//==================================================================
|
2006-06-19 21:28:01 -05:00
|
|
|
DBG_NAME(OTableConnectionData)
|
2001-02-05 02:35:57 -06:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
OTableConnectionData::OTableConnectionData()
|
|
|
|
{
|
|
|
|
DBG_CTOR(OTableConnectionData,NULL);
|
|
|
|
Init();
|
|
|
|
}
|
2007-11-01 09:33:16 -05:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
OTableConnectionData::OTableConnectionData(const TTableWindowData::value_type& _pReferencingTable
|
|
|
|
,const TTableWindowData::value_type& _pReferencedTable
|
|
|
|
,const String& rConnName )
|
|
|
|
:m_pReferencingTable(_pReferencingTable)
|
|
|
|
,m_pReferencedTable(_pReferencedTable)
|
|
|
|
,m_aConnName( rConnName )
|
2001-02-05 02:35:57 -06:00
|
|
|
{
|
|
|
|
DBG_CTOR(OTableConnectionData,NULL);
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
void OTableConnectionData::Init()
|
|
|
|
{
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// LineDataList mit Defaults initialisieren
|
|
|
|
DBG_ASSERT(m_vConnLineData.size() == 0, "OTableConnectionData::Init() : nur mit leere Linienliste aufzurufen !");
|
|
|
|
ResetConnLines(TRUE);
|
|
|
|
// das legt Defaults an
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
OTableConnectionData::OTableConnectionData( const OTableConnectionData& rConnData )
|
|
|
|
{
|
|
|
|
DBG_CTOR(OTableConnectionData,NULL);
|
|
|
|
*this = rConnData;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
void OTableConnectionData::CopyFrom(const OTableConnectionData& rSource)
|
|
|
|
{
|
|
|
|
*this = rSource;
|
|
|
|
// hier ziehe ich mich auf das (nicht-virtuelle) operator= zurueck, das nur meine Members kopiert
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
OTableConnectionData::~OTableConnectionData()
|
|
|
|
{
|
2004-08-02 10:14:22 -05:00
|
|
|
DBG_DTOR(OTableConnectionData,NULL);
|
2001-02-05 02:35:57 -06:00
|
|
|
// LineDataList loeschen
|
2006-07-26 01:49:02 -05:00
|
|
|
OConnectionLineDataVec().swap(m_vConnLineData);
|
|
|
|
//ResetConnLines(FALSE);
|
2001-02-05 02:35:57 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
OTableConnectionData& OTableConnectionData::operator=( const OTableConnectionData& rConnData )
|
|
|
|
{
|
|
|
|
if (&rConnData == this)
|
|
|
|
return *this;
|
|
|
|
|
2007-11-01 09:33:16 -05:00
|
|
|
m_pReferencingTable = rConnData.m_pReferencingTable;
|
|
|
|
m_pReferencedTable = rConnData.m_pReferencedTable;
|
2001-02-05 02:35:57 -06:00
|
|
|
m_aConnName = rConnData.GetConnName();
|
|
|
|
|
|
|
|
// clear line list
|
|
|
|
ResetConnLines(FALSE);
|
|
|
|
|
|
|
|
// und kopieren
|
2001-10-08 01:32:36 -05:00
|
|
|
OConnectionLineDataVec* pLineData = const_cast<OTableConnectionData*>(&rConnData)->GetConnLineDataList();
|
2001-02-05 02:35:57 -06:00
|
|
|
|
2001-10-08 01:32:36 -05:00
|
|
|
OConnectionLineDataVec::const_iterator aIter = pLineData->begin();
|
2009-07-03 07:24:35 -05:00
|
|
|
OConnectionLineDataVec::const_iterator aEnd = pLineData->end();
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 02:35:57 -06:00
|
|
|
m_vConnLineData.push_back(new OConnectionLineData(**aIter));
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
BOOL OTableConnectionData::SetConnLine( USHORT nIndex, const String& rSourceFieldName, const String& rDestFieldName )
|
|
|
|
{
|
|
|
|
if (USHORT(m_vConnLineData.size()) < nIndex)
|
|
|
|
return FALSE;
|
|
|
|
// == ist noch erlaubt, das entspricht einem Append
|
|
|
|
|
|
|
|
if (m_vConnLineData.size() == nIndex)
|
|
|
|
return AppendConnLine(rSourceFieldName, rDestFieldName);
|
|
|
|
|
2001-10-08 01:32:36 -05:00
|
|
|
OConnectionLineDataRef pConnLineData = m_vConnLineData[nIndex];
|
2001-02-05 02:35:57 -06:00
|
|
|
DBG_ASSERT(pConnLineData != NULL, "OTableConnectionData::SetConnLine : habe ungueltiges LineData-Objekt");
|
|
|
|
|
|
|
|
pConnLineData->SetSourceFieldName( rSourceFieldName );
|
|
|
|
pConnLineData->SetDestFieldName( rDestFieldName );
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2001-02-05 09:17:40 -06:00
|
|
|
BOOL OTableConnectionData::AppendConnLine( const ::rtl::OUString& rSourceFieldName, const ::rtl::OUString& rDestFieldName )
|
2001-02-05 02:35:57 -06:00
|
|
|
{
|
2001-10-08 01:32:36 -05:00
|
|
|
OConnectionLineDataVec::iterator aIter = m_vConnLineData.begin();
|
2009-07-03 07:24:35 -05:00
|
|
|
OConnectionLineDataVec::iterator aEnd = m_vConnLineData.end();
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 09:17:40 -06:00
|
|
|
{
|
|
|
|
if((*aIter)->GetDestFieldName() == rDestFieldName && (*aIter)->GetSourceFieldName() == rSourceFieldName)
|
|
|
|
break;
|
|
|
|
}
|
2009-07-03 07:24:35 -05:00
|
|
|
if(aIter == aEnd)
|
2001-02-05 09:17:40 -06:00
|
|
|
{
|
2001-10-08 01:32:36 -05:00
|
|
|
OConnectionLineDataRef pNew = new OConnectionLineData(rSourceFieldName, rDestFieldName);
|
|
|
|
if (!pNew.isValid())
|
2001-02-05 09:17:40 -06:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
m_vConnLineData.push_back(pNew);
|
|
|
|
}
|
2001-02-05 02:35:57 -06:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2007-11-01 09:33:16 -05:00
|
|
|
void OTableConnectionData::ResetConnLines( BOOL /*bUseDefaults*/ )
|
2001-02-05 02:35:57 -06:00
|
|
|
{
|
2001-10-08 01:32:36 -05:00
|
|
|
OConnectionLineDataVec().swap(m_vConnLineData);
|
2001-02-05 02:35:57 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2001-10-08 01:32:36 -05:00
|
|
|
OConnectionLineDataRef OTableConnectionData::CreateLineDataObj()
|
2001-02-05 02:35:57 -06:00
|
|
|
{
|
|
|
|
return new OConnectionLineData();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2001-10-08 01:32:36 -05:00
|
|
|
OConnectionLineDataRef OTableConnectionData::CreateLineDataObj( const OConnectionLineData& rConnLineData )
|
2001-02-05 02:35:57 -06:00
|
|
|
{
|
|
|
|
return new OConnectionLineData( rConnLineData );
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
OTableConnectionData* OTableConnectionData::NewInstance() const
|
|
|
|
{
|
|
|
|
return new OTableConnectionData();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2002-02-06 01:15:30 -06:00
|
|
|
void OTableConnectionData::normalizeLines()
|
|
|
|
{
|
|
|
|
// noch ein wenig Normalisierung auf den LineDatas : leere Lines vom Anfang an das Ende verschieben
|
|
|
|
sal_Int32 nCount = m_vConnLineData.size();
|
|
|
|
for(sal_Int32 i=0;i<nCount;)
|
|
|
|
{
|
2007-11-01 09:33:16 -05:00
|
|
|
if(!m_vConnLineData[i]->GetSourceFieldName().getLength() || !m_vConnLineData[i]->GetDestFieldName().getLength())
|
2002-02-06 01:15:30 -06:00
|
|
|
{
|
|
|
|
OConnectionLineDataRef pData = m_vConnLineData[i];
|
|
|
|
m_vConnLineData.erase(m_vConnLineData.begin()+i);
|
|
|
|
m_vConnLineData.push_back(pData);
|
|
|
|
--nCount;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-02-05 02:35:57 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|