LCOV - code coverage report
Current view: top level - avmedia/source/framework - mediacontrol.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 295 0.0 %
Date: 2014-04-11 Functions: 0 25 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 "mediacontrol.hxx"
      21             : #include "mediacontrol.hrc"
      22             : #include "mediamisc.hxx"
      23             : #include <avmedia/mediawindow.hxx>
      24             : #include <avmedia/mediaplayer.hxx>
      25             : #include "helpids.hrc"
      26             : #include <tools/time.hxx>
      27             : #include <svtools/miscopt.hxx>
      28             : #include <vcl/svapp.hxx>
      29             : #include <vcl/settings.hxx>
      30             : #include <vcl/lstbox.hxx>
      31             : #include <unotools/syslocale.hxx>
      32             : #include <sfx2/viewfrm.hxx>
      33             : #include <math.h>
      34             : #include <algorithm>
      35             : 
      36             : #define AVMEDIA_TIMEOUT             100
      37             : #define AVMEDIA_TIME_RANGE          2048
      38             : #define AVMEDIA_DB_RANGE            -40
      39             : #define AVMEDIA_LINEINCREMENT       1.0
      40             : #define AVMEDIA_PAGEINCREMENT       10.0
      41             : 
      42             : #define AVMEDIA_TOOLBOXITEM_PLAY    0x0001
      43             : #define AVMEDIA_TOOLBOXITEM_PLAYFFW 0x0002
      44             : #define AVMEDIA_TOOLBOXITEM_PAUSE   0x0004
      45             : #define AVMEDIA_TOOLBOXITEM_STOP    0x0008
      46             : #define AVMEDIA_TOOLBOXITEM_MUTE    0x0010
      47             : #define AVMEDIA_TOOLBOXITEM_LOOP    0x0011
      48             : #define AVMEDIA_TOOLBOXITEM_ZOOM    0x0012
      49             : #define AVMEDIA_TOOLBOXITEM_OPEN    0x0014
      50             : #define AVMEDIA_TOOLBOXITEM_INSERT  0x0018
      51             : 
      52             : #define AVMEDIA_ZOOMLEVEL_50        0
      53             : #define AVMEDIA_ZOOMLEVEL_100       1
      54             : #define AVMEDIA_ZOOMLEVEL_200       2
      55             : #define AVMEDIA_ZOOMLEVEL_FIT       3
      56             : #define AVMEDIA_ZOOMLEVEL_SCALED    4
      57             : #define AVMEDIA_ZOOMLEVEL_INVALID   65535
      58             : 
      59             : namespace avmedia
      60             : {
      61             : 
      62             : 
      63             : // - MediaControl -
      64             : 
      65             : 
      66           0 : MediaControl::MediaControl( Window* pParent, MediaControlStyle eControlStyle ) :
      67             :     Control( pParent ),
      68           0 :     maImageList( SvtMiscOptions().AreCurrentSymbolsLarge() ? AVMEDIA_RESID( AVMEDIA_IMGLST_L ) : AVMEDIA_RESID( AVMEDIA_IMGLST ) ),
      69             :     maItem( 0, AVMEDIA_SETMASK_ALL ),
      70             :     maPlayToolBox( this, WB_3DLOOK ),
      71             :     maTimeSlider( this, WB_HORZ | WB_DRAG | WB_3DLOOK | WB_SLIDERSET ),
      72             :     maMuteToolBox( this, WB_3DLOOK ),
      73             :     maVolumeSlider( this, WB_HORZ | WB_DRAG | WB_SLIDERSET ),
      74             :     maZoomToolBox( this, WB_3DLOOK ),
      75           0 :     mpZoomListBox( new ListBox( &maZoomToolBox, WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL | WB_3DLOOK ) ),
      76             :     maTimeEdit( this, WB_CENTER | WB_READONLY | WB_BORDER | WB_3DLOOK | WB_READONLY ),
      77             :     meControlStyle( eControlStyle ),
      78           0 :     mbLocked( false )
      79             : {
      80           0 :     const OUString aTimeText( " 00:00:00/00:00:00 " );
      81             : 
      82           0 :     SetBackground();
      83           0 :     SetPaintTransparent( true );
      84           0 :     SetParentClipMode( PARENTCLIPMODE_NOCLIP );
      85             : 
      86           0 :     if( MEDIACONTROLSTYLE_SINGLELINE != meControlStyle )
      87             :     {
      88           0 :         maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_OPEN, implGetImage( AVMEDIA_IMG_OPEN ), OUString( AVMEDIA_RESID( AVMEDIA_STR_OPEN ) ) );
      89           0 :         maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_OPEN, HID_AVMEDIA_TOOLBOXITEM_OPEN );
      90             : 
      91           0 :         maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_INSERT, implGetImage( AVMEDIA_IMG_INSERT ), OUString( AVMEDIA_RESID( AVMEDIA_STR_INSERT ) ) );
      92           0 :         maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_INSERT, HID_AVMEDIA_TOOLBOXITEM_INSERT );
      93             : 
      94           0 :         maPlayToolBox.InsertSeparator();
      95             :     }
      96             :     else
      97             :     {
      98           0 :         mpZoomListBox->SetBackground();
      99             : 
     100           0 :         maZoomToolBox.SetBackground();
     101           0 :         maZoomToolBox.SetPaintTransparent( true );
     102           0 :         maPlayToolBox.SetBackground();
     103           0 :         maPlayToolBox.SetPaintTransparent( true );
     104           0 :         maMuteToolBox.SetBackground();
     105           0 :         maMuteToolBox.SetPaintTransparent( true );
     106             : 
     107             :     }
     108             : 
     109           0 :     maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_PLAY, implGetImage( AVMEDIA_IMG_PLAY ), OUString( AVMEDIA_RESID( AVMEDIA_STR_PLAY ) ), TIB_CHECKABLE );
     110           0 :        maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_PLAY, HID_AVMEDIA_TOOLBOXITEM_PLAY );
     111             : 
     112           0 :     maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_PAUSE, implGetImage( AVMEDIA_IMG_PAUSE ), OUString( AVMEDIA_RESID( AVMEDIA_STR_PAUSE ) ), TIB_CHECKABLE );
     113           0 :        maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_PAUSE, HID_AVMEDIA_TOOLBOXITEM_PAUSE );
     114             : 
     115           0 :     maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_STOP, implGetImage( AVMEDIA_IMG_STOP ), OUString( AVMEDIA_RESID( AVMEDIA_STR_STOP ) ), TIB_CHECKABLE );
     116           0 :        maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_STOP, HID_AVMEDIA_TOOLBOXITEM_STOP );
     117             : 
     118           0 :     maPlayToolBox.InsertSeparator();
     119             : 
     120           0 :     maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_LOOP, implGetImage( AVMEDIA_IMG_ENDLESS ), OUString( AVMEDIA_RESID( AVMEDIA_STR_ENDLESS ) ) );
     121           0 :        maPlayToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_LOOP, HID_AVMEDIA_TOOLBOXITEM_LOOP );
     122             : 
     123           0 :     if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle )
     124           0 :         maPlayToolBox.InsertSeparator();
     125             : 
     126           0 :     maPlayToolBox.SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) );
     127           0 :     maPlayToolBox.SetSizePixel( maPlayToolBox.CalcWindowSizePixel() );
     128           0 :     maPlayToolBox.Show();
     129           0 :     maMinSize = maPlayToolBox.GetSizePixel();
     130             : 
     131           0 :     maTimeSlider.SetSlideHdl( LINK( this, MediaControl, implTimeHdl ) );
     132           0 :     maTimeSlider.SetEndSlideHdl( LINK( this, MediaControl, implTimeEndHdl ) );
     133           0 :     maTimeSlider.SetRange( Range( 0, AVMEDIA_TIME_RANGE ) );
     134           0 :     maTimeSlider.SetHelpId( HID_AVMEDIA_TIMESLIDER );
     135           0 :     maTimeSlider.SetUpdateMode( true );
     136           0 :     maTimeSlider.SetSizePixel( Size( 128, maPlayToolBox.GetSizePixel().Height() ) );
     137           0 :     maTimeSlider.Show();
     138           0 :     maMinSize.Width() += maTimeSlider.GetSizePixel().Width();
     139             : 
     140           0 :     maTimeEdit.SetText( aTimeText );
     141           0 :     maTimeEdit.SetUpdateMode( true );
     142           0 :     maTimeEdit.SetSizePixel( Size( maTimeEdit.GetTextWidth( aTimeText ) + 8, maPlayToolBox.GetSizePixel().Height() ) );
     143           0 :     maTimeEdit.SetControlBackground( Application::GetSettings().GetStyleSettings().GetWindowColor() );
     144           0 :     maTimeEdit.SetHelpId( HID_AVMEDIA_TIMEEDIT );
     145           0 :     maTimeEdit.Disable();
     146           0 :     maTimeEdit.Show();
     147           0 :     maMinSize.Width() += maTimeEdit.GetSizePixel().Width();
     148             : 
     149           0 :     if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle )
     150           0 :         maMuteToolBox.InsertSeparator();
     151             : 
     152           0 :     maMuteToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_MUTE, implGetImage( AVMEDIA_IMG_MUTE ), OUString( AVMEDIA_RESID( AVMEDIA_STR_MUTE ) ) );
     153           0 :        maMuteToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_MUTE, HID_AVMEDIA_TOOLBOXITEM_MUTE );
     154             : 
     155           0 :     maMuteToolBox.SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) );
     156           0 :     maMuteToolBox.SetSizePixel( maMuteToolBox.CalcWindowSizePixel() );
     157           0 :     maMuteToolBox.Show();
     158           0 :     maMinSize.Width() += maMuteToolBox.GetSizePixel().Width();
     159             : 
     160           0 :     maVolumeSlider.SetSlideHdl( LINK( this, MediaControl, implVolumeHdl ) );
     161           0 :     maVolumeSlider.SetEndSlideHdl( LINK( this, MediaControl, implVolumeEndHdl ) );
     162           0 :     maVolumeSlider.SetRange( Range( AVMEDIA_DB_RANGE, 0 ) );
     163           0 :     maVolumeSlider.SetUpdateMode( true );
     164           0 :     maVolumeSlider.SetHelpId( HID_AVMEDIA_VOLUMESLIDER );
     165           0 :     maVolumeSlider.SetSizePixel( Size( 48, maPlayToolBox.GetSizePixel().Height() ) );
     166           0 :     maVolumeSlider.Show();
     167           0 :     maMinSize.Width() += maVolumeSlider.GetSizePixel().Width();
     168             : 
     169           0 :     mpZoomListBox->SetSizePixel( Size( maTimeEdit.GetSizePixel().Width(), 260 ) );
     170           0 :     mpZoomListBox->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_50 ) ), AVMEDIA_ZOOMLEVEL_50 );
     171           0 :     mpZoomListBox->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_100 ) ), AVMEDIA_ZOOMLEVEL_100 );
     172           0 :     mpZoomListBox->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_200 ) ), AVMEDIA_ZOOMLEVEL_200 );
     173           0 :     mpZoomListBox->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_FIT ) ), AVMEDIA_ZOOMLEVEL_FIT );
     174           0 :     mpZoomListBox->SetSelectHdl( LINK( this, MediaControl, implZoomSelectHdl ) );
     175           0 :     mpZoomListBox->SetHelpId( HID_AVMEDIA_ZOOMLISTBOX );
     176             : 
     177           0 :     maZoomToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_ZOOM, OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM ) ) );
     178           0 :     maZoomToolBox.SetHelpId( AVMEDIA_TOOLBOXITEM_ZOOM, HID_AVMEDIA_ZOOMLISTBOX );
     179             : 
     180           0 :     maZoomToolBox.SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM, mpZoomListBox );
     181           0 :     maZoomToolBox.SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) );
     182           0 :     maZoomToolBox.SetSizePixel( maZoomToolBox.CalcWindowSizePixel() );
     183           0 :     maZoomToolBox.Show();
     184           0 :     maMinSize.Width() += maZoomToolBox.GetSizePixel().Width();
     185             : 
     186           0 :     if( MEDIACONTROLSTYLE_MULTILINE == meControlStyle )
     187             :     {
     188           0 :         maMinSize.Width() = 256;
     189           0 :         maMinSize.Height() = ( maMinSize.Height() << 1 ) + AVMEDIA_CONTROLOFFSET;
     190             :     }
     191             : 
     192           0 :     maTimer.SetTimeout( AVMEDIA_TIMEOUT );
     193           0 :     maTimer.SetTimeoutHdl( LINK( this, MediaControl, implTimeoutHdl ) );
     194           0 :     maTimer.Start();
     195           0 : }
     196             : 
     197             : 
     198             : 
     199           0 : MediaControl::~MediaControl()
     200             : {
     201           0 :     maZoomToolBox.SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM, NULL );
     202           0 :     delete mpZoomListBox;
     203           0 : }
     204             : 
     205             : 
     206             : 
     207           0 : const Size& MediaControl::getMinSizePixel() const
     208             : {
     209           0 :     return maMinSize;
     210             : }
     211             : 
     212             : 
     213             : 
     214           0 : void MediaControl::Resize()
     215             : {
     216           0 :     Point           aPos( 0, 0 );
     217           0 :     const sal_Int32 nPlayToolBoxWidth = maPlayToolBox.GetSizePixel().Width();
     218           0 :     const sal_Int32 nMuteToolBoxWidth = maMuteToolBox.GetSizePixel().Width();
     219           0 :     const sal_Int32 nVolumeSliderWidth = maVolumeSlider.GetSizePixel().Width();
     220           0 :     const sal_Int32 nZoomToolBoxWidth = maZoomToolBox.GetSizePixel().Width();
     221           0 :     const sal_Int32 nTimeEditWidth = maTimeEdit.GetSizePixel().Width();
     222           0 :     const sal_Int32 nTimeSliderHeight = maTimeSlider.GetSizePixel().Height();
     223             : 
     224           0 :     if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle )
     225             :     {
     226           0 :         const sal_Int32 nTimeSliderWidth = GetSizePixel().Width() - ( AVMEDIA_CONTROLOFFSET * 3 ) -
     227           0 :                                            nPlayToolBoxWidth - nMuteToolBoxWidth - nVolumeSliderWidth - nTimeEditWidth - nZoomToolBoxWidth;
     228             : 
     229           0 :         maPlayToolBox.SetPosSizePixel( aPos, maPlayToolBox.GetSizePixel() );
     230             : 
     231           0 :         aPos.X() += nPlayToolBoxWidth;
     232           0 :         maTimeSlider.SetPosSizePixel( aPos, Size( nTimeSliderWidth, nTimeSliderHeight ) );
     233             : 
     234           0 :         aPos.X() += nTimeSliderWidth + AVMEDIA_CONTROLOFFSET;
     235           0 :         maTimeEdit.SetPosSizePixel( aPos, maTimeEdit.GetSizePixel() );
     236             : 
     237           0 :         aPos.X() += nTimeEditWidth + AVMEDIA_CONTROLOFFSET;
     238           0 :         maMuteToolBox.SetPosSizePixel( aPos, maMuteToolBox.GetSizePixel() );
     239             : 
     240           0 :         aPos.X() += nMuteToolBoxWidth;
     241           0 :         maVolumeSlider.SetPosSizePixel( aPos, maVolumeSlider.GetSizePixel() );
     242             : 
     243           0 :         aPos.X() += nVolumeSliderWidth + AVMEDIA_CONTROLOFFSET;
     244           0 :         maZoomToolBox.SetPosSizePixel( aPos, maZoomToolBox.GetSizePixel() );
     245             :     }
     246             :     else
     247             :     {
     248           0 :         const sal_Int32 nTimeSliderWidth = GetSizePixel().Width() - AVMEDIA_CONTROLOFFSET - nTimeEditWidth;
     249             : 
     250           0 :         maTimeSlider.SetPosSizePixel( aPos, Size( nTimeSliderWidth, nTimeSliderHeight ) );
     251             : 
     252           0 :         aPos.X() += nTimeSliderWidth + AVMEDIA_CONTROLOFFSET;
     253           0 :         maTimeEdit.SetPosSizePixel( aPos, maTimeEdit.GetSizePixel() );
     254             : 
     255           0 :         aPos.X() = 0;
     256           0 :         aPos.Y() += nTimeSliderHeight + AVMEDIA_CONTROLOFFSET;
     257           0 :         maPlayToolBox.SetPosSizePixel( aPos, maPlayToolBox.GetSizePixel() );
     258             : 
     259           0 :         aPos.X() = GetSizePixel().Width() - nVolumeSliderWidth - nMuteToolBoxWidth - nZoomToolBoxWidth - AVMEDIA_CONTROLOFFSET;
     260           0 :         maMuteToolBox.SetPosSizePixel( aPos, maMuteToolBox.GetSizePixel() );
     261             : 
     262           0 :         aPos.X() += nMuteToolBoxWidth;
     263           0 :         maVolumeSlider.SetPosSizePixel( aPos, maVolumeSlider.GetSizePixel() );
     264             : 
     265           0 :         aPos.X() = GetSizePixel().Width() - nZoomToolBoxWidth;
     266           0 :         maZoomToolBox.SetPosSizePixel( aPos, maZoomToolBox.GetSizePixel() );
     267             :     }
     268           0 : }
     269             : 
     270             : 
     271             : 
     272           0 : void MediaControl::setState( const MediaItem& rItem )
     273             : {
     274           0 :     if( !mbLocked )
     275             :     {
     276           0 :         maItem.merge( rItem );
     277             : 
     278           0 :         implUpdateToolboxes();
     279           0 :         implUpdateTimeSlider();
     280           0 :         implUpdateVolumeSlider();
     281           0 :         implUpdateTimeField( maItem.getTime() );
     282             :     }
     283           0 : }
     284             : 
     285             : 
     286             : 
     287           0 : void MediaControl::implUpdateToolboxes()
     288             : {
     289           0 :     const bool bValidURL = !maItem.getURL().isEmpty();
     290             : 
     291           0 :     maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_INSERT, bValidURL );
     292           0 :     maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_PLAY, bValidURL );
     293           0 :     maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_PLAYFFW, bValidURL );
     294           0 :     maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_PAUSE, bValidURL );
     295           0 :     maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_STOP, bValidURL );
     296           0 :     maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_LOOP, bValidURL );
     297           0 :     maMuteToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_MUTE, bValidURL );
     298             : 
     299           0 :     if( !bValidURL || !IsEnabled() )
     300             :     {
     301           0 :         mpZoomListBox->Disable();
     302             : 
     303           0 :         if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle )
     304           0 :             maPlayToolBox.Disable();
     305             : 
     306           0 :         maMuteToolBox.Disable();
     307             :     }
     308             :     else
     309             :     {
     310           0 :         maPlayToolBox.Enable();
     311           0 :         maMuteToolBox.Enable();
     312             : 
     313           0 :         if( MEDIASTATE_PLAY == maItem.getState() || MEDIASTATE_PLAYFFW == maItem.getState() )
     314             :         {
     315           0 :             maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, true );
     316           0 :             maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAYFFW, MEDIASTATE_PLAYFFW == maItem.getState() );
     317           0 :             maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, false );
     318           0 :             maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_STOP, false );
     319             :         }
     320           0 :         else if( maItem.getTime() > 0.0 && ( maItem.getTime() < maItem.getDuration() ) )
     321             :         {
     322           0 :             maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, false );
     323           0 :             maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAYFFW, false );
     324           0 :             maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, true );
     325           0 :             maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_STOP, false );
     326             :         }
     327             :         else
     328             :         {
     329           0 :             maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, false );
     330           0 :             maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAYFFW, false );
     331           0 :             maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, false );
     332           0 :             maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_STOP, true );
     333             :         }
     334             : 
     335           0 :         maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_LOOP, maItem.isLoop() );
     336           0 :         maMuteToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_MUTE, maItem.isMute() );
     337             : 
     338           0 :         if( !mpZoomListBox->IsTravelSelect() && !mpZoomListBox->IsInDropDown() )
     339             :         {
     340             :             sal_uInt16 nSelectEntryPos ;
     341             : 
     342           0 :             switch( maItem.getZoom() )
     343             :             {
     344           0 :                 case( ::com::sun::star::media::ZoomLevel_ZOOM_1_TO_2 ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_50; break;
     345           0 :                 case( ::com::sun::star::media::ZoomLevel_ORIGINAL ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_100; break;
     346           0 :                 case( ::com::sun::star::media::ZoomLevel_ZOOM_2_TO_1 ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_200; break;
     347           0 :                 case( ::com::sun::star::media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_FIT; break;
     348           0 :                 case( ::com::sun::star::media::ZoomLevel_FIT_TO_WINDOW ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_SCALED; break;
     349             : 
     350           0 :                 default: nSelectEntryPos = AVMEDIA_ZOOMLEVEL_INVALID; break;
     351             :             }
     352             : 
     353           0 :             if( nSelectEntryPos != AVMEDIA_ZOOMLEVEL_INVALID )
     354             :             {
     355           0 :                 mpZoomListBox->Enable();
     356           0 :                 mpZoomListBox->SelectEntryPos( nSelectEntryPos );
     357             :             }
     358             :             else
     359           0 :                 mpZoomListBox->Disable();
     360             :         }
     361             :     }
     362           0 : }
     363             : 
     364             : 
     365             : 
     366           0 : void MediaControl::implUpdateTimeSlider()
     367             : {
     368           0 :     if( maItem.getURL().isEmpty() || !IsEnabled() )
     369           0 :         maTimeSlider.Disable();
     370             :     else
     371             :     {
     372           0 :         maTimeSlider.Enable();
     373             : 
     374           0 :         const double fDuration = maItem.getDuration();
     375             : 
     376           0 :         if( fDuration > 0.0 )
     377             :         {
     378           0 :             const double fTime = ::std::min( maItem.getTime(), fDuration );
     379             : 
     380           0 :             if( !maTimeSlider.GetLineSize() )
     381           0 :                 maTimeSlider.SetLineSize( static_cast< sal_uInt32 >( AVMEDIA_TIME_RANGE * AVMEDIA_LINEINCREMENT / fDuration ) );
     382             : 
     383           0 :             if( !maTimeSlider.GetPageSize() )
     384           0 :                 maTimeSlider.SetPageSize( static_cast< sal_uInt32 >( AVMEDIA_TIME_RANGE * AVMEDIA_PAGEINCREMENT / fDuration ) );
     385             : 
     386           0 :             maTimeSlider.SetThumbPos( static_cast< sal_Int32 >( fTime / fDuration * AVMEDIA_TIME_RANGE ) );
     387             :         }
     388             :     }
     389           0 : }
     390             : 
     391             : 
     392             : 
     393           0 : void MediaControl::implUpdateVolumeSlider()
     394             : {
     395           0 :     if( maItem.getURL().isEmpty() || !IsEnabled() )
     396           0 :         maVolumeSlider.Disable();
     397             :     else
     398             :     {
     399           0 :         maVolumeSlider.Enable();
     400             : 
     401           0 :         const sal_Int32 nVolumeDB = maItem.getVolumeDB();
     402             : 
     403           0 :         maVolumeSlider.SetThumbPos( ::std::min( ::std::max( nVolumeDB, static_cast< sal_Int32 >( AVMEDIA_DB_RANGE ) ),
     404           0 :                                                 static_cast< sal_Int32 >( 0 ) ) );
     405             :     }
     406           0 : }
     407             : 
     408             : 
     409             : 
     410           0 : void MediaControl::implUpdateTimeField( double fCurTime )
     411             : {
     412           0 :     if( !maItem.getURL().isEmpty() )
     413             :     {
     414           0 :         OUString              aTimeString;
     415             : 
     416           0 :         SvtSysLocale aSysLocale;
     417           0 :         const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData();
     418             : 
     419           0 :         aTimeString += rLocaleData.getDuration( Time( 0, 0, static_cast< sal_uInt32 >( floor( fCurTime ) ) ) ) +
     420           0 :             " / " +
     421           0 :             rLocaleData.getDuration( Time( 0, 0, static_cast< sal_uInt32 >( floor( maItem.getDuration() ) )) );
     422             : 
     423           0 :         if( maTimeEdit.GetText() != aTimeString )
     424           0 :             maTimeEdit.SetText( aTimeString );
     425             :     }
     426           0 : }
     427             : 
     428             : 
     429             : 
     430           0 : Image MediaControl::implGetImage( sal_Int32 nImageId ) const
     431             : {
     432           0 :     return maImageList.GetImage( static_cast< sal_uInt16 >( nImageId ) );
     433             : }
     434             : 
     435             : 
     436             : 
     437           0 : IMPL_LINK( MediaControl, implTimeHdl, Slider*, p )
     438             : {
     439           0 :     mbLocked = true;
     440           0 :     maTimer.Stop();
     441           0 :     implUpdateTimeField( p->GetThumbPos() * maItem.getDuration() / AVMEDIA_TIME_RANGE );
     442             : 
     443           0 :     return 0;
     444             : }
     445             : 
     446             : 
     447             : 
     448           0 : IMPL_LINK( MediaControl, implTimeEndHdl, Slider*, p )
     449             : {
     450           0 :     MediaItem aExecItem;
     451             : 
     452           0 :     aExecItem.setTime( p->GetThumbPos() * maItem.getDuration() / AVMEDIA_TIME_RANGE );
     453           0 :     execute( aExecItem );
     454           0 :     update();
     455           0 :     maTimer.Start();
     456           0 :     mbLocked = false;
     457             : 
     458           0 :     return 0;
     459             : }
     460             : 
     461             : 
     462             : 
     463           0 : IMPL_LINK( MediaControl, implVolumeHdl, Slider*, p )
     464             : {
     465           0 :     MediaItem aExecItem;
     466             : 
     467           0 :     aExecItem.setVolumeDB( static_cast< sal_Int16 >( p->GetThumbPos() ) );
     468           0 :     execute( aExecItem );
     469           0 :     update();
     470             : 
     471           0 :     return 0;
     472             : }
     473             : 
     474             : 
     475             : 
     476           0 : IMPL_LINK_NOARG(MediaControl, implVolumeEndHdl)
     477             : {
     478           0 :     return 0;
     479             : }
     480             : 
     481             : 
     482             : 
     483           0 : IMPL_LINK( MediaControl, implSelectHdl, ToolBox*, p )
     484             : {
     485           0 :     if( p )
     486             :     {
     487           0 :         MediaItem aExecItem;
     488             : 
     489           0 :         switch( p->GetCurItemId() )
     490             :         {
     491             :             case( AVMEDIA_TOOLBOXITEM_OPEN ):
     492             :             {
     493           0 :                 OUString aURL;
     494             : 
     495           0 :                  if (::avmedia::MediaWindow::executeMediaURLDialog(
     496           0 :                              GetParent(), aURL, 0))
     497             :                  {
     498           0 :                      if( !::avmedia::MediaWindow::isMediaURL( aURL, ""/*TODO?*/, true ) )
     499           0 :                         ::avmedia::MediaWindow::executeFormatErrorBox( this );
     500             :                     else
     501             :                     {
     502           0 :                         aExecItem.setURL( aURL, "", ""/*TODO?*/ );
     503           0 :                         aExecItem.setState( MEDIASTATE_PLAY );
     504             :                     }
     505           0 :                 }
     506             :             }
     507           0 :             break;
     508             : 
     509             :             case( AVMEDIA_TOOLBOXITEM_INSERT ):
     510             :             {
     511           0 :                 MediaFloater* pFloater = avmedia::getMediaFloater();
     512             : 
     513           0 :                 if( pFloater )
     514           0 :                     pFloater->dispatchCurrentURL();
     515             :             }
     516           0 :             break;
     517             : 
     518             :             case( AVMEDIA_TOOLBOXITEM_PLAY ):
     519             :             case( AVMEDIA_TOOLBOXITEM_PLAYFFW ):
     520             :             {
     521           0 :                 aExecItem.setState( ( AVMEDIA_TOOLBOXITEM_PLAYFFW == p->GetCurItemId() ) ? MEDIASTATE_PLAYFFW : MEDIASTATE_PLAY );
     522             : 
     523           0 :                 if( maItem.getTime() == maItem.getDuration() )
     524           0 :                     aExecItem.setTime( 0.0 );
     525             :                 else
     526           0 :                     aExecItem.setTime( maItem.getTime() );
     527             :             }
     528           0 :             break;
     529             : 
     530             :             case( AVMEDIA_TOOLBOXITEM_PAUSE ):
     531             :             {
     532           0 :                 aExecItem.setState( MEDIASTATE_PAUSE );
     533             :             }
     534           0 :             break;
     535             : 
     536             :             case( AVMEDIA_TOOLBOXITEM_STOP ):
     537             :             {
     538           0 :                 aExecItem.setState( MEDIASTATE_STOP );
     539           0 :                 aExecItem.setTime( 0.0 );
     540             :             }
     541           0 :             break;
     542             : 
     543             :             case( AVMEDIA_TOOLBOXITEM_MUTE ):
     544             :             {
     545           0 :                 aExecItem.setMute( !maMuteToolBox.IsItemChecked( AVMEDIA_TOOLBOXITEM_MUTE ) );
     546             :             }
     547           0 :             break;
     548             : 
     549             :             case( AVMEDIA_TOOLBOXITEM_LOOP ):
     550             :             {
     551           0 :                 aExecItem.setLoop( !maPlayToolBox.IsItemChecked( AVMEDIA_TOOLBOXITEM_LOOP ) );
     552             :             }
     553           0 :             break;
     554             : 
     555             :             default:
     556           0 :             break;
     557             :         }
     558             : 
     559           0 :         if( aExecItem.getMaskSet() != AVMEDIA_SETMASK_NONE )
     560           0 :             execute( aExecItem );
     561             :     }
     562             : 
     563           0 :     update();
     564           0 :     if(p)
     565             :     {
     566           0 :         p->Invalidate( INVALIDATE_UPDATE );
     567             :     }
     568             : 
     569           0 :     return 0;
     570             : }
     571             : 
     572             : 
     573             : 
     574           0 : IMPL_LINK( MediaControl, implZoomSelectHdl, ListBox*, p )
     575             : {
     576           0 :     if( p )
     577             :     {
     578           0 :         MediaItem aExecItem;
     579             :         ::com::sun::star::media::ZoomLevel eLevel;
     580             : 
     581           0 :         switch( p->GetSelectEntryPos() )
     582             :         {
     583           0 :             case( AVMEDIA_ZOOMLEVEL_50 ): eLevel = ::com::sun::star::media::ZoomLevel_ZOOM_1_TO_2; break;
     584           0 :             case( AVMEDIA_ZOOMLEVEL_100 ): eLevel = ::com::sun::star::media::ZoomLevel_ORIGINAL; break;
     585           0 :             case( AVMEDIA_ZOOMLEVEL_200 ): eLevel = ::com::sun::star::media::ZoomLevel_ZOOM_2_TO_1; break;
     586           0 :             case( AVMEDIA_ZOOMLEVEL_FIT ): eLevel = ::com::sun::star::media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT; break;
     587           0 :             case( AVMEDIA_ZOOMLEVEL_SCALED ): eLevel = ::com::sun::star::media::ZoomLevel_FIT_TO_WINDOW; break;
     588             : 
     589           0 :             default: eLevel = ::com::sun::star::media::ZoomLevel_NOT_AVAILABLE; break;
     590             :         }
     591             : 
     592           0 :         aExecItem.setZoom( eLevel );
     593           0 :         execute( aExecItem );
     594           0 :         update();
     595             :     }
     596             : 
     597           0 :     return 0;
     598             : }
     599             : 
     600             : 
     601             : 
     602           0 : IMPL_LINK_NOARG(MediaControl, implTimeoutHdl)
     603             : {
     604           0 :     update();
     605           0 :     maTimer.Start();
     606             : 
     607           0 :     return 0;
     608             : }
     609             : 
     610             : }
     611             : 
     612             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10