xref: /trunk/main/dbaccess/source/ui/inc/QueryTableView.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef DBAUI_QUERYTABLEVIEW_HXX
28 #define DBAUI_QUERYTABLEVIEW_HXX
29 
30 #ifndef DBAUI_JOINTABLEVIEW_HXX
31 #include "JoinTableView.hxx"
32 #endif
33 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
34 #include <com/sun/star/container/XNameAccess.hpp>
35 #endif
36 #ifndef DBAUI_QUERYCONTROLLER_HXX
37 #include "querycontroller.hxx"
38 #endif
39 
40 namespace dbaui
41 {
42 
43     struct TabWinsChangeNotification
44     {
45         enum ACTION_TYPE    { AT_ADDED_WIN, AT_REMOVED_WIN };
46         ACTION_TYPE         atActionPerformed;
47         String              strAffectedTable;
48 
49         TabWinsChangeNotification(ACTION_TYPE at, const String& str) : atActionPerformed(at), strAffectedTable(str) { }
50     };
51 
52     //========================================================================
53     class OQueryTabWinUndoAct;
54     class OQueryTabConnUndoAction;
55     class OQueryTableConnection;
56     class OQueryTableWindow;
57     class OQueryDesignView;
58     class OQueryTableView : public OJoinTableView
59     {
60         Link    m_lnkTabWinsChangeHandler;
61 
62     protected:
63         virtual void ConnDoubleClicked(OTableConnection* pConnection);
64         virtual void KeyInput(const KeyEvent& rEvt);
65 
66         virtual OTableWindow* createWindow(const TTableWindowData::value_type& _pData);
67 
68         /** called when init fails at the tablewindowdata because the m_xTable object could not provide columns, but no
69             exception was thrown. Expected to throw.
70         */
71         virtual void    onNoColumns_throw();
72 
73         virtual bool supressCrossNaturalJoin(const TTableConnectionData::value_type& _pData) const;
74     public:
75         OQueryTableView(Window* pParent,OQueryDesignView* pView);
76         virtual ~OQueryTableView();
77 
78         // Basisklasse ueberschrieben : Fenster kreieren und loeschen
79         // (eigentlich nicht wirklich LOESCHEN, es geht in die Verantwortung einer UNDO-Action ueber)
80         virtual void AddTabWin( const ::rtl::OUString& _rTableName, const ::rtl::OUString& _rAliasName, sal_Bool bNewTable = sal_False );
81         virtual void RemoveTabWin(OTableWindow* pTabWin);
82 
83         // und ein AddTabWin, das einen Alias vorgibt
84         void    AddTabWin(const ::rtl::OUString& strDatabase, const ::rtl::OUString& strTableName, const ::rtl::OUString& strAlias, sal_Bool bNewTable = sal_False);
85         // TabWin suchen
86         OQueryTableWindow*  FindTable(const String& rAliasName);
87         sal_Bool            FindTableFromField(const String& rFieldName, OTableFieldDescRef& rInfo, sal_uInt16& rCnt);
88 
89         // Basisklasse ueberschrieben : Connections kreieren und loeschen
90         virtual void AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest);
91 
92         virtual bool RemoveConnection( OTableConnection* _pConn ,sal_Bool _bDelete);
93 
94         // Transfer von Connections von/zu einer UndoAction
95         void GetConnection(OQueryTableConnection* pConn);
96             // Einfuegen einer Connection in meine Struktur
97         void DropConnection(OQueryTableConnection* pConn);
98             // Entfernen einer Connection aus meiner Struktur
99 
100             // das resultiert effektiv in einem voelligen Leeren des Abfrageentwurfs, da alle Fenster versteckt werden, und dabei
101             // natuerlich alle Connections an diesen Fenstern und alle Abfrage-Spalten, die auf diesen Tabellen basierten.
102 
103         // TabWin anzeigen oder verstecken (NICHT kreieren oder loeschen)
104         sal_Bool    ShowTabWin(OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction,sal_Bool _bAppend);
105         void    HideTabWin(OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction);
106 
107         // Sichbarkeit eines TabWins sicherstellen (+ Invalidieren der Connections)
108         virtual void EnsureVisible(const OTableWindow* _pWin);
109 
110         // wieviel Tabellen mit einem bestimmten Namen habe ich schon ?
111         sal_Int32   CountTableAlias(const String& rName, sal_Int32& rMax);
112 
113         // ein Feld einfuegen (wird einfach an das Elter weitergereicht
114         void InsertField(const OTableFieldDescRef& rInfo);
115 
116         // alles (TabWins, Connections) neu aufbauen (PRECONDITION : vorher wurde ClearAll gerufen)
117         virtual void ReSync();
118         // alles (TabWins, Connections) loeschen, und zwar hart, es erfolgen also keinerlei Notifications
119         virtual void ClearAll();
120 
121         // wird vom AddTabDlg benutzt, um festzustellen, ob noch Tabellen hinzugefuegt werden duerfen
122         //virtual sal_Bool IsAddAllowed();
123 
124         // eine neu Connection bekanntgeben und einfuegen lassen, wenn nicht schon existent
125         void NotifyTabConnection(const OQueryTableConnection& rNewConn, sal_Bool _bCreateUndoAction = sal_True);
126 
127         Link    SetTabWinsChangeHandler(const Link& lnk) { Link lnkRet = m_lnkTabWinsChangeHandler; m_lnkTabWinsChangeHandler = lnk; return lnkRet; }
128             // der Handler bekommt einen Zeiger auf eine TabWinsChangeNotification-Struktur
129 
130         sal_Bool ExistsAVisitedConn(const OQueryTableWindow* pFrom) const;
131 
132         virtual OTableWindowData* CreateImpl(const ::rtl::OUString& _rComposedName
133                                             ,const ::rtl::OUString& _sTableName
134                                             ,const ::rtl::OUString& _rWinName);
135 
136         /** createNewConnection opens the join dialog and allows to create a new join connection
137         */
138         void createNewConnection();
139 
140     private:
141         using OJoinTableView::EnsureVisible;
142     };
143 }
144 #endif // DBAUI_QUERYTABLEVIEW_HXX
145 
146 
147 
148 
149 
150