LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - present.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 171 0.0 %
Date: 2014-11-03 Functions: 0 13 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             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      21             : #include <com/sun/star/beans/XPropertySet.hpp>
      22             : #include <com/sun/star/container/XIndexAccess.hpp>
      23             : #include <comphelper/processfactory.hxx>
      24             : #include <svl/itemset.hxx>
      25             : #include <vcl/svapp.hxx>
      26             : 
      27             : #include "sdattr.hxx"
      28             : #include "present.hxx"
      29             : #include "sdresid.hxx"
      30             : #include "cusshow.hxx"
      31             : #include "customshowlist.hxx"
      32             : 
      33             : using namespace ::com::sun::star::uno;
      34             : using namespace ::com::sun::star::lang;
      35             : using namespace ::com::sun::star::container;
      36             : using namespace ::com::sun::star::beans;
      37             : 
      38           0 : SdStartPresentationDlg::SdStartPresentationDlg( vcl::Window* pWindow,
      39             :                                   const SfxItemSet& rInAttrs,
      40             :                                   const std::vector<OUString> &rPageNames, SdCustomShowList* pCSList ) :
      41             :                 ModalDialog     ( pWindow, "PresentationDialog", "modules/simpress/ui/presentationdialog.ui" ),
      42             :                 pCustomShowList         ( pCSList ),
      43             :                 rOutAttrs               ( rInAttrs ),
      44           0 :                 mnMonitors              ( 0 )
      45             : {
      46           0 :     get( aRbtAll,               "allslides"             );
      47           0 :     get( aRbtAtDia,             "from"                  );
      48           0 :     get( aRbtCustomshow,        "customslideshow"       );
      49           0 :     get( aLbDias,               "from_cb"               );
      50           0 :     get( aLbCustomshow,         "customslideshow_cb"    );
      51             : 
      52           0 :     get( aRbtStandard,          "default"               );
      53           0 :     get( aRbtWindow,            "window"                );
      54           0 :     get( aRbtAuto,              "auto"                  );
      55           0 :     get( aTmfPause,             "pauseduration"         );
      56           0 :     get( aCbxAutoLogo,          "showlogo"              );
      57             : 
      58           0 :     get( aCbxManuel,            "manualslides"          );
      59           0 :     get( aCbxMousepointer,      "pointervisible"        );
      60           0 :     get( aCbxPen,               "pointeraspen"          );
      61           0 :     get( aCbxNavigator,         "navigatorvisible"      );
      62           0 :     get( aCbxAnimationAllowed,  "animationsallowed"     );
      63           0 :     get( aCbxChangePage,        "changeslidesbyclick"   );
      64           0 :     get( aCbxAlwaysOnTop,       "alwaysontop"           );
      65             : 
      66           0 :     get( maFtMonitor,           "presdisplay_label"     );
      67           0 :     get( maLBMonitor,           "presdisplay_cb"        );
      68             : 
      69           0 :     get( msMonitor,             "monitor_str"           );
      70           0 :     get( msMonitorExternal,     "externalmonitor_str"   );
      71           0 :     get( msExternal,            "external_str"          );
      72           0 :     get( msMonitor,             "monitor_str"           );
      73           0 :     get( msAllMonitors,         "allmonitors_str"       );
      74             : 
      75           0 :     Link aLink( LINK( this, SdStartPresentationDlg, ChangeRangeHdl ) );
      76             : 
      77           0 :     aRbtAll->SetClickHdl( aLink );
      78           0 :     aRbtAtDia->SetClickHdl( aLink );
      79           0 :     aRbtCustomshow->SetClickHdl( aLink );
      80             : 
      81           0 :     aLink = LINK( this, SdStartPresentationDlg, ClickWindowPresentationHdl );
      82           0 :     aRbtStandard->SetClickHdl( aLink );
      83           0 :     aRbtWindow->SetClickHdl( aLink );
      84           0 :     aRbtAuto->SetClickHdl( aLink );
      85             : 
      86           0 :     aTmfPause->SetModifyHdl( LINK( this, SdStartPresentationDlg, ChangePauseHdl ) );
      87           0 :     aTmfPause->SetFormat( TimeFieldFormat::F_SEC );
      88             : 
      89             :     // fill Listbox with page names
      90           0 :     for (std::vector<OUString>::const_iterator pIter = rPageNames.begin(); pIter != rPageNames.end(); ++pIter)
      91           0 :         aLbDias->InsertEntry(*pIter);
      92             : 
      93           0 :     if( pCustomShowList )
      94             :     {
      95           0 :         sal_uInt16 nPosToSelect = (sal_uInt16) pCustomShowList->GetCurPos();
      96             :         SdCustomShow* pCustomShow;
      97             :         // fill Listbox with CustomShows
      98           0 :         for( pCustomShow = (SdCustomShow*) pCustomShowList->First();
      99             :              pCustomShow != NULL;
     100           0 :              pCustomShow = (SdCustomShow*) pCustomShowList->Next() )
     101             :         {
     102           0 :             aLbCustomshow->InsertEntry( pCustomShow->GetName() );
     103             :         }
     104           0 :         aLbCustomshow->SelectEntryPos( nPosToSelect );
     105           0 :         pCustomShowList->Seek( nPosToSelect );
     106             :     }
     107             :     else
     108           0 :         aRbtCustomshow->Disable();
     109             : 
     110           0 :     if( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_CUSTOMSHOW ) ).GetValue() && pCSList )
     111           0 :         aRbtCustomshow->Check();
     112           0 :     else if( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_ALL ) ).GetValue() )
     113           0 :         aRbtAll->Check();
     114             :     else
     115           0 :         aRbtAtDia->Check();
     116             : 
     117           0 :     aLbDias->SelectEntry( ( ( const SfxStringItem& ) rOutAttrs.Get( ATTR_PRESENT_DIANAME ) ).GetValue() );
     118           0 :     aCbxManuel->Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_MANUEL ) ).GetValue() );
     119           0 :     aCbxMousepointer->Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_MOUSE ) ).GetValue() );
     120           0 :     aCbxPen->Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_PEN ) ).GetValue() );
     121           0 :     aCbxNavigator->Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_NAVIGATOR ) ).GetValue() );
     122           0 :     aCbxAnimationAllowed->Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_ANIMATION_ALLOWED ) ).GetValue() );
     123           0 :     aCbxChangePage->Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_CHANGE_PAGE ) ).GetValue() );
     124           0 :     aCbxAlwaysOnTop->Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_ALWAYS_ON_TOP ) ).GetValue() );
     125             : 
     126           0 :     const bool  bEndless = ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_ENDLESS ) ).GetValue();
     127           0 :     const bool  bWindow = !( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_FULLSCREEN ) ).GetValue();
     128           0 :     const long  nPause = ( ( const SfxUInt32Item& ) rOutAttrs.Get( ATTR_PRESENT_PAUSE_TIMEOUT ) ).GetValue();
     129             : 
     130           0 :     aTmfPause->SetTime( tools::Time( 0, 0, nPause ) );
     131             :     // set cursor in timefield
     132           0 :     Edit *pEdit = aTmfPause->GetField();
     133           0 :     Selection aSel( pEdit->GetMaxTextLen(), pEdit->GetMaxTextLen() );
     134           0 :     pEdit->SetSelection( aSel );
     135             : 
     136           0 :     aCbxAutoLogo->Check( ( ( const SfxBoolItem& ) rOutAttrs.Get( ATTR_PRESENT_SHOW_PAUSELOGO ) ).GetValue() );
     137             : 
     138           0 :     if( bWindow )
     139           0 :         aRbtWindow->Check( true );
     140           0 :     else if( bEndless )
     141           0 :         aRbtAuto->Check( true );
     142             :     else
     143           0 :         aRbtStandard->Check( true );
     144             : 
     145           0 :     InitMonitorSettings();
     146             : 
     147           0 :     ChangeRangeHdl( this );
     148             : 
     149           0 :     ClickWindowPresentationHdl( NULL );
     150           0 :     ChangePauseHdl( NULL );
     151           0 : }
     152             : 
     153           0 : OUString SdStartPresentationDlg::GetDisplayName( sal_Int32   nDisplay,
     154             :                                                  DisplayType eType )
     155             : {
     156           0 :     OUString aName;
     157             : 
     158           0 :     switch ( eType )
     159             :     {
     160             :     case EXTERNAL_IS_NUMBER:
     161           0 :         aName = msExternal->GetText();
     162           0 :         break;
     163             :     case MONITOR_IS_EXTERNAL:
     164           0 :         aName = msMonitorExternal->GetText();
     165           0 :         break;
     166             :     default:
     167             :     case MONITOR_NORMAL:
     168           0 :         aName = msMonitor->GetText();
     169           0 :         break;
     170             :     }
     171           0 :     aName = aName.replaceFirst( "%1", OUString::number( nDisplay ) );
     172             : 
     173           0 :     return aName;
     174             : }
     175             : 
     176             : /// Store display index together with name in user data
     177           0 : sal_Int32 SdStartPresentationDlg::InsertDisplayEntry(const rtl::OUString &aName,
     178             :                                                      sal_Int32            nDisplay)
     179             : {
     180           0 :     maLBMonitor->InsertEntry( aName );
     181           0 :     const sal_uInt32 nEntryIndex = maLBMonitor->GetEntryCount() - 1;
     182           0 :     maLBMonitor->SetEntryData( nEntryIndex, (void*)(sal_IntPtr)nDisplay );
     183             : 
     184           0 :     return nEntryIndex;
     185             : }
     186             : 
     187           0 : void SdStartPresentationDlg::InitMonitorSettings()
     188             : {
     189             :     try
     190             :     {
     191           0 :         maFtMonitor->Show( true );
     192           0 :         maLBMonitor->Show( true );
     193             : 
     194           0 :         mnMonitors = Application::GetScreenCount();
     195             : 
     196           0 :         if( mnMonitors <= 1 )
     197             :         {
     198           0 :             maFtMonitor->Enable( false );
     199           0 :             maLBMonitor->Enable( false );
     200             :         }
     201             :         else
     202             :         {
     203           0 :             bool bUnifiedDisplay = Application::IsUnifiedDisplay();
     204           0 :             sal_Int32 nExternalIndex = Application::GetDisplayExternalScreen();
     205             : 
     206           0 :             sal_Int32 nSelectedIndex (-1);
     207           0 :             sal_Int32 nDefaultExternalIndex (-1);
     208             :             const sal_Int32 nDefaultSelectedDisplay (
     209           0 :                 ( ( const SfxInt32Item& ) rOutAttrs.Get( ATTR_PRESENT_DISPLAY ) ).GetValue());
     210             : 
     211             :             // Un-conditionally add a version for '0' the default external display
     212             :             sal_Int32 nInsertedEntry;
     213             : 
     214             :             // Initial entry - the auto-detected external monitor
     215           0 :             OUString aName = GetDisplayName( nExternalIndex + 1, EXTERNAL_IS_NUMBER);
     216           0 :             nInsertedEntry = InsertDisplayEntry( aName, 0 );
     217           0 :             if( nDefaultSelectedDisplay == 0)
     218           0 :                 nSelectedIndex = nInsertedEntry;
     219             : 
     220             :             // The user data contains the real setting
     221           0 :             for( sal_Int32 nDisplay = 0; nDisplay < mnMonitors; nDisplay++ )
     222             :             {
     223           0 :                 aName = GetDisplayName( nDisplay + 1,
     224             :                                         nDisplay == nExternalIndex ?
     225           0 :                                         MONITOR_IS_EXTERNAL : MONITOR_NORMAL );
     226           0 :                 nInsertedEntry = InsertDisplayEntry( aName, nDisplay + 1 );
     227             : 
     228             :                 // Remember the index of the default selection.
     229           0 :                 if( nDisplay + 1 == nDefaultSelectedDisplay )
     230           0 :                     nSelectedIndex = nInsertedEntry;
     231             : 
     232             :                 // Remember index of the default display.
     233           0 :                 if( nDisplay == nExternalIndex )
     234           0 :                     nDefaultExternalIndex = nInsertedEntry;
     235             :             }
     236             : 
     237           0 :             if( bUnifiedDisplay )
     238             :             {
     239           0 :                 nInsertedEntry = InsertDisplayEntry( msAllMonitors->GetText(), -1 );
     240           0 :                 if( nDefaultSelectedDisplay == -1 )
     241           0 :                     nSelectedIndex = nInsertedEntry;
     242             :             }
     243             : 
     244           0 :             if (nSelectedIndex < 0)
     245             :             {
     246           0 :                 if (nExternalIndex < 0)
     247           0 :                     nSelectedIndex = 0;
     248             :                 else
     249           0 :                     nSelectedIndex = nDefaultExternalIndex;
     250             :             }
     251             : 
     252           0 :             maLBMonitor->SelectEntryPos(nSelectedIndex);
     253             :         }
     254             :     }
     255           0 :     catch( Exception& )
     256             :     {
     257             :     }
     258           0 : }
     259             : 
     260             : /**
     261             :  * sets the selected attributes of the dialog
     262             :  */
     263           0 : void SdStartPresentationDlg::GetAttr( SfxItemSet& rAttr )
     264             : {
     265           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ALL, aRbtAll->IsChecked() ) );
     266           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_CUSTOMSHOW, aRbtCustomshow->IsChecked() ) );
     267           0 :     rAttr.Put( SfxStringItem ( ATTR_PRESENT_DIANAME, aLbDias->GetSelectEntry() ) );
     268           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_MANUEL, aCbxManuel->IsChecked() ) );
     269           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_MOUSE, aCbxMousepointer->IsChecked() ) );
     270           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_PEN, aCbxPen->IsChecked() ) );
     271           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_NAVIGATOR, aCbxNavigator->IsChecked() ) );
     272           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ANIMATION_ALLOWED, aCbxAnimationAllowed->IsChecked() ) );
     273           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_CHANGE_PAGE, aCbxChangePage->IsChecked() ) );
     274           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ALWAYS_ON_TOP, aCbxAlwaysOnTop->IsChecked() ) );
     275           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_FULLSCREEN, !aRbtWindow->IsChecked() ) );
     276           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_ENDLESS, aRbtAuto->IsChecked() ) );
     277           0 :     rAttr.Put( SfxUInt32Item ( ATTR_PRESENT_PAUSE_TIMEOUT, aTmfPause->GetTime().GetMSFromTime() / 1000 ) );
     278           0 :     rAttr.Put( SfxBoolItem ( ATTR_PRESENT_SHOW_PAUSELOGO, aCbxAutoLogo->IsChecked() ) );
     279             : 
     280           0 :     sal_Int32 nPos = maLBMonitor->GetSelectEntryPos();
     281           0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     282           0 :         rAttr.Put( SfxInt32Item ( ATTR_PRESENT_DISPLAY, (sal_Int32)(sal_IntPtr)maLBMonitor->GetEntryData(nPos)) );
     283             : 
     284           0 :     nPos = aLbCustomshow->GetSelectEntryPos();
     285           0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     286           0 :         pCustomShowList->Seek( nPos );
     287           0 : }
     288             : 
     289             : /**
     290             :  *      Handler: Enabled/Disabled Listbox "Dias"
     291             :  */
     292           0 : IMPL_LINK_NOARG(SdStartPresentationDlg, ChangeRangeHdl)
     293             : {
     294           0 :     aLbDias->Enable( aRbtAtDia->IsChecked() );
     295           0 :     aLbCustomshow->Enable( aRbtCustomshow->IsChecked() );
     296             : 
     297           0 :     return( 0L );
     298             : }
     299             : 
     300             : /**
     301             :  *      Handler: Enabled/Disabled Checkbox "AlwaysOnTop"
     302             :  */
     303           0 : IMPL_LINK_NOARG(SdStartPresentationDlg, ClickWindowPresentationHdl)
     304             : {
     305           0 :     const bool bAuto = aRbtAuto->IsChecked();
     306           0 :     const bool bWindow = aRbtWindow->IsChecked();
     307             : 
     308             :     // aFtPause.Enable( bAuto );
     309           0 :     aTmfPause->Enable( bAuto );
     310           0 :     aCbxAutoLogo->Enable( bAuto && ( aTmfPause->GetTime().GetMSFromTime() > 0 ) );
     311             : 
     312           0 :     const bool bDisplay = !bWindow && ( mnMonitors > 1 );
     313           0 :     maFtMonitor->Enable( bDisplay );
     314           0 :     maLBMonitor->Enable( bDisplay );
     315             : 
     316           0 :     if( bWindow )
     317             :     {
     318           0 :         aCbxAlwaysOnTop->Enable( false );
     319           0 :         aCbxAlwaysOnTop->Check( false );
     320             :     }
     321             :     else
     322           0 :         aCbxAlwaysOnTop->Enable();
     323             : 
     324           0 :     return( 0L );
     325             : }
     326             : 
     327             : /**
     328             :  *      Handler: Enabled/Disabled Checkbox "AlwaysOnTop"
     329             :  */
     330           0 : IMPL_LINK_NOARG(SdStartPresentationDlg, ChangePauseHdl)
     331             : {
     332           0 :     aCbxAutoLogo->Enable( aRbtAuto->IsChecked() && ( aTmfPause->GetTime().GetMSFromTime() > 0 ) );
     333           0 :     return( 0L );
     334           0 : }
     335             : 
     336             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10