2010-10-12 15:59:03 +02:00
|
|
|
/* -*- 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 .
|
|
|
|
*/
|
2006-09-17 06:20:59 +00:00
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
#include "JoinTableView.hxx"
|
2011-02-03 00:33:36 +01:00
|
|
|
#include <osl/diagnose.h>
|
2001-02-05 08:26:47 +00:00
|
|
|
#include "querycontroller.hxx"
|
2001-02-28 09:18:26 +00:00
|
|
|
#include "JoinDesignView.hxx"
|
2002-08-19 07:01:32 +00:00
|
|
|
#include "dbu_qry.hrc"
|
2001-02-05 08:26:47 +00:00
|
|
|
#include "TableWindow.hxx"
|
|
|
|
#include "TableWindowListBox.hxx"
|
|
|
|
#include "TableConnection.hxx"
|
|
|
|
#include "TableConnectionData.hxx"
|
|
|
|
#include "ConnectionLine.hxx"
|
|
|
|
#include "ConnectionLineData.hxx"
|
|
|
|
#include "browserids.hxx"
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/urlbmk.hxx>
|
2001-02-05 08:26:47 +00:00
|
|
|
#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
|
2001-08-27 13:24:58 +00:00
|
|
|
#include "QueryMoveTabWinUndoAct.hxx"
|
|
|
|
#include "QuerySizeTabWinUndoAct.hxx"
|
2001-02-05 08:26:47 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
2014-01-02 23:52:37 +01:00
|
|
|
#include <vcl/settings.hxx>
|
2001-02-28 09:18:26 +00:00
|
|
|
#include "TableWindowData.hxx"
|
2002-02-06 07:15:30 +00:00
|
|
|
#include "JAccess.hxx"
|
2003-04-24 16:22:16 +00:00
|
|
|
#include <com/sun/star/accessibility/XAccessible.hpp>
|
|
|
|
#include <com/sun/star/accessibility/AccessibleRole.hpp>
|
|
|
|
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
|
2002-05-02 06:54:11 +00:00
|
|
|
#include "UITools.hxx"
|
2007-11-01 14:28:18 +00:00
|
|
|
#include <cppuhelper/exc_hlp.hxx>
|
2012-12-06 14:15:55 +02:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2007-11-01 14:28:18 +00:00
|
|
|
#include <tools/diagnose_ex.h>
|
2009-07-03 12:24:35 +00:00
|
|
|
#include <boost/bind.hpp>
|
2014-02-22 21:51:27 +09:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
2001-10-31 16:32:48 +00:00
|
|
|
#include <algorithm>
|
2001-08-09 08:59:51 +00:00
|
|
|
#include <functional>
|
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
using namespace dbaui;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
2003-04-24 16:22:16 +00:00
|
|
|
using namespace ::com::sun::star::accessibility;
|
2007-11-01 14:28:18 +00:00
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::lang;
|
2002-02-08 08:10:00 +00:00
|
|
|
|
|
|
|
#define LINE_SIZE 50
|
2012-11-25 01:10:10 +01:00
|
|
|
// Constants for the window layout
|
2002-02-08 08:10:00 +00:00
|
|
|
#define TABWIN_SPACING_X 17
|
|
|
|
#define TABWIN_SPACING_Y 17
|
|
|
|
|
|
|
|
#define TABWIN_WIDTH_STD 120
|
|
|
|
#define TABWIN_HEIGHT_STD 120
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
OScrollWindowHelper::OScrollWindowHelper( vcl::Window* pParent) : Window( pParent)
|
2001-02-05 08:26:47 +00:00
|
|
|
,m_aHScrollBar( this, WB_HSCROLL|WB_REPEAT|WB_DRAG )
|
|
|
|
,m_aVScrollBar( this, WB_VSCROLL|WB_REPEAT|WB_DRAG )
|
2001-02-13 15:44:04 +00:00
|
|
|
,m_pCornerWindow(new ScrollBarBox(this, WB_3DLOOK))
|
2006-06-20 02:26:01 +00:00
|
|
|
,m_pTableView(NULL)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2004-08-02 15:12:37 +00:00
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
// ScrollBars
|
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
GetHScrollBar().SetRange( Range(0, 1000) );
|
|
|
|
GetVScrollBar().SetRange( Range(0, 1000) );
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
GetHScrollBar().SetLineSize( LINE_SIZE );
|
|
|
|
GetVScrollBar().SetLineSize( LINE_SIZE );
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
GetHScrollBar().Show();
|
|
|
|
GetVScrollBar().Show();
|
2001-02-13 15:44:04 +00:00
|
|
|
m_pCornerWindow->Show();
|
2002-02-08 08:10:00 +00:00
|
|
|
|
|
|
|
// normally we should be SCROLL_PANE
|
2003-04-24 16:22:16 +00:00
|
|
|
SetAccessibleRole(AccessibleRole::SCROLL_PANE);
|
2001-02-13 15:44:04 +00:00
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2001-02-13 15:44:04 +00:00
|
|
|
OScrollWindowHelper::~OScrollWindowHelper()
|
|
|
|
{
|
2014-09-23 11:20:40 +02:00
|
|
|
boost::scoped_ptr<vcl::Window> aTemp(m_pCornerWindow);
|
2002-05-10 07:23:32 +00:00
|
|
|
m_pCornerWindow = NULL;
|
2001-10-26 06:57:11 +00:00
|
|
|
m_pTableView = NULL;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2001-02-13 15:44:04 +00:00
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
void OScrollWindowHelper::setTableView(OJoinTableView* _pTableView)
|
|
|
|
{
|
|
|
|
m_pTableView = _pTableView;
|
|
|
|
// ScrollBars
|
2014-06-18 12:14:29 +02:00
|
|
|
GetHScrollBar().SetScrollHdl( LINK(m_pTableView, OJoinTableView, ScrollHdl) );
|
|
|
|
GetVScrollBar().SetScrollHdl( LINK(m_pTableView, OJoinTableView, ScrollHdl) );
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2007-11-01 14:28:18 +00:00
|
|
|
void OScrollWindowHelper::resetRange(const Point& _aSize)
|
|
|
|
{
|
|
|
|
Point aPos = PixelToLogic(_aSize);
|
2014-06-18 12:14:29 +02:00
|
|
|
GetHScrollBar().SetRange( Range(0, aPos.X() + TABWIN_SPACING_X) );
|
|
|
|
GetVScrollBar().SetRange( Range(0, aPos.Y() + TABWIN_SPACING_Y) );
|
2007-11-01 14:28:18 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
void OScrollWindowHelper::Resize()
|
|
|
|
{
|
|
|
|
Window::Resize();
|
|
|
|
|
|
|
|
Size aTotalOutputSize = GetOutputSizePixel();
|
2014-06-18 12:14:29 +02:00
|
|
|
long nHScrollHeight = GetHScrollBar().GetSizePixel().Height();
|
|
|
|
long nVScrollWidth = GetVScrollBar().GetSizePixel().Width();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
GetHScrollBar().SetPosSizePixel(
|
2001-02-05 08:26:47 +00:00
|
|
|
Point( 0, aTotalOutputSize.Height()-nHScrollHeight ),
|
|
|
|
Size( aTotalOutputSize.Width()-nVScrollWidth, nHScrollHeight )
|
|
|
|
);
|
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
GetVScrollBar().SetPosSizePixel(
|
2001-02-05 08:26:47 +00:00
|
|
|
Point( aTotalOutputSize.Width()-nVScrollWidth, 0 ),
|
|
|
|
Size( nVScrollWidth, aTotalOutputSize.Height()-nHScrollHeight )
|
|
|
|
);
|
|
|
|
|
2001-02-13 15:44:04 +00:00
|
|
|
m_pCornerWindow->SetPosSizePixel(
|
|
|
|
Point( aTotalOutputSize.Width() - nVScrollWidth, aTotalOutputSize.Height() - nHScrollHeight),
|
|
|
|
Size( nVScrollWidth, nHScrollHeight )
|
|
|
|
);
|
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
GetHScrollBar().SetPageSize( aTotalOutputSize.Width() );
|
|
|
|
GetHScrollBar().SetVisibleSize( aTotalOutputSize.Width() );
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
GetVScrollBar().SetPageSize( aTotalOutputSize.Height() );
|
|
|
|
GetVScrollBar().SetVisibleSize( aTotalOutputSize.Height() );
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2013-03-03 17:11:39 +01:00
|
|
|
// adjust the ranges of the scrollbars if necessary
|
2014-06-18 12:14:29 +02:00
|
|
|
long lRange = GetHScrollBar().GetRange().Max() - GetHScrollBar().GetRange().Min();
|
2001-02-05 08:26:47 +00:00
|
|
|
if (m_pTableView->GetScrollOffset().X() + aTotalOutputSize.Width() > lRange)
|
2014-06-18 12:14:29 +02:00
|
|
|
GetHScrollBar().SetRangeMax(m_pTableView->GetScrollOffset().X() + aTotalOutputSize.Width() + GetHScrollBar().GetRange().Min());
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
lRange = GetVScrollBar().GetRange().Max() - GetVScrollBar().GetRange().Min();
|
2001-02-05 08:26:47 +00:00
|
|
|
if (m_pTableView->GetScrollOffset().Y() + aTotalOutputSize.Height() > lRange)
|
2014-06-18 12:14:29 +02:00
|
|
|
GetVScrollBar().SetRangeMax(m_pTableView->GetScrollOffset().Y() + aTotalOutputSize.Height() + GetVScrollBar().GetRange().Min());
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
m_pTableView->SetPosSizePixel(Point( 0, 0 ),Size( aTotalOutputSize.Width()-nVScrollWidth, aTotalOutputSize.Height()-nHScrollHeight ));
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
// class OJoinTableView
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
OJoinTableView::OJoinTableView( vcl::Window* pParent, OJoinDesignView* pView )
|
2006-06-20 02:26:01 +00:00
|
|
|
:Window( pParent,WB_BORDER )
|
2001-07-26 06:11:02 +00:00
|
|
|
,DropTargetHelper(this)
|
2006-06-20 02:26:01 +00:00
|
|
|
,m_aDragOffset( Point(0,0) )
|
|
|
|
,m_aScrollOffset( Point(0,0) )
|
2001-02-05 08:26:47 +00:00
|
|
|
,m_pDragWin( NULL )
|
|
|
|
,m_pSizingWin( NULL )
|
|
|
|
,m_pSelectedConn( NULL )
|
2014-04-17 11:16:55 +02:00
|
|
|
,m_bTrackingInitiallyMoved(false)
|
2001-02-05 08:26:47 +00:00
|
|
|
,m_pLastFocusTabWin(NULL)
|
2006-06-20 02:26:01 +00:00
|
|
|
,m_pView( pView )
|
2002-02-08 08:10:00 +00:00
|
|
|
,m_pAccessible(NULL)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
SetSizePixel( Size(1000, 1000) );
|
|
|
|
|
|
|
|
InitColors();
|
|
|
|
|
|
|
|
m_aDragScrollTimer.SetTimeoutHdl(LINK(this, OJoinTableView, OnDragScrollTimer));
|
|
|
|
}
|
|
|
|
|
|
|
|
OJoinTableView::~OJoinTableView()
|
|
|
|
{
|
2007-06-27 11:25:30 +00:00
|
|
|
if( m_pAccessible )
|
|
|
|
{
|
|
|
|
m_pAccessible->clearTableView();
|
|
|
|
m_pAccessible = NULL;
|
|
|
|
}
|
2012-11-25 01:10:10 +01:00
|
|
|
// delete lists
|
2001-06-28 13:22:47 +00:00
|
|
|
clearLayoutInformation();
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
IMPL_LINK( OJoinTableView, ScrollHdl, ScrollBar*, pScrollBar )
|
|
|
|
{
|
2012-11-25 01:10:10 +01:00
|
|
|
// move all windows
|
2014-06-18 12:14:29 +02:00
|
|
|
ScrollPane( pScrollBar->GetDelta(), (pScrollBar == &GetHScrollBar()), false );
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
void OJoinTableView::Resize()
|
|
|
|
{
|
|
|
|
Window::Resize();
|
|
|
|
m_aOutputSize = GetSizePixel();
|
|
|
|
|
|
|
|
// tab win positions may not be up-to-date
|
2002-02-06 07:15:30 +00:00
|
|
|
if (m_aTableMap.empty())
|
2001-02-05 08:26:47 +00:00
|
|
|
// no tab wins ...
|
|
|
|
return;
|
|
|
|
|
|
|
|
// we have at least one table so resize it
|
2014-06-18 12:14:29 +02:00
|
|
|
m_aScrollOffset.X() = GetHScrollBar().GetThumbPos();
|
|
|
|
m_aScrollOffset.Y() = GetVScrollBar().GetThumbPos();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
OTableWindow* pCheck = m_aTableMap.begin()->second;
|
|
|
|
Point aRealPos = pCheck->GetPosPixel();
|
|
|
|
Point aAssumedPos = pCheck->GetData()->GetPosition() - GetScrollOffset();
|
|
|
|
|
|
|
|
if (aRealPos == aAssumedPos)
|
|
|
|
// all ok
|
|
|
|
return;
|
|
|
|
|
2013-12-05 22:41:15 +01:00
|
|
|
OTableWindowMap::iterator aIter = m_aTableMap.begin();
|
|
|
|
OTableWindowMap::iterator aEnd = m_aTableMap.end();
|
2009-07-03 12:24:35 +00:00
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
OTableWindow* pCurrent = aIter->second;
|
|
|
|
Point aPos(pCurrent->GetData()->GetPosition() - GetScrollOffset());
|
|
|
|
pCurrent->SetPosPixel(aPos);
|
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2011-01-14 15:00:11 +01:00
|
|
|
sal_uLong OJoinTableView::GetTabWinCount()
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
return m_aTableMap.size();
|
|
|
|
}
|
|
|
|
|
2014-09-12 16:15:27 +02:00
|
|
|
bool OJoinTableView::RemoveConnection( OTableConnection* _pConn,bool _bDelete )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2002-02-08 08:10:00 +00:00
|
|
|
DeselectConn(_pConn);
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2002-02-08 08:10:00 +00:00
|
|
|
// to force a redraw
|
2006-06-20 02:26:01 +00:00
|
|
|
_pConn->InvalidateConnection();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2008-06-25 11:52:18 +00:00
|
|
|
m_pView->getController().removeConnectionData( _pConn->GetData() );
|
2002-02-06 07:15:30 +00:00
|
|
|
|
2008-06-25 11:52:18 +00:00
|
|
|
m_vTableConnection.erase(
|
2002-02-08 08:10:00 +00:00
|
|
|
::std::find(m_vTableConnection.begin(),m_vTableConnection.end(),_pConn) );
|
|
|
|
|
2002-11-26 06:46:13 +00:00
|
|
|
modified();
|
|
|
|
if ( m_pAccessible )
|
2003-04-24 16:22:16 +00:00
|
|
|
m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
|
2004-03-02 11:46:30 +00:00
|
|
|
makeAny(_pConn->GetAccessible()),
|
2002-11-26 06:46:13 +00:00
|
|
|
Any());
|
2002-02-08 08:10:00 +00:00
|
|
|
if ( _bDelete )
|
|
|
|
{
|
|
|
|
delete _pConn;
|
|
|
|
}
|
|
|
|
|
2008-06-25 11:52:18 +00:00
|
|
|
return true;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
2013-09-26 12:17:53 +02:00
|
|
|
OTableWindow* OJoinTableView::GetTabWindow( const OUString& rName )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2013-12-05 22:41:15 +01:00
|
|
|
OTableWindowMap::iterator aIter = m_aTableMap.find(rName);
|
2001-04-06 12:45:42 +00:00
|
|
|
|
|
|
|
return aIter == m_aTableMap.end() ? NULL : aIter->second;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
TTableWindowData::value_type OJoinTableView::createTableWindowData(const OUString& _rComposedName
|
|
|
|
,const OUString& _sTableName
|
|
|
|
,const OUString& _rWinName)
|
2007-11-01 14:28:18 +00:00
|
|
|
{
|
|
|
|
TTableWindowData::value_type pData( CreateImpl(_rComposedName, _sTableName,_rWinName) );
|
|
|
|
OJoinDesignView* pParent = getDesignView();
|
|
|
|
try
|
|
|
|
{
|
2008-06-25 11:52:18 +00:00
|
|
|
if ( !pData->init(pParent->getController().getConnection(),allowQueries()) )
|
2008-06-06 13:12:53 +00:00
|
|
|
{
|
|
|
|
if ( pData->isValid() )
|
|
|
|
onNoColumns_throw();
|
|
|
|
else
|
|
|
|
pData.reset();
|
|
|
|
}
|
2007-11-01 14:28:18 +00:00
|
|
|
}
|
|
|
|
catch ( const SQLException& )
|
|
|
|
{
|
|
|
|
::dbaui::showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ),
|
2013-01-07 17:46:55 +02:00
|
|
|
pParent, pParent->getController().getORB() );
|
2007-11-01 14:28:18 +00:00
|
|
|
}
|
|
|
|
catch( const WrappedTargetException& e )
|
|
|
|
{
|
|
|
|
SQLException aSql;
|
|
|
|
if ( e.TargetException >>= aSql )
|
2013-01-07 17:46:55 +02:00
|
|
|
::dbaui::showError( ::dbtools::SQLExceptionInfo( aSql ), pParent, pParent->getController().getORB() );
|
2007-11-01 14:28:18 +00:00
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
|
|
|
return pData;
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OTableWindowData* OJoinTableView::CreateImpl(const OUString& _rComposedName
|
|
|
|
,const OUString& _sTableName
|
|
|
|
,const OUString& _rWinName)
|
2001-02-28 09:18:26 +00:00
|
|
|
{
|
2007-11-01 14:28:18 +00:00
|
|
|
return new OTableWindowData( NULL,_rComposedName,_sTableName, _rWinName );
|
2001-02-28 09:18:26 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
void OJoinTableView::AddTabWin(const OUString& _rComposedName, const OUString& rWinName, bool /*bNewTable*/)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2011-12-19 18:10:37 -02:00
|
|
|
OSL_ENSURE(!_rComposedName.isEmpty(),"There must be a table name supplied!");
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2007-11-01 14:28:18 +00:00
|
|
|
TTableWindowData::value_type pNewTabWinData(createTableWindowData( _rComposedName, rWinName,rWinName ));
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// insert new window in window list
|
2002-11-08 08:27:59 +00:00
|
|
|
OTableWindow* pNewTabWin = createWindow( pNewTabWinData );
|
|
|
|
if ( pNewTabWin->Init() )
|
2001-02-28 09:18:26 +00:00
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
m_pView->getController().getTableWindowData().push_back( pNewTabWinData);
|
2001-02-28 09:18:26 +00:00
|
|
|
// when we already have a table with this name insert the full qualified one instead
|
|
|
|
if(m_aTableMap.find(rWinName) != m_aTableMap.end())
|
|
|
|
m_aTableMap[_rComposedName] = pNewTabWin;
|
|
|
|
else
|
|
|
|
m_aTableMap[rWinName] = pNewTabWin;
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2001-02-28 09:18:26 +00:00
|
|
|
SetDefaultTabWinPosSize( pNewTabWin );
|
|
|
|
pNewTabWin->Show();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2002-11-26 06:46:13 +00:00
|
|
|
modified();
|
|
|
|
if ( m_pAccessible )
|
2003-04-24 16:22:16 +00:00
|
|
|
m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
|
2002-11-26 06:46:13 +00:00
|
|
|
Any(),
|
|
|
|
makeAny(pNewTabWin->GetAccessible()));
|
2001-02-28 09:18:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-06-27 07:23:50 +00:00
|
|
|
pNewTabWin->clearListBox();
|
2001-02-28 09:18:26 +00:00
|
|
|
delete pNewTabWin;
|
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::RemoveTabWin( OTableWindow* pTabWin )
|
|
|
|
{
|
|
|
|
// first delete all connections of this window to others
|
2008-06-25 11:52:18 +00:00
|
|
|
bool bRemove = true;
|
2007-11-01 14:28:18 +00:00
|
|
|
TTableWindowData::value_type pData = pTabWin->GetData();
|
2001-02-05 08:26:47 +00:00
|
|
|
sal_Int32 nCount = m_vTableConnection.size();
|
2001-03-21 12:49:37 +00:00
|
|
|
::std::vector<OTableConnection*>::reverse_iterator aIter = m_vTableConnection.rbegin();
|
2008-06-25 11:52:18 +00:00
|
|
|
while(aIter != m_vTableConnection.rend() && bRemove)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
OTableConnection* pTabConn = (*aIter);
|
|
|
|
if(
|
2007-11-01 14:28:18 +00:00
|
|
|
( pData == pTabConn->GetData()->getReferencingTable()) ||
|
|
|
|
( pData == pTabConn->GetData()->getReferencedTable())
|
2008-06-25 11:52:18 +00:00
|
|
|
)
|
|
|
|
{
|
2014-09-12 16:15:27 +02:00
|
|
|
bRemove = RemoveConnection( pTabConn ,true);
|
2008-06-25 11:52:18 +00:00
|
|
|
aIter = m_vTableConnection.rbegin();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
++aIter;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// then delete the window itself
|
2002-11-26 06:46:13 +00:00
|
|
|
if ( bRemove )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2002-11-26 06:46:13 +00:00
|
|
|
if ( m_pAccessible )
|
2003-04-24 16:22:16 +00:00
|
|
|
m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
|
2002-11-26 06:46:13 +00:00
|
|
|
makeAny(pTabWin->GetAccessible()),Any()
|
|
|
|
);
|
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
pTabWin->Hide();
|
2008-06-25 11:52:18 +00:00
|
|
|
OJoinController& rController = m_pView->getController();
|
2014-06-18 12:14:29 +02:00
|
|
|
TTableWindowData::iterator aFind = ::std::find(rController.getTableWindowData().begin(), rController.getTableWindowData().end(), pData);
|
|
|
|
if(aFind != rController.getTableWindowData().end())
|
2001-02-05 15:17:40 +00:00
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
rController.getTableWindowData().erase(aFind);
|
2008-06-25 11:52:18 +00:00
|
|
|
rController.setModified(sal_True);
|
2001-02-05 15:17:40 +00:00
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2013-09-26 12:17:53 +02:00
|
|
|
OUString aWinName = pTabWin->GetWinName();
|
2001-03-21 12:49:37 +00:00
|
|
|
if(m_aTableMap.find(aWinName) != m_aTableMap.end())
|
|
|
|
m_aTableMap.erase( aWinName );
|
|
|
|
else
|
2007-11-01 14:28:18 +00:00
|
|
|
m_aTableMap.erase( pTabWin->GetComposedName() );
|
2001-03-21 12:49:37 +00:00
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
if (pTabWin == m_pLastFocusTabWin)
|
|
|
|
m_pLastFocusTabWin = NULL;
|
2002-06-27 07:23:50 +00:00
|
|
|
|
|
|
|
pTabWin->clearListBox();
|
2001-02-05 08:26:47 +00:00
|
|
|
delete pTabWin;
|
|
|
|
|
2008-06-25 11:52:18 +00:00
|
|
|
}
|
|
|
|
if ( (sal_Int32)m_vTableConnection.size() < (nCount-1) ) // if some connections could be removed
|
2002-11-26 06:46:13 +00:00
|
|
|
modified();
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2002-05-22 09:27:07 +00:00
|
|
|
namespace
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
bool isScrollAllowed( OJoinTableView* _pView,long nDelta, bool bHoriz)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2002-05-22 09:27:07 +00:00
|
|
|
// adjust ScrollBar-Positions
|
2014-06-18 12:14:29 +02:00
|
|
|
ScrollBar& rBar = bHoriz ? _pView->GetHScrollBar() : _pView->GetVScrollBar() ;
|
2002-05-22 09:27:07 +00:00
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
long nOldThumbPos = rBar.GetThumbPos();
|
2002-05-22 09:27:07 +00:00
|
|
|
long nNewThumbPos = nOldThumbPos + nDelta;
|
|
|
|
if( nNewThumbPos < 0 )
|
2011-01-09 02:04:00 +09:00
|
|
|
nNewThumbPos = 0;
|
2014-06-18 12:14:29 +02:00
|
|
|
else if( nNewThumbPos > rBar.GetRangeMax() )
|
|
|
|
nNewThumbPos = rBar.GetRangeMax();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2002-05-22 09:27:07 +00:00
|
|
|
if ( bHoriz )
|
|
|
|
{
|
|
|
|
if( nNewThumbPos == _pView->GetScrollOffset().X() )
|
2014-04-17 11:16:55 +02:00
|
|
|
return false;
|
2001-08-27 13:24:58 +00:00
|
|
|
}
|
2002-05-22 09:27:07 +00:00
|
|
|
else if ( nNewThumbPos == _pView->GetScrollOffset().Y() )
|
2014-04-17 11:16:55 +02:00
|
|
|
return false;
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
return true;
|
2002-05-22 09:27:07 +00:00
|
|
|
}
|
2014-04-17 11:16:55 +02:00
|
|
|
bool getMovementImpl(OJoinTableView* _pView,const Point& _rPoint,const Size& _rSize,long& _nScrollX,long& _nScrollY)
|
2002-05-22 09:27:07 +00:00
|
|
|
{
|
|
|
|
_nScrollY = _nScrollX = 0;
|
|
|
|
// data about the tab win
|
|
|
|
Point aUpperLeft = _rPoint;
|
|
|
|
// normalize with respect to visibility
|
2002-06-21 06:09:34 +00:00
|
|
|
aUpperLeft -= _pView->GetScrollOffset();
|
2002-05-22 09:27:07 +00:00
|
|
|
Point aLowerRight(aUpperLeft.X() + _rSize.Width(), aUpperLeft.Y() + _rSize.Height());
|
|
|
|
|
|
|
|
// data about ourself
|
|
|
|
Size aSize = _pView->getRealOutputSize(); //GetOutputSizePixel();
|
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bVisbile = true;
|
|
|
|
bool bFitsHor = (aUpperLeft.X() >= 0) && (aLowerRight.X() <= aSize.Width());
|
|
|
|
bool bFitsVert= (aUpperLeft.Y() >= 0) && (aLowerRight.Y() <= aSize.Height());
|
2002-05-22 09:27:07 +00:00
|
|
|
if (!bFitsHor || !bFitsVert)
|
2001-08-27 13:24:58 +00:00
|
|
|
{
|
2002-05-22 09:27:07 +00:00
|
|
|
if (!bFitsHor)
|
|
|
|
{
|
|
|
|
// ensure the visibility of the right border
|
2002-06-21 06:09:34 +00:00
|
|
|
if ( aLowerRight.X() > aSize.Width() )
|
|
|
|
_nScrollX = aLowerRight.X() - aSize.Width() + TABWIN_SPACING_X;
|
2002-05-22 09:27:07 +00:00
|
|
|
|
2002-06-21 06:09:34 +00:00
|
|
|
// ensure the visibility of the left border (higher priority)
|
2002-06-24 06:56:02 +00:00
|
|
|
if ( aUpperLeft.X() < 0 )
|
2002-05-22 09:27:07 +00:00
|
|
|
_nScrollX = aUpperLeft.X() - TABWIN_SPACING_X;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bFitsVert)
|
|
|
|
{
|
|
|
|
// lower border
|
2002-06-21 06:09:34 +00:00
|
|
|
if ( aLowerRight.Y() > aSize.Height() )
|
|
|
|
_nScrollY = aLowerRight.Y() - aSize.Height() + TABWIN_SPACING_Y;
|
2002-05-22 09:27:07 +00:00
|
|
|
// upper border
|
2002-06-24 06:56:02 +00:00
|
|
|
if ( aUpperLeft.Y() < 0 )
|
2002-05-22 09:27:07 +00:00
|
|
|
_nScrollY = aUpperLeft.Y() - TABWIN_SPACING_Y;
|
|
|
|
}
|
|
|
|
|
2002-06-24 06:56:02 +00:00
|
|
|
if ( _nScrollX ) // aSize.Width() > _rSize.Width() &&
|
2014-04-17 11:16:55 +02:00
|
|
|
bVisbile = isScrollAllowed(_pView,_nScrollX, true);
|
2002-05-22 09:27:07 +00:00
|
|
|
|
2002-06-24 06:56:02 +00:00
|
|
|
if ( _nScrollY ) // aSize.Height() > _rSize.Height() &&
|
2014-04-17 11:16:55 +02:00
|
|
|
bVisbile = bVisbile && isScrollAllowed(_pView,_nScrollY, false);
|
2002-05-22 09:27:07 +00:00
|
|
|
|
2002-06-21 06:09:34 +00:00
|
|
|
if ( bVisbile )
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
sal_Int32 nHRangeMax = _pView->GetHScrollBar().GetRangeMax();
|
|
|
|
sal_Int32 nVRangeMax = _pView->GetVScrollBar().GetRangeMax();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
if ( aSize.Width() + _pView->GetHScrollBar().GetThumbPos() + _nScrollX > nHRangeMax )
|
2014-04-17 11:16:55 +02:00
|
|
|
bVisbile = false;
|
2014-06-18 12:14:29 +02:00
|
|
|
if ( bVisbile && aSize.Height() + _pView->GetVScrollBar().GetThumbPos() + _nScrollY > nVRangeMax )
|
2014-04-17 11:16:55 +02:00
|
|
|
bVisbile = false;
|
2002-06-21 06:09:34 +00:00
|
|
|
}
|
2001-08-27 13:24:58 +00:00
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2002-05-22 09:27:07 +00:00
|
|
|
return bVisbile;
|
|
|
|
}
|
|
|
|
} // end of ano namespace
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool OJoinTableView::isMovementAllowed(const Point& _rPoint,const Size& _rSize)
|
2002-05-22 09:27:07 +00:00
|
|
|
{
|
|
|
|
long nX,nY;
|
|
|
|
return getMovementImpl(this,_rPoint,_rSize,nX,nY);
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2002-05-22 09:27:07 +00:00
|
|
|
void OJoinTableView::EnsureVisible(const OTableWindow* _pWin)
|
|
|
|
{
|
|
|
|
// data about the tab win
|
2007-11-01 14:28:18 +00:00
|
|
|
TTableWindowData::value_type pData = _pWin->GetData();
|
2002-05-22 09:27:07 +00:00
|
|
|
EnsureVisible( pData->GetPosition() , pData->GetSize());
|
|
|
|
Invalidate(INVALIDATE_NOCHILDREN);
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2002-05-22 09:27:07 +00:00
|
|
|
void OJoinTableView::EnsureVisible(const Point& _rPoint,const Size& _rSize)
|
|
|
|
{
|
|
|
|
long nScrollX,nScrollY;
|
|
|
|
|
|
|
|
if ( getMovementImpl(this,_rPoint,_rSize,nScrollX,nScrollY) )
|
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bVisbile = true;
|
2001-08-27 13:24:58 +00:00
|
|
|
if (nScrollX)
|
2014-04-17 11:16:55 +02:00
|
|
|
bVisbile = ScrollPane(nScrollX, true, true);
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2001-08-27 13:24:58 +00:00
|
|
|
if (nScrollY)
|
2014-04-17 11:16:55 +02:00
|
|
|
bVisbile = bVisbile && ScrollPane(nScrollY, false, true);
|
2001-08-27 13:24:58 +00:00
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::SetDefaultTabWinPosSize( OTableWindow* pTabWin )
|
|
|
|
{
|
2012-11-25 01:10:10 +01:00
|
|
|
// determine position:
|
2013-11-25 23:01:00 +01:00
|
|
|
// the window is divided into lines with height TABWIN_SPACING_Y+TABWIN_HEIGHT_STD.
|
2012-11-25 01:10:10 +01:00
|
|
|
// Then for each line is checked, if there is space for another window.
|
|
|
|
// If there is no space, the next line is checked.
|
2001-02-05 08:26:47 +00:00
|
|
|
Size aOutSize = GetSizePixel();
|
|
|
|
Point aNewPos( 0,0 );
|
2011-01-14 15:00:11 +01:00
|
|
|
sal_uInt16 nRow = 0;
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bEnd = false;
|
2001-02-05 08:26:47 +00:00
|
|
|
while( !bEnd )
|
|
|
|
{
|
2012-11-25 01:10:10 +01:00
|
|
|
// Set new position to start of line
|
2001-02-05 08:26:47 +00:00
|
|
|
aNewPos.X() = TABWIN_SPACING_X;
|
|
|
|
aNewPos.Y() = (nRow+1) * TABWIN_SPACING_Y;
|
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// determine rectangle for the corresponding line
|
2001-02-05 08:26:47 +00:00
|
|
|
Rectangle aRowRect( Point(0,0), aOutSize );
|
|
|
|
aRowRect.Top() = nRow * ( TABWIN_SPACING_Y + TABWIN_HEIGHT_STD );
|
|
|
|
aRowRect.Bottom() = (nRow+1) * ( TABWIN_SPACING_Y + TABWIN_HEIGHT_STD );
|
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// check occupied areas of this line
|
2011-01-09 02:04:00 +09:00
|
|
|
OTableWindow* pOtherTabWin;
|
2013-12-05 22:41:15 +01:00
|
|
|
OTableWindowMap::iterator aIter = m_aTableMap.begin();
|
|
|
|
OTableWindowMap::iterator aEnd = m_aTableMap.end();
|
2009-07-03 12:24:35 +00:00
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
pOtherTabWin = aIter->second;
|
|
|
|
Rectangle aOtherTabWinRect( pOtherTabWin->GetPosPixel(), pOtherTabWin->GetSizePixel() );
|
|
|
|
|
|
|
|
if(
|
|
|
|
( (aOtherTabWinRect.Top()>aRowRect.Top()) && (aOtherTabWinRect.Top()<aRowRect.Bottom()) ) ||
|
|
|
|
( (aOtherTabWinRect.Bottom()>aRowRect.Top()) && (aOtherTabWinRect.Bottom()<aRowRect.Bottom()) )
|
|
|
|
)
|
|
|
|
{
|
2012-11-25 01:10:10 +01:00
|
|
|
// TabWin is in the line
|
2001-02-05 08:26:47 +00:00
|
|
|
if( aOtherTabWinRect.Right()>aNewPos.X() )
|
|
|
|
aNewPos.X() = aOtherTabWinRect.Right() + TABWIN_SPACING_X;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// Is there space left in this line?
|
2001-02-05 08:26:47 +00:00
|
|
|
if( (aNewPos.X()+TABWIN_WIDTH_STD)<aRowRect.Right() )
|
|
|
|
{
|
|
|
|
aNewPos.Y() = aRowRect.Top() + TABWIN_SPACING_Y;
|
2014-04-17 11:16:55 +02:00
|
|
|
bEnd = true;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( (aRowRect.Bottom()+aRowRect.GetHeight()) > aOutSize.Height() )
|
|
|
|
{
|
|
|
|
// insert it in the first row
|
|
|
|
sal_Int32 nCount = m_aTableMap.size() % (nRow+1);
|
|
|
|
++nCount;
|
|
|
|
aNewPos.Y() = nCount * TABWIN_SPACING_Y + (nCount-1)*CalcZoom(TABWIN_HEIGHT_STD);
|
2014-04-17 11:16:55 +02:00
|
|
|
bEnd = true;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
nRow++;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// determine size
|
2001-02-05 08:26:47 +00:00
|
|
|
Size aNewSize( CalcZoom(TABWIN_WIDTH_STD), CalcZoom(TABWIN_HEIGHT_STD) );
|
|
|
|
|
|
|
|
// check if the new position in inside the scrollbars ranges
|
|
|
|
Point aBottom(aNewPos);
|
|
|
|
aBottom.X() += aNewSize.Width();
|
|
|
|
aBottom.Y() += aNewSize.Height();
|
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
if(!GetHScrollBar().GetRange().IsInside(aBottom.X()))
|
|
|
|
GetHScrollBar().SetRange( Range(0, aBottom.X()) );
|
|
|
|
if(!GetVScrollBar().GetRange().IsInside(aBottom.Y()))
|
|
|
|
GetVScrollBar().SetRange( Range(0, aBottom.Y()) );
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
pTabWin->SetPosSizePixel( aNewPos, aNewSize );
|
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::DataChanged(const DataChangedEvent& rDCEvt)
|
|
|
|
{
|
|
|
|
if (rDCEvt.GetType() == DATACHANGED_SETTINGS)
|
|
|
|
{
|
2012-11-25 01:10:10 +01:00
|
|
|
// consider the worst case: the colors changed, so adjust me
|
2001-02-05 08:26:47 +00:00
|
|
|
InitColors();
|
|
|
|
Invalidate(INVALIDATE_NOCHILDREN);
|
2012-11-25 01:10:10 +01:00
|
|
|
// due to the Invalidate, the connections are redrawn, so that they are also pictured in the new colors
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::InitColors()
|
|
|
|
{
|
2012-11-25 01:10:10 +01:00
|
|
|
// the colors for the illustration should be the system colors
|
2001-02-05 08:26:47 +00:00
|
|
|
StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
|
2004-08-02 15:12:37 +00:00
|
|
|
SetBackground(Wallpaper(Color(aSystemStyle.GetDialogColor())));
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::BeginChildMove( OTableWindow* pTabWin, const Point& rMousePos )
|
|
|
|
{
|
|
|
|
|
2008-06-25 11:52:18 +00:00
|
|
|
if (m_pView->getController().isReadOnly())
|
2001-02-05 08:26:47 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
m_pDragWin = pTabWin;
|
|
|
|
SetPointer(Pointer(POINTER_MOVE));
|
|
|
|
Point aMousePos = ScreenToOutputPixel( rMousePos );
|
2002-02-06 07:15:30 +00:00
|
|
|
m_aDragOffset = aMousePos - pTabWin->GetPosPixel();
|
2001-02-05 08:26:47 +00:00
|
|
|
m_pDragWin->SetZOrder(NULL, WINDOW_ZORDER_FIRST);
|
2014-04-17 11:16:55 +02:00
|
|
|
m_bTrackingInitiallyMoved = false;
|
2001-02-05 08:26:47 +00:00
|
|
|
StartTracking();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::NotifyTitleClicked( OTableWindow* pTabWin, const Point rMousePos )
|
|
|
|
{
|
|
|
|
DeselectConn(GetSelectedConn());
|
|
|
|
BeginChildMove(pTabWin, rMousePos);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::BeginChildSizing( OTableWindow* pTabWin, const Pointer& rPointer )
|
|
|
|
{
|
|
|
|
|
2008-06-25 11:52:18 +00:00
|
|
|
if (m_pView->getController().isReadOnly())
|
2001-02-05 08:26:47 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
SetPointer( rPointer );
|
|
|
|
m_pSizingWin = pTabWin;
|
|
|
|
StartTracking();
|
|
|
|
}
|
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool OJoinTableView::ScrollPane( long nDelta, bool bHoriz, bool bPaintScrollBars )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bRet = true;
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// adjust ScrollBar-Positions
|
2001-02-05 08:26:47 +00:00
|
|
|
if( bPaintScrollBars )
|
|
|
|
{
|
|
|
|
if( bHoriz )
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
long nOldThumbPos = GetHScrollBar().GetThumbPos();
|
2001-02-05 08:26:47 +00:00
|
|
|
long nNewThumbPos = nOldThumbPos + nDelta;
|
|
|
|
if( nNewThumbPos < 0 )
|
|
|
|
{
|
|
|
|
nNewThumbPos = 0;
|
2014-04-17 11:16:55 +02:00
|
|
|
bRet = false;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2014-06-18 12:14:29 +02:00
|
|
|
if( nNewThumbPos > GetHScrollBar().GetRange().Max() )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
nNewThumbPos = GetHScrollBar().GetRange().Max();
|
2014-04-17 11:16:55 +02:00
|
|
|
bRet = false;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2014-06-18 12:14:29 +02:00
|
|
|
GetHScrollBar().SetThumbPos( nNewThumbPos );
|
|
|
|
nDelta = GetHScrollBar().GetThumbPos() - nOldThumbPos;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
long nOldThumbPos = GetVScrollBar().GetThumbPos();
|
2001-02-05 08:26:47 +00:00
|
|
|
long nNewThumbPos = nOldThumbPos+nDelta;
|
|
|
|
if( nNewThumbPos < 0 )
|
|
|
|
{
|
|
|
|
nNewThumbPos = 0;
|
2014-04-17 11:16:55 +02:00
|
|
|
bRet = false;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2014-06-18 12:14:29 +02:00
|
|
|
if( nNewThumbPos > GetVScrollBar().GetRange().Max() )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
nNewThumbPos = GetVScrollBar().GetRange().Max();
|
2014-04-17 11:16:55 +02:00
|
|
|
bRet = false;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2014-06-18 12:14:29 +02:00
|
|
|
GetVScrollBar().SetThumbPos( nNewThumbPos );
|
|
|
|
nDelta = GetVScrollBar().GetThumbPos() - nOldThumbPos;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// If ScrollOffset hitting borders, no redrawing.
|
2014-06-18 12:14:29 +02:00
|
|
|
if( (GetHScrollBar().GetThumbPos()==m_aScrollOffset.X()) &&
|
|
|
|
(GetVScrollBar().GetThumbPos()==m_aScrollOffset.Y()) )
|
2014-04-17 11:16:55 +02:00
|
|
|
return false;
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// set ScrollOffset anew
|
2001-02-05 08:26:47 +00:00
|
|
|
if (bHoriz)
|
2014-06-18 12:14:29 +02:00
|
|
|
m_aScrollOffset.X() = GetHScrollBar().GetThumbPos();
|
2001-02-05 08:26:47 +00:00
|
|
|
else
|
2014-06-18 12:14:29 +02:00
|
|
|
m_aScrollOffset.Y() = GetVScrollBar().GetThumbPos();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// move all windows
|
2001-02-05 08:26:47 +00:00
|
|
|
OTableWindow* pTabWin;
|
|
|
|
Point aPos;
|
|
|
|
|
2013-12-05 22:41:15 +01:00
|
|
|
OTableWindowMap::iterator aIter = m_aTableMap.begin();
|
|
|
|
OTableWindowMap::iterator aEnd = m_aTableMap.end();
|
2009-07-03 12:24:35 +00:00
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
pTabWin = aIter->second;
|
|
|
|
aPos = pTabWin->GetPosPixel();
|
|
|
|
|
|
|
|
if( bHoriz )
|
|
|
|
aPos.X() -= nDelta;
|
|
|
|
else aPos.Y() -= nDelta;
|
|
|
|
|
|
|
|
pTabWin->SetPosPixel( aPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
Invalidate(); // INVALIDATE_NOCHILDREN
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::Tracking( const TrackingEvent& rTEvt )
|
|
|
|
{
|
|
|
|
HideTracking();
|
|
|
|
|
|
|
|
if (rTEvt.IsTrackingEnded())
|
|
|
|
{
|
|
|
|
if( m_pDragWin )
|
|
|
|
{
|
|
|
|
if (m_aDragScrollTimer.IsActive())
|
|
|
|
m_aDragScrollTimer.Stop();
|
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// adjust position of child after moving
|
|
|
|
// windows are not allowed to leave display range
|
2001-02-05 08:26:47 +00:00
|
|
|
Point aDragWinPos = rTEvt.GetMouseEvent().GetPosPixel() - m_aDragOffset;
|
|
|
|
Size aDragWinSize = m_pDragWin->GetSizePixel();
|
|
|
|
if( aDragWinPos.X() < 0 )
|
|
|
|
aDragWinPos.X() = 0;
|
|
|
|
if( aDragWinPos.Y() < 0 )
|
|
|
|
aDragWinPos.Y() = 0;
|
|
|
|
if( (aDragWinPos.X() + aDragWinSize.Width()) > m_aOutputSize.Width() )
|
2002-05-22 09:27:07 +00:00
|
|
|
aDragWinPos.X() = m_aOutputSize.Width() - aDragWinSize.Width() - 1;
|
2001-02-05 08:26:47 +00:00
|
|
|
if( (aDragWinPos.Y() + aDragWinSize.Height()) > m_aOutputSize.Height() )
|
2002-05-22 09:27:07 +00:00
|
|
|
aDragWinPos.Y() = m_aOutputSize.Height() - aDragWinSize.Height() - 1;
|
2001-02-05 08:26:47 +00:00
|
|
|
if( aDragWinPos.X() < 0 )
|
|
|
|
aDragWinPos.X() = 0;
|
|
|
|
if( aDragWinPos.Y() < 0 )
|
|
|
|
aDragWinPos.Y() = 0;
|
2012-11-25 01:10:10 +01:00
|
|
|
// TODO : don't position window anew, if it is leaving range, but just expand the range
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// position window
|
2001-02-05 08:26:47 +00:00
|
|
|
EndTracking();
|
|
|
|
m_pDragWin->SetZOrder(NULL, WINDOW_ZORDER_FIRST);
|
2012-11-25 01:10:10 +01:00
|
|
|
// check, if I really moved
|
|
|
|
// (this prevents setting the modified-Flag, when there actually was no change0
|
2007-11-01 14:28:18 +00:00
|
|
|
TTableWindowData::value_type pData = m_pDragWin->GetData();
|
2002-02-06 07:15:30 +00:00
|
|
|
if ( ! (pData && pData->HasPosition() && (pData->GetPosition() == aDragWinPos)))
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2012-11-25 01:10:10 +01:00
|
|
|
// old logic coordinates
|
2014-06-18 12:14:29 +02:00
|
|
|
Point ptOldPos = m_pDragWin->GetPosPixel() + Point(GetHScrollBar().GetThumbPos(), GetVScrollBar().GetThumbPos());
|
2012-11-25 01:10:10 +01:00
|
|
|
// new positioning
|
2002-02-06 07:15:30 +00:00
|
|
|
m_pDragWin->SetPosPixel(aDragWinPos);
|
|
|
|
TabWinMoved(m_pDragWin, ptOldPos);
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2002-02-06 07:15:30 +00:00
|
|
|
m_pDragWin->GrabFocus();
|
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
m_pDragWin = NULL;
|
|
|
|
SetPointer(Pointer(POINTER_ARROW));
|
|
|
|
}
|
2002-02-06 07:15:30 +00:00
|
|
|
// else we handle the resizing
|
|
|
|
else if( m_pSizingWin )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
SetPointer( Pointer() );
|
|
|
|
EndTracking();
|
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// old physical coordinates
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
Size szOld = m_pSizingWin->GetSizePixel();
|
|
|
|
Point ptOld = m_pSizingWin->GetPosPixel();
|
|
|
|
Size aNewSize(CalcZoom(m_aSizingRect.GetSize().Width()),CalcZoom(m_aSizingRect.GetSize().Height()));
|
|
|
|
m_pSizingWin->SetPosSizePixel( m_aSizingRect.TopLeft(), aNewSize );
|
|
|
|
TabWinSized(m_pSizingWin, ptOld, szOld);
|
|
|
|
|
|
|
|
m_pSizingWin->Invalidate( m_aSizingRect );
|
|
|
|
m_pSizingWin = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (rTEvt.IsTrackingCanceled())
|
|
|
|
{
|
|
|
|
if (m_aDragScrollTimer.IsActive())
|
|
|
|
m_aDragScrollTimer.Stop();
|
|
|
|
EndTracking();
|
2002-02-06 07:15:30 +00:00
|
|
|
}
|
|
|
|
else
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
if( m_pDragWin )
|
|
|
|
{
|
|
|
|
m_ptPrevDraggingPos = rTEvt.GetMouseEvent().GetPosPixel();
|
2012-11-25 01:10:10 +01:00
|
|
|
// scroll at window borders
|
2001-02-05 08:26:47 +00:00
|
|
|
ScrollWhileDragging();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_pSizingWin )
|
|
|
|
{
|
|
|
|
Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
|
2002-06-24 06:56:02 +00:00
|
|
|
m_aSizingRect = m_pSizingWin->getSizingRect(aMousePos,m_aOutputSize);
|
2001-02-05 08:26:47 +00:00
|
|
|
Update();
|
|
|
|
ShowTracking( m_aSizingRect, SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-20 02:26:01 +00:00
|
|
|
void OJoinTableView::ConnDoubleClicked( OTableConnection* /*pConnection*/ )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::MouseButtonDown( const MouseEvent& rEvt )
|
|
|
|
{
|
|
|
|
GrabFocus();
|
|
|
|
Window::MouseButtonDown(rEvt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::MouseButtonUp( const MouseEvent& rEvt )
|
|
|
|
{
|
|
|
|
Window::MouseButtonUp(rEvt);
|
2012-11-25 01:10:10 +01:00
|
|
|
// Has a connection been selected?
|
2001-10-11 07:38:14 +00:00
|
|
|
if( !m_vTableConnection.empty() )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2001-10-11 07:38:14 +00:00
|
|
|
DeselectConn(GetSelectedConn());
|
|
|
|
|
|
|
|
::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end();
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2001-10-11 07:38:14 +00:00
|
|
|
if( (*aIter)->CheckHit(rEvt.GetPosPixel()) )
|
|
|
|
{
|
|
|
|
SelectConn((*aIter));
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// Double-click
|
2001-10-11 07:38:14 +00:00
|
|
|
if( rEvt.GetClicks() == 2 )
|
|
|
|
ConnDoubleClicked( (*aIter) );
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2001-10-11 07:38:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::KeyInput( const KeyEvent& rEvt )
|
|
|
|
{
|
2011-01-14 15:00:11 +01:00
|
|
|
sal_uInt16 nCode = rEvt.GetKeyCode().GetCode();
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bShift = rEvt.GetKeyCode().IsShift();
|
|
|
|
bool bCtrl = rEvt.GetKeyCode().IsMod1();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
if( !bCtrl && !bShift && (nCode==KEY_DELETE) )
|
|
|
|
{
|
|
|
|
if (GetSelectedConn())
|
2014-09-12 16:15:27 +02:00
|
|
|
RemoveConnection( GetSelectedConn() ,true);
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
Window::KeyInput( rEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::DeselectConn(OTableConnection* pConn)
|
|
|
|
{
|
|
|
|
if (!pConn || !pConn->IsSelected())
|
|
|
|
return;
|
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// deselect the corresponding entries in the ListBox of the table window
|
2001-02-05 08:26:47 +00:00
|
|
|
OTableWindow* pWin = pConn->GetSourceWin();
|
|
|
|
if (pWin && pWin->GetListBox())
|
2014-03-24 15:42:28 +02:00
|
|
|
pWin->GetListBox()->SelectAll(false);
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
pWin = pConn->GetDestWin();
|
|
|
|
if (pWin && pWin->GetListBox())
|
2014-03-24 15:42:28 +02:00
|
|
|
pWin->GetListBox()->SelectAll(false);
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
pConn->Deselect();
|
|
|
|
m_pSelectedConn = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::SelectConn(OTableConnection* pConn)
|
|
|
|
{
|
|
|
|
DeselectConn(GetSelectedConn());
|
|
|
|
|
2002-06-21 06:09:34 +00:00
|
|
|
pConn->Select();
|
|
|
|
m_pSelectedConn = pConn;
|
|
|
|
GrabFocus(); // has to be called here because a table window may still be focused
|
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// select the concerned entries in the windows
|
2001-02-05 08:26:47 +00:00
|
|
|
OTableWindow* pConnSource = pConn->GetSourceWin();
|
|
|
|
OTableWindow* pConnDest = pConn->GetDestWin();
|
|
|
|
if (pConnSource && pConnDest)
|
|
|
|
{
|
|
|
|
OTableWindowListBox* pSourceBox = pConnSource->GetListBox();
|
|
|
|
OTableWindowListBox* pDestBox = pConnDest->GetListBox();
|
|
|
|
if (pSourceBox && pDestBox)
|
|
|
|
{
|
2014-03-24 15:42:28 +02:00
|
|
|
pSourceBox->SelectAll(false);
|
|
|
|
pDestBox->SelectAll(false);
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pFirstSourceVisible = pSourceBox->GetFirstEntryInView();
|
|
|
|
SvTreeListEntry* pFirstDestVisible = pDestBox->GetFirstEntryInView();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
const ::std::vector<OConnectionLine*>& rLines = pConn->GetConnLineList();
|
|
|
|
::std::vector<OConnectionLine*>::const_reverse_iterator aIter = rLines.rbegin();
|
|
|
|
for(;aIter != rLines.rend();++aIter)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
if ((*aIter)->IsValid())
|
|
|
|
{
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pSourceEntry = pSourceBox->GetEntryFromText((*aIter)->GetData()->GetSourceFieldName());
|
2001-02-05 08:26:47 +00:00
|
|
|
if (pSourceEntry)
|
|
|
|
{
|
2014-03-24 15:42:28 +02:00
|
|
|
pSourceBox->Select(pSourceEntry, true);
|
2001-02-05 08:26:47 +00:00
|
|
|
pSourceBox->MakeVisible(pSourceEntry);
|
|
|
|
}
|
|
|
|
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pDestEntry = pDestBox->GetEntryFromText((*aIter)->GetData()->GetDestFieldName());
|
2001-02-05 08:26:47 +00:00
|
|
|
if (pDestEntry)
|
|
|
|
{
|
2014-03-24 15:42:28 +02:00
|
|
|
pDestBox->Select(pDestEntry, true);
|
2001-02-05 08:26:47 +00:00
|
|
|
pDestBox->MakeVisible(pDestEntry);
|
|
|
|
}
|
2001-11-09 07:30:00 +00:00
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((pFirstSourceVisible != pSourceBox->GetFirstEntryInView())
|
|
|
|
|| (pFirstDestVisible != pDestBox->GetFirstEntryInView()))
|
2012-11-25 01:10:10 +01:00
|
|
|
// scrolling was done -> redraw
|
2001-02-05 08:26:47 +00:00
|
|
|
Invalidate(INVALIDATE_NOCHILDREN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
void OJoinTableView::Paint( const Rectangle& rRect )
|
|
|
|
{
|
|
|
|
DrawConnections( rRect );
|
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::InvalidateConnections()
|
|
|
|
{
|
2012-11-25 01:10:10 +01:00
|
|
|
// draw Joins
|
2001-08-09 08:59:51 +00:00
|
|
|
::std::for_each(m_vTableConnection.begin(),m_vTableConnection.end(),
|
2006-06-20 02:26:01 +00:00
|
|
|
::std::mem_fun(& OTableConnection::InvalidateConnection));
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::DrawConnections( const Rectangle& rRect )
|
|
|
|
{
|
2012-11-25 01:10:10 +01:00
|
|
|
// draw Joins
|
2009-07-03 12:24:35 +00:00
|
|
|
::std::for_each(m_vTableConnection.begin(),m_vTableConnection.end(),boost::bind( &OTableConnection::Draw, _1, boost::cref( rRect )));
|
2012-11-25 01:10:10 +01:00
|
|
|
// finally redraw the selected one above all others
|
2001-02-05 08:26:47 +00:00
|
|
|
if (GetSelectedConn())
|
|
|
|
GetSelectedConn()->Draw( rRect );
|
|
|
|
}
|
|
|
|
|
2002-02-06 07:15:30 +00:00
|
|
|
::std::vector<OTableConnection*>::const_iterator OJoinTableView::getTableConnections(const OTableWindow* _pFromWin) const
|
|
|
|
{
|
|
|
|
return ::std::find_if( m_vTableConnection.begin(),
|
|
|
|
m_vTableConnection.end(),
|
|
|
|
::std::bind2nd(::std::mem_fun(&OTableConnection::isTableConnection),_pFromWin));
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2002-02-06 07:15:30 +00:00
|
|
|
sal_Int32 OJoinTableView::getConnectionCount(const OTableWindow* _pFromWin) const
|
|
|
|
{
|
|
|
|
return ::std::count_if( m_vTableConnection.begin(),
|
|
|
|
m_vTableConnection.end(),
|
|
|
|
::std::bind2nd(::std::mem_fun(&OTableConnection::isTableConnection),_pFromWin));
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool OJoinTableView::ExistsAConn(const OTableWindow* pFrom) const
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2002-02-06 07:15:30 +00:00
|
|
|
return getTableConnections(pFrom) != m_vTableConnection.end();
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
void OJoinTableView::ClearAll()
|
|
|
|
{
|
2014-02-21 12:53:51 +01:00
|
|
|
SetUpdateMode(false);
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2001-04-30 12:02:01 +00:00
|
|
|
HideTabWins();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// and the same with the Connections
|
2001-02-05 08:26:47 +00:00
|
|
|
::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end();
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2014-09-12 16:15:27 +02:00
|
|
|
RemoveConnection( *aIter ,true);
|
2001-02-05 08:26:47 +00:00
|
|
|
m_vTableConnection.clear();
|
2001-04-30 12:02:01 +00:00
|
|
|
|
2002-02-06 07:15:30 +00:00
|
|
|
m_pLastFocusTabWin = NULL;
|
|
|
|
m_pSelectedConn = NULL;
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
// scroll to the upper left
|
2014-04-17 11:16:55 +02:00
|
|
|
ScrollPane(-GetScrollOffset().X(), true, true);
|
|
|
|
ScrollPane(-GetScrollOffset().Y(), false, true);
|
2001-04-30 12:02:01 +00:00
|
|
|
Invalidate();
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool OJoinTableView::ScrollWhileDragging()
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2013-02-26 11:40:07 +01:00
|
|
|
OSL_ENSURE(m_pDragWin != NULL, "OJoinTableView::ScrollWhileDragging must not be called when a window is being dragged !");
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// kill the timer
|
2001-02-05 08:26:47 +00:00
|
|
|
if (m_aDragScrollTimer.IsActive())
|
|
|
|
m_aDragScrollTimer.Stop();
|
|
|
|
|
|
|
|
Point aDragWinPos = m_ptPrevDraggingPos - m_aDragOffset;
|
|
|
|
Size aDragWinSize = m_pDragWin->GetSizePixel();
|
|
|
|
Point aLowerRight(aDragWinPos.X() + aDragWinSize.Width(), aDragWinPos.Y() + aDragWinSize.Height());
|
|
|
|
|
|
|
|
if (!m_bTrackingInitiallyMoved && (aDragWinPos == m_pDragWin->GetPosPixel()))
|
2014-04-17 11:16:55 +02:00
|
|
|
return true;
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// avoid illustration errors (when scrolling with active TrackingRect)
|
2001-02-05 08:26:47 +00:00
|
|
|
HideTracking();
|
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bScrolling = false;
|
|
|
|
bool bNeedScrollTimer = false;
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// scroll at window borders
|
|
|
|
// TODO : only catch, if window would disappear completely (don't, if there is still a pixel visible)
|
2001-02-05 08:26:47 +00:00
|
|
|
if( aDragWinPos.X() < 5 )
|
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
bScrolling = ScrollPane( -LINE_SIZE, true, true );
|
2001-02-05 08:26:47 +00:00
|
|
|
if( !bScrolling && (aDragWinPos.X()<0) )
|
|
|
|
aDragWinPos.X() = 0;
|
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// do I need further (timer controlled) scrolling ?
|
2001-02-05 08:26:47 +00:00
|
|
|
bNeedScrollTimer = bScrolling && (aDragWinPos.X() < 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aLowerRight.X() > m_aOutputSize.Width() - 5 )
|
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
bScrolling = ScrollPane( LINE_SIZE, true, true ) ;
|
2001-02-05 08:26:47 +00:00
|
|
|
if( !bScrolling && ( aLowerRight.X() > m_aOutputSize.Width() ) )
|
|
|
|
aDragWinPos.X() = m_aOutputSize.Width() - aDragWinSize.Width();
|
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// do I need further (timer controlled) scrolling ?
|
2001-02-05 08:26:47 +00:00
|
|
|
bNeedScrollTimer = bScrolling && (aLowerRight.X() > m_aOutputSize.Width() - 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aDragWinPos.Y() < 5 )
|
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
bScrolling = ScrollPane( -LINE_SIZE, false, true );
|
2001-02-05 08:26:47 +00:00
|
|
|
if( !bScrolling && (aDragWinPos.Y()<0) )
|
|
|
|
aDragWinPos.Y() = 0;
|
|
|
|
|
|
|
|
bNeedScrollTimer = bScrolling && (aDragWinPos.Y() < 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aLowerRight.Y() > m_aOutputSize.Height() - 5 )
|
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
bScrolling = ScrollPane( LINE_SIZE, false, true );
|
2001-02-05 08:26:47 +00:00
|
|
|
if( !bScrolling && ( (aDragWinPos.Y() + aDragWinSize.Height()) > m_aOutputSize.Height() ) )
|
|
|
|
aDragWinPos.Y() = m_aOutputSize.Height() - aDragWinSize.Height();
|
|
|
|
|
|
|
|
bNeedScrollTimer = bScrolling && (aLowerRight.Y() > m_aOutputSize.Height() - 5);
|
|
|
|
}
|
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// resetting timer, if still necessary
|
2001-02-05 08:26:47 +00:00
|
|
|
if (bNeedScrollTimer)
|
|
|
|
{
|
|
|
|
m_aDragScrollTimer.SetTimeout(100);
|
|
|
|
m_aDragScrollTimer.Start();
|
|
|
|
}
|
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// redraw DraggingRect
|
2001-02-05 08:26:47 +00:00
|
|
|
m_aDragRect = Rectangle(m_ptPrevDraggingPos - m_aDragOffset, m_pDragWin->GetSizePixel());
|
|
|
|
Update();
|
|
|
|
ShowTracking( m_aDragRect, SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
|
|
|
|
|
|
|
|
return bScrolling;
|
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(OJoinTableView, OnDragScrollTimer)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
ScrollWhileDragging();
|
|
|
|
return 0L;
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2002-02-06 07:15:30 +00:00
|
|
|
void OJoinTableView::invalidateAndModify(SfxUndoAction *_pAction)
|
|
|
|
{
|
|
|
|
Invalidate(INVALIDATE_NOCHILDREN);
|
2008-06-25 11:52:18 +00:00
|
|
|
m_pView->getController().addUndoActionAndInvalidate(_pAction);
|
2002-02-06 07:15:30 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
void OJoinTableView::TabWinMoved(OTableWindow* ptWhich, const Point& ptOldPosition)
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
Point ptThumbPos(GetHScrollBar().GetThumbPos(), GetVScrollBar().GetThumbPos());
|
2001-02-05 08:26:47 +00:00
|
|
|
ptWhich->GetData()->SetPosition(ptWhich->GetPosPixel() + ptThumbPos);
|
2001-08-27 13:24:58 +00:00
|
|
|
|
2002-02-06 07:15:30 +00:00
|
|
|
invalidateAndModify(new OJoinMoveTabWinUndoAct(this, ptOldPosition, ptWhich));
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::TabWinSized(OTableWindow* ptWhich, const Point& ptOldPosition, const Size& szOldSize)
|
|
|
|
{
|
|
|
|
ptWhich->GetData()->SetSize(ptWhich->GetSizePixel());
|
|
|
|
ptWhich->GetData()->SetPosition(ptWhich->GetPosPixel());
|
2001-08-27 13:24:58 +00:00
|
|
|
|
2002-02-06 07:15:30 +00:00
|
|
|
invalidateAndModify(new OJoinSizeTabWinUndoAct(this, ptOldPosition, szOldSize, ptWhich));
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool OJoinTableView::IsAddAllowed()
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// not, if Db readonly
|
2008-06-25 11:52:18 +00:00
|
|
|
if (m_pView->getController().isReadOnly())
|
2014-04-17 11:16:55 +02:00
|
|
|
return false;
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2001-10-08 06:32:36 +00:00
|
|
|
try
|
|
|
|
{
|
2008-06-25 11:52:18 +00:00
|
|
|
Reference< XConnection> xConnection = m_pView->getController().getConnection();
|
2001-10-08 06:32:36 +00:00
|
|
|
if(!xConnection.is())
|
2014-04-17 11:16:55 +02:00
|
|
|
return false;
|
2012-11-25 01:10:10 +01:00
|
|
|
// not, if too many tables already
|
2001-10-08 06:32:36 +00:00
|
|
|
Reference < XDatabaseMetaData > xMetaData( xConnection->getMetaData() );
|
|
|
|
|
2003-12-01 09:38:03 +00:00
|
|
|
sal_Int32 nMax = xMetaData.is() ? xMetaData->getMaxTablesInSelect() : 0;
|
2001-10-08 06:32:36 +00:00
|
|
|
if (nMax && nMax <= (sal_Int32)m_aTableMap.size())
|
2014-04-17 11:16:55 +02:00
|
|
|
return false;
|
2001-10-08 06:32:36 +00:00
|
|
|
}
|
|
|
|
catch(SQLException&)
|
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
return false;
|
2001-10-08 06:32:36 +00:00
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
return true;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2002-02-06 07:15:30 +00:00
|
|
|
void OJoinTableView::executePopup(const Point& _aPos,OTableConnection* _pSelConnection)
|
|
|
|
{
|
2002-05-24 12:00:41 +00:00
|
|
|
PopupMenu aContextMenu( ModuleRes( RID_MENU_JOINVIEW_CONNECTION ) );
|
2002-02-06 07:15:30 +00:00
|
|
|
switch (aContextMenu.Execute(this, _aPos))
|
|
|
|
{
|
|
|
|
case SID_DELETE:
|
2014-09-12 16:15:27 +02:00
|
|
|
RemoveConnection( _pSelConnection ,true);
|
2002-02-06 07:15:30 +00:00
|
|
|
break;
|
|
|
|
case ID_QUERY_EDIT_JOINCONNECTION:
|
2002-02-08 08:10:00 +00:00
|
|
|
ConnDoubleClicked( _pSelConnection ); // is the same as double clicked
|
2002-02-06 07:15:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
void OJoinTableView::Command(const CommandEvent& rEvt)
|
|
|
|
{
|
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bHandled = false;
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
switch (rEvt.GetCommand())
|
|
|
|
{
|
|
|
|
case COMMAND_CONTEXTMENU:
|
|
|
|
{
|
2001-10-08 06:32:36 +00:00
|
|
|
if( m_vTableConnection.empty() )
|
2001-02-05 08:26:47 +00:00
|
|
|
return;
|
|
|
|
|
2002-02-06 07:15:30 +00:00
|
|
|
OTableConnection* pSelConnection = GetSelectedConn();
|
|
|
|
// when it wasn't a mouse event use the selected connection
|
|
|
|
if (!rEvt.IsMouseEvent())
|
|
|
|
{
|
|
|
|
if( pSelConnection )
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
const ::std::vector<OConnectionLine*>& rLines = pSelConnection->GetConnLineList();
|
|
|
|
::std::vector<OConnectionLine*>::const_iterator aIter = ::std::find_if(rLines.begin(), rLines.end(),::std::mem_fun(&OConnectionLine::IsValid));
|
|
|
|
if( aIter != rLines.end() )
|
2002-02-06 07:15:30 +00:00
|
|
|
executePopup((*aIter)->getMidPoint(),pSelConnection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2002-02-06 07:15:30 +00:00
|
|
|
DeselectConn(pSelConnection);
|
|
|
|
|
|
|
|
const Point& aMousePos = rEvt.GetMousePosPixel();
|
|
|
|
::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end();
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2002-02-06 07:15:30 +00:00
|
|
|
if( (*aIter)->CheckHit(aMousePos) )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2002-02-06 07:15:30 +00:00
|
|
|
SelectConn(*aIter);
|
2008-06-25 11:52:18 +00:00
|
|
|
if(!getDesignView()->getController().isReadOnly() && getDesignView()->getController().isConnected())
|
2002-02-06 07:15:30 +00:00
|
|
|
executePopup(rEvt.GetMousePosPixel(),*aIter);
|
|
|
|
break;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-04-17 11:16:55 +02:00
|
|
|
bHandled = true;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!bHandled)
|
|
|
|
Window::Command(rEvt);
|
|
|
|
}
|
|
|
|
|
2007-11-01 14:28:18 +00:00
|
|
|
OTableConnection* OJoinTableView::GetTabConn(const OTableWindow* pLhs,const OTableWindow* pRhs,bool _bSupressCrossOrNaturalJoin,const OTableConnection* _rpFirstAfter) const
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
OTableConnection* pConn = NULL;
|
2011-02-03 00:33:36 +01:00
|
|
|
OSL_ENSURE(pRhs || pLhs, "OJoinTableView::GetTabConn : invalid args !");
|
2001-02-05 08:26:47 +00:00
|
|
|
// only one NULL-arg allowed
|
|
|
|
|
|
|
|
if ((!pLhs || pLhs->ExistsAConn()) && (!pRhs || pRhs->ExistsAConn()))
|
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bFoundStart = _rpFirstAfter ? sal_False : sal_True;
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2002-02-06 07:15:30 +00:00
|
|
|
::std::vector<OTableConnection*>::const_iterator aIter = m_vTableConnection.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
::std::vector<OTableConnection*>::const_iterator aEnd = m_vTableConnection.end();
|
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
OTableConnection* pData = *aIter;
|
|
|
|
|
|
|
|
if ( ( (pData->GetSourceWin() == pLhs)
|
|
|
|
&& ( (pData->GetDestWin() == pRhs)
|
|
|
|
|| (NULL == pRhs)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|| ( (pData->GetSourceWin() == pRhs)
|
|
|
|
&& ( (pData->GetDestWin() == pLhs)
|
|
|
|
|| (NULL == pLhs)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
2007-11-01 14:28:18 +00:00
|
|
|
if ( _bSupressCrossOrNaturalJoin )
|
|
|
|
{
|
|
|
|
if ( supressCrossNaturalJoin(pData->GetData()) )
|
|
|
|
continue;
|
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
if (bFoundStart)
|
|
|
|
{
|
|
|
|
pConn = pData;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pConn)
|
|
|
|
// used as fallback : if there is no conn after _rpFirstAfter the first conn between the two tables
|
|
|
|
// will be used
|
|
|
|
pConn = pData;
|
|
|
|
|
|
|
|
if (pData == _rpFirstAfter)
|
2014-04-17 11:16:55 +02:00
|
|
|
bFoundStart = true;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pConn;
|
|
|
|
}
|
|
|
|
|
2014-01-18 00:18:52 +01:00
|
|
|
bool OJoinTableView::PreNotify(NotifyEvent& rNEvt)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bHandled = false;
|
2001-02-05 08:26:47 +00:00
|
|
|
switch (rNEvt.GetType())
|
|
|
|
{
|
|
|
|
case EVENT_COMMAND:
|
|
|
|
{
|
|
|
|
const CommandEvent* pCommand = rNEvt.GetCommandEvent();
|
|
|
|
if (pCommand->GetCommand() == COMMAND_WHEEL)
|
|
|
|
{
|
|
|
|
const CommandWheelData* pData = rNEvt.GetCommandEvent()->GetWheelData();
|
|
|
|
if (pData->GetMode() == COMMAND_WHEEL_SCROLL)
|
|
|
|
{
|
|
|
|
if (pData->GetDelta() > 0)
|
2014-04-17 11:16:55 +02:00
|
|
|
ScrollPane(-10 * pData->GetScrollLines(), pData->IsHorz(), true);
|
2001-02-05 08:26:47 +00:00
|
|
|
else
|
2014-04-17 11:16:55 +02:00
|
|
|
ScrollPane(10 * pData->GetScrollLines(), pData->IsHorz(), true);
|
|
|
|
bHandled = true;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EVENT_KEYINPUT:
|
|
|
|
{
|
2001-10-26 06:57:11 +00:00
|
|
|
if (m_aTableMap.empty())
|
2001-02-05 08:26:47 +00:00
|
|
|
// no tab wins -> no conns -> no traveling
|
|
|
|
break;
|
|
|
|
|
|
|
|
const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
|
|
|
|
if (!pKeyEvent->GetKeyCode().IsMod1())
|
|
|
|
{
|
|
|
|
switch (pKeyEvent->GetKeyCode().GetCode())
|
|
|
|
{
|
|
|
|
case KEY_TAB:
|
|
|
|
{
|
|
|
|
if (!HasChildPathFocus())
|
|
|
|
break;
|
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
bool bForward = !pKeyEvent->GetKeyCode().IsShift();
|
2001-02-05 08:26:47 +00:00
|
|
|
// is there an active tab win ?
|
2013-12-05 22:41:15 +01:00
|
|
|
OTableWindowMap::iterator aIter = m_aTableMap.begin();
|
|
|
|
OTableWindowMap::iterator aEnd = m_aTableMap.end();
|
2009-07-03 12:24:35 +00:00
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 08:26:47 +00:00
|
|
|
if (aIter->second && aIter->second->HasChildPathFocus())
|
|
|
|
break;
|
|
|
|
|
|
|
|
OTableWindow* pNextWin = NULL;
|
|
|
|
OTableConnection* pNextConn = NULL;
|
|
|
|
|
|
|
|
if (aIter != m_aTableMap.end())
|
|
|
|
{ // there is a currently active tab win
|
|
|
|
// check if there is an "overflow" and we should select a conn instead of a win
|
2001-08-09 08:59:51 +00:00
|
|
|
if (!m_vTableConnection.empty())
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
if ((aIter->second == m_aTableMap.rbegin()->second) && bForward)
|
|
|
|
// the last win is active and we're travelling forward -> select the first conn
|
|
|
|
pNextConn = *m_vTableConnection.begin();
|
|
|
|
if ((aIter == m_aTableMap.begin()) && !bForward)
|
|
|
|
// the first win is active an we're traveling backward -> select the last conn
|
|
|
|
pNextConn = *m_vTableConnection.rbegin();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pNextConn)
|
2001-10-26 06:57:11 +00:00
|
|
|
{
|
2001-02-05 08:26:47 +00:00
|
|
|
// no conn for any reason -> select the next or previous tab win
|
2001-10-26 06:57:11 +00:00
|
|
|
if(bForward)
|
|
|
|
{
|
2012-04-23 21:29:13 +03:00
|
|
|
if ( aIter->second == m_aTableMap.rbegin()->second )
|
2001-10-26 06:57:11 +00:00
|
|
|
pNextWin = m_aTableMap.begin()->second;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++aIter;
|
|
|
|
pNextWin = aIter->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (aIter == m_aTableMap.begin())
|
|
|
|
pNextWin = m_aTableMap.rbegin()->second;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
--aIter;
|
|
|
|
pNextWin = aIter->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // no active tab win -> travel the connections
|
|
|
|
// find the currently selected conn within the conn list
|
|
|
|
sal_Int32 i(0);
|
2006-06-20 02:26:01 +00:00
|
|
|
for ( ::std::vector<OTableConnection*>::iterator connectionIter = m_vTableConnection.begin();
|
|
|
|
connectionIter != m_vTableConnection.end();
|
|
|
|
++connectionIter, ++i
|
|
|
|
)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2006-06-20 02:26:01 +00:00
|
|
|
if ( (*connectionIter) == GetSelectedConn() )
|
2001-02-05 08:26:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i == sal_Int32(m_vTableConnection.size() - 1) && bForward)
|
|
|
|
// the last conn is active and we're travelling forward -> select the first win
|
|
|
|
pNextWin = m_aTableMap.begin()->second;
|
2001-08-09 08:59:51 +00:00
|
|
|
if ((i == 0) && !bForward && !m_aTableMap.empty())
|
2001-02-05 08:26:47 +00:00
|
|
|
// the first conn is active and we're travelling backward -> select the last win
|
|
|
|
pNextWin = m_aTableMap.rbegin()->second;
|
|
|
|
|
|
|
|
if (pNextWin)
|
|
|
|
DeselectConn(GetSelectedConn());
|
|
|
|
else
|
|
|
|
// no win for any reason -> select the next or previous conn
|
|
|
|
if (i < (sal_Int32)m_vTableConnection.size())
|
|
|
|
// there is a currently active conn
|
|
|
|
pNextConn = m_vTableConnection[(i + (bForward ? 1 : m_vTableConnection.size() - 1)) % m_vTableConnection.size()];
|
|
|
|
else
|
|
|
|
{ // no tab win selected, no conn selected
|
2001-08-09 08:59:51 +00:00
|
|
|
if (!m_vTableConnection.empty())
|
2001-02-05 08:26:47 +00:00
|
|
|
pNextConn = m_vTableConnection[bForward ? 0 : m_vTableConnection.size() - 1];
|
2001-08-09 08:59:51 +00:00
|
|
|
else if (!m_aTableMap.empty())
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
if(bForward)
|
|
|
|
pNextWin = m_aTableMap.begin()->second;
|
|
|
|
else
|
|
|
|
pNextWin = m_aTableMap.rbegin()->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// now select the object
|
|
|
|
if (pNextWin)
|
|
|
|
{
|
|
|
|
if (pNextWin->GetListBox())
|
|
|
|
pNextWin->GetListBox()->GrabFocus();
|
|
|
|
else
|
|
|
|
pNextWin->GrabFocus();
|
|
|
|
EnsureVisible(pNextWin);
|
|
|
|
}
|
|
|
|
else if (pNextConn)
|
|
|
|
{
|
|
|
|
GrabFocus();
|
2013-03-03 17:11:39 +01:00
|
|
|
// necessary : a conn may be selected even if a tab win has the focus, in this case
|
2014-04-09 12:37:04 +02:00
|
|
|
// the next travel would select the same conn again if we would not reset the focus ...
|
2001-10-26 06:57:11 +00:00
|
|
|
SelectConn(pNextConn);
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case KEY_RETURN:
|
|
|
|
{
|
|
|
|
if (!pKeyEvent->GetKeyCode().IsShift() && GetSelectedConn() && HasFocus())
|
|
|
|
ConnDoubleClicked(GetSelectedConn());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EVENT_GETFOCUS:
|
|
|
|
{
|
2002-02-06 07:15:30 +00:00
|
|
|
if (m_aTableMap.empty())
|
|
|
|
// no tab wins -> no conns -> no focus change
|
|
|
|
break;
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window* pSource = rNEvt.GetWindow();
|
2001-02-05 08:26:47 +00:00
|
|
|
if (pSource)
|
|
|
|
{
|
2014-09-23 11:20:40 +02:00
|
|
|
vcl::Window* pSearchFor = NULL;
|
2001-02-05 08:26:47 +00:00
|
|
|
if (pSource->GetParent() == this)
|
|
|
|
// it may be one of the tab wins
|
|
|
|
pSearchFor = pSource;
|
2001-03-20 07:15:49 +00:00
|
|
|
else if (pSource->GetParent() && (pSource->GetParent()->GetParent() == this))
|
2001-02-05 08:26:47 +00:00
|
|
|
// it may be one of th list boxes of one of the tab wins
|
|
|
|
pSearchFor = pSource->GetParent();
|
|
|
|
|
|
|
|
if (pSearchFor)
|
|
|
|
{
|
2013-12-05 22:41:15 +01:00
|
|
|
OTableWindowMap::iterator aIter = m_aTableMap.begin();
|
|
|
|
OTableWindowMap::iterator aEnd = m_aTableMap.end();
|
2009-07-03 12:24:35 +00:00
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
if (aIter->second == pSearchFor)
|
|
|
|
{
|
|
|
|
m_pLastFocusTabWin = aIter->second;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bHandled)
|
|
|
|
return Window::PreNotify(rNEvt);
|
2014-01-18 00:18:52 +01:00
|
|
|
return true;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::GrabTabWinFocus()
|
|
|
|
{
|
2001-03-20 07:15:49 +00:00
|
|
|
if (m_pLastFocusTabWin && m_pLastFocusTabWin->IsVisible())
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
if (m_pLastFocusTabWin->GetListBox())
|
|
|
|
m_pLastFocusTabWin->GetListBox()->GrabFocus();
|
|
|
|
else
|
|
|
|
m_pLastFocusTabWin->GrabFocus();
|
|
|
|
}
|
2001-08-09 08:59:51 +00:00
|
|
|
else if (!m_aTableMap.empty() && m_aTableMap.begin()->second && m_aTableMap.begin()->second->IsVisible())
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
OTableWindow* pFirstWin = m_aTableMap.begin()->second;
|
|
|
|
if (pFirstWin->GetListBox())
|
|
|
|
pFirstWin->GetListBox()->GrabFocus();
|
|
|
|
else
|
|
|
|
pFirstWin->GrabFocus();
|
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-02-05 08:26:47 +00:00
|
|
|
void OJoinTableView::StateChanged( StateChangedType nType )
|
|
|
|
{
|
|
|
|
Window::StateChanged( nType );
|
|
|
|
|
|
|
|
if ( nType == STATE_CHANGE_ZOOM )
|
|
|
|
{
|
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
|
|
|
|
2014-09-16 10:09:58 +02:00
|
|
|
vcl::Font aFont = rStyleSettings.GetGroupFont();
|
2001-02-05 08:26:47 +00:00
|
|
|
if ( IsControlFont() )
|
|
|
|
aFont.Merge( GetControlFont() );
|
|
|
|
SetZoomedPointFont( aFont );
|
|
|
|
|
2013-12-05 22:41:15 +01:00
|
|
|
OTableWindowMap::iterator aIter = m_aTableMap.begin();
|
|
|
|
OTableWindowMap::iterator aEnd = m_aTableMap.end();
|
2009-07-03 12:24:35 +00:00
|
|
|
for(;aIter != aEnd;++aIter)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
aIter->second->SetZoom(GetZoom());
|
|
|
|
Size aSize(CalcZoom(aIter->second->GetSizePixel().Width()),CalcZoom(aIter->second->GetSizePixel().Height()));
|
|
|
|
aIter->second->SetSizePixel(aSize);
|
|
|
|
}
|
|
|
|
Resize();
|
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-04-30 12:02:01 +00:00
|
|
|
void OJoinTableView::HideTabWins()
|
|
|
|
{
|
2014-02-21 12:53:51 +01:00
|
|
|
SetUpdateMode(false);
|
2001-04-30 12:02:01 +00:00
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
OTableWindowMap& rTabWins = GetTabWinMap();
|
|
|
|
|
|
|
|
// working on a copy because the real list will be cleared in inner calls
|
|
|
|
OTableWindowMap aCopy(rTabWins);
|
|
|
|
OTableWindowMap::iterator aIter = aCopy.begin();
|
|
|
|
OTableWindowMap::iterator aEnd = aCopy.end();
|
|
|
|
for(;aIter != aEnd;++aIter)
|
|
|
|
RemoveTabWin(aIter->second);
|
2001-04-30 12:02:01 +00:00
|
|
|
|
2008-06-25 11:52:18 +00:00
|
|
|
m_pView->getController().setModified(sal_True);
|
2001-04-30 12:02:01 +00:00
|
|
|
|
2014-02-21 12:53:51 +01:00
|
|
|
SetUpdateMode(true);
|
2001-04-30 12:02:01 +00:00
|
|
|
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2006-06-20 02:26:01 +00:00
|
|
|
sal_Int8 OJoinTableView::AcceptDrop( const AcceptDropEvent& /*_rEvt*/ )
|
2001-07-06 08:57:16 +00:00
|
|
|
{
|
|
|
|
return DND_ACTION_NONE;
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2006-06-20 02:26:01 +00:00
|
|
|
sal_Int8 OJoinTableView::ExecuteDrop( const ExecuteDropEvent& /*_rEvt*/ )
|
2001-07-06 08:57:16 +00:00
|
|
|
{
|
|
|
|
return DND_ACTION_NONE;
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-07-06 08:57:16 +00:00
|
|
|
void OJoinTableView::dragFinished( )
|
|
|
|
{
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2006-06-20 02:26:01 +00:00
|
|
|
void OJoinTableView::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ )
|
2001-07-09 05:56:49 +00:00
|
|
|
{
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-06-28 13:22:47 +00:00
|
|
|
void OJoinTableView::clearLayoutInformation()
|
|
|
|
{
|
2006-01-16 14:30:08 +00:00
|
|
|
m_pLastFocusTabWin = NULL;
|
|
|
|
m_pSelectedConn = NULL;
|
2012-11-25 01:10:10 +01:00
|
|
|
// delete lists
|
2013-12-05 22:41:15 +01:00
|
|
|
OTableWindowMap::iterator aIter = m_aTableMap.begin();
|
|
|
|
OTableWindowMap::iterator aEnd = m_aTableMap.end();
|
2002-10-24 08:08:40 +00:00
|
|
|
for(;aIter != aEnd;++aIter)
|
2002-06-27 07:23:50 +00:00
|
|
|
{
|
|
|
|
if ( aIter->second )
|
|
|
|
aIter->second->clearListBox();
|
2014-09-23 11:20:40 +02:00
|
|
|
boost::scoped_ptr<vcl::Window> aTemp(aIter->second);
|
2002-10-24 08:08:40 +00:00
|
|
|
aIter->second = NULL;
|
2002-06-27 07:23:50 +00:00
|
|
|
}
|
2001-06-28 13:22:47 +00:00
|
|
|
|
2002-02-08 08:10:00 +00:00
|
|
|
m_aTableMap.clear();
|
2001-04-30 12:02:01 +00:00
|
|
|
|
2002-02-08 08:10:00 +00:00
|
|
|
::std::vector<OTableConnection*>::const_iterator aIter2 = m_vTableConnection.begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
::std::vector<OTableConnection*>::const_iterator aEnd2 = m_vTableConnection.end();
|
|
|
|
for(;aIter2 != aEnd2;++aIter2)
|
2001-06-28 13:22:47 +00:00
|
|
|
delete *aIter2;
|
|
|
|
|
2002-02-08 08:10:00 +00:00
|
|
|
m_vTableConnection.clear();
|
2001-06-28 13:22:47 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-07-09 05:56:49 +00:00
|
|
|
void OJoinTableView::lookForUiActivities()
|
2001-07-06 10:25:44 +00:00
|
|
|
{
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2002-06-21 06:09:34 +00:00
|
|
|
void OJoinTableView::LoseFocus()
|
|
|
|
{
|
|
|
|
DeselectConn(GetSelectedConn());
|
|
|
|
Window::LoseFocus();
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2001-10-22 07:09:11 +00:00
|
|
|
void OJoinTableView::GetFocus()
|
|
|
|
{
|
2002-05-02 06:54:11 +00:00
|
|
|
Window::GetFocus();
|
2002-06-21 06:09:34 +00:00
|
|
|
if ( !m_aTableMap.empty() && !GetSelectedConn() )
|
2002-05-02 06:54:11 +00:00
|
|
|
GrabTabWinFocus();
|
2001-10-22 07:09:11 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2002-02-06 07:15:30 +00:00
|
|
|
Reference< XAccessible > OJoinTableView::CreateAccessible()
|
|
|
|
{
|
2008-06-25 11:52:18 +00:00
|
|
|
m_pAccessible = new OJoinDesignViewAccess(this);
|
|
|
|
return m_pAccessible;
|
2002-02-06 07:15:30 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2002-11-26 06:46:13 +00:00
|
|
|
void OJoinTableView::modified()
|
2002-02-08 08:10:00 +00:00
|
|
|
{
|
2008-06-25 11:52:18 +00:00
|
|
|
OJoinController& rController = m_pView->getController();
|
|
|
|
rController.setModified( sal_True );
|
|
|
|
rController.InvalidateFeature(ID_BROWSER_ADDTABLE);
|
|
|
|
rController.InvalidateFeature(SID_RELATION_ADD_RELATION);
|
2002-02-08 08:10:00 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2014-04-17 11:16:55 +02:00
|
|
|
void OJoinTableView::addConnection(OTableConnection* _pConnection,bool _bAddData)
|
2002-02-08 08:10:00 +00:00
|
|
|
{
|
2002-03-26 06:52:37 +00:00
|
|
|
if ( _bAddData )
|
|
|
|
{
|
2003-04-15 15:03:42 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
2014-06-18 12:14:29 +02:00
|
|
|
TTableConnectionData& rTabConnDataList = m_pView->getController().getTableConnectionData();
|
|
|
|
OSL_ENSURE( ::std::find(rTabConnDataList.begin(), rTabConnDataList.end(),_pConnection->GetData()) == rTabConnDataList.end(),"Data already in vector!");
|
2002-03-26 06:52:37 +00:00
|
|
|
#endif
|
2014-06-18 12:14:29 +02:00
|
|
|
m_pView->getController().getTableConnectionData().push_back(_pConnection->GetData());
|
2002-03-26 06:52:37 +00:00
|
|
|
}
|
2002-02-08 08:10:00 +00:00
|
|
|
m_vTableConnection.push_back(_pConnection);
|
2002-03-26 07:55:04 +00:00
|
|
|
_pConnection->RecalcLines();
|
2006-06-20 02:26:01 +00:00
|
|
|
_pConnection->InvalidateConnection();
|
2002-11-26 06:46:13 +00:00
|
|
|
|
|
|
|
modified();
|
|
|
|
if ( m_pAccessible )
|
2003-04-24 16:22:16 +00:00
|
|
|
m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
|
2002-11-26 06:46:13 +00:00
|
|
|
Any(),
|
2004-03-02 11:46:30 +00:00
|
|
|
makeAny(_pConnection->GetAccessible()));
|
2002-02-08 08:10:00 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2007-11-01 14:28:18 +00:00
|
|
|
bool OJoinTableView::allowQueries() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2007-11-01 14:28:18 +00:00
|
|
|
void OJoinTableView::onNoColumns_throw()
|
|
|
|
{
|
2011-03-12 11:27:59 +01:00
|
|
|
OSL_FAIL( "OTableWindow::onNoColumns_throw: cannot really handle this!" );
|
2007-11-01 14:28:18 +00:00
|
|
|
throw SQLException();
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2007-11-01 14:28:18 +00:00
|
|
|
bool OJoinTableView::supressCrossNaturalJoin(const TTableConnectionData::value_type& ) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2010-10-12 15:59:03 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|