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_QUERYTABLEVIEW_HXX 28*cdf0e10cSrcweir #define DBAUI_QUERYTABLEVIEW_HXX 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #ifndef DBAUI_JOINTABLEVIEW_HXX 31*cdf0e10cSrcweir #include "JoinTableView.hxx" 32*cdf0e10cSrcweir #endif 33*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ 34*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 35*cdf0e10cSrcweir #endif 36*cdf0e10cSrcweir #ifndef DBAUI_QUERYCONTROLLER_HXX 37*cdf0e10cSrcweir #include "querycontroller.hxx" 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir namespace dbaui 41*cdf0e10cSrcweir { 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir struct TabWinsChangeNotification 44*cdf0e10cSrcweir { 45*cdf0e10cSrcweir enum ACTION_TYPE { AT_ADDED_WIN, AT_REMOVED_WIN }; 46*cdf0e10cSrcweir ACTION_TYPE atActionPerformed; 47*cdf0e10cSrcweir String strAffectedTable; 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir TabWinsChangeNotification(ACTION_TYPE at, const String& str) : atActionPerformed(at), strAffectedTable(str) { } 50*cdf0e10cSrcweir }; 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir //======================================================================== 53*cdf0e10cSrcweir class OQueryTabWinUndoAct; 54*cdf0e10cSrcweir class OQueryTabConnUndoAction; 55*cdf0e10cSrcweir class OQueryTableConnection; 56*cdf0e10cSrcweir class OQueryTableWindow; 57*cdf0e10cSrcweir class OQueryDesignView; 58*cdf0e10cSrcweir class OQueryTableView : public OJoinTableView 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir Link m_lnkTabWinsChangeHandler; 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir protected: 63*cdf0e10cSrcweir virtual void ConnDoubleClicked(OTableConnection* pConnection); 64*cdf0e10cSrcweir virtual void KeyInput(const KeyEvent& rEvt); 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir virtual OTableWindow* createWindow(const TTableWindowData::value_type& _pData); 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir /** called when init fails at the tablewindowdata because the m_xTable object could not provide columns, but no 69*cdf0e10cSrcweir exception was thrown. Expected to throw. 70*cdf0e10cSrcweir */ 71*cdf0e10cSrcweir virtual void onNoColumns_throw(); 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir virtual bool supressCrossNaturalJoin(const TTableConnectionData::value_type& _pData) const; 74*cdf0e10cSrcweir public: 75*cdf0e10cSrcweir OQueryTableView(Window* pParent,OQueryDesignView* pView); 76*cdf0e10cSrcweir virtual ~OQueryTableView(); 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir // Basisklasse ueberschrieben : Fenster kreieren und loeschen 79*cdf0e10cSrcweir // (eigentlich nicht wirklich LOESCHEN, es geht in die Verantwortung einer UNDO-Action ueber) 80*cdf0e10cSrcweir virtual void AddTabWin( const ::rtl::OUString& _rTableName, const ::rtl::OUString& _rAliasName, sal_Bool bNewTable = sal_False ); 81*cdf0e10cSrcweir virtual void RemoveTabWin(OTableWindow* pTabWin); 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir // und ein AddTabWin, das einen Alias vorgibt 84*cdf0e10cSrcweir void AddTabWin(const ::rtl::OUString& strDatabase, const ::rtl::OUString& strTableName, const ::rtl::OUString& strAlias, sal_Bool bNewTable = sal_False); 85*cdf0e10cSrcweir // TabWin suchen 86*cdf0e10cSrcweir OQueryTableWindow* FindTable(const String& rAliasName); 87*cdf0e10cSrcweir sal_Bool FindTableFromField(const String& rFieldName, OTableFieldDescRef& rInfo, sal_uInt16& rCnt); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir // Basisklasse ueberschrieben : Connections kreieren und loeschen 90*cdf0e10cSrcweir virtual void AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest); 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir virtual bool RemoveConnection( OTableConnection* _pConn ,sal_Bool _bDelete); 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir // Transfer von Connections von/zu einer UndoAction 95*cdf0e10cSrcweir void GetConnection(OQueryTableConnection* pConn); 96*cdf0e10cSrcweir // Einfuegen einer Connection in meine Struktur 97*cdf0e10cSrcweir void DropConnection(OQueryTableConnection* pConn); 98*cdf0e10cSrcweir // Entfernen einer Connection aus meiner Struktur 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir // das resultiert effektiv in einem voelligen Leeren des Abfrageentwurfs, da alle Fenster versteckt werden, und dabei 101*cdf0e10cSrcweir // natuerlich alle Connections an diesen Fenstern und alle Abfrage-Spalten, die auf diesen Tabellen basierten. 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir // TabWin anzeigen oder verstecken (NICHT kreieren oder loeschen) 104*cdf0e10cSrcweir sal_Bool ShowTabWin(OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction,sal_Bool _bAppend); 105*cdf0e10cSrcweir void HideTabWin(OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction); 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir // Sichbarkeit eines TabWins sicherstellen (+ Invalidieren der Connections) 108*cdf0e10cSrcweir virtual void EnsureVisible(const OTableWindow* _pWin); 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir // wieviel Tabellen mit einem bestimmten Namen habe ich schon ? 111*cdf0e10cSrcweir sal_Int32 CountTableAlias(const String& rName, sal_Int32& rMax); 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir // ein Feld einfuegen (wird einfach an das Elter weitergereicht 114*cdf0e10cSrcweir void InsertField(const OTableFieldDescRef& rInfo); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir // alles (TabWins, Connections) neu aufbauen (PRECONDITION : vorher wurde ClearAll gerufen) 117*cdf0e10cSrcweir virtual void ReSync(); 118*cdf0e10cSrcweir // alles (TabWins, Connections) loeschen, und zwar hart, es erfolgen also keinerlei Notifications 119*cdf0e10cSrcweir virtual void ClearAll(); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir // wird vom AddTabDlg benutzt, um festzustellen, ob noch Tabellen hinzugefuegt werden duerfen 122*cdf0e10cSrcweir //virtual sal_Bool IsAddAllowed(); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir // eine neu Connection bekanntgeben und einfuegen lassen, wenn nicht schon existent 125*cdf0e10cSrcweir void NotifyTabConnection(const OQueryTableConnection& rNewConn, sal_Bool _bCreateUndoAction = sal_True); 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir Link SetTabWinsChangeHandler(const Link& lnk) { Link lnkRet = m_lnkTabWinsChangeHandler; m_lnkTabWinsChangeHandler = lnk; return lnkRet; } 128*cdf0e10cSrcweir // der Handler bekommt einen Zeiger auf eine TabWinsChangeNotification-Struktur 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir sal_Bool ExistsAVisitedConn(const OQueryTableWindow* pFrom) const; 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir virtual OTableWindowData* CreateImpl(const ::rtl::OUString& _rComposedName 133*cdf0e10cSrcweir ,const ::rtl::OUString& _sTableName 134*cdf0e10cSrcweir ,const ::rtl::OUString& _rWinName); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir /** createNewConnection opens the join dialog and allows to create a new join connection 137*cdf0e10cSrcweir */ 138*cdf0e10cSrcweir void createNewConnection(); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir private: 141*cdf0e10cSrcweir using OJoinTableView::EnsureVisible; 142*cdf0e10cSrcweir }; 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir #endif // DBAUI_QUERYTABLEVIEW_HXX 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir 150