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 DBAUI_QUERYTABLEVIEW_HXX
20 : #define DBAUI_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 : String strAffectedTable;
33 :
34 0 : TabWinsChangeNotification(ACTION_TYPE at, const String& 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);
48 : virtual void KeyInput(const KeyEvent& rEvt);
49 :
50 : virtual OTableWindow* createWindow(const TTableWindowData::value_type& _pData);
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();
56 :
57 : virtual bool supressCrossNaturalJoin(const TTableConnectionData::value_type& _pData) const;
58 :
59 : public:
60 : OQueryTableView(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 : virtual void AddTabWin( const ::rtl::OUString& _rTableName, const ::rtl::OUString& _rAliasName, sal_Bool bNewTable = sal_False );
66 : virtual void RemoveTabWin(OTableWindow* pTabWin);
67 :
68 : /// AddTabWin, setting an alias
69 : void AddTabWin(const ::rtl::OUString& strDatabase, const ::rtl::OUString& strTableName, const ::rtl::OUString& strAlias, sal_Bool bNewTable = sal_False);
70 : /// search TabWin
71 : OQueryTableWindow* FindTable(const String& rAliasName);
72 : sal_Bool FindTableFromField(const String& 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);
76 :
77 : virtual bool RemoveConnection( OTableConnection* _pConn ,sal_Bool _bDelete);
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 : sal_Bool ShowTabWin(OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction,sal_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);
96 :
97 : /// how many tables with a certain alias do I already have?
98 : sal_Int32 CountTableAlias(const String& 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();
106 :
107 : /// delete everything hard (TabWins, Connections), without any notifications
108 : virtual void ClearAll();
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 existant yet
114 : void NotifyTabConnection(const OQueryTableConnection& rNewConn, sal_Bool _bCreateUndoAction = sal_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 : sal_Bool ExistsAVisitedConn(const OQueryTableWindow* pFrom) const;
120 :
121 : virtual OTableWindowData* CreateImpl(const ::rtl::OUString& _rComposedName
122 : ,const ::rtl::OUString& _sTableName
123 : ,const ::rtl::OUString& _rWinName);
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: */
|