Tag: cws_src680_hsqlcsv User: fs Date: 2006/09/14 04:57:15 Modified: dba/dbaccess/source/ui/app/AppDetailPageHelper.cxx dba/dbaccess/source/ui/app/AppDetailPageHelper.hxx
Log: #i69526# outsourced image handling to an ImageProvider class File Changes: Directory: /dba/dbaccess/source/ui/app/ ======================================= File [changed]: AppDetailPageHelper.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppDetailPageHelper.cxx?r1=1.15&r2=1.15.12.1 Delta lines: +68 -82 --------------------- --- AppDetailPageHelper.cxx 28 Aug 2006 15:05:40 -0000 1.15 +++ AppDetailPageHelper.cxx 14 Sep 2006 11:57:13 -0000 1.15.12.1 @@ -4,9 +4,9 @@ * * $RCSfile: AppDetailPageHelper.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.15.12.1 $ * - * last change: $Author: ihi $ $Date: 2006/08/28 15:05:40 $ + * last change: $Author: fs $ $Date: 2006/09/14 11:57:13 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -137,6 +137,9 @@ #ifndef _DBAUI_QUERYDESIGNACCESS_HXX_ #include "querydesignaccess.hxx" #endif +#ifndef DBACCESS_IMAGEPROVIDER_HXX +#include "imageprovider.hxx" +#endif #ifndef _SV_WAITOBJ_HXX #include <vcl/waitobj.hxx> #endif @@ -390,7 +393,7 @@ sort(nPos,SortAscending); } // ----------------------------------------------------------------------------- -void OAppDetailPageHelper::getSelectionElementNames(::std::vector< ::rtl::OUString>& _rNames,const Reference< XDatabaseMetaData>& _xMetaData) const +void OAppDetailPageHelper::getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const { int nPos = getVisibleControlIndex(); if ( nPos < CONTROL_COUNT ) @@ -405,7 +408,7 @@ if ( eType == E_TABLE ) { if( rTree.GetChildCount(pEntry) == 0 ) - _rNames.push_back(getQualifiedName(pEntry,_xMetaData)); + _rNames.push_back(getQualifiedName( pEntry ) ); } else { @@ -423,13 +426,14 @@ } } // ----------------------------------------------------------------------------- -::rtl::OUString OAppDetailPageHelper::getQualifiedName(SvLBoxEntry* _pEntry,const Reference< XDatabaseMetaData>& _xMetaData) const +::rtl::OUString OAppDetailPageHelper::getQualifiedName( SvLBoxEntry* _pEntry ) const { int nPos = getVisibleControlIndex(); ::rtl::OUString sComposedName; - if ( nPos < CONTROL_COUNT ) - { + if ( nPos >= CONTROL_COUNT ) + return sComposedName; + OSL_ENSURE(m_pLists[nPos],"Tables tree view is NULL! -> GPF"); DBTreeListBox& rTree = *m_pLists[nPos]; @@ -437,38 +441,13 @@ if ( !pEntry ) pEntry = rTree.FirstSelected(); - if ( pEntry ) - { - if ( getElementType() == E_TABLE ) - { - OSL_ENSURE(_xMetaData.is(),"The database metadata are NULL! -> GPF"); - - - ::rtl::OUString sCatalog; - ::rtl::OUString sSchema; - ::rtl::OUString sTable; + if ( !pEntry ) + return sComposedName; - SvLBoxEntry* pSchema = rTree.GetParent(pEntry); - if ( pSchema ) - { - SvLBoxEntry* pCatalog = rTree.GetParent(pSchema); - if ( pCatalog || (_xMetaData->supportsCatalogsInDataManipulation() && !_xMetaData->supportsSchemasInDataManipulation()) ) // here we support catalog but no schema - { - if ( pCatalog == NULL ) - { - pCatalog = pSchema; - pSchema = NULL; - } - sCatalog = rTree.GetEntryText( pCatalog ); - } - if ( pSchema ) + if ( getElementType() == E_TABLE ) { - sSchema = rTree.GetEntryText(pSchema); - } - } - sTable = rTree.GetEntryText(pEntry); - - sComposedName = ::dbtools::composeTableName( _xMetaData, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation ); + const OTableTreeListBox& rTreeView = dynamic_cast< const OTableTreeListBox& >( *m_pLists[nPos] ); + sComposedName = rTreeView.getQualifiedTableName( _pEntry ); } else { @@ -480,8 +459,7 @@ pParent = rTree.GetParent(pParent); } } - } - } + return sComposedName; } // ----------------------------------------------------------------------------- @@ -554,7 +532,7 @@ sal_Bool bLeafSelected = sal_False; if ( nPos < CONTROL_COUNT && _pEntry ) { - bLeafSelected = reinterpret_cast<sal_IntPtr>(_pEntry->GetUserData()) != FOLDER_TYPE; + bLeafSelected = reinterpret_cast<sal_IntPtr>(_pEntry->GetUserData()) != FOLDER_INDICATOR; } return bLeafSelected; } @@ -569,7 +547,7 @@ SvLBoxEntry* pEntry = rTree.FirstSelected( ); while( !bLeafSelected && pEntry ) { - bLeafSelected = reinterpret_cast<sal_IntPtr>(pEntry->GetUserData()) != FOLDER_TYPE; + bLeafSelected = reinterpret_cast<sal_IntPtr>(pEntry->GetUserData()) != FOLDER_INDICATOR; pEntry = rTree.NextSelected(pEntry); } } @@ -597,7 +575,13 @@ ,sal_False); pTreeView->SetHelpId(HID_APP_TABLE_TREE); m_pLists[E_TABLE] = pTreeView; - createTree(pTreeView,TABLE_TREE_ICON,TABLE_TREE_ICON_SCH); + + ImageProvider aImageProvider( _xConnection ); + createTree( pTreeView, + aImageProvider.getDefaultImage( DatabaseObject::TABLE, false ), + aImageProvider.getDefaultImage( DatabaseObject::TABLE, true ) + ); + pTreeView->notifyHiContrastChanged(); m_aBorder.SetZOrder(pTreeView, WINDOW_ZORDER_BEHIND); } @@ -617,25 +601,21 @@ // ----------------------------------------------------------------------------- void OAppDetailPageHelper::getElementIcons( ElementType _eType, USHORT& _rImageId, USHORT& _rHighContrastImageId ) { + ImageProvider aImageProvider; _rImageId = _rHighContrastImageId = 0; + + sal_Int32 nDatabaseObjectType( 0 ); switch(_eType ) { - case E_FORM: - _rImageId = FORM_TREE_ICON; - _rHighContrastImageId = FORM_TREE_ICON_SCH; - break; - case E_REPORT: - _rImageId = REPORT_TREE_ICON; - _rHighContrastImageId = REPORT_TREE_ICON_SCH; - break; - case E_QUERY: - _rImageId = QUERY_TREE_ICON; - _rHighContrastImageId = QUERY_TREE_ICON_SCH; - break; + case E_FORM: nDatabaseObjectType = DatabaseObject::FORM; break; + case E_REPORT: nDatabaseObjectType = DatabaseObject::REPORT; break; + case E_QUERY: nDatabaseObjectType = DatabaseObject::QUERY; break; default: OSL_ENSURE( sal_False, "OAppDetailPageHelper::GetElementIcons: invalid element type!" ); - break; + return; } + _rImageId = aImageProvider.getDefaultImageResourceID( nDatabaseObjectType, false ); + _rHighContrastImageId = aImageProvider.getDefaultImageResourceID( nDatabaseObjectType, true ); } // ----------------------------------------------------------------------------- @@ -713,7 +693,13 @@ return createTree(pTreeView,_nCollapsedBitmap,_nCollapsedBitmap_HI); } // ----------------------------------------------------------------------------- -DBTreeListBox* OAppDetailPageHelper::createTree(DBTreeListBox* _pTreeView,USHORT _nCollapsedBitmap,USHORT _nCollapsedBitmap_HI) +DBTreeListBox* OAppDetailPageHelper::createTree( DBTreeListBox* _pTreeView, USHORT _nDefaultIconID, USHORT _nDefaultIconID_HC ) +{ + return createTree( _pTreeView, Image( ModuleRes( _nDefaultIconID ) ), Image( ModuleRes( _nDefaultIconID_HC ) ) ); +} + +// ----------------------------------------------------------------------------- +DBTreeListBox* OAppDetailPageHelper::createTree( DBTreeListBox* _pTreeView, const Image& _rDefaultIcon, const Image& _rDefaultIcon_HC ) { WaitObject aWaitCursor(this); @@ -722,10 +708,10 @@ _pTreeView->EnableCheckButton( NULL ); // do not show any buttons _pTreeView->SetSelectionMode(MULTIPLE_SELECTION); - _pTreeView->SetDefaultCollapsedEntryBmp(Image(ModuleRes(_nCollapsedBitmap))); - _pTreeView->SetDefaultCollapsedEntryBmp(Image(ModuleRes(_nCollapsedBitmap_HI)),BMP_COLOR_HIGHCONTRAST); - _pTreeView->SetDefaultExpandedEntryBmp(Image(ModuleRes(_nCollapsedBitmap))); - _pTreeView->SetDefaultExpandedEntryBmp(Image(ModuleRes(_nCollapsedBitmap_HI)),BMP_COLOR_HIGHCONTRAST); + _pTreeView->SetDefaultCollapsedEntryBmp( _rDefaultIcon ); + _pTreeView->SetDefaultCollapsedEntryBmp( _rDefaultIcon_HC, BMP_COLOR_HIGHCONTRAST ); + _pTreeView->SetDefaultExpandedEntryBmp( _rDefaultIcon ); + _pTreeView->SetDefaultExpandedEntryBmp( _rDefaultIcon_HC, BMP_COLOR_HIGHCONTRAST ); _pTreeView->SetDoubleClickHdl(LINK(this, OAppDetailPageHelper, OnEntryDoubleClick)); _pTreeView->SetEnterKeyHdl(LINK(this, OAppDetailPageHelper, OnEntryDoubleClick)); @@ -776,8 +762,8 @@ { case E_TABLE: OSL_ENSURE(_rxConn.is(),"Connection is NULL! ->GPF"); - static_cast<OTableTreeListBox*>(pTreeView)->removedTable(_rxConn,_rOldName); - static_cast<OTableTreeListBox*>(pTreeView)->addedTable(_rxConn,_rNewName, makeAny(_xObject)); + static_cast<OTableTreeListBox*>(pTreeView)->removedTable( _rOldName ); + static_cast<OTableTreeListBox*>(pTreeView)->addedTable( _rNewName ); return; case E_QUERY: @@ -805,7 +791,7 @@ if( _eType == E_TABLE && pTreeView ) { OSL_ENSURE(_rxConn.is(),"Connection is NULL! ->GPF"); - pRet = static_cast<OTableTreeListBox*>(pTreeView)->addedTable(_rxConn,_rName, _rObject); + pRet = static_cast<OTableTreeListBox*>(pTreeView)->addedTable( _rName ); } else if ( pTreeView ) { @@ -827,7 +813,7 @@ Reference<XNameAccess> xContainer(_rObject,UNO_QUERY); if ( xContainer.is() ) { - pRet = pTreeView->InsertEntry(_rName,pEntry,FALSE,LIST_APPEND,reinterpret_cast<void*>(FOLDER_TYPE)); + pRet = pTreeView->InsertEntry(_rName,pEntry,FALSE,LIST_APPEND,reinterpret_cast<void*>(FOLDER_INDICATOR)); fillNames( xContainer, *pTreeView, nImageId, nImageIdH, pRet ); } else @@ -856,7 +842,7 @@ case E_TABLE: OSL_ENSURE(_rxConn.is(),"Connection is NULL! ->GPF"); // we don't need to clear the table here, it is already done by the dispose listener - static_cast<OTableTreeListBox*>(pTreeView)->removedTable(_rxConn,_rName); + static_cast< OTableTreeListBox* >( pTreeView )->removedTable( _rName ); break; case E_QUERY: if ( pTreeView ) File [changed]: AppDetailPageHelper.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppDetailPageHelper.hxx?r1=1.10&r2=1.10.12.1 Delta lines: +12 -16 --------------------- --- AppDetailPageHelper.hxx 28 Aug 2006 15:05:51 -0000 1.10 +++ AppDetailPageHelper.hxx 14 Sep 2006 11:57:13 -0000 1.10.12.1 @@ -4,9 +4,9 @@ * * $RCSfile: AppDetailPageHelper.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.10.12.1 $ * - * last change: $Author: ihi $ $Date: 2006/08/28 15:05:51 $ + * last change: $Author: fs $ $Date: 2006/09/14 11:57:13 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -174,14 +174,16 @@ /** sets all HandleCallbacks @param _pTreeView The newly created DBTreeListBox - @param _nCollapsedBitmap - The collapsed bitmap resource id - @param _nCollapsedBitmap_HI - The collapsed bitmap resource id for high contrast. + @param _nDefaultIconID + the resource id of the default icon + @param _nDefaultIconID_HC + the resource id of the default icon (HC version) @return The new tree. */ - DBTreeListBox* createTree(DBTreeListBox* _pTreeView,USHORT _nCollapsedBitmap,USHORT _nCollapsedBitmap_HI); + DBTreeListBox* createTree( DBTreeListBox* _pTreeView, USHORT _nDefaultIconID, USHORT _nDefaultIconID_HC ); + + DBTreeListBox* createTree( DBTreeListBox* _pTreeView, const Image& _rDefaultIcon, const Image& _rDefaultIcon_HC ); /** creates the tree and sets all HandleCallbacks @param _nHelpId @@ -263,23 +265,17 @@ /** returns the element names which are selected @param _rNames The list will be filled. - @param _xMetaData - Will be used when the table list should be filled. */ - void getSelectionElementNames(::std::vector< ::rtl::OUString>& _rNames - ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData = NULL) const; + void getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const; /** return the qualified name. @param _pEntry The entry of a table, or query, form, report to get the qualified name. If the entry is <NULL/>, the first selected is chosen. - @param _xMetaData - The meta data are used to create the table name, otherwise this may also be <NULL/> @return the qualified name */ - ::rtl::OUString getQualifiedName(SvLBoxEntry* _pEntry - ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData) const; + ::rtl::OUString getQualifiedName( SvLBoxEntry* _pEntry ) const; /// return the element of currently select entry ElementType getElementType() const; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
