2001-02-05 08:26:47 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 15:30:11 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-02-05 08:26:47 +00:00
|
|
|
*
|
2005-09-08 15:30:11 +00:00
|
|
|
* $RCSfile: TableWindow.cxx,v $
|
2001-02-05 08:26:47 +00:00
|
|
|
*
|
2006-06-20 02:28:47 +00:00
|
|
|
* $Revision: 1.31 $
|
2001-02-05 08:26:47 +00:00
|
|
|
*
|
2006-06-20 02:28:47 +00:00
|
|
|
* last change: $Author: hr $ $Date: 2006-06-20 03:28:47 $
|
2001-02-05 08:26:47 +00:00
|
|
|
*
|
2005-09-08 15:30:11 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2001-02-05 08:26:47 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-08 15:30:11 +00: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-05 08:26:47 +00:00
|
|
|
*
|
2005-09-08 15:30:11 +00: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-05 08:26:47 +00:00
|
|
|
*
|
2005-09-08 15:30:11 +00: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-05 08:26:47 +00:00
|
|
|
*
|
2005-09-08 15:30:11 +00: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-05 08:26:47 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
#ifndef DBAUI_TABLEWINDOW_HXX
|
|
|
|
#include "TableWindow.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_TABLEWINDOWLISTBOX_HXX
|
|
|
|
#include "TableWindowListBox.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_QUERYTABLEVIEW_HXX
|
|
|
|
#include "QueryTableView.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_QUERYDESIGNVIEW_HXX
|
|
|
|
#include "QueryDesignView.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_TABLEWINDOWDATA_HXX
|
|
|
|
#include "TableWindowData.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_SVAPP_HXX
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_WALL_HXX
|
|
|
|
#include <vcl/wall.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_
|
|
|
|
#include <com/sun/star/sdbcx/KeyType.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
|
2003-04-24 16:22:49 +00:00
|
|
|
#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_
|
|
|
|
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
|
2002-11-26 11:44:28 +00:00
|
|
|
#endif
|
2003-04-24 16:22:49 +00:00
|
|
|
#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
|
|
|
|
#include <com/sun/star/accessibility/AccessibleRole.hpp>
|
2002-11-26 11:44:28 +00:00
|
|
|
#endif
|
2001-02-05 08:26:47 +00:00
|
|
|
#ifndef DBAUI_QUERYCONTROLLER_HXX
|
|
|
|
#include "querycontroller.hxx"
|
|
|
|
#endif
|
2002-08-19 07:01:32 +00:00
|
|
|
#ifndef _DBU_QRY_HRC_
|
|
|
|
#include "dbu_qry.hrc"
|
2001-02-05 08:26:47 +00:00
|
|
|
#endif
|
|
|
|
#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
|
|
|
|
#include "dbustrings.hrc"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_QUERY_HRC
|
|
|
|
#include "Query.hrc"
|
|
|
|
#endif
|
2001-03-15 07:29:16 +00:00
|
|
|
#ifndef _COMPHELPER_EXTRACT_HXX_
|
|
|
|
#include <comphelper/extract.hxx>
|
2001-02-14 13:54:12 +00:00
|
|
|
#endif
|
2001-02-23 14:04:37 +00:00
|
|
|
#ifndef DBAUI_TOOLS_HXX
|
|
|
|
#include "UITools.hxx"
|
|
|
|
#endif
|
2002-02-06 07:15:30 +00:00
|
|
|
#ifndef DBACCESS_TABLEWINDOWACCESS_HXX
|
|
|
|
#include "TableWindowAccess.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBACCESS_UI_BROWSER_ID_HXX
|
|
|
|
#include "browserids.hxx"
|
|
|
|
#endif
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
using namespace dbaui;
|
2001-06-28 13:22:47 +00:00
|
|
|
using namespace ::utl;
|
2001-02-05 08:26:47 +00:00
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::container;
|
2001-06-28 13:22:47 +00:00
|
|
|
using namespace ::com::sun::star::lang;
|
2003-04-24 16:22:49 +00:00
|
|
|
using namespace ::com::sun::star::accessibility;
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2002-02-08 08:10:00 +00:00
|
|
|
#define TABWIN_SIZING_AREA 4
|
|
|
|
#define LISTBOX_SCROLLING_AREA 6
|
|
|
|
#define SCROLLING_TIMESPAN 500
|
|
|
|
|
|
|
|
#define TABWIN_WIDTH_MIN 90
|
|
|
|
#define TABWIN_HEIGHT_MIN 80
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
TYPEINIT0(OTableWindow);
|
|
|
|
//========================================================================
|
|
|
|
// class OTableWindow
|
|
|
|
//========================================================================
|
|
|
|
DBG_NAME(OTableWindow);
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
OTableWindow::OTableWindow( Window* pParent, OTableWindowData* pTabWinData )
|
|
|
|
:Window( pParent, WB_3DLOOK|WB_MOVEABLE )
|
|
|
|
,m_aTitle( this )
|
|
|
|
,m_pListBox(NULL)
|
2006-06-20 02:28:47 +00:00
|
|
|
,m_pAccessible(NULL)
|
|
|
|
,m_pData( pTabWinData )
|
2002-02-06 07:15:30 +00:00
|
|
|
,m_nMoveCount(0)
|
|
|
|
,m_nMoveIncrement(1)
|
2006-06-20 02:28:47 +00:00
|
|
|
,m_nSizingFlags( SIZING_NONE )
|
|
|
|
,m_bActive( FALSE )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
DBG_CTOR(OTableWindow,NULL);
|
|
|
|
|
|
|
|
// Position und Groesse bestimmen
|
|
|
|
if( GetData()->HasPosition() )
|
|
|
|
SetPosPixel( GetData()->GetPosition() );
|
|
|
|
|
|
|
|
if( GetData()->HasSize() )
|
|
|
|
SetSizePixel( GetData()->GetSize() );
|
|
|
|
|
|
|
|
// Hintergrund setzen
|
2002-02-06 07:15:30 +00:00
|
|
|
const StyleSettings& aSystemStyle = Application::GetSettings().GetStyleSettings();
|
|
|
|
SetBackground(Wallpaper(aSystemStyle.GetFaceColor()));
|
2001-02-05 08:26:47 +00:00
|
|
|
// und Textfarbe (obwohl ich eigentlich keinen Text habe, aber wer weiss, was
|
|
|
|
// abgeleitete Klassen machen)
|
|
|
|
SetTextColor(aSystemStyle.GetButtonTextColor());
|
|
|
|
|
|
|
|
EnableClipSiblings();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
OTableWindow::~OTableWindow()
|
|
|
|
{
|
2004-08-02 15:14:58 +00:00
|
|
|
DBG_DTOR(OTableWindow,NULL);
|
2001-06-28 13:22:47 +00:00
|
|
|
Reference<XComponent> xComponent(m_xTable,UNO_QUERY);
|
|
|
|
if(xComponent.is())
|
|
|
|
stopComponentListening(xComponent);
|
2001-02-05 08:26:47 +00:00
|
|
|
if (m_pListBox)
|
|
|
|
{
|
2002-06-27 07:23:50 +00:00
|
|
|
OSL_ENSURE(m_pListBox->GetEntryCount()==0,"Forgot to call EmptyListbox()!");
|
2002-05-10 07:23:32 +00:00
|
|
|
::std::auto_ptr<Window> aTemp(m_pListBox);
|
|
|
|
m_pListBox = NULL;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2002-02-08 08:10:00 +00:00
|
|
|
m_pAccessible = NULL;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-02-28 09:18:26 +00:00
|
|
|
const OJoinTableView* OTableWindow::getTableView() const
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2001-02-28 09:18:26 +00:00
|
|
|
OSL_ENSURE(static_cast<OJoinTableView*>(GetParent()),"No OJoinTableView!");
|
|
|
|
return static_cast<OJoinTableView*>(GetParent());
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-02-28 09:18:26 +00:00
|
|
|
OJoinTableView* OTableWindow::getTableView()
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2001-02-28 09:18:26 +00:00
|
|
|
OSL_ENSURE(static_cast<OJoinTableView*>(GetParent()),"No OJoinTableView!");
|
|
|
|
return static_cast<OJoinTableView*>(GetParent());
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-02-28 09:18:26 +00:00
|
|
|
OJoinDesignView* OTableWindow::getDesignView()
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2001-02-28 09:18:26 +00:00
|
|
|
OSL_ENSURE(static_cast<OJoinDesignView*>(GetParent()->GetParent()->GetParent()),"No OJoinDesignView!");
|
|
|
|
return static_cast<OJoinDesignView*>(GetParent()->GetParent()->GetParent());
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableWindow::SetPosPixel( const Point& rNewPos )
|
|
|
|
{
|
|
|
|
Point aNewPosData = rNewPos + getTableView()->GetScrollOffset();
|
|
|
|
GetData()->SetPosition( aNewPosData );
|
|
|
|
Window::SetPosPixel( rNewPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableWindow::SetSizePixel( const Size& rNewSize )
|
|
|
|
{
|
|
|
|
Size aOutSize(rNewSize);
|
|
|
|
if( aOutSize.Width() < TABWIN_WIDTH_MIN )
|
|
|
|
aOutSize.Width() = TABWIN_WIDTH_MIN;
|
|
|
|
if( aOutSize.Height() < TABWIN_HEIGHT_MIN )
|
|
|
|
aOutSize.Height() = TABWIN_HEIGHT_MIN;
|
|
|
|
|
|
|
|
GetData()->SetSize( aOutSize );
|
|
|
|
Window::SetSizePixel( aOutSize );
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableWindow::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
|
|
|
|
{
|
|
|
|
SetPosPixel( rNewPos );
|
|
|
|
SetSizePixel( rNewSize );
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
OTableWindowListBox* OTableWindow::CreateListBox()
|
|
|
|
{
|
2006-06-20 02:28:47 +00:00
|
|
|
return new OTableWindowListBox(this);
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
BOOL OTableWindow::FillListBox()
|
|
|
|
{
|
|
|
|
// mark all primary keys with special image
|
2002-05-08 08:09:31 +00:00
|
|
|
ModuleRes TmpRes(isHiContrast(m_pListBox) ? IMG_JOINS_H : IMG_JOINS);
|
|
|
|
ImageList aImageList(TmpRes);
|
2001-02-05 08:26:47 +00:00
|
|
|
Image aPrimKeyImage = aImageList.GetImage(IMG_PRIMARY_KEY);
|
|
|
|
|
|
|
|
if (GetData()->IsShowAll())
|
2002-06-27 07:23:50 +00:00
|
|
|
{
|
|
|
|
SvLBoxEntry* pEntry = m_pListBox->InsertEntry( ::rtl::OUString::createFromAscii("*") );
|
|
|
|
pEntry->SetUserData( createUserData(NULL,false) );
|
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2001-06-28 13:22:47 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-02-05 08:26:47 +00:00
|
|
|
Reference<XNameAccess> xPKeyColumns;
|
2003-07-21 11:28:12 +00:00
|
|
|
try
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2003-07-21 11:28:12 +00:00
|
|
|
// first we need the keys from the table
|
|
|
|
Reference<XKeysSupplier> xKeys(m_xTable,UNO_QUERY);
|
|
|
|
|
|
|
|
if(xKeys.is())
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2003-07-21 11:28:12 +00:00
|
|
|
Reference< XIndexAccess> xKeyIndex = xKeys->getKeys();
|
|
|
|
Reference<XColumnsSupplier> xColumnsSupplier;
|
|
|
|
// search the one and only primary key
|
|
|
|
if ( xKeyIndex.is() )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2003-07-21 11:28:12 +00:00
|
|
|
for(sal_Int32 i=0;i< xKeyIndex->getCount();++i)
|
2002-11-26 11:44:28 +00:00
|
|
|
{
|
2003-07-21 11:28:12 +00:00
|
|
|
Reference<XPropertySet> xProp;
|
|
|
|
xKeyIndex->getByIndex(i) >>= xProp;
|
|
|
|
if ( xProp.is() )
|
|
|
|
{
|
|
|
|
sal_Int32 nKeyType = 0;
|
|
|
|
xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
|
|
|
|
if(KeyType::PRIMARY == nKeyType)
|
|
|
|
{
|
2004-08-02 15:14:58 +00:00
|
|
|
xColumnsSupplier.set(xProp,UNO_QUERY);
|
2003-07-21 11:28:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-11-26 11:44:28 +00:00
|
|
|
}
|
2003-07-21 11:28:12 +00:00
|
|
|
if ( xColumnsSupplier.is() )
|
|
|
|
xPKeyColumns = xColumnsSupplier->getColumns();
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-07-21 11:28:12 +00:00
|
|
|
catch(Exception&)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2003-07-21 11:28:12 +00:00
|
|
|
OSL_ENSURE(0,"Exception occured!");
|
|
|
|
}
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if(m_xColumns.is())
|
2001-06-28 13:22:47 +00:00
|
|
|
{
|
2003-07-21 11:28:12 +00:00
|
|
|
Sequence< ::rtl::OUString> aColumns = m_xColumns->getElementNames();
|
|
|
|
const ::rtl::OUString* pBegin = aColumns.getConstArray();
|
|
|
|
const ::rtl::OUString* pEnd = pBegin + aColumns.getLength();
|
2002-06-27 07:23:50 +00:00
|
|
|
|
2003-07-21 11:28:12 +00:00
|
|
|
SvLBoxEntry* pEntry = NULL;
|
|
|
|
for (; pBegin != pEnd; ++pBegin)
|
|
|
|
{
|
|
|
|
bool bPrimaryKeyColumn;
|
|
|
|
// is this column in the primary key
|
|
|
|
if ( bPrimaryKeyColumn = (xPKeyColumns.is() && xPKeyColumns->hasByName(*pBegin)) )
|
|
|
|
pEntry = m_pListBox->InsertEntry(*pBegin, aPrimKeyImage, aPrimKeyImage);
|
|
|
|
else
|
|
|
|
pEntry = m_pListBox->InsertEntry(*pBegin);
|
|
|
|
|
|
|
|
Reference<XPropertySet> xColumn;
|
|
|
|
m_xColumns->getByName(*pBegin) >>= xColumn;
|
|
|
|
if ( xColumn.is() )
|
|
|
|
pEntry->SetUserData( createUserData(xColumn,bPrimaryKeyColumn) );
|
|
|
|
}
|
2001-06-28 13:22:47 +00:00
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2003-07-21 11:28:12 +00:00
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0,"Exception occured!");
|
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2002-06-27 07:23:50 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2006-06-20 02:28:47 +00:00
|
|
|
void* OTableWindow::createUserData(const Reference< XPropertySet>& /*_xColumn*/,bool /*_bPrimaryKey*/)
|
2002-06-27 07:23:50 +00:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OTableWindow::deleteUserData(void*& _pUserData)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(!_pUserData,"INVALID call. Need to delete the userclass!");
|
|
|
|
_pUserData = NULL;
|
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2002-06-27 07:23:50 +00:00
|
|
|
void OTableWindow::clearListBox()
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
// da ich defaultmaessig keine USerData an die Items haenge, kann ich hier einfach loeschen
|
2002-02-06 07:15:30 +00:00
|
|
|
if ( m_pListBox )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2002-02-06 07:15:30 +00:00
|
|
|
SvLBoxEntry* pEntry = m_pListBox->First();
|
|
|
|
|
|
|
|
while(pEntry)
|
|
|
|
{
|
2002-06-27 07:23:50 +00:00
|
|
|
void* pUserData = pEntry->GetUserData();
|
|
|
|
deleteUserData(pUserData);
|
2002-02-06 07:15:30 +00:00
|
|
|
SvLBoxEntry* pNextEntry = m_pListBox->Next(pEntry);
|
|
|
|
m_pListBox->GetModel()->Remove(pEntry);
|
|
|
|
pEntry = pNextEntry;
|
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
BOOL OTableWindow::Init()
|
|
|
|
{
|
|
|
|
// get the from the connection
|
2001-02-28 09:18:26 +00:00
|
|
|
OJoinDesignView* pParent = getDesignView();
|
2001-02-05 08:26:47 +00:00
|
|
|
Reference<XConnection > xConnection = pParent->getController()->getConnection();
|
|
|
|
Reference<XTablesSupplier> xSups(xConnection,UNO_QUERY);
|
|
|
|
OSL_ENSURE(xSups.is(),"The connection isn't a tablessupplier!");
|
2001-06-28 13:22:47 +00:00
|
|
|
sal_Bool bInit = sal_False;
|
|
|
|
if(xSups.is())
|
2001-02-23 14:04:37 +00:00
|
|
|
{
|
2001-06-28 13:22:47 +00:00
|
|
|
Reference<XNameAccess> xTables = xSups->getTables();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2001-06-28 13:22:47 +00:00
|
|
|
::rtl::OUString aName = GetComposedName();
|
|
|
|
if(xTables->hasByName(aName))
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
try
|
|
|
|
{
|
|
|
|
::cppu::extractInterface(m_xTable,xTables->getByName(aName));
|
|
|
|
if(m_xTable.is())
|
|
|
|
{
|
|
|
|
Reference<XComponent> xComponent(m_xTable,UNO_QUERY);
|
|
|
|
if(xComponent.is())
|
|
|
|
startComponentListening(xComponent);
|
|
|
|
Reference<XColumnsSupplier> xColumnsSups(m_xTable,UNO_QUERY);
|
|
|
|
OSL_ENSURE(xColumnsSups.is(),"OTableWindow::Init Table isn't a XColumnsSupplier!");
|
|
|
|
if(xColumnsSups.is())
|
|
|
|
{
|
|
|
|
m_xColumns = xColumnsSups->getColumns();
|
|
|
|
bInit = sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(SQLException& e)
|
|
|
|
{
|
|
|
|
::dbaui::showError(::dbtools::SQLExceptionInfo(e),pParent,pParent->getController()->getORB());
|
|
|
|
bInit = FALSE;
|
|
|
|
}
|
2001-08-09 12:30:50 +00:00
|
|
|
catch(WrappedTargetException& e)
|
|
|
|
{
|
|
|
|
SQLException aSql;
|
|
|
|
if(e.TargetException >>= aSql)
|
|
|
|
::dbaui::showError(::dbtools::SQLExceptionInfo(aSql),pParent,pParent->getController()->getORB());
|
|
|
|
bInit = FALSE;
|
|
|
|
}
|
2001-06-28 13:22:47 +00:00
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
bInit = FALSE;
|
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2001-06-28 13:22:47 +00:00
|
|
|
if(bInit)
|
|
|
|
{
|
|
|
|
// ListBox anlegen, wenn notwendig
|
|
|
|
if (!m_pListBox)
|
|
|
|
{
|
|
|
|
m_pListBox = CreateListBox();
|
|
|
|
DBG_ASSERT(m_pListBox != NULL, "OTableWindow::Init() : CreateListBox hat NULL geliefert !");
|
|
|
|
m_pListBox->SetSelectionMode(MULTIPLE_SELECTION);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Titel setzen
|
|
|
|
m_aTitle.SetText( m_pData->GetWinName() );
|
|
|
|
m_aTitle.Show();
|
|
|
|
|
|
|
|
m_pListBox->Show();
|
|
|
|
|
|
|
|
// die Felder in die ListBox eintragen
|
2002-06-27 07:23:50 +00:00
|
|
|
clearListBox();
|
2001-06-28 13:22:47 +00:00
|
|
|
if (bInit = FillListBox())
|
|
|
|
m_pListBox->SelectAll(FALSE);
|
|
|
|
}
|
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
2001-06-28 13:22:47 +00:00
|
|
|
return bInit;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableWindow::DataChanged(const DataChangedEvent& rDCEvt)
|
|
|
|
{
|
|
|
|
if (rDCEvt.GetType() == DATACHANGED_SETTINGS)
|
|
|
|
{
|
|
|
|
// nehmen wir den worst-case an : die Farben haben sich geaendert, also
|
|
|
|
// mich anpassen
|
2002-02-06 07:15:30 +00:00
|
|
|
const StyleSettings& aSystemStyle = Application::GetSettings().GetStyleSettings();
|
2001-02-05 08:26:47 +00:00
|
|
|
SetBackground(Wallpaper(Color(aSystemStyle.GetFaceColor())));
|
|
|
|
SetTextColor(aSystemStyle.GetButtonTextColor());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableWindow::Paint( const Rectangle& rRect )
|
|
|
|
{
|
|
|
|
Rectangle aRect( Point(0,0), GetOutputSizePixel() );
|
|
|
|
Window::Paint( rRect );
|
|
|
|
Draw3DBorder( aRect );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableWindow::SetTitle( const ::rtl::OUString& rTit )
|
|
|
|
{
|
2002-02-08 08:10:00 +00:00
|
|
|
::rtl::OUString sOldTitle = m_aTitle.GetText();
|
2001-02-05 08:26:47 +00:00
|
|
|
m_aTitle.SetText( rTit );
|
2002-02-08 08:10:00 +00:00
|
|
|
if ( m_pAccessible )
|
2003-04-24 16:22:49 +00:00
|
|
|
m_pAccessible->notifyAccessibleEvent(AccessibleEventId::NAME_CHANGED ,makeAny(sOldTitle),makeAny(rTit));
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableWindow::Draw3DBorder(const Rectangle& rRect)
|
|
|
|
{
|
|
|
|
// die Style-Settings des Systems fuer meine Farben
|
2002-02-06 07:15:30 +00:00
|
|
|
const StyleSettings& aSystemStyle = Application::GetSettings().GetStyleSettings();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
// Schwarze Linie unten und rechts
|
|
|
|
SetLineColor(aSystemStyle.GetDarkShadowColor());
|
|
|
|
DrawLine( rRect.BottomLeft(), rRect.BottomRight() );
|
|
|
|
DrawLine( rRect.BottomRight(), rRect.TopRight() );
|
|
|
|
|
|
|
|
// Dunkelgraue Linie ueber der schwarzen
|
|
|
|
SetLineColor(aSystemStyle.GetShadowColor());
|
2002-02-06 07:15:30 +00:00
|
|
|
Point aEHvector(1,1);
|
|
|
|
DrawLine( rRect.BottomLeft()+Point(1,-1), rRect.BottomRight() - aEHvector );
|
|
|
|
DrawLine( rRect.BottomRight() - aEHvector, rRect.TopRight()+Point(-1,1) );
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
// Hellgraue Linie links und oben
|
|
|
|
SetLineColor(aSystemStyle.GetLightColor());
|
2002-02-06 07:15:30 +00:00
|
|
|
DrawLine( rRect.BottomLeft()+Point(1,-2), rRect.TopLeft() + aEHvector );
|
|
|
|
DrawLine( rRect.TopLeft() + aEHvector, rRect.TopRight()+Point(-2,1) );
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2002-06-24 06:49:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Rectangle OTableWindow::getSizingRect(const Point& _rPos,const Size& _rOutputSize) const
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2002-06-24 06:49:59 +00:00
|
|
|
Rectangle aSizingRect = Rectangle( GetPosPixel(), GetSizePixel() );
|
|
|
|
UINT16 nSizingFlags = GetSizingFlags();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2002-06-24 06:49:59 +00:00
|
|
|
if( nSizingFlags & SIZING_TOP )
|
|
|
|
{
|
|
|
|
if( _rPos.Y() < 0 )
|
|
|
|
aSizingRect.Top() = 0;
|
|
|
|
else
|
|
|
|
aSizingRect.Top() = _rPos.Y();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( nSizingFlags & SIZING_BOTTOM )
|
|
|
|
{
|
|
|
|
if( _rPos.Y() > _rOutputSize.Height() )
|
|
|
|
aSizingRect.Bottom() = _rOutputSize.Height();
|
|
|
|
else
|
|
|
|
aSizingRect.Bottom() = _rPos.Y();
|
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
|
2002-06-24 06:49:59 +00:00
|
|
|
if( nSizingFlags & SIZING_RIGHT )
|
|
|
|
{
|
|
|
|
if( _rPos.X() > _rOutputSize.Width() )
|
|
|
|
aSizingRect.Right() = _rOutputSize.Width();
|
|
|
|
else
|
|
|
|
aSizingRect.Right() = _rPos.X();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( nSizingFlags & SIZING_LEFT )
|
|
|
|
{
|
|
|
|
if( _rPos.X() < 0 )
|
|
|
|
aSizingRect.Left() = 0;
|
|
|
|
else
|
|
|
|
aSizingRect.Left() = _rPos.X();
|
|
|
|
}
|
|
|
|
return aSizingRect;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OTableWindow::setSizingFlag(const Point& _rPos)
|
|
|
|
{
|
|
|
|
Size aOutSize = GetOutputSizePixel();
|
2001-02-05 08:26:47 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Flags anpassen, wenn Mauszeiger in sizingArea
|
|
|
|
m_nSizingFlags = SIZING_NONE;
|
|
|
|
|
2002-06-24 06:49:59 +00:00
|
|
|
if( _rPos.X() < TABWIN_SIZING_AREA )
|
2001-02-05 08:26:47 +00:00
|
|
|
m_nSizingFlags |= SIZING_LEFT;
|
|
|
|
|
2002-06-24 06:49:59 +00:00
|
|
|
if( _rPos.Y() < TABWIN_SIZING_AREA )
|
2001-02-05 08:26:47 +00:00
|
|
|
m_nSizingFlags |= SIZING_TOP;
|
|
|
|
|
2002-06-24 06:49:59 +00:00
|
|
|
if( _rPos.X() > aOutSize.Width()-TABWIN_SIZING_AREA )
|
2001-02-05 08:26:47 +00:00
|
|
|
m_nSizingFlags |= SIZING_RIGHT;
|
|
|
|
|
2002-06-24 06:49:59 +00:00
|
|
|
if( _rPos.Y() > aOutSize.Height()-TABWIN_SIZING_AREA )
|
2001-02-05 08:26:47 +00:00
|
|
|
m_nSizingFlags |= SIZING_BOTTOM;
|
2002-06-24 06:49:59 +00:00
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableWindow::MouseMove( const MouseEvent& rEvt )
|
|
|
|
{
|
|
|
|
Window::MouseMove(rEvt);
|
|
|
|
|
|
|
|
OJoinTableView* pCont = getTableView();
|
|
|
|
if (pCont->getDesignView()->getController()->isReadOnly())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Point aPos = rEvt.GetPosPixel();
|
|
|
|
setSizingFlag(aPos);
|
|
|
|
Pointer aPointer;
|
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Mauszeiger anpassen, wenn Mauszeiger in sizingArea
|
|
|
|
switch( m_nSizingFlags )
|
|
|
|
{
|
|
|
|
case SIZING_TOP:
|
|
|
|
case SIZING_BOTTOM:
|
|
|
|
aPointer = Pointer( POINTER_SSIZE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIZING_LEFT:
|
|
|
|
case SIZING_RIGHT:
|
|
|
|
aPointer = Pointer( POINTER_ESIZE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIZING_LEFT+SIZING_TOP:
|
|
|
|
case SIZING_RIGHT+SIZING_BOTTOM:
|
|
|
|
aPointer = Pointer( POINTER_SESIZE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIZING_RIGHT+SIZING_TOP:
|
|
|
|
case SIZING_LEFT+SIZING_BOTTOM:
|
|
|
|
aPointer = Pointer( POINTER_NESIZE );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetPointer( aPointer );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableWindow::MouseButtonDown( const MouseEvent& rEvt )
|
|
|
|
{
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Wenn sizing, dann bekommt Parent die Nachricht,
|
|
|
|
// dass jetzt die Fenstergroesse seines Childs veraendert wird
|
|
|
|
if( m_nSizingFlags )
|
|
|
|
getTableView()->BeginChildSizing( this, GetPointer() );
|
|
|
|
|
|
|
|
Window::MouseButtonDown( rEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableWindow::Resize()
|
|
|
|
{
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Das Fenster darf nicht verschwinden, deshalb min. Groesse setzen
|
|
|
|
Size aOutSize = GetOutputSizePixel();
|
|
|
|
aOutSize = Size(CalcZoom(aOutSize.Width()),CalcZoom(aOutSize.Height()));
|
|
|
|
Point aPos = GetPosPixel();
|
|
|
|
|
|
|
|
long nCharHeight = CalcZoom(GetTextHeight())+ CalcZoom(4);
|
|
|
|
// if( aOutSize.Width() < TABWIN_WIDTH_MIN )
|
|
|
|
// {
|
|
|
|
// aOutSize.Width() = TABWIN_WIDTH_MIN;
|
|
|
|
// bChanged = sal_True;
|
|
|
|
// }
|
|
|
|
// if( aOutSize.Height() < TABWIN_HEIGHT_MIN )
|
|
|
|
// {
|
|
|
|
// aOutSize.Height() = TABWIN_HEIGHT_MIN;
|
|
|
|
// nCharHeight = GetTextHeight() + 4;
|
|
|
|
// bChanged = sal_True;
|
|
|
|
// }
|
|
|
|
// if(bChanged)
|
|
|
|
// {
|
|
|
|
// SetPosSizePixel( aPos, aOutSize );
|
|
|
|
// m_pData->SetSize( aOutSize );
|
|
|
|
// }
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Titel und ListBox anpassen
|
|
|
|
// long nCharHeight = GetTextHeight() + 4;
|
|
|
|
long n5Pos = CalcZoom(5);
|
|
|
|
long n10Pos = CalcZoom(10);
|
|
|
|
m_aTitle.SetPosSizePixel( Point(n5Pos,n5Pos), Size( aOutSize.Width()-n10Pos, nCharHeight) );
|
|
|
|
m_pListBox->SetPosSizePixel( Point(n5Pos,nCharHeight+n5Pos), Size(aOutSize.Width()-n10Pos,aOutSize.Height()-nCharHeight-n10Pos) );
|
|
|
|
|
|
|
|
Window::Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableWindow::SetBoldTitle( BOOL bBold )
|
|
|
|
{
|
|
|
|
Font aFont = m_aTitle.GetFont();
|
|
|
|
aFont.SetWeight( bBold?WEIGHT_BOLD:WEIGHT_NORMAL );
|
|
|
|
m_aTitle.SetFont( aFont );
|
|
|
|
m_aTitle.Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableWindow::GetFocus()
|
|
|
|
{
|
2001-10-26 06:49:36 +00:00
|
|
|
Window::GetFocus();
|
2001-11-09 11:20:17 +00:00
|
|
|
// we have to forward the focus to our listbox to enable keystokes
|
|
|
|
if(m_pListBox)
|
|
|
|
m_pListBox->GrabFocus();
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2001-11-09 11:20:17 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OTableWindow::setActive(sal_Bool _bActive)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2001-11-09 11:20:17 +00:00
|
|
|
SetBoldTitle( _bActive );
|
|
|
|
m_bActive = _bActive;
|
|
|
|
if (!_bActive && m_pListBox && m_pListBox->GetSelectionCount() != 0)
|
2001-10-26 06:49:36 +00:00
|
|
|
m_pListBox->SelectAll(FALSE);
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableWindow::Remove()
|
|
|
|
{
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
// Fenster loeschen
|
2001-02-28 09:18:26 +00:00
|
|
|
OJoinTableView* pTabWinCont = getTableView();
|
2001-02-05 08:26:47 +00:00
|
|
|
pTabWinCont->RemoveTabWin( this );
|
|
|
|
pTabWinCont->Invalidate();
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
2002-05-22 09:38:07 +00:00
|
|
|
BOOL OTableWindow::HandleKeyInput( const KeyEvent& rEvt )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2002-02-06 07:15:30 +00:00
|
|
|
const KeyCode& rCode = rEvt.GetKeyCode();
|
|
|
|
USHORT nCode = rCode.GetCode();
|
|
|
|
BOOL bShift = rCode.IsShift();
|
|
|
|
BOOL bCtrl = rCode.IsMod1();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2002-05-22 09:38:07 +00:00
|
|
|
BOOL bHandle = FALSE;
|
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
if( !bCtrl && !bShift && (nCode==KEY_DELETE) )
|
|
|
|
{
|
|
|
|
Remove();
|
2002-05-22 09:38:07 +00:00
|
|
|
bHandle = TRUE;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2002-05-22 09:38:07 +00:00
|
|
|
return bHandle;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableWindow::InvalidateLines()
|
|
|
|
{
|
|
|
|
getTableView()->InvalidateConnections();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
BOOL OTableWindow::ExistsAConn() const
|
|
|
|
{
|
|
|
|
return getTableView()->ExistsAConn(this);
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OTableWindow::EnumValidFields(::std::vector< ::rtl::OUString>& arrstrFields)
|
|
|
|
{
|
|
|
|
arrstrFields.clear();
|
|
|
|
// diese Default-Implementierung zaehlt einfach alles auf, was es in der ListBox gibt ... fuer anderes Verhalten ueberschreiben
|
2002-02-06 07:15:30 +00:00
|
|
|
if ( m_pListBox )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2002-02-06 07:15:30 +00:00
|
|
|
arrstrFields.reserve(m_pListBox->GetEntryCount());
|
|
|
|
SvLBoxEntry* pEntryLoop = m_pListBox->First();
|
|
|
|
while (pEntryLoop)
|
|
|
|
{
|
|
|
|
arrstrFields.push_back(m_pListBox->GetEntryText(pEntryLoop));
|
|
|
|
pEntryLoop = m_pListBox->Next(pEntryLoop);
|
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OTableWindow::StateChanged( StateChangedType nType )
|
|
|
|
{
|
|
|
|
Window::StateChanged( nType );
|
|
|
|
|
|
|
|
if ( nType == STATE_CHANGE_ZOOM )
|
|
|
|
{
|
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
|
|
|
|
|
|
|
Font aFont = rStyleSettings.GetGroupFont();
|
|
|
|
if ( IsControlFont() )
|
|
|
|
aFont.Merge( GetControlFont() );
|
|
|
|
SetZoomedPointFont( aFont );
|
|
|
|
|
|
|
|
m_aTitle.SetZoom(GetZoom());
|
|
|
|
m_pListBox->SetZoom(GetZoom());
|
|
|
|
Resize();
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2006-06-20 02:28:47 +00:00
|
|
|
void OTableWindow::_disposing( const ::com::sun::star::lang::EventObject& /*_rSource*/ )
|
2001-06-28 13:22:47 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
m_xTable = NULL;
|
|
|
|
m_xColumns = NULL;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2002-02-06 07:15:30 +00:00
|
|
|
Reference< XAccessible > OTableWindow::CreateAccessible()
|
|
|
|
{
|
2003-06-25 10:04:59 +00:00
|
|
|
OTableWindowAccess* pAccessible = new OTableWindowAccess(this);
|
2002-02-08 08:10:00 +00:00
|
|
|
m_pAccessible = pAccessible;
|
|
|
|
return pAccessible;
|
2002-02-06 07:15:30 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OTableWindow::Command(const CommandEvent& rEvt)
|
|
|
|
{
|
|
|
|
switch (rEvt.GetCommand())
|
|
|
|
{
|
|
|
|
case COMMAND_CONTEXTMENU:
|
|
|
|
{
|
|
|
|
OJoinController* pController = getDesignView()->getController();
|
|
|
|
if(!pController->isReadOnly() && pController->isConnected())
|
|
|
|
{
|
|
|
|
Point ptWhere;
|
|
|
|
if ( rEvt.IsMouseEvent() )
|
|
|
|
ptWhere = rEvt.GetMousePosPixel();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pCurrent = m_pListBox->GetCurEntry();
|
|
|
|
if ( pCurrent )
|
2006-06-20 02:28:47 +00:00
|
|
|
ptWhere = m_pListBox->GetEntryPosition(pCurrent);
|
2002-02-06 07:15:30 +00:00
|
|
|
else
|
|
|
|
ptWhere = m_aTitle.GetPosPixel();
|
|
|
|
}
|
2001-06-28 13:22:47 +00:00
|
|
|
|
2002-05-24 12:00:41 +00:00
|
|
|
PopupMenu aContextMenu(ModuleRes(RID_MENU_JOINVIEW_TABLE));
|
2002-02-06 07:15:30 +00:00
|
|
|
switch (aContextMenu.Execute(this, ptWhere))
|
|
|
|
{
|
|
|
|
case SID_DELETE:
|
|
|
|
Remove();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
Window::Command(rEvt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
long OTableWindow::PreNotify(NotifyEvent& rNEvt)
|
|
|
|
{
|
|
|
|
BOOL bHandled = FALSE;
|
|
|
|
switch (rNEvt.GetType())
|
|
|
|
{
|
|
|
|
case EVENT_KEYINPUT:
|
|
|
|
{
|
2002-06-24 06:49:59 +00:00
|
|
|
if ( getDesignView()->getController()->isReadOnly() )
|
|
|
|
break;
|
|
|
|
|
2002-02-06 07:15:30 +00:00
|
|
|
const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
|
|
|
|
const KeyCode& rCode = pKeyEvent->GetKeyCode();
|
2002-06-11 06:33:43 +00:00
|
|
|
if ( rCode.IsMod1() )
|
2002-02-06 07:15:30 +00:00
|
|
|
{
|
|
|
|
Point aStartPoint = GetPosPixel();
|
2002-06-21 06:09:34 +00:00
|
|
|
if ( rCode.IsShift() )
|
|
|
|
{
|
|
|
|
aStartPoint.X() = GetSizePixel().Width();
|
|
|
|
aStartPoint.Y() = GetSizePixel().Height();
|
|
|
|
}
|
|
|
|
|
2002-02-06 07:15:30 +00:00
|
|
|
switch( rCode.GetCode() )
|
|
|
|
{
|
|
|
|
case KEY_DOWN:
|
|
|
|
bHandled = TRUE;
|
|
|
|
aStartPoint.Y() += m_nMoveIncrement;
|
|
|
|
break;
|
|
|
|
case KEY_UP:
|
|
|
|
bHandled = TRUE;
|
|
|
|
aStartPoint.Y() += -m_nMoveIncrement;
|
|
|
|
break;
|
|
|
|
case KEY_LEFT:
|
|
|
|
bHandled = TRUE;
|
|
|
|
aStartPoint.X() += -m_nMoveIncrement;
|
|
|
|
break;
|
|
|
|
case KEY_RIGHT:
|
|
|
|
bHandled = TRUE;
|
|
|
|
aStartPoint.X() += m_nMoveIncrement;
|
|
|
|
break;
|
|
|
|
}
|
2002-06-21 06:09:34 +00:00
|
|
|
if ( bHandled )
|
2002-02-06 07:15:30 +00:00
|
|
|
{
|
2002-06-21 06:09:34 +00:00
|
|
|
if ( rCode.IsShift() )
|
|
|
|
{
|
2002-06-24 06:49:59 +00:00
|
|
|
OJoinTableView* pView = getTableView();
|
|
|
|
Point ptOld = GetPosPixel();
|
|
|
|
Size aSize = pView->getRealOutputSize();
|
|
|
|
Size aNewSize(aStartPoint.X(),aStartPoint.Y());
|
|
|
|
if ( ((ptOld.X() + aNewSize.Width()) <= aSize.Width())
|
|
|
|
&& ((ptOld.Y() + aNewSize.Height()) <= aSize.Height()) )
|
|
|
|
{
|
|
|
|
if ( aNewSize.Width() < TABWIN_WIDTH_MIN )
|
|
|
|
aNewSize.Width() = TABWIN_WIDTH_MIN;
|
|
|
|
if ( aNewSize.Height() < TABWIN_HEIGHT_MIN )
|
|
|
|
aNewSize.Height() = TABWIN_HEIGHT_MIN;
|
|
|
|
|
|
|
|
Size szOld = GetSizePixel();
|
|
|
|
|
|
|
|
aNewSize = Size(pView->CalcZoom(aNewSize.Width()),pView->CalcZoom(aNewSize.Height()));
|
|
|
|
SetPosSizePixel( ptOld, aNewSize );
|
|
|
|
pView->TabWinSized(this, ptOld, szOld);
|
|
|
|
Invalidate( INVALIDATE_NOCHILDREN );
|
|
|
|
}
|
2002-06-21 06:09:34 +00:00
|
|
|
}
|
|
|
|
else
|
2002-05-22 09:38:07 +00:00
|
|
|
{
|
2002-06-21 06:09:34 +00:00
|
|
|
// remember how often the user moved our window
|
|
|
|
++m_nMoveCount;
|
|
|
|
if( m_nMoveCount == 5 )
|
|
|
|
m_nMoveIncrement = 10;
|
|
|
|
else if( m_nMoveCount > 15 )
|
|
|
|
m_nMoveCount = m_nMoveIncrement = 20;
|
|
|
|
|
|
|
|
Point aOldDataPoint = GetData()->GetPosition();
|
|
|
|
Point aNewDataPoint = aStartPoint + getTableView()->GetScrollOffset();
|
|
|
|
if ( aNewDataPoint.X() > -1 && aNewDataPoint.Y() > -1 )
|
2002-05-22 09:38:07 +00:00
|
|
|
{
|
2002-06-21 06:09:34 +00:00
|
|
|
OJoinTableView* pView = getTableView();
|
|
|
|
if ( pView->isMovementAllowed(aNewDataPoint, GetData()->GetSize()) )
|
|
|
|
{
|
|
|
|
SetPosPixel(aStartPoint);
|
|
|
|
|
|
|
|
// aNewDataPoint can not be used here because SetPosPixel reset it
|
|
|
|
pView->EnsureVisible(GetData()->GetPosition(), GetData()->GetSize());
|
|
|
|
pView->TabWinMoved(this,aOldDataPoint);
|
|
|
|
Invalidate(INVALIDATE_NOCHILDREN);
|
|
|
|
getDesignView()->getController()->setModified( sal_True );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_nMoveCount = 0; // reset our movement count
|
|
|
|
m_nMoveIncrement = 1;
|
|
|
|
}
|
2002-05-22 09:38:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_nMoveCount = 0; // reset our movement count
|
|
|
|
m_nMoveIncrement = 1;
|
|
|
|
}
|
|
|
|
}
|
2002-06-24 06:49:59 +00:00
|
|
|
resetSizingFlag();
|
2002-02-06 07:15:30 +00:00
|
|
|
}
|
2002-05-22 09:38:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_nMoveCount = 0; // reset our movement count
|
|
|
|
m_nMoveIncrement = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_nMoveCount = 0; // reset our movement count
|
|
|
|
m_nMoveIncrement = 1;
|
2002-02-06 07:15:30 +00:00
|
|
|
}
|
|
|
|
}
|
2002-05-22 09:38:07 +00:00
|
|
|
break;
|
|
|
|
case EVENT_KEYUP:
|
|
|
|
{
|
|
|
|
const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
|
|
|
|
const KeyCode& rCode = pKeyEvent->GetKeyCode();
|
|
|
|
USHORT nKeyCode = rCode.GetCode();
|
|
|
|
if ( rCode.IsMod2() && nKeyCode != KEY_UP && nKeyCode != KEY_DOWN && nKeyCode != KEY_LEFT && nKeyCode != KEY_RIGHT )
|
|
|
|
{
|
|
|
|
m_nMoveCount = 0; // reset our movement count
|
|
|
|
m_nMoveIncrement = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2002-02-06 07:15:30 +00:00
|
|
|
}
|
|
|
|
if (!bHandled)
|
|
|
|
return Window::PreNotify(rNEvt);
|
|
|
|
return 1L;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2002-02-08 08:10:00 +00:00
|
|
|
String OTableWindow::getTitle() const
|
|
|
|
{
|
|
|
|
return m_aTitle.GetText();
|
|
|
|
}
|
2002-05-08 08:09:31 +00:00
|
|
|
// -----------------------------------------------------------------------------
|