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