LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - present.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 137 0.0 %
Date: 2012-08-25 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #ifdef SD_DLLIMPLEMENTATION
      31                 :            : #undef SD_DLLIMPLEMENTATION
      32                 :            : #endif
      33                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      34                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      35                 :            : #include <com/sun/star/container/XIndexAccess.hpp>
      36                 :            : #include <comphelper/processfactory.hxx>
      37                 :            : #include <svl/itemset.hxx>
      38                 :            : 
      39                 :            : #include "sdattr.hxx"
      40                 :            : #include "present.hxx"
      41                 :            : #include "present.hrc"
      42                 :            : #include "sdresid.hxx"
      43                 :            : #include "cusshow.hxx"
      44                 :            : #include "customshowlist.hxx"
      45                 :            : 
      46                 :            : using ::rtl::OUString;
      47                 :            : using namespace ::com::sun::star::uno;
      48                 :            : using namespace ::com::sun::star::lang;
      49                 :            : using namespace ::com::sun::star::container;
      50                 :            : using namespace ::com::sun::star::beans;
      51                 :            : 
      52                 :            : /*************************************************************************
      53                 :            : |* Ctor
      54                 :            : \************************************************************************/
      55                 :          0 : SdStartPresentationDlg::SdStartPresentationDlg( Window* pWindow,
      56                 :            :                                   const SfxItemSet& rInAttrs,
      57                 :            :                                   const std::vector<String> &rPageNames, SdCustomShowList* pCSList ) :
      58                 :            :                 ModalDialog     ( pWindow, SdResId( DLG_START_PRESENTATION ) ),
      59                 :            :                 aGrpRange               ( this, SdResId( GRP_RANGE ) ),
      60                 :            :                 aRbtAll                 ( this, SdResId( RBT_ALL ) ),
      61                 :            :                 aRbtAtDia               ( this, SdResId( RBT_AT_DIA ) ),
      62                 :            :                 aRbtCustomshow          ( this, SdResId( RBT_CUSTOMSHOW ) ),
      63                 :            :                 aLbDias                 ( this, SdResId( LB_DIAS ) ),
      64                 :            :                 aLbCustomshow           ( this, SdResId( LB_CUSTOMSHOW ) ),
      65                 :            : 
      66                 :            :                 aGrpKind                ( this, SdResId( GRP_KIND ) ),
      67                 :            :                 aRbtStandard            ( this, SdResId( RBT_STANDARD ) ),
      68                 :            :                 aRbtWindow              ( this, SdResId( RBT_WINDOW ) ),
      69                 :            :                 aRbtAuto                ( this, SdResId( RBT_AUTO ) ),
      70                 :            :                 aTmfPause               ( this, SdResId( TMF_PAUSE ) ),
      71                 :            :                 aCbxAutoLogo            ( this, SdResId( CBX_AUTOLOGO ) ),
      72                 :            : 
      73                 :            :                 aGrpOptions             ( this, SdResId( GRP_OPTIONS ) ),
      74                 :            :                 aCbxManuel              ( this, SdResId( CBX_MANUEL ) ),
      75                 :            :                 aCbxMousepointer        ( this, SdResId( CBX_MOUSEPOINTER ) ),
      76                 :            :                 aCbxPen                 ( this, SdResId( CBX_PEN ) ),
      77                 :            :                 aCbxNavigator           ( this, SdResId( CBX_NAVIGATOR ) ),
      78                 :            :                 aCbxAnimationAllowed    ( this, SdResId( CBX_ANIMATION_ALLOWED ) ),
      79                 :            :                 aCbxChangePage          ( this, SdResId( CBX_CHANGE_PAGE ) ),
      80                 :            :                 aCbxAlwaysOnTop         ( this, SdResId( CBX_ALWAYS_ON_TOP ) ),
      81                 :            : 
      82                 :            :                 maGrpMonitor            ( this, SdResId( GRP_MONITOR ) ),
      83                 :            :                 maFtMonitor             ( this, SdResId( FT_MONITOR ) ),
      84                 :            :                 maLBMonitor             ( this, SdResId( LB_MONITOR ) ),
      85                 :            : 
      86                 :            :                 aBtnOK                  ( this, SdResId( BTN_OK ) ),
      87                 :            :                 aBtnCancel              ( this, SdResId( BTN_CANCEL ) ),
      88                 :            :                 aBtnHelp                ( this, SdResId( BTN_HELP ) ),
      89                 :            : 
      90                 :            :                 pCustomShowList         ( pCSList ),
      91                 :            :                 rOutAttrs               ( rInAttrs ),
      92                 :            :                 mnMonitors              ( 0 ),
      93                 :            : 
      94                 :            :                 msExternalMonitor( SdResId(STR_EXTERNAL_MONITOR ) ),
      95                 :            :                 msMonitor( SdResId( STR_MONITOR ) ),
      96                 :          0 :                 msAllMonitors( SdResId( STR_ALL_MONITORS ) )
      97                 :            : {
      98                 :          0 :     FreeResource();
      99                 :            : 
     100                 :          0 :     Link aLink( LINK( this, SdStartPresentationDlg, ChangeRangeHdl ) );
     101                 :            : 
     102                 :          0 :     aRbtAll.SetClickHdl( aLink );
     103                 :          0 :     aRbtAtDia.SetClickHdl( aLink );
     104                 :          0 :     aRbtCustomshow.SetClickHdl( aLink );
     105                 :            : 
     106                 :          0 :     aLink = LINK( this, SdStartPresentationDlg, ClickWindowPresentationHdl );
     107                 :          0 :     aRbtStandard.SetClickHdl( aLink );
     108                 :          0 :     aRbtWindow.SetClickHdl( aLink );
     109                 :          0 :     aRbtAuto.SetClickHdl( aLink );
     110                 :            : 
     111                 :          0 :     aTmfPause.SetModifyHdl( LINK( this, SdStartPresentationDlg, ChangePauseHdl ) );
     112                 :          0 :     aTmfPause.SetFormat( TIMEF_SEC );
     113                 :            : 
     114                 :          0 :     aLbDias.SetAccessibleRelationLabeledBy( &aRbtAtDia );
     115                 :          0 :     aLbDias.SetAccessibleName(aRbtAtDia.GetText());
     116                 :          0 :     aLbCustomshow.SetAccessibleRelationLabeledBy( &aRbtCustomshow );
     117                 :          0 :     aTmfPause.SetAccessibleRelationLabeledBy( &aRbtAuto );
     118                 :          0 :     aTmfPause.SetAccessibleName(aRbtAuto.GetText());
     119                 :            : 
     120                 :            :     // Listbox mit Seitennamen fuellen
     121                 :          0 :     for (std::vector<String>::const_iterator pIter = rPageNames.begin(); pIter != rPageNames.end(); ++pIter)
     122                 :          0 :         aLbDias.InsertEntry(*pIter);
     123                 :            : 
     124                 :          0 :     if( pCustomShowList )
     125                 :            :     {
     126                 :          0 :         sal_uInt16 nPosToSelect = (sal_uInt16) pCustomShowList->GetCurPos();
     127                 :            :         SdCustomShow* pCustomShow;
     128                 :            :         // Listbox mit CustomShows fuellen
     129                 :          0 :         for( pCustomShow = (SdCustomShow*) pCustomShowList->First();
     130                 :            :              pCustomShow != NULL;
     131                 :          0 :              pCustomShow = (SdCustomShow*) pCustomShowList->Next() )
     132                 :            :         {
     133                 :          0 :             aLbCustomshow.InsertEntry( pCustomShow->GetName() );
     134                 :            :         }
     135                 :          0 :         aLbCustomshow.SelectEntryPos( nPosToSelect );
     136                 :          0 :         pCustomShowList->Seek( nPosToSelect );
     137                 :            :     }
     138                 :            :     else
     139                 :          0 :         aRbtCustomshow.Disable();
     140                 :            : 
     141                 :          0 :     if( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_CUSTOMSHOW ) ).GetValue() && pCSList )
     142                 :          0 :         aRbtCustomshow.Check();
     143                 :          0 :     else if( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_ALL ) ).GetValue() )
     144                 :          0 :         aRbtAll.Check();
     145                 :            :     else
     146                 :          0 :         aRbtAtDia.Check();
     147                 :            : 
     148                 :          0 :     aLbDias.SelectEntry( ( ( const SfxStringItem& ) rOutAttrs.Get( ATTR_PRESENT_DIANAME ) ).GetValue() );
     149                 :          0 :     aCbxManuel.Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_MANUEL ) ).GetValue() );
     150                 :          0 :     aCbxMousepointer.Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_MOUSE ) ).GetValue() );
     151                 :          0 :     aCbxPen.Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_PEN ) ).GetValue() );
     152                 :          0 :     aCbxNavigator.Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_NAVIGATOR ) ).GetValue() );
     153                 :          0 :     aCbxAnimationAllowed.Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_ANIMATION_ALLOWED ) ).GetValue() );
     154                 :          0 :     aCbxChangePage.Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_CHANGE_PAGE ) ).GetValue() );
     155                 :          0 :     aCbxAlwaysOnTop.Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_ALWAYS_ON_TOP ) ).GetValue() );
     156                 :            : 
     157                 :          0 :     const sal_Bool  bEndless = ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_ENDLESS ) ).GetValue();
     158                 :          0 :     const sal_Bool  bWindow = !( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_FULLSCREEN ) ).GetValue();
     159                 :          0 :     const long  nPause = ( ( const SfxUInt32Item& ) rOutAttrs.Get( ATTR_PRESENT_PAUSE_TIMEOUT ) ).GetValue();
     160                 :            : 
     161                 :          0 :     aTmfPause.SetTime( Time( 0, 0, nPause ) );
     162                 :            :     // set cursor in timefield
     163                 :          0 :     Edit *pEdit = aTmfPause.GetField();
     164                 :          0 :     Selection aSel( pEdit->GetMaxTextLen(), pEdit->GetMaxTextLen() );
     165                 :          0 :     pEdit->SetSelection( aSel );
     166                 :            : 
     167                 :          0 :     aCbxAutoLogo.Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_SHOW_PAUSELOGO ) ).GetValue() );
     168                 :            : 
     169                 :          0 :     if( bWindow )
     170                 :          0 :         aRbtWindow.Check( sal_True );
     171                 :          0 :     else if( bEndless )
     172                 :          0 :         aRbtAuto.Check( sal_True );
     173                 :            :     else
     174                 :          0 :         aRbtStandard.Check( sal_True );
     175                 :            : 
     176                 :          0 :     InitMonitorSettings();
     177                 :            : 
     178                 :          0 :     ChangeRangeHdl( this );
     179                 :            : 
     180                 :          0 :     ClickWindowPresentationHdl( NULL );
     181                 :          0 :     ChangePauseHdl( NULL );
     182                 :          0 : }
     183                 :            : 
     184                 :          0 : void SdStartPresentationDlg::InitMonitorSettings()
     185                 :            : {
     186                 :            :     try
     187                 :            :     {
     188                 :          0 :         Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
     189                 :          0 :         Reference< XIndexAccess > xMultiMon( xFactory->createInstance("com.sun.star.awt.DisplayAccess" ), UNO_QUERY_THROW );
     190                 :          0 :         maGrpMonitor.Show( true );
     191                 :          0 :         maFtMonitor.Show( true );
     192                 :          0 :         maLBMonitor.Show( true );
     193                 :            : 
     194                 :          0 :         mnMonitors = xMultiMon->getCount();
     195                 :            : 
     196                 :          0 :         if( mnMonitors <= 1 )
     197                 :            :         {
     198                 :          0 :             maFtMonitor.Enable( false );
     199                 :          0 :             maLBMonitor.Enable( false );
     200                 :            :         }
     201                 :            :         else
     202                 :            :         {
     203                 :          0 :             sal_Bool bUnifiedDisplay = false;
     204                 :          0 :             sal_Int32 nExternalIndex = 0;
     205                 :          0 :             Reference< XPropertySet > xMonProps( xMultiMon, UNO_QUERY );
     206                 :          0 :             if( xMonProps.is() ) try
     207                 :            :             {
     208                 :          0 :                 const OUString sPropName1( "IsUnifiedDisplay" );
     209                 :          0 :                 xMonProps->getPropertyValue( sPropName1 ) >>= bUnifiedDisplay;
     210                 :          0 :                 const OUString sPropName2( "ExternalDisplay" );
     211                 :          0 :                 xMonProps->getPropertyValue( sPropName2 ) >>= nExternalIndex;
     212                 :            :             }
     213                 :          0 :             catch( Exception& )
     214                 :            :             {
     215                 :            :             }
     216                 :            : 
     217                 :          0 :             const String sPlaceHolder( RTL_CONSTASCII_USTRINGPARAM( "%1" ) );
     218                 :          0 :             for( sal_Int32 nDisplay = 0; nDisplay < mnMonitors; nDisplay++ )
     219                 :            :             {
     220                 :          0 :                 String aName( nDisplay == nExternalIndex ? msExternalMonitor : msMonitor );
     221                 :          0 :                 const String aNumber( String::CreateFromInt32( nDisplay + 1 ) );
     222                 :          0 :                 aName.SearchAndReplace( sPlaceHolder, aNumber );
     223                 :          0 :                 maLBMonitor.InsertEntry( aName );
     224                 :          0 :             }
     225                 :            : 
     226                 :          0 :             if( bUnifiedDisplay )
     227                 :          0 :                 maLBMonitor.InsertEntry( msAllMonitors );
     228                 :            : 
     229                 :          0 :             sal_Int32 nSelected = ( ( const SfxInt32Item& ) rOutAttrs.Get( ATTR_PRESENT_DISPLAY ) ).GetValue();
     230                 :          0 :             if( nSelected <= 0 )
     231                 :          0 :                 nSelected = nExternalIndex;
     232                 :            :             else
     233                 :          0 :                 nSelected--;
     234                 :            : 
     235                 :          0 :             maLBMonitor.SelectEntryPos( (sal_uInt16)nSelected );
     236                 :          0 :         }
     237                 :            :     }
     238                 :          0 :     catch( Exception& )
     239                 :            :     {
     240                 :            :     }
     241                 :          0 : }
     242                 :            : 
     243                 :            : /*************************************************************************
     244                 :            : |* Setzt die ausgewaehlten Attribute des Dialogs
     245                 :            : \************************************************************************/
     246                 :          0 : void SdStartPresentationDlg::GetAttr( SfxItemSet& rAttr )
     247                 :            : {
     248                 :          0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ALL, aRbtAll.IsChecked() ) );
     249                 :          0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_CUSTOMSHOW, aRbtCustomshow.IsChecked() ) );
     250                 :          0 :     rAttr.Put( SfxStringItem ( ATTR_PRESENT_DIANAME, aLbDias.GetSelectEntry() ) );
     251                 :          0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_MANUEL, aCbxManuel.IsChecked() ) );
     252                 :          0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_MOUSE, aCbxMousepointer.IsChecked() ) );
     253                 :          0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_PEN, aCbxPen.IsChecked() ) );
     254                 :          0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_NAVIGATOR, aCbxNavigator.IsChecked() ) );
     255                 :          0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ANIMATION_ALLOWED, aCbxAnimationAllowed.IsChecked() ) );
     256                 :          0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_CHANGE_PAGE, aCbxChangePage.IsChecked() ) );
     257                 :          0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ALWAYS_ON_TOP, aCbxAlwaysOnTop.IsChecked() ) );
     258                 :          0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_FULLSCREEN, !aRbtWindow.IsChecked() ) );
     259                 :          0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ENDLESS, aRbtAuto.IsChecked() ) );
     260                 :          0 :     rAttr.Put( SfxUInt32Item ( ATTR_PRESENT_PAUSE_TIMEOUT, aTmfPause.GetTime().GetMSFromTime() / 1000 ) );
     261                 :          0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_SHOW_PAUSELOGO, aCbxAutoLogo.IsChecked() ) );
     262                 :            : 
     263                 :          0 :     sal_uInt16 nPos = maLBMonitor.GetSelectEntryPos();
     264                 :          0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     265                 :          0 :         rAttr.Put( SfxInt32Item ( ATTR_PRESENT_DISPLAY, nPos + 1 ) );
     266                 :            : 
     267                 :          0 :     nPos = aLbCustomshow.GetSelectEntryPos();
     268                 :          0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     269                 :          0 :         pCustomShowList->Seek( nPos );
     270                 :          0 : }
     271                 :            : 
     272                 :            : /*************************************************************************
     273                 :            : |*      Handler: Enabled/Disabled Listbox "Dias"
     274                 :            : \************************************************************************/
     275                 :          0 : IMPL_LINK_NOARG(SdStartPresentationDlg, ChangeRangeHdl)
     276                 :            : {
     277                 :          0 :     aLbDias.Enable( aRbtAtDia.IsChecked() );
     278                 :          0 :     aLbCustomshow.Enable( aRbtCustomshow.IsChecked() );
     279                 :            : 
     280                 :          0 :     return( 0L );
     281                 :            : }
     282                 :            : 
     283                 :            : /*************************************************************************
     284                 :            : |*      Handler: Enabled/Disabled Checkbox "AlwaysOnTop"
     285                 :            : \************************************************************************/
     286                 :          0 : IMPL_LINK_NOARG(SdStartPresentationDlg, ClickWindowPresentationHdl)
     287                 :            : {
     288                 :          0 :     const bool bAuto = aRbtAuto.IsChecked();
     289                 :          0 :     const bool bWindow = aRbtWindow.IsChecked();
     290                 :            : 
     291                 :            :     // aFtPause.Enable( bAuto );
     292                 :          0 :     aTmfPause.Enable( bAuto );
     293                 :          0 :     aCbxAutoLogo.Enable( bAuto && ( aTmfPause.GetTime().GetMSFromTime() > 0 ) );
     294                 :            : 
     295                 :          0 :     const bool bDisplay = !bWindow && ( mnMonitors > 1 );
     296                 :          0 :     maFtMonitor.Enable( bDisplay );
     297                 :          0 :     maLBMonitor.Enable( bDisplay );
     298                 :            : 
     299                 :          0 :     if( bWindow )
     300                 :            :     {
     301                 :          0 :         aCbxAlwaysOnTop.Enable( sal_False );
     302                 :          0 :         aCbxAlwaysOnTop.Check( sal_False );
     303                 :            :     }
     304                 :            :     else
     305                 :          0 :         aCbxAlwaysOnTop.Enable();
     306                 :            : 
     307                 :          0 :     return( 0L );
     308                 :            : }
     309                 :            : 
     310                 :            : /*************************************************************************
     311                 :            : |*      Handler: Enabled/Disabled Checkbox "AlwaysOnTop"
     312                 :            : \************************************************************************/
     313                 :          0 : IMPL_LINK_NOARG(SdStartPresentationDlg, ChangePauseHdl)
     314                 :            : {
     315                 :          0 :     aCbxAutoLogo.Enable( aRbtAuto.IsChecked() && ( aTmfPause.GetTime().GetMSFromTime() > 0 ) );
     316                 :          0 :     return( 0L );
     317                 :            : }
     318                 :            : 
     319                 :            : 
     320                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10