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 0 : 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 VclPtr<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 :
62 : /// base class overwritten: create and delete windows
63 : /// (not really delete, as it becomes an UndoAction)
64 : bool ContainsTabWin(const OTableWindow& rTabWin); // #i122589# Allow to check if OTableWindow is registered
65 : virtual void AddTabWin( const OUString& _rTableName, const OUString& _rAliasName, bool bNewTable = false ) SAL_OVERRIDE;
66 : virtual void RemoveTabWin(OTableWindow* pTabWin) SAL_OVERRIDE;
67 :
68 : /// AddTabWin, setting an alias
69 : void AddTabWin(const OUString& strDatabase, const OUString& strTableName, const OUString& strAlias, bool bNewTable = false);
70 : /// search TabWin
71 : OQueryTableWindow* FindTable(const OUString& rAliasName);
72 : bool FindTableFromField(const OUString& rFieldName, OTableFieldDescRef& rInfo, sal_uInt16& rCnt);
73 :
74 : /// base class overwritten: create and delete Connections
75 : virtual void AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest) SAL_OVERRIDE;
76 :
77 : virtual bool RemoveConnection( OTableConnection* _pConn ,bool _bDelete) SAL_OVERRIDE;
78 :
79 : // transfer of connections from and to UndoAction
80 :
81 : /// Inserting a Connection the structure
82 : void GetConnection(OQueryTableConnection* pConn);
83 : /** Removing a Connection from the structure
84 :
85 : This results effectively in complete reset of request form, as all
86 : windows are hidden, as are all Connections to these windows and all
87 : request columns based on those tables */
88 : void DropConnection(OQueryTableConnection* pConn);
89 :
90 : // show and hide TabWin (NOT create or delete)
91 : bool ShowTabWin(OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction, bool _bAppend);
92 : void HideTabWin(OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction);
93 :
94 : /// ensure visibility of TabWins (+ and invalidate connections)
95 : virtual void EnsureVisible(const OTableWindow* _pWin) SAL_OVERRIDE;
96 :
97 : /// how many tables with a certain alias do I already have?
98 : sal_Int32 CountTableAlias(const OUString& rName, sal_Int32& rMax);
99 :
100 : /// insert field (simply passed to parents)
101 : void InsertField(const OTableFieldDescRef& rInfo);
102 :
103 : /// rebuild everything (TabWins, Connections)
104 : /// (PRECONDITION: ClearAll was called previously)
105 : virtual void ReSync() SAL_OVERRIDE;
106 :
107 : /// delete everything hard (TabWins, Connections), without any notifications
108 : virtual void ClearAll() SAL_OVERRIDE;
109 :
110 : // used by AddTabDlg to see if tables can still be added
111 : //virtual sal_Bool IsAddAllowed();
112 :
113 : /// announce new Connection and insert it, if not existing yet
114 : void NotifyTabConnection(const OQueryTableConnection& rNewConn, bool _bCreateUndoAction = true);
115 :
116 : /// @note the Handler receives a pointer to a TabWinsChangeNotification struct
117 : Link<> SetTabWinsChangeHandler(const Link<>& lnk) { Link<> lnkRet = m_lnkTabWinsChangeHandler; m_lnkTabWinsChangeHandler = lnk; return lnkRet; }
118 :
119 : bool ExistsAVisitedConn(const OQueryTableWindow* pFrom) const;
120 :
121 : virtual OTableWindowData* CreateImpl(const OUString& _rComposedName
122 : ,const OUString& _sTableName
123 : ,const OUString& _rWinName) SAL_OVERRIDE;
124 :
125 : /** opens the join dialog and allows to create a new join connection */
126 : void createNewConnection();
127 :
128 : private:
129 : using OJoinTableView::EnsureVisible;
130 : };
131 : }
132 : #endif
133 :
134 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|