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