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>
32 #include <boost/scoped_ptr.hpp>
38 class OTableTreeListBox
: public OMarkableTreeListBox
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?
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 /** determines whether the given entry denotes a table or view
68 static bool isTableOrViewEntry( const SvTreeListEntry
* _pEntry
)
70 return !isFolderEntry( _pEntry
);
73 /** fill the table list with the tables belonging to the connection described by the parameters
75 the connection, which must support the service com.sun.star.sdb.Connection
77 <type scope="com::sun::star::sdbc">SQLException</type> if no connection could be created
80 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
81 ) throw(::com::sun::star::sdbc::SQLException
);
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
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
96 /** returns a NamedDatabaseObject record which describes the given entry
98 ::com::sun::star::sdb::application::NamedDatabaseObject
99 describeObject( SvTreeListEntry
* _pEntry
);
101 /** to be used if a foreign instance added a table
103 SvTreeListEntry
* addedTable( const OUString
& _rName
);
105 /** to be used if a foreign instance removed a table
107 void removedTable( const OUString
& _rName
);
109 /** returns the fully qualified name of a table entry
111 the entry whose name is to be obtained. Must not denote a folder entry.
113 OUString
getQualifiedTableName( SvTreeListEntry
* _pEntry
) const;
115 SvTreeListEntry
* getEntryByQualifiedName( const OUString
& _rName
);
117 SvTreeListEntry
* getAllObjectsEntry() const;
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>
124 void checkWildcard(SvTreeListEntry
* _pEntry
);
126 /** determine if the given entry is 'wildcard checked'
129 static bool isWildcardChecked(SvTreeListEntry
* _pEntry
);
132 virtual void InitEntry(SvTreeListEntry
* _pEntry
, const OUString
& _rString
, const Image
& _rCollapsedBitmap
, const Image
& _rExpandedBitmap
, SvLBoxButtonKind _eButtonKind
) SAL_OVERRIDE
;
134 virtual void checkedButton_noBroadcast(SvTreeListEntry
* _pEntry
) SAL_OVERRIDE
;
136 void implEmphasize(SvTreeListEntry
* _pEntry
, bool _bChecked
, bool _bUpdateDescendants
= true, bool _bUpdateAncestors
= true);
138 /** adds the given entry to our list
140 our image provider must already have been reset to the connection to which the meta data
143 SvTreeListEntry
* implAddEntry(
144 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDatabaseMetaData
>& _rxMeta
,
145 const OUString
& _rTableName
,
146 bool _bCheckName
= true
149 void implSetDefaultImages();
151 void implOnNewConnection( const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
);
153 bool impl_getAndAssertMetaData( ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDatabaseMetaData
>& _out_rMetaData
) const;
155 bool haveVirtualRoot() const { return m_bVirtualRoot
; }
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.
162 void UpdateTableList(
163 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
,
164 const TNames
& _rTables
171 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_TABLETREE_HXX
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */