LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/dlg - present.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 140 0.0 %
Date: 2012-12-27 Functions: 0 9 0.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             : 
      21             : #ifdef SD_DLLIMPLEMENTATION
      22             : #undef SD_DLLIMPLEMENTATION
      23             : #endif
      24             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      25             : #include <com/sun/star/beans/XPropertySet.hpp>
      26             : #include <com/sun/star/container/XIndexAccess.hpp>
      27             : #include <comphelper/processfactory.hxx>
      28             : #include <svl/itemset.hxx>
      29             : #include <vcl/svapp.hxx>
      30             : 
      31             : #include "sdattr.hxx"
      32             : #include "present.hxx"
      33             : #include "present.hrc"
      34             : #include "sdresid.hxx"
      35             : #include "cusshow.hxx"
      36             : #include "customshowlist.hxx"
      37             : 
      38             : using ::rtl::OUString;
      39             : using namespace ::com::sun::star::uno;
      40             : using namespace ::com::sun::star::lang;
      41             : using namespace ::com::sun::star::container;
      42             : using namespace ::com::sun::star::beans;
      43             : 
      44             : /*************************************************************************
      45             : |* Ctor
      46             : \************************************************************************/
      47           0 : SdStartPresentationDlg::SdStartPresentationDlg( Window* pWindow,
      48             :                                   const SfxItemSet& rInAttrs,
      49             :                                   const std::vector<String> &rPageNames, SdCustomShowList* pCSList ) :
      50             :                 ModalDialog     ( pWindow, SdResId( DLG_START_PRESENTATION ) ),
      51             :                 aGrpRange               ( this, SdResId( GRP_RANGE ) ),
      52             :                 aRbtAll                 ( this, SdResId( RBT_ALL ) ),
      53             :                 aRbtAtDia               ( this, SdResId( RBT_AT_DIA ) ),
      54             :                 aRbtCustomshow          ( this, SdResId( RBT_CUSTOMSHOW ) ),
      55             :                 aLbDias                 ( this, SdResId( LB_DIAS ) ),
      56             :                 aLbCustomshow           ( this, SdResId( LB_CUSTOMSHOW ) ),
      57             : 
      58             :                 aGrpKind                ( this, SdResId( GRP_KIND ) ),
      59             :                 aRbtStandard            ( this, SdResId( RBT_STANDARD ) ),
      60             :                 aRbtWindow              ( this, SdResId( RBT_WINDOW ) ),
      61             :                 aRbtAuto                ( this, SdResId( RBT_AUTO ) ),
      62             :                 aTmfPause               ( this, SdResId( TMF_PAUSE ) ),
      63             :                 aCbxAutoLogo            ( this, SdResId( CBX_AUTOLOGO ) ),
      64             : 
      65             :                 aGrpOptions             ( this, SdResId( GRP_OPTIONS ) ),
      66             :                 aCbxManuel              ( this, SdResId( CBX_MANUEL ) ),
      67             :                 aCbxMousepointer        ( this, SdResId( CBX_MOUSEPOINTER ) ),
      68             :                 aCbxPen                 ( this, SdResId( CBX_PEN ) ),
      69             :                 aCbxNavigator           ( this, SdResId( CBX_NAVIGATOR ) ),
      70             :                 aCbxAnimationAllowed    ( this, SdResId( CBX_ANIMATION_ALLOWED ) ),
      71             :                 aCbxChangePage          ( this, SdResId( CBX_CHANGE_PAGE ) ),
      72             :                 aCbxAlwaysOnTop         ( this, SdResId( CBX_ALWAYS_ON_TOP ) ),
      73             : 
      74             :                 maGrpMonitor            ( this, SdResId( GRP_MONITOR ) ),
      75             :                 maFtMonitor             ( this, SdResId( FT_MONITOR ) ),
      76             :                 maLBMonitor             ( this, SdResId( LB_MONITOR ) ),
      77             : 
      78             :                 aBtnOK                  ( this, SdResId( BTN_OK ) ),
      79             :                 aBtnCancel              ( this, SdResId( BTN_CANCEL ) ),
      80             :                 aBtnHelp                ( this, SdResId( BTN_HELP ) ),
      81             : 
      82             :                 pCustomShowList         ( pCSList ),
      83             :                 rOutAttrs               ( rInAttrs ),
      84             :                 mnMonitors              ( 0 ),
      85             : 
      86             :                 msExternalMonitor( SdResId(STR_EXTERNAL_MONITOR ) ),
      87             :                 msMonitor( SdResId( STR_MONITOR ) ),
      88           0 :                 msAllMonitors( SdResId( STR_ALL_MONITORS ) )
      89             : {
      90           0 :     FreeResource();
      91             : 
      92           0 :     Link aLink( LINK( this, SdStartPresentationDlg, ChangeRangeHdl ) );
      93             : 
      94           0 :     aRbtAll.SetClickHdl( aLink );
      95           0 :     aRbtAtDia.SetClickHdl( aLink );
      96           0 :     aRbtCustomshow.SetClickHdl( aLink );
      97             : 
      98           0 :     aLink = LINK( this, SdStartPresentationDlg, ClickWindowPresentationHdl );
      99           0 :     aRbtStandard.SetClickHdl( aLink );
     100           0 :     aRbtWindow.SetClickHdl( aLink );
     101           0 :     aRbtAuto.SetClickHdl( aLink );
     102             : 
     103           0 :     aTmfPause.SetModifyHdl( LINK( this, SdStartPresentationDlg, ChangePauseHdl ) );
     104           0 :     aTmfPause.SetFormat( TIMEF_SEC );
     105             : 
     106           0 :     aLbDias.SetAccessibleRelationLabeledBy( &aRbtAtDia );
     107           0 :     aLbDias.SetAccessibleName(aRbtAtDia.GetText());
     108           0 :     aLbCustomshow.SetAccessibleRelationLabeledBy( &aRbtCustomshow );
     109           0 :     aTmfPause.SetAccessibleRelationLabeledBy( &aRbtAuto );
     110           0 :     aTmfPause.SetAccessibleName(aRbtAuto.GetText());
     111             : 
     112             :     // Listbox mit Seitennamen fuellen
     113           0 :     for (std::vector<String>::const_iterator pIter = rPageNames.begin(); pIter != rPageNames.end(); ++pIter)
     114           0 :         aLbDias.InsertEntry(*pIter);
     115             : 
     116           0 :     if( pCustomShowList )
     117             :     {
     118           0 :         sal_uInt16 nPosToSelect = (sal_uInt16) pCustomShowList->GetCurPos();
     119             :         SdCustomShow* pCustomShow;
     120             :         // Listbox mit CustomShows fuellen
     121           0 :         for( pCustomShow = (SdCustomShow*) pCustomShowList->First();
     122             :              pCustomShow != NULL;
     123           0 :              pCustomShow = (SdCustomShow*) pCustomShowList->Next() )
     124             :         {
     125           0 :             aLbCustomshow.InsertEntry( pCustomShow->GetName() );
     126             :         }
     127           0 :         aLbCustomshow.SelectEntryPos( nPosToSelect );
     128           0 :         pCustomShowList->Seek( nPosToSelect );
     129             :     }
     130             :     else
     131           0 :         aRbtCustomshow.Disable();
     132             : 
     133           0 :     if( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_CUSTOMSHOW ) ).GetValue() && pCSList )
     134           0 :         aRbtCustomshow.Check();
     135           0 :     else if( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_ALL ) ).GetValue() )
     136           0 :         aRbtAll.Check();
     137             :     else
     138           0 :         aRbtAtDia.Check();
     139             : 
     140           0 :     aLbDias.SelectEntry( ( ( const SfxStringItem& ) rOutAttrs.Get( ATTR_PRESENT_DIANAME ) ).GetValue() );
     141           0 :     aCbxManuel.Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_MANUEL ) ).GetValue() );
     142           0 :     aCbxMousepointer.Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_MOUSE ) ).GetValue() );
     143           0 :     aCbxPen.Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_PEN ) ).GetValue() );
     144           0 :     aCbxNavigator.Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_NAVIGATOR ) ).GetValue() );
     145           0 :     aCbxAnimationAllowed.Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_ANIMATION_ALLOWED ) ).GetValue() );
     146           0 :     aCbxChangePage.Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_CHANGE_PAGE ) ).GetValue() );
     147           0 :     aCbxAlwaysOnTop.Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_ALWAYS_ON_TOP ) ).GetValue() );
     148             : 
     149           0 :     const sal_Bool  bEndless = ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_ENDLESS ) ).GetValue();
     150           0 :     const sal_Bool  bWindow = !( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_FULLSCREEN ) ).GetValue();
     151           0 :     const long  nPause = ( ( const SfxUInt32Item& ) rOutAttrs.Get( ATTR_PRESENT_PAUSE_TIMEOUT ) ).GetValue();
     152             : 
     153           0 :     aTmfPause.SetTime( Time( 0, 0, nPause ) );
     154             :     // set cursor in timefield
     155           0 :     Edit *pEdit = aTmfPause.GetField();
     156           0 :     Selection aSel( pEdit->GetMaxTextLen(), pEdit->GetMaxTextLen() );
     157           0 :     pEdit->SetSelection( aSel );
     158             : 
     159           0 :     aCbxAutoLogo.Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_SHOW_PAUSELOGO ) ).GetValue() );
     160             : 
     161           0 :     if( bWindow )
     162           0 :         aRbtWindow.Check( sal_True );
     163           0 :     else if( bEndless )
     164           0 :         aRbtAuto.Check( sal_True );
     165             :     else
     166           0 :         aRbtStandard.Check( sal_True );
     167             : 
     168           0 :     InitMonitorSettings();
     169             : 
     170           0 :     ChangeRangeHdl( this );
     171             : 
     172           0 :     ClickWindowPresentationHdl( NULL );
     173           0 :     ChangePauseHdl( NULL );
     174           0 : }
     175             : 
     176           0 : void SdStartPresentationDlg::InitMonitorSettings()
     177             : {
     178             :     try
     179             :     {
     180           0 :         maGrpMonitor.Show( true );
     181           0 :         maFtMonitor.Show( true );
     182           0 :         maLBMonitor.Show( true );
     183             : 
     184           0 :         mnMonitors = Application::GetScreenCount();
     185             : 
     186           0 :         if( mnMonitors <= 1 )
     187             :         {
     188           0 :             maFtMonitor.Enable( false );
     189           0 :             maLBMonitor.Enable( false );
     190             :         }
     191             :         else
     192             :         {
     193           0 :             sal_Bool bUnifiedDisplay = Application::IsUnifiedDisplay();
     194           0 :             sal_Int32 nExternalIndex = Application::GetDisplayExternalScreen();
     195             : 
     196           0 :             sal_Int32 nSelectedIndex (-1);
     197           0 :             sal_Int32 nDefaultExternalIndex (-1);
     198             :             const sal_Int32 nDefaultSelectedDisplay (
     199           0 :                 ( ( const SfxInt32Item& ) rOutAttrs.Get( ATTR_PRESENT_DISPLAY ) ).GetValue());
     200           0 :             const String sPlaceHolder( RTL_CONSTASCII_USTRINGPARAM( "%1" ) );
     201           0 :             for( sal_Int32 nDisplay = 0; nDisplay < mnMonitors; nDisplay++ )
     202             :             {
     203           0 :                 String aName( nDisplay == nExternalIndex ? msExternalMonitor : msMonitor );
     204           0 :                 const String aNumber( String::CreateFromInt32( nDisplay + 1 ) );
     205           0 :                 aName.SearchAndReplace( sPlaceHolder, aNumber );
     206           0 :                 maLBMonitor.InsertEntry( aName );
     207             : 
     208             :                 // Store display index together with name.
     209           0 :                 const sal_uInt32 nEntryIndex (maLBMonitor.GetEntryCount()-1);
     210           0 :                 maLBMonitor.SetEntryData(nEntryIndex, (void*)(sal_IntPtr)nDisplay);
     211             : 
     212             :                 // Remember the index of the default selection.
     213           0 :                 if (nDefaultSelectedDisplay == nDisplay)
     214           0 :                     nSelectedIndex = nEntryIndex;
     215             : 
     216             :                 // Remember index of the default display.
     217           0 :                 if (nDisplay == nExternalIndex)
     218           0 :                     nDefaultExternalIndex = nEntryIndex;
     219           0 :             }
     220             : 
     221           0 :             if( bUnifiedDisplay )
     222             :             {
     223           0 :                 maLBMonitor.InsertEntry( msAllMonitors );
     224           0 :                 const sal_uInt32 nEntryIndex (maLBMonitor.GetEntryCount()-1);
     225           0 :                 maLBMonitor.SetEntryData(nEntryIndex, (void*)-1);
     226           0 :                 if (nDefaultSelectedDisplay == -1)
     227           0 :                     nSelectedIndex = nEntryIndex;
     228             :             }
     229             : 
     230           0 :             if (nSelectedIndex < 0)
     231             :             {
     232           0 :                 if (nExternalIndex < 0)
     233           0 :                     nSelectedIndex = 0;
     234             :                 else
     235           0 :                     nSelectedIndex = nDefaultExternalIndex;
     236             :             }
     237             : 
     238           0 :             maLBMonitor.SelectEntryPos((sal_uInt16)nSelectedIndex);
     239             :         }
     240             :     }
     241           0 :     catch( Exception& )
     242             :     {
     243             :     }
     244           0 : }
     245             : 
     246             : /*************************************************************************
     247             : |* Setzt die ausgewaehlten Attribute des Dialogs
     248             : \************************************************************************/
     249           0 : void SdStartPresentationDlg::GetAttr( SfxItemSet& rAttr )
     250             : {
     251           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ALL, aRbtAll.IsChecked() ) );
     252           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_CUSTOMSHOW, aRbtCustomshow.IsChecked() ) );
     253           0 :     rAttr.Put( SfxStringItem ( ATTR_PRESENT_DIANAME, aLbDias.GetSelectEntry() ) );
     254           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_MANUEL, aCbxManuel.IsChecked() ) );
     255           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_MOUSE, aCbxMousepointer.IsChecked() ) );
     256           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_PEN, aCbxPen.IsChecked() ) );
     257           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_NAVIGATOR, aCbxNavigator.IsChecked() ) );
     258           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ANIMATION_ALLOWED, aCbxAnimationAllowed.IsChecked() ) );
     259           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_CHANGE_PAGE, aCbxChangePage.IsChecked() ) );
     260           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ALWAYS_ON_TOP, aCbxAlwaysOnTop.IsChecked() ) );
     261           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_FULLSCREEN, !aRbtWindow.IsChecked() ) );
     262           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ENDLESS, aRbtAuto.IsChecked() ) );
     263           0 :     rAttr.Put( SfxUInt32Item ( ATTR_PRESENT_PAUSE_TIMEOUT, aTmfPause.GetTime().GetMSFromTime() / 1000 ) );
     264           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_SHOW_PAUSELOGO, aCbxAutoLogo.IsChecked() ) );
     265             : 
     266           0 :     sal_uInt16 nPos = maLBMonitor.GetSelectEntryPos();
     267           0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     268           0 :         rAttr.Put( SfxInt32Item ( ATTR_PRESENT_DISPLAY, (sal_Int32)(sal_IntPtr)maLBMonitor.GetEntryData(nPos)) );
     269             : 
     270           0 :     nPos = aLbCustomshow.GetSelectEntryPos();
     271           0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     272           0 :         pCustomShowList->Seek( nPos );
     273           0 : }
     274             : 
     275             : /*************************************************************************
     276             : |*      Handler: Enabled/Disabled Listbox "Dias"
     277             : \************************************************************************/
     278           0 : IMPL_LINK_NOARG(SdStartPresentationDlg, ChangeRangeHdl)
     279             : {
     280           0 :     aLbDias.Enable( aRbtAtDia.IsChecked() );
     281           0 :     aLbCustomshow.Enable( aRbtCustomshow.IsChecked() );
     282             : 
     283           0 :     return( 0L );
     284             : }
     285             : 
     286             : /*************************************************************************
     287             : |*      Handler: Enabled/Disabled Checkbox "AlwaysOnTop"
     288             : \************************************************************************/
     289           0 : IMPL_LINK_NOARG(SdStartPresentationDlg, ClickWindowPresentationHdl)
     290             : {
     291           0 :     const bool bAuto = aRbtAuto.IsChecked();
     292           0 :     const bool bWindow = aRbtWindow.IsChecked();
     293             : 
     294             :     // aFtPause.Enable( bAuto );
     295           0 :     aTmfPause.Enable( bAuto );
     296           0 :     aCbxAutoLogo.Enable( bAuto && ( aTmfPause.GetTime().GetMSFromTime() > 0 ) );
     297             : 
     298           0 :     const bool bDisplay = !bWindow && ( mnMonitors > 1 );
     299           0 :     maFtMonitor.Enable( bDisplay );
     300           0 :     maLBMonitor.Enable( bDisplay );
     301             : 
     302           0 :     if( bWindow )
     303             :     {
     304           0 :         aCbxAlwaysOnTop.Enable( sal_False );
     305           0 :         aCbxAlwaysOnTop.Check( sal_False );
     306             :     }
     307             :     else
     308           0 :         aCbxAlwaysOnTop.Enable();
     309             : 
     310           0 :     return( 0L );
     311             : }
     312             : 
     313             : /*************************************************************************
     314             : |*      Handler: Enabled/Disabled Checkbox "AlwaysOnTop"
     315             : \************************************************************************/
     316           0 : IMPL_LINK_NOARG(SdStartPresentationDlg, ChangePauseHdl)
     317             : {
     318           0 :     aCbxAutoLogo.Enable( aRbtAuto.IsChecked() && ( aTmfPause.GetTime().GetMSFromTime() > 0 ) );
     319           0 :     return( 0L );
     320             : }
     321             : 
     322             : 
     323             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10