1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: JoinTableView.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef DBAUI_JOINTABLEVIEW_HXX
31 #define DBAUI_JOINTABLEVIEW_HXX
33 #ifndef _SV_WINDOW_HXX
34 #include <vcl/window.hxx>
37 #include <vcl/timer.hxx>
39 #ifndef _SV_SCRBAR_HXX
40 #include <vcl/scrbar.hxx>
43 #include <tools/rtti.hxx>
46 #include <svtools/transfer.hxx>
49 #ifndef _COMPHELPER_STLTYPES_HXX_
50 #include <comphelper/stl_types.hxx>
52 #ifndef _DBACCESS_UI_CALLBACKS_HXX_
53 #include "callbacks.hxx"
55 #include "TableConnectionData.hxx"
56 #include "TableWindowData.hxx"
60 struct AcceptDropEvent
;
61 struct ExecuteDropEvent
;
65 class OTableConnection
;
67 struct OJoinExchangeData
;
68 class OJoinDesignView
;
69 class OTableWindowData
;
70 class OJoinDesignViewAccess
;
72 // this class conatins only the scrollbars to avoid that the tablewindows clip the scrollbars
74 class OScrollWindowHelper
: public Window
76 ScrollBar m_aHScrollBar
;
77 ScrollBar m_aVScrollBar
;
78 Window
* m_pCornerWindow
;
79 OJoinTableView
* m_pTableView
;
82 virtual void Resize();
84 OScrollWindowHelper( Window
* pParent
);
85 ~OScrollWindowHelper();
87 void setTableView(OJoinTableView
* _pTableView
);
89 void resetRange(const Point
& _aSize
);
92 ScrollBar
* GetHScrollBar() { return &m_aHScrollBar
; }
93 ScrollBar
* GetVScrollBar() { return &m_aVScrollBar
; }
97 class OJoinTableView
: public Window
98 ,public IDragTransferableListener
99 ,public DropTargetHelper
101 friend class OJoinMoveTabWinUndoAct
;
103 DECLARE_STL_USTRINGACCESS_MAP(OTableWindow
*,OTableWindowMap
);
105 OTableWindowMap m_aTableMap
;
106 ::std::vector
<OTableConnection
*> m_vTableConnection
;
108 Timer m_aDragScrollTimer
;
109 Rectangle m_aDragRect
;
110 Rectangle m_aSizingRect
;
112 Point m_aScrollOffset
;
113 Point m_ptPrevDraggingPos
;
117 OTableWindow
* m_pDragWin
;
118 OTableWindow
* m_pSizingWin
;
119 OTableConnection
* m_pSelectedConn
;
122 BOOL m_bTrackingInitiallyMoved
;
124 DECL_LINK(OnDragScrollTimer
, void*);
127 OTableWindow
* m_pLastFocusTabWin
;
128 OJoinDesignView
* m_pView
;
129 OJoinDesignViewAccess
* m_pAccessible
;
132 OJoinTableView( Window
* pParent
, OJoinDesignView
* pView
);
133 virtual ~OJoinTableView();
136 virtual void StateChanged( StateChangedType nStateChange
);
137 virtual void GetFocus();
138 virtual void LoseFocus();
139 virtual void KeyInput( const KeyEvent
& rEvt
);
141 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> CreateAccessible();
144 ScrollBar
* GetHScrollBar() { return static_cast<OScrollWindowHelper
*>(GetParent())->GetHScrollBar(); }
145 ScrollBar
* GetVScrollBar() { return static_cast<OScrollWindowHelper
*>(GetParent())->GetVScrollBar(); }
146 DECL_LINK( ScrollHdl
, ScrollBar
* );
148 void DrawConnections( const Rectangle
& rRect
);
149 void InvalidateConnections();
151 void BeginChildMove( OTableWindow
* pTabWin
, const Point
& rMousePos
);
152 void BeginChildSizing( OTableWindow
* pTabWin
, const Pointer
& rPointer
);
154 void NotifyTitleClicked( OTableWindow
* pTabWin
, const Point rMousePos
);
156 virtual void AddTabWin(const ::rtl::OUString
& _rComposedName
, const ::rtl::OUString
& rWinName
, BOOL bNewTable
= FALSE
);
157 virtual void RemoveTabWin( OTableWindow
* pTabWin
);
159 // alle TabWins verstecken (NICHT loeschen, sie werden in eine Undo-Action gepackt)
160 virtual void HideTabWins();
162 virtual void AddConnection(const OJoinExchangeData
& jxdSource
, const OJoinExchangeData
& jxdDest
) = 0;
164 /** RemoveConnection allows to remove connections from join table view, it implies that the same as addConnection
167 the connection which should be removed
169 when truie then the connection will be deleted
171 @return an iterator to next valid connection, so it can be used in any loop
173 virtual bool RemoveConnection(OTableConnection
* _pConnection
,sal_Bool _bDelete
);
175 /** allows to add new connections to join table view, it implies an invalidation of the features
176 ID_BROWSER_ADDTABLE and SID_RELATION_ADD_RELATION also the modified flag will be set to true
178 the connection which should be added
180 <TRUE/> when the data should also be appended
182 void addConnection(OTableConnection
* _pConnection
,sal_Bool _bAddData
= sal_True
);
184 BOOL
ScrollPane( long nDelta
, BOOL bHoriz
, BOOL bPaintScrollBars
);
185 ULONG
GetTabWinCount();
186 Point
GetScrollOffset() const { return m_aScrollOffset
; }
188 OJoinDesignView
* getDesignView() const { return m_pView
; }
189 OTableWindow
* GetTabWindow( const String
& rName
);
191 OTableConnection
* GetSelectedConn() { return m_pSelectedConn
; }
192 void DeselectConn(OTableConnection
* pConn
); // NULL ist ausdruecklich zugelassen, dann passiert nichts
193 void SelectConn(OTableConnection
* pConn
);
195 OTableWindowMap
* GetTabWinMap() { return &m_aTableMap
; }
196 const OTableWindowMap
* GetTabWinMap() const { return &m_aTableMap
; }
198 /** gives a read only access to the connection vector
200 const ::std::vector
<OTableConnection
*>* getTableConnections() const { return &m_vTableConnection
; }
203 BOOL
ExistsAConn(const OTableWindow
* pFromWin
) const;
205 /** getTableConnections searchs for all connections of a table
206 @param _pFromWin the table for which connections should be found
208 @return an iterator which can be used to travel all connections of the table
210 ::std::vector
<OTableConnection
*>::const_iterator
getTableConnections(const OTableWindow
* _pFromWin
) const;
212 /** getConnectionCount returns how many connection belongs to single table
213 @param _pFromWin the table for which connections should be found
215 @return the count of connections wich belongs to this table
217 sal_Int32
getConnectionCount(const OTableWindow
* _pFromWin
) const;
219 OTableConnection
* GetTabConn(const OTableWindow
* pLhs
,const OTableWindow
* pRhs
,bool _bSupressCrossOrNaturalJoin
= false,const OTableConnection
* _rpFirstAfter
= NULL
) const;
221 // clears the window map and connection vector without destroying it
222 // that means teh data of the windows and connection will be untouched
223 void clearLayoutInformation();
225 // set the focus to that tab win which most recently had it (or to the first available one)
226 void GrabTabWinFocus();
228 // ReSync ist dazu gedacht, aus dem Dokument alle WinData und ConnData zu holen und entsprechend Wins und Conns anzulegen
229 virtual void ReSync() { }
230 // ClearAll implementiert ein hartes Loeschen, es werden alle Conns und alle Wins aus ihren jeweiligen Listen geloescht
231 // sowie die entsprechenden Datas aus dem Dokument ausgetragen
232 virtual void ClearAll();
234 // wird vom AddTabDlg benutzt, um festzustellen, ob noch Tabellen hinzugefuegt werden duerfen
235 virtual BOOL
IsAddAllowed();
236 virtual long PreNotify(NotifyEvent
& rNEvt
);
239 virtual void StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
);
240 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
);
241 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
);
244 can be used in derevied classes to make some special ui handling
247 virtual void lookForUiActivities();
249 // wird nach Verschieben/Groessenaenderung der TabWins aufgerufen (die Standardimplementation reicht die neuen Daten einfach
250 // an die Daten des Wins weiter)
251 virtual void TabWinMoved(OTableWindow
* ptWhich
, const Point
& ptOldPosition
);
252 // die Position ist "virtuell" : der Container hat sozusagen eine virtuelle Flaeche, von der immer nur ein bestimmter Bereich
253 // - der mittels der Scrollbar veraendert werden kann - zu sehen ist. Insbesondere hat ptOldPosition immer positive Koordinaten,
254 // auch wenn er einen Punkt oberhalb des aktuell sichtbaren Bereichs bezeichnet, dessen physische Ordinate eigentlich
256 virtual void TabWinSized(OTableWindow
* ptWhich
, const Point
& ptOldPosition
, const Size
& szOldSize
);
260 /** returns if teh given window is visible.
264 The Size to be check as well
266 <TRUE/> if the area is visible otherwise <FALSE/>
269 BOOL
isMovementAllowed(const Point
& _rPoint
,const Size
& _rSize
);
271 Size
getRealOutputSize() const { return m_aOutputSize
; }
275 virtual void EnsureVisible(const OTableWindow
* _pWin
);
276 virtual void EnsureVisible(const Point
& _rPoint
,const Size
& _rSize
);
278 TTableWindowData::value_type
createTableWindowData(const ::rtl::OUString
& _rComposedName
279 ,const ::rtl::OUString
& _sTableName
280 ,const ::rtl::OUString
& _rWinName
);
283 virtual void MouseButtonUp( const MouseEvent
& rEvt
);
284 virtual void MouseButtonDown( const MouseEvent
& rEvt
);
285 virtual void Tracking( const TrackingEvent
& rTEvt
);
286 virtual void Paint( const Rectangle
& rRect
);
287 virtual void ConnDoubleClicked( OTableConnection
* pConnection
);
288 virtual void SetDefaultTabWinPosSize( OTableWindow
* pTabWin
);
289 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
291 virtual void Resize();
293 virtual void dragFinished( );
294 // hier ist die Position (die sich waehrend des Sizings aendern kann) physisch, da waehrend des Sizens nicht gescrollt wird
295 virtual void Command(const CommandEvent
& rEvt
);
297 virtual OTableWindowData
* CreateImpl(const ::rtl::OUString
& _rComposedName
298 ,const ::rtl::OUString
& _sTableName
299 ,const ::rtl::OUString
& _rWinName
);
301 /** factory method to create table windows
303 The data corresponding to the window.
307 virtual OTableWindow
* createWindow(const TTableWindowData::value_type
& _pData
) = 0;
309 /** determines whether the classes Init method should accept a query name, or only table names
311 virtual bool allowQueries() const;
313 /** called when init fails at the tablewindowdata because the m_xTable object could not provide columns, but no
314 exception was thrown. Expected to throw.
316 virtual void onNoColumns_throw();
318 virtual bool supressCrossNaturalJoin(const TTableConnectionData::value_type
& _pData
) const;
322 BOOL
ScrollWhileDragging();
324 /** executePopup opens the context menu to delate a connection
325 @param _aPos the position where the popup menu should appear
326 @param _pSelConnection the connection which should be deleted
328 void executePopup(const Point
& _aPos
,OTableConnection
* _pSelConnection
);
330 /** invalidateAndModify invalidates this window without children and
331 set the controller modified
332 @param _pAction a possible undo action to add at the controller
334 void invalidateAndModify(SfxUndoAction
*_pAction
=NULL
);
337 using Window::Scroll
;
340 #endif // DBAUI_JOINTABLEVIEW_HXX