xref: /aoo41x/main/dbaccess/source/ui/inc/tabletree.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _DBAUI_TABLETREE_HXX_
29 #define _DBAUI_TABLETREE_HXX_
30 
31 #ifndef _DBAUI_MARKTREE_HXX_
32 #include "marktree.hxx"
33 #endif
34 
35 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
36 #include <com/sun/star/beans/PropertyValue.hpp>
37 #endif
38 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
39 #include <com/sun/star/container/XNameAccess.hpp>
40 #endif
41 #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
42 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
43 #endif
44 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
45 #include <com/sun/star/sdbc/XConnection.hpp>
46 #endif
47 #ifndef _COM_SUN_STAR_SDBC_XDRIVER_HPP_
48 #include <com/sun/star/sdbc/XDriver.hpp>
49 #endif
50 #ifndef _COM_SUN_STAR_SDB_APPLICATION_NAMEDDATABASEOBJECT_HPP_
51 #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
52 #endif
53 
54 #include <memory>
55 
56 //.........................................................................
57 namespace dbaui
58 {
59 //.........................................................................
60 
61 class ImageProvider;
62 
63 //========================================================================
64 //= OTableTreeListBox
65 //========================================================================
66 class OTableTreeListBox : public OMarkableTreeListBox
67 {
68 protected:
69     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
70                     m_xConnection;      // the connection we're working for, set in implOnNewConnection, called by UpdateTableList
71     ::std::auto_ptr< ImageProvider >
72                     m_pImageProvider;   // provider for our images
73 	sal_Bool		m_bVirtualRoot; // should the first entry be visible
74     bool            m_bNoEmptyFolders;  // should empty catalogs/schematas be prevented from being displayed?
75 
76 public:
77 	OTableTreeListBox(
78         Window* pParent,
79 		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
80         WinBits nWinStyle,
81         sal_Bool _bVirtualRoot );
82 
83 	OTableTreeListBox(
84         Window* pParent,
85 		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
86         const ResId& rResId,
87         sal_Bool _bVirtualRoot );
88 
89     ~OTableTreeListBox();
90 
91 	typedef ::std::pair< ::rtl::OUString,sal_Bool>	TTableViewName;
92 	typedef ::std::vector< TTableViewName >			TNames;
93 
94     void    suppressEmptyFolders() { m_bNoEmptyFolders = true; }
95 
96     /** call when HiContrast change.
97 	*/
98 	void notifyHiContrastChanged();
99 
100     /** determines whether the given entry denotes a tables folder
101     */
102     bool    isFolderEntry( const SvLBoxEntry* _pEntry ) const;
103 
104     /** determines whether the given entry denotes a table or view
105     */
106     bool    isTableOrViewEntry( const SvLBoxEntry* _pEntry ) const
107     {
108         return !isFolderEntry( _pEntry );
109     }
110 
111 	/** fill the table list with the tables belonging to the connection described by the parameters
112 		@param _rxConnection
113 			the connection, which must support the service com.sun.star.sdb.Connection
114 		@throws
115 			<type scope="com::sun::star::sdbc">SQLException</type> if no connection could be created
116 	*/
117 	void    UpdateTableList(
118 				const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
119 			)	throw(::com::sun::star::sdbc::SQLException);
120 
121 	/** fill the table list with the tables and views determined by the two given containers.
122 		The views sequence is used to determine which table is of type view.
123 		@param		_rxConnection   the connection where you got the object names from. Must not be NULL.
124 									Used to split the full qualified names into it's parts.
125 		@param		_rTables		table/view sequence
126 		@param		_rViews			view sequence
127 	*/
128 	void	UpdateTableList(
129 				const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
130 				const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _rTables,
131 				const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _rViews
132 			);
133 
134     /** returns a NamedDatabaseObject record which describes the given entry
135     */
136     ::com::sun::star::sdb::application::NamedDatabaseObject
137             describeObject( SvLBoxEntry* _pEntry );
138 
139 	/** to be used if a foreign instance added a table
140 	*/
141 	SvLBoxEntry* addedTable( const ::rtl::OUString& _rName );
142 
143 	/** to be used if a foreign instance removed a table
144 	*/
145 	void	removedTable( const ::rtl::OUString& _rName );
146 
147     /** returns the fully qualified name of a table entry
148         @param _pEntry
149             the entry whose name is to be obtained. Must not denote a folder entry.
150     */
151     String getQualifiedTableName( SvLBoxEntry* _pEntry ) const;
152 
153 	SvLBoxEntry*	getEntryByQualifiedName( const ::rtl::OUString& _rName );
154 
155 	SvLBoxEntry*	getAllObjectsEntry() const;
156 
157 	/** does a wildcard check of the given entry
158 		<p>There are two different 'checked' states: If the user checks all children of an entry, this is different
159 		from checking the entry itself. The second is called 'wildcard' checking, 'cause in the resulting
160 		table filter it's represented by a wildcard.</p>
161 	*/
162 	void			checkWildcard(SvLBoxEntry* _pEntry);
163 
164 	/** determine if the given entry is 'wildcard checked'
165 		@see checkWildcard
166 	*/
167 	sal_Bool		isWildcardChecked(SvLBoxEntry* _pEntry) const;
168 
169 protected:
170 	virtual void InitEntry(SvLBoxEntry* _pEntry, const XubString& _rString, const Image& _rCollapsedBitmap, const Image& _rExpandedBitmap, SvLBoxButtonKind _eButtonKind);
171 
172 	virtual void checkedButton_noBroadcast(SvLBoxEntry* _pEntry);
173 
174 	void implEmphasize(SvLBoxEntry* _pEntry, sal_Bool _bChecked, sal_Bool _bUpdateDescendants = sal_True, sal_Bool _bUpdateAncestors = sal_True);
175 
176     /** adds the given entry to our list
177         @precond
178             our image provider must already have been reset to the connection to which the meta data
179             belong.
180     */
181 	SvLBoxEntry* implAddEntry(
182 			const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxMeta,
183 			const ::rtl::OUString& _rTableName,
184 			sal_Bool _bCheckName = sal_True
185 		);
186 
187     void    implSetDefaultImages();
188 
189     void    implOnNewConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection );
190 
191     bool    impl_getAndAssertMetaData( ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _out_rMetaData ) const;
192 
193 	sal_Bool haveVirtualRoot() const { return m_bVirtualRoot; }
194 
195 	/** fill the table list with the tables and views determined by the two given containers
196 		@param		_rxConnection	the connection where you got the object names from. Must not be NULL.
197 									Used to split the full qualified names into it's parts.
198 		@param		_rTables		table/view sequence, the second argument is <TRUE/> if it is a table, otherwise it is a view.
199 	*/
200 	void	UpdateTableList(
201 				const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
202 				const TNames& _rTables
203 			);
204 
205 };
206 
207 //.........................................................................
208 }	// namespace dbaui
209 //.........................................................................
210 
211 #endif // _DBAUI_TABLETREE_HXX_
212 
213