Bump version to 5.0-14
[LibreOffice.git] / dbaccess / source / ui / inc / JoinTableView.hxx
blob2cdfdbab4792a56eacfd2493a7cb3eb72e0b3d79
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_JOINTABLEVIEW_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_INC_JOINTABLEVIEW_HXX
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>
30 #include "callbacks.hxx"
31 #include "TableConnectionData.hxx"
32 #include "TableWindowData.hxx"
34 #include <map>
35 #include <vector>
37 struct AcceptDropEvent;
38 struct ExecuteDropEvent;
39 class SfxUndoAction;
41 namespace dbaui
43 class OTableConnection;
44 class OTableWindow;
45 struct OJoinExchangeData;
46 class OJoinDesignView;
47 class OTableWindowData;
48 class OJoinDesignViewAccess;
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
55 VclPtr<ScrollBar> m_aHScrollBar;
56 VclPtr<ScrollBar> m_aVScrollBar;
57 VclPtr<vcl::Window> m_pCornerWindow;
58 VclPtr<OJoinTableView> m_pTableView;
60 protected:
61 virtual void Resize() SAL_OVERRIDE;
63 public:
64 OScrollWindowHelper( vcl::Window* pParent);
65 virtual ~OScrollWindowHelper();
66 virtual void dispose() SAL_OVERRIDE;
68 void setTableView(OJoinTableView* _pTableView);
70 void resetRange(const Point& _aSize);
72 // own methods
73 ScrollBar& GetHScrollBar() { return *m_aHScrollBar.get(); }
74 ScrollBar& GetVScrollBar() { return *m_aVScrollBar.get(); }
78 class OJoinTableView : public vcl::Window,
79 public IDragTransferableListener,
80 public DropTargetHelper
82 friend class OJoinMoveTabWinUndoAct;
84 public:
85 typedef std::map<OUString, VclPtr<OTableWindow> > OTableWindowMap;
87 private:
88 OTableWindowMap m_aTableMap;
89 ::std::vector<VclPtr<OTableConnection> > m_vTableConnection;
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;
100 VclPtr<OTableWindow> m_pDragWin;
101 VclPtr<OTableWindow> m_pSizingWin;
102 VclPtr<OTableConnection> m_pSelectedConn;
105 bool m_bTrackingInitiallyMoved;
107 DECL_LINK_TYPED(OnDragScrollTimer, Idle*, void);
109 protected:
110 VclPtr<OTableWindow> m_pLastFocusTabWin;
111 VclPtr<OJoinDesignView> m_pView;
112 OJoinDesignViewAccess* m_pAccessible;
114 public:
115 OJoinTableView( vcl::Window* pParent, OJoinDesignView* pView );
116 virtual ~OJoinTableView();
117 virtual void dispose() SAL_OVERRIDE;
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;
127 // own methods
128 ScrollBar& GetHScrollBar() { return static_cast<OScrollWindowHelper*>(GetParent())->GetHScrollBar(); }
129 ScrollBar& GetVScrollBar() { return static_cast<OScrollWindowHelper*>(GetParent())->GetVScrollBar(); }
130 DECL_LINK( ScrollHdl, ScrollBar* );
132 void DrawConnections(vcl::RenderContext& rRenderContext, const Rectangle& rRect);
133 void InvalidateConnections();
135 void BeginChildMove( OTableWindow* pTabWin, const Point& rMousePos );
136 void BeginChildSizing( OTableWindow* pTabWin, const Pointer& rPointer );
138 void NotifyTitleClicked( OTableWindow* pTabWin, const Point& rMousePos );
140 virtual void AddTabWin(const OUString& _rComposedName, const OUString& rWinName, bool bNewTable = false);
141 virtual void RemoveTabWin( OTableWindow* pTabWin );
143 // hide all TabWins (does NOT delete them; they are put in an UNDO action)
144 void HideTabWins();
146 virtual void AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest) = 0;
148 /** RemoveConnection allows to remove connections from join table view
150 it implies that the same as addConnection
152 @param _pConnection the connection which should be removed
153 @param _bDelete when true then the connection will be deleted
155 @return an iterator to next valid connection, so it can be used in any loop
157 virtual bool RemoveConnection(OTableConnection* _pConnection,bool _bDelete);
159 /** allows to add new connections to join table view
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
164 @param _pConnection the connection which should be added
165 @param _bAddData when true then the data should also be appended
167 void addConnection(OTableConnection* _pConnection,bool _bAddData = true);
169 bool ScrollPane( long nDelta, bool bHoriz, bool bPaintScrollBars );
170 sal_uLong GetTabWinCount();
171 Point GetScrollOffset() const { return m_aScrollOffset; }
173 OJoinDesignView* getDesignView() const { return m_pView; }
174 OTableWindow* GetTabWindow( const OUString& rName );
176 OTableConnection* GetSelectedConn() { return m_pSelectedConn; }
177 /** @note NULL is explicitly allowed (then no-op) */
178 void DeselectConn(OTableConnection* pConn);
179 void SelectConn(OTableConnection* pConn);
181 OTableWindowMap& GetTabWinMap() { return m_aTableMap; }
182 const OTableWindowMap& GetTabWinMap() const { return m_aTableMap; }
184 /** gives a read only access to the connection vector
186 const ::std::vector<VclPtr<OTableConnection> >& getTableConnections() const { return m_vTableConnection; }
188 bool ExistsAConn(const OTableWindow* pFromWin) const;
190 /** search for all connections of a table
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
195 ::std::vector<VclPtr<OTableConnection> >::const_iterator getTableConnections(const OTableWindow* _pFromWin) const;
197 /** how many connection belongs to single table
199 @param _pFromWin the table for which connections should be found
200 @return the count of connections which belongs to this table
202 sal_Int32 getConnectionCount(const OTableWindow* _pFromWin) const;
204 OTableConnection* GetTabConn(const OTableWindow* pLhs,const OTableWindow* pRhs,bool _bSupressCrossOrNaturalJoin = false,const OTableConnection* _rpFirstAfter = NULL) const;
206 /** clear the window map and connection vector without destroying it
208 that means that the data of the windows and connection will be
209 untouched
211 void clearLayoutInformation();
213 /** set the focus to that tab win which most recently had it
214 (or to the first available one) **/
215 void GrabTabWinFocus();
217 /** take all WinData and ConnData from the document and create the
218 corresponding Wins and Conns */
219 virtual void ReSync() { }
221 /** Hart deletion
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();
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;
231 // DnD stuff
232 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
233 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
235 /** @note can be used for special ui handling after d&d */
236 virtual void lookForUiActivities();
238 /** Hook that is called after moving/resizing TabWins
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
245 @note The standard implementation just passes the new data to the
246 Wins
248 void TabWinMoved(OTableWindow* ptWhich, const Point& ptOldPosition);
250 void TabWinSized(OTableWindow* ptWhich, const Point& ptOldPosition, const Size& szOldSize);
252 void modified();
254 /** check if the given window is visible.
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
260 bool isMovementAllowed(const Point& _rPoint,const Size& _rSize);
262 Size getRealOutputSize() const { return m_aOutputSize; }
264 virtual void EnsureVisible(const OTableWindow* _pWin);
265 void EnsureVisible(const Point& _rPoint,const Size& _rSize);
267 TTableWindowData::value_type createTableWindowData(const OUString& _rComposedName
268 ,const OUString& _sTableName
269 ,const OUString& _rWinName);
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;
280 virtual void Resize() SAL_OVERRIDE;
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;
287 virtual OTableWindowData* CreateImpl(const OUString& _rComposedName
288 ,const OUString& _sTableName
289 ,const OUString& _rWinName);
291 /** factory method to create table windows
293 @param _pData The data corresponding to the window.
294 @return The new TableWindow
296 virtual VclPtr<OTableWindow> createWindow(const TTableWindowData::value_type& _pData) = 0;
298 /** determines whether the classes Init method should accept a query
299 name, or only table names */
300 virtual bool allowQueries() const;
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();
307 virtual bool supressCrossNaturalJoin(const TTableConnectionData::value_type& _pData) const;
309 private:
310 void InitColors();
311 bool ScrollWhileDragging();
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
317 void executePopup(const Point& _aPos,OTableConnection* _pSelConnection);
319 /** invalidates this window without children and set the controller
320 modified
321 @param _pAction a possible undo action to add at the controller
323 void invalidateAndModify(SfxUndoAction *_pAction=NULL);
325 private:
326 using Window::Scroll;
329 #endif
331 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */