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

Generated by: LCOV version 1.10