Files
libreoffice/dbaccess/source/ui/control/RelationControl.cxx

711 lines
27 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-06-14 17:39:53 +01:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "RelationControl.hxx"
#include "RelationControl.hrc"
#include <svtools/editbrowsebox.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <tools/diagnose_ex.h>
#include "TableConnectionData.hxx"
#include "TableConnection.hxx"
#include "TableWindow.hxx"
#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
#include "UITools.hxx"
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include "RelControliFace.hxx"
2002-08-19 07:01:32 +00:00
#include "dbu_control.hrc"
#include "dbaccess_helpid.hrc"
2011-02-03 00:33:36 +01:00
#include <osl/diagnose.h>
2002-02-18 12:35:32 +00:00
#include <algorithm>
2002-02-06 13:31:05 +00:00
#define SOURCE_COLUMN 1
#define DEST_COLUMN 2
namespace dbaui
{
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::container;
using namespace svt;
typedef ::svt::EditBrowseBox ORelationControl_Base;
class ORelationControl : public ORelationControl_Base
{
friend class OTableListBoxControl;
::std::auto_ptr< ::svt::ListBoxControl> m_pListCell;
TTableConnectionData::value_type m_pConnData;
2002-02-06 13:31:05 +00:00
OTableListBoxControl* m_pBoxControl;
long m_nDataPos;
Reference< XPropertySet> m_xSourceDef;
Reference< XPropertySet> m_xDestDef;
void fillListBox(const Reference< XPropertySet>& _xDest,long nRow,sal_uInt16 nColumnId);
2002-02-06 13:31:05 +00:00
/** returns the column id for the editbrowsebox
@param _nColId
the column id SOURCE_COLUMN or DEST_COLUMN
@return the current column id eihter SOURCE_COLUMN or DEST_COLUMN depends on the connection data
*/
sal_uInt16 getColumnIdent( sal_uInt16 _nColId ) const;
public:
ORelationControl( OTableListBoxControl* pParent );
virtual ~ORelationControl();
2002-02-06 13:31:05 +00:00
/** searches for a connection between these two tables
@param _pSource
the left table
@param _pDest
the right window
*/
void setWindowTables(const OTableWindow* _pSource,const OTableWindow* _pDest);
2002-02-06 13:31:05 +00:00
/** allows to access the connection data from outside
@return rthe connection data
*/
inline TTableConnectionData::value_type getData() const { return m_pConnData; }
2002-11-08 08:26:00 +00:00
void lateInit();
protected:
virtual void Resize();
virtual long PreNotify(NotifyEvent& rNEvt );
virtual sal_Bool IsTabAllowed(sal_Bool bForward) const;
virtual void Init(const TTableConnectionData::value_type& _pConnData);
virtual void Init() { ORelationControl_Base::Init(); }
virtual void InitController( ::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol );
virtual ::svt::CellController* GetController( long nRow, sal_uInt16 nCol );
virtual void PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColId ) const;
virtual sal_Bool SeekRow( long nRow );
virtual sal_Bool SaveModified();
virtual String GetCellText( long nRow, sal_uInt16 nColId ) const;
virtual void CellModified();
DECL_LINK( AsynchDeactivate, void* );
private:
DECL_LINK( AsynchActivate, void* );
};
//========================================================================
// class ORelationControl
//========================================================================
2002-03-06 09:01:07 +00:00
DBG_NAME(ORelationControl)
//------------------------------------------------------------------------
ORelationControl::ORelationControl( OTableListBoxControl* pParent )
2010-11-29 23:29:33 +09:00
:EditBrowseBox( pParent, EBBF_SMART_TAB_TRAVEL | EBBF_NOROWPICTURE, WB_TABSTOP | WB_BORDER | BROWSER_AUTOSIZE_LASTCOL)
,m_pBoxControl(pParent)
,m_xSourceDef( NULL )
,m_xDestDef( NULL )
{
DBG_CTOR(ORelationControl,NULL);
}
//------------------------------------------------------------------------
ORelationControl::~ORelationControl()
{
DBG_DTOR(ORelationControl,NULL);
}
//------------------------------------------------------------------------
void ORelationControl::Init(const TTableConnectionData::value_type& _pConnData)
{
DBG_CHKTHIS(ORelationControl,NULL);
m_pConnData = _pConnData;
OSL_ENSURE(m_pConnData, "No data supplied!");
m_pConnData->normalizeLines();
2002-11-08 08:26:00 +00:00
}
//------------------------------------------------------------------------------
void ORelationControl::lateInit()
{
if ( !m_pConnData.get() )
return;
m_xSourceDef = m_pConnData->getReferencingTable()->getTable();
m_xDestDef = m_pConnData->getReferencedTable()->getTable();
2002-02-06 13:31:05 +00:00
if ( ColCount() == 0 )
{
InsertDataColumn( SOURCE_COLUMN, m_pConnData->getReferencingTable()->GetWinName(), 100);
InsertDataColumn( DEST_COLUMN, m_pConnData->getReferencedTable()->GetWinName(), 100);
2012-04-13 14:39:59 +02:00
// If the Defs do not yet exits, we need to set them with SetSource-/-DestDef
m_pListCell.reset( new ListBoxControl( &GetDataWindow() ) );
//////////////////////////////////////////////////////////////////////
2002-02-06 13:31:05 +00:00
// set browse mode
SetMode( BROWSER_COLUMNSELECTION |
BROWSER_HLINESFULL |
BROWSER_VLINESFULL |
BROWSER_HIDECURSOR |
2002-04-02 05:51:46 +00:00
BROWSER_HIDESELECT |
BROWSER_AUTO_HSCROLL |
BROWSER_AUTO_VSCROLL);
}
else
// not the first call
RowRemoved(0, GetRowCount());
RowInserted(0, m_pConnData->GetConnLineDataList()->size() + 1, sal_True); // add one extra row
}
//------------------------------------------------------------------------------
void ORelationControl::Resize()
{
DBG_CHKTHIS(ORelationControl,NULL);
EditBrowseBox::Resize();
2002-02-06 13:31:05 +00:00
long nOutputWidth = GetOutputSizePixel().Width();
SetColumnWidth(1, (nOutputWidth / 2));
SetColumnWidth(2, (nOutputWidth / 2));
}
//------------------------------------------------------------------------------
long ORelationControl::PreNotify(NotifyEvent& rNEvt)
{
DBG_CHKTHIS(ORelationControl,NULL);
2002-02-06 13:31:05 +00:00
if (rNEvt.GetType() == EVENT_LOSEFOCUS && !HasChildPathFocus() )
PostUserEvent(LINK(this, ORelationControl, AsynchDeactivate));
else if (rNEvt.GetType() == EVENT_GETFOCUS)
PostUserEvent(LINK(this, ORelationControl, AsynchActivate));
return EditBrowseBox::PreNotify(rNEvt);
}
//------------------------------------------------------------------------------
IMPL_LINK_NOARG(ORelationControl, AsynchActivate)
{
ActivateCell();
return 0L;
}
//------------------------------------------------------------------------------
IMPL_LINK_NOARG(ORelationControl, AsynchDeactivate)
{
DeactivateCell();
return 0L;
}
//------------------------------------------------------------------------------
sal_Bool ORelationControl::IsTabAllowed(sal_Bool bForward) const
{
DBG_CHKTHIS(ORelationControl,NULL);
long nRow = GetCurRow();
sal_uInt16 nCol = GetCurColumnId();
sal_Bool bRet = !(( ( bForward && (nCol == DEST_COLUMN) && (nRow == GetRowCount() - 1)))
2002-02-06 13:31:05 +00:00
|| (!bForward && (nCol == SOURCE_COLUMN) && (nRow == 0)));
2002-02-06 13:31:05 +00:00
return bRet && EditBrowseBox::IsTabAllowed(bForward);
}
//------------------------------------------------------------------------------
sal_Bool ORelationControl::SaveModified()
{
DBG_CHKTHIS(ORelationControl,NULL);
sal_Int32 nRow = GetCurRow();
if ( nRow != BROWSER_ENDOFSELECTION )
2002-11-21 14:28:38 +00:00
{
String sFieldName(m_pListCell->GetSelectEntry());
OConnectionLineDataVec* pLines = m_pConnData->GetConnLineDataList();
if ( pLines->size() <= static_cast<sal_uInt32>(nRow) )
{
pLines->push_back(new OConnectionLineData());
nRow = pLines->size() - 1;
}
OConnectionLineDataRef pConnLineData = (*pLines)[nRow];
2002-11-21 14:28:38 +00:00
switch( getColumnIdent( GetCurColumnId() ) )
{
case SOURCE_COLUMN:
pConnLineData->SetSourceFieldName( sFieldName );
break;
case DEST_COLUMN:
pConnLineData->SetDestFieldName( sFieldName );
break;
}
}
return sal_True;
}
//------------------------------------------------------------------------------
sal_uInt16 ORelationControl::getColumnIdent( sal_uInt16 _nColId ) const
{
sal_uInt16 nId = _nColId;
if ( m_pConnData->getReferencingTable() != m_pBoxControl->getReferencingTable() )
nId = ( _nColId == SOURCE_COLUMN) ? DEST_COLUMN : SOURCE_COLUMN;
return nId;
}
//------------------------------------------------------------------------------
String ORelationControl::GetCellText( long nRow, sal_uInt16 nColId ) const
{
DBG_CHKTHIS(ORelationControl,NULL);
String sText;
if ( m_pConnData->GetConnLineDataList()->size() > static_cast<size_t>(nRow) )
{
OConnectionLineDataRef pConnLineData = (*m_pConnData->GetConnLineDataList())[nRow];
switch( getColumnIdent( nColId ) )
{
case SOURCE_COLUMN:
sText = pConnLineData->GetSourceFieldName();
break;
case DEST_COLUMN:
sText = pConnLineData->GetDestFieldName();
break;
}
}
return sText;
}
//------------------------------------------------------------------------------
void ORelationControl::InitController( CellControllerRef& /*rController*/, long nRow, sal_uInt16 nColumnId )
{
DBG_CHKTHIS(ORelationControl,NULL);
rtl::OString sHelpId( HID_RELATIONDIALOG_LEFTFIELDCELL );
Reference< XPropertySet> xDef;
2002-11-08 08:26:00 +00:00
switch ( getColumnIdent(nColumnId) )
{
case SOURCE_COLUMN:
xDef = m_xSourceDef;
sHelpId = HID_RELATIONDIALOG_LEFTFIELDCELL;
break;
case DEST_COLUMN:
xDef = m_xDestDef;
sHelpId = HID_RELATIONDIALOG_RIGHTFIELDCELL;
break;
default:
// ?????????
break;
}
2002-11-08 08:26:00 +00:00
if ( xDef.is() )
{
fillListBox(xDef,nRow,nColumnId);
2002-11-08 08:26:00 +00:00
String sName = GetCellText( nRow, nColumnId );
m_pListCell->SelectEntry( sName );
if ( m_pListCell->GetSelectEntry() != sName )
{
m_pListCell->InsertEntry( sName );
m_pListCell->SelectEntry( sName );
}
m_pListCell->SetHelpId(sHelpId);
}
}
//------------------------------------------------------------------------------
CellController* ORelationControl::GetController( long /*nRow*/, sal_uInt16 /*nColumnId*/ )
{
DBG_CHKTHIS(ORelationControl,NULL);
return new ListBoxCellController( m_pListCell.get() );
}
//------------------------------------------------------------------------------
sal_Bool ORelationControl::SeekRow( long nRow )
{
DBG_CHKTHIS(ORelationControl,NULL);
m_nDataPos = nRow;
return sal_True;
}
//------------------------------------------------------------------------------
void ORelationControl::PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId ) const
{
DBG_CHKTHIS(ORelationControl,NULL);
String aText =const_cast< ORelationControl*>(this)->GetCellText( m_nDataPos, nColumnId );
Point aPos( rRect.TopLeft() );
Size aTextSize( GetDataWindow().GetTextHeight(),GetDataWindow().GetTextWidth( aText ));
if( aPos.X() < rRect.Right() || aPos.X() + aTextSize.Width() > rRect.Right() ||
aPos.Y() < rRect.Top() || aPos.Y() + aTextSize.Height() > rRect.Bottom() )
rDev.SetClipRegion( rRect );
rDev.DrawText( aPos, aText );
if( rDev.IsClipRegion() )
rDev.SetClipRegion();
}
// -----------------------------------------------------------------------------
void ORelationControl::fillListBox(const Reference< XPropertySet>& _xDest,long /*_nRow*/,sal_uInt16 /*nColumnId*/)
{
m_pListCell->Clear();
try
{
2002-11-08 08:26:00 +00:00
if ( _xDest.is() )
{
//sal_Int32 nRows = GetRowCount();
Reference<XColumnsSupplier> xSup(_xDest,UNO_QUERY);
Reference<XNameAccess> xColumns = xSup->getColumns();
Sequence< ::rtl::OUString> aNames = xColumns->getElementNames();
const ::rtl::OUString* pIter = aNames.getConstArray();
const ::rtl::OUString* pEnd = pIter + aNames.getLength();
for(;pIter != pEnd;++pIter)
{
m_pListCell->InsertEntry( *pIter );
}
m_pListCell->InsertEntry(String(), 0);
}
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
}
// -----------------------------------------------------------------------------
void ORelationControl::setWindowTables(const OTableWindow* _pSource,const OTableWindow* _pDest)
{
2012-04-13 14:39:59 +02:00
// If I edit here, hide
sal_Bool bWasEditing = IsEditing();
2002-11-08 08:26:00 +00:00
if ( bWasEditing )
DeactivateCell();
2002-11-08 08:26:00 +00:00
if ( _pSource && _pDest )
{
m_xSourceDef = _pSource->GetTable();
2002-11-21 14:28:38 +00:00
SetColumnTitle(1, _pSource->GetName());
m_xDestDef = _pDest->GetTable();
2002-11-21 14:28:38 +00:00
SetColumnTitle(2, _pDest->GetName());
const OJoinTableView* pView = _pSource->getTableView();
OTableConnection* pConn = pView->GetTabConn(_pSource,_pDest);
CWS-TOOLING: integrate CWS dba31d 2008-12-08 16:22:07 +0100 rt r265005 : Remove DOS lineends 2008-12-05 13:56:24 +0100 fs r264906 : #i10000# removed unreachable statement 2008-11-20 11:41:26 +0100 fs r264037 : merged in the fix for #i95865# (it was wrongly committed to CWS dba32a, should have been here) 2008-11-20 11:34:24 +0100 fs r264036 : line ends 2008-11-14 08:44:50 +0100 lla r263665 : #i10000# comparsion between int and uint fixed 2008-11-13 13:31:12 +0100 lla r263641 : #i10000# build problem fixed 2008-11-13 11:20:01 +0100 lla r263625 : #i96130# hard code name of extension 2008-11-12 11:13:41 +0100 fs r263582 : #i96096# when opening a SRB-report fails due to the missing SRB extension, log this as warning only, and proceed with the migration 2008-11-12 11:11:35 +0100 fs r263581 : #i96096# ContentType handling. Now all contents deliver proper results in XContent::getContentType 2008-11-12 11:10:11 +0100 fs r263580 : #i96096# new ctors taking UNO_QUERY_THROW 2008-11-11 10:10:13 +0100 lla r263546 : CWS-TOOLING: rebase CWS dba31d to trunk@263288 (milestone: DEV300:m35) 2008-11-06 15:55:39 +0100 oj r263393 : #i93452# get field from model fallbackis the name 2008-11-06 15:31:47 +0100 oj r263392 : #i93465# remeber location of floating windows 2008-11-06 13:36:24 +0100 oj r263381 : #i93450# check typemap for null 2008-11-06 13:28:49 +0100 oj r263379 : #i93020# empty column list boxes when new relation should be created 2008-11-06 12:33:53 +0100 oj r263377 : #i93012# set border to default : flat 2008-11-06 12:26:54 +0100 oj r263375 : #i74927# do some less calls for odbc 2008-11-06 09:34:01 +0100 oj r263362 : #i93383# grabFocus in suspend to get allmodified cells 2008-11-03 21:01:39 +0100 oj r263308 : #i86739# check if slash can be valid for tables 2008-11-03 14:40:21 +0100 oj r263287 : #i86739# check if slash can be valid for tables 2008-11-03 14:32:17 +0100 oj r263286 : #i95227# column width 2008-11-03 14:27:26 +0100 oj r263285 : link fwe 2008-11-03 14:24:54 +0100 oj r263284 : #i95235# changed to hold no ref only weak 2008-10-31 11:21:48 +0100 oj r262859 : #i93459# set images add menu entry 2008-10-31 09:06:37 +0100 oj r262851 : #i88629# correct fileopen filter for database odb files 2008-10-30 15:01:04 +0100 oj r262828 : #i95229# set filter at the composer 2008-10-29 15:57:41 +0100 oj r262817 : #i95235# changed to hold no ref only weak 2008-10-29 15:57:19 +0100 oj r262816 : #i95235# changed to hold no ref only weak 2008-10-29 15:57:03 +0100 oj r262815 : #i95235# changed to hold no ref only weak 2008-10-29 15:56:15 +0100 oj r262814 : #i95235# filtermanger changed to hold no ref only weak 2008-10-29 10:32:39 +0100 oj r262773 : #i93474# use correct table name 2008-10-28 13:49:33 +0100 lla r262744 : #i95524# make an Invalidate and refresh on Tables 2008-10-28 10:45:02 +0100 fs r262707 : line ends 2008-10-28 10:34:42 +0100 fs r262706 : #i95522# don't expect the component to live in a TopWindow 2008-10-28 08:30:40 +0100 lla r262696 : #i93176# set preview mode on view 2008-10-28 07:56:57 +0100 oj r262694 : merge cvs svn 2008-10-27 14:13:51 +0100 oj r262673 : #i94129# use dummy data 2008-10-27 12:38:45 +0100 fs r262669 : #i94125# rework ScrollColumns 2008-10-23 15:53:57 +0200 oj r262624 : #i94568# do not load the embeddedobj just copy the storage 2008-10-23 14:39:14 +0200 oj r262622 : #i94129# handle chart correctly 2008-10-22 10:51:19 +0200 lla r262582 : #i94115# problem with left walk chart shape fixed 2008-10-22 07:47:48 +0200 oj r262576 : #i94455# rename now do not use remove insert 2008-10-22 07:47:27 +0200 oj r262575 : #i94455# rename now do not use remove insert 2008-10-21 12:46:26 +0200 lla r262567 : #i93845# extra check if default schema doesn't exists, fix assertion
2008-12-09 07:25:38 +00:00
if ( pConn && !m_pConnData->GetConnLineDataList()->empty() )
{
m_pConnData->CopyFrom(*pConn->GetData());
m_pBoxControl->getContainer()->notifyConnectionChange();
}
else
{
// no connection found so we clear our data
OConnectionLineDataVec* pLines = m_pConnData->GetConnLineDataList();
::std::for_each(pLines->begin(),
pLines->end(),
OUnaryRefFunctor<OConnectionLineData>( ::std::mem_fun(&OConnectionLineData::Reset))
);
m_pConnData->setReferencingTable(_pSource->GetData());
m_pConnData->setReferencedTable(_pDest->GetData());
}
m_pConnData->normalizeLines();
}
2012-04-13 14:39:59 +02:00
// Repaint
Invalidate();
2002-11-08 08:26:00 +00:00
if ( bWasEditing )
{
GoToRow(0);
ActivateCell();
}
}
//------------------------------------------------------------------------
void ORelationControl::CellModified()
{
DBG_CHKTHIS(ORelationControl,NULL);
EditBrowseBox::CellModified();
SaveModified();
#if OSL_DEBUG_LEVEL > 0
OTableListBoxControl *parent = dynamic_cast<OTableListBoxControl*>(GetParent());
#else
OTableListBoxControl *parent = static_cast<OTableListBoxControl*>(GetParent());
#endif
assert(parent);
parent->NotifyCellChange();
}
//========================================================================
// class OTableListBoxControl
DBG_NAME(OTableListBoxControl)
//========================================================================
OTableListBoxControl::OTableListBoxControl( Window* _pParent
,const ResId& _rResId
,const OJoinTableView::OTableWindowMap* _pTableMap
,IRelationControlInterface* _pParentDialog)
: Window(_pParent,_rResId)
, m_aFL_InvolvedTables( this, ResId(FL_INVOLVED_TABLES,*_rResId.GetResMgr()))
, m_lmbLeftTable( this, ResId(LB_LEFT_TABLE,*_rResId.GetResMgr()))
, m_lmbRightTable( this, ResId(LB_RIGHT_TABLE,*_rResId.GetResMgr()))
, m_aFL_InvolvedFields( this, ResId(FL_INVOLVED_FIELDS,*_rResId.GetResMgr()))
, m_pTableMap(_pTableMap)
, m_pParentDialog(_pParentDialog)
{
m_pRC_Tables = new ORelationControl( this );
m_pRC_Tables->SetHelpId(HID_RELDLG_KEYFIELDS);
m_pRC_Tables->Init( );
m_pRC_Tables->SetZOrder(&m_lmbRightTable, WINDOW_ZORDER_BEHIND);
lateUIInit();
2002-02-06 13:31:05 +00:00
Link aLink(LINK(this, OTableListBoxControl, OnTableChanged));
m_lmbLeftTable.SetSelectHdl(aLink);
m_lmbRightTable.SetSelectHdl(aLink);
FreeResource();
DBG_CTOR(OTableListBoxControl,NULL);
}
// -----------------------------------------------------------------------------
OTableListBoxControl::~OTableListBoxControl()
{
2002-11-08 08:26:00 +00:00
ORelationControl* pTemp = m_pRC_Tables;
m_pRC_Tables = NULL;
delete pTemp;
DBG_DTOR(OTableListBoxControl,NULL);
}
// -----------------------------------------------------------------------------
void OTableListBoxControl::fillListBoxes()
{
2011-02-03 00:33:36 +01:00
OSL_ENSURE( !m_pTableMap->empty(), "OTableListBoxControl::fillListBoxes: no table window!");
OTableWindow* pInitialLeft = NULL;
OTableWindow* pInitialRight = NULL;
2012-04-13 14:39:59 +02:00
// Collect the names of all TabWins
OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->begin();
CWS-TOOLING: integrate CWS dbaperf2 2009-06-22 11:04:36 +0200 msc r273202 : #100000# fix to run this test 2009-06-22 09:41:04 +0200 msc r273200 : #100000# correct case 2009-06-22 09:02:42 +0200 msc r273199 : new SRB 2009-06-22 08:53:26 +0200 msc r273198 : #100000 2009-06-15 12:36:32 +0200 oj r272976 : test 2009-06-12 14:23:23 +0200 msc r272918 : #101587# unused feature was removed 2009-06-12 06:45:17 +0200 oj r272903 : use GUI instead of OS 2009-06-11 09:12:30 +0200 oj r272845 : remove unused dep 2009-06-11 09:11:09 +0200 oj r272844 : ColumnAliasInOrderBy not supported 2009-06-11 08:27:00 +0200 oj r272843 : CWS-TOOLING: rebase CWS dbaperf2 to trunk@272827 (milestone: DEV300:m50) 2009-06-10 15:30:17 +0200 msc r272822 : #100000 2009-06-10 15:27:40 +0200 msc r272820 : #102515# new function for the database type list 2009-06-10 15:26:09 +0200 msc r272818 : move file to dbaccess/tools/dbcreatetools.inc 2009-06-10 15:20:10 +0200 msc r272816 : #102515# new function for the database type list 2009-06-10 12:34:46 +0200 oj r272803 : #i101587# check extension 2009-06-10 11:53:45 +0200 oj r272800 : remove unused code 2009-06-09 09:57:25 +0200 oj r272752 : #i101587# EscapeDateTime moved into features section 2009-06-09 09:56:26 +0200 oj r272751 : enable finish 2009-06-08 11:50:37 +0200 oj r272726 : #i102588# move convert tzo saveDataSource 2009-06-05 11:54:20 +0200 jsk r272676 : #i102515# - NEW: Functions to retrieve Database names from API 2009-06-05 10:52:22 +0200 jsk r272671 : NEW: Functions to retrieve Database names from API 2009-06-05 09:36:54 +0200 oj r272666 : handle win and unx differently 2009-06-05 09:36:28 +0200 oj r272665 : handle win and unx differently 2009-06-04 13:41:56 +0200 oj r272625 : #i101268# make use of stringbuffer instead of oustring 2009-06-04 10:18:14 +0200 oj r272612 : add SAL_DLLPUBLIC_EXPORT 2009-05-28 10:56:33 +0200 oj r272381 : #i101587# create langpacks 2009-05-28 10:41:59 +0200 oj r272380 : #i101587# create langpacks 2009-05-28 10:29:30 +0200 oj r272379 : #i101587# create langpacks 2009-05-07 10:11:46 +0200 oj r271635 : fix compile warnings 2009-05-07 07:01:31 +0200 oj r271619 : change type from int32 to PathID 2009-05-07 06:53:19 +0200 oj r271618 : add all 2009-05-06 14:57:02 +0200 oj r271595 : add missing lib 2009-05-06 14:56:54 +0200 oj r271594 : no used anymore 2009-05-06 14:56:08 +0200 oj r271593 : no used anymore 2009-05-06 14:54:25 +0200 oj r271592 : no used anymore 2009-05-06 14:45:59 +0200 oj r271591 : add missing lib 2009-05-06 14:41:54 +0200 oj r271590 : change wnt 2009-05-06 14:22:21 +0200 oj r271589 : #i101587# use config for the drivers 2009-05-06 14:21:39 +0200 oj r271588 : #i101587# add new set for metadata and config data for driver 2009-05-06 14:19:36 +0200 oj r271587 : #i101587# handle metadata and props of driver 2009-05-06 10:11:11 +0200 oj r271570 : #i101587# correct wrong use of reference 2009-05-06 09:24:33 +0200 oj r271567 : #i101587# add new set for metadata 2009-05-06 08:52:06 +0200 oj r271563 : #i101587# add driver configuration 2009-05-06 08:51:04 +0200 oj r271562 : #i101587# add driver configuration 2009-05-04 10:24:41 +0200 oj r271442 : CWS-TOOLING: rebase CWS dbaperf2 to trunk@271427 (milestone: DEV300:m47) 2009-04-28 07:06:22 +0200 oj r271303 : compile error 2009-04-27 14:12:48 +0200 oj r271270 : #i101268# make use of stringbuffer instead of oustring 2009-04-27 14:12:27 +0200 oj r271269 : #i101268# make use of stringbuffer instead of oustring 2009-04-27 09:30:10 +0200 oj r271255 : use string buffer when possible 2009-04-24 11:56:01 +0200 oj r271207 : #i101268# remove end() call from loop 2009-04-23 14:24:03 +0200 oj r271171 : add dep 2009-04-23 13:25:25 +0200 oj r271164 : #i101268# add config entries for database drivers 2009-04-23 13:07:13 +0200 oj r271161 : #i101268# add config entries for database drivers 2009-04-23 13:06:33 +0200 oj r271160 : #i101268# add parent url pattern entry for driver node 2009-04-23 13:05:39 +0200 oj r271159 : #i101268# add config entry for driver node 2009-04-23 13:04:09 +0200 oj r271157 : #i101268# add config entry for driver node 2009-04-23 06:41:32 +0200 oj r271142 : #i101268# add new configuration file Drivers 2009-04-22 13:49:19 +0200 oj r271103 : convert EOL 2009-04-22 13:29:17 +0200 oj r271101 : #i101268# use of driver configuration entries for features and properties 2009-04-22 13:28:08 +0200 oj r271100 : #i101268# use of driver configuration entries for features and properties 2009-04-22 13:15:26 +0200 oj r271098 : #i101268# add new configuration file Drivers 2009-04-22 13:14:43 +0200 oj r271097 : #i101268# use of driver configuration entries for features and properties
2009-07-03 12:24:35 +00:00
OJoinTableView::OTableWindowMap::const_iterator aEnd = m_pTableMap->end();
for(;aIter != aEnd;++aIter)
{
m_lmbLeftTable.InsertEntry(aIter->first);
m_lmbRightTable.InsertEntry(aIter->first);
if (!pInitialLeft)
2002-11-07 13:06:21 +00:00
{
pInitialLeft = aIter->second;
2002-11-07 13:06:21 +00:00
m_strCurrentLeft = aIter->first;
}
else if (!pInitialRight)
2002-11-07 13:06:21 +00:00
{
pInitialRight = aIter->second;
2002-11-07 13:06:21 +00:00
m_strCurrentRight = aIter->first;
}
2010-11-29 23:29:33 +09:00
}
if ( !pInitialRight )
{
pInitialRight = pInitialLeft;
m_strCurrentRight = m_strCurrentLeft;
}
2012-04-13 14:39:59 +02:00
// The corresponding Defs for my Controls
m_pRC_Tables->setWindowTables(pInitialLeft,pInitialRight);
2012-04-13 14:39:59 +02:00
// The table selected in a ComboBox must not be available in the other
2002-02-06 13:31:05 +00:00
2002-11-08 08:26:00 +00:00
if ( m_pTableMap->size() > 2 )
{
m_lmbLeftTable.RemoveEntry(m_strCurrentRight);
m_lmbRightTable.RemoveEntry(m_strCurrentLeft);
}
2012-04-13 14:39:59 +02:00
// Select the first one on the left side and on the right side,
// select the second one
2002-11-08 08:26:00 +00:00
m_lmbLeftTable.SelectEntry(m_strCurrentLeft);
m_lmbRightTable.SelectEntry(m_strCurrentRight);
m_lmbLeftTable.GrabFocus();
}
// -----------------------------------------------------------------------------
IMPL_LINK( OTableListBoxControl, OnTableChanged, ListBox*, pListBox )
{
String strSelected(pListBox->GetSelectEntry());
OTableWindow* pLeft = NULL;
OTableWindow* pRight = NULL;
2012-04-13 14:39:59 +02:00
// Special treatment: If there are only two tables, we need to switch the other one too when changing in a LB
2002-11-08 08:26:00 +00:00
if ( m_pTableMap->size() == 2 )
{
ListBox* pOther;
2002-11-08 08:26:00 +00:00
if ( pListBox == &m_lmbLeftTable )
pOther = &m_lmbRightTable;
else
pOther = &m_lmbLeftTable;
pOther->SelectEntryPos(1 - pOther->GetSelectEntryPos());
OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->begin();
OTableWindow* pFirst = aIter->second;
++aIter;
OTableWindow* pSecond = aIter->second;
2002-11-08 08:26:00 +00:00
if ( m_lmbLeftTable.GetSelectEntry() == String(pFirst->GetName()) )
{
pLeft = pFirst;
pRight = pSecond;
}
else
{
pLeft = pSecond;
pRight = pFirst;
}
}
else
{
2012-04-13 14:39:59 +02:00
// First we need the TableDef to the Table and with it the TabWin
OJoinTableView::OTableWindowMap::const_iterator aFind = m_pTableMap->find(strSelected);
OTableWindow* pLoop = NULL;
if( aFind != m_pTableMap->end() )
pLoop = aFind->second;
2012-04-13 14:39:59 +02:00
OSL_ENSURE(pLoop != NULL, "ORelationDialog::OnTableChanged: invalid ListBox entry!");
// We need to find strSelect, because we filled the ListBoxes with the table names with which we compare now
if (pListBox == &m_lmbLeftTable)
{
2012-04-13 14:39:59 +02:00
// Insert the previously selected Entry on the left side on the right side
m_lmbRightTable.InsertEntry(m_strCurrentLeft);
2012-04-13 14:39:59 +02:00
// Remove the currently selected Entry
m_lmbRightTable.RemoveEntry(strSelected);
m_strCurrentLeft = strSelected;
pLeft = pLoop;
OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->find(m_lmbRightTable.GetSelectEntry());
OSL_ENSURE( aIter != m_pTableMap->end(), "Invalid name");
if ( aIter != m_pTableMap->end() )
pRight = aIter->second;
m_lmbLeftTable.GrabFocus();
}
else
{
2012-04-13 14:39:59 +02:00
// Insert the previously selected Entry on the right side on the left side
m_lmbLeftTable.InsertEntry(m_strCurrentRight);
2012-04-13 14:39:59 +02:00
// Remove the currently selected Entry
m_lmbLeftTable.RemoveEntry(strSelected);
m_strCurrentRight = strSelected;
pRight = pLoop;
OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->find(m_lmbLeftTable.GetSelectEntry());
OSL_ENSURE( aIter != m_pTableMap->end(), "Invalid name");
if ( aIter != m_pTableMap->end() )
pLeft = aIter->second;
}
}
pListBox->GrabFocus();
m_pRC_Tables->setWindowTables(pLeft,pRight);
NotifyCellChange();
return 0;
}
// -----------------------------------------------------------------------------
void OTableListBoxControl::NotifyCellChange()
{
2012-04-13 14:39:59 +02:00
// Enable/disable the OK button, depending on having a valid situation
TTableConnectionData::value_type pConnData = m_pRC_Tables->getData();
const OConnectionLineDataVec* pLines = pConnData->GetConnLineDataList();
m_pParentDialog->setValid(!pLines->empty());
if ( pLines->size() >= static_cast<sal_uInt32>(m_pRC_Tables->GetRowCount()) )
{
m_pRC_Tables->DeactivateCell();
m_pRC_Tables->RowInserted(m_pRC_Tables->GetRowCount(), pLines->size() - static_cast<sal_uInt32>(m_pRC_Tables->GetRowCount()) + 1, sal_True);
m_pRC_Tables->ActivateCell();
}
}
// -----------------------------------------------------------------------------
void fillEntryAndDisable(ListBox& _rListBox,const String& _sEntry)
{
_rListBox.InsertEntry(_sEntry);
_rListBox.SelectEntryPos(0);
_rListBox.Disable();
}
// -----------------------------------------------------------------------------
void OTableListBoxControl::fillAndDisable(const TTableConnectionData::value_type& _pConnectionData)
{
fillEntryAndDisable(m_lmbLeftTable,_pConnectionData->getReferencingTable()->GetWinName());
fillEntryAndDisable(m_lmbRightTable,_pConnectionData->getReferencedTable()->GetWinName());
}
// -----------------------------------------------------------------------------
void OTableListBoxControl::Init(const TTableConnectionData::value_type& _pConnData)
{
m_pRC_Tables->Init(_pConnData);
}
// -----------------------------------------------------------------------------
void OTableListBoxControl::lateUIInit(Window* _pTableSeparator)
{
const sal_Int32 nDiff = LogicToPixel( Point(0,6), MAP_APPFONT ).Y();
Point aDlgPoint = LogicToPixel( Point(12,43), MAP_APPFONT );
if ( _pTableSeparator )
{
_pTableSeparator->SetZOrder(&m_lmbRightTable, WINDOW_ZORDER_BEHIND);
m_pRC_Tables->SetZOrder(_pTableSeparator, WINDOW_ZORDER_BEHIND);
_pTableSeparator->SetPosPixel(Point(0,m_aFL_InvolvedFields.GetPosPixel().Y()));
const Size aSize = _pTableSeparator->GetSizePixel();
aDlgPoint.Y() = _pTableSeparator->GetPosPixel().Y() + aSize.Height();
m_aFL_InvolvedFields.SetPosPixel(Point(m_aFL_InvolvedFields.GetPosPixel().X(),aDlgPoint.Y()));
aDlgPoint.Y() += nDiff + m_aFL_InvolvedFields.GetSizePixel().Height();
}
//////////////////////////////////////////////////////////////////////
// positing BrowseBox control
const Size aCurrentSize = GetSizePixel();
Size aDlgSize = LogicToPixel( Size(24,0), MAP_APPFONT );
aDlgSize.Width() = aCurrentSize.Width() - aDlgSize.Width();
aDlgSize.Height() = aCurrentSize.Height() - aDlgPoint.Y() - nDiff;
m_pRC_Tables->SetPosSizePixel( aDlgPoint, aDlgSize );
m_pRC_Tables->Show();
lateInit();
}
// -----------------------------------------------------------------------------
2002-11-08 08:26:00 +00:00
void OTableListBoxControl::lateInit()
{
m_pRC_Tables->lateInit();
}
// -----------------------------------------------------------------------------
sal_Bool OTableListBoxControl::SaveModified()
{
sal_Bool bRet = m_pRC_Tables->SaveModified();
m_pRC_Tables->getData()->normalizeLines();
return bRet;
}
// -----------------------------------------------------------------------------
TTableWindowData::value_type OTableListBoxControl::getReferencingTable() const
{
return m_pRC_Tables->getData()->getReferencingTable();
}
// -----------------------------------------------------------------------------
void OTableListBoxControl::enableRelation(bool _bEnable)
{
if ( !_bEnable )
PostUserEvent(LINK(m_pRC_Tables, ORelationControl, AsynchDeactivate));
m_pRC_Tables->Enable(_bEnable);
}
// -----------------------------------------------------------------------------
}
// -----------------------------------------------------------------------------
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */