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