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

Generated by: LCOV version 1.11