Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include "JoinTableView.hxx"
21 : : #include <osl/diagnose.h>
22 : : #include "querycontroller.hxx"
23 : : #include "JoinDesignView.hxx"
24 : : #include "dbu_qry.hrc"
25 : : #include "TableWindow.hxx"
26 : : #include "TableWindowListBox.hxx"
27 : : #include "TableConnection.hxx"
28 : : #include "TableConnectionData.hxx"
29 : : #include "ConnectionLine.hxx"
30 : : #include "ConnectionLineData.hxx"
31 : : #include "browserids.hxx"
32 : : #include <svl/urlbmk.hxx>
33 : : #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
34 : : #include "QueryMoveTabWinUndoAct.hxx"
35 : : #include "QuerySizeTabWinUndoAct.hxx"
36 : : #include <vcl/svapp.hxx>
37 : : #include "TableWindowData.hxx"
38 : : #include "JAccess.hxx"
39 : : #include <com/sun/star/accessibility/XAccessible.hpp>
40 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
41 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
42 : : #include "UITools.hxx"
43 : : #include <cppuhelper/exc_hlp.hxx>
44 : : #include <tools/diagnose_ex.h>
45 : : #include <boost/bind.hpp>
46 : : #include <algorithm>
47 : : #include <functional>
48 : :
49 : : using namespace dbaui;
50 : : using namespace ::com::sun::star::uno;
51 : : using namespace ::com::sun::star::sdbc;
52 : : using namespace ::com::sun::star::accessibility;
53 : : using namespace ::com::sun::star::container;
54 : : using namespace ::com::sun::star::lang;
55 : :
56 : : #define LINE_SIZE 50
57 : : ////////////////////////////////////////////////////////////////
58 : : // Konstanten fuer das Fensterlayout
59 : : #define TABWIN_SPACING_X 17
60 : : #define TABWIN_SPACING_Y 17
61 : :
62 : : #define TABWIN_WIDTH_STD 120
63 : : #define TABWIN_HEIGHT_STD 120
64 : :
65 : : DBG_NAME(OScrollWindowHelper)
66 : 0 : OScrollWindowHelper::OScrollWindowHelper( Window* pParent) : Window( pParent)
67 : : ,m_aHScrollBar( this, WB_HSCROLL|WB_REPEAT|WB_DRAG )
68 : : ,m_aVScrollBar( this, WB_VSCROLL|WB_REPEAT|WB_DRAG )
69 [ # # ]: 0 : ,m_pCornerWindow(new ScrollBarBox(this, WB_3DLOOK))
70 [ # # ][ # # ]: 0 : ,m_pTableView(NULL)
[ # # ]
71 : : {
72 : : DBG_CTOR(OScrollWindowHelper,NULL);
73 : :
74 : : //////////////////////////////////////////////////////////////////////
75 : : // ScrollBars
76 : :
77 [ # # ]: 0 : GetHScrollBar()->SetRange( Range(0, 1000) );
78 [ # # ]: 0 : GetVScrollBar()->SetRange( Range(0, 1000) );
79 : :
80 : 0 : GetHScrollBar()->SetLineSize( LINE_SIZE );
81 : 0 : GetVScrollBar()->SetLineSize( LINE_SIZE );
82 : :
83 [ # # ]: 0 : GetHScrollBar()->Show();
84 [ # # ]: 0 : GetVScrollBar()->Show();
85 [ # # ]: 0 : m_pCornerWindow->Show();
86 : :
87 : : // normally we should be SCROLL_PANE
88 [ # # ]: 0 : SetAccessibleRole(AccessibleRole::SCROLL_PANE);
89 : 0 : }
90 : :
91 : : // -----------------------------------------------------------------------------
92 [ # # ][ # # ]: 0 : OScrollWindowHelper::~OScrollWindowHelper()
93 : : {
94 : : DBG_DTOR(OScrollWindowHelper,NULL);
95 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
96 : 0 : ::std::auto_ptr<Window> aTemp(m_pCornerWindow);
97 : : SAL_WNODEPRECATED_DECLARATIONS_POP
98 : 0 : m_pCornerWindow = NULL;
99 [ # # ]: 0 : m_pTableView = NULL;
100 [ # # ]: 0 : }
101 : :
102 : : // -----------------------------------------------------------------------------
103 : 0 : void OScrollWindowHelper::setTableView(OJoinTableView* _pTableView)
104 : : {
105 : 0 : m_pTableView = _pTableView;
106 : : //////////////////////////////////////////////////////////////////////
107 : : // ScrollBars
108 : 0 : GetHScrollBar()->SetScrollHdl( LINK(m_pTableView, OJoinTableView, ScrollHdl) );
109 : 0 : GetVScrollBar()->SetScrollHdl( LINK(m_pTableView, OJoinTableView, ScrollHdl) );
110 : 0 : }
111 : : // -----------------------------------------------------------------------------
112 : 0 : void OScrollWindowHelper::resetRange(const Point& _aSize)
113 : : {
114 [ # # ]: 0 : Point aPos = PixelToLogic(_aSize);
115 [ # # ]: 0 : GetHScrollBar()->SetRange( Range(0, aPos.X() + TABWIN_SPACING_X) );
116 [ # # ]: 0 : GetVScrollBar()->SetRange( Range(0, aPos.Y() + TABWIN_SPACING_Y) );
117 : 0 : }
118 : : //------------------------------------------------------------------------------
119 : 0 : void OScrollWindowHelper::Resize()
120 : : {
121 [ # # ]: 0 : Window::Resize();
122 : :
123 : 0 : Size aTotalOutputSize = GetOutputSizePixel();
124 [ # # ]: 0 : long nHScrollHeight = GetHScrollBar()->GetSizePixel().Height();
125 [ # # ]: 0 : long nVScrollWidth = GetVScrollBar()->GetSizePixel().Width();
126 : :
127 : 0 : GetHScrollBar()->SetPosSizePixel(
128 : 0 : Point( 0, aTotalOutputSize.Height()-nHScrollHeight ),
129 : 0 : Size( aTotalOutputSize.Width()-nVScrollWidth, nHScrollHeight )
130 [ # # ]: 0 : );
131 : :
132 : 0 : GetVScrollBar()->SetPosSizePixel(
133 : 0 : Point( aTotalOutputSize.Width()-nVScrollWidth, 0 ),
134 : 0 : Size( nVScrollWidth, aTotalOutputSize.Height()-nHScrollHeight )
135 [ # # ]: 0 : );
136 : :
137 : : m_pCornerWindow->SetPosSizePixel(
138 : 0 : Point( aTotalOutputSize.Width() - nVScrollWidth, aTotalOutputSize.Height() - nHScrollHeight),
139 : : Size( nVScrollWidth, nHScrollHeight )
140 [ # # ]: 0 : );
141 : :
142 : 0 : GetHScrollBar()->SetPageSize( aTotalOutputSize.Width() );
143 [ # # ]: 0 : GetHScrollBar()->SetVisibleSize( aTotalOutputSize.Width() );
144 : :
145 : 0 : GetVScrollBar()->SetPageSize( aTotalOutputSize.Height() );
146 [ # # ]: 0 : GetVScrollBar()->SetVisibleSize( aTotalOutputSize.Height() );
147 : :
148 : : // adjust the ranges of the scrollbars if neccessary
149 : 0 : long lRange = GetHScrollBar()->GetRange().Max() - GetHScrollBar()->GetRange().Min();
150 [ # # ]: 0 : if (m_pTableView->GetScrollOffset().X() + aTotalOutputSize.Width() > lRange)
151 [ # # ]: 0 : GetHScrollBar()->SetRangeMax(m_pTableView->GetScrollOffset().X() + aTotalOutputSize.Width() + GetHScrollBar()->GetRange().Min());
152 : :
153 : 0 : lRange = GetVScrollBar()->GetRange().Max() - GetVScrollBar()->GetRange().Min();
154 [ # # ]: 0 : if (m_pTableView->GetScrollOffset().Y() + aTotalOutputSize.Height() > lRange)
155 [ # # ]: 0 : GetVScrollBar()->SetRangeMax(m_pTableView->GetScrollOffset().Y() + aTotalOutputSize.Height() + GetVScrollBar()->GetRange().Min());
156 : :
157 [ # # ]: 0 : m_pTableView->SetPosSizePixel(Point( 0, 0 ),Size( aTotalOutputSize.Width()-nVScrollWidth, aTotalOutputSize.Height()-nHScrollHeight ));
158 : 0 : }
159 : : // -----------------------------------------------------------------------------
160 : : // -----------------------------------------------------------------------------
161 : : //==================================================================
162 : : // class OJoinTableView
163 : : //==================================================================
164 : :
165 : : DBG_NAME(OJoinTableView);
166 : : //------------------------------------------------------------------------------
167 : 0 : OJoinTableView::OJoinTableView( Window* pParent, OJoinDesignView* pView )
168 : : :Window( pParent,WB_BORDER )
169 : : ,DropTargetHelper(this)
170 : : ,m_aDragOffset( Point(0,0) )
171 : : ,m_aScrollOffset( Point(0,0) )
172 : : ,m_pDragWin( NULL )
173 : : ,m_pSizingWin( NULL )
174 : : ,m_pSelectedConn( NULL )
175 : : ,m_bTrackingInitiallyMoved(sal_False)
176 : : ,m_pLastFocusTabWin(NULL)
177 : : ,m_pView( pView )
178 [ # # ][ # # ]: 0 : ,m_pAccessible(NULL)
[ # # ][ # # ]
[ # # ][ # # ]
179 : : {
180 : : DBG_CTOR(OJoinTableView,NULL);
181 [ # # ]: 0 : SetSizePixel( Size(1000, 1000) );
182 : :
183 [ # # ]: 0 : InitColors();
184 : :
185 [ # # ]: 0 : m_aDragScrollTimer.SetTimeoutHdl(LINK(this, OJoinTableView, OnDragScrollTimer));
186 : 0 : }
187 : :
188 : : //------------------------------------------------------------------------------
189 [ # # ][ # # ]: 0 : OJoinTableView::~OJoinTableView()
190 : : {
191 : : DBG_DTOR(OJoinTableView,NULL);
192 [ # # ]: 0 : if( m_pAccessible )
193 : : {
194 [ # # ]: 0 : m_pAccessible->clearTableView();
195 : 0 : m_pAccessible = NULL;
196 : : }
197 : : //////////////////////////////////////////////////////////////////////
198 : : // Listen loeschen
199 [ # # ]: 0 : clearLayoutInformation();
200 [ # # ]: 0 : }
201 : : //------------------------------------------------------------------------------
202 : 0 : IMPL_LINK( OJoinTableView, ScrollHdl, ScrollBar*, pScrollBar )
203 : : {
204 : : //////////////////////////////////////////////////////////////////////
205 : : // Alle Fenster verschieben
206 : 0 : ScrollPane( pScrollBar->GetDelta(), (pScrollBar == GetHScrollBar()), sal_False );
207 : :
208 : 0 : return 0;
209 : : }
210 : : //------------------------------------------------------------------------------
211 : 0 : void OJoinTableView::Resize()
212 : : {
213 : : DBG_CHKTHIS(OJoinTableView,NULL);
214 [ # # ]: 0 : Window::Resize();
215 [ # # ]: 0 : m_aOutputSize = GetSizePixel();
216 : :
217 : : // tab win positions may not be up-to-date
218 [ # # ]: 0 : if (m_aTableMap.empty())
219 : : // no tab wins ...
220 : : return;
221 : :
222 : : // we have at least one table so resize it
223 [ # # ]: 0 : m_aScrollOffset.X() = GetHScrollBar()->GetThumbPos();
224 [ # # ]: 0 : m_aScrollOffset.Y() = GetVScrollBar()->GetThumbPos();
225 : :
226 : 0 : OTableWindow* pCheck = m_aTableMap.begin()->second;
227 [ # # ]: 0 : Point aRealPos = pCheck->GetPosPixel();
228 [ # # ][ # # ]: 0 : Point aAssumedPos = pCheck->GetData()->GetPosition() - GetScrollOffset();
229 : :
230 [ # # ]: 0 : if (aRealPos == aAssumedPos)
231 : : // all ok
232 : : return;
233 : :
234 : 0 : OTableWindowMapIterator aIter = m_aTableMap.begin();
235 : 0 : OTableWindowMapIterator aEnd = m_aTableMap.end();
236 [ # # ]: 0 : for(;aIter != aEnd;++aIter)
237 : : {
238 : 0 : OTableWindow* pCurrent = aIter->second;
239 [ # # ][ # # ]: 0 : Point aPos(pCurrent->GetData()->GetPosition() - GetScrollOffset());
240 [ # # ]: 0 : pCurrent->SetPosPixel(aPos);
241 : : }
242 : : }
243 : : //------------------------------------------------------------------------------
244 : 0 : sal_uLong OJoinTableView::GetTabWinCount()
245 : : {
246 : : DBG_CHKTHIS(OJoinTableView,NULL);
247 : 0 : return m_aTableMap.size();
248 : : }
249 : :
250 : : //------------------------------------------------------------------------------
251 : 0 : bool OJoinTableView::RemoveConnection( OTableConnection* _pConn,sal_Bool _bDelete )
252 : : {
253 : : DBG_CHKTHIS(OJoinTableView,NULL);
254 : 0 : DeselectConn(_pConn);
255 : :
256 : : // to force a redraw
257 : 0 : _pConn->InvalidateConnection();
258 : :
259 [ # # ]: 0 : m_pView->getController().removeConnectionData( _pConn->GetData() );
260 : :
261 : : m_vTableConnection.erase(
262 : 0 : ::std::find(m_vTableConnection.begin(),m_vTableConnection.end(),_pConn) );
263 : :
264 : 0 : modified();
265 [ # # ]: 0 : if ( m_pAccessible )
266 : : m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
267 : : makeAny(_pConn->GetAccessible()),
268 [ # # ][ # # ]: 0 : Any());
[ # # ]
269 [ # # ]: 0 : if ( _bDelete )
270 : : {
271 [ # # ]: 0 : delete _pConn;
272 : : }
273 : :
274 : 0 : return true;
275 : : }
276 : :
277 : : //------------------------------------------------------------------------
278 : 0 : OTableWindow* OJoinTableView::GetTabWindow( const String& rName )
279 : : {
280 : : DBG_CHKTHIS(OJoinTableView,NULL);
281 [ # # ][ # # ]: 0 : OTableWindowMapIterator aIter = m_aTableMap.find(rName);
282 : :
283 [ # # ]: 0 : return aIter == m_aTableMap.end() ? NULL : aIter->second;
284 : : }
285 : : // -----------------------------------------------------------------------------
286 : 0 : TTableWindowData::value_type OJoinTableView::createTableWindowData(const ::rtl::OUString& _rComposedName
287 : : ,const ::rtl::OUString& _sTableName
288 : : ,const ::rtl::OUString& _rWinName)
289 : : {
290 : 0 : TTableWindowData::value_type pData( CreateImpl(_rComposedName, _sTableName,_rWinName) );
291 : 0 : OJoinDesignView* pParent = getDesignView();
292 : : try
293 : : {
294 [ # # ][ # # ]: 0 : if ( !pData->init(pParent->getController().getConnection(),allowQueries()) )
[ # # ][ # # ]
295 : : {
296 [ # # ]: 0 : if ( pData->isValid() )
297 [ # # ]: 0 : onNoColumns_throw();
298 : : else
299 [ # # ]: 0 : pData.reset();
300 : : }
301 : : }
302 [ # # ]: 0 : catch ( const SQLException& )
303 : : {
304 : : ::dbaui::showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ),
305 [ # # # # : 0 : pParent, pParent->getController().getORB() );
# # # # #
# ]
306 : : }
307 [ # # # # : 0 : catch( const WrappedTargetException& e )
# # ]
308 : : {
309 [ # # ]: 0 : SQLException aSql;
310 [ # # # # ]: 0 : if ( e.TargetException >>= aSql )
311 [ # # # # : 0 : ::dbaui::showError( ::dbtools::SQLExceptionInfo( aSql ), pParent, pParent->getController().getORB() );
# # # # #
# ]
312 : : }
313 [ # # ]: 0 : catch( const Exception& )
314 : : {
315 : : DBG_UNHANDLED_EXCEPTION();
316 : : }
317 : 0 : return pData;
318 : : }
319 : : // -----------------------------------------------------------------------------
320 : 0 : OTableWindowData* OJoinTableView::CreateImpl(const ::rtl::OUString& _rComposedName
321 : : ,const ::rtl::OUString& _sTableName
322 : : ,const ::rtl::OUString& _rWinName)
323 : : {
324 [ # # ][ # # ]: 0 : return new OTableWindowData( NULL,_rComposedName,_sTableName, _rWinName );
325 : : }
326 : : //------------------------------------------------------------------------------
327 : 0 : void OJoinTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::rtl::OUString& rWinName, sal_Bool /*bNewTable*/)
328 : : {
329 : : DBG_CHKTHIS(OJoinTableView,NULL);
330 : : OSL_ENSURE(!_rComposedName.isEmpty(),"There must be a table name supplied!");
331 : :
332 [ # # ]: 0 : TTableWindowData::value_type pNewTabWinData(createTableWindowData( _rComposedName, rWinName,rWinName ));
333 : :
334 : : //////////////////////////////////////////////////////////////////
335 : : // Neues Fenster in Fensterliste eintragen
336 [ # # ]: 0 : OTableWindow* pNewTabWin = createWindow( pNewTabWinData );
337 [ # # ][ # # ]: 0 : if ( pNewTabWin->Init() )
338 : : {
339 [ # # ]: 0 : m_pView->getController().getTableWindowData()->push_back( pNewTabWinData);
340 : : // when we already have a table with this name insert the full qualified one instead
341 [ # # ][ # # ]: 0 : if(m_aTableMap.find(rWinName) != m_aTableMap.end())
342 [ # # ]: 0 : m_aTableMap[_rComposedName] = pNewTabWin;
343 : : else
344 [ # # ]: 0 : m_aTableMap[rWinName] = pNewTabWin;
345 : :
346 [ # # ]: 0 : SetDefaultTabWinPosSize( pNewTabWin );
347 [ # # ]: 0 : pNewTabWin->Show();
348 : :
349 [ # # ]: 0 : modified();
350 [ # # ]: 0 : if ( m_pAccessible )
351 : : m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
352 : : Any(),
353 [ # # ][ # # ]: 0 : makeAny(pNewTabWin->GetAccessible()));
[ # # ]
354 : : }
355 : : else
356 : : {
357 [ # # ]: 0 : pNewTabWin->clearListBox();
358 [ # # ][ # # ]: 0 : delete pNewTabWin;
359 [ # # ]: 0 : }
360 : 0 : }
361 : :
362 : : //------------------------------------------------------------------------------
363 : 0 : void OJoinTableView::RemoveTabWin( OTableWindow* pTabWin )
364 : : {
365 : : DBG_CHKTHIS(OJoinTableView,NULL);
366 : : //////////////////////////////////////////////////////////////////////
367 : : // first delete all connections of this window to others
368 : 0 : bool bRemove = true;
369 [ # # ]: 0 : TTableWindowData::value_type pData = pTabWin->GetData();
370 : 0 : sal_Int32 nCount = m_vTableConnection.size();
371 : 0 : ::std::vector<OTableConnection*>::reverse_iterator aIter = m_vTableConnection.rbegin();
372 [ # # ][ # # ]: 0 : while(aIter != m_vTableConnection.rend() && bRemove)
[ # # ][ # # ]
[ # # # # ]
373 : : {
374 [ # # ]: 0 : OTableConnection* pTabConn = (*aIter);
375 [ # # ][ # # ]: 0 : if(
[ # # ]
376 [ # # ][ # # ]: 0 : ( pData == pTabConn->GetData()->getReferencingTable()) ||
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
377 [ # # ][ # # ]: 0 : ( pData == pTabConn->GetData()->getReferencedTable())
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
378 : : )
379 : : {
380 [ # # ]: 0 : bRemove = RemoveConnection( pTabConn ,sal_True);
381 : 0 : aIter = m_vTableConnection.rbegin();
382 : : }
383 : : else
384 [ # # ]: 0 : ++aIter;
385 : : }
386 : :
387 : : //////////////////////////////////////////////////////////////////////
388 : : // then delete the window itself
389 [ # # ]: 0 : if ( bRemove )
390 : : {
391 [ # # ]: 0 : if ( m_pAccessible )
392 : : m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
393 : : makeAny(pTabWin->GetAccessible()),Any()
394 [ # # ][ # # ]: 0 : );
[ # # ]
395 : :
396 [ # # ]: 0 : pTabWin->Hide();
397 : 0 : OJoinController& rController = m_pView->getController();
398 [ # # ]: 0 : TTableWindowData::iterator aFind = ::std::find(rController.getTableWindowData()->begin(),rController.getTableWindowData()->end(),pData);
399 [ # # ][ # # ]: 0 : if(aFind != rController.getTableWindowData()->end())
400 : : {
401 [ # # ]: 0 : rController.getTableWindowData()->erase(aFind);
402 [ # # ]: 0 : rController.setModified(sal_True);
403 : : }
404 : :
405 [ # # ][ # # ]: 0 : String aWinName = pTabWin->GetWinName();
406 [ # # ][ # # ]: 0 : if(m_aTableMap.find(aWinName) != m_aTableMap.end())
[ # # ]
407 [ # # ][ # # ]: 0 : m_aTableMap.erase( aWinName );
408 : : else
409 [ # # ][ # # ]: 0 : m_aTableMap.erase( pTabWin->GetComposedName() );
410 : :
411 [ # # ]: 0 : if (pTabWin == m_pLastFocusTabWin)
412 : 0 : m_pLastFocusTabWin = NULL;
413 : :
414 [ # # ]: 0 : pTabWin->clearListBox();
415 [ # # ][ # # ]: 0 : delete pTabWin;
[ # # ]
416 : :
417 : : }
418 [ # # ]: 0 : if ( (sal_Int32)m_vTableConnection.size() < (nCount-1) ) // if some connections could be removed
419 [ # # ][ # # ]: 0 : modified();
420 : 0 : }
421 : : namespace
422 : : {
423 : : // -----------------------------------------------------------------------------
424 : 0 : sal_Bool isScrollAllowed( OJoinTableView* _pView,long nDelta, sal_Bool bHoriz)
425 : : {
426 : : //////////////////////////////////////////////////////////////////////
427 : : // adjust ScrollBar-Positions
428 : 0 : ScrollBar* pBar = _pView->GetVScrollBar();
429 [ # # ]: 0 : if( bHoriz )
430 : 0 : pBar = _pView->GetHScrollBar();
431 : :
432 : 0 : long nOldThumbPos = pBar->GetThumbPos();
433 : 0 : long nNewThumbPos = nOldThumbPos + nDelta;
434 [ # # ]: 0 : if( nNewThumbPos < 0 )
435 : 0 : nNewThumbPos = 0;
436 [ # # ]: 0 : else if( nNewThumbPos > pBar->GetRangeMax() )
437 : 0 : nNewThumbPos = pBar->GetRangeMax();
438 : :
439 [ # # ]: 0 : if ( bHoriz )
440 : : {
441 [ # # ]: 0 : if( nNewThumbPos == _pView->GetScrollOffset().X() )
442 : 0 : return sal_False;
443 : : }
444 [ # # ]: 0 : else if ( nNewThumbPos == _pView->GetScrollOffset().Y() )
445 : 0 : return sal_False;
446 : :
447 : 0 : return sal_True;
448 : : }
449 : : // -----------------------------------------------------------------------------
450 : 0 : sal_Bool getMovementImpl(OJoinTableView* _pView,const Point& _rPoint,const Size& _rSize,long& _nScrollX,long& _nScrollY)
451 : : {
452 : 0 : _nScrollY = _nScrollX = 0;
453 : : // data about the tab win
454 : 0 : Point aUpperLeft = _rPoint;
455 : : // normalize with respect to visibility
456 : 0 : aUpperLeft -= _pView->GetScrollOffset();
457 : 0 : Point aLowerRight(aUpperLeft.X() + _rSize.Width(), aUpperLeft.Y() + _rSize.Height());
458 : :
459 : : // data about ourself
460 : 0 : Size aSize = _pView->getRealOutputSize(); //GetOutputSizePixel();
461 : :
462 : 0 : sal_Bool bVisbile = sal_True;
463 [ # # ][ # # ]: 0 : sal_Bool bFitsHor = (aUpperLeft.X() >= 0) && (aLowerRight.X() <= aSize.Width());
464 [ # # ][ # # ]: 0 : sal_Bool bFitsVert= (aUpperLeft.Y() >= 0) && (aLowerRight.Y() <= aSize.Height());
465 [ # # ][ # # ]: 0 : if (!bFitsHor || !bFitsVert)
466 : : {
467 [ # # ]: 0 : if (!bFitsHor)
468 : : {
469 : : // ensure the visibility of the right border
470 [ # # ]: 0 : if ( aLowerRight.X() > aSize.Width() )
471 : 0 : _nScrollX = aLowerRight.X() - aSize.Width() + TABWIN_SPACING_X;
472 : :
473 : : // ensure the visibility of the left border (higher priority)
474 [ # # ]: 0 : if ( aUpperLeft.X() < 0 )
475 : 0 : _nScrollX = aUpperLeft.X() - TABWIN_SPACING_X;
476 : : }
477 : :
478 [ # # ]: 0 : if (!bFitsVert)
479 : : {
480 : : // lower border
481 [ # # ]: 0 : if ( aLowerRight.Y() > aSize.Height() )
482 : 0 : _nScrollY = aLowerRight.Y() - aSize.Height() + TABWIN_SPACING_Y;
483 : : // upper border
484 [ # # ]: 0 : if ( aUpperLeft.Y() < 0 )
485 : 0 : _nScrollY = aUpperLeft.Y() - TABWIN_SPACING_Y;
486 : : }
487 : :
488 [ # # ]: 0 : if ( _nScrollX ) // aSize.Width() > _rSize.Width() &&
489 [ # # ]: 0 : bVisbile = isScrollAllowed(_pView,_nScrollX, sal_True);
490 : :
491 [ # # ]: 0 : if ( _nScrollY ) // aSize.Height() > _rSize.Height() &&
492 [ # # ][ # # ]: 0 : bVisbile = bVisbile && isScrollAllowed(_pView,_nScrollY, sal_False);
[ # # ]
493 : :
494 [ # # ]: 0 : if ( bVisbile )
495 : : {
496 [ # # ]: 0 : sal_Int32 nHRangeMax = _pView->GetHScrollBar()->GetRangeMax();
497 [ # # ]: 0 : sal_Int32 nVRangeMax = _pView->GetVScrollBar()->GetRangeMax();
498 : :
499 [ # # ][ # # ]: 0 : if ( aSize.Width() + _pView->GetHScrollBar()->GetThumbPos() + _nScrollX > nHRangeMax )
500 : 0 : bVisbile = sal_False;
501 [ # # ][ # # ]: 0 : if ( bVisbile && aSize.Height() + _pView->GetVScrollBar()->GetThumbPos() + _nScrollY > nVRangeMax )
[ # # ][ # # ]
502 : 0 : bVisbile = sal_False;
503 : : }
504 : : }
505 : :
506 : :
507 : 0 : return bVisbile;
508 : : }
509 : : } // end of ano namespace
510 : : // -----------------------------------------------------------------------------
511 : 0 : sal_Bool OJoinTableView::isMovementAllowed(const Point& _rPoint,const Size& _rSize)
512 : : {
513 : : long nX,nY;
514 [ # # ]: 0 : return getMovementImpl(this,_rPoint,_rSize,nX,nY);
515 : : }
516 : : //------------------------------------------------------------------------------
517 : 0 : void OJoinTableView::EnsureVisible(const OTableWindow* _pWin)
518 : : {
519 : : // data about the tab win
520 [ # # ]: 0 : TTableWindowData::value_type pData = _pWin->GetData();
521 [ # # ]: 0 : EnsureVisible( pData->GetPosition() , pData->GetSize());
522 [ # # ][ # # ]: 0 : Invalidate(INVALIDATE_NOCHILDREN);
523 : 0 : }
524 : : //------------------------------------------------------------------------------
525 : 0 : void OJoinTableView::EnsureVisible(const Point& _rPoint,const Size& _rSize)
526 : : {
527 : : long nScrollX,nScrollY;
528 : :
529 [ # # ][ # # ]: 0 : if ( getMovementImpl(this,_rPoint,_rSize,nScrollX,nScrollY) )
530 : : {
531 : 0 : sal_Bool bVisbile = sal_True;
532 [ # # ]: 0 : if (nScrollX)
533 [ # # ]: 0 : bVisbile = ScrollPane(nScrollX, sal_True, sal_True);
534 : :
535 [ # # ]: 0 : if (nScrollY)
536 [ # # ][ # # ]: 0 : bVisbile = bVisbile && ScrollPane(nScrollY, sal_False, sal_True);
[ # # ]
537 : : }
538 : 0 : }
539 : :
540 : : //------------------------------------------------------------------------------
541 : 0 : void OJoinTableView::SetDefaultTabWinPosSize( OTableWindow* pTabWin )
542 : : {
543 : : DBG_CHKTHIS(OJoinTableView,NULL);
544 : : //////////////////////////////////////////////////////////////////
545 : : // Position bestimmen:
546 : : // Das Fenster wird in Zeilen der Hoehe TABWIN_SPACING_Y+TABWIN_HEIGTH_STD aufgeteilt.
547 : : // Dann wird fuer jede Zeile geprueft, ob noch Platz fuer ein weiteres Fenster ist.
548 : : // Wenn kein Platz ist, wird die naechste Zeile ueberprueft.
549 [ # # ]: 0 : Size aOutSize = GetSizePixel();
550 : 0 : Point aNewPos( 0,0 );
551 : 0 : sal_uInt16 nRow = 0;
552 : 0 : sal_Bool bEnd = sal_False;
553 [ # # ]: 0 : while( !bEnd )
554 : : {
555 : : //////////////////////////////////////////////////////////////////
556 : : // Neue Position auf Zeilenbeginn setzen
557 : 0 : aNewPos.X() = TABWIN_SPACING_X;
558 : 0 : aNewPos.Y() = (nRow+1) * TABWIN_SPACING_Y;
559 : :
560 : : //////////////////////////////////////////////////////////////////
561 : : // Rectangle fuer die jeweilige Zeile bestimmen
562 [ # # ]: 0 : Rectangle aRowRect( Point(0,0), aOutSize );
563 : 0 : aRowRect.Top() = nRow * ( TABWIN_SPACING_Y + TABWIN_HEIGHT_STD );
564 : 0 : aRowRect.Bottom() = (nRow+1) * ( TABWIN_SPACING_Y + TABWIN_HEIGHT_STD );
565 : :
566 : : //////////////////////////////////////////////////////////////////
567 : : // Belegte Bereiche dieser Zeile pruefen
568 : : OTableWindow* pOtherTabWin;
569 : 0 : OTableWindowMapIterator aIter = m_aTableMap.begin();
570 : 0 : OTableWindowMapIterator aEnd = m_aTableMap.end();
571 [ # # ]: 0 : for(;aIter != aEnd;++aIter)
572 : : {
573 : 0 : pOtherTabWin = aIter->second;
574 [ # # ][ # # ]: 0 : Rectangle aOtherTabWinRect( pOtherTabWin->GetPosPixel(), pOtherTabWin->GetSizePixel() );
[ # # ]
575 : :
576 [ # # ][ # # : 0 : if(
# # # # #
# ]
577 : 0 : ( (aOtherTabWinRect.Top()>aRowRect.Top()) && (aOtherTabWinRect.Top()<aRowRect.Bottom()) ) ||
578 : 0 : ( (aOtherTabWinRect.Bottom()>aRowRect.Top()) && (aOtherTabWinRect.Bottom()<aRowRect.Bottom()) )
579 : : )
580 : : {
581 : : //////////////////////////////////////////////////////////////////
582 : : // TabWin liegt in der Zeile
583 [ # # ]: 0 : if( aOtherTabWinRect.Right()>aNewPos.X() )
584 : 0 : aNewPos.X() = aOtherTabWinRect.Right() + TABWIN_SPACING_X;
585 : : }
586 : : }
587 : :
588 : : //////////////////////////////////////////////////////////////////
589 : : // Ist in dieser Zeile noch Platz?
590 [ # # ]: 0 : if( (aNewPos.X()+TABWIN_WIDTH_STD)<aRowRect.Right() )
591 : : {
592 : 0 : aNewPos.Y() = aRowRect.Top() + TABWIN_SPACING_Y;
593 : 0 : bEnd = sal_True;
594 : : }
595 : : else
596 : : {
597 [ # # ][ # # ]: 0 : if( (aRowRect.Bottom()+aRowRect.GetHeight()) > aOutSize.Height() )
598 : : {
599 : : // insert it in the first row
600 : 0 : sal_Int32 nCount = m_aTableMap.size() % (nRow+1);
601 : 0 : ++nCount;
602 [ # # ]: 0 : aNewPos.Y() = nCount * TABWIN_SPACING_Y + (nCount-1)*CalcZoom(TABWIN_HEIGHT_STD);
603 : 0 : bEnd = sal_True;
604 : : }
605 : : else
606 : 0 : nRow++;
607 : :
608 : : }
609 : : }
610 : :
611 : : //////////////////////////////////////////////////////////////////
612 : : // Groesse bestimmen
613 [ # # ][ # # ]: 0 : Size aNewSize( CalcZoom(TABWIN_WIDTH_STD), CalcZoom(TABWIN_HEIGHT_STD) );
614 : :
615 : : // check if the new position in inside the scrollbars ranges
616 : 0 : Point aBottom(aNewPos);
617 : 0 : aBottom.X() += aNewSize.Width();
618 : 0 : aBottom.Y() += aNewSize.Height();
619 : :
620 [ # # ][ # # ]: 0 : if(!GetHScrollBar()->GetRange().IsInside(aBottom.X()))
621 [ # # ][ # # ]: 0 : GetHScrollBar()->SetRange( Range(0, aBottom.X()) );
622 [ # # ][ # # ]: 0 : if(!GetVScrollBar()->GetRange().IsInside(aBottom.Y()))
623 [ # # ][ # # ]: 0 : GetVScrollBar()->SetRange( Range(0, aBottom.Y()) );
624 : :
625 [ # # ]: 0 : pTabWin->SetPosSizePixel( aNewPos, aNewSize );
626 : 0 : }
627 : :
628 : : //------------------------------------------------------------------------------
629 : 0 : void OJoinTableView::DataChanged(const DataChangedEvent& rDCEvt)
630 : : {
631 : : DBG_CHKTHIS(OJoinTableView,NULL);
632 [ # # ]: 0 : if (rDCEvt.GetType() == DATACHANGED_SETTINGS)
633 : : {
634 : : // nehmen wir den worst-case an : die Farben haben sich geaendert, also
635 : : // mich anpassen
636 : 0 : InitColors();
637 : 0 : Invalidate(INVALIDATE_NOCHILDREN);
638 : : // durch das Invalidate werden auch die Connections neu gezeichnet, so dass die auch
639 : : // gleich in den neuen Farben dargestellt werden
640 : : }
641 : 0 : }
642 : :
643 : : //------------------------------------------------------------------------------
644 : 0 : void OJoinTableView::InitColors()
645 : : {
646 : : DBG_CHKTHIS(OJoinTableView,NULL);
647 : : // die Farben fuer die Darstellung sollten die Systemfarben sein
648 [ # # ][ # # ]: 0 : StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
649 [ # # ][ # # ]: 0 : SetBackground(Wallpaper(Color(aSystemStyle.GetDialogColor())));
[ # # ][ # # ]
650 : 0 : }
651 : :
652 : : //------------------------------------------------------------------------------
653 : 0 : void OJoinTableView::BeginChildMove( OTableWindow* pTabWin, const Point& rMousePos )
654 : : {
655 : : DBG_CHKTHIS(OJoinTableView,NULL);
656 : :
657 [ # # ][ # # ]: 0 : if (m_pView->getController().isReadOnly())
658 : 0 : return;
659 : :
660 : 0 : m_pDragWin = pTabWin;
661 [ # # ]: 0 : SetPointer(Pointer(POINTER_MOVE));
662 [ # # ]: 0 : Point aMousePos = ScreenToOutputPixel( rMousePos );
663 [ # # ]: 0 : m_aDragOffset = aMousePos - pTabWin->GetPosPixel();
664 [ # # ]: 0 : m_pDragWin->SetZOrder(NULL, WINDOW_ZORDER_FIRST);
665 : 0 : m_bTrackingInitiallyMoved = sal_False;
666 [ # # ]: 0 : StartTracking();
667 : : }
668 : :
669 : 0 : void OJoinTableView::NotifyTitleClicked( OTableWindow* pTabWin, const Point rMousePos )
670 : : {
671 : : DBG_CHKTHIS(OJoinTableView,NULL);
672 : 0 : DeselectConn(GetSelectedConn());
673 : 0 : BeginChildMove(pTabWin, rMousePos);
674 : 0 : }
675 : :
676 : : //------------------------------------------------------------------------------
677 : 0 : void OJoinTableView::BeginChildSizing( OTableWindow* pTabWin, const Pointer& rPointer )
678 : : {
679 : : DBG_CHKTHIS(OJoinTableView,NULL);
680 : :
681 [ # # ]: 0 : if (m_pView->getController().isReadOnly())
682 : 0 : return;
683 : :
684 : 0 : SetPointer( rPointer );
685 : 0 : m_pSizingWin = pTabWin;
686 : 0 : StartTracking();
687 : : }
688 : :
689 : : //------------------------------------------------------------------------------
690 : 0 : sal_Bool OJoinTableView::ScrollPane( long nDelta, sal_Bool bHoriz, sal_Bool bPaintScrollBars )
691 : : {
692 : : DBG_CHKTHIS(OJoinTableView,NULL);
693 : 0 : sal_Bool bRet = sal_True;
694 : :
695 : : //////////////////////////////////////////////////////////////////////
696 : : // ScrollBar-Positionen anpassen
697 [ # # ]: 0 : if( bPaintScrollBars )
698 : : {
699 [ # # ]: 0 : if( bHoriz )
700 : : {
701 [ # # ]: 0 : long nOldThumbPos = GetHScrollBar()->GetThumbPos();
702 : 0 : long nNewThumbPos = nOldThumbPos + nDelta;
703 [ # # ]: 0 : if( nNewThumbPos < 0 )
704 : : {
705 : 0 : nNewThumbPos = 0;
706 : 0 : bRet = sal_False;
707 : : }
708 [ # # ][ # # ]: 0 : if( nNewThumbPos > GetHScrollBar()->GetRange().Max() )
709 : : {
710 [ # # ]: 0 : nNewThumbPos = GetHScrollBar()->GetRange().Max();
711 : 0 : bRet = sal_False;
712 : : }
713 [ # # ][ # # ]: 0 : GetHScrollBar()->SetThumbPos( nNewThumbPos );
714 [ # # ]: 0 : nDelta = GetHScrollBar()->GetThumbPos() - nOldThumbPos;
715 : : }
716 : : else
717 : : {
718 [ # # ]: 0 : long nOldThumbPos = GetVScrollBar()->GetThumbPos();
719 : 0 : long nNewThumbPos = nOldThumbPos+nDelta;
720 [ # # ]: 0 : if( nNewThumbPos < 0 )
721 : : {
722 : 0 : nNewThumbPos = 0;
723 : 0 : bRet = sal_False;
724 : : }
725 [ # # ][ # # ]: 0 : if( nNewThumbPos > GetVScrollBar()->GetRange().Max() )
726 : : {
727 [ # # ]: 0 : nNewThumbPos = GetVScrollBar()->GetRange().Max();
728 : 0 : bRet = sal_False;
729 : : }
730 [ # # ][ # # ]: 0 : GetVScrollBar()->SetThumbPos( nNewThumbPos );
731 [ # # ]: 0 : nDelta = GetVScrollBar()->GetThumbPos() - nOldThumbPos;
732 : : }
733 : : }
734 : :
735 : : //////////////////////////////////////////////////////////////////////
736 : : // Wenn ScrollOffset bereits an den Grenzen liegt, kein Neuzeichnen
737 [ # # ]: 0 : if( (GetHScrollBar()->GetThumbPos()==m_aScrollOffset.X()) &&
[ # # # # ]
[ # # ]
738 [ # # ]: 0 : (GetVScrollBar()->GetThumbPos()==m_aScrollOffset.Y()) )
739 : 0 : return sal_False;
740 : :
741 : : //////////////////////////////////////////////////////////////////////
742 : : // ScrollOffset neu setzen
743 [ # # ]: 0 : if (bHoriz)
744 [ # # ]: 0 : m_aScrollOffset.X() = GetHScrollBar()->GetThumbPos();
745 : : else
746 [ # # ]: 0 : m_aScrollOffset.Y() = GetVScrollBar()->GetThumbPos();
747 : :
748 : : //////////////////////////////////////////////////////////////////////
749 : : // Alle Fenster verschieben
750 : : OTableWindow* pTabWin;
751 : 0 : Point aPos;
752 : :
753 : 0 : OTableWindowMapIterator aIter = m_aTableMap.begin();
754 : 0 : OTableWindowMapIterator aEnd = m_aTableMap.end();
755 [ # # ]: 0 : for(;aIter != aEnd;++aIter)
756 : : {
757 : 0 : pTabWin = aIter->second;
758 [ # # ]: 0 : aPos = pTabWin->GetPosPixel();
759 : :
760 [ # # ]: 0 : if( bHoriz )
761 : 0 : aPos.X() -= nDelta;
762 : 0 : else aPos.Y() -= nDelta;
763 : :
764 [ # # ]: 0 : pTabWin->SetPosPixel( aPos );
765 : : }
766 : :
767 [ # # ]: 0 : Invalidate(); // INVALIDATE_NOCHILDREN
768 : :
769 : 0 : return bRet;
770 : : }
771 : :
772 : : //------------------------------------------------------------------------------
773 : 0 : void OJoinTableView::Tracking( const TrackingEvent& rTEvt )
774 : : {
775 : : DBG_CHKTHIS(OJoinTableView,NULL);
776 : 0 : HideTracking();
777 : :
778 [ # # ]: 0 : if (rTEvt.IsTrackingEnded())
779 : : {
780 [ # # ]: 0 : if( m_pDragWin )
781 : : {
782 [ # # ]: 0 : if (m_aDragScrollTimer.IsActive())
783 [ # # ]: 0 : m_aDragScrollTimer.Stop();
784 : :
785 : : //////////////////////////////////////////////////////////////////////
786 : : // Position des Childs nach Verschieben anpassen
787 : : //////////////////////////////////////////////////////////////////////
788 : : // Fenster duerfen nicht aus Anzeigebereich herausbewegt werden
789 : 0 : Point aDragWinPos = rTEvt.GetMouseEvent().GetPosPixel() - m_aDragOffset;
790 [ # # ]: 0 : Size aDragWinSize = m_pDragWin->GetSizePixel();
791 [ # # ]: 0 : if( aDragWinPos.X() < 0 )
792 : 0 : aDragWinPos.X() = 0;
793 [ # # ]: 0 : if( aDragWinPos.Y() < 0 )
794 : 0 : aDragWinPos.Y() = 0;
795 [ # # ]: 0 : if( (aDragWinPos.X() + aDragWinSize.Width()) > m_aOutputSize.Width() )
796 : 0 : aDragWinPos.X() = m_aOutputSize.Width() - aDragWinSize.Width() - 1;
797 [ # # ]: 0 : if( (aDragWinPos.Y() + aDragWinSize.Height()) > m_aOutputSize.Height() )
798 : 0 : aDragWinPos.Y() = m_aOutputSize.Height() - aDragWinSize.Height() - 1;
799 [ # # ]: 0 : if( aDragWinPos.X() < 0 )
800 : 0 : aDragWinPos.X() = 0;
801 [ # # ]: 0 : if( aDragWinPos.Y() < 0 )
802 : 0 : aDragWinPos.Y() = 0;
803 : : // TODO : nicht das Fenster neu positionieren, wenn es uebersteht, sondern einfach meinen Bereich erweitern
804 : :
805 : :
806 : : //////////////////////////////////////////////////////////////////////
807 : : // Fenster positionieren
808 [ # # ]: 0 : EndTracking();
809 [ # # ]: 0 : m_pDragWin->SetZOrder(NULL, WINDOW_ZORDER_FIRST);
810 : : // erst mal testen, ob ich mich ueberhaupt bewegt habe
811 : : // (das verhindert das Setzen des modified-Flags, wenn sich eigentlich gar nichts getan hat)
812 [ # # ]: 0 : TTableWindowData::value_type pData = m_pDragWin->GetData();
813 [ # # ][ # # ]: 0 : if ( ! (pData && pData->HasPosition() && (pData->GetPosition() == aDragWinPos)))
[ # # ][ # # ]
[ # # ]
[ # # # # ]
814 : : {
815 : : // die alten logischen Koordinaten
816 [ # # ][ # # ]: 0 : Point ptOldPos = m_pDragWin->GetPosPixel() + Point(GetHScrollBar()->GetThumbPos(), GetVScrollBar()->GetThumbPos());
[ # # ]
817 : : // neu positionieren
818 [ # # ]: 0 : m_pDragWin->SetPosPixel(aDragWinPos);
819 [ # # ]: 0 : TabWinMoved(m_pDragWin, ptOldPos);
820 : :
821 [ # # ]: 0 : m_pDragWin->GrabFocus();
822 : : }
823 : 0 : m_pDragWin = NULL;
824 [ # # ][ # # ]: 0 : SetPointer(Pointer(POINTER_ARROW));
825 : : }
826 : : // else we handle the resizing
827 [ # # ]: 0 : else if( m_pSizingWin )
828 : : {
829 [ # # ]: 0 : SetPointer( Pointer() );
830 [ # # ]: 0 : EndTracking();
831 : :
832 : : // die alten physikalischen Koordinaten
833 : :
834 [ # # ]: 0 : Size szOld = m_pSizingWin->GetSizePixel();
835 [ # # ]: 0 : Point ptOld = m_pSizingWin->GetPosPixel();
836 [ # # ][ # # ]: 0 : Size aNewSize(CalcZoom(m_aSizingRect.GetSize().Width()),CalcZoom(m_aSizingRect.GetSize().Height()));
[ # # ][ # # ]
837 [ # # ]: 0 : m_pSizingWin->SetPosSizePixel( m_aSizingRect.TopLeft(), aNewSize );
838 [ # # ]: 0 : TabWinSized(m_pSizingWin, ptOld, szOld);
839 : :
840 [ # # ]: 0 : m_pSizingWin->Invalidate( m_aSizingRect );
841 : 0 : m_pSizingWin = NULL;
842 : : }
843 : : }
844 [ # # ]: 0 : else if (rTEvt.IsTrackingCanceled())
845 : : {
846 [ # # ]: 0 : if (m_aDragScrollTimer.IsActive())
847 : 0 : m_aDragScrollTimer.Stop();
848 : 0 : EndTracking();
849 : : }
850 : : else
851 : : {
852 [ # # ]: 0 : if( m_pDragWin )
853 : : {
854 : 0 : m_ptPrevDraggingPos = rTEvt.GetMouseEvent().GetPosPixel();
855 : : // an Fenstergrenzen scrollen
856 : 0 : ScrollWhileDragging();
857 : : }
858 : :
859 [ # # ]: 0 : if( m_pSizingWin )
860 : : {
861 : 0 : Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
862 [ # # ]: 0 : m_aSizingRect = m_pSizingWin->getSizingRect(aMousePos,m_aOutputSize);
863 [ # # ]: 0 : Update();
864 [ # # ]: 0 : ShowTracking( m_aSizingRect, SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
865 : : }
866 : : }
867 : 0 : }
868 : :
869 : : //------------------------------------------------------------------------------
870 : 0 : void OJoinTableView::ConnDoubleClicked( OTableConnection* /*pConnection*/ )
871 : : {
872 : : DBG_CHKTHIS(OJoinTableView,NULL);
873 : 0 : }
874 : :
875 : : //------------------------------------------------------------------------------
876 : 0 : void OJoinTableView::MouseButtonDown( const MouseEvent& rEvt )
877 : : {
878 : : DBG_CHKTHIS(OJoinTableView,NULL);
879 : 0 : GrabFocus();
880 : 0 : Window::MouseButtonDown(rEvt);
881 : 0 : }
882 : :
883 : : //------------------------------------------------------------------------------
884 : 0 : void OJoinTableView::MouseButtonUp( const MouseEvent& rEvt )
885 : : {
886 : : DBG_CHKTHIS(OJoinTableView,NULL);
887 : 0 : Window::MouseButtonUp(rEvt);
888 : : //////////////////////////////////////////////////////////////////////
889 : : // Wurde eine Connection ausgewaehlt?
890 [ # # ]: 0 : if( !m_vTableConnection.empty() )
891 : : {
892 [ # # ]: 0 : DeselectConn(GetSelectedConn());
893 : :
894 : 0 : ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin();
895 : 0 : ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end();
896 [ # # ][ # # ]: 0 : for(;aIter != aEnd;++aIter)
897 : : {
898 [ # # ][ # # ]: 0 : if( (*aIter)->CheckHit(rEvt.GetPosPixel()) )
899 : : {
900 [ # # ]: 0 : SelectConn((*aIter));
901 : :
902 : : // Doppelclick
903 [ # # ]: 0 : if( rEvt.GetClicks() == 2 )
904 [ # # ]: 0 : ConnDoubleClicked( (*aIter) );
905 : :
906 : 0 : break;
907 : : }
908 : : }
909 : : }
910 : 0 : }
911 : :
912 : : //------------------------------------------------------------------------------
913 : 0 : void OJoinTableView::KeyInput( const KeyEvent& rEvt )
914 : : {
915 : : DBG_CHKTHIS(OJoinTableView,NULL);
916 : 0 : sal_uInt16 nCode = rEvt.GetKeyCode().GetCode();
917 : 0 : sal_Bool bShift = rEvt.GetKeyCode().IsShift();
918 : 0 : sal_Bool bCtrl = rEvt.GetKeyCode().IsMod1();
919 : :
920 [ # # ][ # # ]: 0 : if( !bCtrl && !bShift && (nCode==KEY_DELETE) )
[ # # ]
921 : : {
922 [ # # ]: 0 : if (GetSelectedConn())
923 : 0 : RemoveConnection( GetSelectedConn() ,sal_True);
924 : : }
925 : : else
926 : 0 : Window::KeyInput( rEvt );
927 : 0 : }
928 : :
929 : : //------------------------------------------------------------------------------
930 : 0 : void OJoinTableView::DeselectConn(OTableConnection* pConn)
931 : : {
932 : : DBG_CHKTHIS(OJoinTableView,NULL);
933 [ # # ][ # # ]: 0 : if (!pConn || !pConn->IsSelected())
[ # # ]
934 : 0 : return;
935 : :
936 : : // die zugehoerigen Eitnraege in der ListBox des Tabellenfenster deselektieren
937 : 0 : OTableWindow* pWin = pConn->GetSourceWin();
938 [ # # ][ # # ]: 0 : if (pWin && pWin->GetListBox())
[ # # ]
939 : 0 : pWin->GetListBox()->SelectAll(sal_False);
940 : :
941 : 0 : pWin = pConn->GetDestWin();
942 [ # # ][ # # ]: 0 : if (pWin && pWin->GetListBox())
[ # # ]
943 : 0 : pWin->GetListBox()->SelectAll(sal_False);
944 : :
945 : 0 : pConn->Deselect();
946 : 0 : m_pSelectedConn = NULL;
947 : : }
948 : :
949 : : //------------------------------------------------------------------------------
950 : 0 : void OJoinTableView::SelectConn(OTableConnection* pConn)
951 : : {
952 : : DBG_CHKTHIS(OJoinTableView,NULL);
953 : 0 : DeselectConn(GetSelectedConn());
954 : :
955 : 0 : pConn->Select();
956 : 0 : m_pSelectedConn = pConn;
957 : 0 : GrabFocus(); // has to be called here because a table window may still be focused
958 : :
959 : : // die betroffenene Eintraege in den Windows selektieren
960 : 0 : OTableWindow* pConnSource = pConn->GetSourceWin();
961 : 0 : OTableWindow* pConnDest = pConn->GetDestWin();
962 [ # # ][ # # ]: 0 : if (pConnSource && pConnDest)
963 : : {
964 : 0 : OTableWindowListBox* pSourceBox = pConnSource->GetListBox();
965 : 0 : OTableWindowListBox* pDestBox = pConnDest->GetListBox();
966 [ # # ][ # # ]: 0 : if (pSourceBox && pDestBox)
967 : : {
968 [ # # ]: 0 : pSourceBox->SelectAll(sal_False);
969 [ # # ]: 0 : pDestBox->SelectAll(sal_False);
970 : :
971 [ # # ]: 0 : SvLBoxEntry* pFirstSourceVisible = pSourceBox->GetFirstEntryInView();
972 [ # # ]: 0 : SvLBoxEntry* pFirstDestVisible = pDestBox->GetFirstEntryInView();
973 : :
974 : 0 : const ::std::vector<OConnectionLine*>* pLines = pConn->GetConnLineList();
975 : 0 : ::std::vector<OConnectionLine*>::const_reverse_iterator aIter = pLines->rbegin();
976 [ # # ][ # # ]: 0 : for(;aIter != pLines->rend();++aIter)
[ # # ]
977 : : {
978 [ # # ][ # # ]: 0 : if ((*aIter)->IsValid())
[ # # ]
979 : : {
980 [ # # ][ # # ]: 0 : SvLBoxEntry* pSourceEntry = pSourceBox->GetEntryFromText((*aIter)->GetData()->GetSourceFieldName());
[ # # ][ # # ]
[ # # ][ # # ]
981 [ # # ]: 0 : if (pSourceEntry)
982 : : {
983 [ # # ]: 0 : pSourceBox->Select(pSourceEntry, sal_True);
984 [ # # ]: 0 : pSourceBox->MakeVisible(pSourceEntry);
985 : : }
986 : :
987 [ # # ][ # # ]: 0 : SvLBoxEntry* pDestEntry = pDestBox->GetEntryFromText((*aIter)->GetData()->GetDestFieldName());
[ # # ][ # # ]
[ # # ][ # # ]
988 [ # # ]: 0 : if (pDestEntry)
989 : : {
990 [ # # ]: 0 : pDestBox->Select(pDestEntry, sal_True);
991 [ # # ]: 0 : pDestBox->MakeVisible(pDestEntry);
992 : : }
993 : :
994 : : }
995 : : }
996 : :
997 [ # # ][ # # ]: 0 : if ((pFirstSourceVisible != pSourceBox->GetFirstEntryInView())
[ # # ][ # # ]
998 [ # # ]: 0 : || (pFirstDestVisible != pDestBox->GetFirstEntryInView()))
999 : : // es wurde gescrollt -> neu zeichnen
1000 [ # # ]: 0 : Invalidate(INVALIDATE_NOCHILDREN);
1001 : : }
1002 : : }
1003 : 0 : }
1004 : : //------------------------------------------------------------------------------
1005 : 0 : void OJoinTableView::Paint( const Rectangle& rRect )
1006 : : {
1007 : : DBG_CHKTHIS(OJoinTableView,NULL);
1008 : 0 : DrawConnections( rRect );
1009 : 0 : }
1010 : :
1011 : : //------------------------------------------------------------------------------
1012 : 0 : void OJoinTableView::InvalidateConnections()
1013 : : {
1014 : : DBG_CHKTHIS(OJoinTableView,NULL);
1015 : : //////////////////////////////////////////////////////////////////////
1016 : : // Die Joins zeichnen
1017 : : ::std::for_each(m_vTableConnection.begin(),m_vTableConnection.end(),
1018 : 0 : ::std::mem_fun(& OTableConnection::InvalidateConnection));
1019 : 0 : }
1020 : :
1021 : : //------------------------------------------------------------------------------
1022 : 0 : void OJoinTableView::DrawConnections( const Rectangle& rRect )
1023 : : {
1024 : : DBG_CHKTHIS(OJoinTableView,NULL);
1025 : : //////////////////////////////////////////////////////////////////////
1026 : : // Die Joins zeichnen
1027 : 0 : ::std::for_each(m_vTableConnection.begin(),m_vTableConnection.end(),boost::bind( &OTableConnection::Draw, _1, boost::cref( rRect )));
1028 : : // zum Schluss noch mal die selektierte ueber alle anderen drueber
1029 [ # # ]: 0 : if (GetSelectedConn())
1030 : 0 : GetSelectedConn()->Draw( rRect );
1031 : 0 : }
1032 : :
1033 : :
1034 : : //------------------------------------------------------------------------------
1035 : 0 : ::std::vector<OTableConnection*>::const_iterator OJoinTableView::getTableConnections(const OTableWindow* _pFromWin) const
1036 : : {
1037 : : return ::std::find_if( m_vTableConnection.begin(),
1038 : : m_vTableConnection.end(),
1039 [ # # ][ # # ]: 0 : ::std::bind2nd(::std::mem_fun(&OTableConnection::isTableConnection),_pFromWin));
1040 : : }
1041 : : // -----------------------------------------------------------------------------
1042 : 0 : sal_Int32 OJoinTableView::getConnectionCount(const OTableWindow* _pFromWin) const
1043 : : {
1044 : : return ::std::count_if( m_vTableConnection.begin(),
1045 : : m_vTableConnection.end(),
1046 [ # # ][ # # ]: 0 : ::std::bind2nd(::std::mem_fun(&OTableConnection::isTableConnection),_pFromWin));
1047 : : }
1048 : : //------------------------------------------------------------------------------
1049 : 0 : sal_Bool OJoinTableView::ExistsAConn(const OTableWindow* pFrom) const
1050 : : {
1051 : : DBG_CHKTHIS(OJoinTableView,NULL);
1052 [ # # ][ # # ]: 0 : return getTableConnections(pFrom) != m_vTableConnection.end();
1053 : : }
1054 : : //------------------------------------------------------------------------
1055 : 0 : void OJoinTableView::ClearAll()
1056 : : {
1057 : : DBG_CHKTHIS(OJoinTableView,NULL);
1058 [ # # ]: 0 : SetUpdateMode(sal_False);
1059 : :
1060 [ # # ]: 0 : HideTabWins();
1061 : :
1062 : : // und das selbe mit den Connections
1063 : 0 : ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin();
1064 : 0 : ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end();
1065 [ # # ][ # # ]: 0 : for(;aIter != aEnd;++aIter)
1066 [ # # ]: 0 : RemoveConnection( *aIter ,sal_True);
1067 : 0 : m_vTableConnection.clear();
1068 : :
1069 : 0 : m_pLastFocusTabWin = NULL;
1070 : 0 : m_pSelectedConn = NULL;
1071 : :
1072 : : // scroll to the upper left
1073 [ # # ]: 0 : ScrollPane(-GetScrollOffset().X(), sal_True, sal_True);
1074 [ # # ]: 0 : ScrollPane(-GetScrollOffset().Y(), sal_False, sal_True);
1075 [ # # ]: 0 : Invalidate();
1076 : 0 : }
1077 : :
1078 : : //------------------------------------------------------------------------
1079 : 0 : sal_Bool OJoinTableView::ScrollWhileDragging()
1080 : : {
1081 : : DBG_CHKTHIS(OJoinTableView,NULL);
1082 : : OSL_ENSURE(m_pDragWin != NULL, "OJoinTableView::ScrollWhileDragging darf nur waehrend Dragging eines Fensters aufgerufen werden !");
1083 : :
1084 : : // den Timer schon mal killen
1085 [ # # ]: 0 : if (m_aDragScrollTimer.IsActive())
1086 [ # # ]: 0 : m_aDragScrollTimer.Stop();
1087 : :
1088 : 0 : Point aDragWinPos = m_ptPrevDraggingPos - m_aDragOffset;
1089 [ # # ]: 0 : Size aDragWinSize = m_pDragWin->GetSizePixel();
1090 : 0 : Point aLowerRight(aDragWinPos.X() + aDragWinSize.Width(), aDragWinPos.Y() + aDragWinSize.Height());
1091 : :
1092 [ # # ][ # # ]: 0 : if (!m_bTrackingInitiallyMoved && (aDragWinPos == m_pDragWin->GetPosPixel()))
[ # # ]
[ # # # # ]
[ # # ]
1093 : 0 : return sal_True;
1094 : :
1095 : : // Darstellungsfehler vermeiden (wenn bei aktivem TrackingRect gescrollt wird)
1096 [ # # ]: 0 : HideTracking();
1097 : :
1098 : 0 : sal_Bool bScrolling = sal_False;
1099 : 0 : sal_Bool bNeedScrollTimer = sal_False;
1100 : :
1101 : : // An Fenstergrenzen scrollen
1102 : : // TODO : nur dann abfangen, wenn das Fenster komplett verschwinden wuerde (nicht, solange noch ein Pixel sichtbar ist)
1103 [ # # ]: 0 : if( aDragWinPos.X() < 5 )
1104 : : {
1105 [ # # ]: 0 : bScrolling = ScrollPane( -LINE_SIZE, sal_True, sal_True );
1106 [ # # ][ # # ]: 0 : if( !bScrolling && (aDragWinPos.X()<0) )
[ # # ]
1107 : 0 : aDragWinPos.X() = 0;
1108 : :
1109 : : // brauche ich weiteres (timergesteuertes) Scrolling ?
1110 [ # # ][ # # ]: 0 : bNeedScrollTimer = bScrolling && (aDragWinPos.X() < 5);
1111 : : }
1112 : :
1113 [ # # ]: 0 : if( aLowerRight.X() > m_aOutputSize.Width() - 5 )
1114 : : {
1115 [ # # ]: 0 : bScrolling = ScrollPane( LINE_SIZE, sal_True, sal_True ) ;
1116 [ # # ][ # # ]: 0 : if( !bScrolling && ( aLowerRight.X() > m_aOutputSize.Width() ) )
[ # # ]
1117 : 0 : aDragWinPos.X() = m_aOutputSize.Width() - aDragWinSize.Width();
1118 : :
1119 : : // brauche ich weiteres (timergesteuertes) Scrolling ?
1120 [ # # ][ # # ]: 0 : bNeedScrollTimer = bScrolling && (aLowerRight.X() > m_aOutputSize.Width() - 5);
1121 : : }
1122 : :
1123 [ # # ]: 0 : if( aDragWinPos.Y() < 5 )
1124 : : {
1125 [ # # ]: 0 : bScrolling = ScrollPane( -LINE_SIZE, sal_False, sal_True );
1126 [ # # ][ # # ]: 0 : if( !bScrolling && (aDragWinPos.Y()<0) )
[ # # ]
1127 : 0 : aDragWinPos.Y() = 0;
1128 : :
1129 [ # # ][ # # ]: 0 : bNeedScrollTimer = bScrolling && (aDragWinPos.Y() < 5);
1130 : : }
1131 : :
1132 [ # # ]: 0 : if( aLowerRight.Y() > m_aOutputSize.Height() - 5 )
1133 : : {
1134 [ # # ]: 0 : bScrolling = ScrollPane( LINE_SIZE, sal_False, sal_True );
1135 [ # # ][ # # ]: 0 : if( !bScrolling && ( (aDragWinPos.Y() + aDragWinSize.Height()) > m_aOutputSize.Height() ) )
[ # # ]
1136 : 0 : aDragWinPos.Y() = m_aOutputSize.Height() - aDragWinSize.Height();
1137 : :
1138 [ # # ][ # # ]: 0 : bNeedScrollTimer = bScrolling && (aLowerRight.Y() > m_aOutputSize.Height() - 5);
1139 : : }
1140 : :
1141 : : // Timer neu setzen, wenn noch notwendig
1142 [ # # ]: 0 : if (bNeedScrollTimer)
1143 : : {
1144 [ # # ]: 0 : m_aDragScrollTimer.SetTimeout(100);
1145 [ # # ]: 0 : m_aDragScrollTimer.Start();
1146 : : }
1147 : :
1148 : : // das DraggingRect neu zeichnen
1149 [ # # ][ # # ]: 0 : m_aDragRect = Rectangle(m_ptPrevDraggingPos - m_aDragOffset, m_pDragWin->GetSizePixel());
1150 [ # # ]: 0 : Update();
1151 [ # # ]: 0 : ShowTracking( m_aDragRect, SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
1152 : :
1153 : 0 : return bScrolling;
1154 : : }
1155 : :
1156 : : //------------------------------------------------------------------------
1157 : 0 : IMPL_LINK_NOARG(OJoinTableView, OnDragScrollTimer)
1158 : : {
1159 : 0 : ScrollWhileDragging();
1160 : 0 : return 0L;
1161 : : }
1162 : : // -----------------------------------------------------------------------------
1163 : 0 : void OJoinTableView::invalidateAndModify(SfxUndoAction *_pAction)
1164 : : {
1165 : 0 : Invalidate(INVALIDATE_NOCHILDREN);
1166 : 0 : m_pView->getController().addUndoActionAndInvalidate(_pAction);
1167 : 0 : }
1168 : : //------------------------------------------------------------------------
1169 : 0 : void OJoinTableView::TabWinMoved(OTableWindow* ptWhich, const Point& ptOldPosition)
1170 : : {
1171 : : DBG_CHKTHIS(OJoinTableView,NULL);
1172 [ # # ][ # # ]: 0 : Point ptThumbPos(GetHScrollBar()->GetThumbPos(), GetVScrollBar()->GetThumbPos());
1173 [ # # ][ # # ]: 0 : ptWhich->GetData()->SetPosition(ptWhich->GetPosPixel() + ptThumbPos);
[ # # ]
1174 : :
1175 [ # # ][ # # ]: 0 : invalidateAndModify(new OJoinMoveTabWinUndoAct(this, ptOldPosition, ptWhich));
[ # # ]
1176 : 0 : }
1177 : :
1178 : : //------------------------------------------------------------------------
1179 : 0 : void OJoinTableView::TabWinSized(OTableWindow* ptWhich, const Point& ptOldPosition, const Size& szOldSize)
1180 : : {
1181 : : DBG_CHKTHIS(OJoinTableView,NULL);
1182 [ # # ][ # # ]: 0 : ptWhich->GetData()->SetSize(ptWhich->GetSizePixel());
1183 [ # # ][ # # ]: 0 : ptWhich->GetData()->SetPosition(ptWhich->GetPosPixel());
1184 : :
1185 [ # # ]: 0 : invalidateAndModify(new OJoinSizeTabWinUndoAct(this, ptOldPosition, szOldSize, ptWhich));
1186 : 0 : }
1187 : :
1188 : : //------------------------------------------------------------------------------
1189 : 0 : sal_Bool OJoinTableView::IsAddAllowed()
1190 : : {
1191 : : DBG_CHKTHIS(OJoinTableView,NULL);
1192 : :
1193 : : // nicht wenn Db readonly
1194 [ # # ]: 0 : if (m_pView->getController().isReadOnly())
1195 : 0 : return sal_False;
1196 : :
1197 : : try
1198 : : {
1199 [ # # ]: 0 : Reference< XConnection> xConnection = m_pView->getController().getConnection();
1200 [ # # ]: 0 : if(!xConnection.is())
1201 : 0 : return sal_False;
1202 : : // nicht wenn schon zuviele Tabellen
1203 [ # # ][ # # ]: 0 : Reference < XDatabaseMetaData > xMetaData( xConnection->getMetaData() );
1204 : :
1205 [ # # ][ # # ]: 0 : sal_Int32 nMax = xMetaData.is() ? xMetaData->getMaxTablesInSelect() : 0;
[ # # ]
1206 [ # # ][ # # ]: 0 : if (nMax && nMax <= (sal_Int32)m_aTableMap.size())
[ # # ]
1207 [ # # ]: 0 : return sal_False;
[ # # # # ]
1208 : : }
1209 : 0 : catch(SQLException&)
1210 : : {
1211 : 0 : return sal_False;
1212 : : }
1213 : :
1214 : 0 : return sal_True;
1215 : : }
1216 : : // -----------------------------------------------------------------------------
1217 : 0 : void OJoinTableView::executePopup(const Point& _aPos,OTableConnection* _pSelConnection)
1218 : : {
1219 [ # # ][ # # ]: 0 : PopupMenu aContextMenu( ModuleRes( RID_MENU_JOINVIEW_CONNECTION ) );
1220 [ # # ]: 0 : switch (aContextMenu.Execute(this, _aPos))
[ # # # ]
1221 : : {
1222 : : case SID_DELETE:
1223 [ # # ]: 0 : RemoveConnection( _pSelConnection ,sal_True);
1224 : 0 : break;
1225 : : case ID_QUERY_EDIT_JOINCONNECTION:
1226 [ # # ]: 0 : ConnDoubleClicked( _pSelConnection ); // is the same as double clicked
1227 : 0 : break;
1228 [ # # ]: 0 : }
1229 : 0 : }
1230 : : //------------------------------------------------------------------------------
1231 : 0 : void OJoinTableView::Command(const CommandEvent& rEvt)
1232 : : {
1233 : : DBG_CHKTHIS(OJoinTableView,NULL);
1234 : :
1235 : 0 : sal_Bool bHandled = sal_False;
1236 : :
1237 [ # # ]: 0 : switch (rEvt.GetCommand())
1238 : : {
1239 : : case COMMAND_CONTEXTMENU:
1240 : : {
1241 [ # # ]: 0 : if( m_vTableConnection.empty() )
1242 : 0 : return;
1243 : :
1244 : 0 : OTableConnection* pSelConnection = GetSelectedConn();
1245 : : // when it wasn't a mouse event use the selected connection
1246 [ # # ]: 0 : if (!rEvt.IsMouseEvent())
1247 : : {
1248 [ # # ]: 0 : if( pSelConnection )
1249 : : {
1250 : 0 : const ::std::vector<OConnectionLine*>* pLines = pSelConnection->GetConnLineList();
1251 [ # # ][ # # ]: 0 : ::std::vector<OConnectionLine*>::const_iterator aIter = ::std::find_if(pLines->begin(),pLines->end(),::std::mem_fun(&OConnectionLine::IsValid));
1252 [ # # ][ # # ]: 0 : if( aIter != pLines->end() )
1253 [ # # ][ # # ]: 0 : executePopup((*aIter)->getMidPoint(),pSelConnection);
1254 : : }
1255 : : }
1256 : : else
1257 : : {
1258 [ # # ]: 0 : DeselectConn(pSelConnection);
1259 : :
1260 : 0 : const Point& aMousePos = rEvt.GetMousePosPixel();
1261 : 0 : ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin();
1262 : 0 : ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end();
1263 [ # # ][ # # ]: 0 : for(;aIter != aEnd;++aIter)
1264 : : {
1265 [ # # ][ # # ]: 0 : if( (*aIter)->CheckHit(aMousePos) )
1266 : : {
1267 [ # # ]: 0 : SelectConn(*aIter);
1268 [ # # ][ # # ]: 0 : if(!getDesignView()->getController().isReadOnly() && getDesignView()->getController().isConnected())
[ # # ][ # # ]
[ # # ]
1269 [ # # ]: 0 : executePopup(rEvt.GetMousePosPixel(),*aIter);
1270 : 0 : break;
1271 : : }
1272 : : }
1273 : : }
1274 : 0 : bHandled = sal_True;
1275 : : }
1276 : : }
1277 [ # # ]: 0 : if (!bHandled)
1278 : 0 : Window::Command(rEvt);
1279 : : }
1280 : :
1281 : : //------------------------------------------------------------------------------
1282 : 0 : OTableConnection* OJoinTableView::GetTabConn(const OTableWindow* pLhs,const OTableWindow* pRhs,bool _bSupressCrossOrNaturalJoin,const OTableConnection* _rpFirstAfter) const
1283 : : {
1284 : 0 : OTableConnection* pConn = NULL;
1285 : : OSL_ENSURE(pRhs || pLhs, "OJoinTableView::GetTabConn : invalid args !");
1286 : : // only one NULL-arg allowed
1287 : :
1288 [ # # ][ # # ]: 0 : if ((!pLhs || pLhs->ExistsAConn()) && (!pRhs || pRhs->ExistsAConn()))
[ # # ][ # # ]
[ # # ]
1289 : : {
1290 : 0 : sal_Bool bFoundStart = _rpFirstAfter ? sal_False : sal_True;
1291 : :
1292 : 0 : ::std::vector<OTableConnection*>::const_iterator aIter = m_vTableConnection.begin();
1293 : 0 : ::std::vector<OTableConnection*>::const_iterator aEnd = m_vTableConnection.end();
1294 [ # # ][ # # ]: 0 : for(;aIter != aEnd;++aIter)
1295 : : {
1296 : 0 : OTableConnection* pData = *aIter;
1297 : :
1298 [ # # ][ # # ]: 0 : if ( ( (pData->GetSourceWin() == pLhs)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1299 [ # # ]: 0 : && ( (pData->GetDestWin() == pRhs)
1300 : : || (NULL == pRhs)
1301 : : )
1302 : : )
1303 [ # # ]: 0 : || ( (pData->GetSourceWin() == pRhs)
1304 [ # # ]: 0 : && ( (pData->GetDestWin() == pLhs)
1305 : : || (NULL == pLhs)
1306 : : )
1307 : : )
1308 : : )
1309 : : {
1310 [ # # ]: 0 : if ( _bSupressCrossOrNaturalJoin )
1311 : : {
1312 [ # # ][ # # ]: 0 : if ( supressCrossNaturalJoin(pData->GetData()) )
[ # # ][ # # ]
1313 : 0 : continue;
1314 : : }
1315 [ # # ]: 0 : if (bFoundStart)
1316 : : {
1317 : 0 : pConn = pData;
1318 : 0 : break;
1319 : : }
1320 : :
1321 [ # # ]: 0 : if (!pConn)
1322 : : // used as fallback : if there is no conn after _rpFirstAfter the first conn between the two tables
1323 : : // will be used
1324 : 0 : pConn = pData;
1325 : :
1326 [ # # ]: 0 : if (pData == _rpFirstAfter)
1327 : 0 : bFoundStart = sal_True;
1328 : : }
1329 : : }
1330 : : }
1331 : 0 : return pConn;
1332 : : }
1333 : :
1334 : : //------------------------------------------------------------------------------
1335 : 0 : long OJoinTableView::PreNotify(NotifyEvent& rNEvt)
1336 : : {
1337 : 0 : sal_Bool bHandled = sal_False;
1338 [ # # # # ]: 0 : switch (rNEvt.GetType())
1339 : : {
1340 : : case EVENT_COMMAND:
1341 : : {
1342 : 0 : const CommandEvent* pCommand = rNEvt.GetCommandEvent();
1343 [ # # ]: 0 : if (pCommand->GetCommand() == COMMAND_WHEEL)
1344 : : {
1345 : 0 : const CommandWheelData* pData = rNEvt.GetCommandEvent()->GetWheelData();
1346 [ # # ]: 0 : if (pData->GetMode() == COMMAND_WHEEL_SCROLL)
1347 : : {
1348 [ # # ]: 0 : if (pData->GetDelta() > 0)
1349 : 0 : ScrollPane(-10 * pData->GetScrollLines(), pData->IsHorz(), sal_True);
1350 : : else
1351 : 0 : ScrollPane(10 * pData->GetScrollLines(), pData->IsHorz(), sal_True);
1352 : 0 : bHandled = sal_True;
1353 : : }
1354 : : }
1355 : : }
1356 : 0 : break;
1357 : : case EVENT_KEYINPUT:
1358 : : {
1359 [ # # ]: 0 : if (m_aTableMap.empty())
1360 : : // no tab wins -> no conns -> no traveling
1361 : 0 : break;
1362 : :
1363 : 0 : const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
1364 [ # # ]: 0 : if (!pKeyEvent->GetKeyCode().IsMod1())
1365 : : {
1366 [ # # # ]: 0 : switch (pKeyEvent->GetKeyCode().GetCode())
1367 : : {
1368 : : case KEY_TAB:
1369 : : {
1370 [ # # ][ # # ]: 0 : if (!HasChildPathFocus())
1371 : : break;
1372 : :
1373 : 0 : sal_Bool bForward = !pKeyEvent->GetKeyCode().IsShift();
1374 : : // is there an active tab win ?
1375 : 0 : OTableWindowMapIterator aIter = m_aTableMap.begin();
1376 : 0 : OTableWindowMapIterator aEnd = m_aTableMap.end();
1377 [ # # ]: 0 : for(;aIter != aEnd;++aIter)
1378 [ # # ][ # # ]: 0 : if (aIter->second && aIter->second->HasChildPathFocus())
[ # # ][ # # ]
1379 : 0 : break;
1380 : :
1381 : 0 : OTableWindow* pNextWin = NULL;
1382 : 0 : OTableConnection* pNextConn = NULL;
1383 : :
1384 [ # # ]: 0 : if (aIter != m_aTableMap.end())
1385 : : { // there is a currently active tab win
1386 : : // check if there is an "overflow" and we should select a conn instead of a win
1387 [ # # ]: 0 : if (!m_vTableConnection.empty())
1388 : : {
1389 [ # # ][ # # ]: 0 : if ((aIter->second == m_aTableMap.rbegin()->second) && bForward)
[ # # ][ # # ]
[ # # # # ]
1390 : : // the last win is active and we're travelling forward -> select the first conn
1391 : 0 : pNextConn = *m_vTableConnection.begin();
1392 [ # # ][ # # ]: 0 : if ((aIter == m_aTableMap.begin()) && !bForward)
[ # # ][ # # ]
1393 : : // the first win is active an we're traveling backward -> select the last conn
1394 [ # # ]: 0 : pNextConn = *m_vTableConnection.rbegin();
1395 : : }
1396 : :
1397 [ # # ]: 0 : if (!pNextConn)
1398 : : {
1399 : : // no conn for any reason -> select the next or previous tab win
1400 [ # # ]: 0 : if(bForward)
1401 : : {
1402 [ # # ][ # # ]: 0 : if ( aIter->second == m_aTableMap.rbegin()->second )
1403 : 0 : pNextWin = m_aTableMap.begin()->second;
1404 : : else
1405 : : {
1406 : 0 : ++aIter;
1407 : 0 : pNextWin = aIter->second;
1408 : : }
1409 : : }
1410 : : else
1411 : : {
1412 [ # # ]: 0 : if (aIter == m_aTableMap.begin())
1413 [ # # ]: 0 : pNextWin = m_aTableMap.rbegin()->second;
1414 : : else
1415 : : {
1416 : 0 : --aIter;
1417 : 0 : pNextWin = aIter->second;
1418 : : }
1419 : : }
1420 : : }
1421 : : }
1422 : : else
1423 : : { // no active tab win -> travel the connections
1424 : : // find the currently selected conn within the conn list
1425 : 0 : sal_Int32 i(0);
1426 [ # # ][ # # ]: 0 : for ( ::std::vector<OTableConnection*>::iterator connectionIter = m_vTableConnection.begin();
1427 : 0 : connectionIter != m_vTableConnection.end();
1428 : : ++connectionIter, ++i
1429 : : )
1430 : : {
1431 [ # # ]: 0 : if ( (*connectionIter) == GetSelectedConn() )
1432 : 0 : break;
1433 : : }
1434 [ # # ][ # # ]: 0 : if (i == sal_Int32(m_vTableConnection.size() - 1) && bForward)
[ # # ]
1435 : : // the last conn is active and we're travelling forward -> select the first win
1436 : 0 : pNextWin = m_aTableMap.begin()->second;
1437 [ # # ][ # # ]: 0 : if ((i == 0) && !bForward && !m_aTableMap.empty())
[ # # ][ # # ]
1438 : : // the first conn is active and we're travelling backward -> select the last win
1439 [ # # ]: 0 : pNextWin = m_aTableMap.rbegin()->second;
1440 : :
1441 [ # # ]: 0 : if (pNextWin)
1442 [ # # ]: 0 : DeselectConn(GetSelectedConn());
1443 : : else
1444 : : // no win for any reason -> select the next or previous conn
1445 [ # # ]: 0 : if (i < (sal_Int32)m_vTableConnection.size())
1446 : : // there is a currently active conn
1447 [ # # ]: 0 : pNextConn = m_vTableConnection[(i + (bForward ? 1 : m_vTableConnection.size() - 1)) % m_vTableConnection.size()];
1448 : : else
1449 : : { // no tab win selected, no conn selected
1450 [ # # ]: 0 : if (!m_vTableConnection.empty())
1451 [ # # ]: 0 : pNextConn = m_vTableConnection[bForward ? 0 : m_vTableConnection.size() - 1];
1452 [ # # ]: 0 : else if (!m_aTableMap.empty())
1453 : : {
1454 [ # # ]: 0 : if(bForward)
1455 : 0 : pNextWin = m_aTableMap.begin()->second;
1456 : : else
1457 [ # # ]: 0 : pNextWin = m_aTableMap.rbegin()->second;
1458 : : }
1459 : : }
1460 : : }
1461 : :
1462 : : // now select the object
1463 [ # # ]: 0 : if (pNextWin)
1464 : : {
1465 [ # # ]: 0 : if (pNextWin->GetListBox())
1466 [ # # ]: 0 : pNextWin->GetListBox()->GrabFocus();
1467 : : else
1468 [ # # ]: 0 : pNextWin->GrabFocus();
1469 [ # # ]: 0 : EnsureVisible(pNextWin);
1470 : : }
1471 [ # # ]: 0 : else if (pNextConn)
1472 : : {
1473 [ # # ]: 0 : GrabFocus();
1474 : : // neccessary : a conn may be selected even if a tab win has the focus, in this case
1475 : : // the next travel would select the same conn again if we would not reset te focus ...
1476 [ # # ]: 0 : SelectConn(pNextConn);
1477 : : }
1478 : : }
1479 : 0 : break;
1480 : : case KEY_RETURN:
1481 : : {
1482 [ # # ][ # # ]: 0 : if (!pKeyEvent->GetKeyCode().IsShift() && GetSelectedConn() && HasFocus())
[ # # ][ # # ]
1483 : 0 : ConnDoubleClicked(GetSelectedConn());
1484 : 0 : break;
1485 : : }
1486 : : }
1487 : : }
1488 : : }
1489 : 0 : break;
1490 : : case EVENT_GETFOCUS:
1491 : : {
1492 [ # # ]: 0 : if (m_aTableMap.empty())
1493 : : // no tab wins -> no conns -> no focus change
1494 : 0 : break;
1495 : 0 : Window* pSource = rNEvt.GetWindow();
1496 [ # # ]: 0 : if (pSource)
1497 : : {
1498 : 0 : Window* pSearchFor = NULL;
1499 [ # # ]: 0 : if (pSource->GetParent() == this)
1500 : : // it may be one of the tab wins
1501 : 0 : pSearchFor = pSource;
1502 [ # # ][ # # ]: 0 : else if (pSource->GetParent() && (pSource->GetParent()->GetParent() == this))
[ # # ]
1503 : : // it may be one of th list boxes of one of the tab wins
1504 : 0 : pSearchFor = pSource->GetParent();
1505 : :
1506 [ # # ]: 0 : if (pSearchFor)
1507 : : {
1508 : 0 : OTableWindowMapIterator aIter = m_aTableMap.begin();
1509 : 0 : OTableWindowMapIterator aEnd = m_aTableMap.end();
1510 [ # # ]: 0 : for(;aIter != aEnd;++aIter)
1511 : : {
1512 [ # # ][ # # ]: 0 : if (aIter->second == pSearchFor)
1513 : : {
1514 : 0 : m_pLastFocusTabWin = aIter->second;
1515 : 0 : break;
1516 : : }
1517 : : }
1518 : : }
1519 : : }
1520 : : }
1521 : 0 : break;
1522 : : }
1523 : :
1524 [ # # ]: 0 : if (!bHandled)
1525 : 0 : return Window::PreNotify(rNEvt);
1526 : 0 : return 1L;
1527 : : }
1528 : :
1529 : : //------------------------------------------------------------------------------
1530 : 0 : void OJoinTableView::GrabTabWinFocus()
1531 : : {
1532 [ # # ][ # # ]: 0 : if (m_pLastFocusTabWin && m_pLastFocusTabWin->IsVisible())
[ # # ]
1533 : : {
1534 [ # # ]: 0 : if (m_pLastFocusTabWin->GetListBox())
1535 : 0 : m_pLastFocusTabWin->GetListBox()->GrabFocus();
1536 : : else
1537 : 0 : m_pLastFocusTabWin->GrabFocus();
1538 : : }
1539 [ # # ][ # # ]: 0 : else if (!m_aTableMap.empty() && m_aTableMap.begin()->second && m_aTableMap.begin()->second->IsVisible())
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # ]
1540 : : {
1541 : 0 : OTableWindow* pFirstWin = m_aTableMap.begin()->second;
1542 [ # # ]: 0 : if (pFirstWin->GetListBox())
1543 : 0 : pFirstWin->GetListBox()->GrabFocus();
1544 : : else
1545 : 0 : pFirstWin->GrabFocus();
1546 : : }
1547 : 0 : }
1548 : : // -----------------------------------------------------------------------------
1549 : 0 : void OJoinTableView::StateChanged( StateChangedType nType )
1550 : : {
1551 : 0 : Window::StateChanged( nType );
1552 : :
1553 [ # # ]: 0 : if ( nType == STATE_CHANGE_ZOOM )
1554 : : {
1555 : 0 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1556 : :
1557 [ # # ]: 0 : Font aFont = rStyleSettings.GetGroupFont();
1558 [ # # ][ # # ]: 0 : if ( IsControlFont() )
1559 [ # # ][ # # ]: 0 : aFont.Merge( GetControlFont() );
[ # # ]
1560 [ # # ]: 0 : SetZoomedPointFont( aFont );
1561 : :
1562 : 0 : OTableWindowMapIterator aIter = m_aTableMap.begin();
1563 : 0 : OTableWindowMapIterator aEnd = m_aTableMap.end();
1564 [ # # ]: 0 : for(;aIter != aEnd;++aIter)
1565 : : {
1566 [ # # ][ # # ]: 0 : aIter->second->SetZoom(GetZoom());
1567 [ # # ][ # # ]: 0 : Size aSize(CalcZoom(aIter->second->GetSizePixel().Width()),CalcZoom(aIter->second->GetSizePixel().Height()));
[ # # ][ # # ]
1568 [ # # ]: 0 : aIter->second->SetSizePixel(aSize);
1569 : : }
1570 [ # # ][ # # ]: 0 : Resize();
1571 : : }
1572 : 0 : }
1573 : : //------------------------------------------------------------------------------
1574 : 0 : void OJoinTableView::HideTabWins()
1575 : : {
1576 : : DBG_CHKTHIS(OJoinTableView,NULL);
1577 : 0 : SetUpdateMode(sal_False);
1578 : :
1579 : 0 : OTableWindowMap* pTabWins = GetTabWinMap();
1580 [ # # ]: 0 : if ( pTabWins )
1581 : : {
1582 : : // working on a copy because the real list will be cleared in inner calls
1583 [ # # ]: 0 : OTableWindowMap aCopy(*pTabWins);
1584 : 0 : OTableWindowMap::iterator aIter = aCopy.begin();
1585 : 0 : OTableWindowMap::iterator aEnd = aCopy.end();
1586 [ # # ]: 0 : for(;aIter != aEnd;++aIter)
1587 [ # # ]: 0 : RemoveTabWin(aIter->second);
1588 : : }
1589 : :
1590 : 0 : m_pView->getController().setModified(sal_True);
1591 : :
1592 : 0 : SetUpdateMode(sal_True);
1593 : :
1594 : 0 : }
1595 : : // -----------------------------------------------------------------------------
1596 : 0 : sal_Int8 OJoinTableView::AcceptDrop( const AcceptDropEvent& /*_rEvt*/ )
1597 : : {
1598 : 0 : return DND_ACTION_NONE;
1599 : : }
1600 : : // -----------------------------------------------------------------------------
1601 : 0 : sal_Int8 OJoinTableView::ExecuteDrop( const ExecuteDropEvent& /*_rEvt*/ )
1602 : : {
1603 : 0 : return DND_ACTION_NONE;
1604 : : }
1605 : : // -----------------------------------------------------------------------------
1606 : 0 : void OJoinTableView::dragFinished( )
1607 : : {
1608 : 0 : }
1609 : : //------------------------------------------------------------------------------
1610 : 0 : void OJoinTableView::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ )
1611 : : {
1612 : 0 : }
1613 : : // -----------------------------------------------------------------------------
1614 : 0 : void OJoinTableView::clearLayoutInformation()
1615 : : {
1616 : 0 : m_pLastFocusTabWin = NULL;
1617 : 0 : m_pSelectedConn = NULL;
1618 : : //////////////////////////////////////////////////////////////////////
1619 : : // Listen loeschen
1620 : 0 : OTableWindowMapIterator aIter = m_aTableMap.begin();
1621 : 0 : OTableWindowMapIterator aEnd = m_aTableMap.end();
1622 [ # # ]: 0 : for(;aIter != aEnd;++aIter)
1623 : : {
1624 [ # # ]: 0 : if ( aIter->second )
1625 [ # # ]: 0 : aIter->second->clearListBox();
1626 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
1627 [ # # ]: 0 : ::std::auto_ptr<Window> aTemp(aIter->second);
1628 : : SAL_WNODEPRECATED_DECLARATIONS_POP
1629 : 0 : aIter->second = NULL;
1630 [ # # ]: 0 : }
1631 : :
1632 : 0 : m_aTableMap.clear();
1633 : :
1634 [ # # ]: 0 : ::std::vector<OTableConnection*>::const_iterator aIter2 = m_vTableConnection.begin();
1635 [ # # ]: 0 : ::std::vector<OTableConnection*>::const_iterator aEnd2 = m_vTableConnection.end();
1636 [ # # ][ # # ]: 0 : for(;aIter2 != aEnd2;++aIter2)
1637 [ # # ][ # # ]: 0 : delete *aIter2;
1638 : :
1639 : 0 : m_vTableConnection.clear();
1640 : 0 : }
1641 : : // -----------------------------------------------------------------------------
1642 : 0 : void OJoinTableView::lookForUiActivities()
1643 : : {
1644 : 0 : }
1645 : : // -----------------------------------------------------------------------------
1646 : 0 : void OJoinTableView::LoseFocus()
1647 : : {
1648 : 0 : DeselectConn(GetSelectedConn());
1649 : 0 : Window::LoseFocus();
1650 : 0 : }
1651 : : // -----------------------------------------------------------------------------
1652 : 0 : void OJoinTableView::GetFocus()
1653 : : {
1654 : 0 : Window::GetFocus();
1655 [ # # ][ # # ]: 0 : if ( !m_aTableMap.empty() && !GetSelectedConn() )
[ # # ]
1656 : 0 : GrabTabWinFocus();
1657 : 0 : }
1658 : : // -----------------------------------------------------------------------------
1659 : 0 : Reference< XAccessible > OJoinTableView::CreateAccessible()
1660 : : {
1661 [ # # ]: 0 : m_pAccessible = new OJoinDesignViewAccess(this);
1662 [ # # ]: 0 : return m_pAccessible;
1663 : : }
1664 : : // -----------------------------------------------------------------------------
1665 : 0 : void OJoinTableView::modified()
1666 : : {
1667 : 0 : OJoinController& rController = m_pView->getController();
1668 : 0 : rController.setModified( sal_True );
1669 [ # # ]: 0 : rController.InvalidateFeature(ID_BROWSER_ADDTABLE);
1670 [ # # ]: 0 : rController.InvalidateFeature(SID_RELATION_ADD_RELATION);
1671 : 0 : }
1672 : : // -----------------------------------------------------------------------------
1673 : 0 : void OJoinTableView::addConnection(OTableConnection* _pConnection,sal_Bool _bAddData)
1674 : : {
1675 [ # # ]: 0 : if ( _bAddData )
1676 : : {
1677 : : #if OSL_DEBUG_LEVEL > 0
1678 : : TTableConnectionData* pTabConnDataList = m_pView->getController().getTableConnectionData();
1679 : : OSL_ENSURE( ::std::find(pTabConnDataList->begin(),pTabConnDataList->end(),_pConnection->GetData()) == pTabConnDataList->end(),"Data already in vector!");
1680 : : #endif
1681 [ # # ]: 0 : m_pView->getController().getTableConnectionData()->push_back(_pConnection->GetData());
1682 : : }
1683 : 0 : m_vTableConnection.push_back(_pConnection);
1684 : 0 : _pConnection->RecalcLines();
1685 : 0 : _pConnection->InvalidateConnection();
1686 : :
1687 : 0 : modified();
1688 [ # # ]: 0 : if ( m_pAccessible )
1689 : : m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
1690 : : Any(),
1691 [ # # ][ # # ]: 0 : makeAny(_pConnection->GetAccessible()));
1692 : 0 : }
1693 : : // -----------------------------------------------------------------------------
1694 : 0 : bool OJoinTableView::allowQueries() const
1695 : : {
1696 : 0 : return true;
1697 : : }
1698 : : // -----------------------------------------------------------------------------
1699 : 0 : void OJoinTableView::onNoColumns_throw()
1700 : : {
1701 : : OSL_FAIL( "OTableWindow::onNoColumns_throw: cannot really handle this!" );
1702 [ # # ]: 0 : throw SQLException();
1703 : : }
1704 : : //------------------------------------------------------------------------------
1705 : 0 : bool OJoinTableView::supressCrossNaturalJoin(const TTableConnectionData::value_type& ) const
1706 : : {
1707 : 0 : return false;
1708 [ + - ][ + - ]: 42 : }
1709 : :
1710 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|