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 :
20 : #ifndef _DBAUI_TABLETREE_HXX_
21 : #define _DBAUI_TABLETREE_HXX_
22 :
23 : #include "marktree.hxx"
24 :
25 : #include <com/sun/star/beans/PropertyValue.hpp>
26 : #include <com/sun/star/container/XNameAccess.hpp>
27 : #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
28 : #include <com/sun/star/sdbc/XConnection.hpp>
29 : #include <com/sun/star/sdbc/XDriver.hpp>
30 : #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
31 :
32 : #include <memory>
33 :
34 : //.........................................................................
35 : namespace dbaui
36 : {
37 : //.........................................................................
38 :
39 : class ImageProvider;
40 :
41 : //========================================================================
42 : //= OTableTreeListBox
43 : //========================================================================
44 : class OTableTreeListBox : public OMarkableTreeListBox
45 : {
46 : protected:
47 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
48 : m_xConnection; // the connection we're working for, set in implOnNewConnection, called by UpdateTableList
49 : ::std::auto_ptr< ImageProvider >
50 : m_pImageProvider; // provider for our images
51 : sal_Bool m_bVirtualRoot; // should the first entry be visible
52 : bool m_bNoEmptyFolders; // should empty catalogs/schematas be prevented from being displayed?
53 :
54 : public:
55 : OTableTreeListBox(
56 : Window* pParent,
57 : WinBits nWinStyle,
58 : sal_Bool _bVirtualRoot );
59 :
60 : OTableTreeListBox(
61 : Window* pParent,
62 : const ResId& rResId,
63 : sal_Bool _bVirtualRoot );
64 :
65 : ~OTableTreeListBox();
66 :
67 : typedef ::std::pair< OUString,sal_Bool> TTableViewName;
68 : typedef ::std::vector< TTableViewName > TNames;
69 :
70 0 : void suppressEmptyFolders() { m_bNoEmptyFolders = true; }
71 :
72 : /** call when HiContrast change.
73 : */
74 : void notifyHiContrastChanged();
75 :
76 : /** determines whether the given entry denotes a tables folder
77 : */
78 : bool isFolderEntry( const SvTreeListEntry* _pEntry ) const;
79 :
80 : /** determines whether the given entry denotes a table or view
81 : */
82 : bool isTableOrViewEntry( const SvTreeListEntry* _pEntry ) const
83 : {
84 : return !isFolderEntry( _pEntry );
85 : }
86 :
87 : /** fill the table list with the tables belonging to the connection described by the parameters
88 : @param _rxConnection
89 : the connection, which must support the service com.sun.star.sdb.Connection
90 : @throws
91 : <type scope="com::sun::star::sdbc">SQLException</type> if no connection could be created
92 : */
93 : void UpdateTableList(
94 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
95 : ) throw(::com::sun::star::sdbc::SQLException);
96 :
97 : /** fill the table list with the tables and views determined by the two given containers.
98 : The views sequence is used to determine which table is of type view.
99 : @param _rxConnection the connection where you got the object names from. Must not be NULL.
100 : Used to split the full qualified names into it's parts.
101 : @param _rTables table/view sequence
102 : @param _rViews view sequence
103 : */
104 : void UpdateTableList(
105 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
106 : const ::com::sun::star::uno::Sequence< OUString>& _rTables,
107 : const ::com::sun::star::uno::Sequence< OUString>& _rViews
108 : );
109 :
110 : /** returns a NamedDatabaseObject record which describes the given entry
111 : */
112 : ::com::sun::star::sdb::application::NamedDatabaseObject
113 : describeObject( SvTreeListEntry* _pEntry );
114 :
115 : /** to be used if a foreign instance added a table
116 : */
117 : SvTreeListEntry* addedTable( const OUString& _rName );
118 :
119 : /** to be used if a foreign instance removed a table
120 : */
121 : void removedTable( const OUString& _rName );
122 :
123 : /** returns the fully qualified name of a table entry
124 : @param _pEntry
125 : the entry whose name is to be obtained. Must not denote a folder entry.
126 : */
127 : String getQualifiedTableName( SvTreeListEntry* _pEntry ) const;
128 :
129 : SvTreeListEntry* getEntryByQualifiedName( const OUString& _rName );
130 :
131 : SvTreeListEntry* getAllObjectsEntry() const;
132 :
133 : /** does a wildcard check of the given entry
134 : <p>There are two different 'checked' states: If the user checks all children of an entry, this is different
135 : from checking the entry itself. The second is called 'wildcard' checking, 'cause in the resulting
136 : table filter it's represented by a wildcard.</p>
137 : */
138 : void checkWildcard(SvTreeListEntry* _pEntry);
139 :
140 : /** determine if the given entry is 'wildcard checked'
141 : @see checkWildcard
142 : */
143 : sal_Bool isWildcardChecked(SvTreeListEntry* _pEntry) const;
144 :
145 : protected:
146 : virtual void InitEntry(SvTreeListEntry* _pEntry, const OUString& _rString, const Image& _rCollapsedBitmap, const Image& _rExpandedBitmap, SvLBoxButtonKind _eButtonKind);
147 :
148 : virtual void checkedButton_noBroadcast(SvTreeListEntry* _pEntry);
149 :
150 : void implEmphasize(SvTreeListEntry* _pEntry, sal_Bool _bChecked, sal_Bool _bUpdateDescendants = sal_True, sal_Bool _bUpdateAncestors = sal_True);
151 :
152 : /** adds the given entry to our list
153 : @precond
154 : our image provider must already have been reset to the connection to which the meta data
155 : belong.
156 : */
157 : SvTreeListEntry* implAddEntry(
158 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxMeta,
159 : const OUString& _rTableName,
160 : sal_Bool _bCheckName = sal_True
161 : );
162 :
163 : void implSetDefaultImages();
164 :
165 : void implOnNewConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection );
166 :
167 : bool impl_getAndAssertMetaData( ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _out_rMetaData ) const;
168 :
169 0 : sal_Bool haveVirtualRoot() const { return m_bVirtualRoot; }
170 :
171 : /** fill the table list with the tables and views determined by the two given containers
172 : @param _rxConnection the connection where you got the object names from. Must not be NULL.
173 : Used to split the full qualified names into it's parts.
174 : @param _rTables table/view sequence, the second argument is <TRUE/> if it is a table, otherwise it is a view.
175 : */
176 : void UpdateTableList(
177 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
178 : const TNames& _rTables
179 : );
180 :
181 : };
182 :
183 : //.........................................................................
184 : } // namespace dbaui
185 : //.........................................................................
186 :
187 : #endif // _DBAUI_TABLETREE_HXX_
188 :
189 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|