LCOV - code coverage report
Current view: top level - dbaccess/source/ui/inc - JoinTableView.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 11 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 11 0.0 %
Legend: Lines: hit not hit

          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             : #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_JOINTABLEVIEW_HXX
      20             : #define INCLUDED_DBACCESS_SOURCE_UI_INC_JOINTABLEVIEW_HXX
      21             : 
      22             : #include <vcl/window.hxx>
      23             : #include <vcl/timer.hxx>
      24             : #include <vcl/idle.hxx>
      25             : #include <vcl/scrbar.hxx>
      26             : #include <vcl/vclptr.hxx>
      27             : #include <tools/rtti.hxx>
      28             : #include <svtools/transfer.hxx>
      29             : 
      30             : #include "callbacks.hxx"
      31             : #include "TableConnectionData.hxx"
      32             : #include "TableWindowData.hxx"
      33             : 
      34             : #include <map>
      35             : #include <vector>
      36             : 
      37             : struct AcceptDropEvent;
      38             : struct ExecuteDropEvent;
      39             : class SfxUndoAction;
      40             : 
      41             : namespace dbaui
      42             : {
      43             :     class OTableConnection;
      44             :     class OTableWindow;
      45             :     struct OJoinExchangeData;
      46             :     class OJoinDesignView;
      47             :     class OTableWindowData;
      48             :     class OJoinDesignViewAccess;
      49             : 
      50             :     // this class conatins only the scrollbars to avoid that
      51             :     // the tablewindows clip the scrollbars
      52             :     class OJoinTableView;
      53             :     class OScrollWindowHelper : public vcl::Window
      54             :     {
      55             :         VclPtr<ScrollBar>          m_aHScrollBar;
      56             :         VclPtr<ScrollBar>          m_aVScrollBar;
      57             :         VclPtr<vcl::Window>        m_pCornerWindow;
      58             :         VclPtr<OJoinTableView>     m_pTableView;
      59             : 
      60             :     protected:
      61             :         virtual void Resize() SAL_OVERRIDE;
      62             : 
      63             :     public:
      64             :         OScrollWindowHelper( vcl::Window* pParent);
      65             :         virtual ~OScrollWindowHelper();
      66             :         virtual void dispose() SAL_OVERRIDE;
      67             : 
      68             :         void setTableView(OJoinTableView* _pTableView);
      69             : 
      70             :         void resetRange(const Point& _aSize);
      71             : 
      72             :         // own methods
      73           0 :         ScrollBar& GetHScrollBar() { return *m_aHScrollBar.get(); }
      74           0 :         ScrollBar& GetVScrollBar() { return *m_aVScrollBar.get(); }
      75             :     };
      76             : 
      77             : 
      78             :     class OJoinTableView : public vcl::Window,
      79             :                            public IDragTransferableListener,
      80             :                            public DropTargetHelper
      81             :     {
      82             :         friend class OJoinMoveTabWinUndoAct;
      83             : 
      84             :     public:
      85             :         typedef std::map<OUString, VclPtr<OTableWindow> > OTableWindowMap;
      86             : 
      87             :     private:
      88             :         OTableWindowMap     m_aTableMap;
      89             :         ::std::vector<VclPtr<OTableConnection> >    m_vTableConnection;
      90             : 
      91             :         Idle                m_aDragScrollIdle;
      92             :         Rectangle           m_aDragRect;
      93             :         Rectangle           m_aSizingRect;
      94             :         Point               m_aDragOffset;
      95             :         Point               m_aScrollOffset;
      96             :         Point               m_ptPrevDraggingPos;
      97             :         Size                m_aOutputSize;
      98             : 
      99             : 
     100             :         VclPtr<OTableWindow>           m_pDragWin;
     101             :         VclPtr<OTableWindow>           m_pSizingWin;
     102             :         VclPtr<OTableConnection>       m_pSelectedConn;
     103             : 
     104             : 
     105             :         bool                    m_bTrackingInitiallyMoved;
     106             : 
     107             :         DECL_LINK_TYPED(OnDragScrollTimer, Idle*, void);
     108             : 
     109             :     protected:
     110             :         VclPtr<OTableWindow>               m_pLastFocusTabWin;
     111             :         VclPtr<OJoinDesignView>            m_pView;
     112             :         OJoinDesignViewAccess*      m_pAccessible;
     113             : 
     114             :     public:
     115             :         OJoinTableView( vcl::Window* pParent, OJoinDesignView* pView );
     116             :         virtual ~OJoinTableView();
     117             :         virtual void dispose() SAL_OVERRIDE;
     118             : 
     119             :         // window override
     120             :         virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
     121             :         virtual void GetFocus() SAL_OVERRIDE;
     122             :         virtual void LoseFocus() SAL_OVERRIDE;
     123             :         virtual void KeyInput( const KeyEvent& rEvt ) SAL_OVERRIDE;
     124             :         // Accessibility
     125             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
     126             : 
     127             :         // own methods
     128           0 :         ScrollBar& GetHScrollBar() { return static_cast<OScrollWindowHelper*>(GetParent())->GetHScrollBar(); }
     129           0 :         ScrollBar& GetVScrollBar() { return static_cast<OScrollWindowHelper*>(GetParent())->GetVScrollBar(); }
     130             :         DECL_LINK( ScrollHdl, ScrollBar* );
     131             : 
     132             :         void DrawConnections(vcl::RenderContext& rRenderContext, const Rectangle& rRect);
     133             :         void InvalidateConnections();
     134             : 
     135             :         void BeginChildMove( OTableWindow* pTabWin, const Point& rMousePos );
     136             :         void BeginChildSizing( OTableWindow* pTabWin, const Pointer& rPointer );
     137             : 
     138             :         void NotifyTitleClicked( OTableWindow* pTabWin, const Point& rMousePos );
     139             : 
     140             :         virtual void AddTabWin(const OUString& _rComposedName, const OUString& rWinName, bool bNewTable = false);
     141             :         virtual void RemoveTabWin( OTableWindow* pTabWin );
     142             : 
     143             :         // hide all TabWins (does NOT delete them; they are put in an UNDO action)
     144             :         void HideTabWins();
     145             : 
     146             :         virtual void AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest) = 0;
     147             : 
     148             :         /** RemoveConnection allows to remove connections from join table view
     149             : 
     150             :             it implies that the same as addConnection
     151             : 
     152             :             @param  _pConnection the connection which should be removed
     153             :             @param  _bDelete     when true then the connection will be deleted
     154             : 
     155             :             @return an iterator to next valid connection, so it can be used in any loop
     156             :         */
     157             :         virtual bool RemoveConnection(OTableConnection* _pConnection,bool _bDelete);
     158             : 
     159             :         /** allows to add new connections to join table view
     160             : 
     161             :             it implies an invalidation of the features ID_BROWSER_ADDTABLE and
     162             :             SID_RELATION_ADD_RELATION also the modified flag will be set to true
     163             : 
     164             :             @param  _pConnection the connection which should be added
     165             :             @param  _bAddData    when true then the data should also be appended
     166             :         */
     167             :         void addConnection(OTableConnection* _pConnection,bool _bAddData = true);
     168             : 
     169             :         bool ScrollPane( long nDelta, bool bHoriz, bool bPaintScrollBars );
     170             :         sal_uLong GetTabWinCount();
     171           0 :         Point GetScrollOffset() const { return m_aScrollOffset; }
     172             : 
     173           0 :         OJoinDesignView* getDesignView() const { return m_pView; }
     174             :         OTableWindow* GetTabWindow( const OUString& rName );
     175             : 
     176           0 :         OTableConnection* GetSelectedConn() { return m_pSelectedConn; }
     177             :         /** @note NULL is explicitly allowed (then no-op) */
     178             :         void DeselectConn(OTableConnection* pConn);
     179             :         void SelectConn(OTableConnection* pConn);
     180             : 
     181           0 :         OTableWindowMap& GetTabWinMap() { return m_aTableMap; }
     182             :         const OTableWindowMap& GetTabWinMap() const { return m_aTableMap; }
     183             : 
     184             :         /** gives a read only access to the connection vector
     185             :         */
     186           0 :         const ::std::vector<VclPtr<OTableConnection> >& getTableConnections() const { return m_vTableConnection; }
     187             : 
     188             :         bool ExistsAConn(const OTableWindow* pFromWin) const;
     189             : 
     190             :         /** search for all connections of a table
     191             : 
     192             :             @param  _pFromWin   the table for which connections should be found
     193             :             @return an iterator which can be used to travel all connections of the table
     194             :         */
     195             :         ::std::vector<VclPtr<OTableConnection> >::const_iterator getTableConnections(const OTableWindow* _pFromWin) const;
     196             : 
     197             :         /** how many connection belongs to single table
     198             : 
     199             :             @param  _pFromWin the table for which connections should be found
     200             :             @return the count of connections which belongs to this table
     201             :         */
     202             :         sal_Int32 getConnectionCount(const OTableWindow* _pFromWin) const;
     203             : 
     204             :         OTableConnection* GetTabConn(const OTableWindow* pLhs,const OTableWindow* pRhs,bool _bSupressCrossOrNaturalJoin = false,const OTableConnection* _rpFirstAfter = NULL) const;
     205             : 
     206             :         /** clear the window map and connection vector without destroying it
     207             : 
     208             :             that means that the data of the windows and connection will be
     209             :             untouched
     210             :          */
     211             :         void clearLayoutInformation();
     212             : 
     213             :         /** set the focus to that tab win which most recently had it
     214             :             (or to the first available one) **/
     215             :         void GrabTabWinFocus();
     216             : 
     217             :         /** take all WinData and ConnData from the document and create the
     218             :             corresponding Wins and Conns */
     219           0 :         virtual void ReSync() { }
     220             : 
     221             :         /** Hart deletion
     222             : 
     223             :             That means that all Conns and Wins are deleted from their respective
     224             :             lists and the corresponding Datas removed from the document */
     225             :         virtual void ClearAll();
     226             : 
     227             :         /** @note used by AddTabDlg to see if more tables can be added */
     228             :         virtual bool IsAddAllowed();
     229             :         virtual bool PreNotify(NotifyEvent& rNEvt) SAL_OVERRIDE;
     230             : 
     231             :         // DnD stuff
     232             :         virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
     233             :         virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
     234             : 
     235             :         /** @note can be used for special ui handling after d&d */
     236             :         virtual void lookForUiActivities();
     237             : 
     238             :         /** Hook that is called after moving/resizing TabWins
     239             : 
     240             :             The position is 'virtual': the container has a virtual area of
     241             :             which only a part - changeable by scroll bar - is visible.
     242             :             Therefore: ptOldPosition is always positive, even if it represents
     243             :             a point with a negative physical ordinate above the visible area
     244             : 
     245             :             @note The standard implementation just passes the new data to the
     246             :                   Wins
     247             :          */
     248             :         void TabWinMoved(OTableWindow* ptWhich, const Point& ptOldPosition);
     249             : 
     250             :         void TabWinSized(OTableWindow* ptWhich, const Point& ptOldPosition, const Size& szOldSize);
     251             : 
     252             :         void modified();
     253             : 
     254             :         /** check if the given window is visible.
     255             : 
     256             :             @param _rPoint  The Point to check
     257             :             @param _rSize   The Size to be check as well
     258             :             @return true if the area is visible, false otherwise
     259             :         */
     260             :         bool isMovementAllowed(const Point& _rPoint,const Size& _rSize);
     261             : 
     262           0 :         Size getRealOutputSize() const { return m_aOutputSize; }
     263             : 
     264             :         virtual void EnsureVisible(const OTableWindow* _pWin);
     265             :         void EnsureVisible(const Point& _rPoint,const Size& _rSize);
     266             : 
     267             :         TTableWindowData::value_type createTableWindowData(const OUString& _rComposedName
     268             :                                             ,const OUString& _sTableName
     269             :                                             ,const OUString& _rWinName);
     270             : 
     271             :     protected:
     272             :         virtual void MouseButtonUp( const MouseEvent& rEvt ) SAL_OVERRIDE;
     273             :         virtual void MouseButtonDown( const MouseEvent& rEvt ) SAL_OVERRIDE;
     274             :         virtual void Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
     275             :         virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
     276             :         virtual void ConnDoubleClicked( OTableConnection* pConnection );
     277             :         void SetDefaultTabWinPosSize( OTableWindow* pTabWin );
     278             :         virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     279             : 
     280             :         virtual void Resize() SAL_OVERRIDE;
     281             : 
     282             :         virtual void dragFinished( ) SAL_OVERRIDE;
     283             :         /// @note here the physical position (that can be changed while
     284             :         ///     resizing) is used, as no scrolling can take place while resizing
     285             :         virtual void Command(const CommandEvent& rEvt) SAL_OVERRIDE;
     286             : 
     287             :         virtual OTableWindowData* CreateImpl(const OUString& _rComposedName
     288             :                                             ,const OUString& _sTableName
     289             :                                             ,const OUString& _rWinName);
     290             : 
     291             :         /** factory method to create table windows
     292             : 
     293             :             @param _pData The data corresponding to the window.
     294             :             @return The new TableWindow
     295             :         */
     296             :         virtual VclPtr<OTableWindow> createWindow(const TTableWindowData::value_type& _pData) = 0;
     297             : 
     298             :         /** determines whether the classes Init method should accept a query
     299             :             name, or only table names */
     300             :         virtual bool allowQueries() const;
     301             : 
     302             :         /** called when init fails at the tablewindowdata because the m_xTable
     303             :             object could not provide columns, but no exception was thrown.
     304             :             Expected to throw. */
     305             :         virtual void onNoColumns_throw();
     306             : 
     307             :         virtual bool supressCrossNaturalJoin(const TTableConnectionData::value_type& _pData) const;
     308             : 
     309             :     private:
     310             :         void InitColors();
     311             :         bool ScrollWhileDragging();
     312             : 
     313             :         /** opens the context menu to delate a connection
     314             :             @param _aPos the position where the popup menu should appear
     315             :             @param _pSelConnection the connection which should be deleted
     316             :         */
     317             :         void executePopup(const Point& _aPos,OTableConnection* _pSelConnection);
     318             : 
     319             :         /** invalidates this window without children and set the controller
     320             :             modified
     321             :             @param _pAction a possible undo action to add at the controller
     322             :         */
     323             :         void invalidateAndModify(SfxUndoAction *_pAction=NULL);
     324             : 
     325             :     private:
     326             :         using Window::Scroll;
     327             :     };
     328             : }
     329             : #endif
     330             : 
     331             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11