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"
|
2017-06-11 20:56:30 +01:00
|
|
|
#include "strings.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>
|
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)
|
2015-04-20 14:00:04 +01:00
|
|
|
,m_aHScrollBar( VclPtr<ScrollBar>::Create(this, WB_HSCROLL|WB_REPEAT|WB_DRAG) )
|
|
|
|
,m_aVScrollBar( VclPtr<ScrollBar>::Create(this, WB_VSCROLL|WB_REPEAT|WB_DRAG) )
|
|
|
|
,m_pCornerWindow(VclPtr<ScrollBarBox>::Create(this, WB_3DLOOK))
|
2015-11-10 10:13:39 +01:00
|
|
|
,m_pTableView(nullptr)
|
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()
|
|
|
|
{
|
2015-03-10 09:07:06 +02:00
|
|
|
disposeOnce();
|
2015-01-16 15:29:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void OScrollWindowHelper::dispose()
|
2001-02-13 15:44:04 +00:00
|
|
|
{
|
2015-01-16 15:29:28 +02:00
|
|
|
m_aHScrollBar.disposeAndClear();
|
|
|
|
m_aVScrollBar.disposeAndClear();
|
2015-04-10 10:44:13 +01:00
|
|
|
m_pCornerWindow.disposeAndClear();
|
2015-03-09 14:29:30 +02:00
|
|
|
m_pTableView.clear();
|
2015-01-16 15:29:28 +02:00
|
|
|
vcl::Window::dispose();
|
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) )
|
2015-11-10 10:13:39 +01:00
|
|
|
,m_pDragWin( nullptr )
|
|
|
|
,m_pSizingWin( nullptr )
|
|
|
|
,m_pSelectedConn( nullptr )
|
2014-04-17 11:16:55 +02:00
|
|
|
,m_bTrackingInitiallyMoved(false)
|
2015-11-10 10:13:39 +01:00
|
|
|
,m_pLastFocusTabWin(nullptr)
|
2006-06-20 02:26:01 +00:00
|
|
|
,m_pView( pView )
|
2015-11-10 10:13:39 +01:00
|
|
|
,m_pAccessible(nullptr)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
SetSizePixel( Size(1000, 1000) );
|
|
|
|
|
|
|
|
InitColors();
|
|
|
|
|
2017-01-23 19:37:51 +01:00
|
|
|
m_aDragScrollIdle.SetInvokeHandler(LINK(this, OJoinTableView, OnDragScrollTimer));
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OJoinTableView::~OJoinTableView()
|
2015-01-16 15:29:28 +02:00
|
|
|
{
|
2015-03-10 09:07:06 +02:00
|
|
|
disposeOnce();
|
2015-01-16 15:29:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::dispose()
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2007-06-27 11:25:30 +00:00
|
|
|
if( m_pAccessible )
|
|
|
|
{
|
|
|
|
m_pAccessible->clearTableView();
|
2015-11-10 10:13:39 +01:00
|
|
|
m_pAccessible = nullptr;
|
2007-06-27 11:25:30 +00:00
|
|
|
}
|
2012-11-25 01:10:10 +01:00
|
|
|
// delete lists
|
2001-06-28 13:22:47 +00:00
|
|
|
clearLayoutInformation();
|
2015-03-09 14:29:30 +02:00
|
|
|
m_pDragWin.clear();
|
|
|
|
m_pSizingWin.clear();
|
|
|
|
m_pSelectedConn.clear();
|
|
|
|
m_pLastFocusTabWin.clear();
|
|
|
|
m_pView.clear();
|
2016-06-30 14:09:31 +02:00
|
|
|
m_vTableConnection.clear();
|
2015-01-16 15:29:28 +02:00
|
|
|
vcl::Window::dispose();
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK( OJoinTableView, ScrollHdl, ScrollBar*, pScrollBar, void )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
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
|
|
|
}
|
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
|
|
|
|
2016-11-10 12:53:02 +02:00
|
|
|
VclPtr<OTableWindow> pCheck = m_aTableMap.begin()->second;
|
2001-02-05 08:26:47 +00:00
|
|
|
Point aRealPos = pCheck->GetPosPixel();
|
|
|
|
Point aAssumedPos = pCheck->GetData()->GetPosition() - GetScrollOffset();
|
|
|
|
|
|
|
|
if (aRealPos == aAssumedPos)
|
|
|
|
// all ok
|
|
|
|
return;
|
|
|
|
|
2016-03-28 19:17:45 +02:00
|
|
|
OTableWindowMap::const_iterator aIter = m_aTableMap.begin();
|
|
|
|
OTableWindowMap::const_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();
|
|
|
|
}
|
|
|
|
|
2016-05-26 11:41:27 +01:00
|
|
|
bool OJoinTableView::RemoveConnection(VclPtr<OTableConnection>& rConn, bool _bDelete)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2016-05-26 11:41:27 +01:00
|
|
|
VclPtr<OTableConnection> xConn(rConn);
|
2016-05-26 10:57:26 +01:00
|
|
|
|
|
|
|
DeselectConn(xConn);
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2002-02-08 08:10:00 +00:00
|
|
|
// to force a redraw
|
2016-05-26 10:57:26 +01:00
|
|
|
xConn->InvalidateConnection();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2016-05-26 10:57:26 +01:00
|
|
|
m_pView->getController().removeConnectionData(xConn->GetData());
|
2002-02-06 07:15:30 +00:00
|
|
|
|
2016-05-26 10:57:26 +01:00
|
|
|
m_vTableConnection.erase(std::find(m_vTableConnection.begin(), m_vTableConnection.end(), xConn));
|
2002-02-08 08:10:00 +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,
|
2016-05-26 10:57:26 +01:00
|
|
|
makeAny(xConn->GetAccessible()),
|
2002-11-26 06:46:13 +00:00
|
|
|
Any());
|
2016-05-26 10:57:26 +01:00
|
|
|
if (_bDelete)
|
|
|
|
xConn->disposeOnce();
|
2002-02-08 08:10:00 +00:00
|
|
|
|
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
|
|
|
{
|
2016-03-28 19:17:45 +02:00
|
|
|
OTableWindowMap::const_iterator aIter = m_aTableMap.find(rName);
|
2001-04-06 12:45:42 +00:00
|
|
|
|
2015-03-09 14:29:30 +02:00
|
|
|
return aIter == m_aTableMap.end() ? nullptr : 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
|
|
|
{
|
2015-11-10 10:13:39 +01:00
|
|
|
return new OTableWindowData( nullptr,_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
|
2015-03-18 08:33:14 +02:00
|
|
|
VclPtr<OTableWindow> pNewTabWin = createWindow( pNewTabWinData );
|
2002-11-08 08:27:59 +00:00
|
|
|
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();
|
2015-03-18 08:33:14 +02:00
|
|
|
pNewTabWin.disposeAndClear();
|
2001-02-28 09:18:26 +00:00
|
|
|
}
|
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();
|
2015-03-09 14:29:30 +02:00
|
|
|
auto 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
|
|
|
{
|
2016-05-26 11:41:27 +01:00
|
|
|
VclPtr<OTableConnection>& rTabConn = (*aIter);
|
|
|
|
if (
|
|
|
|
(pData == rTabConn->GetData()->getReferencingTable()) ||
|
|
|
|
(pData == rTabConn->GetData()->getReferencedTable())
|
|
|
|
)
|
2008-06-25 11:52:18 +00:00
|
|
|
{
|
2016-05-26 11:41:27 +01:00
|
|
|
bRemove = RemoveConnection(rTabConn, true);
|
|
|
|
aIter = m_vTableConnection.rbegin();
|
2008-06-25 11:52:18 +00:00
|
|
|
}
|
|
|
|
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();
|
2017-02-17 19:06:24 +02:00
|
|
|
TTableWindowData::iterator aFind = std::find(rController.getTableWindowData().begin(), rController.getTableWindowData().end(), pData);
|
2014-06-18 12:14:29 +02:00
|
|
|
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);
|
2016-04-20 17:16:13 +02:00
|
|
|
rController.setModified(true);
|
2001-02-05 15:17:40 +00:00
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2015-03-12 21:37:31 +01:00
|
|
|
if ( !m_aTableMap.erase( pTabWin->GetWinName() ) )
|
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)
|
2015-11-10 10:13:39 +01:00
|
|
|
m_pLastFocusTabWin = nullptr;
|
2002-06-27 07:23:50 +00:00
|
|
|
|
|
|
|
pTabWin->clearListBox();
|
2015-04-13 15:39:37 +01:00
|
|
|
pTabWin->disposeOnce();
|
2008-06-25 11:52:18 +00:00
|
|
|
}
|
2015-04-13 15:39:37 +01:00
|
|
|
|
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();
|
|
|
|
|
2015-04-21 14:15:06 +01:00
|
|
|
bool bVisible = true;
|
2014-04-17 11:16:55 +02:00
|
|
|
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() &&
|
2015-04-21 14:15:06 +01:00
|
|
|
bVisible = 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() &&
|
2015-04-21 14:15:06 +01:00
|
|
|
bVisible = bVisible && isScrollAllowed(_pView,_nScrollY, false);
|
2002-05-22 09:27:07 +00:00
|
|
|
|
2015-04-21 14:15:06 +01:00
|
|
|
if ( bVisible )
|
2002-06-21 06:09:34 +00:00
|
|
|
{
|
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 )
|
2015-04-21 14:15:06 +01:00
|
|
|
bVisible = false;
|
|
|
|
if ( bVisible && aSize.Height() + _pView->GetVScrollBar().GetThumbPos() + _nScrollY > nVRangeMax )
|
|
|
|
bVisible = 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
|
|
|
|
2015-04-21 14:15:06 +01:00
|
|
|
return bVisible;
|
2002-05-22 09:27:07 +00:00
|
|
|
}
|
|
|
|
} // 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());
|
2015-05-25 11:20:10 +02:00
|
|
|
Invalidate(InvalidateFlags::NoChildren);
|
2002-05-22 09:27:07 +00:00
|
|
|
}
|
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) )
|
|
|
|
{
|
2015-04-21 14:15:06 +01:00
|
|
|
bool bVisible = true;
|
2001-08-27 13:24:58 +00:00
|
|
|
if (nScrollX)
|
2015-04-21 14:15:06 +01:00
|
|
|
bVisible = ScrollPane(nScrollX, true, true);
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2015-04-21 14:15:06 +01:00
|
|
|
if (nScrollY && bVisible)
|
2015-03-12 22:09:46 +01:00
|
|
|
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
|
2017-03-30 20:27:55 +02:00
|
|
|
tools::Rectangle aRowRect( Point(0,0), aOutSize );
|
2001-02-05 08:26:47 +00:00
|
|
|
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
|
2016-03-28 19:17:45 +02:00
|
|
|
OTableWindowMap::const_iterator aIter = m_aTableMap.begin();
|
|
|
|
OTableWindowMap::const_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
|
|
|
{
|
2014-12-08 21:09:53 +01:00
|
|
|
OTableWindow* pOtherTabWin = aIter->second;
|
2017-03-30 20:27:55 +02:00
|
|
|
tools::Rectangle aOtherTabWinRect( pOtherTabWin->GetPosPixel(), pOtherTabWin->GetSizePixel() );
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2015-01-09 16:29:43 +02:00
|
|
|
if (rDCEvt.GetType() == DataChangedEventType::SETTINGS)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
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();
|
2015-05-25 11:20:10 +02:00
|
|
|
Invalidate(InvalidateFlags::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;
|
2015-05-20 14:05:50 +02:00
|
|
|
SetPointer(Pointer(PointerStyle::Move));
|
2001-02-05 08:26:47 +00:00
|
|
|
Point aMousePos = ScreenToOutputPixel( rMousePos );
|
2002-02-06 07:15:30 +00:00
|
|
|
m_aDragOffset = aMousePos - pTabWin->GetPosPixel();
|
2015-11-10 10:13:39 +01:00
|
|
|
m_pDragWin->SetZOrder(nullptr, ZOrderFlags::First);
|
2014-04-17 11:16:55 +02:00
|
|
|
m_bTrackingInitiallyMoved = false;
|
2001-02-05 08:26:47 +00:00
|
|
|
StartTracking();
|
|
|
|
}
|
|
|
|
|
2015-03-05 09:27:29 +00:00
|
|
|
void OJoinTableView::NotifyTitleClicked( OTableWindow* pTabWin, const Point& rMousePos )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2016-03-28 19:17:45 +02:00
|
|
|
OTableWindowMap::const_iterator aIter = m_aTableMap.begin();
|
|
|
|
OTableWindowMap::const_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 );
|
|
|
|
}
|
|
|
|
|
2015-05-25 11:20:10 +02:00
|
|
|
Invalidate(); // InvalidateFlags::NoChildren
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::Tracking( const TrackingEvent& rTEvt )
|
|
|
|
{
|
|
|
|
HideTracking();
|
|
|
|
|
|
|
|
if (rTEvt.IsTrackingEnded())
|
|
|
|
{
|
|
|
|
if( m_pDragWin )
|
|
|
|
{
|
2014-11-10 14:57:14 +00:00
|
|
|
if (m_aDragScrollIdle.IsActive())
|
|
|
|
m_aDragScrollIdle.Stop();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
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();
|
2015-11-10 10:13:39 +01:00
|
|
|
m_pDragWin->SetZOrder(nullptr, ZOrderFlags::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();
|
|
|
|
}
|
2015-11-10 10:13:39 +01:00
|
|
|
m_pDragWin = nullptr;
|
2015-05-20 14:05:50 +02:00
|
|
|
SetPointer(Pointer(PointerStyle::Arrow));
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
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 );
|
2015-11-10 10:13:39 +01:00
|
|
|
m_pSizingWin = nullptr;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (rTEvt.IsTrackingCanceled())
|
|
|
|
{
|
2014-11-10 14:57:14 +00:00
|
|
|
if (m_aDragScrollIdle.IsActive())
|
|
|
|
m_aDragScrollIdle.Stop();
|
2001-02-05 08:26:47 +00:00
|
|
|
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();
|
2016-05-11 16:57:46 +02:00
|
|
|
ShowTracking( m_aSizingRect, ShowTrackFlags::Small | ShowTrackFlags::TrackWindow );
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-26 11:41:27 +01:00
|
|
|
void OJoinTableView::ConnDoubleClicked(VclPtr<OTableConnection>& /*rConnection*/)
|
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());
|
|
|
|
|
2015-03-09 14:29:30 +02:00
|
|
|
auto aIter = m_vTableConnection.begin();
|
|
|
|
auto aEnd = m_vTableConnection.end();
|
2009-07-03 12:24:35 +00:00
|
|
|
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 )
|
2017-07-07 08:42:54 +02:00
|
|
|
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())
|
2016-05-26 11:41:27 +01: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();
|
2015-11-10 10:13:39 +01:00
|
|
|
m_pSelectedConn = nullptr;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2016-11-25 16:23:17 +02:00
|
|
|
OTableWindowListBox* pSourceBox = pConnSource->GetListBox().get();
|
|
|
|
OTableWindowListBox* pDestBox = pConnDest->GetListBox().get();
|
2001-02-05 08:26:47 +00:00
|
|
|
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
|
|
|
|
2017-02-17 19:06:24 +02:00
|
|
|
const std::vector<OConnectionLine*>& rLines = pConn->GetConnLineList();
|
|
|
|
std::vector<OConnectionLine*>::const_reverse_iterator aIter = rLines.rbegin();
|
2014-06-18 12:14:29 +02:00
|
|
|
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)
|
|
|
|
{
|
2015-08-12 15:09:51 +02:00
|
|
|
pSourceBox->Select(pSourceEntry);
|
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)
|
|
|
|
{
|
2015-08-12 15:09:51 +02:00
|
|
|
pDestBox->Select(pDestEntry);
|
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
|
2015-05-25 11:20:10 +02:00
|
|
|
Invalidate(InvalidateFlags::NoChildren);
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2017-03-30 20:27:55 +02:00
|
|
|
void OJoinTableView::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2015-05-15 20:39:06 +09:00
|
|
|
DrawConnections(rRenderContext, rRect);
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OJoinTableView::InvalidateConnections()
|
|
|
|
{
|
2012-11-25 01:10:10 +01:00
|
|
|
// draw Joins
|
2015-05-15 20:39:06 +09:00
|
|
|
for (auto & conn : m_vTableConnection)
|
2015-03-09 14:29:30 +02:00
|
|
|
conn->InvalidateConnection();
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
2017-03-30 20:27:55 +02:00
|
|
|
void OJoinTableView::DrawConnections(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2012-11-25 01:10:10 +01:00
|
|
|
// draw Joins
|
2015-11-21 08:14:05 -08:00
|
|
|
for(const auto& connection : m_vTableConnection)
|
2015-05-15 20:39:06 +09:00
|
|
|
connection->Draw(rRenderContext, 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())
|
2015-05-15 20:39:06 +09:00
|
|
|
GetSelectedConn()->Draw(rRenderContext, rRect);
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
2017-02-17 19:06:24 +02:00
|
|
|
std::vector<VclPtr<OTableConnection> >::const_iterator OJoinTableView::getTableConnections(const OTableWindow* _pFromWin) const
|
2002-02-06 07:15:30 +00:00
|
|
|
{
|
2017-02-17 19:06:24 +02:00
|
|
|
return std::find_if( m_vTableConnection.begin(),
|
2002-02-06 07:15:30 +00:00
|
|
|
m_vTableConnection.end(),
|
2017-02-17 19:06:24 +02:00
|
|
|
std::bind2nd(std::mem_fun(&OTableConnection::isTableConnection),_pFromWin));
|
2002-02-06 07:15:30 +00:00
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2002-02-06 07:15:30 +00:00
|
|
|
sal_Int32 OJoinTableView::getConnectionCount(const OTableWindow* _pFromWin) const
|
|
|
|
{
|
2017-02-17 19:06:24 +02:00
|
|
|
return std::count_if( m_vTableConnection.begin(),
|
2002-02-06 07:15:30 +00:00
|
|
|
m_vTableConnection.end(),
|
2017-02-17 19:06:24 +02:00
|
|
|
std::bind2nd(std::mem_fun(&OTableConnection::isTableConnection),_pFromWin));
|
2002-02-06 07:15:30 +00:00
|
|
|
}
|
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
|
2015-07-01 19:03:55 +01:00
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
auto aIter = m_vTableConnection.begin();
|
|
|
|
if (aIter == m_vTableConnection.end())
|
|
|
|
break;
|
|
|
|
RemoveConnection(*aIter, true);
|
|
|
|
}
|
2001-02-05 08:26:47 +00:00
|
|
|
m_vTableConnection.clear();
|
2001-04-30 12:02:01 +00:00
|
|
|
|
2015-11-10 10:13:39 +01:00
|
|
|
m_pLastFocusTabWin = nullptr;
|
|
|
|
m_pSelectedConn = nullptr;
|
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
|
|
|
}
|
|
|
|
|
2016-01-11 08:40:36 +02:00
|
|
|
void OJoinTableView::ScrollWhileDragging()
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2015-03-09 14:29:30 +02:00
|
|
|
OSL_ENSURE(m_pDragWin != nullptr, "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
|
2014-11-10 14:57:14 +00:00
|
|
|
if (m_aDragScrollIdle.IsActive())
|
|
|
|
m_aDragScrollIdle.Stop();
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
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()))
|
2016-01-11 08:40:36 +02:00
|
|
|
return;
|
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)
|
|
|
|
{
|
Reorganize Scheduler priority classes
This is based on glibs classification of tasks, but while glib uses
an int for more fine grained priority, we stay with our enum.
1. Timers start with DEFAULT priority, which directly corresponds
with the previous HIGH priority
2. Idles start with DEFAULT_IDLE priority instead of the previous
HIGH priority, so idle default becomes "really run when idle".
As RESIZE and REPAINT are special, and the DEFAULTS are set, there
is just one primary decision for the programmer: should my idle
run before paint (AKA HIGH_IDLE)?
If we really need a more fine-grained classification, we can add it
later, or also switch to a real int. As a result, this drops many
classifications from the code and drastically changes behaviour,
AKA a mail merge from KDE is now as fast as Gtk+ again.
Change-Id: I498a73fd02d5fb6f5d7e9f742f3bce972de9b1f9
2016-08-10 12:00:53 +02:00
|
|
|
m_aDragScrollIdle.SetPriority( TaskPriority::HIGH_IDLE );
|
2014-11-10 14:57:14 +00:00
|
|
|
m_aDragScrollIdle.Start();
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
2012-11-25 01:10:10 +01:00
|
|
|
// redraw DraggingRect
|
2017-03-30 20:27:55 +02:00
|
|
|
m_aDragRect = tools::Rectangle(m_ptPrevDraggingPos - m_aDragOffset, m_pDragWin->GetSizePixel());
|
2001-02-05 08:26:47 +00:00
|
|
|
Update();
|
2016-05-11 16:57:46 +02:00
|
|
|
ShowTracking( m_aDragRect, ShowTrackFlags::Small | ShowTrackFlags::TrackWindow );
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
2017-01-23 19:37:51 +01:00
|
|
|
IMPL_LINK_NOARG(OJoinTableView, OnDragScrollTimer, Timer *, void)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
ScrollWhileDragging();
|
|
|
|
}
|
2013-08-17 23:43:14 +02:00
|
|
|
|
2002-02-06 07:15:30 +00:00
|
|
|
void OJoinTableView::invalidateAndModify(SfxUndoAction *_pAction)
|
|
|
|
{
|
2015-05-25 11:20:10 +02:00
|
|
|
Invalidate(InvalidateFlags::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
|
|
|
|
2016-05-26 11:41:27 +01:00
|
|
|
void OJoinTableView::executePopup(const Point& _aPos, VclPtr<OTableConnection>& rSelConnection)
|
2002-02-06 07:15:30 +00:00
|
|
|
{
|
2017-04-18 11:21:36 +01:00
|
|
|
VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "dbaccess/ui/joinviewmenu.ui", "");
|
|
|
|
VclPtr<PopupMenu> aContextMenu(aBuilder.get_menu("menu"));
|
|
|
|
aContextMenu->Execute(this, _aPos);
|
|
|
|
OString sIdent = aContextMenu->GetCurItemIdent();
|
|
|
|
if (sIdent == "delete")
|
|
|
|
RemoveConnection(rSelConnection, true);
|
|
|
|
else if (sIdent == "edit")
|
|
|
|
ConnDoubleClicked(rSelConnection); // is the same as double clicked
|
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::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())
|
|
|
|
{
|
2015-05-07 15:25:20 +02:00
|
|
|
case CommandEventId::ContextMenu:
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2001-10-08 06:32:36 +00:00
|
|
|
if( m_vTableConnection.empty() )
|
2001-02-05 08:26:47 +00:00
|
|
|
return;
|
|
|
|
|
2016-05-26 11:41:27 +01:00
|
|
|
VclPtr<OTableConnection>& rSelConnection = GetSelectedConn();
|
2002-02-06 07:15:30 +00:00
|
|
|
// when it wasn't a mouse event use the selected connection
|
|
|
|
if (!rEvt.IsMouseEvent())
|
|
|
|
{
|
2016-05-26 11:41:27 +01:00
|
|
|
if (rSelConnection)
|
2002-02-06 07:15:30 +00:00
|
|
|
{
|
2017-02-17 19:06:24 +02:00
|
|
|
const std::vector<OConnectionLine*>& rLines = rSelConnection->GetConnLineList();
|
|
|
|
std::vector<OConnectionLine*>::const_iterator aIter = std::find_if(rLines.begin(), rLines.end(),std::mem_fun(&OConnectionLine::IsValid));
|
2014-06-18 12:14:29 +02:00
|
|
|
if( aIter != rLines.end() )
|
2016-05-26 11:41:27 +01:00
|
|
|
executePopup((*aIter)->getMidPoint(), rSelConnection);
|
2002-02-06 07:15:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2016-05-26 11:41:27 +01:00
|
|
|
DeselectConn(rSelConnection);
|
2002-02-06 07:15:30 +00:00
|
|
|
|
|
|
|
const Point& aMousePos = rEvt.GetMousePosPixel();
|
2015-03-09 14:29:30 +02:00
|
|
|
auto aIter = m_vTableConnection.begin();
|
|
|
|
auto aEnd = m_vTableConnection.end();
|
2009-07-03 12:24:35 +00:00
|
|
|
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
|
|
|
}
|
2015-05-07 15:25:20 +02:00
|
|
|
break;
|
|
|
|
default: break;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
if (!bHandled)
|
|
|
|
Window::Command(rEvt);
|
|
|
|
}
|
|
|
|
|
2016-09-12 12:56:25 +02:00
|
|
|
OTableConnection* OJoinTableView::GetTabConn(const OTableWindow* pLhs,const OTableWindow* pRhs,bool _bSupressCrossOrNaturalJoin) const
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2015-11-10 10:13:39 +01:00
|
|
|
OTableConnection* pConn = nullptr;
|
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()))
|
|
|
|
{
|
2016-11-25 16:23:17 +02:00
|
|
|
for(VclPtr<OTableConnection> const & pData : m_vTableConnection)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
if ( ( (pData->GetSourceWin() == pLhs)
|
|
|
|
&& ( (pData->GetDestWin() == pRhs)
|
2015-11-10 10:13:39 +01:00
|
|
|
|| (nullptr == pRhs)
|
2001-02-05 08:26:47 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|| ( (pData->GetSourceWin() == pRhs)
|
|
|
|
&& ( (pData->GetDestWin() == pLhs)
|
2015-11-10 10:13:39 +01:00
|
|
|
|| (nullptr == pLhs)
|
2001-02-05 08:26:47 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
2007-11-01 14:28:18 +00:00
|
|
|
if ( _bSupressCrossOrNaturalJoin )
|
|
|
|
{
|
|
|
|
if ( supressCrossNaturalJoin(pData->GetData()) )
|
|
|
|
continue;
|
|
|
|
}
|
2016-09-12 12:56:25 +02:00
|
|
|
pConn = pData;
|
|
|
|
break;
|
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())
|
|
|
|
{
|
2014-11-26 14:53:25 +00:00
|
|
|
case MouseNotifyEvent::COMMAND:
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
const CommandEvent* pCommand = rNEvt.GetCommandEvent();
|
2015-05-07 15:25:20 +02:00
|
|
|
if (pCommand->GetCommand() == CommandEventId::Wheel)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
const CommandWheelData* pData = rNEvt.GetCommandEvent()->GetWheelData();
|
2014-10-31 07:26:39 +02:00
|
|
|
if (pData->GetMode() == CommandWheelMode::SCROLL)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
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;
|
2014-11-26 14:53:25 +00:00
|
|
|
case MouseNotifyEvent::KEYINPUT:
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
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 ?
|
2016-03-28 19:17:45 +02:00
|
|
|
OTableWindowMap::const_iterator aIter = m_aTableMap.begin();
|
|
|
|
OTableWindowMap::const_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;
|
|
|
|
|
2015-11-10 10:13:39 +01:00
|
|
|
OTableWindow* pNextWin = nullptr;
|
|
|
|
OTableConnection* pNextConn = nullptr;
|
2001-02-05 08:26:47 +00:00
|
|
|
|
|
|
|
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
|
2016-11-25 16:23:17 +02:00
|
|
|
pNextConn = m_vTableConnection.begin()->get();
|
2001-02-05 08:26:47 +00:00
|
|
|
if ((aIter == m_aTableMap.begin()) && !bForward)
|
|
|
|
// the first win is active an we're traveling backward -> select the last conn
|
2016-11-25 16:23:17 +02:00
|
|
|
pNextConn = m_vTableConnection.rbegin()->get();
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2015-03-09 14:29:30 +02:00
|
|
|
for ( auto connectionIter = m_vTableConnection.begin();
|
2006-06-20 02:26:01 +00:00
|
|
|
connectionIter != m_vTableConnection.end();
|
|
|
|
++connectionIter, ++i
|
|
|
|
)
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
2015-03-09 14:29:30 +02:00
|
|
|
if ( (*connectionIter).get() == 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
|
2016-11-25 16:23:17 +02:00
|
|
|
pNextConn = m_vTableConnection[(i + (bForward ? 1 : m_vTableConnection.size() - 1)) % m_vTableConnection.size()].get();
|
2001-02-05 08:26:47 +00:00
|
|
|
else
|
|
|
|
{ // no tab win selected, no conn selected
|
2001-08-09 08:59:51 +00:00
|
|
|
if (!m_vTableConnection.empty())
|
2016-11-25 16:23:17 +02:00
|
|
|
pNextConn = m_vTableConnection[bForward ? 0 : m_vTableConnection.size() - 1].get();
|
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;
|
2014-11-26 14:53:25 +00:00
|
|
|
case MouseNotifyEvent::GETFOCUS:
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
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)
|
|
|
|
{
|
2015-11-10 10:13:39 +01:00
|
|
|
vcl::Window* pSearchFor = nullptr;
|
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)
|
|
|
|
{
|
2016-03-28 19:17:45 +02:00
|
|
|
OTableWindowMap::const_iterator aIter = m_aTableMap.begin();
|
|
|
|
OTableWindowMap::const_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;
|
2014-12-01 11:48:22 +01:00
|
|
|
default:
|
|
|
|
break;
|
2001-02-05 08:26:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2016-11-10 12:53:02 +02:00
|
|
|
VclPtr<OTableWindow> pFirstWin = m_aTableMap.begin()->second;
|
2001-02-05 08:26:47 +00:00
|
|
|
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 );
|
|
|
|
|
2015-05-17 22:56:46 +09:00
|
|
|
// FIXME RenderContext
|
2015-05-05 13:46:44 +02:00
|
|
|
if ( nType == StateChangedType::Zoom )
|
2001-02-05 08:26:47 +00:00
|
|
|
{
|
|
|
|
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() );
|
2015-05-17 22:56:46 +09:00
|
|
|
SetZoomedPointFont(*this, aFont);
|
2001-02-05 08:26:47 +00:00
|
|
|
|
2016-03-28 19:17:45 +02:00
|
|
|
OTableWindowMap::const_iterator aIter = m_aTableMap.begin();
|
|
|
|
OTableWindowMap::const_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);
|
2016-03-28 19:17:45 +02:00
|
|
|
OTableWindowMap::const_iterator aIter = aCopy.begin();
|
|
|
|
OTableWindowMap::const_iterator aEnd = aCopy.end();
|
2014-06-18 12:14:29 +02:00
|
|
|
for(;aIter != aEnd;++aIter)
|
|
|
|
RemoveTabWin(aIter->second);
|
2001-04-30 12:02:01 +00:00
|
|
|
|
2016-04-20 17:16:13 +02:00
|
|
|
m_pView->getController().setModified(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
|
|
|
|
2001-06-28 13:22:47 +00:00
|
|
|
void OJoinTableView::clearLayoutInformation()
|
|
|
|
{
|
2015-11-10 10:13:39 +01:00
|
|
|
m_pLastFocusTabWin = nullptr;
|
|
|
|
m_pSelectedConn = nullptr;
|
2012-11-25 01:10:10 +01:00
|
|
|
// delete lists
|
2013-12-05 22:41:15 +01:00
|
|
|
OTableWindowMap::iterator aIter = m_aTableMap.begin();
|
2016-03-28 19:17:45 +02:00
|
|
|
OTableWindowMap::const_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();
|
2015-07-09 16:07:49 +01:00
|
|
|
aIter->second.disposeAndClear();
|
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
|
|
|
|
2015-03-20 15:00:03 +00:00
|
|
|
for(auto i = m_vTableConnection.begin();
|
|
|
|
i != m_vTableConnection.end(); ++i)
|
|
|
|
i->disposeAndClear();
|
2001-06-28 13:22:47 +00:00
|
|
|
|
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();
|
2016-04-20 17:16:13 +02:00
|
|
|
rController.setModified( true );
|
2008-06-25 11:52:18 +00:00
|
|
|
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();
|
2017-02-17 19:06:24 +02:00
|
|
|
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
|
|
|
}
|
2017-09-11 08:54:30 +02:00
|
|
|
m_vTableConnection.emplace_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: */
|