12e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
32e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
42e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
52e2212a7SAndrew Rist  * distributed with this work for additional information
62e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
72e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
82e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
92e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
102e2212a7SAndrew Rist  *
112e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
122e2212a7SAndrew Rist  *
132e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
142e2212a7SAndrew Rist  * software distributed under the License is distributed on an
152e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
172e2212a7SAndrew Rist  * specific language governing permissions and limitations
182e2212a7SAndrew Rist  * under the License.
192e2212a7SAndrew Rist  *
202e2212a7SAndrew Rist  *************************************************************/
212e2212a7SAndrew Rist 
222e2212a7SAndrew Rist 
23cdf0e10cSrcweir #ifndef DBAUI_QUERYTABLEVIEW_HXX
24cdf0e10cSrcweir #define DBAUI_QUERYTABLEVIEW_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #ifndef DBAUI_JOINTABLEVIEW_HXX
27cdf0e10cSrcweir #include "JoinTableView.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
30cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef DBAUI_QUERYCONTROLLER_HXX
33cdf0e10cSrcweir #include "querycontroller.hxx"
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace dbaui
37cdf0e10cSrcweir {
38cdf0e10cSrcweir 
39cdf0e10cSrcweir 	struct TabWinsChangeNotification
40cdf0e10cSrcweir 	{
41cdf0e10cSrcweir 		enum ACTION_TYPE	{ AT_ADDED_WIN, AT_REMOVED_WIN };
42cdf0e10cSrcweir 		ACTION_TYPE			atActionPerformed;
43cdf0e10cSrcweir 		String				strAffectedTable;
44cdf0e10cSrcweir 
TabWinsChangeNotificationdbaui::TabWinsChangeNotification45cdf0e10cSrcweir 		TabWinsChangeNotification(ACTION_TYPE at, const String& str) : atActionPerformed(at), strAffectedTable(str) { }
46cdf0e10cSrcweir 	};
47cdf0e10cSrcweir 
48cdf0e10cSrcweir 	//========================================================================
49cdf0e10cSrcweir 	class OQueryTabWinUndoAct;
50cdf0e10cSrcweir 	class OQueryTabConnUndoAction;
51cdf0e10cSrcweir 	class OQueryTableConnection;
52cdf0e10cSrcweir 	class OQueryTableWindow;
53cdf0e10cSrcweir 	class OQueryDesignView;
54cdf0e10cSrcweir 	class OQueryTableView : public OJoinTableView
55cdf0e10cSrcweir 	{
56cdf0e10cSrcweir 		Link	m_lnkTabWinsChangeHandler;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 	protected:
59cdf0e10cSrcweir 		virtual void ConnDoubleClicked(OTableConnection* pConnection);
60cdf0e10cSrcweir 		virtual void KeyInput(const KeyEvent& rEvt);
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 		virtual OTableWindow* createWindow(const TTableWindowData::value_type& _pData);
63cdf0e10cSrcweir 
64cdf0e10cSrcweir         /** called when init fails at the tablewindowdata because the m_xTable object could not provide columns, but no
65cdf0e10cSrcweir             exception was thrown. Expected to throw.
66cdf0e10cSrcweir         */
67cdf0e10cSrcweir         virtual void    onNoColumns_throw();
68cdf0e10cSrcweir 
69cdf0e10cSrcweir         virtual bool supressCrossNaturalJoin(const TTableConnectionData::value_type& _pData) const;
70cdf0e10cSrcweir 	public:
71cdf0e10cSrcweir 		OQueryTableView(Window* pParent,OQueryDesignView* pView);
72cdf0e10cSrcweir 		virtual ~OQueryTableView();
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 		// Basisklasse ueberschrieben : Fenster kreieren und loeschen
75cdf0e10cSrcweir 		// (eigentlich nicht wirklich LOESCHEN, es geht in die Verantwortung einer UNDO-Action ueber)
76*67bd56d3SArmin Le Grand         bool ContainsTabWin(const OTableWindow& rTabWin); // #122589# Allow to check if OTableWindow is registered
77cdf0e10cSrcweir 		virtual void AddTabWin( const ::rtl::OUString& _rTableName, const ::rtl::OUString& _rAliasName, sal_Bool bNewTable = sal_False );
78cdf0e10cSrcweir 		virtual void RemoveTabWin(OTableWindow* pTabWin);
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 		// und ein AddTabWin, das einen Alias vorgibt
81cdf0e10cSrcweir 		void	AddTabWin(const ::rtl::OUString& strDatabase, const ::rtl::OUString& strTableName, const ::rtl::OUString& strAlias, sal_Bool bNewTable = sal_False);
82cdf0e10cSrcweir 		// TabWin suchen
83cdf0e10cSrcweir 		OQueryTableWindow*	FindTable(const String& rAliasName);
84cdf0e10cSrcweir 		sal_Bool			FindTableFromField(const String& rFieldName, OTableFieldDescRef& rInfo, sal_uInt16& rCnt);
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 		// Basisklasse ueberschrieben : Connections kreieren und loeschen
87cdf0e10cSrcweir 		virtual void AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest);
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 		virtual bool RemoveConnection( OTableConnection* _pConn ,sal_Bool _bDelete);
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 		// Transfer von Connections von/zu einer UndoAction
92cdf0e10cSrcweir 		void GetConnection(OQueryTableConnection* pConn);
93cdf0e10cSrcweir 			// Einfuegen einer Connection in meine Struktur
94cdf0e10cSrcweir 		void DropConnection(OQueryTableConnection* pConn);
95cdf0e10cSrcweir 			// Entfernen einer Connection aus meiner Struktur
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 			// das resultiert effektiv in einem voelligen Leeren des Abfrageentwurfs, da alle Fenster versteckt werden, und dabei
98cdf0e10cSrcweir 			// natuerlich alle Connections an diesen Fenstern und alle Abfrage-Spalten, die auf diesen Tabellen basierten.
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 		// TabWin anzeigen oder verstecken (NICHT kreieren oder loeschen)
101cdf0e10cSrcweir 		sal_Bool	ShowTabWin(OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction,sal_Bool _bAppend);
102cdf0e10cSrcweir 		void	HideTabWin(OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction);
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 		// Sichbarkeit eines TabWins sicherstellen (+ Invalidieren der Connections)
105cdf0e10cSrcweir 		virtual void EnsureVisible(const OTableWindow* _pWin);
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 		// wieviel Tabellen mit einem bestimmten Namen habe ich schon ?
108cdf0e10cSrcweir 		sal_Int32	CountTableAlias(const String& rName, sal_Int32& rMax);
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 		// ein Feld einfuegen (wird einfach an das Elter weitergereicht
111cdf0e10cSrcweir 		void InsertField(const OTableFieldDescRef& rInfo);
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 		// alles (TabWins, Connections) neu aufbauen (PRECONDITION : vorher wurde ClearAll gerufen)
114cdf0e10cSrcweir 		virtual void ReSync();
115cdf0e10cSrcweir 		// alles (TabWins, Connections) loeschen, und zwar hart, es erfolgen also keinerlei Notifications
116cdf0e10cSrcweir 		virtual void ClearAll();
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 		// wird vom AddTabDlg benutzt, um festzustellen, ob noch Tabellen hinzugefuegt werden duerfen
119cdf0e10cSrcweir 		//virtual sal_Bool IsAddAllowed();
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 		// eine neu Connection bekanntgeben und einfuegen lassen, wenn nicht schon existent
122cdf0e10cSrcweir 		void NotifyTabConnection(const OQueryTableConnection& rNewConn, sal_Bool _bCreateUndoAction = sal_True);
123cdf0e10cSrcweir 
SetTabWinsChangeHandler(const Link & lnk)124cdf0e10cSrcweir 		Link	SetTabWinsChangeHandler(const Link& lnk) { Link lnkRet = m_lnkTabWinsChangeHandler; m_lnkTabWinsChangeHandler = lnk; return lnkRet; }
125cdf0e10cSrcweir 			// der Handler bekommt einen Zeiger auf eine TabWinsChangeNotification-Struktur
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 		sal_Bool ExistsAVisitedConn(const OQueryTableWindow* pFrom) const;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 		virtual OTableWindowData* CreateImpl(const ::rtl::OUString& _rComposedName
130cdf0e10cSrcweir                                             ,const ::rtl::OUString& _sTableName
131cdf0e10cSrcweir 											,const ::rtl::OUString& _rWinName);
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 		/** createNewConnection opens the join dialog and allows to create a new join connection
134cdf0e10cSrcweir 		*/
135cdf0e10cSrcweir 		void createNewConnection();
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     private:
138cdf0e10cSrcweir         using OJoinTableView::EnsureVisible;
139cdf0e10cSrcweir 	};
140cdf0e10cSrcweir }
141cdf0e10cSrcweir #endif // DBAUI_QUERYTABLEVIEW_HXX
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 
147