1*2e2212a7SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2e2212a7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2e2212a7SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2e2212a7SAndrew Rist * distributed with this work for additional information 6*2e2212a7SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2e2212a7SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2e2212a7SAndrew Rist * "License"); you may not use this file except in compliance 9*2e2212a7SAndrew Rist * with the License. You may obtain a copy of the License at 10*2e2212a7SAndrew Rist * 11*2e2212a7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2e2212a7SAndrew Rist * 13*2e2212a7SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2e2212a7SAndrew Rist * software distributed under the License is distributed on an 15*2e2212a7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2e2212a7SAndrew Rist * KIND, either express or implied. See the License for the 17*2e2212a7SAndrew Rist * specific language governing permissions and limitations 18*2e2212a7SAndrew Rist * under the License. 19*2e2212a7SAndrew Rist * 20*2e2212a7SAndrew Rist *************************************************************/ 21*2e2212a7SAndrew Rist 22*2e2212a7SAndrew 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 45cdf0e10cSrcweir 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) 76cdf0e10cSrcweir virtual void AddTabWin( const ::rtl::OUString& _rTableName, const ::rtl::OUString& _rAliasName, sal_Bool bNewTable = sal_False ); 77cdf0e10cSrcweir virtual void RemoveTabWin(OTableWindow* pTabWin); 78cdf0e10cSrcweir 79cdf0e10cSrcweir // und ein AddTabWin, das einen Alias vorgibt 80cdf0e10cSrcweir void AddTabWin(const ::rtl::OUString& strDatabase, const ::rtl::OUString& strTableName, const ::rtl::OUString& strAlias, sal_Bool bNewTable = sal_False); 81cdf0e10cSrcweir // TabWin suchen 82cdf0e10cSrcweir OQueryTableWindow* FindTable(const String& rAliasName); 83cdf0e10cSrcweir sal_Bool FindTableFromField(const String& rFieldName, OTableFieldDescRef& rInfo, sal_uInt16& rCnt); 84cdf0e10cSrcweir 85cdf0e10cSrcweir // Basisklasse ueberschrieben : Connections kreieren und loeschen 86cdf0e10cSrcweir virtual void AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest); 87cdf0e10cSrcweir 88cdf0e10cSrcweir virtual bool RemoveConnection( OTableConnection* _pConn ,sal_Bool _bDelete); 89cdf0e10cSrcweir 90cdf0e10cSrcweir // Transfer von Connections von/zu einer UndoAction 91cdf0e10cSrcweir void GetConnection(OQueryTableConnection* pConn); 92cdf0e10cSrcweir // Einfuegen einer Connection in meine Struktur 93cdf0e10cSrcweir void DropConnection(OQueryTableConnection* pConn); 94cdf0e10cSrcweir // Entfernen einer Connection aus meiner Struktur 95cdf0e10cSrcweir 96cdf0e10cSrcweir // das resultiert effektiv in einem voelligen Leeren des Abfrageentwurfs, da alle Fenster versteckt werden, und dabei 97cdf0e10cSrcweir // natuerlich alle Connections an diesen Fenstern und alle Abfrage-Spalten, die auf diesen Tabellen basierten. 98cdf0e10cSrcweir 99cdf0e10cSrcweir // TabWin anzeigen oder verstecken (NICHT kreieren oder loeschen) 100cdf0e10cSrcweir sal_Bool ShowTabWin(OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction,sal_Bool _bAppend); 101cdf0e10cSrcweir void HideTabWin(OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction); 102cdf0e10cSrcweir 103cdf0e10cSrcweir // Sichbarkeit eines TabWins sicherstellen (+ Invalidieren der Connections) 104cdf0e10cSrcweir virtual void EnsureVisible(const OTableWindow* _pWin); 105cdf0e10cSrcweir 106cdf0e10cSrcweir // wieviel Tabellen mit einem bestimmten Namen habe ich schon ? 107cdf0e10cSrcweir sal_Int32 CountTableAlias(const String& rName, sal_Int32& rMax); 108cdf0e10cSrcweir 109cdf0e10cSrcweir // ein Feld einfuegen (wird einfach an das Elter weitergereicht 110cdf0e10cSrcweir void InsertField(const OTableFieldDescRef& rInfo); 111cdf0e10cSrcweir 112cdf0e10cSrcweir // alles (TabWins, Connections) neu aufbauen (PRECONDITION : vorher wurde ClearAll gerufen) 113cdf0e10cSrcweir virtual void ReSync(); 114cdf0e10cSrcweir // alles (TabWins, Connections) loeschen, und zwar hart, es erfolgen also keinerlei Notifications 115cdf0e10cSrcweir virtual void ClearAll(); 116cdf0e10cSrcweir 117cdf0e10cSrcweir // wird vom AddTabDlg benutzt, um festzustellen, ob noch Tabellen hinzugefuegt werden duerfen 118cdf0e10cSrcweir //virtual sal_Bool IsAddAllowed(); 119cdf0e10cSrcweir 120cdf0e10cSrcweir // eine neu Connection bekanntgeben und einfuegen lassen, wenn nicht schon existent 121cdf0e10cSrcweir void NotifyTabConnection(const OQueryTableConnection& rNewConn, sal_Bool _bCreateUndoAction = sal_True); 122cdf0e10cSrcweir 123cdf0e10cSrcweir Link SetTabWinsChangeHandler(const Link& lnk) { Link lnkRet = m_lnkTabWinsChangeHandler; m_lnkTabWinsChangeHandler = lnk; return lnkRet; } 124cdf0e10cSrcweir // der Handler bekommt einen Zeiger auf eine TabWinsChangeNotification-Struktur 125cdf0e10cSrcweir 126cdf0e10cSrcweir sal_Bool ExistsAVisitedConn(const OQueryTableWindow* pFrom) const; 127cdf0e10cSrcweir 128cdf0e10cSrcweir virtual OTableWindowData* CreateImpl(const ::rtl::OUString& _rComposedName 129cdf0e10cSrcweir ,const ::rtl::OUString& _sTableName 130cdf0e10cSrcweir ,const ::rtl::OUString& _rWinName); 131cdf0e10cSrcweir 132cdf0e10cSrcweir /** createNewConnection opens the join dialog and allows to create a new join connection 133cdf0e10cSrcweir */ 134cdf0e10cSrcweir void createNewConnection(); 135cdf0e10cSrcweir 136cdf0e10cSrcweir private: 137cdf0e10cSrcweir using OJoinTableView::EnsureVisible; 138cdf0e10cSrcweir }; 139cdf0e10cSrcweir } 140cdf0e10cSrcweir #endif // DBAUI_QUERYTABLEVIEW_HXX 141cdf0e10cSrcweir 142cdf0e10cSrcweir 143cdf0e10cSrcweir 144cdf0e10cSrcweir 145cdf0e10cSrcweir 146