1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*96de5490SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*96de5490SAndrew Rist  * distributed with this work for additional information
6*96de5490SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*96de5490SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist  * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*96de5490SAndrew Rist  *
11*96de5490SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*96de5490SAndrew Rist  *
13*96de5490SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist  * software distributed under the License is distributed on an
15*96de5490SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist  * KIND, either express or implied.  See the License for the
17*96de5490SAndrew Rist  * specific language governing permissions and limitations
18*96de5490SAndrew Rist  * under the License.
19*96de5490SAndrew Rist  *
20*96de5490SAndrew Rist  *************************************************************/
21*96de5490SAndrew Rist 
22*96de5490SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir #ifndef DBAUI_TABLEWINDOWLISTBOX_HXX
27cdf0e10cSrcweir #include "TableWindowListBox.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef DBAUI_TABLEWINDOW_HXX
30cdf0e10cSrcweir #include "TableWindow.hxx"
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef DBAUI_QUERYDESIGNVIEW_HXX
33cdf0e10cSrcweir #include "QueryDesignView.hxx"
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef DBAUI_QUERYTABLEVIEW_HXX
36cdf0e10cSrcweir #include "QueryTableView.hxx"
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #ifndef DBAUI_QUERYCONTROLLER_HXX
39cdf0e10cSrcweir #include "querycontroller.hxx"
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #ifndef DBAUI_JOINEXCHANGE_HXX
42cdf0e10cSrcweir #include "JoinExchange.hxx"
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX
45cdf0e10cSrcweir #include <tools/debug.hxx>
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
48cdf0e10cSrcweir #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir #ifndef _SVX_DBEXCH_HRC
51cdf0e10cSrcweir #include <svx/dbexch.hrc>
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #ifndef _SV_SVAPP_HXX
54cdf0e10cSrcweir #include <vcl/svapp.hxx>
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir 
57cdf0e10cSrcweir using namespace dbaui;
58cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
59cdf0e10cSrcweir using namespace ::com::sun::star::uno;
60cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer;
61cdf0e10cSrcweir 
OJoinExchangeData(OTableWindowListBox * pBox)62cdf0e10cSrcweir OJoinExchangeData::OJoinExchangeData(OTableWindowListBox* pBox)
63cdf0e10cSrcweir 	: pListBox(pBox)
64cdf0e10cSrcweir 	, pEntry(pBox->FirstSelected())
65cdf0e10cSrcweir { }
66cdf0e10cSrcweir 
67cdf0e10cSrcweir const sal_uLong SCROLLING_TIMESPAN = 500;
68cdf0e10cSrcweir const long LISTBOX_SCROLLING_AREA = 6;
69cdf0e10cSrcweir //==================================================================
70cdf0e10cSrcweir // class OTableWindowListBox
71cdf0e10cSrcweir //==================================================================
DBG_NAME(OTableWindowListBox)72cdf0e10cSrcweir DBG_NAME(OTableWindowListBox)
73cdf0e10cSrcweir //------------------------------------------------------------------------------
74cdf0e10cSrcweir OTableWindowListBox::OTableWindowListBox( OTableWindow* pParent )
75cdf0e10cSrcweir     :SvTreeListBox( pParent, WB_HASBUTTONS | WB_BORDER)
76cdf0e10cSrcweir 	,m_aMousePos( Point(0,0) )
77cdf0e10cSrcweir 	,m_pTabWin( pParent )
78cdf0e10cSrcweir 	,m_nDropEvent(0)
79cdf0e10cSrcweir 	,m_nUiEvent(0)
80cdf0e10cSrcweir 	,m_bReallyScrolled( sal_False )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir 	DBG_CTOR(OTableWindowListBox,NULL);
83cdf0e10cSrcweir 	m_aScrollTimer.SetTimeout( SCROLLING_TIMESPAN );
84cdf0e10cSrcweir 	SetDoubleClickHdl( LINK(this, OTableWindowListBox, OnDoubleClick) );
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 	SetSelectionMode(SINGLE_SELECTION);
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	SetHighlightRange( );
89cdf0e10cSrcweir }
90cdf0e10cSrcweir 
91cdf0e10cSrcweir //------------------------------------------------------------------------------
dragFinished()92cdf0e10cSrcweir void OTableWindowListBox::dragFinished( )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir 	// first show the error msg when existing
95cdf0e10cSrcweir 	m_pTabWin->getDesignView()->getController().showError(m_pTabWin->getDesignView()->getController().clearOccuredError());
96cdf0e10cSrcweir 	// second look for ui activities which should happen after d&d
97cdf0e10cSrcweir 	if (m_nUiEvent)
98cdf0e10cSrcweir 		Application::RemoveUserEvent(m_nUiEvent);
99cdf0e10cSrcweir 	m_nUiEvent = Application::PostUserEvent(LINK(this, OTableWindowListBox, LookForUiHdl));
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir //------------------------------------------------------------------------------
~OTableWindowListBox()103cdf0e10cSrcweir OTableWindowListBox::~OTableWindowListBox()
104cdf0e10cSrcweir {
105cdf0e10cSrcweir 	DBG_DTOR(OTableWindowListBox,NULL);
106cdf0e10cSrcweir 	if (m_nDropEvent)
107cdf0e10cSrcweir 		Application::RemoveUserEvent(m_nDropEvent);
108cdf0e10cSrcweir 	if (m_nUiEvent)
109cdf0e10cSrcweir 		Application::RemoveUserEvent(m_nUiEvent);
110cdf0e10cSrcweir 	if( m_aScrollTimer.IsActive() )
111cdf0e10cSrcweir 		m_aScrollTimer.Stop();
112cdf0e10cSrcweir 	m_pTabWin = NULL;
113cdf0e10cSrcweir }
114cdf0e10cSrcweir 
115cdf0e10cSrcweir //------------------------------------------------------------------------------
GetEntryFromText(const String & rEntryText)116cdf0e10cSrcweir SvLBoxEntry* OTableWindowListBox::GetEntryFromText( const String& rEntryText )
117cdf0e10cSrcweir {
118cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
119cdf0e10cSrcweir 	// Liste durchiterieren
120cdf0e10cSrcweir 	SvTreeList* pTreeList = GetModel();
121cdf0e10cSrcweir 	SvLBoxEntry* pEntry = (SvLBoxEntry*)pTreeList->First();
122cdf0e10cSrcweir 	OJoinDesignView* pView = m_pTabWin->getDesignView();
123cdf0e10cSrcweir 	OJoinController& rController = pView->getController();
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	sal_Bool bCase = sal_False;
126cdf0e10cSrcweir 	try
127cdf0e10cSrcweir 	{
128cdf0e10cSrcweir 		Reference<XConnection> xConnection = rController.getConnection();
129cdf0e10cSrcweir 		if(xConnection.is())
130cdf0e10cSrcweir 		{
131cdf0e10cSrcweir 			Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
132cdf0e10cSrcweir 			if(xMeta.is())
133cdf0e10cSrcweir 				bCase = xMeta->supportsMixedCaseQuotedIdentifiers();
134cdf0e10cSrcweir 		}
135cdf0e10cSrcweir 		while( pEntry )
136cdf0e10cSrcweir 		{
137cdf0e10cSrcweir 			if((bCase ? rEntryText == GetEntryText(pEntry) : rEntryText.EqualsIgnoreCaseAscii(GetEntryText(pEntry))))
138cdf0e10cSrcweir 			{
139cdf0e10cSrcweir 				return pEntry;
140cdf0e10cSrcweir 			}
141cdf0e10cSrcweir 			pEntry = (SvLBoxEntry*)pTreeList->Next( pEntry );
142cdf0e10cSrcweir 		}
143cdf0e10cSrcweir 	}
144cdf0e10cSrcweir 	catch(SQLException&)
145cdf0e10cSrcweir 	{
146cdf0e10cSrcweir 	}
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	return NULL;
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir //------------------------------------------------------------------------------
NotifyScrolled()152cdf0e10cSrcweir void OTableWindowListBox::NotifyScrolled()
153cdf0e10cSrcweir {
154cdf0e10cSrcweir 	m_bReallyScrolled = sal_True;
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
157cdf0e10cSrcweir //------------------------------------------------------------------------------
NotifyEndScroll()158cdf0e10cSrcweir void OTableWindowListBox::NotifyEndScroll()
159cdf0e10cSrcweir {
160cdf0e10cSrcweir 	if (m_bReallyScrolled)
161cdf0e10cSrcweir 		// die Verbindungen, die diese Tabelle eventuell hat, muessen neu gezeichnet werden
162cdf0e10cSrcweir 		m_pTabWin->getTableView()->Invalidate(INVALIDATE_NOCHILDREN);
163cdf0e10cSrcweir 		// ohne das INVALIDATE_NOCHILDREN wuerden auch alle Tabellen neu gezeichnet werden,
164cdf0e10cSrcweir 		// sprich : es flackert
165cdf0e10cSrcweir 	m_bReallyScrolled = sal_False;
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir //------------------------------------------------------------------------------
PreNotify(NotifyEvent & rNEvt)169cdf0e10cSrcweir long OTableWindowListBox::PreNotify(NotifyEvent& rNEvt)
170cdf0e10cSrcweir {
171cdf0e10cSrcweir 	sal_Bool bHandled = sal_False;
172cdf0e10cSrcweir 	switch (rNEvt.GetType())
173cdf0e10cSrcweir 	{
174cdf0e10cSrcweir 		case EVENT_KEYINPUT:
175cdf0e10cSrcweir 		{
176cdf0e10cSrcweir 			const KeyEvent* pKeyEvent =	rNEvt.GetKeyEvent();
177cdf0e10cSrcweir 			const KeyCode& rCode = pKeyEvent->GetKeyCode();
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 			if (rCode.GetCode() != KEY_RETURN)
180cdf0e10cSrcweir 			{
181cdf0e10cSrcweir 				if(m_pTabWin)
182cdf0e10cSrcweir 				{
183cdf0e10cSrcweir 					bHandled = m_pTabWin->HandleKeyInput(*pKeyEvent);
184cdf0e10cSrcweir 					//	bHandled = sal_True;
185cdf0e10cSrcweir 				}
186cdf0e10cSrcweir 				break;
187cdf0e10cSrcweir 			}
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 			if (rCode.IsMod1() || rCode.IsMod2() || rCode.IsShift())
190cdf0e10cSrcweir 				break;
191cdf0e10cSrcweir 			if (FirstSelected())
192cdf0e10cSrcweir 				static_cast<OTableWindow*>(Window::GetParent())->OnEntryDoubleClicked(FirstSelected());
193cdf0e10cSrcweir 		}
194cdf0e10cSrcweir 		break;
195cdf0e10cSrcweir 	}
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 	if (!bHandled)
198cdf0e10cSrcweir 		return SvTreeListBox::PreNotify(rNEvt);
199cdf0e10cSrcweir 	return 1L;
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
202cdf0e10cSrcweir //------------------------------------------------------------------------------
203cdf0e10cSrcweir IMPL_LINK( OTableWindowListBox, ScrollUpHdl, SvTreeListBox*, /*pBox*/ )
204cdf0e10cSrcweir {
205cdf0e10cSrcweir 	SvLBoxEntry* pEntry = GetEntry( m_aMousePos );
206cdf0e10cSrcweir 	if( !pEntry )
207cdf0e10cSrcweir 		return 0;
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 	if( pEntry != Last() )
210cdf0e10cSrcweir 	{
211cdf0e10cSrcweir 		ScrollOutputArea( -1 );
212cdf0e10cSrcweir 		pEntry = GetEntry( m_aMousePos );
213cdf0e10cSrcweir 		Select( pEntry, sal_True );
214cdf0e10cSrcweir //		m_aScrollTimer.Start();
215cdf0e10cSrcweir 	}
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 	return 0;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir 
220cdf0e10cSrcweir //------------------------------------------------------------------------------
221cdf0e10cSrcweir IMPL_LINK( OTableWindowListBox, ScrollDownHdl, SvTreeListBox*, /*pBox*/ )
222cdf0e10cSrcweir {
223cdf0e10cSrcweir 	SvLBoxEntry* pEntry = GetEntry( m_aMousePos );
224cdf0e10cSrcweir 	if( !pEntry )
225cdf0e10cSrcweir 		return 0;
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 	if( pEntry != Last() )
228cdf0e10cSrcweir 	{
229cdf0e10cSrcweir 		ScrollOutputArea( 1 );
230cdf0e10cSrcweir 		pEntry = GetEntry( m_aMousePos );
231cdf0e10cSrcweir 		Select( pEntry, sal_True );
232cdf0e10cSrcweir //		m_aScrollTimer.Start();
233cdf0e10cSrcweir 	}
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 	return 0;
236cdf0e10cSrcweir }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir //------------------------------------------------------------------------------
StartDrag(sal_Int8,const Point &)239cdf0e10cSrcweir void OTableWindowListBox::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ )
240cdf0e10cSrcweir {
241cdf0e10cSrcweir 	OJoinTableView* pCont = m_pTabWin->getTableView();
242cdf0e10cSrcweir 	if (!pCont->getDesignView()->getController().isReadOnly() && pCont->getDesignView()->getController().isConnected())
243cdf0e10cSrcweir 	{
244cdf0e10cSrcweir 		// #100271# OJ asterix was not allowed to be copied to selection browsebox
245cdf0e10cSrcweir 		sal_Bool bFirstNotAllowed = FirstSelected() == First() && m_pTabWin->GetData()->IsShowAll();
246cdf0e10cSrcweir 		EndSelection();
247cdf0e10cSrcweir 		// create a description of the source
248cdf0e10cSrcweir 		OJoinExchangeData jxdSource(this);
249cdf0e10cSrcweir 		// put it into a exchange object
250cdf0e10cSrcweir 		OJoinExchObj* pJoin = new OJoinExchObj(jxdSource,bFirstNotAllowed);
251cdf0e10cSrcweir 		Reference< XTransferable > xEnsureDelete(pJoin);
252cdf0e10cSrcweir 		pJoin->StartDrag(this, DND_ACTION_LINK, this);
253cdf0e10cSrcweir 	}
254cdf0e10cSrcweir }
255cdf0e10cSrcweir 
256cdf0e10cSrcweir //------------------------------------------------------------------------------
AcceptDrop(const AcceptDropEvent & _rEvt)257cdf0e10cSrcweir sal_Int8 OTableWindowListBox::AcceptDrop( const AcceptDropEvent& _rEvt )
258cdf0e10cSrcweir {
259cdf0e10cSrcweir 	sal_Int8 nDND_Action = DND_ACTION_NONE;
260cdf0e10cSrcweir 	// check the format
261cdf0e10cSrcweir 	if ( !OJoinExchObj::isFormatAvailable(GetDataFlavorExVector(),SOT_FORMATSTR_ID_SBA_TABID) // this means that the first entry is to be draged
262cdf0e10cSrcweir 		&& OJoinExchObj::isFormatAvailable(GetDataFlavorExVector(),SOT_FORMATSTR_ID_SBA_JOIN) )
263cdf0e10cSrcweir 	{	// don't drop into the window if it's the drag source itself
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 		// remove the selection if the dragging operation is leaving the window
267cdf0e10cSrcweir 		if (_rEvt.mbLeaving)
268cdf0e10cSrcweir 			SelectAll(sal_False);
269cdf0e10cSrcweir 		else
270cdf0e10cSrcweir 		{
271cdf0e10cSrcweir 			// hit test
272cdf0e10cSrcweir 			m_aMousePos = _rEvt.maPosPixel;
273cdf0e10cSrcweir 			Size aOutputSize = GetOutputSizePixel();
274cdf0e10cSrcweir 			SvLBoxEntry* pEntry = GetEntry( m_aMousePos );
275cdf0e10cSrcweir 			if( !pEntry )
276cdf0e10cSrcweir 				return DND_ACTION_NONE;
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 			// Scrolling Areas
279cdf0e10cSrcweir 			Rectangle aBottomScrollArea( Point(0, aOutputSize.Height()-LISTBOX_SCROLLING_AREA),
280cdf0e10cSrcweir 										 Size(aOutputSize.Width(), LISTBOX_SCROLLING_AREA) );
281cdf0e10cSrcweir 			Rectangle aTopScrollArea( Point(0,0), Size(aOutputSize.Width(), LISTBOX_SCROLLING_AREA) );
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 			// Wenn Zeiger auf der oberen ScrollingArea steht, nach oben scrollen
284cdf0e10cSrcweir 			if( aBottomScrollArea.IsInside(m_aMousePos) )
285cdf0e10cSrcweir 			{
286cdf0e10cSrcweir 				if( !m_aScrollTimer.IsActive() )
287cdf0e10cSrcweir 				{
288cdf0e10cSrcweir 					m_aScrollTimer.SetTimeoutHdl( LINK(this, OTableWindowListBox, ScrollUpHdl) );
289cdf0e10cSrcweir 					ScrollUpHdl( this );
290cdf0e10cSrcweir 				}
291cdf0e10cSrcweir 			}
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 			// Wenn Zeiger auf der oberen ScrollingArea steht, nach unten scrollen
294cdf0e10cSrcweir 			else if( aTopScrollArea.IsInside(m_aMousePos) )
295cdf0e10cSrcweir 			{
296cdf0e10cSrcweir 				if( !m_aScrollTimer.IsActive() )
297cdf0e10cSrcweir 				{
298cdf0e10cSrcweir 					m_aScrollTimer.SetTimeoutHdl( LINK(this, OTableWindowListBox, ScrollDownHdl) );
299cdf0e10cSrcweir 					ScrollDownHdl( this );
300cdf0e10cSrcweir 				}
301cdf0e10cSrcweir 			}
302cdf0e10cSrcweir 			else
303cdf0e10cSrcweir 			{
304cdf0e10cSrcweir 				if( m_aScrollTimer.IsActive() )
305cdf0e10cSrcweir 					m_aScrollTimer.Stop();
306cdf0e10cSrcweir 			}
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 			// Beim Drag automatisch den richtigen Eintrag selektieren
309cdf0e10cSrcweir 			if ((FirstSelected() != pEntry) || (FirstSelected() && NextSelected(FirstSelected())))
310cdf0e10cSrcweir 				SelectAll(sal_False);
311cdf0e10cSrcweir 			Select(pEntry, sal_True);
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 			// Auf den ersten Eintrag (*) kann nicht gedroppt werden
314cdf0e10cSrcweir 			if(!( m_pTabWin->GetData()->IsShowAll() && (pEntry==First()) ))
315cdf0e10cSrcweir 				nDND_Action = DND_ACTION_LINK;
316cdf0e10cSrcweir 		}
317cdf0e10cSrcweir 	}
318cdf0e10cSrcweir 	return nDND_Action;
319cdf0e10cSrcweir }
320cdf0e10cSrcweir // -----------------------------------------------------------------------------
321cdf0e10cSrcweir 
322cdf0e10cSrcweir //------------------------------------------------------------------------------
323cdf0e10cSrcweir IMPL_LINK( OTableWindowListBox, LookForUiHdl, void *, /*EMPTY_ARG*/)
324cdf0e10cSrcweir {
325cdf0e10cSrcweir 	m_nUiEvent = 0;
326cdf0e10cSrcweir 	m_pTabWin->getTableView()->lookForUiActivities();
327cdf0e10cSrcweir 	return 0L;
328cdf0e10cSrcweir }
329cdf0e10cSrcweir //------------------------------------------------------------------------------
330cdf0e10cSrcweir IMPL_LINK( OTableWindowListBox, DropHdl, void *, /*EMPTY_ARG*/)
331cdf0e10cSrcweir {
332cdf0e10cSrcweir 	// create the connection
333cdf0e10cSrcweir 	m_nDropEvent = 0;
334cdf0e10cSrcweir 	OSL_ENSURE(m_pTabWin,"No TableWindow!");
335cdf0e10cSrcweir 	try
336cdf0e10cSrcweir 	{
337cdf0e10cSrcweir 		OJoinTableView* pCont = m_pTabWin->getTableView();
338cdf0e10cSrcweir 		OSL_ENSURE(pCont,"No QueryTableView!");
339cdf0e10cSrcweir 		pCont->AddConnection(m_aDropInfo.aSource, m_aDropInfo.aDest);
340cdf0e10cSrcweir 	}
341cdf0e10cSrcweir 	catch(const SQLException& e)
342cdf0e10cSrcweir 	{
343cdf0e10cSrcweir 		// remember the exception so that we can show them later when d&d is finished
344cdf0e10cSrcweir 		m_pTabWin->getDesignView()->getController().setErrorOccured(::dbtools::SQLExceptionInfo(e));
345cdf0e10cSrcweir 	}
346cdf0e10cSrcweir 	return 0L;
347cdf0e10cSrcweir }
348cdf0e10cSrcweir //------------------------------------------------------------------------------
ExecuteDrop(const ExecuteDropEvent & _rEvt)349cdf0e10cSrcweir sal_Int8 OTableWindowListBox::ExecuteDrop( const ExecuteDropEvent& _rEvt )
350cdf0e10cSrcweir {
351cdf0e10cSrcweir 	TransferableDataHelper aDropped(_rEvt.maDropEvent.Transferable);
352cdf0e10cSrcweir 	if ( OJoinExchObj::isFormatAvailable(aDropped.GetDataFlavorExVector()))
353cdf0e10cSrcweir 	{	// don't drop into the window if it's the drag source itself
354cdf0e10cSrcweir 		m_aDropInfo.aSource	= OJoinExchangeData(this);
355cdf0e10cSrcweir 		m_aDropInfo.aDest	= OJoinExchObj::GetSourceDescription(_rEvt.maDropEvent.Transferable);
356cdf0e10cSrcweir 
357cdf0e10cSrcweir 		if (m_nDropEvent)
358cdf0e10cSrcweir 			Application::RemoveUserEvent(m_nDropEvent);
359cdf0e10cSrcweir 		m_nDropEvent = Application::PostUserEvent(LINK(this, OTableWindowListBox, DropHdl));
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 		return DND_ACTION_LINK;
362cdf0e10cSrcweir 	}
363cdf0e10cSrcweir 	return DND_ACTION_NONE;
364cdf0e10cSrcweir }
365cdf0e10cSrcweir 
366cdf0e10cSrcweir //------------------------------------------------------------------------------
LoseFocus()367cdf0e10cSrcweir void OTableWindowListBox::LoseFocus()
368cdf0e10cSrcweir {
369cdf0e10cSrcweir 	if(m_pTabWin)
370cdf0e10cSrcweir 		m_pTabWin->setActive(sal_False);
371cdf0e10cSrcweir 	SvTreeListBox::LoseFocus();
372cdf0e10cSrcweir }
373cdf0e10cSrcweir 
374cdf0e10cSrcweir //------------------------------------------------------------------------------
GetFocus()375cdf0e10cSrcweir void OTableWindowListBox::GetFocus()
376cdf0e10cSrcweir {
377cdf0e10cSrcweir 	if(m_pTabWin)
378cdf0e10cSrcweir 		m_pTabWin->setActive();
379cdf0e10cSrcweir 
380cdf0e10cSrcweir 	if (GetCurEntry() != NULL)
381cdf0e10cSrcweir 	{
382cdf0e10cSrcweir 		if ( GetSelectionCount() == 0 || GetCurEntry() != FirstSelected() )
383cdf0e10cSrcweir 		{
384cdf0e10cSrcweir 			if ( FirstSelected() )
385cdf0e10cSrcweir 				Select(FirstSelected(), sal_False);
386cdf0e10cSrcweir 			Select(GetCurEntry(), sal_True);
387cdf0e10cSrcweir 		}
388cdf0e10cSrcweir 		else
389cdf0e10cSrcweir 			ShowFocusRect(FirstSelected());
390cdf0e10cSrcweir 	}
391cdf0e10cSrcweir 	SvTreeListBox::GetFocus();
392cdf0e10cSrcweir }
393cdf0e10cSrcweir 
394cdf0e10cSrcweir //------------------------------------------------------------------------------
395cdf0e10cSrcweir IMPL_LINK( OTableWindowListBox, OnDoubleClick, SvTreeListBox *, /*pBox*/ )
396cdf0e10cSrcweir {
397cdf0e10cSrcweir 	// meinem Elter Bescheid sagen
398cdf0e10cSrcweir 	Window* pParent = Window::GetParent();
399cdf0e10cSrcweir 	DBG_ASSERT(pParent != NULL, "OTableWindowListBox::OnDoubleClick : habe kein Parent !");
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 	static_cast<OTableWindow*>(pParent)->OnEntryDoubleClicked(GetHdlEntry());
402cdf0e10cSrcweir 
403cdf0e10cSrcweir 	return 0;
404cdf0e10cSrcweir }
405cdf0e10cSrcweir // -----------------------------------------------------------------------------
Command(const CommandEvent & rEvt)406cdf0e10cSrcweir void OTableWindowListBox::Command(const CommandEvent& rEvt)
407cdf0e10cSrcweir {
408cdf0e10cSrcweir 	switch (rEvt.GetCommand())
409cdf0e10cSrcweir 	{
410cdf0e10cSrcweir 		case COMMAND_CONTEXTMENU:
411cdf0e10cSrcweir 		{
412cdf0e10cSrcweir 			static_cast<OTableWindow*>(Window::GetParent())->Command(rEvt);
413cdf0e10cSrcweir 			break;
414cdf0e10cSrcweir 		}
415cdf0e10cSrcweir 		default:
416cdf0e10cSrcweir 			SvTreeListBox::Command(rEvt);
417cdf0e10cSrcweir 	}
418cdf0e10cSrcweir }
419cdf0e10cSrcweir // -----------------------------------------------------------------------------
420