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 _DBAUI_TABLETREE_HXX_
21 #define _DBAUI_TABLETREE_HXX_
23 #include "marktree.hxx"
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>
34 //.........................................................................
37 //.........................................................................
41 //========================================================================
43 //========================================================================
44 class OTableTreeListBox
: public OMarkableTreeListBox
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?
58 sal_Bool _bVirtualRoot
);
63 sal_Bool _bVirtualRoot
);
67 typedef ::std::pair
< OUString
,sal_Bool
> TTableViewName
;
68 typedef ::std::vector
< TTableViewName
> TNames
;
70 void suppressEmptyFolders() { m_bNoEmptyFolders
= true; }
72 /** call when HiContrast change.
74 void notifyHiContrastChanged();
76 /** determines whether the given entry denotes a tables folder
78 bool isFolderEntry( const SvTreeListEntry
* _pEntry
) const;
80 /** determines whether the given entry denotes a table or view
82 bool isTableOrViewEntry( const SvTreeListEntry
* _pEntry
) const
84 return !isFolderEntry( _pEntry
);
87 /** fill the table list with the tables belonging to the connection described by the parameters
89 the connection, which must support the service com.sun.star.sdb.Connection
91 <type scope="com::sun::star::sdbc">SQLException</type> if no connection could be created
94 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
95 ) throw(::com::sun::star::sdbc::SQLException
);
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
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
110 /** returns a NamedDatabaseObject record which describes the given entry
112 ::com::sun::star::sdb::application::NamedDatabaseObject
113 describeObject( SvTreeListEntry
* _pEntry
);
115 /** to be used if a foreign instance added a table
117 SvTreeListEntry
* addedTable( const OUString
& _rName
);
119 /** to be used if a foreign instance removed a table
121 void removedTable( const OUString
& _rName
);
123 /** returns the fully qualified name of a table entry
125 the entry whose name is to be obtained. Must not denote a folder entry.
127 String
getQualifiedTableName( SvTreeListEntry
* _pEntry
) const;
129 SvTreeListEntry
* getEntryByQualifiedName( const OUString
& _rName
);
131 SvTreeListEntry
* getAllObjectsEntry() const;
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>
138 void checkWildcard(SvTreeListEntry
* _pEntry
);
140 /** determine if the given entry is 'wildcard checked'
143 sal_Bool
isWildcardChecked(SvTreeListEntry
* _pEntry
) const;
146 virtual void InitEntry(SvTreeListEntry
* _pEntry
, const OUString
& _rString
, const Image
& _rCollapsedBitmap
, const Image
& _rExpandedBitmap
, SvLBoxButtonKind _eButtonKind
);
148 virtual void checkedButton_noBroadcast(SvTreeListEntry
* _pEntry
);
150 void implEmphasize(SvTreeListEntry
* _pEntry
, sal_Bool _bChecked
, sal_Bool _bUpdateDescendants
= sal_True
, sal_Bool _bUpdateAncestors
= sal_True
);
152 /** adds the given entry to our list
154 our image provider must already have been reset to the connection to which the meta data
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
163 void implSetDefaultImages();
165 void implOnNewConnection( const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
);
167 bool impl_getAndAssertMetaData( ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDatabaseMetaData
>& _out_rMetaData
) const;
169 sal_Bool
haveVirtualRoot() const { return m_bVirtualRoot
; }
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.
176 void UpdateTableList(
177 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
,
178 const TNames
& _rTables
183 //.........................................................................
185 //.........................................................................
187 #endif // _DBAUI_TABLETREE_HXX_
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */