1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYTABLEVIEW_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYTABLEVIEW_HXX
22 #include "JoinTableView.hxx"
23 #include <com/sun/star/container/XNameAccess.hpp>
24 #include "querycontroller.hxx"
28 struct TabWinsChangeNotification
30 enum ACTION_TYPE
{ AT_ADDED_WIN
, AT_REMOVED_WIN
};
31 ACTION_TYPE atActionPerformed
;
32 OUString strAffectedTable
;
34 TabWinsChangeNotification(ACTION_TYPE at
, const OUString
& str
) : atActionPerformed(at
), strAffectedTable(str
) { }
37 class OQueryTabWinUndoAct
;
38 class OQueryTableConnection
;
39 class OQueryTableWindow
;
40 class OQueryDesignView
;
42 class OQueryTableView
: public OJoinTableView
44 Link
<> m_lnkTabWinsChangeHandler
;
47 virtual void ConnDoubleClicked(OTableConnection
* pConnection
) SAL_OVERRIDE
;
48 virtual void KeyInput(const KeyEvent
& rEvt
) SAL_OVERRIDE
;
50 virtual VclPtr
<OTableWindow
> createWindow(const TTableWindowData::value_type
& _pData
) SAL_OVERRIDE
;
52 /** called when init fails at the tablewindowdata because the m_xTable
53 object could not provide columns, but no exception was thrown.
55 virtual void onNoColumns_throw() SAL_OVERRIDE
;
57 virtual bool supressCrossNaturalJoin(const TTableConnectionData::value_type
& _pData
) const SAL_OVERRIDE
;
60 OQueryTableView(vcl::Window
* pParent
,OQueryDesignView
* pView
);
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
;
68 /// AddTabWin, setting an alias
69 void AddTabWin(const OUString
& strDatabase
, const OUString
& strTableName
, const OUString
& strAlias
, bool bNewTable
= false);
71 OQueryTableWindow
* FindTable(const OUString
& rAliasName
);
72 bool FindTableFromField(const OUString
& rFieldName
, OTableFieldDescRef
& rInfo
, sal_uInt16
& rCnt
);
74 /// base class overwritten: create and delete Connections
75 virtual void AddConnection(const OJoinExchangeData
& jxdSource
, const OJoinExchangeData
& jxdDest
) SAL_OVERRIDE
;
77 virtual bool RemoveConnection( OTableConnection
* _pConn
,bool _bDelete
) SAL_OVERRIDE
;
79 // transfer of connections from and to UndoAction
81 /// Inserting a Connection the structure
82 void GetConnection(OQueryTableConnection
* pConn
);
83 /** Removing a Connection from the structure
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
);
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
);
94 /// ensure visibility of TabWins (+ and invalidate connections)
95 virtual void EnsureVisible(const OTableWindow
* _pWin
) SAL_OVERRIDE
;
97 /// how many tables with a certain alias do I already have?
98 sal_Int32
CountTableAlias(const OUString
& rName
, sal_Int32
& rMax
);
100 /// insert field (simply passed to parents)
101 void InsertField(const OTableFieldDescRef
& rInfo
);
103 /// rebuild everything (TabWins, Connections)
104 /// (PRECONDITION: ClearAll was called previously)
105 virtual void ReSync() SAL_OVERRIDE
;
107 /// delete everything hard (TabWins, Connections), without any notifications
108 virtual void ClearAll() SAL_OVERRIDE
;
110 // used by AddTabDlg to see if tables can still be added
111 //virtual sal_Bool IsAddAllowed();
113 /// announce new Connection and insert it, if not existing yet
114 void NotifyTabConnection(const OQueryTableConnection
& rNewConn
, bool _bCreateUndoAction
= true);
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
; }
119 bool ExistsAVisitedConn(const OQueryTableWindow
* pFrom
) const;
121 virtual OTableWindowData
* CreateImpl(const OUString
& _rComposedName
122 ,const OUString
& _sTableName
123 ,const OUString
& _rWinName
) SAL_OVERRIDE
;
125 /** opens the join dialog and allows to create a new join connection */
126 void createNewConnection();
129 using OJoinTableView::EnsureVisible
;
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */