LibreOffice Module dbaccess (master) 1
JoinTableView.cxx
Go to the documentation of this file.
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 <JoinController.hxx>
23#include <JoinDesignView.hxx>
24#include <TableWindow.hxx>
26#include <TableConnection.hxx>
28#include <ConnectionLine.hxx>
30#include <browserids.hxx>
31#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
32#include <com/sun/star/sdbc/SQLException.hpp>
36#include <vcl/svapp.hxx>
37#include <vcl/settings.hxx>
38#include <vcl/commandevent.hxx>
39#include <vcl/event.hxx>
40#include <vcl/ptrstyle.hxx>
41#include <vcl/weldutils.hxx>
42#include <TableWindowData.hxx>
43#include <JAccess.hxx>
44#include <com/sun/star/accessibility/XAccessible.hpp>
45#include <com/sun/star/accessibility/AccessibleRole.hpp>
46#include <com/sun/star/accessibility/AccessibleEventId.hpp>
50#include <algorithm>
51#include <functional>
52
53using namespace dbaui;
54using namespace ::com::sun::star::uno;
55using namespace ::com::sun::star::sdbc;
56using namespace ::com::sun::star::accessibility;
57using namespace ::com::sun::star::container;
58using namespace ::com::sun::star::lang;
59
60#define LINE_SIZE 50
61// Constants for the window layout
62#define TABWIN_SPACING_X 17
63#define TABWIN_SPACING_Y 17
64
65#define TABWIN_WIDTH_STD 120
66#define TABWIN_HEIGHT_STD 120
67
68OScrollWindowHelper::OScrollWindowHelper( vcl::Window* pParent) : Window( pParent)
69 ,m_aHScrollBar( VclPtr<ScrollAdaptor>::Create(this, true) )
70 ,m_aVScrollBar( VclPtr<ScrollAdaptor>::Create(this, false) )
71 ,m_pTableView(nullptr)
72{
74 SetBackground(aSystemStyle.GetFaceColor());
75
76 // ScrollBars
77 GetHScrollBar().SetRange( Range(0, 1000) );
78 GetVScrollBar().SetRange( Range(0, 1000) );
79
82
83 GetHScrollBar().Show();
84 GetVScrollBar().Show();
85
86 // normally we should be SCROLL_PANE
87 SetAccessibleRole(AccessibleRole::SCROLL_PANE);
88}
89
91{
93}
94
96{
99 m_pTableView.clear();
101}
102
104{
105 m_pTableView = _pTableView;
106 // ScrollBars
109}
110
112{
113 Point aPos = PixelToLogic(_aSize);
116}
117
119{
121
122 Size aTotalOutputSize = GetOutputSizePixel();
123 tools::Long nHScrollHeight = GetHScrollBar().GetSizePixel().Height();
124 tools::Long nVScrollWidth = GetVScrollBar().GetSizePixel().Width();
125
126 GetHScrollBar().SetPosSizePixel(
127 Point( 0, aTotalOutputSize.Height()-nHScrollHeight ),
128 Size( aTotalOutputSize.Width()-nVScrollWidth, nHScrollHeight )
129 );
130
131 GetVScrollBar().SetPosSizePixel(
132 Point( aTotalOutputSize.Width()-nVScrollWidth, 0 ),
133 Size( nVScrollWidth, aTotalOutputSize.Height()-nHScrollHeight )
134 );
135
136 GetHScrollBar().SetPageSize( aTotalOutputSize.Width() );
137 GetHScrollBar().SetVisibleSize( aTotalOutputSize.Width() );
138
139 GetVScrollBar().SetPageSize( aTotalOutputSize.Height() );
140 GetVScrollBar().SetVisibleSize( aTotalOutputSize.Height() );
141
142 // adjust the ranges of the scrollbars if necessary
144 if (m_pTableView->GetScrollOffset().X() + aTotalOutputSize.Width() > lRange)
145 GetHScrollBar().SetRangeMax(m_pTableView->GetScrollOffset().X() + aTotalOutputSize.Width() + GetHScrollBar().GetRange().Min());
146
147 lRange = GetVScrollBar().GetRange().Max() - GetVScrollBar().GetRange().Min();
148 if (m_pTableView->GetScrollOffset().Y() + aTotalOutputSize.Height() > lRange)
149 GetVScrollBar().SetRangeMax(m_pTableView->GetScrollOffset().Y() + aTotalOutputSize.Height() + GetVScrollBar().GetRange().Min());
150
151 m_pTableView->SetPosSizePixel(Point( 0, 0 ),Size( aTotalOutputSize.Width()-nVScrollWidth, aTotalOutputSize.Height()-nHScrollHeight ));
152}
153
154
156 :Window( pParent,WB_BORDER )
157 ,DropTargetHelper(this)
158 ,m_aDragScrollIdle("dbaccess OJoinTableView m_aDragScrollIdle")
159 ,m_aDragOffset( Point(0,0) )
160 ,m_aScrollOffset( Point(0,0) )
161 ,m_pDragWin( nullptr )
162 ,m_pSizingWin( nullptr )
163 ,m_pSelectedConn( nullptr )
164 ,m_pLastFocusTabWin(nullptr)
165 ,m_pView( pView )
166{
167 SetSizePixel( Size(1000, 1000) );
168
169 InitColors();
170
171 m_aDragScrollIdle.SetInvokeHandler(LINK(this, OJoinTableView, OnDragScrollTimer));
172}
173
175{
176 disposeOnce();
177}
178
180{
181 if( m_pAccessible )
182 {
183 m_pAccessible->clearTableView();
184 m_pAccessible = nullptr;
185 }
186 // delete lists
188 m_pDragWin.clear();
189 m_pSizingWin.clear();
190 m_pSelectedConn.clear();
191 m_pLastFocusTabWin.clear();
192 m_pView.clear();
193 m_vTableConnection.clear();
195}
196
197IMPL_LINK(OJoinTableView, HorzScrollHdl, weld::Scrollbar&, rScrollbar, void)
198{
199 // move all windows
200 ScrollPane(rScrollbar.adjustment_get_value() - m_aScrollOffset.X(), true, false);
201}
202
203IMPL_LINK(OJoinTableView, VertScrollHdl, weld::Scrollbar&, rScrollbar, void)
204{
205 // move all windows
206 ScrollPane(rScrollbar.adjustment_get_value() - m_aScrollOffset.Y(), false, false);
207}
208
210{
213
214 // tab win positions may not be up-to-date
215 if (m_aTableMap.empty())
216 // no tab wins ...
217 return;
218
219 // we have at least one table so resize it
220 m_aScrollOffset.setX( GetHScrollBar().GetThumbPos() );
221 m_aScrollOffset.setY( GetVScrollBar().GetThumbPos() );
222
223 VclPtr<OTableWindow> pCheck = m_aTableMap.begin()->second;
224 Point aRealPos = pCheck->GetPosPixel();
225 Point aAssumedPos = pCheck->GetData()->GetPosition() - GetScrollOffset();
226
227 if (aRealPos == aAssumedPos)
228 // all ok
229 return;
230
231 for (auto const& elem : m_aTableMap)
232 {
233 OTableWindow* pCurrent = elem.second;
234 Point aPos(pCurrent->GetData()->GetPosition() - GetScrollOffset());
235 pCurrent->SetPosPixel(aPos);
236 }
237}
238
240{
241 return m_aTableMap.size();
242}
243
245{
246 VclPtr<OTableConnection> xConn(rConn);
247
248 DeselectConn(xConn);
249
250 // to force a redraw
251 xConn->InvalidateConnection();
252
253 m_pView->getController().removeConnectionData(xConn->GetData());
254
255 m_vTableConnection.erase(std::find(m_vTableConnection.begin(), m_vTableConnection.end(), xConn));
256
257 modified();
258 if ( m_pAccessible )
259 m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
260 Any(xConn->GetAccessible()),
261 Any());
262 if (_bDelete)
263 xConn->disposeOnce();
264
265 return true;
266}
267
269{
270 OTableWindowMap::const_iterator aIter = m_aTableMap.find(rName);
271
272 return aIter == m_aTableMap.end() ? nullptr : aIter->second;
273}
274
275TTableWindowData::value_type OJoinTableView::createTableWindowData(const OUString& _rComposedName
276 ,const OUString& _sTableName
277 ,const OUString& _rWinName)
278{
279 TTableWindowData::value_type pData( CreateImpl(_rComposedName, _sTableName,_rWinName) );
280 OJoinDesignView* pParent = getDesignView();
281 try
282 {
283 if ( !pData->init(pParent->getController().getConnection(),allowQueries()) )
284 {
285 if ( pData->isValid() )
287 else
288 pData.reset();
289 }
290 }
291 catch ( const SQLException& )
292 {
293 ::dbtools::showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ),
294 VCLUnoHelper::GetInterface(pParent), pParent->getController().getORB() );
295 }
296 catch( const WrappedTargetException& e )
297 {
298 SQLException aSql;
299 if ( e.TargetException >>= aSql )
300 ::dbtools::showError( ::dbtools::SQLExceptionInfo( aSql ), VCLUnoHelper::GetInterface(pParent), pParent->getController().getORB() );
301 }
302 catch( const Exception& )
303 {
304 DBG_UNHANDLED_EXCEPTION("dbaccess");
305 }
306 return pData;
307}
308
309std::shared_ptr<OTableWindowData> OJoinTableView::CreateImpl(const OUString& _rComposedName
310 ,const OUString& _sTableName
311 ,const OUString& _rWinName)
312{
313 return std::make_shared<OTableWindowData>( nullptr,_rComposedName,_sTableName, _rWinName );
314}
315
316void OJoinTableView::AddTabWin(const OUString& _rComposedName, const OUString& rWinName, bool /*bNewTable*/)
317{
318 OSL_ENSURE(!_rComposedName.isEmpty(),"There must be a table name supplied!");
319
320 TTableWindowData::value_type pNewTabWinData(createTableWindowData( _rComposedName, rWinName,rWinName ));
321
322 // insert new window in window list
323 VclPtr<OTableWindow> pNewTabWin = createWindow( pNewTabWinData );
324 if ( pNewTabWin->Init() )
325 {
326 m_pView->getController().getTableWindowData().push_back( pNewTabWinData);
327 // when we already have a table with this name insert the full qualified one instead
328 if(m_aTableMap.find(rWinName) != m_aTableMap.end())
329 m_aTableMap[_rComposedName] = pNewTabWin;
330 else
331 m_aTableMap[rWinName] = pNewTabWin;
332
333 SetDefaultTabWinPosSize( pNewTabWin );
334 pNewTabWin->Show();
335
336 modified();
337 if ( m_pAccessible )
338 m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
339 Any(),
340 Any(pNewTabWin->GetAccessible()));
341 }
342 else
343 {
344 pNewTabWin->clearListBox();
345 pNewTabWin.disposeAndClear();
346 }
347}
348
350{
351 // first delete all connections of this window to others
352 bool bRemove = true;
353 TTableWindowData::value_type pData = pTabWin->GetData();
354 sal_Int32 nCount = m_vTableConnection.size();
355 auto aIter = m_vTableConnection.rbegin();
356 while(aIter != m_vTableConnection.rend() && bRemove)
357 {
358 VclPtr<OTableConnection>& rTabConn = *aIter;
359 if (
360 (pData == rTabConn->GetData()->getReferencingTable()) ||
361 (pData == rTabConn->GetData()->getReferencedTable())
362 )
363 {
364 bRemove = RemoveConnection(rTabConn, true);
365 aIter = m_vTableConnection.rbegin();
366 }
367 else
368 ++aIter;
369 }
370
371 // then delete the window itself
372 if ( bRemove )
373 {
374 if ( m_pAccessible )
375 m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
376 Any(pTabWin->GetAccessible()),Any()
377 );
378
379 pTabWin->Hide();
380 OJoinController& rController = m_pView->getController();
381 TTableWindowData::iterator aFind = std::find(rController.getTableWindowData().begin(), rController.getTableWindowData().end(), pData);
382 if(aFind != rController.getTableWindowData().end())
383 {
384 rController.getTableWindowData().erase(aFind);
385 rController.setModified(true);
386 }
387
388 if ( !m_aTableMap.erase( pTabWin->GetWinName() ) )
389 m_aTableMap.erase( pTabWin->GetComposedName() );
390
391 if (pTabWin == m_pLastFocusTabWin)
392 m_pLastFocusTabWin = nullptr;
393
394 pTabWin->clearListBox();
395 pTabWin->disposeOnce();
396 }
397
398 if ( static_cast<sal_Int32>(m_vTableConnection.size()) < (nCount-1) ) // if some connections could be removed
399 modified();
400}
401
402namespace
403{
404 bool isScrollAllowed( OJoinTableView* _pView,tools::Long nDelta, bool bHoriz)
405 {
406 // adjust ScrollBar-Positions
407 ScrollAdaptor& rBar = bHoriz ? _pView->GetHScrollBar() : _pView->GetVScrollBar();
408
409 tools::Long nOldThumbPos = rBar.GetThumbPos();
410 tools::Long nNewThumbPos = nOldThumbPos + nDelta;
411 if( nNewThumbPos < 0 )
412 nNewThumbPos = 0;
413 else if( nNewThumbPos > rBar.GetRangeMax() )
414 nNewThumbPos = rBar.GetRangeMax();
415
416 if ( bHoriz )
417 {
418 if( nNewThumbPos == _pView->GetScrollOffset().X() )
419 return false;
420 }
421 else if ( nNewThumbPos == _pView->GetScrollOffset().Y() )
422 return false;
423
424 return true;
425 }
426 bool getMovementImpl(OJoinTableView* _pView,const Point& _rPoint,const Size& _rSize,tools::Long& _nScrollX,tools::Long& _nScrollY)
427 {
428 _nScrollY = _nScrollX = 0;
429 // data about the tab win
430 Point aUpperLeft = _rPoint;
431 // normalize with respect to visibility
432 aUpperLeft -= _pView->GetScrollOffset();
433 Point aLowerRight(aUpperLeft.X() + _rSize.Width(), aUpperLeft.Y() + _rSize.Height());
434
435 // data about ourself
436 Size aSize = _pView->getRealOutputSize(); //GetOutputSizePixel();
437
438 bool bVisible = true;
439 bool bFitsHor = (aUpperLeft.X() >= 0) && (aLowerRight.X() <= aSize.Width());
440 bool bFitsVert= (aUpperLeft.Y() >= 0) && (aLowerRight.Y() <= aSize.Height());
441 if (!bFitsHor || !bFitsVert)
442 {
443 if (!bFitsHor)
444 {
445 // ensure the visibility of the right border
446 if ( aLowerRight.X() > aSize.Width() )
447 _nScrollX = aLowerRight.X() - aSize.Width() + TABWIN_SPACING_X;
448
449 // ensure the visibility of the left border (higher priority)
450 if ( aUpperLeft.X() < 0 )
451 _nScrollX = aUpperLeft.X() - TABWIN_SPACING_X;
452 }
453
454 if (!bFitsVert)
455 {
456 // lower border
457 if ( aLowerRight.Y() > aSize.Height() )
458 _nScrollY = aLowerRight.Y() - aSize.Height() + TABWIN_SPACING_Y;
459 // upper border
460 if ( aUpperLeft.Y() < 0 )
461 _nScrollY = aUpperLeft.Y() - TABWIN_SPACING_Y;
462 }
463
464 if ( _nScrollX ) // aSize.Width() > _rSize.Width() &&
465 bVisible = isScrollAllowed(_pView,_nScrollX, true);
466
467 if ( _nScrollY ) // aSize.Height() > _rSize.Height() &&
468 bVisible = bVisible && isScrollAllowed(_pView,_nScrollY, false);
469
470 if ( bVisible )
471 {
472 sal_Int32 nHRangeMax = _pView->GetHScrollBar().GetRangeMax();
473 sal_Int32 nVRangeMax = _pView->GetVScrollBar().GetRangeMax();
474
475 if ( aSize.Width() + _pView->GetHScrollBar().GetThumbPos() + _nScrollX > nHRangeMax )
476 bVisible = false;
477 if ( bVisible && aSize.Height() + _pView->GetVScrollBar().GetThumbPos() + _nScrollY > nVRangeMax )
478 bVisible = false;
479 }
480 }
481
482 return bVisible;
483 }
484} // end of ano namespace
485
486bool OJoinTableView::isMovementAllowed(const Point& _rPoint,const Size& _rSize)
487{
488 tools::Long nX,nY;
489 return getMovementImpl(this,_rPoint,_rSize,nX,nY);
490}
491
493{
494 // data about the tab win
495 TTableWindowData::value_type pData = _pWin->GetData();
496 EnsureVisible( pData->GetPosition() , pData->GetSize());
497 Invalidate(InvalidateFlags::NoChildren);
498}
499
500void OJoinTableView::EnsureVisible(const Point& _rPoint,const Size& _rSize)
501{
503
504 if ( getMovementImpl(this,_rPoint,_rSize,nScrollX,nScrollY) )
505 {
506 bool bVisible = true;
507 if (nScrollX)
508 bVisible = ScrollPane(nScrollX, true, true);
509
510 if (nScrollY && bVisible)
511 ScrollPane(nScrollY, false, true);
512 }
513}
514
516{
517 // determine position:
518 // the window is divided into lines with height TABWIN_SPACING_Y+TABWIN_HEIGHT_STD.
519 // Then for each line is checked, if there is space for another window.
520 // If there is no space, the next line is checked.
521 Size aOutSize = GetSizePixel();
522 Point aNewPos( 0,0 );
523 sal_uInt16 nRow = 0;
524 bool bEnd = false;
525 while( !bEnd )
526 {
527 // Set new position to start of line
528 aNewPos.setX( TABWIN_SPACING_X );
529 aNewPos.setY( (nRow+1) * TABWIN_SPACING_Y );
530
531 // determine rectangle for the corresponding line
532 tools::Rectangle aRowRect( Point(0,0), aOutSize );
533 aRowRect.SetTop( nRow * ( TABWIN_SPACING_Y + TABWIN_HEIGHT_STD ) );
534 aRowRect.SetBottom( (nRow+1) * ( TABWIN_SPACING_Y + TABWIN_HEIGHT_STD ) );
535
536 // check occupied areas of this line
537 for (auto const& elem : m_aTableMap)
538 {
539 OTableWindow* pOtherTabWin = elem.second;
540 tools::Rectangle aOtherTabWinRect( pOtherTabWin->GetPosPixel(), pOtherTabWin->GetSizePixel() );
541
542 if(
543 ( (aOtherTabWinRect.Top()>aRowRect.Top()) && (aOtherTabWinRect.Top()<aRowRect.Bottom()) ) ||
544 ( (aOtherTabWinRect.Bottom()>aRowRect.Top()) && (aOtherTabWinRect.Bottom()<aRowRect.Bottom()) )
545 )
546 {
547 // TabWin is in the line
548 if( aOtherTabWinRect.Right()>aNewPos.X() )
549 aNewPos.setX( aOtherTabWinRect.Right() + TABWIN_SPACING_X );
550 }
551 }
552
553 // Is there space left in this line?
554 if( (aNewPos.X()+TABWIN_WIDTH_STD)<aRowRect.Right() )
555 {
556 aNewPos.setY( aRowRect.Top() + TABWIN_SPACING_Y );
557 bEnd = true;
558 }
559 else
560 {
561 if( (aRowRect.Bottom()+aRowRect.GetHeight()) > aOutSize.Height() )
562 {
563 // insert it in the first row
564 sal_Int32 nCount = m_aTableMap.size() % (nRow+1);
565 ++nCount;
567 bEnd = true;
568 }
569 else
570 nRow++;
571
572 }
573 }
574
575 // determine size
577
578 // check if the new position in inside the scrollbars ranges
579 Point aBottom(aNewPos);
580 aBottom.AdjustX(aNewSize.Width() );
581 aBottom.AdjustY(aNewSize.Height() );
582
583 if(!GetHScrollBar().GetRange().Contains(aBottom.X()))
584 GetHScrollBar().SetRange( Range(0, aBottom.X()) );
585 if(!GetVScrollBar().GetRange().Contains(aBottom.Y()))
586 GetVScrollBar().SetRange( Range(0, aBottom.Y()) );
587
588 pTabWin->SetPosSizePixel( aNewPos, aNewSize );
589}
590
592{
593 if (rDCEvt.GetType() == DataChangedEventType::SETTINGS)
594 {
595 // consider the worst case: the colors changed, so adjust me
596 InitColors();
597 Invalidate(InvalidateFlags::NoChildren);
598 // due to the Invalidate, the connections are redrawn, so that they are also pictured in the new colors
599 }
600}
601
603{
604 // the colors for the illustration should be the system colors
606 SetBackground(Wallpaper(aSystemStyle.GetDialogColor()));
607}
608
609void OJoinTableView::BeginChildMove( OTableWindow* pTabWin, const Point& rMousePos )
610{
611
612 if (m_pView->getController().isReadOnly())
613 return;
614
615 m_pDragWin = pTabWin;
616 SetPointer(PointerStyle::Move);
617 Point aMousePos = ScreenToOutputPixel( rMousePos );
618 m_aDragOffset = aMousePos - pTabWin->GetPosPixel();
619 m_pDragWin->SetZOrder(nullptr, ZOrderFlags::First);
621}
622
623void OJoinTableView::NotifyTitleClicked( OTableWindow* pTabWin, const Point& rMousePos )
624{
626 BeginChildMove(pTabWin, rMousePos);
627}
628
630{
631
632 if (m_pView->getController().isReadOnly())
633 return;
634
635 SetPointer( nPointer );
636 m_pSizingWin = pTabWin;
638}
639
640bool OJoinTableView::ScrollPane( tools::Long nDelta, bool bHoriz, bool bPaintScrollBars )
641{
642 bool bRet = true;
643
644 // adjust ScrollBar-Positions
645 if( bPaintScrollBars )
646 {
647 if( bHoriz )
648 {
649 tools::Long nOldThumbPos = GetHScrollBar().GetThumbPos();
650 tools::Long nNewThumbPos = nOldThumbPos + nDelta;
651 if( nNewThumbPos < 0 )
652 {
653 nNewThumbPos = 0;
654 bRet = false;
655 }
656 if( nNewThumbPos > GetHScrollBar().GetRange().Max() )
657 {
658 nNewThumbPos = GetHScrollBar().GetRange().Max();
659 bRet = false;
660 }
661 GetHScrollBar().SetThumbPos( nNewThumbPos );
662 nDelta = GetHScrollBar().GetThumbPos() - nOldThumbPos;
663 }
664 else
665 {
666 tools::Long nOldThumbPos = GetVScrollBar().GetThumbPos();
667 tools::Long nNewThumbPos = nOldThumbPos+nDelta;
668 if( nNewThumbPos < 0 )
669 {
670 nNewThumbPos = 0;
671 bRet = false;
672 }
673 if( nNewThumbPos > GetVScrollBar().GetRange().Max() )
674 {
675 nNewThumbPos = GetVScrollBar().GetRange().Max();
676 bRet = false;
677 }
678 GetVScrollBar().SetThumbPos( nNewThumbPos );
679 nDelta = GetVScrollBar().GetThumbPos() - nOldThumbPos;
680 }
681 }
682
683 // If ScrollOffset hitting borders, no redrawing.
684 if( (GetHScrollBar().GetThumbPos()==m_aScrollOffset.X()) &&
685 (GetVScrollBar().GetThumbPos()==m_aScrollOffset.Y()) )
686 return false;
687
688 // set ScrollOffset anew
689 if (bHoriz)
690 m_aScrollOffset.setX( GetHScrollBar().GetThumbPos() );
691 else
692 m_aScrollOffset.setY( GetVScrollBar().GetThumbPos() );
693
694 // move all windows
695 OTableWindow* pTabWin;
696 Point aPos;
697
698 for (auto const& elem : m_aTableMap)
699 {
700 pTabWin = elem.second;
701 aPos = pTabWin->GetPosPixel();
702
703 if( bHoriz )
704 aPos.AdjustX( -nDelta );
705 else aPos.AdjustY( -nDelta );
706
707 pTabWin->SetPosPixel( aPos );
708 }
709
710 Invalidate(); // InvalidateFlags::NoChildren
711
712 return bRet;
713}
714
716{
717 HideTracking();
718
719 if (rTEvt.IsTrackingEnded())
720 {
721 if( m_pDragWin )
722 {
725
726 // adjust position of child after moving
727 // windows are not allowed to leave display range
728 Point aDragWinPos = rTEvt.GetMouseEvent().GetPosPixel() - m_aDragOffset;
729 Size aDragWinSize = m_pDragWin->GetSizePixel();
730 if( aDragWinPos.X() < 0 )
731 aDragWinPos.setX( 0 );
732 if( aDragWinPos.Y() < 0 )
733 aDragWinPos.setY( 0 );
734 if( (aDragWinPos.X() + aDragWinSize.Width()) > m_aOutputSize.Width() )
735 aDragWinPos.setX( m_aOutputSize.Width() - aDragWinSize.Width() - 1 );
736 if( (aDragWinPos.Y() + aDragWinSize.Height()) > m_aOutputSize.Height() )
737 aDragWinPos.setY( m_aOutputSize.Height() - aDragWinSize.Height() - 1 );
738 if( aDragWinPos.X() < 0 )
739 aDragWinPos.setX( 0 );
740 if( aDragWinPos.Y() < 0 )
741 aDragWinPos.setY( 0 );
742 // TODO : don't position window anew, if it is leaving range, but just expand the range
743
744 // position window
745 EndTracking();
746 m_pDragWin->SetZOrder(nullptr, ZOrderFlags::First);
747 // check, if I really moved
748 // (this prevents setting the modified-Flag, when there actually was no change0
749 TTableWindowData::value_type pData = m_pDragWin->GetData();
750 if ( ! (pData && pData->HasPosition() && (pData->GetPosition() == aDragWinPos)))
751 {
752 // old logic coordinates
753 Point ptOldPos = m_pDragWin->GetPosPixel() + Point(GetHScrollBar().GetThumbPos(), GetVScrollBar().GetThumbPos());
754 // new positioning
755 m_pDragWin->SetPosPixel(aDragWinPos);
756 TabWinMoved(m_pDragWin, ptOldPos);
757
758 m_pDragWin->GrabFocus();
759 }
760 m_pDragWin = nullptr;
761 SetPointer(PointerStyle::Arrow);
762 }
763 // else we handle the resizing
764 else if( m_pSizingWin )
765 {
766 SetPointer( PointerStyle::Arrow );
767 EndTracking();
768
769 // old physical coordinates
770
771 Size szOld = m_pSizingWin->GetSizePixel();
772 Point ptOld = m_pSizingWin->GetPosPixel();
774 m_pSizingWin->SetPosSizePixel( m_aSizingRect.TopLeft(), aNewSize );
775 TabWinSized(m_pSizingWin, ptOld, szOld);
776
777 m_pSizingWin->Invalidate( m_aSizingRect );
778 m_pSizingWin = nullptr;
779 }
780 }
781 else if (rTEvt.IsTrackingCanceled())
782 {
785 EndTracking();
786 }
787 else
788 {
789 if( m_pDragWin )
790 {
792 // scroll at window borders
794 }
795
796 if( m_pSizingWin )
797 {
798 Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
799 m_aSizingRect = m_pSizingWin->getSizingRect(aMousePos,m_aOutputSize);
801 ShowTracking( m_aSizingRect, ShowTrackFlags::Small | ShowTrackFlags::TrackWindow );
802 }
803 }
804}
805
807{
808}
809
811{
812 GrabFocus();
814}
815
817{
819 // Has a connection been selected?
820 if( m_vTableConnection.empty() )
821 return;
822
824
825 for (auto & elem : m_vTableConnection)
826 {
827 if( elem->CheckHit(rEvt.GetPosPixel()) )
828 {
829 SelectConn(elem);
830
831 // Double-click
832 if( rEvt.GetClicks() == 2 )
833 ConnDoubleClicked(elem);
834
835 break;
836 }
837 }
838}
839
841{
842 sal_uInt16 nCode = rEvt.GetKeyCode().GetCode();
843 bool bShift = rEvt.GetKeyCode().IsShift();
844 bool bCtrl = rEvt.GetKeyCode().IsMod1();
845
846 if( !bCtrl && !bShift && (nCode==KEY_DELETE) )
847 {
848 if (GetSelectedConn())
850 }
851 else
852 Window::KeyInput( rEvt );
853}
854
856{
857 if (!pConn || !pConn->IsSelected())
858 return;
859
860 // deselect the corresponding entries in the ListBox of the table window
861 OTableWindow* pWin = pConn->GetSourceWin();
862 if (pWin && pWin->GetListBox())
863 pWin->GetListBox()->get_widget().unselect_all();
864
865 pWin = pConn->GetDestWin();
866 if (pWin && pWin->GetListBox())
867 pWin->GetListBox()->get_widget().unselect_all();
868
869 pConn->Deselect();
870 m_pSelectedConn = nullptr;
871}
872
874{
876
877 pConn->Select();
878 m_pSelectedConn = pConn;
879 GrabFocus(); // has to be called here because a table window may still be focused
880
881 // select the concerned entries in the windows
882 OTableWindow* pConnSource = pConn->GetSourceWin();
883 OTableWindow* pConnDest = pConn->GetDestWin();
884 if (!(pConnSource && pConnDest))
885 return;
886
887 OTableWindowListBox* pSourceBox = pConnSource->GetListBox().get();
888 OTableWindowListBox* pDestBox = pConnDest->GetListBox().get();
889 if (!(pSourceBox && pDestBox))
890 return;
891
892 pSourceBox->get_widget().unselect_all();
893 pDestBox->get_widget().unselect_all();
894
895 bool bScrolled = false;
896
897 const std::vector<std::unique_ptr<OConnectionLine>>& rLines = pConn->GetConnLineList();
898 auto aIter = rLines.rbegin();
899 for(;aIter != rLines.rend();++aIter)
900 {
901 if ((*aIter)->IsValid())
902 {
903 int nSourceEntry = pSourceBox->GetEntryFromText((*aIter)->GetData()->GetSourceFieldName());
904 if (nSourceEntry != -1)
905 {
906 pSourceBox->get_widget().select(nSourceEntry);
907 pSourceBox->get_widget().scroll_to_row(nSourceEntry);
908 bScrolled = true;
909 }
910
911 int nDestEntry = pDestBox->GetEntryFromText((*aIter)->GetData()->GetDestFieldName());
912 if (nDestEntry != -1)
913 {
914 pDestBox->get_widget().select(nDestEntry);
915 pDestBox->get_widget().scroll_to_row(nDestEntry);
916 bScrolled = true;
917 }
918 }
919 }
920
921 if (bScrolled)
922 {
923 // scrolling was done -> redraw
924 Invalidate(InvalidateFlags::NoChildren);
925 }
926}
927
929{
930 DrawConnections(rRenderContext, rRect);
931}
932
934{
935 // draw Joins
936 for (auto & conn : m_vTableConnection)
937 conn->InvalidateConnection();
938}
939
941{
942 // draw Joins
943 for(const auto& connection : m_vTableConnection)
944 connection->Draw(rRenderContext, rRect);
945 // finally redraw the selected one above all others
946 if (GetSelectedConn())
947 GetSelectedConn()->Draw(rRenderContext, rRect);
948}
949
950std::vector<VclPtr<OTableConnection> >::const_iterator OJoinTableView::getTableConnections(const OTableWindow* _pFromWin) const
951{
952 return std::find_if( m_vTableConnection.begin(),
953 m_vTableConnection.end(),
954 [_pFromWin](OTableConnection * p) { return p->isTableConnection(_pFromWin); });
955}
956
957sal_Int32 OJoinTableView::getConnectionCount(const OTableWindow* _pFromWin) const
958{
959 return std::count_if( m_vTableConnection.begin(),
960 m_vTableConnection.end(),
961 [_pFromWin](OTableConnection * p) { return p->isTableConnection(_pFromWin); });
962}
963
965{
966 return getTableConnections(pFrom) != m_vTableConnection.end();
967}
968
970{
971 SetUpdateMode(false);
972
973 HideTabWins();
974
975 // and the same with the Connections
976 for (auto & elem : m_vTableConnection)
977 {
978 RemoveConnection(elem, true);
979 }
980 m_vTableConnection.clear();
981
982 m_pLastFocusTabWin = nullptr;
983 m_pSelectedConn = nullptr;
984
985 // scroll to the upper left
986 ScrollPane(-GetScrollOffset().X(), true, true);
987 ScrollPane(-GetScrollOffset().Y(), false, true);
988 Invalidate();
989}
990
992{
993 OSL_ENSURE(m_pDragWin != nullptr, "OJoinTableView::ScrollWhileDragging must not be called when a window is being dragged !");
994
995 // kill the timer
998
1000 Size aDragWinSize = m_pDragWin->GetSizePixel();
1001 Point aLowerRight(aDragWinPos.X() + aDragWinSize.Width(), aDragWinPos.Y() + aDragWinSize.Height());
1002
1003 if (aDragWinPos == m_pDragWin->GetPosPixel())
1004 return;
1005
1006 // avoid illustration errors (when scrolling with active TrackingRect)
1007 HideTracking();
1008
1009 bool bScrolling = false;
1010 bool bNeedScrollTimer = false;
1011
1012 // scroll at window borders
1013 // TODO : only catch, if window would disappear completely (don't, if there is still a pixel visible)
1014 if( aDragWinPos.X() < 5 )
1015 {
1016 bScrolling = ScrollPane( -LINE_SIZE, true, true );
1017 if( !bScrolling && (aDragWinPos.X()<0) )
1018 aDragWinPos.setX( 0 );
1019
1020 // do I need further (timer controlled) scrolling ?
1021 bNeedScrollTimer = bScrolling && (aDragWinPos.X() < 5);
1022 }
1023
1024 if( aLowerRight.X() > m_aOutputSize.Width() - 5 )
1025 {
1026 bScrolling = ScrollPane( LINE_SIZE, true, true ) ;
1027 if( !bScrolling && ( aLowerRight.X() > m_aOutputSize.Width() ) )
1028 aDragWinPos.setX( m_aOutputSize.Width() - aDragWinSize.Width() );
1029
1030 // do I need further (timer controlled) scrolling ?
1031 bNeedScrollTimer = bScrolling && (aLowerRight.X() > m_aOutputSize.Width() - 5);
1032 }
1033
1034 if( aDragWinPos.Y() < 5 )
1035 {
1036 bScrolling = ScrollPane( -LINE_SIZE, false, true );
1037 if( !bScrolling && (aDragWinPos.Y()<0) )
1038 aDragWinPos.setY( 0 );
1039
1040 bNeedScrollTimer = bScrolling && (aDragWinPos.Y() < 5);
1041 }
1042
1043 if( aLowerRight.Y() > m_aOutputSize.Height() - 5 )
1044 {
1045 bScrolling = ScrollPane( LINE_SIZE, false, true );
1046 if( !bScrolling && ( (aDragWinPos.Y() + aDragWinSize.Height()) > m_aOutputSize.Height() ) )
1047 aDragWinPos.setY( m_aOutputSize.Height() - aDragWinSize.Height() );
1048
1049 bNeedScrollTimer = bScrolling && (aLowerRight.Y() > m_aOutputSize.Height() - 5);
1050 }
1051
1052 // resetting timer, if still necessary
1053 if (bNeedScrollTimer)
1054 {
1055 m_aDragScrollIdle.SetPriority( TaskPriority::HIGH_IDLE );
1057 }
1058
1059 // redraw DraggingRect
1062 ShowTracking( m_aDragRect, ShowTrackFlags::Small | ShowTrackFlags::TrackWindow );
1063}
1064
1065IMPL_LINK_NOARG(OJoinTableView, OnDragScrollTimer, Timer *, void)
1066{
1067 ScrollWhileDragging();
1068}
1069
1070void OJoinTableView::invalidateAndModify(std::unique_ptr<SfxUndoAction> _pAction)
1071{
1072 Invalidate(InvalidateFlags::NoChildren);
1073 m_pView->getController().addUndoActionAndInvalidate(std::move(_pAction));
1074}
1075
1076void OJoinTableView::TabWinMoved(OTableWindow* ptWhich, const Point& ptOldPosition)
1077{
1078 Point ptThumbPos(GetHScrollBar().GetThumbPos(), GetVScrollBar().GetThumbPos());
1079 ptWhich->GetData()->SetPosition(ptWhich->GetPosPixel() + ptThumbPos);
1080
1081 invalidateAndModify(std::make_unique<OJoinMoveTabWinUndoAct>(this, ptOldPosition, ptWhich));
1082}
1083
1084void OJoinTableView::TabWinSized(OTableWindow* ptWhich, const Point& ptOldPosition, const Size& szOldSize)
1085{
1086 ptWhich->GetData()->SetSize(ptWhich->GetSizePixel());
1087 ptWhich->GetData()->SetPosition(ptWhich->GetPosPixel());
1088
1089 invalidateAndModify(std::make_unique<OJoinSizeTabWinUndoAct>(this, ptOldPosition, szOldSize, ptWhich));
1090}
1091
1093{
1094
1095 // not, if Db readonly
1096 if (m_pView->getController().isReadOnly())
1097 return false;
1098
1099 try
1100 {
1101 Reference< XConnection> xConnection = m_pView->getController().getConnection();
1102 if(!xConnection.is())
1103 return false;
1104 // not, if too many tables already
1105 Reference < XDatabaseMetaData > xMetaData( xConnection->getMetaData() );
1106
1107 sal_Int32 nMax = xMetaData.is() ? xMetaData->getMaxTablesInSelect() : 0;
1108 if (nMax && nMax <= static_cast<sal_Int32>(m_aTableMap.size()))
1109 return false;
1110 }
1111 catch(SQLException&)
1112 {
1113 return false;
1114 }
1115
1116 return true;
1117}
1118
1120{
1121 ::tools::Rectangle aRect(rPos, Size(1, 1));
1122 weld::Window* pPopupParent = weld::GetPopupParent(*this, aRect);
1123 std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pPopupParent, "dbaccess/ui/joinviewmenu.ui"));
1124 std::unique_ptr<weld::Menu> xContextMenu(xBuilder->weld_menu("menu"));
1125 OUString sIdent = xContextMenu->popup_at_rect(pPopupParent, aRect);
1126 if (sIdent == "delete")
1127 RemoveConnection(rSelConnection, true);
1128 else if (sIdent == "edit")
1129 ConnDoubleClicked(rSelConnection); // is the same as double clicked
1130}
1131
1133{
1134
1135 bool bHandled = false;
1136
1137 switch (rEvt.GetCommand())
1138 {
1139 case CommandEventId::ContextMenu:
1140 {
1141 if( m_vTableConnection.empty() )
1142 return;
1143
1144 VclPtr<OTableConnection>& rSelConnection = GetSelectedConn();
1145 // when it wasn't a mouse event use the selected connection
1146 if (!rEvt.IsMouseEvent())
1147 {
1148 if (rSelConnection)
1149 {
1150 const std::vector<std::unique_ptr<OConnectionLine>>& rLines = rSelConnection->GetConnLineList();
1151 auto aIter = std::find_if(rLines.begin(), rLines.end(),std::mem_fn(&OConnectionLine::IsValid));
1152 if( aIter != rLines.end() )
1153 executePopup((*aIter)->getMidPoint(), rSelConnection);
1154 }
1155 }
1156 else
1157 {
1158 DeselectConn(rSelConnection);
1159
1160 const Point& aMousePos = rEvt.GetMousePosPixel();
1161 for (auto & elem : m_vTableConnection)
1162 {
1163 if( elem->CheckHit(aMousePos) )
1164 {
1165 SelectConn(elem);
1166 if(!getDesignView()->getController().isReadOnly() && getDesignView()->getController().isConnected())
1167 executePopup(rEvt.GetMousePosPixel(),elem);
1168 break;
1169 }
1170 }
1171 }
1172 bHandled = true;
1173 }
1174 break;
1175 default: break;
1176 }
1177 if (!bHandled)
1178 Window::Command(rEvt);
1179}
1180
1181OTableConnection* OJoinTableView::GetTabConn(const OTableWindow* pLhs,const OTableWindow* pRhs,bool _bSuppressCrossOrNaturalJoin) const
1182{
1183 OTableConnection* pConn = nullptr;
1184 OSL_ENSURE(pRhs || pLhs, "OJoinTableView::GetTabConn : invalid args !");
1185 // only one NULL-arg allowed
1186
1187 if ((!pLhs || pLhs->ExistsAConn()) && (!pRhs || pRhs->ExistsAConn()))
1188 {
1190 {
1191 if ( ( (pData->GetSourceWin() == pLhs)
1192 && ( (pData->GetDestWin() == pRhs)
1193 || (nullptr == pRhs)
1194 )
1195 )
1196 || ( (pData->GetSourceWin() == pRhs)
1197 && ( (pData->GetDestWin() == pLhs)
1198 || (nullptr == pLhs)
1199 )
1200 )
1201 )
1202 {
1203 if ( _bSuppressCrossOrNaturalJoin )
1204 {
1205 if ( suppressCrossNaturalJoin(pData->GetData()) )
1206 continue;
1207 }
1208 pConn = pData;
1209 break;
1210 }
1211 }
1212 }
1213 return pConn;
1214}
1215
1217{
1218 bool bHandled = false;
1219 switch (rNEvt.GetType())
1220 {
1221 case NotifyEventType::COMMAND:
1222 {
1223 const CommandEvent* pCommand = rNEvt.GetCommandEvent();
1224 if (pCommand->GetCommand() == CommandEventId::Wheel)
1225 {
1227 if (pData->GetMode() == CommandWheelMode::SCROLL)
1228 {
1229 if (pData->GetDelta() > 0)
1230 ScrollPane(-10 * pData->GetScrollLines(), pData->IsHorz(), true);
1231 else
1232 ScrollPane(10 * pData->GetScrollLines(), pData->IsHorz(), true);
1233 bHandled = true;
1234 }
1235 }
1236 }
1237 break;
1238 case NotifyEventType::KEYINPUT:
1239 {
1240 if (m_aTableMap.empty())
1241 // no tab wins -> no conns -> no traveling
1242 break;
1243
1244 const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
1245 if (!pKeyEvent->GetKeyCode().IsMod1())
1246 {
1247 switch (pKeyEvent->GetKeyCode().GetCode())
1248 {
1249 case KEY_TAB:
1250 {
1251 if (!HasChildPathFocus())
1252 break;
1253
1254 bool bForward = !pKeyEvent->GetKeyCode().IsShift();
1255 // is there an active tab win ?
1256 OTableWindowMap::const_iterator aIter = std::find_if(m_aTableMap.begin(), m_aTableMap.end(),
1257 [](const OTableWindowMap::value_type& rEntry) { return rEntry.second && rEntry.second->HasChildPathFocus(); });
1258
1259 OTableWindow* pNextWin = nullptr;
1260 OTableConnection* pNextConn = nullptr;
1261
1262 if (aIter != m_aTableMap.end())
1263 { // there is a currently active tab win
1264 // check if there is an "overflow" and we should select a conn instead of a win
1265 if (!m_vTableConnection.empty())
1266 {
1267 if ((aIter->second == m_aTableMap.rbegin()->second) && bForward)
1268 // the last win is active and we're travelling forward -> select the first conn
1269 pNextConn = m_vTableConnection.begin()->get();
1270 if ((aIter == m_aTableMap.begin()) && !bForward)
1271 // the first win is active and we're traveling backward -> select the last conn
1272 pNextConn = m_vTableConnection.rbegin()->get();
1273 }
1274
1275 if (!pNextConn)
1276 {
1277 // no conn for any reason -> select the next or previous tab win
1278 if(bForward)
1279 {
1280 if ( aIter->second == m_aTableMap.rbegin()->second )
1281 pNextWin = m_aTableMap.begin()->second;
1282 else
1283 {
1284 ++aIter;
1285 pNextWin = aIter->second;
1286 }
1287 }
1288 else
1289 {
1290 if (aIter == m_aTableMap.begin())
1291 pNextWin = m_aTableMap.rbegin()->second;
1292 else
1293 {
1294 --aIter;
1295 pNextWin = aIter->second;
1296 }
1297 }
1298 }
1299 }
1300 else
1301 { // no active tab win -> travel the connections
1302 // find the currently selected conn within the conn list
1303 sal_Int32 i(0);
1304 for (auto const& elem : m_vTableConnection)
1305 {
1306 if ( elem.get() == GetSelectedConn() )
1307 break;
1308 ++i;
1309 }
1310 if (i == sal_Int32(m_vTableConnection.size() - 1) && bForward)
1311 // the last conn is active and we're travelling forward -> select the first win
1312 pNextWin = m_aTableMap.begin()->second;
1313 if ((i == 0) && !bForward && !m_aTableMap.empty())
1314 // the first conn is active and we're travelling backward -> select the last win
1315 pNextWin = m_aTableMap.rbegin()->second;
1316
1317 if (pNextWin)
1319 else
1320 // no win for any reason -> select the next or previous conn
1321 if (i < static_cast<sal_Int32>(m_vTableConnection.size()))
1322 // there is a currently active conn
1323 pNextConn = m_vTableConnection[(i + (bForward ? 1 : m_vTableConnection.size() - 1)) % m_vTableConnection.size()].get();
1324 else
1325 { // no tab win selected, no conn selected
1326 if (!m_vTableConnection.empty())
1327 pNextConn = m_vTableConnection[bForward ? 0 : m_vTableConnection.size() - 1].get();
1328 else if (!m_aTableMap.empty())
1329 {
1330 if(bForward)
1331 pNextWin = m_aTableMap.begin()->second;
1332 else
1333 pNextWin = m_aTableMap.rbegin()->second;
1334 }
1335 }
1336 }
1337
1338 // now select the object
1339 if (pNextWin)
1340 {
1341 if (pNextWin->GetListBox())
1342 pNextWin->GetListBox()->GrabFocus();
1343 else
1344 pNextWin->GrabFocus();
1345 EnsureVisible(pNextWin);
1346 }
1347 else if (pNextConn)
1348 {
1349 GrabFocus();
1350 // necessary : a conn may be selected even if a tab win has the focus, in this case
1351 // the next travel would select the same conn again if we would not reset the focus ...
1352 SelectConn(pNextConn);
1353 }
1354 }
1355 break;
1356 case KEY_RETURN:
1357 {
1358 if (!pKeyEvent->GetKeyCode().IsShift() && GetSelectedConn() && HasFocus())
1360 break;
1361 }
1362 }
1363 }
1364 }
1365 break;
1366 case NotifyEventType::GETFOCUS:
1367 {
1368 if (m_aTableMap.empty())
1369 // no tab wins -> no conns -> no focus change
1370 break;
1371 vcl::Window* pSource = rNEvt.GetWindow();
1372 if (pSource)
1373 {
1374 vcl::Window* pSearchFor = nullptr;
1375 if (pSource->GetParent() == this)
1376 // it may be one of the tab wins
1377 pSearchFor = pSource;
1378 else if (pSource->GetParent() && (pSource->GetParent()->GetParent() == this))
1379 // it may be one of th list boxes of one of the tab wins
1380 pSearchFor = pSource->GetParent();
1381
1382 if (pSearchFor)
1383 {
1384 for (auto const& elem : m_aTableMap)
1385 {
1386 if (elem.second == pSearchFor)
1387 {
1388 m_pLastFocusTabWin = elem.second;
1389 break;
1390 }
1391 }
1392 }
1393 }
1394 }
1395 break;
1396 default:
1397 break;
1398 }
1399
1400 if (!bHandled)
1401 return Window::PreNotify(rNEvt);
1402 return true;
1403}
1404
1406{
1407 if (m_pLastFocusTabWin && m_pLastFocusTabWin->IsVisible())
1408 {
1409 if (m_pLastFocusTabWin->GetListBox())
1410 m_pLastFocusTabWin->GetListBox()->GrabFocus();
1411 else
1412 m_pLastFocusTabWin->GrabFocus();
1413 }
1414 else if (!m_aTableMap.empty() && m_aTableMap.begin()->second && m_aTableMap.begin()->second->IsVisible())
1415 {
1416 VclPtr<OTableWindow> pFirstWin = m_aTableMap.begin()->second;
1417 if (pFirstWin->GetListBox())
1418 pFirstWin->GetListBox()->GrabFocus();
1419 else
1420 pFirstWin->GrabFocus();
1421 }
1422}
1423
1425{
1427
1428 // FIXME RenderContext
1429 if ( nType != StateChangedType::Zoom )
1430 return;
1431
1432 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1433
1434 vcl::Font aFont = rStyleSettings.GetGroupFont();
1435 if ( IsControlFont() )
1436 aFont.Merge( GetControlFont() );
1437 SetZoomedPointFont(*GetOutDev(), aFont);
1438
1439 for (auto const& elem : m_aTableMap)
1440 {
1441 elem.second->SetZoom(GetZoom());
1442 Size aSize(CalcZoom(elem.second->GetSizePixel().Width()),CalcZoom(elem.second->GetSizePixel().Height()));
1443 elem.second->SetSizePixel(aSize);
1444 }
1445 Resize();
1446}
1447
1449{
1450 SetUpdateMode(false);
1451
1452 OTableWindowMap& rTabWins = GetTabWinMap();
1453
1454 // working on a copy because the real list will be cleared in inner calls
1455 OTableWindowMap aCopy(rTabWins);
1456 for (auto const& elem : aCopy)
1457 RemoveTabWin(elem.second);
1458
1459 m_pView->getController().setModified(true);
1460
1461 SetUpdateMode(true);
1462
1463}
1464
1466{
1467 return DND_ACTION_NONE;
1468}
1469
1471{
1472 return DND_ACTION_NONE;
1473}
1474
1476{
1477}
1478
1480{
1481 m_pLastFocusTabWin = nullptr;
1482 m_pSelectedConn = nullptr;
1483 // delete lists
1484 for (auto & elem : m_aTableMap)
1485 {
1486 if ( elem.second )
1487 elem.second->clearListBox();
1488 elem.second.disposeAndClear();
1489 }
1490
1491 m_aTableMap.clear();
1492
1493 for (auto & elem : m_vTableConnection)
1494 elem.disposeAndClear();
1495
1496 m_vTableConnection.clear();
1497}
1498
1500{
1501}
1502
1504{
1507}
1508
1510{
1512 if ( !m_aTableMap.empty() && !GetSelectedConn() )
1514}
1515
1517{
1519 return m_pAccessible;
1520}
1521
1523{
1524 OJoinController& rController = m_pView->getController();
1525 rController.setModified( true );
1526 rController.InvalidateFeature(ID_BROWSER_ADDTABLE);
1527 rController.InvalidateFeature(SID_RELATION_ADD_RELATION);
1528}
1529
1530void OJoinTableView::addConnection(OTableConnection* _pConnection,bool _bAddData)
1531{
1532 if ( _bAddData )
1533 {
1534#if OSL_DEBUG_LEVEL > 0
1535 TTableConnectionData& rTabConnDataList = m_pView->getController().getTableConnectionData();
1536 OSL_ENSURE( std::find(rTabConnDataList.begin(), rTabConnDataList.end(),_pConnection->GetData()) == rTabConnDataList.end(),"Data already in vector!");
1537#endif
1538 m_pView->getController().getTableConnectionData().push_back(_pConnection->GetData());
1539 }
1540 m_vTableConnection.emplace_back(_pConnection);
1541 _pConnection->RecalcLines();
1542 _pConnection->InvalidateConnection();
1543
1544 modified();
1545 if ( m_pAccessible )
1546 m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
1547 Any(),
1548 Any(_pConnection->GetAccessible()));
1549}
1550
1552{
1553 return true;
1554}
1555
1557{
1558 OSL_FAIL( "OTableWindow::onNoColumns_throw: cannot really handle this!" );
1559 throw SQLException();
1560}
1561
1562bool OJoinTableView::suppressCrossNaturalJoin(const TTableConnectionData::value_type& ) const
1563{
1564 return false;
1565}
1566
1567/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define TABWIN_SPACING_Y
#define TABWIN_WIDTH_STD
#define TABWIN_HEIGHT_STD
#define TABWIN_SPACING_X
#define LINE_SIZE
#define ID_BROWSER_ADDTABLE
Definition: browserids.hxx:53
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
CommandEventId GetCommand() const
const CommandWheelData * GetWheelData() const
const Point & GetMousePosPixel() const
bool IsMouseEvent() const
DataChangedEventType GetType() const
virtual void Start(bool bStartTimer=true) override
const vcl::KeyCode & GetKeyCode() const
sal_uInt16 GetClicks() const
const Point & GetPosPixel() const
const KeyEvent * GetKeyEvent() const
vcl::Window * GetWindow() const
const CommandEvent * GetCommandEvent() const
NotifyEventType GetType() const
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
tools::Long Max() const
tools::Long Min() const
void SetScrollHdl(const Link< weld::Scrollbar &, void > &rLink)
virtual void SetRange(const Range &rRange) override
virtual tools::Long GetThumbPos() const override
virtual Range GetRange() const override
virtual void SetPageSize(tools::Long nNewSize) override
virtual void SetVisibleSize(tools::Long nNewSize) override
virtual void SetRangeMax(tools::Long nNewRange) override
virtual tools::Long GetRangeMax() const override
virtual void SetLineSize(tools::Long nNewSize) override
virtual void SetThumbPos(tools::Long nThumbPos) override
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const vcl::Font & GetGroupFont() const
const Color & GetDialogColor() const
const Color & GetFaceColor() const
bool IsActive() const
void SetPriority(TaskPriority ePriority)
void Stop()
void SetInvokeHandler(const Link< Timer *, void > &rLink)
bool IsTrackingEnded() const
bool IsTrackingCanceled() const
const MouseEvent & GetMouseEvent() const
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
void disposeAndClear()
TTableWindowData & getTableWindowData()
the class OJoinDesignViewAccess represents the accessible object for join views like the QueryDesign ...
Definition: JAccess.hxx:33
OJoinController & getController() const
void NotifyTitleClicked(OTableWindow *pTabWin, const Point &rMousePos)
virtual void dispose() override
void BeginChildMove(OTableWindow *pTabWin, const Point &rMousePos)
void TabWinMoved(OTableWindow *ptWhich, const Point &ptOldPosition)
Hook that is called after moving/resizing TabWins.
virtual void KeyInput(const KeyEvent &rEvt) override
virtual void LoseFocus() override
ScrollAdaptor & GetVScrollBar()
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
rtl::Reference< OJoinDesignViewAccess > m_pAccessible
const std::vector< VclPtr< OTableConnection > > & getTableConnections() const
gives a read only access to the connection vector
void executePopup(const Point &_aPos, VclPtr< OTableConnection > &rSelConnection)
opens the context menu to delete a connection
virtual bool RemoveConnection(VclPtr< OTableConnection > &rConnection, bool bDelete)
RemoveConnection allows to remove connections from join table view.
const Point & GetScrollOffset() const
OTableWindow * GetTabWindow(const OUString &rName)
VclPtr< OTableWindow > m_pLastFocusTabWin
VclPtr< OTableWindow > m_pDragWin
void TabWinSized(OTableWindow *ptWhich, const Point &ptOldPosition, const Size &szOldSize)
sal_Int32 getConnectionCount(const OTableWindow *_pFromWin) const
how many connection belongs to single table
tools::Rectangle m_aSizingRect
void clearLayoutInformation()
clear the window map and connection vector without destroying it
virtual VclPtr< OTableWindow > createWindow(const TTableWindowData::value_type &_pData)=0
factory method to create table windows
virtual void MouseButtonDown(const MouseEvent &rEvt) override
TTableWindowData::value_type createTableWindowData(const OUString &_rComposedName, const OUString &_sTableName, const OUString &_rWinName)
virtual ~OJoinTableView() override
virtual void EnsureVisible(const OTableWindow *_pWin)
virtual void Resize() override
virtual void Command(const CommandEvent &rEvt) override
VclPtr< OTableWindow > m_pSizingWin
bool ExistsAConn(const OTableWindow *pFromWin) const
std::map< OUString, VclPtr< OTableWindow > > OTableWindowMap
void BeginChildSizing(OTableWindow *pTabWin, PointerStyle nPointer)
virtual bool IsAddAllowed()
virtual void ClearAll()
Hard deletion.
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
VclPtr< OTableConnection > m_pSelectedConn
virtual bool allowQueries() const
determines whether the classes Init method should accept a query name, or only table names
void GrabTabWinFocus()
set the focus to that tab win which most recently had it (or to the first available one)
void SelectConn(OTableConnection *pConn)
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
virtual bool suppressCrossNaturalJoin(const TTableConnectionData::value_type &_pData) const
virtual std::shared_ptr< OTableWindowData > CreateImpl(const OUString &_rComposedName, const OUString &_sTableName, const OUString &_rWinName)
OJoinDesignView * getDesignView() const
OTableWindowMap m_aTableMap
virtual void GetFocus() override
virtual void Tracking(const TrackingEvent &rTEvt) override
void DeselectConn(OTableConnection *pConn)
std::vector< VclPtr< OTableConnection > > m_vTableConnection
VclPtr< OJoinDesignView > m_pView
bool ScrollPane(tools::Long nDelta, bool bHoriz, bool bPaintScrollBars)
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
virtual void ConnDoubleClicked(VclPtr< OTableConnection > &rConnection)
const Size & getRealOutputSize() const
sal_Int64 GetTabWinCount() const
bool isMovementAllowed(const Point &_rPoint, const Size &_rSize)
check if the given window is visible.
VclPtr< OTableConnection > & GetSelectedConn()
virtual void RemoveTabWin(OTableWindow *pTabWin)
void SetDefaultTabWinPosSize(OTableWindow *pTabWin)
virtual bool PreNotify(NotifyEvent &rNEvt) override
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
tools::Rectangle m_aDragRect
void DrawConnections(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
virtual void dragFinished() override
called when a drag operation done with a Transferable has been finished
ScrollAdaptor & GetHScrollBar()
void invalidateAndModify(std::unique_ptr< SfxUndoAction > _pAction)
invalidates this window without children and set the controller modified
OTableConnection * GetTabConn(const OTableWindow *pLhs, const OTableWindow *pRhs, bool _bSuppressCrossOrNaturalJoin=false) const
OJoinTableView(vcl::Window *pParent, OJoinDesignView *pView)
void addConnection(OTableConnection *_pConnection, bool _bAddData=true)
allows to add new connections to join table view
virtual void lookForUiActivities()
virtual void StateChanged(StateChangedType nStateChange) override
OTableWindowMap & GetTabWinMap()
virtual void AddTabWin(const OUString &_rComposedName, const OUString &rWinName, bool bNewTable=false)
virtual void onNoColumns_throw()
called when init fails at the tablewindowdata because the m_xTable object could not provide columns,...
virtual void MouseButtonUp(const MouseEvent &rEvt) override
ScrollAdaptor & GetVScrollBar()
virtual void dispose() override
void setTableView(OJoinTableView *_pTableView)
virtual ~OScrollWindowHelper() override
VclPtr< ScrollAdaptor > m_aVScrollBar
ScrollAdaptor & GetHScrollBar()
VclPtr< OJoinTableView > m_pTableView
virtual void Resize() override
VclPtr< ScrollAdaptor > m_aHScrollBar
void resetRange(const Point &_aSize)
const TTableConnectionData::value_type & GetData() const
OTableWindow * GetDestWin() const
OTableWindow * GetSourceWin() const
const std::vector< std::unique_ptr< OConnectionLine > > & GetConnLineList() const
int GetEntryFromText(std::u16string_view rEntryText)
const weld::TreeView & get_widget() const
bool ExistsAConn() const
const TTableWindowData::value_type & GetData() const
void SetPosPixel(const Point &rNewPos) override
OUString const & GetWinName() const
void clearListBox()
clears the listbox inside.
const VclPtr< OTableWindowListBox > & GetListBox() const
void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize) override
OUString const & GetComposedName() const
constexpr void SetTop(tools::Long v)
constexpr tools::Long Top() const
constexpr Point TopLeft() const
constexpr Size GetSize() const
constexpr tools::Long Right() const
constexpr void SetBottom(tools::Long v)
constexpr tools::Long GetHeight() const
constexpr tools::Long Bottom() const
void Merge(const Font &rFont)
bool IsMod1() const
sal_uInt16 GetCode() const
bool IsShift() const
virtual void dispose() override
void SetUpdateMode(bool bUpdate)
virtual void GetFocus()
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
vcl::Window * GetParent() const
virtual void StateChanged(StateChangedType nStateChange)
void PaintImmediately()
bool HasChildPathFocus(bool bSystemWindow=false) const
bool IsControlFont() const
void EndTracking(TrackingEventFlags nFlags=TrackingEventFlags::NONE)
void SetZoomedPointFont(vcl::RenderContext &rRenderContext, const vcl::Font &rFont)
void HideTracking()
virtual void SetSizePixel(const Size &rNewSize)
virtual void Resize()
virtual void Command(const CommandEvent &rCEvt)
tools::Long CalcZoom(tools::Long n) const
void GrabFocus()
bool HasFocus() const
virtual void MouseButtonDown(const MouseEvent &rMEvt)
virtual Point GetPosPixel() const
const Fraction & GetZoom() const
const AllSettings & GetSettings() const
virtual void MouseButtonUp(const MouseEvent &rMEvt)
virtual void KeyInput(const KeyEvent &rKEvt)
void ShowTracking(const tools::Rectangle &rRect, ShowTrackFlags nFlags=ShowTrackFlags::Small)
virtual bool PreNotify(NotifyEvent &rNEvt)
vcl::Font GetControlFont() const
::OutputDevice const * GetOutDev() const
void SetAccessibleRole(sal_uInt16 nRole)
Point PixelToLogic(const Point &rDevicePt) const
css::uno::Reference< css::accessibility::XAccessible > GetAccessible(bool bCreate=true)
virtual Size GetSizePixel() const
Size GetOutputSizePixel() const
virtual void LoseFocus()
virtual void SetPointer(PointerStyle)
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Point ScreenToOutputPixel(const Point &rPos) const
void SetBackground()
virtual void scroll_to_row(int row)=0
void unselect_all()
virtual void select(int pos)=0
int nCount
#define DBG_UNHANDLED_EXCEPTION(...)
void * p
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_TAB
constexpr sal_uInt16 KEY_DELETE
std::unique_ptr< sal_Int32[]> pData
@ Exception
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)
std::vector< std::shared_ptr< OTableConnectionData > > TTableConnectionData
IMPL_LINK(OApplicationController, OnSelectContainer, void *, _pType, void)
int i
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
long Long
weld::Window * GetPopupParent(vcl::Window &rOutWin, tools::Rectangle &rRect)
#define Y
PointerStyle
QPRO_FUNC_TYPE nType
bool bVisible
#define DND_ACTION_NONE
signed char sal_Int8
const tools::Long nScrollX
const tools::Long nScrollY
StateChangedType
WinBits const WB_BORDER