Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYTABLEVIEW_HXX
20 : #define INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYTABLEVIEW_HXX
21 :
22 : #include "JoinTableView.hxx"
23 : #include <com/sun/star/container/XNameAccess.hpp>
24 : #include "querycontroller.hxx"
25 :
26 : namespace dbaui
27 : {
28 0 : struct TabWinsChangeNotification
29 : {
30 : enum ACTION_TYPE { AT_ADDED_WIN, AT_REMOVED_WIN };
31 : ACTION_TYPE atActionPerformed;
32 : OUString strAffectedTable;
33 :
34 0 : TabWinsChangeNotification(ACTION_TYPE at, const OUString& str) : atActionPerformed(at), strAffectedTable(str) { }
35 : };
36 :
37 : class OQueryTabWinUndoAct;
38 : class OQueryTableConnection;
39 : class OQueryTableWindow;
40 : class OQueryDesignView;
41 :
42 : class OQueryTableView : public OJoinTableView
43 : {
44 : Link m_lnkTabWinsChangeHandler;
45 :
46 : protected:
47 : virtual void ConnDoubleClicked(OTableConnection* pConnection) SAL_OVERRIDE;
48 : virtual void KeyInput(const KeyEvent& rEvt) SAL_OVERRIDE;
49 :
50 : virtual OTableWindow* createWindow(const TTableWindowData::value_type& _pData) SAL_OVERRIDE;
51 :
52 : /** called when init fails at the tablewindowdata because the m_xTable
53 : object could not provide columns, but no exception was thrown.
54 : Expected to throw. */
55 : virtual void onNoColumns_throw() SAL_OVERRIDE;
56 :
57 : virtual bool supressCrossNaturalJoin(const TTableConnectionData::value_type& _pData) const SAL_OVERRIDE;
58 :
59 : public:
60 : OQueryTableView(vcl::Window* pParent,OQueryDesignView* pView);
61 : virtual ~OQueryTableView();
62 :
63 : /// base class overwritten: create and delete windows
64 : /// (not really delete, as it becomes an UndoAction)
65 : bool ContainsTabWin(const OTableWindow& rTabWin); // #i122589# Allow to check if OTableWindow is registered
66 : virtual void AddTabWin( const OUString& _rTableName, const OUString& _rAliasName, bool bNewTable = false ) SAL_OVERRIDE;
67 : virtual void RemoveTabWin(OTableWindow* pTabWin) SAL_OVERRIDE;
68 :
69 : /// AddTabWin, setting an alias
70 : void AddTabWin(const OUString& strDatabase, const OUString& strTableName, const OUString& strAlias, bool bNewTable = false);
71 : /// search TabWin
72 : OQueryTableWindow* FindTable(const OUString& rAliasName);
73 : bool FindTableFromField(const OUString& rFieldName, OTableFieldDescRef& rInfo, sal_uInt16& rCnt);
74 :
75 : /// base class overwritten: create and delete Connections
76 : virtual void AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest) SAL_OVERRIDE;
77 :
78 : virtual bool RemoveConnection( OTableConnection* _pConn ,bool _bDelete) SAL_OVERRIDE;
79 :
80 : // transfer of connections from and to UndoAction
81 :
82 : /// Inserting a Connection the structure
83 : void GetConnection(OQueryTableConnection* pConn);
84 : /** Removing a Connection from the structure
85 :
86 : This results effectively in complete reset of request form, as all
87 : windows are hidden, as are all Connections to these windows and all
88 : request columns based on those tables */
89 : void DropConnection(OQueryTableConnection* pConn);
90 :
91 : // show and hide TabWin (NOT create or delete)
92 : bool ShowTabWin(OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction, bool _bAppend);
93 : void HideTabWin(OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction);
94 :
95 : /// ensure visibility of TabWins (+ and invalidate connections)
96 : virtual void EnsureVisible(const OTableWindow* _pWin) SAL_OVERRIDE;
97 :
98 : /// how many tables with a certain alias do I already have?
99 : sal_Int32 CountTableAlias(const OUString& rName, sal_Int32& rMax);
100 :
101 : /// insert field (simply passed to parents)
102 : void InsertField(const OTableFieldDescRef& rInfo);
103 :
104 : /// rebuild everything (TabWins, Connections)
105 : /// (PRECONDITION: ClearAll was called previously)
106 : virtual void ReSync() SAL_OVERRIDE;
107 :
108 : /// delete everything hard (TabWins, Connections), without any notifications
109 : virtual void ClearAll() SAL_OVERRIDE;
110 :
111 : // used by AddTabDlg to see if tables can still be added
112 : //virtual sal_Bool IsAddAllowed();
113 :
114 : /// announce new Connection and insert it, if not existant yet
115 : void NotifyTabConnection(const OQueryTableConnection& rNewConn, bool _bCreateUndoAction = true);
116 :
117 : /// @note the Handler receives a pointer to a TabWinsChangeNotification struct
118 : Link SetTabWinsChangeHandler(const Link& lnk) { Link lnkRet = m_lnkTabWinsChangeHandler; m_lnkTabWinsChangeHandler = lnk; return lnkRet; }
119 :
120 : bool ExistsAVisitedConn(const OQueryTableWindow* pFrom) const;
121 :
122 : virtual OTableWindowData* CreateImpl(const OUString& _rComposedName
123 : ,const OUString& _sTableName
124 : ,const OUString& _rWinName) SAL_OVERRIDE;
125 :
126 : /** opens the join dialog and allows to create a new join connection */
127 : void createNewConnection();
128 :
129 : private:
130 : using OJoinTableView::EnsureVisible;
131 : };
132 : }
133 : #endif
134 :
135 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|