diff options
Diffstat (limited to 'dbaccess/source/ui/app/AppDetailPageHelper.cxx')
-rw-r--r-- | dbaccess/source/ui/app/AppDetailPageHelper.cxx | 199 |
1 files changed, 41 insertions, 158 deletions
diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.cxx b/dbaccess/source/ui/app/AppDetailPageHelper.cxx index 00abdacd576c..a71ae69477d4 100644 --- a/dbaccess/source/ui/app/AppDetailPageHelper.cxx +++ b/dbaccess/source/ui/app/AppDetailPageHelper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -27,137 +28,51 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbui.hxx" -#ifndef DBAUI_APPDETAILPAGEHELPER_HXX #include "AppDetailPageHelper.hxx" -#endif -#ifndef _DBAUI_MODULE_DBU_HXX_ #include "moduledbu.hxx" -#endif -#ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> -#endif -#ifndef TOOLS_DIAGNOSE_EX_H #include <tools/diagnose_ex.h> -#endif -#ifndef _CONNECTIVITY_DBTOOLS_HXX_ #include <connectivity/dbtools.hxx> -#endif -#ifndef _DBAUI_TABLETREE_HXX_ #include "tabletree.hxx" -#endif -#ifndef DBAUI_TOOLS_HXX #include "UITools.hxx" -#endif -#ifndef DBAUI_DBTREELISTBOX_HXX #include "dbtreelistbox.hxx" -#endif -#ifndef _COM_SUN_STAR_FRAME_XLAYOUTMANAGER_HPP_ #include <com/sun/star/frame/XLayoutManager.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ #include <com/sun/star/beans/XPropertySet.hpp> -#endif -#ifndef _COM_SUN_STAR_AWT_XTABCONTROLLER_HPP_ #include <com/sun/star/awt/XTabController.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ #include <com/sun/star/sdbc/XConnection.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XTablesSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XViewsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_ #include <com/sun/star/frame/XFrame.hpp> -#endif -#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_ #include <com/sun/star/frame/FrameSearchFlag.hpp> -#endif -#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_ #include <com/sun/star/frame/XComponentLoader.hpp> -#endif -#ifndef _COM_SUN_STAR_FRAME_XFRAMES_HPP_ #include <com/sun/star/frame/XFrames.hpp> -#endif -#ifndef _COM_SUN_STAR_FRAME_XFRAMESSUPPLIER_HPP_ #include <com/sun/star/frame/XFramesSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_ #include <com/sun/star/awt/XWindow.hpp> -#endif -#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include <toolkit/helper/vclunohelper.hxx> -#endif -#ifndef _COM_SUN_STAR_UCB_XCOMMANDENVIRONMENT_HPP_ #include <com/sun/star/ucb/XCommandEnvironment.hpp> -#endif -#ifndef _COM_SUN_STAR_UCB_XCOMMANDPROCESSOR_HPP_ #include <com/sun/star/ucb/XCommandProcessor.hpp> -#endif -#ifndef _COM_SUN_STAR_UCB_COMMAND_HPP_ #include <com/sun/star/ucb/Command.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_ #include <com/sun/star/form/XLoadable.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ #include <com/sun/star/container/XChild.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_ #include <com/sun/star/container/XContainer.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ #include <com/sun/star/sdb/CommandType.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_XCLOSEABLE_HPP_ #include <com/sun/star/util/XCloseable.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_APPLICATION_XDATABASEDOCUMENTUI_HPP_ #include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp> -#endif #include <com/sun/star/sdb/application/DatabaseObject.hpp> #include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp> -#ifndef DBAUI_APPVIEW_HXX #include "AppView.hxx" -#endif -#ifndef _DBA_DBACCESS_HELPID_HRC_ #include "dbaccess_helpid.hrc" -#endif -#ifndef _DBU_APP_HRC_ #include "dbu_app.hrc" -#endif -#ifndef _DBACCESS_UI_CALLBACKS_HXX_ #include "callbacks.hxx" -#endif -#ifndef DBAUI_ICONTROLLER_HXX #include "IController.hxx" -#endif -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" -#endif -#ifndef _DBACCESS_SLOTID_HRC_ #include "dbaccess_slotid.hrc" -#endif -#ifndef DBACCESS_DATABASE_OBJECT_VIEW_HXX #include "databaseobjectview.hxx" -#endif -#ifndef DBACCESS_IMAGEPROVIDER_HXX #include "imageprovider.hxx" -#endif -#ifndef _SV_WAITOBJ_HXX #include <vcl/waitobj.hxx> -#endif -#ifndef _STREAM_HXX #include <tools/stream.hxx> -#endif -#ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> -#endif -#ifndef _RTL_USTRBUF_HXX_ #include <rtl/ustrbuf.hxx> -#endif #include "IApplicationController.hxx" #include <com/sun/star/document/XDocumentProperties.hpp> @@ -278,7 +193,7 @@ namespace { SetTextColor( rStyleSettings.GetFieldTextColor() ); SetTextFillColor(); - } // if( bForeground || bFont ) + } if( bBackground ) SetBackground( rStyleSettings.GetFieldColor() ); @@ -337,9 +252,9 @@ OAppDetailPageHelper::~OAppDetailPageHelper() if ( xCloseable.is() ) xCloseable->close(sal_True); } - catch(Exception) + catch(const Exception&) { - OSL_ENSURE(0,"Exception thrown while disposing preview frame!"); + OSL_FAIL("Exception thrown while disposing preview frame!"); } for (int i=0; i < E_ELEMENT_TYPE_COUNT; ++i) @@ -459,7 +374,7 @@ void OAppDetailPageHelper::describeCurrentSelectionForControl( const Control& _r return; } } - OSL_ENSURE( false, "OAppDetailPageHelper::describeCurrentSelectionForControl: invalid control!" ); + OSL_FAIL( "OAppDetailPageHelper::describeCurrentSelectionForControl: invalid control!" ); } // ----------------------------------------------------------------------------- @@ -515,7 +430,7 @@ void OAppDetailPageHelper::describeCurrentSelectionForType( const ElementType _e } break; default: - OSL_ENSURE( false, "OAppDetailPageHelper::describeCurrentSelectionForType: unexpected type!" ); + OSL_FAIL( "OAppDetailPageHelper::describeCurrentSelectionForType: unexpected type!" ); break; } @@ -628,13 +543,11 @@ sal_Bool OAppDetailPageHelper::isCutAllowed() // ----------------------------------------------------------------------------- sal_Bool OAppDetailPageHelper::isCopyAllowed() { - //int nPos = getVisibleControlIndex(); return sal_True; } // ----------------------------------------------------------------------------- sal_Bool OAppDetailPageHelper::isPasteAllowed() { - //int nPos = getVisibleControlIndex(); return sal_True; } // ----------------------------------------------------------------------------- @@ -708,8 +621,7 @@ void OAppDetailPageHelper::createTablesPage(const Reference< XConnection>& _xCon ImageProvider aImageProvider( _xConnection ); createTree( pTreeView, - aImageProvider.getDefaultImage( DatabaseObject::TABLE, false ), - aImageProvider.getDefaultImage( DatabaseObject::TABLE, true ) + aImageProvider.getDefaultImage( DatabaseObject::TABLE ) ); pTreeView->notifyHiContrastChanged(); @@ -729,10 +641,10 @@ void OAppDetailPageHelper::createTablesPage(const Reference< XConnection>& _xCon } // ----------------------------------------------------------------------------- -void OAppDetailPageHelper::getElementIcons( ElementType _eType, sal_uInt16& _rImageId, sal_uInt16& _rHighContrastImageId ) +void OAppDetailPageHelper::getElementIcons( ElementType _eType, sal_uInt16& _rImageId) { ImageProvider aImageProvider; - _rImageId = _rHighContrastImageId = 0; + _rImageId = 0; sal_Int32 nDatabaseObjectType( 0 ); switch(_eType ) @@ -741,11 +653,10 @@ void OAppDetailPageHelper::getElementIcons( ElementType _eType, sal_uInt16& _rIm case E_REPORT: nDatabaseObjectType = DatabaseObject::REPORT; break; case E_QUERY: nDatabaseObjectType = DatabaseObject::QUERY; break; default: - OSL_ENSURE( sal_False, "OAppDetailPageHelper::GetElementIcons: invalid element type!" ); + OSL_FAIL( "OAppDetailPageHelper::GetElementIcons: invalid element type!" ); return; } - _rImageId = aImageProvider.getDefaultImageResourceID( nDatabaseObjectType, false ); - _rHighContrastImageId = aImageProvider.getDefaultImageResourceID( nDatabaseObjectType, true ); + _rImageId = aImageProvider.getDefaultImageResourceID( nDatabaseObjectType ); } // ----------------------------------------------------------------------------- @@ -753,42 +664,39 @@ void OAppDetailPageHelper::createPage(ElementType _eType,const Reference< XNameA { OSL_ENSURE(E_TABLE != _eType,"E_TABLE isn't allowed."); - sal_uInt16 nImageId = 0, nImageIdH = 0; + sal_uInt16 nImageId = 0; rtl::OString sHelpId; ImageProvider aImageProvider; - Image aFolderImage, aFolderImageHC; + Image aFolderImage; switch( _eType ) { case E_FORM: sHelpId = HID_APP_FORM_TREE; - aFolderImage = aImageProvider.getFolderImage( DatabaseObject::FORM, false ); - aFolderImageHC = aImageProvider.getFolderImage( DatabaseObject::FORM, true ); + aFolderImage = aImageProvider.getFolderImage( DatabaseObject::FORM ); break; case E_REPORT: sHelpId = HID_APP_REPORT_TREE; - aFolderImage = aImageProvider.getFolderImage( DatabaseObject::REPORT, false ); - aFolderImageHC = aImageProvider.getFolderImage( DatabaseObject::REPORT, true ); + aFolderImage = aImageProvider.getFolderImage( DatabaseObject::REPORT ); break; case E_QUERY: sHelpId = HID_APP_QUERY_TREE; - aFolderImage = aImageProvider.getFolderImage( DatabaseObject::QUERY, false ); - aFolderImageHC = aImageProvider.getFolderImage( DatabaseObject::QUERY, true ); + aFolderImage = aImageProvider.getFolderImage( DatabaseObject::QUERY ); break; default: - OSL_ENSURE(0,"Illegal call!"); + OSL_FAIL("Illegal call!"); } - getElementIcons( _eType, nImageId, nImageIdH ); + getElementIcons( _eType, nImageId ); if ( !m_pLists[_eType] ) { - m_pLists[_eType] = createSimpleTree( sHelpId, aFolderImage, aFolderImageHC ); + m_pLists[_eType] = createSimpleTree( sHelpId, aFolderImage ); } if ( m_pLists[_eType] ) { if ( !m_pLists[_eType]->GetEntryCount() && _xContainer.is() ) { - fillNames( _xContainer, _eType, nImageId, nImageIdH, NULL ); + fillNames( _xContainer, _eType, nImageId, NULL ); m_pLists[_eType]->SelectAll(sal_False); } @@ -836,7 +744,7 @@ namespace // ----------------------------------------------------------------------------- void OAppDetailPageHelper::fillNames( const Reference< XNameAccess >& _xContainer, const ElementType _eType, - const sal_uInt16 _nImageId, const sal_uInt16 _nHighContrastImageId, SvLBoxEntry* _pParent ) + const sal_uInt16 _nImageId, SvLBoxEntry* _pParent ) { OSL_ENSURE(_xContainer.is(),"Data source is NULL! -> GPF"); OSL_ENSURE( ( _eType >= E_TABLE ) && ( _eType < E_ELEMENT_TYPE_COUNT ), "OAppDetailPageHelper::fillNames: invalid type!" ); @@ -861,33 +769,29 @@ void OAppDetailPageHelper::fillNames( const Reference< XNameAccess >& _xContaine { pEntry = pList->InsertEntry( *pIter, _pParent, sal_False, LIST_APPEND, reinterpret_cast< void* >( nFolderIndicator ) ); getBorderWin().getView()->getAppController().containerFound( Reference< XContainer >( xSubElements, UNO_QUERY ) ); - fillNames( xSubElements, _eType, _nImageId, _nHighContrastImageId, pEntry ); + fillNames( xSubElements, _eType, _nImageId, pEntry ); } else { pEntry = pList->InsertEntry( *pIter, _pParent ); Image aImage = Image( ModuleRes( _nImageId ) ); - pList->SetExpandedEntryBmp( pEntry, aImage, BMP_COLOR_NORMAL ); - pList->SetCollapsedEntryBmp( pEntry, aImage, BMP_COLOR_NORMAL ); - - Image aHCImage = Image( ModuleRes( _nHighContrastImageId ) ); - pList->SetExpandedEntryBmp( pEntry, aHCImage, BMP_COLOR_HIGHCONTRAST ); - pList->SetCollapsedEntryBmp( pEntry, aHCImage, BMP_COLOR_HIGHCONTRAST ); + pList->SetExpandedEntryBmp( pEntry, aImage ); + pList->SetCollapsedEntryBmp( pEntry, aImage ); } } } } // ----------------------------------------------------------------------------- -DBTreeListBox* OAppDetailPageHelper::createSimpleTree( const rtl::OString& _sHelpId, const Image& _rImage, const Image& _rImageHC ) +DBTreeListBox* OAppDetailPageHelper::createSimpleTree( const rtl::OString& _sHelpId, const Image& _rImage) { DBTreeListBox* pTreeView = new DBTreeListBox(this,getBorderWin().getView()->getORB(),WB_HASLINES | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT | WB_TABSTOP); pTreeView->SetHelpId( _sHelpId ); - return createTree( pTreeView, _rImage, _rImageHC ); + return createTree( pTreeView, _rImage ); } // ----------------------------------------------------------------------------- -DBTreeListBox* OAppDetailPageHelper::createTree( DBTreeListBox* _pTreeView, const Image& _rImage, const Image& _rImageHC ) +DBTreeListBox* OAppDetailPageHelper::createTree( DBTreeListBox* _pTreeView, const Image& _rImage ) { WaitObject aWaitCursor(this); @@ -897,9 +801,7 @@ DBTreeListBox* OAppDetailPageHelper::createTree( DBTreeListBox* _pTreeView, cons _pTreeView->SetSelectionMode(MULTIPLE_SELECTION); _pTreeView->SetDefaultCollapsedEntryBmp( _rImage ); - _pTreeView->SetDefaultCollapsedEntryBmp( _rImageHC, BMP_COLOR_HIGHCONTRAST ); _pTreeView->SetDefaultExpandedEntryBmp( _rImage ); - _pTreeView->SetDefaultExpandedEntryBmp( _rImageHC, BMP_COLOR_HIGHCONTRAST ); _pTreeView->SetDoubleClickHdl(LINK(this, OAppDetailPageHelper, OnEntryDoubleClick)); _pTreeView->SetEnterKeyHdl(LINK(this, OAppDetailPageHelper, OnEntryDoubleClick)); @@ -958,7 +860,7 @@ void OAppDetailPageHelper::elementReplaced(ElementType _eType pEntry = lcl_findEntry(*pTreeView,_rOldName,pTreeView->First()); break; default: - OSL_ENSURE(0,"Invalid element type"); + OSL_FAIL("Invalid element type"); } OSL_ENSURE(pEntry,"Do you know that the name isn't existence!"); if ( pEntry ) @@ -991,26 +893,22 @@ SvLBoxEntry* OAppDetailPageHelper::elementAdded(ElementType _eType,const ::rtl:: } } - sal_uInt16 nImageId = 0, nImageIdH = 0; - getElementIcons( _eType, nImageId, nImageIdH ); + sal_uInt16 nImageId = 0; + getElementIcons( _eType, nImageId ); Reference<XNameAccess> xContainer(_rObject,UNO_QUERY); if ( xContainer.is() ) { const sal_Int32 nFolderIndicator = lcl_getFolderIndicatorForType( _eType ); pRet = pTreeView->InsertEntry( _rName, pEntry, sal_False, LIST_APPEND, reinterpret_cast< void* >( nFolderIndicator ) ); - fillNames( xContainer, _eType, nImageId, nImageIdH, pRet ); + fillNames( xContainer, _eType, nImageId, pRet ); } else { pRet = pTreeView->InsertEntry( _rName, pEntry ); Image aImage = Image( ModuleRes( nImageId ) ); - pTreeView->SetExpandedEntryBmp( pRet, aImage, BMP_COLOR_NORMAL ); - pTreeView->SetCollapsedEntryBmp( pRet, aImage, BMP_COLOR_NORMAL ); - - Image aHCImage = Image( ModuleRes( nImageIdH ) ); - pTreeView->SetExpandedEntryBmp( pRet, aHCImage, BMP_COLOR_HIGHCONTRAST ); - pTreeView->SetCollapsedEntryBmp( pRet, aHCImage, BMP_COLOR_HIGHCONTRAST ); + pTreeView->SetExpandedEntryBmp( pRet, aImage ); + pTreeView->SetCollapsedEntryBmp( pRet, aImage ); } } return pRet; @@ -1047,7 +945,7 @@ void OAppDetailPageHelper::elementRemoved( ElementType _eType,const ::rtl::OUStr } break; default: - OSL_ENSURE(0,"Invalid element type"); + OSL_FAIL("Invalid element type"); } if ( !pTreeView->GetEntryCount() ) showPreview(NULL); @@ -1093,8 +991,7 @@ IMPL_LINK( OAppDetailPageHelper, OnDeleteEntry, void*, /*NOINTERESTEDIN*/ ) // ----------------------------------------------------------------------------- void OAppDetailPageHelper::Resize() { - ////////////////////////////////////////////////////////////////////// - // Abmessungen parent window + // parent window dimension Size aOutputSize( GetOutputSize() ); long nOutputWidth = aOutputSize.Width(); long nOutputHeight = aOutputSize.Height(); @@ -1231,12 +1128,6 @@ void OAppDetailPageHelper::showPreview(const Reference< XContent >& _xContent) { m_aPreview.Hide(); m_aDocumentInfo.Hide(); - - // Why the below code? It might have side effects, as the tree view needs to know - // its current selection for other purposes than the preview, too. -// DBTreeListBox* pTreeView = getCurrentView(); -// if ( pTreeView ) -// pTreeView->clearCurrentSelection(); } } catch( const Exception& ) @@ -1263,9 +1154,9 @@ void OAppDetailPageHelper::showPreview( const ::rtl::OUString& _sDataSourceName, m_xFrame = Reference < XFrame > ( getBorderWin().getView()->getORB()->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Frame")) ), UNO_QUERY ); m_xFrame->initialize( m_xWindow ); - // work-around for #150518#: no layout manager (and thus no toolbars) in the preview + // no layout manager (and thus no toolbars) in the preview // Must be called after initialize ... but before any other call to this frame. - // Otherwhise frame throws "life time exceptions" as e.g. NON_INITIALIZED + // Otherwise frame throws "life time exceptions" as e.g. NON_INITIALIZED Reference< XPropertySet > xFrameProps( m_xFrame, UNO_QUERY_THROW ); xFrameProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ), makeAny(Reference< XLayoutManager >()) ); @@ -1276,7 +1167,7 @@ void OAppDetailPageHelper::showPreview( const ::rtl::OUString& _sDataSourceName, xFrames->append(m_xFrame); } } - catch(Exception) + catch(const Exception&) { } } @@ -1334,7 +1225,7 @@ IMPL_LINK(OAppDetailPageHelper, OnDropdownClickHdl, ToolBox*, /*pToolBox*/) , SID_DB_APP_VIEW_DOCINFO_PREVIEW }; - for(size_t i=0; i < sizeof(pActions)/sizeof(pActions[0]);++i) + for(size_t i=0; i < SAL_N_ELEMENTS(pActions);++i) { aMenu->CheckItem(pActions[i],m_aMenu->IsItemChecked(pActions[i])); } @@ -1400,34 +1291,25 @@ void OAppDetailPageHelper::DataChanged( const DataChangedEvent& rDCEvt ) void OAppDetailPageHelper::ImplInitSettings() { const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - if( true ) - { Font aFont; aFont = rStyleSettings.GetFieldFont(); aFont.SetColor( rStyleSettings.GetWindowTextColor() ); SetPointFont( aFont ); m_aTBPreview.SetPointFont( aFont ); - } - if( true ) - { SetTextColor( rStyleSettings.GetFieldTextColor() ); SetTextFillColor(); m_aBorder.SetTextColor( rStyleSettings.GetFieldTextColor() ); m_aBorder.SetTextFillColor(); m_aTBPreview.SetTextColor( rStyleSettings.GetFieldTextColor() ); m_aTBPreview.SetTextFillColor(); - } // if( true ) - if( true ) - { SetBackground( rStyleSettings.GetFieldColor() ); m_aBorder.SetBackground( rStyleSettings.GetFieldColor() ); m_aFL.SetBackground( rStyleSettings.GetFieldColor() ); m_aDocumentInfo.SetBackground( rStyleSettings.GetFieldColor() ); m_aTBPreview.SetBackground( rStyleSettings.GetFieldColor() ); m_pTablePreview->SetBackground( rStyleSettings.GetFieldColor() ); - } // if( true ) } // ----------------------------------------------------------------------------- OPreviewWindow::OPreviewWindow(Window* _pParent) @@ -1514,7 +1396,7 @@ void OPreviewWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal { SetTextColor( rStyleSettings.GetFieldTextColor() ); SetTextFillColor(); - } // if( bForeground || bFont ) + } if( bBackground ) SetBackground( rStyleSettings.GetFieldColor() ); @@ -1522,3 +1404,4 @@ void OPreviewWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |