LCOV - code coverage report
Current view: top level - dbaccess/source/ui/app - AppDetailView.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 216 460 47.0 %
Date: 2014-11-03 Functions: 30 76 39.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include "AppDetailView.hxx"
      21             : #include <osl/diagnose.h>
      22             : #include "dbaccess_helpid.hrc"
      23             : #include "dbu_app.hrc"
      24             : #include "AppView.hxx"
      25             : #include <com/sun/star/ui/XUIConfigurationManager.hpp>
      26             : #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
      27             : #include <com/sun/star/ui/XImageManager.hpp>
      28             : #include <com/sun/star/ui/ImageType.hpp>
      29             : #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
      30             : #include <com/sun/star/graphic/XGraphic.hpp>
      31             : #include <com/sun/star/util/URL.hpp>
      32             : #include "listviewitems.hxx"
      33             : #include <vcl/image.hxx>
      34             : #include <vcl/mnemonic.hxx>
      35             : #include <vcl/settings.hxx>
      36             : #include "browserids.hxx"
      37             : #include "AppDetailPageHelper.hxx"
      38             : #include <vcl/svapp.hxx>
      39             : #include "callbacks.hxx"
      40             : #include <dbaccess/IController.hxx>
      41             : #include "moduledbu.hxx"
      42             : #include <svtools/localresaccess.hxx>
      43             : #include "svtools/treelistentry.hxx"
      44             : #include "svtools/viewdataentry.hxx"
      45             : #include <algorithm>
      46             : #include "dbtreelistbox.hxx"
      47             : #include "IApplicationController.hxx"
      48             : #include "imageprovider.hxx"
      49             : #include "comphelper/processfactory.hxx"
      50             : 
      51             : using namespace ::dbaui;
      52             : using namespace ::com::sun::star::uno;
      53             : using namespace ::com::sun::star::sdbc;
      54             : using namespace ::com::sun::star::sdbcx;
      55             : using namespace ::com::sun::star::lang;
      56             : using namespace ::com::sun::star::ucb;
      57             : using namespace ::com::sun::star::graphic;
      58             : using namespace ::com::sun::star::ui;
      59             : using namespace ::com::sun::star::container;
      60             : using namespace ::com::sun::star::beans;
      61             : using ::com::sun::star::util::URL;
      62             : using ::com::sun::star::sdb::application::NamedDatabaseObject;
      63             : 
      64             : #define SPACEBETWEENENTRIES     4
      65             : 
      66          12 : TaskEntry::TaskEntry( const sal_Char* _pAsciiUNOCommand, sal_uInt16 _nHelpID, sal_uInt16 _nTitleResourceID, bool _bHideWhenDisabled )
      67             :     :sUNOCommand( OUString::createFromAscii( _pAsciiUNOCommand ) )
      68             :     ,nHelpID( _nHelpID )
      69             :     ,sTitle( ModuleRes( _nTitleResourceID ) )
      70          12 :     ,bHideWhenDisabled( _bHideWhenDisabled )
      71             : {
      72          12 : }
      73             : 
      74          16 : OCreationList::OCreationList( OTasksWindow& _rParent )
      75             :     :SvTreeListBox( &_rParent, WB_TABSTOP | WB_HASBUTTONSATROOT | WB_HASBUTTONS )
      76             :     ,m_rTaskWindow( _rParent )
      77             :     ,m_pMouseDownEntry( NULL )
      78          16 :     ,m_pLastActiveEntry( NULL )
      79             : {
      80          16 :     sal_uInt16 nSize = SPACEBETWEENENTRIES;
      81          16 :     SetSpaceBetweenEntries(nSize);
      82          16 :     SetSelectionMode( NO_SELECTION );
      83          16 :     SetExtendedWinBits( EWB_NO_AUTO_CURENTRY );
      84          16 :     SetNodeDefaultImages( );
      85          16 :     EnableEntryMnemonics();
      86          16 : }
      87             : 
      88          12 : void OCreationList::Paint( const Rectangle& _rRect )
      89             : {
      90          12 :     if ( m_pMouseDownEntry )
      91           0 :         m_aOriginalFont = GetFont();
      92             : 
      93          12 :     m_aOriginalBackgroundColor = GetBackground().GetColor();
      94          12 :     SvTreeListBox::Paint( _rRect );
      95          12 :     SetBackground( m_aOriginalBackgroundColor );
      96             : 
      97          12 :     if ( m_pMouseDownEntry )
      98           0 :         Control::SetFont( m_aOriginalFont );
      99          12 : }
     100             : 
     101           0 : void OCreationList::PreparePaint( SvTreeListEntry* _pEntry )
     102             : {
     103           0 :     Wallpaper aEntryBackground( m_aOriginalBackgroundColor );
     104           0 :     if ( _pEntry )
     105             :     {
     106           0 :         if ( _pEntry == GetCurEntry() )
     107             :         {
     108             :             // draw a selection background
     109           0 :             bool bIsMouseDownEntry = ( _pEntry == m_pMouseDownEntry );
     110           0 :             DrawSelectionBackground( GetBoundingRect( _pEntry ), bIsMouseDownEntry ? 1 : 2, false, true, false );
     111             : 
     112           0 :             if ( bIsMouseDownEntry )
     113             :             {
     114           0 :                 vcl::Font aFont( GetFont() );
     115           0 :                 aFont.SetColor( GetSettings().GetStyleSettings().GetHighlightTextColor() );
     116           0 :                 Control::SetFont( aFont );
     117             :             }
     118             : 
     119             :             // and temporary set a transparent background, for all the other
     120             :             // paint operations the SvTreeListBox is going to do
     121           0 :             aEntryBackground = Wallpaper( Color( COL_TRANSPARENT ) );
     122             :         }
     123             :     }
     124             : 
     125           0 :     SetBackground( aEntryBackground );
     126           0 : }
     127             : 
     128           0 : void OCreationList::SelectSearchEntry( const void* _pEntry )
     129             : {
     130           0 :     SvTreeListEntry* pEntry = const_cast< SvTreeListEntry* >( static_cast< const SvTreeListEntry* >( _pEntry ) );
     131             :     OSL_ENSURE( pEntry, "OCreationList::SelectSearchEntry: invalid entry!" );
     132             : 
     133           0 :     if ( pEntry )
     134           0 :         setCurrentEntryInvalidate( pEntry );
     135             : 
     136           0 :     if ( !HasChildPathFocus() )
     137           0 :         GrabFocus();
     138           0 : }
     139             : 
     140           0 : void OCreationList::ExecuteSearchEntry( const void* _pEntry ) const
     141             : {
     142           0 :     SvTreeListEntry* pEntry = const_cast< SvTreeListEntry* >( static_cast< const SvTreeListEntry* >( _pEntry ) );
     143             :     OSL_ENSURE( pEntry, "OCreationList::ExecuteSearchEntry: invalid entry!" );
     144             :     OSL_ENSURE( pEntry == GetCurEntry(), "OCreationList::ExecuteSearchEntry: SelectSearchEntry should have been called before!" );
     145             : 
     146           0 :     if ( pEntry )
     147           0 :         onSelected( pEntry );
     148           0 : }
     149             : 
     150           0 : Rectangle OCreationList::GetFocusRect( SvTreeListEntry* _pEntry, long _nLine )
     151             : {
     152           0 :     Rectangle aRect = SvTreeListBox::GetFocusRect( _pEntry, _nLine );
     153           0 :     aRect.Left() = 0;
     154             : 
     155             :     // try to let the focus rect start before the bitmap item - this looks better
     156           0 :     SvLBoxItem* pBitmapItem = _pEntry->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP );
     157           0 :     SvLBoxTab* pTab = pBitmapItem ? GetTab( _pEntry, pBitmapItem ) : NULL;
     158           0 :     SvViewDataItem* pItemData = pBitmapItem ? GetViewDataItem( _pEntry, pBitmapItem ) : NULL;
     159             :     OSL_ENSURE( pTab && pItemData, "OCreationList::GetFocusRect: could not find the first bitmap item!" );
     160           0 :     if ( pTab && pItemData )
     161           0 :         aRect.Left() = pTab->GetPos() - pItemData->maSize.Width() / 2;
     162             : 
     163             :     // inflate the rectangle a little bit - looks better, too
     164           0 :     aRect.Left() = ::std::max< long >( 0, aRect.Left() - 2 );
     165           0 :     aRect.Right() = ::std::min< long >( GetOutputSizePixel().Width() - 1, aRect.Right() + 2 );
     166             : 
     167           0 :     return aRect;
     168             : }
     169             : 
     170           0 : void OCreationList::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ )
     171             : {
     172             :     // don't give this to the base class, it does a ReleaseMouse as very first action
     173             :     // Though I think this is a bug (it should ReleaseMouse only if it is going to do
     174             :     // something with the drag-event), I hesitate to fix it in the current state,
     175             :     // since I don't overlook the consequences, and we're close to 2.0 ...)
     176           0 : }
     177             : 
     178          18 : void OCreationList::ModelHasCleared()
     179             : {
     180          18 :     SvTreeListBox::ModelHasCleared();
     181          18 :     m_pLastActiveEntry = NULL;
     182          18 :     m_pMouseDownEntry = NULL;
     183          18 : }
     184             : 
     185           0 : void OCreationList::GetFocus()
     186             : {
     187           0 :     SvTreeListBox::GetFocus();
     188           0 :     if ( !GetCurEntry() )
     189           0 :         setCurrentEntryInvalidate( m_pLastActiveEntry ? m_pLastActiveEntry : GetFirstEntryInView() );
     190           0 : }
     191             : 
     192           0 : void OCreationList::LoseFocus()
     193             : {
     194           0 :     SvTreeListBox::LoseFocus();
     195           0 :     m_pLastActiveEntry = GetCurEntry();
     196           0 :     setCurrentEntryInvalidate( NULL );
     197           0 : }
     198             : 
     199           0 : void OCreationList::MouseButtonDown( const MouseEvent& rMEvt )
     200             : {
     201           0 :     SvTreeListBox::MouseButtonDown( rMEvt );
     202             : 
     203             :     OSL_ENSURE( !m_pMouseDownEntry, "OCreationList::MouseButtonDown: I missed some mouse event!" );
     204           0 :     m_pMouseDownEntry = GetCurEntry();
     205           0 :     if ( m_pMouseDownEntry )
     206             :     {
     207           0 :         InvalidateEntry( m_pMouseDownEntry );
     208           0 :         CaptureMouse();
     209             :     }
     210           0 : }
     211             : 
     212           0 : void OCreationList::MouseMove( const MouseEvent& rMEvt )
     213             : {
     214           0 :     if ( rMEvt.IsLeaveWindow() )
     215             :     {
     216           0 :         setCurrentEntryInvalidate( NULL );
     217             :     }
     218           0 :     else if ( !rMEvt.IsSynthetic() )
     219             :     {
     220           0 :         SvTreeListEntry* pEntry = GetEntry( rMEvt.GetPosPixel() );
     221             : 
     222           0 :         if ( m_pMouseDownEntry )
     223             :         {
     224             :             // we're currently in a "mouse down" phase
     225             :             OSL_ENSURE( IsMouseCaptured(), "OCreationList::MouseMove: inconsistence (1)!" );
     226           0 :             if ( pEntry == m_pMouseDownEntry )
     227             :             {
     228           0 :                 setCurrentEntryInvalidate( m_pMouseDownEntry );
     229             :             }
     230             :             else
     231             :             {
     232             :                 OSL_ENSURE( ( GetCurEntry() == m_pMouseDownEntry ) || !GetCurEntry(),
     233             :                     "OCreationList::MouseMove: inconsistence (2)!" );
     234           0 :                 setCurrentEntryInvalidate( NULL );
     235             :             }
     236             :         }
     237             :         else
     238             :         {
     239             :             // the user is simply hovering with the mouse
     240           0 :             if ( setCurrentEntryInvalidate( pEntry ) )
     241             :             {
     242           0 :                 if ( !m_pMouseDownEntry )
     243           0 :                     updateHelpText();
     244             :             }
     245             :         }
     246             :     }
     247             : 
     248           0 :     SvTreeListBox::MouseMove(rMEvt);
     249           0 : }
     250             : 
     251           0 : void OCreationList::MouseButtonUp( const MouseEvent& rMEvt )
     252             : {
     253           0 :     SvTreeListEntry* pEntry = GetEntry( rMEvt.GetPosPixel() );
     254           0 :     bool bExecute = false;
     255             :     // Was the mouse released over the active entry?
     256             :     // (i.e. the entry which was under the mouse when the button went down)
     257           0 :     if ( pEntry && ( m_pMouseDownEntry == pEntry ) )
     258             :     {
     259           0 :         if ( !rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() && rMEvt.IsLeft() && rMEvt.GetClicks() == 1 )
     260           0 :             bExecute = true;
     261             :     }
     262             : 
     263           0 :     if ( m_pMouseDownEntry )
     264             :     {
     265             :         OSL_ENSURE( IsMouseCaptured(), "OCreationList::MouseButtonUp: hmmm .... no mouse captured, but an active entry?" );
     266           0 :         ReleaseMouse();
     267             : 
     268           0 :         InvalidateEntry( m_pMouseDownEntry );
     269           0 :         m_pMouseDownEntry = NULL;
     270             :     }
     271             : 
     272           0 :     SvTreeListBox::MouseButtonUp( rMEvt );
     273             : 
     274           0 :     if ( bExecute )
     275           0 :         onSelected( pEntry );
     276           0 : }
     277             : 
     278           0 : bool OCreationList::setCurrentEntryInvalidate( SvTreeListEntry* _pEntry )
     279             : {
     280           0 :     if ( GetCurEntry() != _pEntry )
     281             :     {
     282           0 :         if ( GetCurEntry() )
     283           0 :             InvalidateEntry( GetCurEntry() );
     284           0 :         SetCurEntry( _pEntry );
     285           0 :         if ( GetCurEntry() )
     286             :         {
     287           0 :             InvalidateEntry( GetCurEntry() );
     288           0 :             CallEventListeners( VCLEVENT_LISTBOX_SELECT, GetCurEntry() );
     289             :         }
     290           0 :         updateHelpText();
     291           0 :         return true;
     292             :     }
     293           0 :     return false;
     294             : }
     295             : 
     296           6 : void OCreationList::updateHelpText()
     297             : {
     298           6 :     sal_uInt16 nHelpTextId = 0;
     299           6 :     if ( GetCurEntry() )
     300           0 :         nHelpTextId = reinterpret_cast< TaskEntry* >( GetCurEntry()->GetUserData() )->nHelpID;
     301           6 :     m_rTaskWindow.setHelpText( nHelpTextId );
     302           6 : }
     303             : 
     304           0 : void OCreationList::onSelected( SvTreeListEntry* _pEntry ) const
     305             : {
     306             :     OSL_ENSURE( _pEntry, "OCreationList::onSelected: invalid entry!" );
     307           0 :     URL aCommand;
     308           0 :     aCommand.Complete = reinterpret_cast< TaskEntry* >( _pEntry->GetUserData() )->sUNOCommand;
     309           0 :     m_rTaskWindow.getDetailView()->getBorderWin().getView()->getAppController().executeChecked( aCommand, Sequence< PropertyValue >() );
     310           0 : }
     311             : 
     312           0 : void OCreationList::KeyInput( const KeyEvent& rKEvt )
     313             : {
     314           0 :     const vcl::KeyCode& rCode = rKEvt.GetKeyCode();
     315           0 :     if ( !rCode.IsMod1() && !rCode.IsMod2() && !rCode.IsShift() )
     316             :     {
     317           0 :         if ( rCode.GetCode() == KEY_RETURN )
     318             :         {
     319           0 :             SvTreeListEntry* pEntry = GetCurEntry() ? GetCurEntry() : FirstSelected();
     320           0 :             if ( pEntry )
     321           0 :                 onSelected( pEntry );
     322           0 :             return;
     323             :         }
     324             :     }
     325           0 :     SvTreeListEntry* pOldCurrent = GetCurEntry();
     326           0 :     SvTreeListBox::KeyInput(rKEvt);
     327           0 :     SvTreeListEntry* pNewCurrent = GetCurEntry();
     328             : 
     329           0 :     if ( pOldCurrent != pNewCurrent )
     330             :     {
     331           0 :         if ( pOldCurrent )
     332           0 :             InvalidateEntry( pOldCurrent );
     333           0 :         if ( pNewCurrent )
     334             :         {
     335           0 :             InvalidateEntry( pNewCurrent );
     336           0 :             CallEventListeners( VCLEVENT_LISTBOX_SELECT, pNewCurrent );
     337             :         }
     338           0 :         updateHelpText();
     339             :     }
     340             : }
     341             : 
     342          16 : OTasksWindow::OTasksWindow(vcl::Window* _pParent,OApplicationDetailView* _pDetailView)
     343             :     : Window(_pParent,WB_DIALOGCONTROL )
     344             :     ,m_aCreation(*this)
     345             :     ,m_aDescription(this)
     346             :     ,m_aHelpText(this,WB_WORDBREAK)
     347             :     ,m_aFL(this,WB_VERT)
     348          16 :     ,m_pDetailView(_pDetailView)
     349             : {
     350          16 :     SetUniqueId(UID_APP_TASKS_WINDOW);
     351          16 :     m_aCreation.SetHelpId(HID_APP_CREATION_LIST);
     352          16 :     m_aCreation.SetSelectHdl(LINK(this, OTasksWindow, OnEntrySelectHdl));
     353          16 :     m_aHelpText.SetHelpId(HID_APP_HELP_TEXT);
     354          16 :     m_aDescription.SetHelpId(HID_APP_DESCRIPTION_TEXT);
     355          16 :     m_aDescription.SetText(ModuleRes(STR_DESCRIPTION));
     356             : 
     357          16 :     ImageProvider aImageProvider;
     358          32 :     Image aFolderImage = aImageProvider.getFolderImage( css::sdb::application::DatabaseObject::FORM );
     359          16 :     m_aCreation.SetDefaultCollapsedEntryBmp( aFolderImage );
     360          16 :     m_aCreation.SetDefaultExpandedEntryBmp( aFolderImage );
     361             : 
     362          32 :     ImplInitSettings(true,true,true);
     363          16 : }
     364             : 
     365          36 : OTasksWindow::~OTasksWindow()
     366             : {
     367          12 :     Clear();
     368          24 : }
     369             : 
     370           0 : void OTasksWindow::DataChanged( const DataChangedEvent& rDCEvt )
     371             : {
     372           0 :     Window::DataChanged( rDCEvt );
     373             : 
     374           0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
     375           0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     376             :     {
     377           0 :         ImplInitSettings( true, true, true );
     378           0 :         Invalidate();
     379             :     }
     380           0 : }
     381             : 
     382          16 : void OTasksWindow::ImplInitSettings( bool bFont, bool bForeground, bool bBackground )
     383             : {
     384          16 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     385          16 :     if( bFont )
     386             :     {
     387          16 :         vcl::Font aFont;
     388          16 :         aFont = rStyleSettings.GetFieldFont();
     389          16 :         aFont.SetColor( rStyleSettings.GetWindowTextColor() );
     390          16 :         SetPointFont( aFont );
     391             :     }
     392             : 
     393          16 :     if( bForeground || bFont )
     394             :     {
     395          16 :         SetTextColor( rStyleSettings.GetFieldTextColor() );
     396          16 :         SetTextFillColor();
     397          16 :         m_aHelpText.SetTextColor( rStyleSettings.GetFieldTextColor() );
     398          16 :         m_aHelpText.SetTextFillColor();
     399          16 :         m_aDescription.SetTextColor( rStyleSettings.GetFieldTextColor() );
     400          16 :         m_aDescription.SetTextFillColor();
     401             :     }
     402             : 
     403          16 :     if( bBackground )
     404             :     {
     405          16 :         SetBackground( rStyleSettings.GetFieldColor() );
     406          16 :         m_aHelpText.SetBackground( rStyleSettings.GetFieldColor() );
     407          16 :         m_aDescription.SetBackground( rStyleSettings.GetFieldColor() );
     408          16 :         m_aFL.SetBackground( rStyleSettings.GetFieldColor() );
     409             :     }
     410             : 
     411          16 :     vcl::Font aFont = m_aDescription.GetControlFont();
     412          16 :     aFont.SetWeight(WEIGHT_BOLD);
     413          16 :     m_aDescription.SetControlFont(aFont);
     414          16 : }
     415             : 
     416           6 : void OTasksWindow::setHelpText(sal_uInt16 _nId)
     417             : {
     418           6 :     if ( _nId )
     419             :     {
     420           0 :         OUString sText = ModuleRes(_nId);
     421           0 :         m_aHelpText.SetText(sText);
     422             :     }
     423             :     else
     424             :     {
     425           6 :         m_aHelpText.SetText(OUString());
     426             : }
     427             : 
     428           6 : }
     429             : 
     430           0 : IMPL_LINK(OTasksWindow, OnEntrySelectHdl, SvTreeListBox*, /*_pTreeBox*/)
     431             : {
     432           0 :     SvTreeListEntry* pEntry = m_aCreation.GetHdlEntry();
     433           0 :     if ( pEntry )
     434           0 :         m_aHelpText.SetText( ModuleRes( reinterpret_cast< TaskEntry* >( pEntry->GetUserData() )->nHelpID ) );
     435           0 :     return 1L;
     436             : }
     437             : 
     438          30 : void OTasksWindow::Resize()
     439             : {
     440             :     // parent window dimension
     441          30 :     Size aOutputSize( GetOutputSize() );
     442          30 :     long nOutputWidth   = aOutputSize.Width();
     443          30 :     long nOutputHeight  = aOutputSize.Height();
     444             : 
     445          30 :     Size aFLSize = LogicToPixel( Size( 2, 6 ), MAP_APPFONT );
     446          30 :     sal_Int32 n6PPT = aFLSize.Height();
     447          30 :     long nHalfOutputWidth = static_cast<long>(nOutputWidth * 0.5);
     448             : 
     449          30 :     m_aCreation.SetPosSizePixel( Point(0, 0), Size(nHalfOutputWidth - n6PPT, nOutputHeight) );
     450             :     // i77897 make the m_aHelpText a little bit smaller. (-5)
     451          30 :     sal_Int32 nNewWidth = nOutputWidth - nHalfOutputWidth - aFLSize.Width() - 5;
     452          30 :     m_aDescription.SetPosSizePixel( Point(nHalfOutputWidth + n6PPT, 0), Size(nNewWidth, nOutputHeight) );
     453          30 :     Size aDesc = m_aDescription.CalcMinimumSize();
     454          30 :     m_aHelpText.SetPosSizePixel( Point(nHalfOutputWidth + n6PPT, aDesc.Height() ), Size(nNewWidth, nOutputHeight - aDesc.Height() - n6PPT) );
     455             : 
     456          30 :     m_aFL.SetPosSizePixel( Point(nHalfOutputWidth , 0), Size(aFLSize.Width(), nOutputHeight ) );
     457          30 : }
     458             : 
     459           6 : void OTasksWindow::fillTaskEntryList( const TaskEntryList& _rList )
     460             : {
     461           6 :     Clear();
     462             : 
     463             :     try
     464             :     {
     465             :         Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier =
     466           6 :             theModuleUIConfigurationManagerSupplier::get( getDetailView()->getBorderWin().getView()->getORB() );
     467           6 :         Reference< XUIConfigurationManager > xUIConfigMgr = xModuleCfgMgrSupplier->getUIConfigurationManager(
     468             :             OUString( "com.sun.star.sdb.OfficeDatabaseDocument" )
     469          12 :         );
     470          12 :         Reference< XImageManager > xImageMgr( xUIConfigMgr->getImageManager(), UNO_QUERY );
     471             : 
     472             :         // copy the commands so we can use them with the config managers
     473          12 :         Sequence< OUString > aCommands( _rList.size() );
     474           6 :         OUString* pCommands = aCommands.getArray();
     475           6 :         TaskEntryList::const_iterator aEnd = _rList.end();
     476          18 :         for ( TaskEntryList::const_iterator pCopyTask = _rList.begin(); pCopyTask != aEnd; ++pCopyTask, ++pCommands )
     477          12 :             *pCommands = pCopyTask->sUNOCommand;
     478             : 
     479           6 :         Sequence< Reference< XGraphic> > aImages = xImageMgr->getImages(
     480             :             ImageType::SIZE_DEFAULT | ImageType::COLOR_NORMAL ,
     481             :             aCommands
     482           6 :         );
     483             : 
     484           0 :         const Reference< XGraphic >* pImages( aImages.getConstArray() );
     485             : 
     486           0 :         for ( TaskEntryList::const_iterator pTask = _rList.begin(); pTask != aEnd; ++pTask, ++pImages )
     487             :         {
     488           0 :             SvTreeListEntry* pEntry = m_aCreation.InsertEntry( pTask->sTitle );
     489           0 :             pEntry->SetUserData( reinterpret_cast< void* >( new TaskEntry( *pTask ) ) );
     490             : 
     491           0 :             Image aImage = Image( *pImages );
     492           0 :             m_aCreation.SetExpandedEntryBmp(  pEntry, aImage );
     493           0 :             m_aCreation.SetCollapsedEntryBmp( pEntry, aImage );
     494           6 :         }
     495             :     }
     496           6 :     catch(Exception&)
     497             :     {
     498             :     }
     499             : 
     500           6 :     m_aCreation.Show();
     501           6 :     m_aCreation.SelectAll(false);
     502           6 :     m_aHelpText.Show();
     503           6 :     m_aDescription.Show();
     504           6 :     m_aFL.Show();
     505           6 :     m_aCreation.updateHelpText();
     506           6 :     Enable(!_rList.empty());
     507           6 : }
     508             : 
     509          18 : void OTasksWindow::Clear()
     510             : {
     511          18 :     m_aCreation.resetLastActive();
     512          18 :     SvTreeListEntry* pEntry = m_aCreation.First();
     513          36 :     while ( pEntry )
     514             :     {
     515           0 :         delete reinterpret_cast< TaskEntry* >( pEntry->GetUserData() );
     516           0 :         pEntry = m_aCreation.Next(pEntry);
     517             :     }
     518          18 :     m_aCreation.Clear();
     519          18 : }
     520             : 
     521             : // class OApplicationDetailView
     522             : 
     523          16 : OApplicationDetailView::OApplicationDetailView(OAppBorderWindow& _rParent,PreviewMode _ePreviewMode) : OSplitterView(&_rParent,false )
     524             :     ,m_aHorzSplitter(this)
     525             :     ,m_aTasks(this,STR_TASKS,WB_BORDER | WB_DIALOGCONTROL )
     526             :     ,m_aContainer(this,0,WB_BORDER | WB_DIALOGCONTROL )
     527          16 :     ,m_rBorderWin(_rParent)
     528             : {
     529          16 :     SetUniqueId(UID_APP_DETAIL_VIEW);
     530          16 :     ImplInitSettings( true, true, true );
     531             : 
     532          16 :     m_pControlHelper = new OAppDetailPageHelper(&m_aContainer,m_rBorderWin,_ePreviewMode);
     533          16 :     m_pControlHelper->Show();
     534          16 :     m_aContainer.setChildWindow(m_pControlHelper);
     535             : 
     536          16 :     OTasksWindow* pTasks = new OTasksWindow(&m_aTasks,this);
     537          16 :     pTasks->Show();
     538          16 :     pTasks->Disable(m_rBorderWin.getView()->getCommandController().isDataSourceReadOnly());
     539          16 :     m_aTasks.setChildWindow(pTasks);
     540          16 :     m_aTasks.SetUniqueId(UID_APP_TASKS_VIEW);
     541          16 :     m_aTasks.Show();
     542             : 
     543          16 :     m_aContainer.SetUniqueId(UID_APP_CONTAINER_VIEW);
     544          16 :     m_aContainer.Show();
     545             : 
     546          16 :     const long  nFrameWidth = LogicToPixel( Size( 3, 0 ), MAP_APPFONT ).Width();
     547          16 :     m_aHorzSplitter.SetPosSizePixel( Point(0,50), Size(0,nFrameWidth) );
     548             :     // now set the components at the base class
     549          16 :     set(&m_aContainer,&m_aTasks);
     550             : 
     551          16 :     m_aHorzSplitter.Show();
     552          16 :     m_aHorzSplitter.SetUniqueId(UID_APP_VIEW_HORZ_SPLIT);
     553          16 :     setSplitter(&m_aHorzSplitter);
     554          16 : }
     555             : 
     556          36 : OApplicationDetailView::~OApplicationDetailView()
     557             : {
     558          12 :     set(NULL,NULL);
     559          12 :     setSplitter(NULL);
     560          12 :     m_pControlHelper = NULL;
     561          24 : }
     562             : 
     563          16 : void OApplicationDetailView::ImplInitSettings( bool bFont, bool bForeground, bool bBackground )
     564             : {
     565          16 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     566          16 :     if( bFont )
     567             :     {
     568          16 :         vcl::Font aFont;
     569          16 :         aFont = rStyleSettings.GetFieldFont();
     570          16 :         aFont.SetColor( rStyleSettings.GetWindowTextColor() );
     571          16 :         SetPointFont( aFont );
     572             :     }
     573             : 
     574          16 :     if( bForeground || bFont )
     575             :     {
     576          16 :         SetTextColor( rStyleSettings.GetFieldTextColor() );
     577          16 :         SetTextFillColor();
     578             :     }
     579             : 
     580          16 :     if( bBackground )
     581          16 :         SetBackground( rStyleSettings.GetFieldColor() );
     582             : 
     583          16 :     m_aHorzSplitter.SetBackground( rStyleSettings.GetDialogColor() );
     584          16 :     m_aHorzSplitter.SetFillColor( rStyleSettings.GetDialogColor() );
     585          16 :     m_aHorzSplitter.SetTextFillColor(rStyleSettings.GetDialogColor() );
     586          16 : }
     587             : 
     588           0 : void OApplicationDetailView::DataChanged( const DataChangedEvent& rDCEvt )
     589             : {
     590           0 :     OSplitterView::DataChanged( rDCEvt );
     591             : 
     592           0 :     if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
     593           0 :         (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
     594           0 :         (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
     595           0 :         ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
     596           0 :         (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
     597             :     {
     598           0 :         ImplInitSettings( true, true, true );
     599           0 :         Invalidate();
     600             :     }
     601           0 : }
     602             : 
     603           0 : void OApplicationDetailView::GetFocus()
     604             : {
     605           0 :     OSplitterView::GetFocus();
     606           0 : }
     607             : 
     608          16 : void OApplicationDetailView::setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics )
     609             : {
     610          16 :     m_aExternalMnemonics = _rMnemonics;
     611          16 : }
     612             : 
     613           0 : bool OApplicationDetailView::interceptKeyInput( const KeyEvent& _rEvent )
     614             : {
     615           0 :     const vcl::KeyCode& rKeyCode = _rEvent.GetKeyCode();
     616           0 :     if ( rKeyCode.GetModifier() == KEY_MOD2 )
     617           0 :         return getTasksWindow().HandleKeyInput( _rEvent );
     618             : 
     619             :     // not handled
     620           0 :     return false;
     621             : }
     622             : 
     623           0 : void OApplicationDetailView::createTablesPage(const Reference< XConnection >& _xConnection )
     624             : {
     625           0 :     impl_createPage( E_TABLE, _xConnection, NULL );
     626           0 : }
     627             : 
     628           6 : void OApplicationDetailView::createPage( ElementType _eType,const Reference< XNameAccess >& _xContainer )
     629             : {
     630           6 :     impl_createPage( _eType, NULL, _xContainer );
     631           6 : }
     632             : 
     633           6 : void OApplicationDetailView::impl_createPage( ElementType _eType, const Reference< XConnection >& _rxConnection,
     634             :     const Reference< XNameAccess >& _rxNonTableElements )
     635             : {
     636             :     // get the data for the pane
     637           6 :     const TaskPaneData& rData = impl_getTaskPaneData( _eType );
     638           6 :     getTasksWindow().fillTaskEntryList( rData.aTasks );
     639             : 
     640             :     // enable the pane as a whole, depending on the availability of the first command
     641             :     OSL_ENSURE( !rData.aTasks.empty(), "OApplicationDetailView::impl_createPage: no tasks at all!?" );
     642           6 :     bool bEnabled = rData.aTasks.empty()
     643             :                 ?   false
     644           6 :                 :   getBorderWin().getView()->getCommandController().isCommandEnabled( rData.aTasks[0].sUNOCommand );
     645           6 :     getTasksWindow().Enable( bEnabled );
     646           6 :     m_aContainer.setTitle( rData.nTitleId );
     647             : 
     648             :     // let our helper create the object list
     649           6 :     if ( _eType == E_TABLE )
     650           0 :         m_pControlHelper->createTablesPage( _rxConnection );
     651             :     else
     652           6 :         m_pControlHelper->createPage( _eType, _rxNonTableElements );
     653             : 
     654             :     // resize for proper window arrangements
     655           6 :     Resize();
     656           6 : }
     657             : 
     658           6 : const TaskPaneData& OApplicationDetailView::impl_getTaskPaneData( ElementType _eType )
     659             : {
     660           6 :     if ( m_aTaskPaneData.empty() )
     661           6 :         m_aTaskPaneData.resize( ELEMENT_COUNT );
     662             :     OSL_ENSURE( ( _eType >= 0 ) && ( _eType < E_ELEMENT_TYPE_COUNT ), "OApplicationDetailView::impl_getTaskPaneData: illegal element type!" );
     663           6 :     TaskPaneData& rData = m_aTaskPaneData[ _eType ];
     664             : 
     665             :     //oj: do not check, otherwise extensions will only be visible after a reload.
     666           6 :     impl_fillTaskPaneData( _eType, rData );
     667             : 
     668           6 :     return rData;
     669             : }
     670             : 
     671           6 : void OApplicationDetailView::impl_fillTaskPaneData( ElementType _eType, TaskPaneData& _rData ) const
     672             : {
     673           6 :     TaskEntryList& rList( _rData.aTasks );
     674           6 :     rList.clear(); rList.reserve( 4 );
     675             : 
     676           6 :     switch ( _eType )
     677             :     {
     678             :     case E_TABLE:
     679           0 :         rList.push_back( TaskEntry( ".uno:DBNewTable", RID_STR_TABLES_HELP_TEXT_DESIGN, RID_STR_NEW_TABLE ) );
     680           0 :         rList.push_back( TaskEntry( ".uno:DBNewTableAutoPilot", RID_STR_TABLES_HELP_TEXT_WIZARD, RID_STR_NEW_TABLE_AUTO ) );
     681           0 :         rList.push_back( TaskEntry( ".uno:DBNewView", RID_STR_VIEWS_HELP_TEXT_DESIGN, RID_STR_NEW_VIEW, true ) );
     682           0 :         _rData.nTitleId = RID_STR_TABLES_CONTAINER;
     683           0 :         break;
     684             : 
     685             :     case E_FORM:
     686           6 :         rList.push_back( TaskEntry( ".uno:DBNewForm", RID_STR_FORMS_HELP_TEXT, RID_STR_NEW_FORM ) );
     687           6 :         rList.push_back( TaskEntry( ".uno:DBNewFormAutoPilot", RID_STR_FORMS_HELP_TEXT_WIZARD, RID_STR_NEW_FORM_AUTO ) );
     688           6 :         _rData.nTitleId = RID_STR_FORMS_CONTAINER;
     689           6 :         break;
     690             : 
     691             :     case E_REPORT:
     692           0 :         rList.push_back( TaskEntry( ".uno:DBNewReport", RID_STR_REPORT_HELP_TEXT, RID_STR_NEW_REPORT, true ) );
     693           0 :         rList.push_back( TaskEntry( ".uno:DBNewReportAutoPilot", RID_STR_REPORTS_HELP_TEXT_WIZARD, RID_STR_NEW_REPORT_AUTO ) );
     694           0 :         _rData.nTitleId = RID_STR_REPORTS_CONTAINER;
     695           0 :         break;
     696             : 
     697             :     case E_QUERY:
     698           0 :         rList.push_back( TaskEntry( ".uno:DBNewQuery", RID_STR_QUERIES_HELP_TEXT, RID_STR_NEW_QUERY ) );
     699           0 :         rList.push_back( TaskEntry( ".uno:DBNewQueryAutoPilot", RID_STR_QUERIES_HELP_TEXT_WIZARD, RID_STR_NEW_QUERY_AUTO ) );
     700           0 :         rList.push_back( TaskEntry( ".uno:DBNewQuerySql", RID_STR_QUERIES_HELP_TEXT_SQL, RID_STR_NEW_QUERY_SQL ) );
     701           0 :         _rData.nTitleId = RID_STR_QUERIES_CONTAINER;
     702           0 :         break;
     703             : 
     704             :     default:
     705             :         OSL_FAIL( "OApplicationDetailView::impl_fillTaskPaneData: illegal element type!" );
     706             :     }
     707             : 
     708           6 :     MnemonicGenerator aAllMnemonics( m_aExternalMnemonics );
     709             : 
     710             :     // remove the entries which are not enabled currently
     711          42 :     for (   TaskEntryList::iterator pTask = rList.begin();
     712          36 :             pTask != rList.end();
     713             :         )
     714             :     {
     715          24 :         if  (   pTask->bHideWhenDisabled
     716          12 :             &&  !getBorderWin().getView()->getCommandController().isCommandEnabled( pTask->sUNOCommand )
     717             :             )
     718           0 :             pTask = rList.erase( pTask );
     719             :         else
     720             :         {
     721          12 :             aAllMnemonics.RegisterMnemonic( pTask->sTitle );
     722          12 :             ++pTask;
     723             :         }
     724             :     }
     725             : 
     726             :     // for the remaining entries, assign mnemonics
     727          54 :     for (   TaskEntryList::iterator pTask = rList.begin();
     728          36 :             pTask != rList.end();
     729             :             ++pTask
     730             :         )
     731             :     {
     732          12 :         aAllMnemonics.CreateMnemonic( pTask->sTitle );
     733             :         // don't do this for now, until our task window really supports mnemonics
     734           6 :     }
     735           6 : }
     736             : 
     737           0 : OUString OApplicationDetailView::getQualifiedName( SvTreeListEntry* _pEntry ) const
     738             : {
     739           0 :     return m_pControlHelper->getQualifiedName( _pEntry );
     740             : }
     741             : 
     742           0 : bool OApplicationDetailView::isLeaf(SvTreeListEntry* _pEntry) const
     743             : {
     744           0 :     return m_pControlHelper->isLeaf(_pEntry);
     745             : }
     746             : 
     747          36 : bool OApplicationDetailView::isALeafSelected() const
     748             : {
     749          36 :     return m_pControlHelper->isALeafSelected();
     750             : }
     751             : 
     752           0 : void OApplicationDetailView::selectAll()
     753             : {
     754           0 :     m_pControlHelper->selectAll();
     755           0 : }
     756             : 
     757           0 : void OApplicationDetailView::sortDown()
     758             : {
     759           0 :     m_pControlHelper->sortDown();
     760           0 : }
     761             : 
     762           0 : void OApplicationDetailView::sortUp()
     763             : {
     764           0 :     m_pControlHelper->sortUp();
     765           0 : }
     766             : 
     767          24 : bool OApplicationDetailView::isFilled() const
     768             : {
     769          24 :     return m_pControlHelper->isFilled();
     770             : }
     771             : 
     772           0 : ElementType OApplicationDetailView::getElementType() const
     773             : {
     774           0 :     return m_pControlHelper->getElementType();
     775             : }
     776             : 
     777           0 : void OApplicationDetailView::clearPages(bool _bTaskAlso)
     778             : {
     779           0 :     if ( _bTaskAlso )
     780           0 :         getTasksWindow().Clear();
     781           0 :     m_pControlHelper->clearPages();
     782           0 : }
     783             : 
     784         216 : sal_Int32 OApplicationDetailView::getSelectionCount()
     785             : {
     786         216 :     return m_pControlHelper->getSelectionCount();
     787             : }
     788             : 
     789          36 : sal_Int32 OApplicationDetailView::getElementCount()
     790             : {
     791          36 :     return m_pControlHelper->getElementCount();
     792             : }
     793             : 
     794           0 : void OApplicationDetailView::getSelectionElementNames( ::std::vector< OUString>& _rNames ) const
     795             : {
     796           0 :     m_pControlHelper->getSelectionElementNames( _rNames );
     797           0 : }
     798             : 
     799           0 : void OApplicationDetailView::describeCurrentSelectionForControl( const Control& _rControl, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
     800             : {
     801           0 :     m_pControlHelper->describeCurrentSelectionForControl( _rControl, _out_rSelectedObjects );
     802           0 : }
     803             : 
     804           0 : void OApplicationDetailView::describeCurrentSelectionForType( const ElementType _eType, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
     805             : {
     806           0 :     m_pControlHelper->describeCurrentSelectionForType( _eType, _out_rSelectedObjects );
     807           0 : }
     808             : 
     809           0 : void OApplicationDetailView::selectElements(const Sequence< OUString>& _aNames)
     810             : {
     811           0 :     m_pControlHelper->selectElements( _aNames );
     812           0 : }
     813             : 
     814           0 : SvTreeListEntry* OApplicationDetailView::getEntry( const Point& _aPoint ) const
     815             : {
     816           0 :     return m_pControlHelper->getEntry(_aPoint);
     817             : }
     818             : 
     819           0 : bool OApplicationDetailView::isCutAllowed()
     820             : {
     821           0 :     return m_pControlHelper->isCutAllowed();
     822             : }
     823             : 
     824           0 : bool OApplicationDetailView::isCopyAllowed()
     825             : {
     826           0 :     return m_pControlHelper->isCopyAllowed();
     827             : }
     828             : 
     829           0 : bool OApplicationDetailView::isPasteAllowed()   { return m_pControlHelper->isPasteAllowed(); }
     830             : 
     831           0 : void OApplicationDetailView::copy() { m_pControlHelper->copy(); }
     832             : 
     833           0 : void OApplicationDetailView::cut()  { m_pControlHelper->cut(); }
     834             : 
     835           0 : void OApplicationDetailView::paste()
     836             : {
     837           0 :     m_pControlHelper->paste();
     838           0 : }
     839             : 
     840           0 : SvTreeListEntry*  OApplicationDetailView::elementAdded(ElementType _eType,const OUString& _rName, const Any& _rObject )
     841             : {
     842           0 :     return m_pControlHelper->elementAdded(_eType,_rName, _rObject );
     843             : }
     844             : 
     845           0 : void OApplicationDetailView::elementRemoved(ElementType _eType,const OUString& _rName )
     846             : {
     847           0 :     m_pControlHelper->elementRemoved(_eType,_rName );
     848           0 : }
     849             : 
     850           0 : void OApplicationDetailView::elementReplaced(ElementType _eType
     851             :                                                     ,const OUString& _rOldName
     852             :                                                     ,const OUString& _rNewName )
     853             : {
     854           0 :     m_pControlHelper->elementReplaced( _eType, _rOldName, _rNewName );
     855           0 : }
     856             : 
     857          54 : PreviewMode OApplicationDetailView::getPreviewMode()
     858             : {
     859          54 :     return m_pControlHelper->getPreviewMode();
     860             : }
     861             : 
     862           0 : bool OApplicationDetailView::isPreviewEnabled()
     863             : {
     864           0 :     return m_pControlHelper->isPreviewEnabled();
     865             : }
     866             : 
     867           0 : void OApplicationDetailView::switchPreview(PreviewMode _eMode)
     868             : {
     869           0 :     m_pControlHelper->switchPreview(_eMode);
     870           0 : }
     871             : 
     872          12 : void OApplicationDetailView::showPreview(const Reference< XContent >& _xContent)
     873             : {
     874          12 :     m_pControlHelper->showPreview(_xContent);
     875          12 : }
     876             : 
     877           0 : void OApplicationDetailView::showPreview(   const OUString& _sDataSourceName,
     878             :                                             const OUString& _sName,
     879             :                                             bool _bTable)
     880             : {
     881           0 :     m_pControlHelper->showPreview(_sDataSourceName,_sName,_bTable);
     882           0 : }
     883             : 
     884           0 : bool OApplicationDetailView::isSortUp() const
     885             : {
     886           0 :     return m_pControlHelper->isSortUp();
     887             : }
     888             : 
     889           0 : vcl::Window* OApplicationDetailView::getTreeWindow() const
     890             : {
     891           0 :     return m_pControlHelper->getCurrentView();
     892          72 : }
     893             : 
     894             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10