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