1*2e2212a7SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2e2212a7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2e2212a7SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2e2212a7SAndrew Rist * distributed with this work for additional information 6*2e2212a7SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2e2212a7SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2e2212a7SAndrew Rist * "License"); you may not use this file except in compliance 9*2e2212a7SAndrew Rist * with the License. You may obtain a copy of the License at 10*2e2212a7SAndrew Rist * 11*2e2212a7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2e2212a7SAndrew Rist * 13*2e2212a7SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2e2212a7SAndrew Rist * software distributed under the License is distributed on an 15*2e2212a7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2e2212a7SAndrew Rist * KIND, either express or implied. See the License for the 17*2e2212a7SAndrew Rist * specific language governing permissions and limitations 18*2e2212a7SAndrew Rist * under the License. 19*2e2212a7SAndrew Rist * 20*2e2212a7SAndrew Rist *************************************************************/ 21*2e2212a7SAndrew Rist 22*2e2212a7SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _DBAUI_TABLETREE_HXX_ 25cdf0e10cSrcweir #define _DBAUI_TABLETREE_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifndef _DBAUI_MARKTREE_HXX_ 28cdf0e10cSrcweir #include "marktree.hxx" 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir 31cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ 32cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 33cdf0e10cSrcweir #endif 34cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ 35cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 36cdf0e10cSrcweir #endif 37cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ 38cdf0e10cSrcweir #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> 39cdf0e10cSrcweir #endif 40cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ 41cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp> 42cdf0e10cSrcweir #endif 43cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XDRIVER_HPP_ 44cdf0e10cSrcweir #include <com/sun/star/sdbc/XDriver.hpp> 45cdf0e10cSrcweir #endif 46cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_APPLICATION_NAMEDDATABASEOBJECT_HPP_ 47cdf0e10cSrcweir #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp> 48cdf0e10cSrcweir #endif 49cdf0e10cSrcweir 50cdf0e10cSrcweir #include <memory> 51cdf0e10cSrcweir 52cdf0e10cSrcweir //......................................................................... 53cdf0e10cSrcweir namespace dbaui 54cdf0e10cSrcweir { 55cdf0e10cSrcweir //......................................................................... 56cdf0e10cSrcweir 57cdf0e10cSrcweir class ImageProvider; 58cdf0e10cSrcweir 59cdf0e10cSrcweir //======================================================================== 60cdf0e10cSrcweir //= OTableTreeListBox 61cdf0e10cSrcweir //======================================================================== 62cdf0e10cSrcweir class OTableTreeListBox : public OMarkableTreeListBox 63cdf0e10cSrcweir { 64cdf0e10cSrcweir protected: 65cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > 66cdf0e10cSrcweir m_xConnection; // the connection we're working for, set in implOnNewConnection, called by UpdateTableList 67cdf0e10cSrcweir ::std::auto_ptr< ImageProvider > 68cdf0e10cSrcweir m_pImageProvider; // provider for our images 69cdf0e10cSrcweir sal_Bool m_bVirtualRoot; // should the first entry be visible 70cdf0e10cSrcweir bool m_bNoEmptyFolders; // should empty catalogs/schematas be prevented from being displayed? 71cdf0e10cSrcweir 72cdf0e10cSrcweir public: 73cdf0e10cSrcweir OTableTreeListBox( 74cdf0e10cSrcweir Window* pParent, 75cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, 76cdf0e10cSrcweir WinBits nWinStyle, 77cdf0e10cSrcweir sal_Bool _bVirtualRoot ); 78cdf0e10cSrcweir 79cdf0e10cSrcweir OTableTreeListBox( 80cdf0e10cSrcweir Window* pParent, 81cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, 82cdf0e10cSrcweir const ResId& rResId, 83cdf0e10cSrcweir sal_Bool _bVirtualRoot ); 84cdf0e10cSrcweir 85cdf0e10cSrcweir ~OTableTreeListBox(); 86cdf0e10cSrcweir 87cdf0e10cSrcweir typedef ::std::pair< ::rtl::OUString,sal_Bool> TTableViewName; 88cdf0e10cSrcweir typedef ::std::vector< TTableViewName > TNames; 89cdf0e10cSrcweir suppressEmptyFolders()90cdf0e10cSrcweir void suppressEmptyFolders() { m_bNoEmptyFolders = true; } 91cdf0e10cSrcweir 92cdf0e10cSrcweir /** call when HiContrast change. 93cdf0e10cSrcweir */ 94cdf0e10cSrcweir void notifyHiContrastChanged(); 95cdf0e10cSrcweir 96cdf0e10cSrcweir /** determines whether the given entry denotes a tables folder 97cdf0e10cSrcweir */ 98cdf0e10cSrcweir bool isFolderEntry( const SvLBoxEntry* _pEntry ) const; 99cdf0e10cSrcweir 100cdf0e10cSrcweir /** determines whether the given entry denotes a table or view 101cdf0e10cSrcweir */ isTableOrViewEntry(const SvLBoxEntry * _pEntry) const102cdf0e10cSrcweir bool isTableOrViewEntry( const SvLBoxEntry* _pEntry ) const 103cdf0e10cSrcweir { 104cdf0e10cSrcweir return !isFolderEntry( _pEntry ); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir /** fill the table list with the tables belonging to the connection described by the parameters 108cdf0e10cSrcweir @param _rxConnection 109cdf0e10cSrcweir the connection, which must support the service com.sun.star.sdb.Connection 110cdf0e10cSrcweir @throws 111cdf0e10cSrcweir <type scope="com::sun::star::sdbc">SQLException</type> if no connection could be created 112cdf0e10cSrcweir */ 113cdf0e10cSrcweir void UpdateTableList( 114cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection 115cdf0e10cSrcweir ) throw(::com::sun::star::sdbc::SQLException); 116cdf0e10cSrcweir 117cdf0e10cSrcweir /** fill the table list with the tables and views determined by the two given containers. 118cdf0e10cSrcweir The views sequence is used to determine which table is of type view. 119cdf0e10cSrcweir @param _rxConnection the connection where you got the object names from. Must not be NULL. 120cdf0e10cSrcweir Used to split the full qualified names into it's parts. 121cdf0e10cSrcweir @param _rTables table/view sequence 122cdf0e10cSrcweir @param _rViews view sequence 123cdf0e10cSrcweir */ 124cdf0e10cSrcweir void UpdateTableList( 125cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, 126cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _rTables, 127cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _rViews 128cdf0e10cSrcweir ); 129cdf0e10cSrcweir 130cdf0e10cSrcweir /** returns a NamedDatabaseObject record which describes the given entry 131cdf0e10cSrcweir */ 132cdf0e10cSrcweir ::com::sun::star::sdb::application::NamedDatabaseObject 133cdf0e10cSrcweir describeObject( SvLBoxEntry* _pEntry ); 134cdf0e10cSrcweir 135cdf0e10cSrcweir /** to be used if a foreign instance added a table 136cdf0e10cSrcweir */ 137cdf0e10cSrcweir SvLBoxEntry* addedTable( const ::rtl::OUString& _rName ); 138cdf0e10cSrcweir 139cdf0e10cSrcweir /** to be used if a foreign instance removed a table 140cdf0e10cSrcweir */ 141cdf0e10cSrcweir void removedTable( const ::rtl::OUString& _rName ); 142cdf0e10cSrcweir 143cdf0e10cSrcweir /** returns the fully qualified name of a table entry 144cdf0e10cSrcweir @param _pEntry 145cdf0e10cSrcweir the entry whose name is to be obtained. Must not denote a folder entry. 146cdf0e10cSrcweir */ 147cdf0e10cSrcweir String getQualifiedTableName( SvLBoxEntry* _pEntry ) const; 148cdf0e10cSrcweir 149cdf0e10cSrcweir SvLBoxEntry* getEntryByQualifiedName( const ::rtl::OUString& _rName ); 150cdf0e10cSrcweir 151cdf0e10cSrcweir SvLBoxEntry* getAllObjectsEntry() const; 152cdf0e10cSrcweir 153cdf0e10cSrcweir /** does a wildcard check of the given entry 154cdf0e10cSrcweir <p>There are two different 'checked' states: If the user checks all children of an entry, this is different 155cdf0e10cSrcweir from checking the entry itself. The second is called 'wildcard' checking, 'cause in the resulting 156cdf0e10cSrcweir table filter it's represented by a wildcard.</p> 157cdf0e10cSrcweir */ 158cdf0e10cSrcweir void checkWildcard(SvLBoxEntry* _pEntry); 159cdf0e10cSrcweir 160cdf0e10cSrcweir /** determine if the given entry is 'wildcard checked' 161cdf0e10cSrcweir @see checkWildcard 162cdf0e10cSrcweir */ 163cdf0e10cSrcweir sal_Bool isWildcardChecked(SvLBoxEntry* _pEntry) const; 164cdf0e10cSrcweir 165cdf0e10cSrcweir protected: 166cdf0e10cSrcweir virtual void InitEntry(SvLBoxEntry* _pEntry, const XubString& _rString, const Image& _rCollapsedBitmap, const Image& _rExpandedBitmap, SvLBoxButtonKind _eButtonKind); 167cdf0e10cSrcweir 168cdf0e10cSrcweir virtual void checkedButton_noBroadcast(SvLBoxEntry* _pEntry); 169cdf0e10cSrcweir 170cdf0e10cSrcweir void implEmphasize(SvLBoxEntry* _pEntry, sal_Bool _bChecked, sal_Bool _bUpdateDescendants = sal_True, sal_Bool _bUpdateAncestors = sal_True); 171cdf0e10cSrcweir 172cdf0e10cSrcweir /** adds the given entry to our list 173cdf0e10cSrcweir @precond 174cdf0e10cSrcweir our image provider must already have been reset to the connection to which the meta data 175cdf0e10cSrcweir belong. 176cdf0e10cSrcweir */ 177cdf0e10cSrcweir SvLBoxEntry* implAddEntry( 178cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxMeta, 179cdf0e10cSrcweir const ::rtl::OUString& _rTableName, 180cdf0e10cSrcweir sal_Bool _bCheckName = sal_True 181cdf0e10cSrcweir ); 182cdf0e10cSrcweir 183cdf0e10cSrcweir void implSetDefaultImages(); 184cdf0e10cSrcweir 185cdf0e10cSrcweir void implOnNewConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection ); 186cdf0e10cSrcweir 187cdf0e10cSrcweir bool impl_getAndAssertMetaData( ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _out_rMetaData ) const; 188cdf0e10cSrcweir haveVirtualRoot() const189cdf0e10cSrcweir sal_Bool haveVirtualRoot() const { return m_bVirtualRoot; } 190cdf0e10cSrcweir 191cdf0e10cSrcweir /** fill the table list with the tables and views determined by the two given containers 192cdf0e10cSrcweir @param _rxConnection the connection where you got the object names from. Must not be NULL. 193cdf0e10cSrcweir Used to split the full qualified names into it's parts. 194cdf0e10cSrcweir @param _rTables table/view sequence, the second argument is <TRUE/> if it is a table, otherwise it is a view. 195cdf0e10cSrcweir */ 196cdf0e10cSrcweir void UpdateTableList( 197cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, 198cdf0e10cSrcweir const TNames& _rTables 199cdf0e10cSrcweir ); 200cdf0e10cSrcweir 201cdf0e10cSrcweir }; 202cdf0e10cSrcweir 203cdf0e10cSrcweir //......................................................................... 204cdf0e10cSrcweir } // namespace dbaui 205cdf0e10cSrcweir //......................................................................... 206cdf0e10cSrcweir 207cdf0e10cSrcweir #endif // _DBAUI_TABLETREE_HXX_ 208cdf0e10cSrcweir 209