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 .
20 #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_TABLETREE_HXX
21 #define INCLUDED_DBACCESS_SOURCE_UI_INC_TABLETREE_HXX
23 #include "imageprovider.hxx"
24 #include "marktree.hxx"
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>
38 class OTableTreeListBox
: public OMarkableTreeListBox
41 css::uno::Reference
< css::sdbc::XConnection
>
42 m_xConnection
; // the connection we're working for, set in implOnNewConnection, called by UpdateTableList
43 std::unique_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?
49 OTableTreeListBox(vcl::Window
* pParent
, WinBits nWinStyle
);
51 void init(bool bVirtualRoot
) { m_bVirtualRoot
= bVirtualRoot
; }
53 typedef ::std::pair
< OUString
, bool > TTableViewName
;
54 typedef ::std::vector
< TTableViewName
> TNames
;
56 void suppressEmptyFolders() { m_bNoEmptyFolders
= true; }
58 /** call when HiContrast change.
60 void notifyHiContrastChanged();
62 /** determines whether the given entry denotes a tables folder
64 static bool isFolderEntry( const SvTreeListEntry
* _pEntry
);
66 /** fill the table list with the tables belonging to the connection described by the parameters
68 the connection, which must support the service com.sun.star.sdb.Connection
70 <type scope="css::sdbc">SQLException</type> if no connection could be created
73 const css::uno::Reference
< css::sdbc::XConnection
>& _rxConnection
74 ) throw(css::sdbc::SQLException
, std::exception
);
76 /** fill the table list with the tables and views determined by the two given containers.
77 The views sequence is used to determine which table is of type view.
78 @param _rxConnection the connection where you got the object names from. Must not be NULL.
79 Used to split the full qualified names into its parts.
80 @param _rTables table/view sequence
81 @param _rViews view sequence
84 const css::uno::Reference
< css::sdbc::XConnection
>& _rxConnection
,
85 const css::uno::Sequence
< OUString
>& _rTables
,
86 const css::uno::Sequence
< OUString
>& _rViews
89 /** returns a NamedDatabaseObject record which describes the given entry
91 css::sdb::application::NamedDatabaseObject
92 describeObject( SvTreeListEntry
* _pEntry
);
94 /** to be used if a foreign instance added a table
96 SvTreeListEntry
* addedTable( const OUString
& _rName
);
98 /** to be used if a foreign instance removed a table
100 void removedTable( const OUString
& _rName
);
102 /** returns the fully qualified name of a table entry
104 the entry whose name is to be obtained. Must not denote a folder entry.
106 OUString
getQualifiedTableName( SvTreeListEntry
* _pEntry
) const;
108 SvTreeListEntry
* getEntryByQualifiedName( const OUString
& _rName
);
110 SvTreeListEntry
* getAllObjectsEntry() const;
112 /** does a wildcard check of the given entry
113 <p>There are two different 'checked' states: If the user checks all children of an entry, this is different
114 from checking the entry itself. The second is called 'wildcard' checking, 'cause in the resulting
115 table filter it's represented by a wildcard.</p>
117 void checkWildcard(SvTreeListEntry
* _pEntry
);
119 /** determine if the given entry is 'wildcard checked'
122 static bool isWildcardChecked(SvTreeListEntry
* _pEntry
);
125 virtual void InitEntry(SvTreeListEntry
* _pEntry
, const OUString
& _rString
, const Image
& _rCollapsedBitmap
, const Image
& _rExpandedBitmap
, SvLBoxButtonKind _eButtonKind
) override
;
127 virtual void checkedButton_noBroadcast(SvTreeListEntry
* _pEntry
) override
;
129 void implEmphasize(SvTreeListEntry
* _pEntry
, bool _bChecked
, bool _bUpdateDescendants
= true, bool _bUpdateAncestors
= true);
131 /** adds the given entry to our list
133 our image provider must already have been reset to the connection to which the meta data
136 SvTreeListEntry
* implAddEntry(
137 const css::uno::Reference
< css::sdbc::XDatabaseMetaData
>& _rxMeta
,
138 const OUString
& _rTableName
,
139 bool _bCheckName
= true
142 void implSetDefaultImages();
144 void implOnNewConnection( const css::uno::Reference
< css::sdbc::XConnection
>& _rxConnection
);
146 bool impl_getAndAssertMetaData( css::uno::Reference
< css::sdbc::XDatabaseMetaData
>& _out_rMetaData
) const;
148 bool haveVirtualRoot() const { return m_bVirtualRoot
; }
150 /** fill the table list with the tables and views determined by the two given containers
151 @param _rxConnection the connection where you got the object names from. Must not be NULL.
152 Used to split the full qualified names into its parts.
153 @param _rTables table/view sequence, the second argument is <TRUE/> if it is a table, otherwise it is a view.
155 void UpdateTableList(
156 const css::uno::Reference
< css::sdbc::XConnection
>& _rxConnection
,
157 const TNames
& _rTables
164 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_TABLETREE_HXX
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */