diff options
41 files changed, 8823 insertions, 0 deletions
diff --git a/avmedia/inc/mediacontrol.hxx b/avmedia/inc/mediacontrol.hxx new file mode 100644 index 000000000000..f47dd958fe96 --- /dev/null +++ b/avmedia/inc/mediacontrol.hxx @@ -0,0 +1,147 @@ +/************************************************************************* + * + * $RCSfile: mediacontrol.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _AVMEDIA_MEDIACONTROL_HXX +#define _AVMEDIA_MEDIACONTROL_HXX + +#include "mediaitem.hxx" + +#include <vcl/timer.hxx> +#include <vcl/slider.hxx> +#include <vcl/toolbox.hxx> +#include <vcl/edit.hxx> +#include <vcl/image.hxx> + +#define AVMEDIA_CONTROLOFFSET 6 + +class ListBox; + +namespace avmedia +{ + +// --------------------- +// - MediaControlStyle - +// --------------------- + +enum MediaControlStyle +{ + MEDIACONTROLSTYLE_SINGLELINE = 0, + MEDIACONTROLSTYLE_MULTILINE = 1 +}; + +// ---------------- +// - MediaControl - +// --------------- + +class MediaItem; + +class MediaControl : public Control +{ +public: + + MediaControl( Window* pParent, MediaControlStyle eControlStyle ); + ~MediaControl(); + + const Size& getMinSizePixel() const; + + void setState( const MediaItem& rItem ); + void getState( MediaItem& rItem ) const; + +protected: + + virtual void update() = 0; + virtual void execute( const MediaItem& rItem ) = 0; + + virtual void Resize(); + +private: + + void implUpdateToolboxes(); + void implUpdateTimeSlider(); + void implUpdateVolumeSlider(); + void implUpdateTimeField( double fCurTime ); + Image implGetImage( sal_Int32 nImageId ) const; + + DECL_LINK( implTimeHdl, Slider* ); + DECL_LINK( implTimeEndHdl, Slider* ); + DECL_LINK( implVolumeHdl, Slider* ); + DECL_LINK( implVolumeEndHdl, Slider* ); + DECL_LINK( implSelectHdl, ToolBox* ); + DECL_LINK( implZoomSelectHdl, ListBox* ); + DECL_LINK( implTimeoutHdl, Timer* ); + + ImageList maImageList; + Timer maTimer; + MediaItem maItem; + ToolBox maPlayToolBox; + Slider maTimeSlider;; + ToolBox maMuteToolBox; + Slider maVolumeSlider; + ToolBox maZoomToolBox; + ListBox* mpZoomListBox; + Edit maTimeEdit; + Size maMinSize; + MediaControlStyle meControlStyle; +}; + +} + +#endif diff --git a/avmedia/prj/build.lst b/avmedia/prj/build.lst new file mode 100644 index 000000000000..f198a3bc03aa --- /dev/null +++ b/avmedia/prj/build.lst @@ -0,0 +1,9 @@ +av avmedia : sfx2 NULL +av avmedia usr1 - all av_mkout NULL +av avmedia\prj get - all av_prj NULL +av avmedia\inc get - all av_inv NULL +av avmedia\source\viewer nmake - all av_viewer NULL +av avmedia\source\framework nmake - all av_framework NULL +av avmedia\source\win nmake - all av_win NULL +av avmedia\source\java nmake - all av_java NULL +av avmedia\util nmake - all av_inv av_viewer av_framework av_win av_java NULL diff --git a/avmedia/prj/d.lst b/avmedia/prj/d.lst new file mode 100644 index 000000000000..8e5159064f0d --- /dev/null +++ b/avmedia/prj/d.lst @@ -0,0 +1,12 @@ +mkdir: %COMMON_DEST%\res%_EXT% +..\%__SRC%\bin\avmedia*.dll %_DEST%\bin%_EXT%\avmedia*.dll +..\source\java\avmedia.jar %_DEST%\bin%_EXT%\avmedia.jar +..\%__SRC%\lib\lib*.* %_DEST%\lib%_EXT%\lib*.* +..\%__SRC%\lib\*.lib %_DEST%\lib%_EXT%\*.lib +..\%__SRC%\bin\avmedia*.res %_DEST%\bin%_EXT%\avmedia*.res + +mkdir: %_DEST%\inc%_EXT%\avmedia +hedabu: ..\inc\mediawindow.hxx %_DEST%\inc%_EXT%\avmedia\mediawindow.hxx +hedabu: ..\inc\mediaitem.hxx %_DEST%\inc%_EXT%\avmedia\mediaitem.hxx +hedabu: ..\inc\mediaplayer.hxx %_DEST%\inc%_EXT%\avmedia\mediaplayer.hxx +hedabu: ..\inc\mediatoolbox.hxx %_DEST%\inc%_EXT%\avmedia\mediatoolbox.hxx diff --git a/avmedia/source/framework/makefile.mk b/avmedia/source/framework/makefile.mk new file mode 100644 index 000000000000..0ba3b2722d4b --- /dev/null +++ b/avmedia/source/framework/makefile.mk @@ -0,0 +1,90 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. +PRJNAME=avmedia +TARGET=framework + +# --- Settings ---------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +# --- Resources --------------------------------- + +SRS1NAME=$(TARGET) +SRC1FILES =\ + mediacontrol.src + +# --- Files ------------------------------------- + +SLOFILES= \ + $(SLO)$/mediaitem.obj \ + $(SLO)$/mediamisc.obj \ + $(SLO)$/mediacontrol.obj \ + $(SLO)$/mediatoolbox.obj \ + $(SLO)$/mediaplayer.obj + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk diff --git a/avmedia/source/framework/mediacontrol.cxx b/avmedia/source/framework/mediacontrol.cxx new file mode 100644 index 000000000000..e1cd92174474 --- /dev/null +++ b/avmedia/source/framework/mediacontrol.cxx @@ -0,0 +1,622 @@ +/************************************************************************* + * + * $RCSfile: mediacontrol.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "mediacontrol.hxx" +#include "mediacontrol.hrc" +#include "mediamisc.hxx" +#include "mediawindow.hxx" +#include "mediaplayer.hxx" +#include <vcl/svapp.hxx> +#include <vcl/lstbox.hxx> +#include <sfx2/viewfrm.hxx> +#include <cmath> +#include <algorithm> + +#define AVMEDIA_TIMEOUT 100 +#define AVMEDIA_TIME_RANGE 2048 +#define AVMEDIA_DB_RANGE -40 +#define AVMEDIA_LINEINCREMENT 1.0 +#define AVMEDIA_PAGEINCREMENT 10.0 + +#define AVMEDIA_TOOLBOXITEM_PLAY 0x0001 +#define AVMEDIA_TOOLBOXITEM_PLAYFFW 0x0002 +#define AVMEDIA_TOOLBOXITEM_PAUSE 0x0004 +#define AVMEDIA_TOOLBOXITEM_STOP 0x0008 +#define AVMEDIA_TOOLBOXITEM_MUTE 0x0010 +#define AVMEDIA_TOOLBOXITEM_LOOP 0x0011 +#define AVMEDIA_TOOLBOXITEM_ZOOM 0x0012 +#define AVMEDIA_TOOLBOXITEM_OPEN 0x0014 +#define AVMEDIA_TOOLBOXITEM_INSERT 0x0018 + +#define AVMEDIA_ZOOMLEVEL_50 0 +#define AVMEDIA_ZOOMLEVEL_100 1 +#define AVMEDIA_ZOOMLEVEL_200 2 +#define AVMEDIA_ZOOMLEVEL_FIT 3 +#define AVMEDIA_ZOOMLEVEL_SCALED 4 +#define AVMEDIA_ZOOMLEVEL_INVALID 65535 + +namespace avmedia +{ + +// ---------------- +// - MediaControl - +// --------------- + +MediaControl::MediaControl( Window* pParent, MediaControlStyle eControlStyle ) : + Control( pParent ), + maImageList( AVMEDIA_RESID( AVMEDIA_IMGLST ) ), + maItem( 0, AVMEDIA_SETMASK_ALL ), + maTimeSlider( this, WB_HORZ | WB_DRAG | WB_3DLOOK | WB_SLIDERSET ), + maPlayToolBox( this, WB_3DLOOK ), + maMuteToolBox( this, WB_3DLOOK ), + maVolumeSlider( this, WB_HORZ | WB_DRAG | WB_SLIDERSET ), + maZoomToolBox( this, WB_3DLOOK ), + mpZoomListBox( new ListBox( &maZoomToolBox, WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL | WB_3DLOOK ) ), + maTimeEdit( this, WB_CENTER | WB_READONLY | WB_BORDER | WB_3DLOOK | WB_READONLY ), + meControlStyle( eControlStyle ) +{ + const String aTimeText( RTL_CONSTASCII_USTRINGPARAM( " 00:00:00/00:00:00 " ) ); + + SetBackground(); + + if( MEDIACONTROLSTYLE_SINGLELINE != meControlStyle ) + { + maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_OPEN, implGetImage( AVMEDIA_IMG_OPEN ), String( AVMEDIA_RESID( AVMEDIA_STR_OPEN ) ) ); + maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_INSERT, implGetImage( AVMEDIA_IMG_INSERT ), String( AVMEDIA_RESID( AVMEDIA_STR_INSERT ) ) ); + maPlayToolBox.InsertSeparator(); + } + else + { + maTimeSlider.SetBackground(); + maPlayToolBox.SetBackground(); + maMuteToolBox.SetBackground(); + maVolumeSlider.SetBackground(); + maZoomToolBox.SetBackground(); + mpZoomListBox->SetBackground(); + //maTimeEdit.SetBackground(); + } + + maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_PLAY, implGetImage( AVMEDIA_IMG_PLAY ), String( AVMEDIA_RESID( AVMEDIA_STR_PLAY ) ), TIB_CHECKABLE ); + maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_PAUSE, implGetImage( AVMEDIA_IMG_PAUSE ), String( AVMEDIA_RESID( AVMEDIA_STR_PAUSE ) ), TIB_CHECKABLE ); + maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_STOP, implGetImage( AVMEDIA_IMG_STOP ), String( AVMEDIA_RESID( AVMEDIA_STR_STOP ) ), TIB_CHECKABLE ); + maPlayToolBox.InsertSeparator(); + maPlayToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_LOOP, implGetImage( AVMEDIA_IMG_ENDLESS ), String( AVMEDIA_RESID( AVMEDIA_STR_ENDLESS ) ) ); + + if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle ) + maPlayToolBox.InsertSeparator(); + + maPlayToolBox.SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) ); + maPlayToolBox.SetSizePixel( maPlayToolBox.CalcWindowSizePixel() ); + maPlayToolBox.Show(); + maMinSize = maPlayToolBox.GetSizePixel(); + + maTimeSlider.SetSlideHdl( LINK( this, MediaControl, implTimeHdl ) ); + maTimeSlider.SetEndSlideHdl( LINK( this, MediaControl, implTimeEndHdl ) ); + maTimeSlider.SetRange( Range( 0, AVMEDIA_TIME_RANGE ) ); + maTimeSlider.SetUpdateMode( true ); + maTimeSlider.SetSizePixel( Size( 128, maPlayToolBox.GetSizePixel().Height() ) ); + maTimeSlider.Show(); + maMinSize.Width() += maTimeSlider.GetSizePixel().Width(); + + maTimeEdit.SetText( aTimeText ); + maTimeEdit.SetUpdateMode( true ); + maTimeEdit.SetSizePixel( Size( maTimeEdit.GetTextWidth( aTimeText ) + 8, maPlayToolBox.GetSizePixel().Height() ) ); + maTimeEdit.SetControlBackground( Application::GetSettings().GetStyleSettings().GetWindowColor() ); + maTimeEdit.Disable(); + maTimeEdit.Show(); + maMinSize.Width() += maTimeEdit.GetSizePixel().Width(); + + if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle ) + maMuteToolBox.InsertSeparator(); + + maMuteToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_MUTE, implGetImage( AVMEDIA_IMG_MUTE ), String( AVMEDIA_RESID( AVMEDIA_STR_MUTE ) ) ); + maMuteToolBox.SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) ); + maMuteToolBox.SetSizePixel( maMuteToolBox.CalcWindowSizePixel() ); + maMuteToolBox.Show(); + maMinSize.Width() += maMuteToolBox.GetSizePixel().Width(); + + maVolumeSlider.SetSlideHdl( LINK( this, MediaControl, implVolumeHdl ) ); + maVolumeSlider.SetEndSlideHdl( LINK( this, MediaControl, implVolumeEndHdl ) ); + maVolumeSlider.SetRange( Range( AVMEDIA_DB_RANGE, 0 ) ); + maTimeSlider.SetLineSize( labs( AVMEDIA_DB_RANGE / 33 ) ); + maTimeSlider.SetPageSize( labs( AVMEDIA_DB_RANGE / 10 ) ); + maVolumeSlider.SetUpdateMode( true ); + maVolumeSlider.SetSizePixel( Size( 48, maPlayToolBox.GetSizePixel().Height() ) ); + maVolumeSlider.Show(); + maMinSize.Width() += maVolumeSlider.GetSizePixel().Width(); + + mpZoomListBox->SetSizePixel( Size( maTimeEdit.GetSizePixel().Width(), 260 ) ); + mpZoomListBox->InsertEntry( String( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_50 ) ), AVMEDIA_ZOOMLEVEL_50 ); + mpZoomListBox->InsertEntry( String( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_100 ) ), AVMEDIA_ZOOMLEVEL_100 ); + mpZoomListBox->InsertEntry( String( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_200 ) ), AVMEDIA_ZOOMLEVEL_200 ); + mpZoomListBox->InsertEntry( String( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_FIT ) ), AVMEDIA_ZOOMLEVEL_FIT ); + // mpZoomListBox->InsertEntry( String( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_SCALED ) ), AVMEDIA_ZOOMLEVEL_SCALED ); + mpZoomListBox->SetSelectHdl( LINK( this, MediaControl, implZoomSelectHdl ) ); + + maZoomToolBox.InsertItem( AVMEDIA_TOOLBOXITEM_ZOOM, String( AVMEDIA_RESID( AVMEDIA_STR_ZOOM ) ) ); + maZoomToolBox.SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM, mpZoomListBox ); + maZoomToolBox.SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) ); + maZoomToolBox.SetSizePixel( maZoomToolBox.CalcWindowSizePixel() ); + maZoomToolBox.Show(); + maMinSize.Width() += maZoomToolBox.GetSizePixel().Width(); + + if( MEDIACONTROLSTYLE_MULTILINE == meControlStyle ) + { + maMinSize.Width() = 256; + maMinSize.Height() = ( maMinSize.Height() << 1 ) + AVMEDIA_CONTROLOFFSET; + } + + maTimer.SetTimeout( AVMEDIA_TIMEOUT ); + maTimer.SetTimeoutHdl( LINK( this, MediaControl, implTimeoutHdl ) ); + maTimer.Start(); +} + +// ------------------------------------------------------------------------------ + +MediaControl::~MediaControl() +{ + maZoomToolBox.SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM, NULL ); + delete mpZoomListBox; +} + +// ------------------------------------------------------------------------------ + +const Size& MediaControl::getMinSizePixel() const +{ + return maMinSize; +} + +// ------------------------------------------------------------------------------ + +void MediaControl::Resize() +{ + Point aPos( 0, 0 ); + const sal_Int32 nPlayToolBoxWidth = maPlayToolBox.GetSizePixel().Width(); + const sal_Int32 nMuteToolBoxWidth = maMuteToolBox.GetSizePixel().Width(); + const sal_Int32 nVolumeSliderWidth = maVolumeSlider.GetSizePixel().Width(); + const sal_Int32 nZoomToolBoxWidth = maZoomToolBox.GetSizePixel().Width(); + const sal_Int32 nTimeEditWidth = maTimeEdit.GetSizePixel().Width(); + const sal_Int32 nTimeSliderHeight = maTimeSlider.GetSizePixel().Height(); + + if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle ) + { + const sal_Int32 nTimeSliderWidth = GetSizePixel().Width() - ( AVMEDIA_CONTROLOFFSET * 3 ) - + nPlayToolBoxWidth - nMuteToolBoxWidth - nVolumeSliderWidth - nTimeEditWidth - nZoomToolBoxWidth; + + maPlayToolBox.SetPosSizePixel( aPos, maPlayToolBox.GetSizePixel() ); + + aPos.X() += nPlayToolBoxWidth; + maTimeSlider.SetPosSizePixel( aPos, Size( nTimeSliderWidth, nTimeSliderHeight ) ); + + aPos.X() += nTimeSliderWidth + AVMEDIA_CONTROLOFFSET; + maTimeEdit.SetPosSizePixel( aPos, maTimeEdit.GetSizePixel() ); + + aPos.X() += nTimeEditWidth + AVMEDIA_CONTROLOFFSET; + maMuteToolBox.SetPosSizePixel( aPos, maMuteToolBox.GetSizePixel() ); + + aPos.X() += nMuteToolBoxWidth; + maVolumeSlider.SetPosSizePixel( aPos, maVolumeSlider.GetSizePixel() ); + + aPos.X() += nVolumeSliderWidth + AVMEDIA_CONTROLOFFSET; + maZoomToolBox.SetPosSizePixel( aPos, maZoomToolBox.GetSizePixel() ); + } + else + { + const sal_Int32 nTimeSliderWidth = GetSizePixel().Width() - AVMEDIA_CONTROLOFFSET - nTimeEditWidth; + + maTimeSlider.SetPosSizePixel( aPos, Size( nTimeSliderWidth, nTimeSliderHeight ) ); + + aPos.X() += nTimeSliderWidth + AVMEDIA_CONTROLOFFSET; + maTimeEdit.SetPosSizePixel( aPos, maTimeEdit.GetSizePixel() ); + + aPos.X() = 0; + aPos.Y() += nTimeSliderHeight + AVMEDIA_CONTROLOFFSET; + maPlayToolBox.SetPosSizePixel( aPos, maPlayToolBox.GetSizePixel() ); + + aPos.X() = GetSizePixel().Width() - nVolumeSliderWidth - nMuteToolBoxWidth - nZoomToolBoxWidth - AVMEDIA_CONTROLOFFSET; + maMuteToolBox.SetPosSizePixel( aPos, maMuteToolBox.GetSizePixel() ); + + aPos.X() += nMuteToolBoxWidth; + maVolumeSlider.SetPosSizePixel( aPos, maVolumeSlider.GetSizePixel() ); + + aPos.X() = GetSizePixel().Width() - nZoomToolBoxWidth; + maZoomToolBox.SetPosSizePixel( aPos, maZoomToolBox.GetSizePixel() ); + } +} + +// ------------------------------------------------------------------------------ + +void MediaControl::setState( const MediaItem& rItem ) +{ + maItem.merge( rItem ); + + implUpdateToolboxes(); + implUpdateTimeSlider(); + implUpdateVolumeSlider(); + implUpdateTimeField( maItem.getTime() ); +} + +// ------------------------------------------------------------------------------ + +void MediaControl::getState( MediaItem& rItem ) const +{ + rItem.merge( maItem ); +} + +// ------------------------------------------------------------------------------ + +void MediaControl::update() +{ +} + +// ------------------------------------------------------------------------------ + +void MediaControl::execute( const MediaItem& rItem ) +{ +} + +// ------------------------------------------------------------------------------ + +void MediaControl::implUpdateToolboxes() +{ + const bool bValidURL = ( maItem.getURL().getLength() > 0 ); + + maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_INSERT, bValidURL ); + maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_PLAY, bValidURL ); + maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_PLAYFFW, bValidURL ); + maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_PAUSE, bValidURL ); + maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_STOP, bValidURL ); + maPlayToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_LOOP, bValidURL ); + maMuteToolBox.EnableItem( AVMEDIA_TOOLBOXITEM_MUTE, bValidURL ); + + if( !bValidURL ) + mpZoomListBox->Disable(); + else + { + if( MEDIASTATE_PLAY == maItem.getState() || MEDIASTATE_PLAYFFW == maItem.getState() ) + { + maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, true ); + maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAYFFW, MEDIASTATE_PLAYFFW == maItem.getState() ); + maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, false ); + maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_STOP, false ); + } + else if( maItem.getTime() > 0.0 && ( maItem.getTime() < maItem.getDuration() ) ) + { + maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, false ); + maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAYFFW, false ); + maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, true ); + maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_STOP, false ); + } + else + { + maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, false ); + maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PLAYFFW, false ); + maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, false ); + maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_STOP, true ); + } + + maPlayToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_LOOP, maItem.isLoop() ); + maMuteToolBox.CheckItem( AVMEDIA_TOOLBOXITEM_MUTE, maItem.isMute() ); + + if( !mpZoomListBox->IsTravelSelect() && !mpZoomListBox->IsInDropDown() ) + { + USHORT nSelectEntryPos ; + + switch( maItem.getZoom() ) + { + case( ::com::sun::star::media::ZoomLevel_ZOOM_1_TO_2 ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_50; break; + case( ::com::sun::star::media::ZoomLevel_ORIGINAL ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_100; break; + case( ::com::sun::star::media::ZoomLevel_ZOOM_2_TO_1 ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_200; break; + case( ::com::sun::star::media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_FIT; break; + case( ::com::sun::star::media::ZoomLevel_FIT_TO_WINDOW ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_SCALED; break; + + default: nSelectEntryPos = AVMEDIA_ZOOMLEVEL_INVALID; break; + } + + if( nSelectEntryPos != AVMEDIA_ZOOMLEVEL_INVALID ) + { + mpZoomListBox->Enable(); + mpZoomListBox->SelectEntryPos( nSelectEntryPos ); + } + else + mpZoomListBox->Disable(); + } + } +} + +// ------------------------------------------------------------------------------ + +void MediaControl::implUpdateTimeSlider() +{ + if( maItem.getURL().getLength() == 0 ) + maTimeSlider.Disable(); + else + { + const double fDuration = maItem.getDuration(); + + maTimeSlider.Enable(); + + if( fDuration > 0.0 ) + { + const double fTime = ::std::min( maItem.getTime(), fDuration ); + + if( !maTimeSlider.GetLineSize() ) + maTimeSlider.SetLineSize( static_cast< sal_uInt32 >( AVMEDIA_TIME_RANGE * AVMEDIA_LINEINCREMENT / fDuration ) ); + + if( !maTimeSlider.GetPageSize() ) + maTimeSlider.SetPageSize( static_cast< sal_uInt32 >( AVMEDIA_TIME_RANGE * AVMEDIA_PAGEINCREMENT / fDuration ) ); + + maTimeSlider.SetThumbPos( static_cast< sal_Int32 >( fTime / fDuration * AVMEDIA_TIME_RANGE ) ); + } + } +} + +// ------------------------------------------------------------------------------ + +void MediaControl::implUpdateVolumeSlider() +{ + if( maItem.getURL().getLength() == 0 ) + maVolumeSlider.Disable(); + else + { + const sal_Int32 nVolumeDB = maItem.getVolumeDB(); + + maVolumeSlider.Enable(); + maVolumeSlider.SetThumbPos( ::std::min( ::std::max( nVolumeDB, static_cast< sal_Int32 >( AVMEDIA_DB_RANGE ) ), + static_cast< sal_Int32 >( 0 ) ) ); + } +} + +// ------------------------------------------------------------------------------ + +void MediaControl::implUpdateTimeField( double fCurTime ) +{ + maTimeEdit.Disable(); + + if( maItem.getURL().getLength() > 0 ) + { + const International aInternational; + String aTimeString; + + aTimeString += aInternational.GetDuration( Time( 0, 0, static_cast< sal_uInt32 >( floor( fCurTime ) ) ) ); + aTimeString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " / " )); + aTimeString += aInternational.GetDuration( Time( 0, 0, static_cast< sal_uInt32 >( floor( maItem.getDuration() ) ) ) ); + maTimeEdit.SetText( aTimeString ); + } +} + +// ------------------------------------------------------------------------------ + +Image MediaControl::implGetImage( sal_Int32 nImageId ) const +{ + return maImageList.GetImage( static_cast< USHORT >( nImageId ) ); +} + +// ------------------------------------------------------------------------------ + +IMPL_LINK( MediaControl, implTimeHdl, Slider*, p ) +{ + maTimer.Stop(); + implUpdateTimeField( p->GetThumbPos() * maItem.getDuration() / AVMEDIA_TIME_RANGE ); + + return 0; +} + +// ------------------------------------------------------------------------------ + +IMPL_LINK( MediaControl, implTimeEndHdl, Slider*, p ) +{ + MediaItem aExecItem; + + aExecItem.setTime( p->GetThumbPos() * maItem.getDuration() / AVMEDIA_TIME_RANGE ); + execute( aExecItem ); + update(); + maTimer.Start(); + + return 0; +} + +// ------------------------------------------------------------------------------ + +IMPL_LINK( MediaControl, implVolumeHdl, Slider*, p ) +{ + MediaItem aExecItem; + + aExecItem.setVolumeDB( p->GetThumbPos() ); + execute( aExecItem ); + update(); + + return 0; +} + +// ------------------------------------------------------------------------------ + +IMPL_LINK( MediaControl, implVolumeEndHdl, Slider*, p ) +{ + return 0; +} + +// ------------------------------------------------------------------------------ + +IMPL_LINK( MediaControl, implSelectHdl, ToolBox*, p ) +{ + if( p ) + { + MediaItem aExecItem; + + switch( p->GetCurItemId() ) + { + case( AVMEDIA_TOOLBOXITEM_OPEN ): + { + ::rtl::OUString aURL; + + if( ::avmedia::MediaWindow::executeMediaURLDialog( GetParent(), aURL, false ) ) + { + if( !::avmedia::MediaWindow::isMediaURL( aURL, true ) ) + ::avmedia::MediaWindow::executeFormatErrorBox( this ); + else + { + aExecItem.setURL( aURL ); + aExecItem.setState( MEDIASTATE_PLAY ); + } + } + } + break; + + case( AVMEDIA_TOOLBOXITEM_INSERT ): + { + MediaFloater* pFloater = AVMEDIA_MEDIAWINDOW(); + + if( pFloater ) + pFloater->dispatchCurrentURL(); + } + break; + + case( AVMEDIA_TOOLBOXITEM_PLAY ): + case( AVMEDIA_TOOLBOXITEM_PLAYFFW ): + { + aExecItem.setState( ( AVMEDIA_TOOLBOXITEM_PLAYFFW == p->GetCurItemId() ) ? MEDIASTATE_PLAYFFW : MEDIASTATE_PLAY ); + + if( maItem.getTime() == maItem.getDuration() ) + aExecItem.setTime( 0.0 ); + else + aExecItem.setTime( maItem.getTime() ); + } + break; + + case( AVMEDIA_TOOLBOXITEM_PAUSE ): + { + aExecItem.setState( MEDIASTATE_PAUSE ); + } + break; + + case( AVMEDIA_TOOLBOXITEM_STOP ): + { + aExecItem.setState( MEDIASTATE_STOP ); + aExecItem.setTime( 0.0 ); + } + break; + + case( AVMEDIA_TOOLBOXITEM_MUTE ): + { + aExecItem.setMute( !maMuteToolBox.IsItemChecked( AVMEDIA_TOOLBOXITEM_MUTE ) ); + } + break; + + case( AVMEDIA_TOOLBOXITEM_LOOP ): + { + aExecItem.setLoop( !maPlayToolBox.IsItemChecked( AVMEDIA_TOOLBOXITEM_LOOP ) ); + } + break; + + default: + break; + } + + if( aExecItem.getMaskSet() != AVMEDIA_SETMASK_NONE ) + execute( aExecItem ); + } + + update(); + p->Invalidate(); + + return 0; +} + +// ------------------------------------------------------------------------------ + +IMPL_LINK( MediaControl, implZoomSelectHdl, ListBox*, p ) +{ + if( p ) + { + MediaItem aExecItem; + ::com::sun::star::media::ZoomLevel eLevel; + + switch( p->GetSelectEntryPos() ) + { + case( AVMEDIA_ZOOMLEVEL_50 ): eLevel = ::com::sun::star::media::ZoomLevel_ZOOM_1_TO_2; break; + case( AVMEDIA_ZOOMLEVEL_100 ): eLevel = ::com::sun::star::media::ZoomLevel_ORIGINAL; break; + case( AVMEDIA_ZOOMLEVEL_200 ): eLevel = ::com::sun::star::media::ZoomLevel_ZOOM_2_TO_1; break; + case( AVMEDIA_ZOOMLEVEL_FIT ): eLevel = ::com::sun::star::media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT; break; + case( AVMEDIA_ZOOMLEVEL_SCALED ): eLevel = ::com::sun::star::media::ZoomLevel_FIT_TO_WINDOW; break; + + default: eLevel = ::com::sun::star::media::ZoomLevel_NOT_AVAILABLE; break; + } + + aExecItem.setZoom( eLevel ); + execute( aExecItem ); + update(); + } + + return 0; +} + +// ------------------------------------------------------------------------------ + +IMPL_LINK( MediaControl, implTimeoutHdl, Timer*, p ) +{ + update(); + maTimer.Start(); + + return 0; +} + +} diff --git a/avmedia/source/framework/mediacontrol.hrc b/avmedia/source/framework/mediacontrol.hrc new file mode 100644 index 000000000000..4a741f291b27 --- /dev/null +++ b/avmedia/source/framework/mediacontrol.hrc @@ -0,0 +1,87 @@ + /************************************************************************* + * + * $RCSfile: mediacontrol.hrc,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#define AVMEDIA_STR_PLAY 1024 +#define AVMEDIA_STR_PAUSE 1025 +#define AVMEDIA_STR_STOP 1026 +#define AVMEDIA_STR_ENDLESS 1027 +#define AVMEDIA_STR_ZOOM 1028 +#define AVMEDIA_STR_ZOOM_50 1029 +#define AVMEDIA_STR_ZOOM_100 1030 +#define AVMEDIA_STR_ZOOM_200 1031 +#define AVMEDIA_STR_ZOOM_FIT 1032 +#define AVMEDIA_STR_MUTE 1033 +#define AVMEDIA_STR_OPEN 1034 +#define AVMEDIA_STR_INSERT 1035 +#define AVMEDIA_STR_MEDIAPLAYER 1036 + +#define AVMEDIA_IMG_OPEN 2048 +#define AVMEDIA_IMG_PLAY 2049 +#define AVMEDIA_IMG_PAUSE 2050 +#define AVMEDIA_IMG_STOP 2051 +#define AVMEDIA_IMG_ENDLESS 2052 +#define AVMEDIA_IMG_INSERT 2053 +#define AVMEDIA_IMG_MUTE 2054 + +#define AVMEDIA_IMGLST 3072 +#define AVMEDIA_IMGLST_HC 3073 +#define AVMEDIA_IMGLST_L 3074 +#define AVMEDIA_IMGLST_L_HC 3075 diff --git a/avmedia/source/framework/mediacontrol.src b/avmedia/source/framework/mediacontrol.src new file mode 100644 index 000000000000..db0871c3d6af --- /dev/null +++ b/avmedia/source/framework/mediacontrol.src @@ -0,0 +1,240 @@ + /************************************************************************* + * + * $RCSfile: mediacontrol.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2. + * - Sun Industry Standards Source License Version 1. + * + * Sun Microsystems Inc., October, + * + * GNU Lesser General Public License Version 2. + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1. + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, +;5~ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "mediacontrol.hrc" + +String AVMEDIA_STR_OPEN +{ + Text[de] = "ffnen"; + Text[en-us] = "Open"; +}; + +// ------------------------------------------------------------------------------ + +String AVMEDIA_STR_INSERT +{ + Text [ de ] = "Zuweisen" ; + Text [ en-us ] = "Apply" ; +}; + +// ------------------------------------------------------------------------------ + +String AVMEDIA_STR_PLAY +{ + Text[de] = "Abspielen"; + Text[en-us] = "Play"; +}; + +// ------------------------------------------------------------------------------ + +String AVMEDIA_STR_PAUSE +{ + Text[de] = "Pause"; + Text[en-us] = "Pause"; +}; + +// ------------------------------------------------------------------------------ + +String AVMEDIA_STR_STOP +{ + Text[de] = "Stopp"; + Text[en-us] = "Stop"; +}; + +// ------------------------------------------------------------------------------ + +String AVMEDIA_STR_ENDLESS +{ + Text[de] = "Wiederholen"; + Text[en-us] = "Repeat"; +}; + +// ------------------------------------------------------------------------------ + +String AVMEDIA_STR_MUTE +{ + Text[de] = "Stumm"; + Text[en-us] = "Mute"; +}; + +// ------------------------------------------------------------------------------ + +String AVMEDIA_STR_ZOOM +{ + Text[de] = "Ansicht"; + Text[en-us] = "View"; +}; + +// ------------------------------------------------------------------------------ + +String AVMEDIA_STR_ZOOM_50 +{ + Text[de] = "50%"; + Text[en-us] = "50%"; +}; + +// ------------------------------------------------------------------------------ + +String AVMEDIA_STR_ZOOM_100 +{ + Text[de] = "100%"; + Text[en-us] = "100%"; +}; + +// ------------------------------------------------------------------------------ + +String AVMEDIA_STR_ZOOM_200 +{ + Text[de] = "200%"; + Text[en-us] = "200%"; +}; + +// ------------------------------------------------------------------------------ + +String AVMEDIA_STR_ZOOM_FIT +{ + Text[de] = "Angepat"; + Text[en-us] = "Scaled"; +}; + +// ------------------------------------------------------------------------------ + +String AVMEDIA_STR_MEDIAPLAYER +{ + Text[de] = "Mediaplayer"; + Text[en-us] = "Media Player"; +}; + +// ------------------------------------------------------------------------------ + +ImageList AVMEDIA_IMGLST +{ + Prefix = "av"; + MaskColor = Color{ Red = 0xff00; Green = 0x0000; Blue = 0xff00; }; + IdList = + { + AVMEDIA_IMG_OPEN; + AVMEDIA_IMG_PLAY; + AVMEDIA_IMG_PAUSE; + AVMEDIA_IMG_STOP; + AVMEDIA_IMG_ENDLESS; + AVMEDIA_IMG_INSERT; + AVMEDIA_IMG_MUTE; + }; + IdCount = 7; +}; + +// ------------------------------------------------------------------------------ + +ImageList AVMEDIA_IMGLST_L +{ + Prefix = "avl"; + MaskColor = Color{ Red = 0xff00; Green = 0x0000; Blue = 0xff00; }; + IdList = + { + AVMEDIA_IMG_OPEN; + AVMEDIA_IMG_PLAY; + AVMEDIA_IMG_PAUSE; + AVMEDIA_IMG_STOP; + AVMEDIA_IMG_ENDLESS; + AVMEDIA_IMG_INSERT; + AVMEDIA_IMG_MUTE; + }; + IdCount = 7; +}; + +// ------------------------------------------------------------------------------ + +ImageList AVMEDIA_IMGLST_HC +{ + Prefix = "avh"; + MaskColor = Color{ Red = 0xff00; Green = 0x0000; Blue = 0xff00; }; + IdList = + { + AVMEDIA_IMG_OPEN; + AVMEDIA_IMG_PLAY; + AVMEDIA_IMG_PAUSE; + AVMEDIA_IMG_STOP; + AVMEDIA_IMG_ENDLESS; + AVMEDIA_IMG_INSERT; + AVMEDIA_IMG_MUTE; + }; + IdCount = 7; +}; + +// ------------------------------------------------------------------------------ + +ImageList AVMEDIA_IMGLST_L_HC +{ + Prefix = "avlh"; + MaskColor = Color{ Red = 0xff00; Green = 0x0000; Blue = 0xff00; }; + IdList = + { + AVMEDIA_IMG_OPEN; + AVMEDIA_IMG_PLAY; + AVMEDIA_IMG_PAUSE; + AVMEDIA_IMG_STOP; + AVMEDIA_IMG_ENDLESS; + AVMEDIA_IMG_INSERT; + AVMEDIA_IMG_MUTE; + }; + IdCount = 7; +}; diff --git a/avmedia/source/framework/mediaitem.cxx b/avmedia/source/framework/mediaitem.cxx new file mode 100644 index 000000000000..31cee88611c6 --- /dev/null +++ b/avmedia/source/framework/mediaitem.cxx @@ -0,0 +1,363 @@ +/************************************************************************* + * + * $RCSfile: mediaitem.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "mediaitem.hxx" +#include <com/sun/star/uno/Sequence.hxx> + +using namespace ::com::sun::star; + +namespace avmedia +{ + +// ------------- +// - MediaItem - +// ------------- + +TYPEINIT1_AUTOFACTORY( MediaItem, ::SfxPoolItem ); + ::rtl::OUString maURL; + sal_uInt32 mnMaskSet; + MediaState meState; + double mfTime; + double mfDuration; + sal_Int16 mnVolumeDB; + sal_Bool mbLoop; + sal_Bool mbMute; + ::com::sun::star::media::ZoomLevel meZoom; + +// ------------------------------------------------------------------------------ + +MediaItem::MediaItem( USHORT nWhich, sal_uInt32 nMaskSet ) : + SfxPoolItem( nWhich ), + mnMaskSet( nMaskSet ), + meState( MEDIASTATE_STOP ), + mfDuration( 0.0 ), + mfTime( 0.0 ), + mnVolumeDB( 0 ), + mbLoop( false ), + mbMute( false ), + meZoom( ::com::sun::star::media::ZoomLevel_NOT_AVAILABLE ) +{ +} + +// ------------------------------------------------------------------------------ + +MediaItem::MediaItem( const MediaItem& rItem ) : + SfxPoolItem( rItem ), + maURL( rItem.maURL ), + mnMaskSet( rItem.mnMaskSet ), + meState( rItem.meState ), + mfDuration( rItem.mfDuration ), + mfTime( rItem.mfTime ), + mnVolumeDB( rItem.mnVolumeDB ), + mbLoop( rItem.mbLoop ), + mbMute( rItem.mbMute ), + meZoom( rItem.meZoom ) +{ +} + +// ------------------------------------------------------------------------------ + +MediaItem::~MediaItem() +{ +} + +// ------------------------------------------------------------------------------ + +int MediaItem::operator==( const SfxPoolItem& rItem ) const +{ + DBG_ASSERT( SfxPoolItem::operator==(rItem), "unequal types" ); + return( mnMaskSet == static_cast< const MediaItem& >( rItem ).mnMaskSet && + maURL == static_cast< const MediaItem& >( rItem ).maURL && + meState == static_cast< const MediaItem& >( rItem ).meState && + mfDuration == static_cast< const MediaItem& >( rItem ).mfDuration && + mfTime == static_cast< const MediaItem& >( rItem ).mfTime && + mnVolumeDB == static_cast< const MediaItem& >( rItem ).mnVolumeDB && + mbLoop == static_cast< const MediaItem& >( rItem ).mbLoop && + mbMute == static_cast< const MediaItem& >( rItem ).mbMute && + meZoom == static_cast< const MediaItem& >( rItem ).meZoom ); +} + +// ------------------------------------------------------------------------------ + +SfxPoolItem* MediaItem::Clone( SfxItemPool* pPool ) const +{ + return new MediaItem( *this ); +} + +//------------------------------------------------------------------------ + +SfxItemPresentation MediaItem::GetPresentation( SfxItemPresentation ePres, + SfxMapUnit eCoreUnit, + SfxMapUnit ePresUnit, + XubString& rText, + const IntlWrapper *pIntl ) const +{ + rText.Erase(); + return SFX_ITEM_PRESENTATION_NONE; +} + +//------------------------------------------------------------------------ + +BOOL MediaItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId ) const +{ + uno::Sequence< uno::Any > aSeq( 9 ); + + aSeq[ 0 ] <<= maURL; + aSeq[ 1 ] <<= mnMaskSet; + aSeq[ 2 ] <<= static_cast< sal_Int32 >( meState ); + aSeq[ 3 ] <<= mfTime; + aSeq[ 4 ] <<= mfDuration; + aSeq[ 5 ] <<= mnVolumeDB; + aSeq[ 6 ] <<= mbLoop; + aSeq[ 7 ] <<= mbMute; + aSeq[ 8 ] <<= meZoom; + + rVal <<= aSeq; + + return true; +} + +//------------------------------------------------------------------------ + +BOOL MediaItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE nMemberId ) +{ + uno::Sequence< uno::Any > aSeq; + BOOL bRet = false; + + if( ( rVal >>= aSeq ) && ( aSeq.getLength() == 9 ) ) + { + sal_Int32 nInt32; + + aSeq[ 0 ] >>= maURL; + aSeq[ 1 ] >>= mnMaskSet; + aSeq[ 2 ] >>= nInt32; meState = static_cast< MediaState >( nInt32 ); + aSeq[ 3 ] >>= mfTime; + aSeq[ 4 ] >>= mfDuration; + aSeq[ 5 ] >>= mnVolumeDB; + aSeq[ 6 ] >>= mbLoop; + aSeq[ 7 ] >>= mbMute; + aSeq[ 8 ] >>= meZoom; + + bRet = true; + } + + return bRet; +} + +//------------------------------------------------------------------------ + +void MediaItem::merge( const MediaItem& rMediaItem ) +{ + const sal_uInt32 nMaskSet = rMediaItem.getMaskSet(); + + if( AVMEDIA_SETMASK_URL & nMaskSet ) + setURL( rMediaItem.getURL() ); + + if( AVMEDIA_SETMASK_STATE & nMaskSet ) + setState( rMediaItem.getState() ); + + if( AVMEDIA_SETMASK_DURATION & nMaskSet ) + setDuration( rMediaItem.getDuration() ); + + if( AVMEDIA_SETMASK_TIME & nMaskSet ) + setTime( rMediaItem.getTime() ); + + if( AVMEDIA_SETMASK_LOOP & nMaskSet ) + setLoop( rMediaItem.isLoop() ); + + if( AVMEDIA_SETMASK_MUTE & nMaskSet ) + setMute( rMediaItem.isMute() ); + + if( AVMEDIA_SETMASK_VOLUMEDB & nMaskSet ) + setVolumeDB( rMediaItem.getVolumeDB() ); + + if( AVMEDIA_SETMASK_ZOOM & nMaskSet ) + setZoom( rMediaItem.getZoom() ); +} + +//------------------------------------------------------------------------ + +sal_uInt32 MediaItem::getMaskSet() const +{ + return mnMaskSet; +} + +//------------------------------------------------------------------------ + +void MediaItem::setURL( const ::rtl::OUString& rURL ) +{ + maURL = rURL; + mnMaskSet |= AVMEDIA_SETMASK_URL; +} + +//------------------------------------------------------------------------ + +const ::rtl::OUString& MediaItem::getURL() const +{ + return maURL; +} + +//------------------------------------------------------------------------ + +void MediaItem::setState( MediaState eState ) +{ + meState = eState; + mnMaskSet |= AVMEDIA_SETMASK_STATE; +} + +//------------------------------------------------------------------------ + +MediaState MediaItem::getState() const +{ + return meState; +} + +//------------------------------------------------------------------------ + +void MediaItem::setDuration( double fDuration ) +{ + mfDuration = fDuration; + mnMaskSet |= AVMEDIA_SETMASK_DURATION; +} + +//------------------------------------------------------------------------ + +double MediaItem::getDuration() const +{ + return mfDuration; +} + +//------------------------------------------------------------------------ + +void MediaItem::setTime( double fTime ) +{ + mfTime = fTime; + mnMaskSet |= AVMEDIA_SETMASK_TIME; +} + +//------------------------------------------------------------------------ + +double MediaItem::getTime() const +{ + return mfTime; +} + +//------------------------------------------------------------------------ + +void MediaItem::setLoop( sal_Bool bLoop ) +{ + mbLoop = bLoop; + mnMaskSet |= AVMEDIA_SETMASK_LOOP; +} + +//------------------------------------------------------------------------ + +sal_Bool MediaItem::isLoop() const +{ + return mbLoop; +} + +//------------------------------------------------------------------------ + +void MediaItem::setMute( sal_Bool bMute ) +{ + mbMute = bMute; + mnMaskSet |= AVMEDIA_SETMASK_MUTE; +} + +//------------------------------------------------------------------------ + +sal_Bool MediaItem::isMute() const +{ + return mbMute; +} + +//------------------------------------------------------------------------ + +void MediaItem::setVolumeDB( sal_Int16 nDB ) +{ + mnVolumeDB = nDB; + mnMaskSet |= AVMEDIA_SETMASK_VOLUMEDB; +} + +//------------------------------------------------------------------------ + +sal_Int16 MediaItem::getVolumeDB() const +{ + return mnVolumeDB; +} + +//------------------------------------------------------------------------ + +void MediaItem::setZoom( ::com::sun::star::media::ZoomLevel eZoom ) +{ + meZoom = eZoom; + mnMaskSet |= AVMEDIA_SETMASK_ZOOM; +} + +//------------------------------------------------------------------------ + +::com::sun::star::media::ZoomLevel MediaItem::getZoom() const +{ + return meZoom; +} + +} diff --git a/avmedia/source/framework/mediamisc.cxx b/avmedia/source/framework/mediamisc.cxx new file mode 100644 index 000000000000..1ab56407ff09 --- /dev/null +++ b/avmedia/source/framework/mediamisc.cxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * $RCSfile: mediamisc.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <tools/resmgr.hxx> +#include <svtools/solar.hrc> +#include <vcl/svapp.hxx> + +namespace avmedia { + +ResMgr* GetResMgr() +{ + static ResMgr* pResMgr = NULL; + + if( !pResMgr ) + { + ByteString aResMgrName( "avmedia" ); + + aResMgrName += ByteString::CreateFromInt32( SOLARUPD ); + pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() ); + } + + return pResMgr; +} + +} // namespace avemdia diff --git a/avmedia/source/framework/mediaplayer.cxx b/avmedia/source/framework/mediaplayer.cxx new file mode 100644 index 000000000000..cba99382d2a4 --- /dev/null +++ b/avmedia/source/framework/mediaplayer.cxx @@ -0,0 +1,192 @@ +/************************************************************************* + * + * $RCSfile: mediaplayer.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "mediaplayer.hxx" +#include "mediawindow.hxx" +#include "mediaitem.hxx" +#include "mediamisc.hxx" +#include "mediacontrol.hrc" + +#include <svtools/stritem.hxx> +#include <sfx2/app.hxx> +#include <sfx2/sfxsids.hrc> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> + +namespace avmedia +{ + +// --------------- +// - MediaPlayer - +// --------------- + +MediaPlayer::MediaPlayer( Window* pParent, USHORT nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo ) : + SfxChildWindow( pParent, nId ) +{ + pWindow = new MediaFloater( pBindings, this, pParent ); + eChildAlignment = SFX_ALIGN_NOALIGNMENT; + static_cast< MediaFloater* >( pWindow )->Initialize( pInfo ); +}; + +// ----------------------------------------------------------------------------- + +MediaPlayer::~MediaPlayer() +{ +} + +// ----------------------------------------------------------------------------- + +SFX_IMPL_DOCKINGWINDOW( MediaPlayer, SID_AVMEDIA_PLAYER ) + +// ---------------- +// - MediaFloater - +// ---------------- + +MediaFloater::MediaFloater( SfxBindings* pBindings, SfxChildWindow* pCW, Window* pParent ) : + SfxDockingWindow( pBindings, pCW, pParent, WB_CLOSEABLE | WB_MOVEABLE | WB_SIZEABLE | WB_DOCKABLE ), + mpMediaWindow( new MediaWindow( this, true ) ) +{ + const Size aSize( 378, 256 ); + + SetPosSizePixel( Point( 0, 0 ), aSize ); + SetMinOutputSizePixel( aSize ); + SetText( String( AVMEDIA_RESID( AVMEDIA_STR_MEDIAPLAYER ) ) ); + implInit(); + mpMediaWindow->show(); +} + +// ----------------------------------------------------------------------------- + +MediaFloater::~MediaFloater() +{ + delete mpMediaWindow; + mpMediaWindow = NULL; +} + +// ----------------------------------------------------------------------------- + +void MediaFloater::implInit() +{ +} + +// ------------------------------------------------------------------------- + +void MediaFloater::Resize() +{ + SfxDockingWindow::Resize(); + + if( mpMediaWindow ) + mpMediaWindow->setPosSize( Rectangle( Point(), GetOutputSizePixel() ) ); +} + +// ----------------------------------------------------------------------------- + +void MediaFloater::ToggleFloatingMode() +{ + ::avmedia::MediaItem aRestoreItem; + + mpMediaWindow->updateMediaItem( aRestoreItem ); + delete mpMediaWindow; + mpMediaWindow = NULL; + + SfxDockingWindow::ToggleFloatingMode(); + + mpMediaWindow = new MediaWindow( this, true ); + mpMediaWindow->setPosSize( Rectangle( Point(), GetOutputSizePixel() ) ); + mpMediaWindow->executeMediaItem( aRestoreItem ); + mpMediaWindow->show(); +} + +// ----------------------------------------------------------------------------- + +void MediaFloater::setURL( const ::rtl::OUString& rURL, bool bPlayImmediately ) +{ + if( mpMediaWindow ) + { + mpMediaWindow->setURL( rURL ); + + if( mpMediaWindow->isValid() && bPlayImmediately ) + mpMediaWindow->start(); + } +} + +// ----------------------------------------------------------------------------- + +const ::rtl::OUString& MediaFloater::getURL() const +{ + static const ::rtl::OUString aEmptyStr; + return( mpMediaWindow ? mpMediaWindow->getURL() : aEmptyStr ); +} + +// ----------------------------------------------------------------------------- + +void MediaFloater::dispatchCurrentURL() +{ + SfxDispatcher* pDispatcher = GetBindings().GetDispatcher(); + + if( pDispatcher ) + { + const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, getURL() ); + pDispatcher->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_RECORD, &aMediaURLItem, 0L ); + } +} + +} diff --git a/avmedia/source/framework/mediatoolbox.cxx b/avmedia/source/framework/mediatoolbox.cxx new file mode 100644 index 000000000000..4df26950520c --- /dev/null +++ b/avmedia/source/framework/mediatoolbox.cxx @@ -0,0 +1,199 @@ +/************************************************************************* + * + * $RCSfile: mediatoolbox.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "mediatoolbox.hxx" +#include "mediaitem.hxx" +#include "mediacontrol.hxx" + +#include <sfx2/app.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/sfxsids.hrc> + +using namespace ::com::sun::star; + +namespace avmedia +{ + +// ----------------------- +// - MediaToolboxControl - +// ----------------------- + +class MediaToolBoxControl_Impl : public MediaControl +{ +public: + + MediaToolBoxControl_Impl( Window& rParent, MediaToolBoxControl& rControl ); + ~MediaToolBoxControl_Impl(); + + void update(); + void execute( const MediaItem& rItem ); + +private: + + MediaToolBoxControl* mpToolBoxControl; +}; + +// --------------------------------------------------------------------- + +MediaToolBoxControl_Impl::MediaToolBoxControl_Impl( Window& rParent, MediaToolBoxControl& rControl ) : + MediaControl( &rParent, MEDIACONTROLSTYLE_SINGLELINE ), + mpToolBoxControl( &rControl ) +{ + SetSizePixel( getMinSizePixel() ); +} + +// --------------------------------------------------------------------- + +MediaToolBoxControl_Impl::~MediaToolBoxControl_Impl() +{ +} + +// --------------------------------------------------------------------- + +void MediaToolBoxControl_Impl::update() +{ + mpToolBoxControl->implUpdateMediaControl(); +} + +// --------------------------------------------------------------------- + +void MediaToolBoxControl_Impl::execute( const MediaItem& rItem ) +{ + mpToolBoxControl->implExecuteMediaControl( rItem ); +} + +// ----------------------- +// - MediaToolBoxControl - +// ----------------------- + +SFX_IMPL_TOOLBOX_CONTROL( ::avmedia::MediaToolBoxControl, ::avmedia::MediaItem ); + +// ----------------------------------------------------------------------------- + +MediaToolBoxControl::MediaToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) : + SfxToolBoxControl( nSlotId, nId, rTbx ) +{ + rTbx.Invalidate(); +} + +// ----------------------------------------------------------------------------- + +MediaToolBoxControl::~MediaToolBoxControl() +{ +} + +// ----------------------------------------------------------------------------- + +void MediaToolBoxControl::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) + +{ + MediaToolBoxControl_Impl* pCtrl = static_cast< MediaToolBoxControl_Impl* >( GetToolBox().GetItemWindow( GetId() ) ); + + DBG_ASSERT( pCtrl, "MediaToolBoxControl::StateChanged: media control not found" ); + + if( eState == SFX_ITEM_DISABLED ) + { + pCtrl->Disable(); + pCtrl->SetText( String() ); + } + else + { + pCtrl->Enable(); + + const MediaItem* pMediaItem = PTR_CAST( MediaItem, pState ); + + if( pMediaItem && ( SFX_ITEM_AVAILABLE == eState ) ) + pCtrl->setState( *pMediaItem ); + } +} + +// ----------------------------------------------------------------------------- + +Window* MediaToolBoxControl::CreateItemWindow( Window *pParent ) +{ + return( pParent ? new MediaToolBoxControl_Impl( *pParent, *this ) : NULL ); +} + +// ----------------------------------------------------------------------------- + +void MediaToolBoxControl::implUpdateMediaControl() +{ + updateStatus( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AVMediaToolBox" ) ) ); +} + +// ----------------------------------------------------------------------------- + +void MediaToolBoxControl::implExecuteMediaControl( const MediaItem& rItem ) +{ + MediaItem aExecItem( SID_AVMEDIA_TOOLBOX ); + uno::Sequence< beans::PropertyValue > aArgs( 1 ); + uno::Any aAny; + + aExecItem.merge( rItem ); + aExecItem.QueryValue( aAny ); + aArgs[ 0 ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AVMediaToolBox" ) ); + aArgs[ 0 ].Value = aAny; + + Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AVMediaToolBox" ) ), aArgs ); +} + +} diff --git a/avmedia/source/inc/mediamisc.hxx b/avmedia/source/inc/mediamisc.hxx new file mode 100644 index 000000000000..5a1c957b5ee1 --- /dev/null +++ b/avmedia/source/inc/mediamisc.hxx @@ -0,0 +1,76 @@ +/************************************************************************* + * + * $RCSfile: mediamisc.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +class ResMgr; + +#define AVMEDIA_RESID( nId ) ResId( nId, ::avmedia::GetResMgr() ) + +#ifdef WNT +#define AVMEDIA_MANAGER_SERVICE_NAME "com.sun.star.media.Manager_DirectX" +#else +#define AVMEDIA_MANAGER_SERVICE_NAME "com.sun.star.media.Manager_Java" +#endif + + +namespace avmedia +{ + ResMgr* GetResMgr(); +} diff --git a/avmedia/source/java/Manager.java b/avmedia/source/java/Manager.java new file mode 100644 index 000000000000..747d41cd8d00 --- /dev/null +++ b/avmedia/source/java/Manager.java @@ -0,0 +1,173 @@ +/************************************************************************* + * + * $RCSfile: Manager.java,v $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// UNO +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.IQueryInterface; +import com.sun.star.lang.XInitialization; + +// media +import com.sun.star.media.*; + +public class Manager implements com.sun.star.lang.XServiceInfo, + com.sun.star.lang.XTypeProvider, + com.sun.star.media.XManager + +{ + public Manager() + { + } + + // ------------ + // - XManager - + // ------------ + + public com.sun.star.media.XPlayer createPlayer( String aURL ) + { + javax.media.Player aPlayer = null; + + try + { + aPlayer = javax.media.Manager.createRealizedPlayer( new java.net.URL( aURL ) ); + } + catch( java.net.MalformedURLException e ) + { + } + catch( java.io.IOException e ) + { + } + catch( javax.media.NoPlayerException e ) + { + } + catch( javax.media.CannotRealizeException e ) + { + } + catch( java.lang.Exception e ) + { + } + + if( aPlayer != null ) + { + return new Player( aPlayer ); + } + else + return null; + } + + // ---------------- + // - XServiceInfo - + // ---------------- + + private static final String s_implName = "com.sun.star.comp.media.Manager_Java"; + private static final String s_serviceName = "com.sun.star.media.Manager_Java"; + + public synchronized String getImplementationName() + { + return s_implName; + } + + // ------------------------------------------------------------------------- + + public synchronized String [] getSupportedServiceNames() + { + return new String [] { s_serviceName }; + } + + // ------------------------------------------------------------------------- + + public synchronized boolean supportsService( String serviceName ) + { + return serviceName.equals( s_serviceName ); + } + + // ----------------- + // - XTypeProvider - + // ----------------- + protected byte[] maImplementationId; + + public com.sun.star.uno.Type[] getTypes() + { + com.sun.star.uno.Type[] retValue = new com.sun.star.uno.Type[ 3 ]; + + retValue[ 0 ]= new com.sun.star.uno.Type( com.sun.star.lang.XServiceInfo.class ); + retValue[ 1 ]= new com.sun.star.uno.Type( com.sun.star.lang.XTypeProvider.class ); + retValue[ 2 ]= new com.sun.star.uno.Type( com.sun.star.media.XManager.class ); + + return retValue; + } + + // ------------------------------------------------------------------------- + + synchronized public byte[] getImplementationId() + { + if( maImplementationId == null) + { + maImplementationId = new byte[ 16 ]; + + int hash = hashCode(); + + maImplementationId[ 0 ] = (byte)(hash & 0xff); + maImplementationId[ 1 ] = (byte)((hash >>> 8) & 0xff); + maImplementationId[ 2 ] = (byte)((hash >>> 16) & 0xff); + maImplementationId[ 3 ] = (byte)((hash >>>24) & 0xff); + } + + return maImplementationId; + } +} diff --git a/avmedia/source/java/Player.java b/avmedia/source/java/Player.java new file mode 100644 index 000000000000..185c60782f1e --- /dev/null +++ b/avmedia/source/java/Player.java @@ -0,0 +1,326 @@ +/************************************************************************* + * + * $RCSfile: Player.java,v $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// UNO +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.IQueryInterface; +import com.sun.star.lang.XInitialization; + +// awt +import com.sun.star.awt.*; + +// media +import com.sun.star.media.*; + +public class Player implements javax.media.ControllerListener, + com.sun.star.lang.XServiceInfo, + com.sun.star.media.XPlayer + + +{ + private String maURL; + private javax.media.Player maPlayer; + private javax.media.GainControl maGainControl; + private boolean mbStarted = false; + private boolean mbLooping = false; + + // ------------------------------------------------------------------------- + + public Player( javax.media.Player aPlayer ) + { + maPlayer = aPlayer; + maPlayer.addControllerListener( this ); + maGainControl = maPlayer.getGainControl(); + } + + // ------------------------------------------------------------------------- + + public synchronized void controllerUpdate( javax.media.ControllerEvent aEvt ) + { + if( aEvt instanceof javax.media.EndOfMediaEvent || + aEvt instanceof javax.media.StopAtTimeEvent ) + { + mbStarted = false; + + if( mbLooping ) + { + setMediaTime( 0.0 ); + start(); + } + else if( aEvt instanceof javax.media.EndOfMediaEvent ) + setMediaTime( getDuration() ); + } + } + + // ----------- + // - XPlayer - + // ----------- + + public synchronized void start() + { + if( !mbStarted ) + { + maPlayer.start(); + mbStarted = true; + } + } + + // ------------------------------------------------------------------------- + + public synchronized void stop() + { + if( mbStarted ) + { + maPlayer.stop(); + mbStarted = false; + } + } + + // ------------------------------------------------------------------------- + + public synchronized boolean isPlaying() + { + return mbStarted; + } + + // ------------------------------------------------------------------------- + + public synchronized double getDuration() + { + return maPlayer.getDuration().getSeconds(); + } + + // ------------------------------------------------------------------------- + + public synchronized void setMediaTime( double fTime ) + { + if( fTime >= 0.0 && fTime <= getDuration() ) + maPlayer.setMediaTime( new javax.media.Time( fTime ) ); + } + + // ------------------------------------------------------------------------- + + public synchronized double getMediaTime() + { + return maPlayer.getMediaTime().getSeconds(); + } + + // ------------------------------------------------------------------------- + + public synchronized void setStopTime( double fTime ) + { + boolean bOldStarted = mbStarted; + + if( mbStarted ) + stop(); + + maPlayer.setStopTime( new javax.media.Time( fTime ) ); + + if( bOldStarted ) + start(); + } + + // ------------------------------------------------------------------------- + + public synchronized double getStopTime() + { + return maPlayer.getStopTime().getSeconds(); + } + + // ------------------------------------------------------------------------- + + public synchronized void setRate( double fRate ) + { + boolean bOldStarted = mbStarted; + + if( mbStarted ) + stop(); + + maPlayer.setRate( (float) fRate ); + + if( bOldStarted ) + start(); + } + + // ------------------------------------------------------------------------- + + public synchronized double getRate() + { + return (double) maPlayer.getRate(); + } + + // ------------------------------------------------------------------------- + + public synchronized void setPlaybackLoop( boolean bSet ) + { + mbLooping = bSet; + } + + // ------------------------------------------------------------------------- + + public synchronized boolean isPlaybackLoop() + { + return mbLooping; + } + + // ------------------------------------------------------------------------- + + public synchronized void setVolumeDB( short nVolumeDB ) + { + if( maGainControl != null ) + maGainControl.setDB( nVolumeDB ); + } + + // ------------------------------------------------------------------------- + + public synchronized short getVolumeDB() + { + return( maGainControl != null ? (short) maGainControl.getDB() : 0 ); + } + + // ------------------------------------------------------------------------- + + public synchronized void setMute( boolean bSet ) + { + if( maGainControl != null ) + maGainControl.setMute( bSet ); + } + + // ------------------------------------------------------------------------- + + public synchronized boolean isMute() + { + return( maGainControl != null ? maGainControl.getMute() : false ); + } + + // ------------------------------------------------------------------------- + + public synchronized com.sun.star.awt.Size getPreferredPlayerWindowSize() + { + java.awt.Component aVisualComponent = maPlayer.getVisualComponent(); + java.awt.Component aControlComponent = maPlayer.getControlPanelComponent(); + com.sun.star.awt.Size aSize = new com.sun.star.awt.Size( 0, 0 ); + + if( aVisualComponent != null ) + { + java.awt.Dimension aDim = aVisualComponent.getPreferredSize(); + + aSize.Width = Math.max( aDim.width, aSize.Width ); + aSize.Height += aDim.height; + } + + if( aControlComponent != null ) + { + java.awt.Dimension aDim = aControlComponent.getPreferredSize(); + + aSize.Width = Math.max( aDim.width, aSize.Width ); + aSize.Height += aDim.height; + } + + return aSize; + } + + // ------------------------------------------------------------------------- + + public synchronized com.sun.star.media.XPlayerWindow createPlayerWindow( java.lang.Object[] aArgs ) + { + try + { + com.sun.star.media.XPlayerWindow xPlayerWindow = ( ( ( aArgs.length > 1 ) && ( AnyConverter.toInt( aArgs[ 0 ] ) > 0 ) ) ? + new PlayerWindow( aArgs, maPlayer ) : + null ); + + // check if it is a real player window (video window) + if( xPlayerWindow != null && xPlayerWindow.getZoomLevel() == com.sun.star.media.ZoomLevel.NOT_AVAILABLE ) + xPlayerWindow = null; + + return xPlayerWindow; + } + catch( com.sun.star.lang.IllegalArgumentException e ) + { + return null; + } + } + + // ---------------- + // - XServiceInfo - + // ---------------- + + private static final String s_implName = "com.sun.star.comp.Player_Java"; + private static final String s_serviceName = "com.sun.star.media.Player_Java"; + + public synchronized String getImplementationName() + { + return s_implName; + } + + // ------------------------------------------------------------------------- + + public synchronized String [] getSupportedServiceNames() + { + return new String [] { s_serviceName }; + } + + // ------------------------------------------------------------------------- + + public synchronized boolean supportsService( String serviceName ) + { + return serviceName.equals( s_serviceName ); + } +} diff --git a/avmedia/source/java/PlayerWindow.java b/avmedia/source/java/PlayerWindow.java new file mode 100644 index 000000000000..26f3e131905e --- /dev/null +++ b/avmedia/source/java/PlayerWindow.java @@ -0,0 +1,628 @@ +/************************************************************************* + * + * $RCSfile: PlayerWindow.java,v $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.IQueryInterface; +import com.sun.star.lang.XInitialization; +import com.sun.star.lang.XEventListener; +import com.sun.star.awt.*; +import com.sun.star.media.*; + +// ----------------- +// - Player Window - +// ----------------- + +public class PlayerWindow implements java.awt.event.KeyListener, + java.awt.event.MouseListener, + java.awt.event.MouseMotionListener, + java.awt.event.FocusListener, + com.sun.star.lang.XServiceInfo, + com.sun.star.media.XPlayerWindow +{ + private WindowAdapter maFrame; + private javax.media.Player maPlayer; + private com.sun.star.media.ZoomLevel meZoomLevel = com.sun.star.media.ZoomLevel.ORIGINAL; + private boolean mbShowControls = false; + + + // ------------------------------------------------------------------------- + + public PlayerWindow( java.lang.Object[] aArgs, javax.media.Player aPlayer ) + { + try + { + if( aArgs.length > 1 ) + { + com.sun.star.awt.Rectangle aBoundRect = (com.sun.star.awt.Rectangle) aArgs[ 1 ]; + + maFrame = new WindowAdapter( AnyConverter.toInt( aArgs[ 0 ] ) ); + maFrame.setPosSize( aBoundRect.X, aBoundRect.Y, aBoundRect.Width, aBoundRect.Height, (short) 0 ); + + if( aArgs.length > 2 ) + mbShowControls = AnyConverter.toBoolean( aArgs[ 2 ] ); + + java.awt.Panel aPanel = new java.awt.Panel( new java.awt.BorderLayout() ); + + aPanel.setLayout( null ); + aPanel.setBackground( java.awt.Color.black ); + aPanel.addKeyListener( this ); + aPanel.addMouseListener( this ); + aPanel.addMouseMotionListener( this ); + + if( mbShowControls ) + { + java.awt.Component aControlComponent = aPlayer.getControlPanelComponent(); + + if( aControlComponent != null ) + aPanel.add( aControlComponent ); + else + mbShowControls = false; + } + + java.awt.Component aVisualComponent = aPlayer.getVisualComponent(); + + if( aVisualComponent != null ) + { + aVisualComponent.addKeyListener( this ); + aVisualComponent.addMouseListener( this ); + aVisualComponent.addMouseMotionListener( this ); + aVisualComponent.addFocusListener( this ); + aPanel.add( aVisualComponent ); + } + else + meZoomLevel = com.sun.star.media.ZoomLevel.NOT_AVAILABLE; + + if( maFrame.getJavaFrame() != null ) + maFrame.getJavaFrame().add( aPanel ); + + LayoutComponents(); + } + } + catch( com.sun.star.lang.IllegalArgumentException e ) + { + } + } + + // ------------------------------------------------------------------------- + + protected synchronized void LayoutComponents() + { + if( maFrame.getJavaFrame() != null ) + { + java.awt.Panel aPanel = (java.awt.Panel) maFrame.getJavaFrame().getComponent( 0 ); + int nW = maFrame.getJavaFrame().getWidth(); + int nH = maFrame.getJavaFrame().getHeight(); + int nControlH = 0; + + aPanel.setBounds( 0, 0, nW, nH ); + + if( mbShowControls ) + { + java.awt.Component aControlComponent = aPanel.getComponent( 0 ); + + if( aControlComponent != null ) + { + java.awt.Dimension aControlDimension = aControlComponent.getPreferredSize(); + + nControlH = Math.min( nH, aControlDimension.height ); + aControlComponent.setBounds( 0, nH - nControlH, nW, nControlH ); + } + } + + if( com.sun.star.media.ZoomLevel.NOT_AVAILABLE != meZoomLevel ) + { + java.awt.Component aVisualComponent = aPanel.getComponent( mbShowControls ? 1 : 0 ); + + if( aVisualComponent != null ) + { + java.awt.Dimension aPrefDim = aVisualComponent.getPreferredSize(); + int nVideoW = nW, nVideoH = ( nH - nControlH ); + int nX = 0, nY = 0, nWidth = 0, nHeight = 0; + boolean bDone = false, bZoom = false; + + if( com.sun.star.media.ZoomLevel.ORIGINAL == meZoomLevel ) + { + bZoom = true; + } + else if( com.sun.star.media.ZoomLevel.ZOOM_1_TO_4 == meZoomLevel ) + { + aPrefDim.width >>= 2; + aPrefDim.height >>= 2; + bZoom = true; + } + else if( com.sun.star.media.ZoomLevel.ZOOM_1_TO_2 == meZoomLevel ) + { + aPrefDim.width >>= 1; + aPrefDim.height >>= 1; + bZoom = true; + } + else if( com.sun.star.media.ZoomLevel.ZOOM_2_TO_1 == meZoomLevel ) + { + aPrefDim.width <<= 1; + aPrefDim.height <<= 1; + bZoom = true; + } + else if( com.sun.star.media.ZoomLevel.ZOOM_4_TO_1 == meZoomLevel ) + { + aPrefDim.width <<= 2; + aPrefDim.height <<= 2; + bZoom = true; + } + else if( com.sun.star.media.ZoomLevel.FIT_TO_WINDOW == meZoomLevel ) + { + nWidth = nVideoW; + nHeight = nVideoH; + bDone = true; + } + + if( bZoom ) + { + if( ( aPrefDim.width <= nVideoW ) && ( aPrefDim.height <= nVideoH ) ) + { + nX = ( nVideoW - aPrefDim.width ) >> 1; + nY = ( nVideoH - aPrefDim.height ) >> 1; + nWidth = aPrefDim.width; + nHeight = aPrefDim.height; + bDone = true; + } + } + + if( !bDone ) + { + if( aPrefDim.width > 0 && aPrefDim.height > 0 && nVideoW > 0 && nVideoH > 0 ) + { + double fPrefWH = (double) aPrefDim.width / aPrefDim.height; + + if( fPrefWH < ( (double) nVideoW / nVideoH ) ) + nVideoW = (int)( nVideoH * fPrefWH ); + else + nVideoH = (int)( nVideoW / fPrefWH ); + + nX = ( nW - nVideoW ) >> 1; + nY = ( nH - nControlH - nVideoH ) >> 1; + nWidth = nVideoW; + nHeight = nVideoH; + } + else + nX = nY = nWidth = nHeight = 0; + } + + aVisualComponent.setBounds( nX, nY, nWidth, nHeight ); + aVisualComponent.requestFocus(); + } + else + aPanel.requestFocus(); + } + else + aPanel.requestFocus(); + } + } + + // ------------------------------------------------------------------------- + + private void implFireMouseEvent( java.awt.event.MouseEvent aEvt ) + { + if( aEvt.getSource() != null && + aEvt.getSource() instanceof java.awt.Component ) + { + aEvt.translatePoint( ( (java.awt.Component) aEvt.getSource() ).getX(), + ( (java.awt.Component) aEvt.getSource() ).getY() ); + } + + maFrame.fireMouseEvent( aEvt ); + } + + // --------------- + // - KeyListener - + // --------------- + + public void keyPressed( java.awt.event.KeyEvent aEvt ) + { + maFrame.fireKeyEvent( aEvt ); + } + + // ------------------------------------------------------------------------- + + public void keyReleased( java.awt.event.KeyEvent aEvt ) + { + maFrame.fireKeyEvent( aEvt ); + } + + // ------------------------------------------------------------------------- + + public void keyTyped( java.awt.event.KeyEvent aEvt ) + { + maFrame.fireKeyEvent( aEvt ); + } + + // ----------------- + // - MouseListener - + // ----------------- + + public void mousePressed( java.awt.event.MouseEvent aEvt ) + { + implFireMouseEvent( aEvt ); + } + + // ------------------------------------------------------------------------- + + public void mouseClicked( java.awt.event.MouseEvent aEvt ) + { + implFireMouseEvent( aEvt ); + } + + // ------------------------------------------------------------------------- + + public void mouseEntered( java.awt.event.MouseEvent aEvt ) + { + implFireMouseEvent( aEvt ); + } + + // ------------------------------------------------------------------------- + + public void mouseExited( java.awt.event.MouseEvent aEvt ) + { + implFireMouseEvent( aEvt ); + } + + // ------------------------------------------------------------------------- + + public void mouseReleased( java.awt.event.MouseEvent aEvt ) + { + implFireMouseEvent( aEvt ); + } + + // ----------------------- + // - MouseMotionListener - + // ----------------------- + + public void mouseDragged( java.awt.event.MouseEvent aEvt ) + { + implFireMouseEvent( aEvt ); + } + + // ------------------------------------------------------------------------- + + public void mouseMoved( java.awt.event.MouseEvent aEvt ) + { + implFireMouseEvent( aEvt ); + } + + // ----------------------- + // - FocusListener - + // ----------------------- + + public void focusGained( java.awt.event.FocusEvent aEvt ) + { + if( maFrame.getJavaFrame() != null ) + maFrame.fireFocusEvent( aEvt ); + } + + // ------------------------------------------------------------------------- + + public void focusLost( java.awt.event.FocusEvent aEvt ) + { + if( maFrame.getJavaFrame() != null ) + maFrame.fireFocusEvent( aEvt ); + } + + // ----------------- + // - XPlayerWindow - + // ----------------- + + public synchronized void update() + { + if( maFrame.getJavaFrame() != null ) + maFrame.getJavaFrame().repaint(); + } + + // ------------------------------------------------------------------------- + + public synchronized boolean setZoomLevel( com.sun.star.media.ZoomLevel eZoomLevel ) + { + boolean bRet = false; + + if( com.sun.star.media.ZoomLevel.NOT_AVAILABLE != meZoomLevel && + com.sun.star.media.ZoomLevel.NOT_AVAILABLE != eZoomLevel ) + { + if( eZoomLevel != meZoomLevel ) + { + meZoomLevel = eZoomLevel; + LayoutComponents(); + } + + bRet = true; + } + + return bRet; + } + + // ------------------------------------------------------------------------- + + public synchronized com.sun.star.media.ZoomLevel getZoomLevel() + { + return meZoomLevel; + } + + // ------------------------------------------------------------------------- + + public synchronized void setPointerType( int nPointerType ) + { + if( maFrame.getJavaFrame() != null ) + { + int nCursor; + + switch( nPointerType ) + { + case( com.sun.star.awt.SystemPointer.CROSS ): nCursor = java.awt.Cursor.CROSSHAIR_CURSOR; break; + case( com.sun.star.awt.SystemPointer.HAND ): nCursor = java.awt.Cursor.HAND_CURSOR; break; + case( com.sun.star.awt.SystemPointer.MOVE ): nCursor = java.awt.Cursor.MOVE_CURSOR; break; + case( com.sun.star.awt.SystemPointer.WAIT ): nCursor = java.awt.Cursor.WAIT_CURSOR; break; + + default: nCursor = java.awt.Cursor.DEFAULT_CURSOR; break; + } + + maFrame.getJavaFrame().setCursor( java.awt.Cursor.getPredefinedCursor( nCursor ) ); + } + } + + // -------------- + // - XComponent - + // -------------- + + public synchronized void dispose() + { + if( maFrame != null ) + { + java.awt.Panel aPanel = (java.awt.Panel) maFrame.getJavaFrame().getComponent( 0 ); + + if( aPanel != null && aPanel.getComponent( 0 ) != null ) + aPanel.getComponent( 0 ).removeFocusListener( this ); + + if( maFrame.getJavaFrame() != null ) + maFrame.getJavaFrame().dispose(); + + maFrame.fireDisposingEvent(); + } + + maFrame = null; + } + + // ----------- + // - XWindow - + // ----------- + + public synchronized void setPosSize( int X, int Y, int Width, int Height, short Flags ) + { + if( maFrame != null ) + { + maFrame.setPosSize( X, Y, Width, Height, Flags ); + LayoutComponents(); + } + } + + // ------------------------------------------------------------------------- + + public synchronized com.sun.star.awt.Rectangle getPosSize() + { + return( ( maFrame != null ) ? maFrame.getPosSize() : new com.sun.star.awt.Rectangle() ); + } + + // ------------------------------------------------------------------------- + + public synchronized void setVisible( boolean visible ) + { + if( maFrame != null ) + maFrame.setVisible( visible ); + } + + // ------------------------------------------------------------------------- + + public synchronized void setEnable( boolean enable ) + { + if( maFrame != null ) + maFrame.setEnable( enable ); + } + + // ------------------------------------------------------------------------- + + public synchronized void setFocus() + { + if( maFrame != null ) + maFrame.setFocus(); + } + + // ------------------------------------------------------------------------- + + public synchronized void addEventListener( com.sun.star.lang.XEventListener xListener ) + { + if( maFrame != null ) + maFrame.addEventListener( xListener ); + } + + // ------------------------------------------------------------------------- + + public synchronized void removeEventListener( com.sun.star.lang.XEventListener xListener ) + { + if( maFrame != null ) + maFrame.removeEventListener( xListener ); + } + + // ------------------------------------------------------------------------- + + public synchronized void addWindowListener( XWindowListener xListener ) + { + if( maFrame != null ) + maFrame.addWindowListener( xListener ); + } + + // ------------------------------------------------------------------------- + + public synchronized void removeWindowListener( XWindowListener xListener ) + { + if( maFrame != null ) + maFrame.removeWindowListener( xListener ); + } + + // ------------------------------------------------------------------------- + + public synchronized void addFocusListener( XFocusListener xListener ) + { + if( maFrame != null ) + maFrame.addFocusListener( xListener ); + } + + // ------------------------------------------------------------------------- + + public synchronized void removeFocusListener( XFocusListener xListener ) + { + if( maFrame != null ) + maFrame.removeFocusListener( xListener ); + } + + // ------------------------------------------------------------------------- + + public synchronized void addKeyListener( XKeyListener xListener ) + { + if( maFrame != null ) + maFrame.addKeyListener( xListener ); + } + + // ------------------------------------------------------------------------- + + public synchronized void removeKeyListener( XKeyListener xListener ) + { + if( maFrame != null ) + maFrame.removeKeyListener( xListener ); + } + + // ------------------------------------------------------------------------- + + public synchronized void addMouseListener( XMouseListener xListener ) + { + if( maFrame != null ) + maFrame.addMouseListener( xListener ); + } + + // ------------------------------------------------------------------------- + + public synchronized void removeMouseListener( XMouseListener xListener ) + { + if( maFrame != null ) + maFrame.removeMouseListener( xListener ); + } + + // ------------------------------------------------------------------------- + + public synchronized void addMouseMotionListener( XMouseMotionListener xListener ) + { + if( maFrame != null ) + maFrame.addMouseMotionListener( xListener ); + } + + // ------------------------------------------------------------------------- + + public synchronized void removeMouseMotionListener( XMouseMotionListener xListener ) + { + if( maFrame != null ) + maFrame.removeMouseMotionListener( xListener ); + } + + // ------------------------------------------------------------------------- + + public synchronized void addPaintListener( XPaintListener xListener ) + { + if( maFrame != null ) + maFrame.addPaintListener( xListener ); + } + + // ------------------------------------------------------------------------- + + public synchronized void removePaintListener( XPaintListener xListener ) + { + if( maFrame != null ) + maFrame.removePaintListener( xListener ); + } + + // ---------------- + // - XServiceInfo - + // ---------------- + + private static final String s_implName = "com.sun.star.comp.PlayerWindow_Java"; + private static final String s_serviceName = "com.sun.star.media.PlayerWindow_Java"; + + public synchronized String getImplementationName() + { + return s_implName; + } + + // ------------------------------------------------------------------------- + + public synchronized String [] getSupportedServiceNames() + { + return new String [] { s_serviceName }; + } + + // ------------------------------------------------------------------------- + + public synchronized boolean supportsService( String serviceName ) + { + return serviceName.equals( s_serviceName ); + } +} diff --git a/avmedia/source/java/WindowAdapter.java b/avmedia/source/java/WindowAdapter.java new file mode 100644 index 000000000000..7135304fde52 --- /dev/null +++ b/avmedia/source/java/WindowAdapter.java @@ -0,0 +1,540 @@ +/************************************************************************* + * + * $RCSfile: WindowAdapter.java,v $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +import sun.awt.*; +import com.sun.star.awt.*; +import com.sun.star.lang.*; +import java.util.*; +import javax.swing.*; + +public class WindowAdapter +{ + private java.awt.Frame maFrame; + private LinkedList maEventListeners = new LinkedList(); + private LinkedList maWindowListeners = new LinkedList(); + private LinkedList maFocusListeners = new LinkedList(); + private LinkedList maKeyListeners = new LinkedList(); + private LinkedList maMouseListeners = new LinkedList(); + private LinkedList maMouseMotionListeners = new LinkedList(); + private LinkedList maPaintListeners = new LinkedList(); + private boolean mbShift = false, mbMod1 = false, mbMod2 = false; + + // ----------------- + // - WindowAdapter - + // ----------------- + + public WindowAdapter( int windowHandle ) + { + maFrame = SystemWindowAdapter.createFrame( windowHandle ); + } + + //---------------------------------------------------------------------------------- + + public java.awt.Frame getJavaFrame() + { + return maFrame; + } + + //---------------------------------------------------------------------------------- + + private short implGetUNOKeyCode( int nJavaKeyCode ) + { + short nRet = 0; + + System.out.println( nJavaKeyCode ); + + switch( nJavaKeyCode ) + { + case( java.awt.event.KeyEvent.VK_NUMPAD0 ): + case( java.awt.event.KeyEvent.VK_0 ): nRet = com.sun.star.awt.Key.NUM0; break; + case( java.awt.event.KeyEvent.VK_NUMPAD1 ): + case( java.awt.event.KeyEvent.VK_1 ): nRet = com.sun.star.awt.Key.NUM1; break; + case( java.awt.event.KeyEvent.VK_NUMPAD2 ): + case( java.awt.event.KeyEvent.VK_2 ): nRet = com.sun.star.awt.Key.NUM2; break; + case( java.awt.event.KeyEvent.VK_NUMPAD3 ): + case( java.awt.event.KeyEvent.VK_3 ): nRet = com.sun.star.awt.Key.NUM3; break; + case( java.awt.event.KeyEvent.VK_NUMPAD4 ): + case( java.awt.event.KeyEvent.VK_4 ): nRet = com.sun.star.awt.Key.NUM4; break; + case( java.awt.event.KeyEvent.VK_NUMPAD5 ): + case( java.awt.event.KeyEvent.VK_5 ): nRet = com.sun.star.awt.Key.NUM5; break; + case( java.awt.event.KeyEvent.VK_NUMPAD6 ): + case( java.awt.event.KeyEvent.VK_6 ): nRet = com.sun.star.awt.Key.NUM6; break; + case( java.awt.event.KeyEvent.VK_NUMPAD7 ): + case( java.awt.event.KeyEvent.VK_7 ): nRet = com.sun.star.awt.Key.NUM7; break; + case( java.awt.event.KeyEvent.VK_NUMPAD8 ): + case( java.awt.event.KeyEvent.VK_8 ): nRet = com.sun.star.awt.Key.NUM8; break; + case( java.awt.event.KeyEvent.VK_NUMPAD9 ): + case( java.awt.event.KeyEvent.VK_9 ): nRet = com.sun.star.awt.Key.NUM9; break; + + case( java.awt.event.KeyEvent.VK_A ): nRet = com.sun.star.awt.Key.A; break; + case( java.awt.event.KeyEvent.VK_B ): nRet = com.sun.star.awt.Key.B; break; + case( java.awt.event.KeyEvent.VK_C ): nRet = com.sun.star.awt.Key.C; break; + case( java.awt.event.KeyEvent.VK_D ): nRet = com.sun.star.awt.Key.D; break; + case( java.awt.event.KeyEvent.VK_E ): nRet = com.sun.star.awt.Key.E; break; + case( java.awt.event.KeyEvent.VK_F ): nRet = com.sun.star.awt.Key.F; break; + case( java.awt.event.KeyEvent.VK_G ): nRet = com.sun.star.awt.Key.G; break; + case( java.awt.event.KeyEvent.VK_H ): nRet = com.sun.star.awt.Key.H; break; + case( java.awt.event.KeyEvent.VK_I ): nRet = com.sun.star.awt.Key.I; break; + case( java.awt.event.KeyEvent.VK_J ): nRet = com.sun.star.awt.Key.J; break; + case( java.awt.event.KeyEvent.VK_K ): nRet = com.sun.star.awt.Key.K; break; + case( java.awt.event.KeyEvent.VK_L ): nRet = com.sun.star.awt.Key.L; break; + case( java.awt.event.KeyEvent.VK_M ): nRet = com.sun.star.awt.Key.M; break; + case( java.awt.event.KeyEvent.VK_N ): nRet = com.sun.star.awt.Key.N; break; + case( java.awt.event.KeyEvent.VK_O ): nRet = com.sun.star.awt.Key.O; break; + case( java.awt.event.KeyEvent.VK_P ): nRet = com.sun.star.awt.Key.P; break; + case( java.awt.event.KeyEvent.VK_Q ): nRet = com.sun.star.awt.Key.Q; break; + case( java.awt.event.KeyEvent.VK_R ): nRet = com.sun.star.awt.Key.R; break; + case( java.awt.event.KeyEvent.VK_S ): nRet = com.sun.star.awt.Key.S; break; + case( java.awt.event.KeyEvent.VK_T ): nRet = com.sun.star.awt.Key.T; break; + case( java.awt.event.KeyEvent.VK_U ): nRet = com.sun.star.awt.Key.U; break; + case( java.awt.event.KeyEvent.VK_V ): nRet = com.sun.star.awt.Key.V; break; + case( java.awt.event.KeyEvent.VK_W ): nRet = com.sun.star.awt.Key.W; break; + case( java.awt.event.KeyEvent.VK_X ): nRet = com.sun.star.awt.Key.X; break; + case( java.awt.event.KeyEvent.VK_Y ): nRet = com.sun.star.awt.Key.Y; break; + case( java.awt.event.KeyEvent.VK_Z ): nRet = com.sun.star.awt.Key.Z; break; + + case( java.awt.event.KeyEvent.VK_F1 ): nRet = com.sun.star.awt.Key.F1; break; + case( java.awt.event.KeyEvent.VK_F2 ): nRet = com.sun.star.awt.Key.F2; break; + case( java.awt.event.KeyEvent.VK_F3 ): nRet = com.sun.star.awt.Key.F3; break; + case( java.awt.event.KeyEvent.VK_F4 ): nRet = com.sun.star.awt.Key.F4; break; + case( java.awt.event.KeyEvent.VK_F5 ): nRet = com.sun.star.awt.Key.F5; break; + case( java.awt.event.KeyEvent.VK_F6 ): nRet = com.sun.star.awt.Key.F6; break; + case( java.awt.event.KeyEvent.VK_F7 ): nRet = com.sun.star.awt.Key.F7; break; + case( java.awt.event.KeyEvent.VK_F8 ): nRet = com.sun.star.awt.Key.F8; break; + case( java.awt.event.KeyEvent.VK_F9 ): nRet = com.sun.star.awt.Key.F9; break; + case( java.awt.event.KeyEvent.VK_F10 ): nRet = com.sun.star.awt.Key.F10; break; + case( java.awt.event.KeyEvent.VK_F11 ): nRet = com.sun.star.awt.Key.F11; break; + case( java.awt.event.KeyEvent.VK_F12 ): nRet = com.sun.star.awt.Key.F12; break; + case( java.awt.event.KeyEvent.VK_F13 ): nRet = com.sun.star.awt.Key.F13; break; + case( java.awt.event.KeyEvent.VK_F14 ): nRet = com.sun.star.awt.Key.F14; break; + case( java.awt.event.KeyEvent.VK_F15 ): nRet = com.sun.star.awt.Key.F15; break; + case( java.awt.event.KeyEvent.VK_F16 ): nRet = com.sun.star.awt.Key.F16; break; + case( java.awt.event.KeyEvent.VK_F17 ): nRet = com.sun.star.awt.Key.F17; break; + case( java.awt.event.KeyEvent.VK_F18 ): nRet = com.sun.star.awt.Key.F18; break; + case( java.awt.event.KeyEvent.VK_F19 ): nRet = com.sun.star.awt.Key.F19; break; + case( java.awt.event.KeyEvent.VK_F20 ): nRet = com.sun.star.awt.Key.F20; break; + case( java.awt.event.KeyEvent.VK_F21 ): nRet = com.sun.star.awt.Key.F21; break; + case( java.awt.event.KeyEvent.VK_F22 ): nRet = com.sun.star.awt.Key.F22; break; + case( java.awt.event.KeyEvent.VK_F23 ): nRet = com.sun.star.awt.Key.F23; break; + case( java.awt.event.KeyEvent.VK_F24 ): nRet = com.sun.star.awt.Key.F24; break; + + case( java.awt.event.KeyEvent.VK_UP ): nRet = com.sun.star.awt.Key.UP; break; + case( java.awt.event.KeyEvent.VK_DOWN): nRet = com.sun.star.awt.Key.DOWN; break; + case( java.awt.event.KeyEvent.VK_LEFT ): nRet = com.sun.star.awt.Key.LEFT; break; + case( java.awt.event.KeyEvent.VK_RIGHT ): nRet = com.sun.star.awt.Key.RIGHT; break; + + case( java.awt.event.KeyEvent.VK_HOME ): nRet = com.sun.star.awt.Key.HOME; break; + case( java.awt.event.KeyEvent.VK_END ): nRet = com.sun.star.awt.Key.END; break; + + case( java.awt.event.KeyEvent.VK_PAGE_UP ): nRet = com.sun.star.awt.Key.PAGEUP; break; + case( java.awt.event.KeyEvent.VK_PAGE_DOWN ): nRet = com.sun.star.awt.Key.PAGEDOWN; break; + + case( java.awt.event.KeyEvent.VK_ENTER ): nRet = com.sun.star.awt.Key.RETURN; break; + case( java.awt.event.KeyEvent.VK_ESCAPE ): nRet = com.sun.star.awt.Key.ESCAPE; break; + + case( java.awt.event.KeyEvent.VK_TAB ): nRet = com.sun.star.awt.Key.TAB; break; + case( java.awt.event.KeyEvent.VK_BACK_SPACE ): nRet = com.sun.star.awt.Key.BACKSPACE; break; + case( java.awt.event.KeyEvent.VK_SPACE ): nRet = com.sun.star.awt.Key.SPACE; break; + case( java.awt.event.KeyEvent.VK_INSERT): nRet = com.sun.star.awt.Key.INSERT; break; + case( java.awt.event.KeyEvent.VK_DELETE): nRet = com.sun.star.awt.Key.DELETE; break; + case( java.awt.event.KeyEvent.VK_ADD ): nRet = com.sun.star.awt.Key.ADD; break; + case( java.awt.event.KeyEvent.VK_SUBTRACT ): nRet = com.sun.star.awt.Key.SUBTRACT; break; + case( java.awt.event.KeyEvent.VK_MULTIPLY ): nRet = com.sun.star.awt.Key.MULTIPLY; break; + case( java.awt.event.KeyEvent.VK_DIVIDE ): nRet = com.sun.star.awt.Key.DIVIDE; break; + case( java.awt.event.KeyEvent.VK_DECIMAL ): nRet = com.sun.star.awt.Key.POINT; break; + // case( java.awt.event.KeyEvent.VK_ COMMA; break; + case( java.awt.event.KeyEvent.VK_LESS ): nRet = com.sun.star.awt.Key.LESS; break; + case( java.awt.event.KeyEvent.VK_GREATER ): nRet = com.sun.star.awt.Key.GREATER; break; + case( java.awt.event.KeyEvent.VK_EQUALS ): nRet = com.sun.star.awt.Key.EQUAL; break; + // case( java.awt.event.KeyEvent.VK_ OPEN; break; + // case( java.awt.event.KeyEvent.VK_ CUT; break; + // case( java.awt.event.KeyEvent.VK_ COPY; break; + // case( java.awt.event.KeyEvent.VK_ PASTE; break; + // case( java.awt.event.KeyEvent.VK_ UNDO; break; + // case( java.awt.event.KeyEvent.VK_ REPEAT; break; + // case( java.awt.event.KeyEvent.VK_ FIND; break; + // case( java.awt.event.KeyEvent.VK_ PROPERTIES; break; + // case( java.awt.event.KeyEvent.VK_ FRONT; break; + // case( java.awt.event.KeyEvent.VK_ CONTEXTMENU; break; + // case( java.awt.event.KeyEvent.VK_ HELP; break; + + default: + break; + } + + return nRet; + } + + //---------------------------------------------------------------------------------- + + public void fireKeyEvent( java.awt.event.KeyEvent aEvt ) + { + if( maKeyListeners.size() > 0 ) + { + boolean bProcess = false, bPressed = false; + + if( java.awt.event.KeyEvent.KEY_PRESSED == aEvt.getID() ) + { + switch( aEvt.getKeyCode() ) + { + case( java.awt.event.KeyEvent.VK_SHIFT ): mbShift = true; break; + case( java.awt.event.KeyEvent.VK_CONTROL ): mbMod1 = true; break; + case( java.awt.event.KeyEvent.VK_ALT ): mbMod2 = true; break; + + default: + { + bProcess = bPressed = true; + } + break; + } + } + else if( java.awt.event.KeyEvent.KEY_RELEASED == aEvt.getID() ) + { + switch( aEvt.getKeyCode() ) + { + case( java.awt.event.KeyEvent.VK_SHIFT ): mbShift = false; break; + case( java.awt.event.KeyEvent.VK_CONTROL ): mbMod1 = false; break; + case( java.awt.event.KeyEvent.VK_ALT ): mbMod2 = false; break; + + default: + { + bProcess = true; + } + break; + } + } + + if( bProcess ) + { + KeyEvent aUNOEvt = new KeyEvent(); + + aUNOEvt.Modifiers = 0; + + if( mbShift ) + aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.SHIFT; + + if( mbMod1 ) + aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.MOD1; + + if( mbMod2 ) + aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.MOD2; + + aUNOEvt.KeyCode = implGetUNOKeyCode( aEvt.getKeyCode() ); + aUNOEvt.KeyChar = aEvt.getKeyChar(); + aUNOEvt.KeyFunc = com.sun.star.awt.KeyFunction.DONTKNOW; + + ListIterator aIter = maKeyListeners.listIterator( 0 ); + + while( aIter.hasNext() ) + { + if( bPressed ) + ( (XKeyListener) aIter.next() ).keyPressed( aUNOEvt ); + else + ( (XKeyListener) aIter.next() ).keyReleased( aUNOEvt ); + } + } + } + } + + //---------------------------------------------------------------------------------- + + public void fireMouseEvent( java.awt.event.MouseEvent aEvt ) + { + MouseEvent aUNOEvt = new MouseEvent(); + + aUNOEvt.Modifiers = 0; + aUNOEvt.Buttons = 0; + aUNOEvt.X = aEvt.getX(); + aUNOEvt.Y = aEvt.getY(); + aUNOEvt.PopupTrigger = false; + + // Modifiers + if( aEvt.isShiftDown() ) + aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.SHIFT; + + if( aEvt.isControlDown() ) + aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.MOD1; + + if( aEvt.isAltDown() ) + aUNOEvt.Modifiers |= com.sun.star.awt.KeyModifier.MOD2; + + // Buttons + if( SwingUtilities.isLeftMouseButton( aEvt ) ) + aUNOEvt.Buttons |= com.sun.star.awt.MouseButton.LEFT; + + if( SwingUtilities.isMiddleMouseButton( aEvt ) ) + aUNOEvt.Buttons |= com.sun.star.awt.MouseButton.MIDDLE; + + if( SwingUtilities.isRightMouseButton( aEvt ) ) + aUNOEvt.Buttons |= com.sun.star.awt.MouseButton.RIGHT; + + // event type + if( java.awt.event.MouseEvent.MOUSE_PRESSED == aEvt.getID() ) + { + ListIterator aIter = maMouseListeners.listIterator( 0 ); + + aUNOEvt.ClickCount = 1; + + while( aIter.hasNext() ) + ( (XMouseListener) aIter.next() ).mousePressed( aUNOEvt ); + } + else if( java.awt.event.MouseEvent.MOUSE_RELEASED == aEvt.getID() ) + { + ListIterator aIter = maMouseListeners.listIterator( 0 ); + + aUNOEvt.ClickCount = 1; + + while( aIter.hasNext() ) + ( (XMouseListener) aIter.next() ).mouseReleased( aUNOEvt ); + } + else if( java.awt.event.MouseEvent.MOUSE_DRAGGED == aEvt.getID() ) + { + ListIterator aIter = maMouseMotionListeners.listIterator( 0 ); + + aUNOEvt.ClickCount = 0; + + while( aIter.hasNext() ) + ( (XMouseMotionListener) aIter.next() ).mouseDragged( aUNOEvt ); + } + else if( java.awt.event.MouseEvent.MOUSE_MOVED == aEvt.getID() ) + { + ListIterator aIter = maMouseMotionListeners.listIterator( 0 ); + + aUNOEvt.ClickCount = 0; + + while( aIter.hasNext() ) + ( (XMouseMotionListener) aIter.next() ).mouseMoved( aUNOEvt ); + } + } + + //---------------------------------------------------------------------------------- + + public void fireFocusEvent( java.awt.event.FocusEvent aEvt ) + { + if( java.awt.event.FocusEvent.FOCUS_GAINED == aEvt.getID() ) + { + ListIterator aIter = maFocusListeners.listIterator( 0 ); + FocusEvent aUNOEvt = new FocusEvent(); + + while( aIter.hasNext() ) + { + ( (XFocusListener) aIter.next() ).focusGained( aUNOEvt ); + } + } + } + + //---------------------------------------------------------------------------------- + + public void fireDisposingEvent() + { + ListIterator aIter = maEventListeners.listIterator( 0 ); + + while( aIter.hasNext() ) + { + ( (XEventListener) aIter.next() ).disposing( new com.sun.star.lang.EventObject() ); + } + } + + // -------------------- + // - XWindow methods - + // -------------------- + + public void setPosSize( int X, int Y, int Width, int Height, short Flags ) + { + maFrame.setBounds( X, Y, Width, Height ); + } + + //---------------------------------------------------------------------------------- + + public com.sun.star.awt.Rectangle getPosSize( ) + { + java.awt.Rectangle bounds = maFrame.getBounds(); + return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height ); + } + + //---------------------------------------------------------------------------------- + + public void setVisible( boolean visible ) + { + maFrame.setVisible( visible ); + } + + //---------------------------------------------------------------------------------- + + public void setEnable( boolean enable ) + { + maFrame.setEnabled( enable ); + } + + //---------------------------------------------------------------------------------- + + public void setFocus() + { + } + + //---------------------------------------------------------------------------------- + + public void addEventListener( XEventListener xListener ) + { + if( xListener != null ) + maEventListeners.add( xListener ); + } + + //---------------------------------------------------------------------------------- + + public void removeEventListener( XEventListener xListener ) + { + if( xListener != null ) + maEventListeners.remove( xListener ); + } + + //---------------------------------------------------------------------------------- + + public void addWindowListener( XWindowListener xListener ) + { + if( xListener != null ) + maWindowListeners.add( xListener ); + } + + //---------------------------------------------------------------------------------- + + public void removeWindowListener( XWindowListener xListener ) + { + if( xListener != null ) + maWindowListeners.remove( xListener ); + } + + //---------------------------------------------------------------------------------- + + public void addFocusListener( XFocusListener xListener ) + { + if( xListener != null ) + maFocusListeners.add( xListener ); + } + + //---------------------------------------------------------------------------------- + + public void removeFocusListener( XFocusListener xListener ) + { + if( xListener != null ) + maFocusListeners.remove( xListener ); + } + + //---------------------------------------------------------------------------------- + + public void addKeyListener( XKeyListener xListener ) + { + if( xListener != null ) + maKeyListeners.add( xListener ); + } + + //---------------------------------------------------------------------------------- + + public void removeKeyListener( XKeyListener xListener ) + { + if( xListener != null ) + maKeyListeners.remove( xListener ); + } + + //---------------------------------------------------------------------------------- + + public void addMouseListener( XMouseListener xListener ) + { + if( xListener != null ) + maMouseListeners.add( xListener ); + } + + //---------------------------------------------------------------------------------- + + public void removeMouseListener( XMouseListener xListener ) + { + if( xListener != null ) + maMouseListeners.remove( xListener ); + } + + //---------------------------------------------------------------------------------- + + public void addMouseMotionListener( XMouseMotionListener xListener ) + { + if( xListener != null ) + maMouseMotionListeners.add( xListener ); + } + + //---------------------------------------------------------------------------------- + + public void removeMouseMotionListener( XMouseMotionListener xListener ) + { + if( xListener != null ) + maMouseMotionListeners.remove( xListener ); + } + + //---------------------------------------------------------------------------------- + + public void addPaintListener( XPaintListener xListener ) + { + if( xListener != null ) + maPaintListeners.add( xListener ); + } + + //---------------------------------------------------------------------------------- + + public void removePaintListener( XPaintListener xListener ) + { + if( xListener != null ) + maPaintListeners.remove( xListener ); + } +} diff --git a/avmedia/source/java/makefile.mk b/avmedia/source/java/makefile.mk new file mode 100644 index 000000000000..9176071358ab --- /dev/null +++ b/avmedia/source/java/makefile.mk @@ -0,0 +1,73 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ +# +# The Contents of this file are made available subject to the terms of +# the BSD license. +# +# Copyright (c) 2003 by Sun Microsystems, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of Sun Microsystems, Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +#************************************************************************** + +# Builds the Java Canvas implementation. + +PRJNAME = avmedia +PRJ = ..$/.. +TARGET = avmedia +PACKAGE = avmedia + +# --- Settings ----------------------------------------------------- + +.INCLUDE: settings.mk + +.IF "$(GUIBASE)"=="javamedia" + +JAVAFILES = \ + Manager.java \ + Player.java \ + PlayerWindow.java \ + WindowAdapter.java \ + MediaUno.java \ + x11$/SystemWindowAdapter.java + +JARFILES = sandbox.jar jurt.jar unoil.jar ridl.jar juh.jar java_uno.jar jmf.jar +JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) + +JARTARGET = $(TARGET).jar +JARCOMPRESS = TRUE +CUSTOMMANIFESTFILE = manifest + +.ENDIF # "$(GUIBASE)"=="javamedia" + +# --- Targets ------------------------------------------------------ + +.INCLUDE: target.mk diff --git a/avmedia/source/java/manifest b/avmedia/source/java/manifest new file mode 100644 index 000000000000..b2c2fe2599a5 --- /dev/null +++ b/avmedia/source/java/manifest @@ -0,0 +1 @@ +RegistrationClassName: MediaUno diff --git a/avmedia/source/java/win/SystemWindowAdapter.java b/avmedia/source/java/win/SystemWindowAdapter.java new file mode 100644 index 000000000000..f6654e77944a --- /dev/null +++ b/avmedia/source/java/win/SystemWindowAdapter.java @@ -0,0 +1,83 @@ +/************************************************************************* + * + * $RCSfile: SystemWindowAdapter.java,v $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +import sun.awt.*; +import com.sun.star.awt.*; + +public class SystemWindowAdapter +{ + static public java.awt.Frame createFrame( int windowHandle ) + { + java.awt.Frame aFrame; + + // we're initialized with the operating system window handle + // as the parameter. We then generate a dummy Java frame with + // that window as the parent, to fake a root window for the + // Java implementation. + + // now, we're getting slightly system dependent here. + String os = (String) System.getProperty( "os.name" ); + + // create the embedded frame + if( os.startsWith( "Windows" ) ) + aFrame = new sun.awt.windows.WEmbeddedFrame( windowHandle ); + else + throw new com.sun.star.uno.RuntimeException(); + + return aFrame; + } +} diff --git a/avmedia/source/java/x11/SystemWindowAdapter.java b/avmedia/source/java/x11/SystemWindowAdapter.java new file mode 100644 index 000000000000..f253c10ac7af --- /dev/null +++ b/avmedia/source/java/x11/SystemWindowAdapter.java @@ -0,0 +1,88 @@ +/************************************************************************* + * + * $RCSfile: SystemWindowAdapter.java,v $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +import sun.awt.*; +import com.sun.star.awt.*; + +public class SystemWindowAdapter +{ + static public java.awt.Frame createFrame( int windowHandle ) + { + java.awt.Frame aFrame; + + // we're initialized with the operating system window handle + // as the parameter. We then generate a dummy Java frame with + // that window as the parent, to fake a root window for the + // Java implementation. + + // now, we're getting slightly system dependent here. + String os = (String) System.getProperty( "os.name" ); + + // create the embedded frame + if( os.startsWith( "Linux" ) ) + { + // create a java frame from that + aFrame = new sun.awt.motif.MEmbeddedFrame( windowHandle ); + } + else + { + throw new com.sun.star.uno.RuntimeException(); + } + + return aFrame; + } +} diff --git a/avmedia/source/viewer/makefile.mk b/avmedia/source/viewer/makefile.mk new file mode 100644 index 000000000000..111d3e4f132a --- /dev/null +++ b/avmedia/source/viewer/makefile.mk @@ -0,0 +1,93 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: ka $ $Date: 2004-08-23 09:04:42 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. +PRJNAME=avmedia +TARGET=viewer + +# --- Settings ---------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +# --- Resources --------------------------------- + +SRS1NAME=$(TARGET) +SRC1FILES =\ + mediawindow.src + +# --- Files ------------------------------------- + +SLOFILES= \ + $(SLO)$/mediaevent_impl.obj \ + $(SLO)$/mediawindowbase_impl.obj \ + $(SLO)$/mediawindow_impl.obj \ + $(SLO)$/mediawindow.obj + +EXCEPTIONSFILES= \ + $(SLO)$/mediawindow.obj \ + $(SLO)$/mediawindowbase_impl.obj + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk diff --git a/avmedia/source/viewer/mediaevent_impl.cxx b/avmedia/source/viewer/mediaevent_impl.cxx new file mode 100644 index 000000000000..87748d07da1d --- /dev/null +++ b/avmedia/source/viewer/mediaevent_impl.cxx @@ -0,0 +1,253 @@ +/************************************************************************* + * + * $RCSfile: mediaevent_impl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "mediaevent_impl.hxx" +#include "mediawindow_impl.hxx" +#include <osl/mutex.hxx> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> +#include <vcl/event.hxx> + +using namespace ::com::sun::star; + +/* Definition of MediaWindowImpl class */ + +namespace avmedia { namespace priv { +// --------------------------- +// - MediaEventListenersImpl - +// --------------------------- + +MediaEventListenersImpl::MediaEventListenersImpl( Window& rEventWindow ) : + mpNotifyWindow( &rEventWindow ) +{ +} + +// --------------------------------------------------------------------- + +MediaEventListenersImpl::~MediaEventListenersImpl() +{ +} + +// --------------------------------------------------------------------- + +void MediaEventListenersImpl::cleanUp() +{ + Application::RemoveMouseAndKeyEvents( reinterpret_cast< ::Window* >( mpNotifyWindow ) ); + mpNotifyWindow = NULL; +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::disposing( const ::com::sun::star::lang::EventObject& Source ) + throw (::com::sun::star::uno::RuntimeException) +{ +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::keyPressed( const ::com::sun::star::awt::KeyEvent& e ) + throw (::com::sun::star::uno::RuntimeException) +{ + const ::osl::MutexGuard aGuard( maMutex ); + const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); + + if( mpNotifyWindow ) + { + KeyCode aVCLKeyCode( e.KeyCode, + ( ( e.Modifiers & 1 ) ? KEY_SHIFT : 0 ) | + ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) | + ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) ); + KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode ); + + Application::PostKeyEvent( VCLEVENT_WINDOW_KEYINPUT, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLKeyEvt ); + } +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::keyReleased( const ::com::sun::star::awt::KeyEvent& e ) + throw (::com::sun::star::uno::RuntimeException) +{ + const ::osl::MutexGuard aGuard( maMutex ); + const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); + + if( mpNotifyWindow ) + { + KeyCode aVCLKeyCode( e.KeyCode, + ( ( e.Modifiers & 1 ) ? KEY_SHIFT : 0 ) | + ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) | + ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) ); + KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode ); + Application::PostKeyEvent( VCLEVENT_WINDOW_KEYUP, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLKeyEvt ); + } +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::mousePressed( const ::com::sun::star::awt::MouseEvent& e ) + throw (::com::sun::star::uno::RuntimeException) +{ + const ::osl::MutexGuard aGuard( maMutex ); + const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); + + if( mpNotifyWindow ) + { + MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), e.ClickCount, 0, + ( ( e.Buttons & 1 ) ? MOUSE_LEFT : 0 ) | + ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) | + ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ), + e.Modifiers ); + Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); + } +} + +// ----------------------------------------------gvd----------------------- + +void SAL_CALL MediaEventListenersImpl::mouseReleased( const ::com::sun::star::awt::MouseEvent& e ) + throw (::com::sun::star::uno::RuntimeException) +{ + const ::osl::MutexGuard aGuard( maMutex ); + const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); + + if( mpNotifyWindow ) + { + MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), e.ClickCount, 0, + ( ( e.Buttons & 1 ) ? MOUSE_LEFT : 0 ) | + ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) | + ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ), + e.Modifiers ); + Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONUP, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); + } +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::mouseEntered( const ::com::sun::star::awt::MouseEvent& e ) + throw (::com::sun::star::uno::RuntimeException) +{ + const ::osl::MutexGuard aGuard( maMutex ); + const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); + + if( mpNotifyWindow ) + { + } +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::mouseExited( const ::com::sun::star::awt::MouseEvent& e ) + throw (::com::sun::star::uno::RuntimeException) +{ + const ::osl::MutexGuard aGuard( maMutex ); + const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); + + if( mpNotifyWindow ) + { + } +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::mouseDragged( const ::com::sun::star::awt::MouseEvent& e ) + throw (::com::sun::star::uno::RuntimeException) +{ + const ::osl::MutexGuard aGuard( maMutex ); + const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); + + if( mpNotifyWindow ) + { + MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, 0, e.Buttons, e.Modifiers ); + Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); + } +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::mouseMoved( const ::com::sun::star::awt::MouseEvent& e ) + throw (::com::sun::star::uno::RuntimeException) +{ + const ::osl::MutexGuard aGuard( maMutex ); + const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); + + if( mpNotifyWindow ) + { + MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, 0, e.Buttons, e.Modifiers ); + Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); + } +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::focusGained( const ::com::sun::star::awt::FocusEvent& e ) + throw (::com::sun::star::uno::RuntimeException) +{ +} + +// --------------------------------------------------------------------- + +void SAL_CALL MediaEventListenersImpl::focusLost( const ::com::sun::star::awt::FocusEvent& e ) + throw (::com::sun::star::uno::RuntimeException) +{ +} + +} // namespace priv +} // namespace avemdia + diff --git a/avmedia/source/viewer/mediaevent_impl.hxx b/avmedia/source/viewer/mediaevent_impl.hxx new file mode 100644 index 000000000000..08bdb556421c --- /dev/null +++ b/avmedia/source/viewer/mediaevent_impl.hxx @@ -0,0 +1,134 @@ +/************************************************************************* + * + * $RCSfile: mediaevent_impl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _AVMEDIA_MEDIAEVENT_IMPL_HXX +#define _AVMEDIA_MEDIAEVENT_IMPL_HXX + +#include "mediawindow.hxx" + +#ifndef _CPPUHELPER_COMPBASE4_HXX_ +#include <cppuhelper/compbase4.hxx> +#endif +#ifndef _COM_SUN_STAR_AWT_XKEYLISTENER_HPP_ +#include <com/sun/star/awt/XKeyListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XMOUSELISTENER_HPP_ +#include <com/sun/star/awt/XMouseListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XMOUSEMOTIONLISTENER_HPP_ +#include <com/sun/star/awt/XMouseMotionListener.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_XFOCUSLISTENER_HPP_ +#include <com/sun/star/awt/XFocusListener.hpp> +#endif + +namespace avmedia +{ + namespace priv + { + // --------------------------- + // - MediaEventListenersImpl - + // --------------------------- + + class MediaWindowImpl; + + class MediaEventListenersImpl : public ::cppu::WeakImplHelper4< ::com::sun::star::awt::XKeyListener, + ::com::sun::star::awt::XMouseListener, + ::com::sun::star::awt::XMouseMotionListener, + ::com::sun::star::awt::XFocusListener > + { + public: + + MediaEventListenersImpl( Window& rNotifyWindow ); + ~MediaEventListenersImpl(); + + void cleanUp(); + + protected: + + // XKeyListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL keyPressed( const ::com::sun::star::awt::KeyEvent& e ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL keyReleased( const ::com::sun::star::awt::KeyEvent& e ) throw (::com::sun::star::uno::RuntimeException); + + // XMouseListener + virtual void SAL_CALL mousePressed( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseReleased( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseEntered( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseExited( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException); + + // XMouseMotionListener + virtual void SAL_CALL mouseDragged( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseMoved( const ::com::sun::star::awt::MouseEvent& e ) throw (::com::sun::star::uno::RuntimeException); + + // XFocusListener + virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException); + + private: + + Window* mpNotifyWindow; + mutable ::osl::Mutex maMutex; + }; + } +} + +#endif diff --git a/avmedia/source/viewer/mediawindow.cxx b/avmedia/source/viewer/mediawindow.cxx new file mode 100644 index 000000000000..ef470bcb3196 --- /dev/null +++ b/avmedia/source/viewer/mediawindow.cxx @@ -0,0 +1,561 @@ +/************************************************************************* + * + * $RCSfile: mediawindow.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "mediawindow.hxx" +#include "mediawindow_impl.hxx" +#include "mediamisc.hxx" +#include "mediawindow.hrc" +#include <tools/urlobj.hxx> +#include <vcl/msgbox.hxx> +#include <svtools/pathoptions.hxx> +#include <sfx2/filedlghelper.hxx> + +#ifndef _COMPHELPER_PROCESSFACTORY_HXX_ +#include <comphelper/processfactory.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_MEDIA_XMANAGER_HPP_ +#include <com/sun/star/media/XManager.hpp> +#endif + +using namespace ::com::sun::star; + +namespace avmedia { + +// --------------- +// - MediaWindow - +// --------------- + +MediaWindow::MediaWindow( Window* parent, bool bInternalMediaControl ) : + mpImpl( new priv::MediaWindowImpl( parent, this, bInternalMediaControl ) ) +{ + mpImpl->Show(); +} + +// ------------------------------------------------------------------------- + +MediaWindow::~MediaWindow() +{ + mpImpl->cleanUp(); + delete mpImpl; + mpImpl = NULL; +} + +// ------------------------------------------------------------------------- + +void MediaWindow::setURL( const ::rtl::OUString& rURL ) +{ + if( mpImpl ) + mpImpl->setURL( rURL ); +} + +// ------------------------------------------------------------------------- + +const ::rtl::OUString& MediaWindow::getURL() const +{ + return mpImpl->getURL(); +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::isValid() const +{ + return( mpImpl != NULL && mpImpl->isValid() ); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::MouseMove( const MouseEvent& rMEvt ) +{ +} + +// --------------------------------------------------------------------- + +void MediaWindow::MouseButtonDown( const MouseEvent& rMEvt ) +{ +} + +// --------------------------------------------------------------------- + +void MediaWindow::MouseButtonUp( const MouseEvent& rMEvt ) +{ +} + +// ------------------------------------------------------------------------- + +void MediaWindow::KeyInput( const KeyEvent& rKEvt ) +{ +} + +// ------------------------------------------------------------------------- + +void MediaWindow::KeyUp( const KeyEvent& rKEvt ) +{ +} + +// ------------------------------------------------------------------------- + +void MediaWindow::Command( const CommandEvent& rCEvt ) +{ +} + +// ------------------------------------------------------------------------- + +sal_Int8 MediaWindow::AcceptDrop( const AcceptDropEvent& rEvt ) +{ + return 0; +} + +// ------------------------------------------------------------------------- + +sal_Int8 MediaWindow::ExecuteDrop( const ExecuteDropEvent& rEvt ) +{ + return 0; +} + +// ------------------------------------------------------------------------- + +void MediaWindow::StartDrag( sal_Int8 nAction, const Point& rPosPixel ) +{ +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::hasPreferredSize() const +{ + return( mpImpl != NULL && mpImpl->hasPreferredSize() ); +} + +// ------------------------------------------------------------------------- + +Size MediaWindow::getPreferredSize() const +{ + return mpImpl->getPreferredSize(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::setPosSize( const Rectangle& rNewRect ) +{ + if( mpImpl ) + mpImpl->setPosSize( rNewRect ); +} + +// ------------------------------------------------------------------------- + +Rectangle MediaWindow::getPosSize() const +{ + return Rectangle( mpImpl->GetPosPixel(), mpImpl->GetSizePixel() ); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::setPointer( const Pointer& rPointer ) +{ + if( mpImpl ) + mpImpl->setPointer( rPointer ); +} + +// ------------------------------------------------------------------------- + +const Pointer& MediaWindow::getPointer() const +{ + return mpImpl->getPointer(); +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::setZoom( ::com::sun::star::media::ZoomLevel eLevel ) +{ + return( mpImpl != NULL && mpImpl->setZoom( eLevel ) ); +} + +// ------------------------------------------------------------------------- + +::com::sun::star::media::ZoomLevel MediaWindow::getZoom() const +{ + return mpImpl->getZoom(); +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::start() +{ + return( mpImpl != NULL && mpImpl->start() ); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::stop() +{ + if( mpImpl ) + mpImpl->stop(); +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::isPlaying() const +{ + return( mpImpl != NULL && mpImpl->isPlaying() ); +} + +// ------------------------------------------------------------------------- + +double MediaWindow::getDuration() const +{ + return mpImpl->getDuration(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::setMediaTime( double fTime ) +{ + if( mpImpl ) + mpImpl->setMediaTime( fTime ); +} + +// ------------------------------------------------------------------------- + +double MediaWindow::getMediaTime() const +{ + return mpImpl->getMediaTime(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::setStopTime( double fTime ) +{ + if( mpImpl ) + mpImpl->setStopTime( fTime ); +} + +// ------------------------------------------------------------------------- + +double MediaWindow::getStopTime() const +{ + return mpImpl->getStopTime(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::setRate( double fRate ) +{ + if( mpImpl ) + mpImpl->setRate( fRate ); +} + +// ------------------------------------------------------------------------- + +double MediaWindow::getRate() const +{ + return mpImpl->getRate(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::setPlaybackLoop( bool bSet ) +{ + if( mpImpl ) + mpImpl->setPlaybackLoop( bSet ); +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::isPlaybackLoop() const +{ + return mpImpl->isPlaybackLoop(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::setMute( bool bSet ) +{ + if( mpImpl ) + mpImpl->setMute( bSet ); +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::isMute() const +{ + return mpImpl->isMute(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::updateMediaItem( MediaItem& rItem ) const +{ + if( mpImpl ) + mpImpl->updateMediaItem( rItem ); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::executeMediaItem( const MediaItem& rItem ) +{ + if( mpImpl ) + mpImpl->executeMediaItem( rItem ); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::show() +{ + if( mpImpl ) + mpImpl->Show(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::hide() +{ + if( mpImpl ) + mpImpl->Hide(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::enable() +{ + if( mpImpl ) + mpImpl->Enable(); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::disable() +{ + if( mpImpl ) + mpImpl->Disable(); +} + +// ------------------------------------------------------------------------- + +Window* MediaWindow::getWindow() const +{ + return mpImpl; +} + +// ------------------------------------------------------------------------- + +void MediaWindow::getMediaFilters( FilterNameVector& rFilterNameVector ) +{ + static const char* pFilters[] = { "AIF Audio", "aif;aiff", + "AU Audio", "au", + "AVI", "avi", + "CD Audio", "cda", + "MIDI Audio", "mid;midi", + "MPEG Audio", "mp2;mp3;mpa", + "MPEG Video", "mpg;mpeg;mpv", + "Quicktime Video", "mov", + "Vivo Video", "viv", + "WAVE Audio", "wav" }; + + for( int i = 0; i < ( sizeof( pFilters ) / sizeof( char* ) ); i += 2 ) + { + rFilterNameVector.push_back( ::std::make_pair< ::rtl::OUString, ::rtl::OUString >( + ::rtl::OUString::createFromAscii( pFilters[ i ] ), + ::rtl::OUString::createFromAscii( pFilters[ i + 1 ] ) ) ); + } +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::executeMediaURLDialog( Window* pParent, ::rtl::OUString& rURL, bool bInsertDialog ) +{ + ::sfx2::FileDialogHelper aDlg( ::sfx2::FILEOPEN_SIMPLE, 0 ); + static const ::rtl::OUString aWildcard( RTL_CONSTASCII_USTRINGPARAM( "*." ) ); + FilterNameVector aFilters; + const ::rtl::OUString aSeparator( RTL_CONSTASCII_USTRINGPARAM( ";" ) ); + ::rtl::OUString aAllTypes; + + aDlg.SetTitle( AVMEDIA_RESID( bInsertDialog ? AVMEDIA_STR_INSERTMEDIA_DLG : AVMEDIA_STR_OPENMEDIA_DLG ) ); + + getMediaFilters( aFilters ); + + for( int i = 0; i < aFilters.size(); ++i ) + { + for( sal_Int32 nIndex = 0; nIndex >= 0; ) + { + if( aAllTypes.getLength() ) + aAllTypes += aSeparator; + + ( aAllTypes += aWildcard ) += aFilters[ i ].second.getToken( 0, ';', nIndex ); + } + } + + // add filter for all media types + aDlg.AddFilter( AVMEDIA_RESID( AVMEDIA_STR_ALL_MEDIAFILES ), aAllTypes ); + + for( int i = 0; i < aFilters.size(); ++i ) + { + ::rtl::OUString aTypes; + + for( sal_Int32 nIndex = 0; nIndex >= 0; ) + { + if( aTypes.getLength() ) + aTypes += aSeparator; + + ( aTypes += aWildcard ) += aFilters[ i ].second.getToken( 0, ';', nIndex ); + } + + // add single filters + aDlg.AddFilter( aFilters[ i ].first, aTypes ); + } + + // add filter for all types + aDlg.AddFilter( AVMEDIA_RESID( AVMEDIA_STR_ALL_FILES ), String( RTL_CONSTASCII_USTRINGPARAM( "*.*" ) ) ); + + if( aDlg.Execute() == ERRCODE_NONE ) + { + const INetURLObject aURL( aDlg.GetPath() ); + rURL = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ); + } + else if( rURL.getLength() ) + rURL = ::rtl::OUString(); + + return( rURL.getLength() > 0 ); +} + +// ------------------------------------------------------------------------- + +void MediaWindow::executeFormatErrorBox( Window* pParent ) +{ + ErrorBox aErrBox( pParent, AVMEDIA_RESID( AVMEDIA_ERR_URL ) ); + + aErrBox.Execute(); +} + +// ------------------------------------------------------------------------- + +bool MediaWindow::isMediaURL( const ::rtl::OUString& rURL, bool bDeep, Size* pPreferredSizePixel ) +{ + const INetURLObject aURL( rURL ); + bool bRet = false; + + if( aURL.GetProtocol() != INET_PROT_NOT_VALID ) + { + if( bDeep || pPreferredSizePixel ) + { + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); + + if( xFactory.is() ) + { + try + { + uno::Reference< ::com::sun::star::media::XManager > xManager( + xFactory->createInstance( ::rtl::OUString::createFromAscii( AVMEDIA_MANAGER_SERVICE_NAME ) ), + uno::UNO_QUERY ); + + if( xManager.is() ) + { + uno::Reference< media::XPlayer > xPlayer( xManager->createPlayer( aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) ); + + if( xPlayer.is() ) + { + bRet = true; + + if( pPreferredSizePixel ) + { + const awt::Size aAwtSize( xPlayer->getPreferredPlayerWindowSize() ); + + pPreferredSizePixel->Width() = aAwtSize.Width; + pPreferredSizePixel->Height() = aAwtSize.Height; + } + } + } + } + catch( ... ) + { + } + } + } + else + { + FilterNameVector aFilters; + const ::rtl::OUString aExt( aURL.getExtension() ); + + getMediaFilters( aFilters ); + + for( int i = 0; ( i < aFilters.size() ) && !bRet; ++i ) + { + for( sal_Int32 nIndex = 0; nIndex >= 0 && !bRet; ) + { + if( aExt.equalsIgnoreAsciiCase( aFilters[ i ].second.getToken( 0, ';', nIndex ) ) ) + bRet = true; + } + } + } + } + + return bRet; +} + +// ------------------------------------------------------------------------- + +uno::Reference< media::XPlayer > MediaWindow::createPlayer( const ::rtl::OUString& rURL ) +{ + return priv::MediaWindowImpl::createPlayer( rURL ); +} + +} // namespace avemdia diff --git a/avmedia/source/viewer/mediawindow.hrc b/avmedia/source/viewer/mediawindow.hrc new file mode 100644 index 000000000000..67036e300c13 --- /dev/null +++ b/avmedia/source/viewer/mediawindow.hrc @@ -0,0 +1,9 @@ +#define AVMEDIA_STR_OPENMEDIA_DLG 16384 +#define AVMEDIA_STR_INSERTMEDIA_DLG 16385 +#define AVMEDIA_STR_ALL_MEDIAFILES 16386 +#define AVMEDIA_STR_ALL_FILES 16387 + +#define AVMEDIA_BMP_AUDIOLOGO 20000 +#define AVMEDIA_BMP_EMPTYLOGO 20001 + +#define AVMEDIA_ERR_URL 21000 diff --git a/avmedia/source/viewer/mediawindow.src b/avmedia/source/viewer/mediawindow.src new file mode 100644 index 000000000000..df818e76305e --- /dev/null +++ b/avmedia/source/viewer/mediawindow.src @@ -0,0 +1,116 @@ + /************************************************************************* + * + * $RCSfile: mediawindow.src,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "mediawindow.hrc" + +String AVMEDIA_STR_INSERTMEDIA_DLG +{ + Text[de] = "Film und Klang einfgen"; + Text[en-us] = "Insert Movie and Sound"; +}; + +// ------------------------------------------------------------------------------ + +STRING AVMEDIA_STR_OPENMEDIA_DLG +{ + Text[de] = "Film und Klang ffnen"; + Text[en-us] = "Open Movie and Sound"; +}; + +// ------------------------------------------------------------------------------ + +String AVMEDIA_STR_ALL_MEDIAFILES +{ + Text[de] = "Alle Film- und Klangdateien"; + Text[en-us] = "All movie and sound files"; +}; + +// ------------------------------------------------------------------------------ + +String AVMEDIA_STR_ALL_FILES +{ + Text[de] = "Alle Dateien (*.*)"; + Text[en-us] = "All files (*.*)"; +}; + +// ------------------------------------------------------------------------------ + +Bitmap AVMEDIA_BMP_AUDIOLOGO +{ + file = "avaudiologo.png"; +}; + +// ------------------------------------------------------------------------------ + +Bitmap AVMEDIA_BMP_EMPTYLOGO +{ + file = "avemptylogo.png"; +}; + +// ------------------------------------------------------------------------------ + +ErrorBox AVMEDIA_ERR_URL +{ + BUTTONS = WB_OK ; + DEFBUTTON = WB_DEF_OK ; + Message[de] = "Das Format der ausgewhlten Datei wird nicht untersttzt."; + Message[en-us] = "The format of the selected file is not supported."; +}; diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx new file mode 100644 index 000000000000..577ca58dfd99 --- /dev/null +++ b/avmedia/source/viewer/mediawindow_impl.cxx @@ -0,0 +1,567 @@ +/************************************************************************* + * + * $RCSfile: mediawindow_impl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "mediawindow_impl.hxx" +#include "mediaevent_impl.hxx" +#include "mediamisc.hxx" +#include "mediawindow.hrc" + +#include <algorithm> +#include <cmath> +#include <osl/mutex.hxx> +#include <tools/time.hxx> +#include <tools/intn.hxx> +#include <vcl/svapp.hxx> + +#ifndef _COM_SUN_STAR_AWT_SYSTEMPOINTER_HDL_ +#include <com/sun/star/awt/SystemPointer.hdl> +#endif +#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HDL_ +#include <com/sun/star/lang/XComponent.hdl> +#endif + +#define AVMEDIA_TOOLBOXITEM_PREV 0x0001 +#define AVMEDIA_TOOLBOXITEM_PLAY 0x0002 +#define AVMEDIA_TOOLBOXITEM_PAUSE 0x0004 +#define AVMEDIA_TOOLBOXITEM_STOP 0x0008 +#define AVMEDIA_TOOLBOXITEM_NEXT 0x0010 +#define AVMEDIA_TOOLBOXITEM_MUTE 0x0100 + +#define AVMEDIA_FFW_PLAYRATE 4 + +using namespace ::com::sun::star; + +namespace avmedia { namespace priv { + +// ---------------------- +// - MediaWindowControl - +// ---------------------- + +MediaWindowControl::MediaWindowControl( Window* pParent ) : + MediaControl( pParent, MEDIACONTROLSTYLE_MULTILINE ) +{ +} + +// --------------------------------------------------------------------- + +MediaWindowControl::~MediaWindowControl() +{ +} + +// --------------------------------------------------------------------- + +void MediaWindowControl::update() +{ + MediaItem aItem; + + static_cast< MediaWindowImpl* >( GetParent() )->updateMediaItem( aItem ); + setState( aItem ); +} + +// --------------------------------------------------------------------- + +void MediaWindowControl::execute( const MediaItem& rItem ) +{ + static_cast< MediaWindowImpl* >( GetParent() )->executeMediaItem( rItem ); +} + +// -------------------- +// - MediaChildWindow - +// -------------------- + +MediaChildWindow::MediaChildWindow( Window* pParent ) : + JavaChildWindow( pParent, WB_CLIPCHILDREN ) +{ +} + +// --------------------------------------------------------------------- + +MediaChildWindow::~MediaChildWindow() +{ +} + +// --------------------------------------------------------------------- + +void MediaChildWindow::MouseMove( const MouseEvent& rMEvt ) +{ + const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), + rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() ); + + JavaChildWindow::MouseMove( rMEvt ); + GetParent()->MouseMove( aTransformedEvent ); +} + +// --------------------------------------------------------------------- + +void MediaChildWindow::MouseButtonDown( const MouseEvent& rMEvt ) +{ + const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), + rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() ); + + JavaChildWindow::MouseButtonDown( rMEvt ); + GetParent()->MouseButtonDown( aTransformedEvent ); +} + +// --------------------------------------------------------------------- + +void MediaChildWindow::MouseButtonUp( const MouseEvent& rMEvt ) +{ + const MouseEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ), + rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() ); + + JavaChildWindow::MouseButtonUp( rMEvt ); + GetParent()->MouseButtonUp( aTransformedEvent ); +} + +// --------------------------------------------------------------------- + +void MediaChildWindow::KeyInput( const KeyEvent& rKEvt ) +{ + JavaChildWindow::KeyInput( rKEvt ); + GetParent()->KeyInput( rKEvt ); +} + +// --------------------------------------------------------------------- + +void MediaChildWindow::KeyUp( const KeyEvent& rKEvt ) +{ + JavaChildWindow::KeyUp( rKEvt ); + GetParent()->KeyUp( rKEvt ); +} + +// --------------------------------------------------------------------- + +void MediaChildWindow::Command( const CommandEvent& rCEvt ) +{ + const CommandEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rCEvt.GetMousePosPixel() ) ), + rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetData() ); + + JavaChildWindow::Command( rCEvt ); + GetParent()->Command( aTransformedEvent ); +} + +// ---------------------- +// - MediaWindowImpl - +// ---------------------- + +MediaWindowImpl::MediaWindowImpl( Window* pParent, MediaWindow* pMediaWindow, bool bInternalMediaControl ) : + Control( pParent ), + MediaWindowBaseImpl( pMediaWindow ), + maChildWindow( this ), + DropTargetHelper( this ), + DragSourceHelper( this ), + mxEventsIf( static_cast< ::cppu::OWeakObject* >( mpEvents = new MediaEventListenersImpl( maChildWindow ) ) ), + mpMediaWindowControl( bInternalMediaControl ? new MediaWindowControl( this ) : NULL ), + mpEmptyBmpEx( NULL ), + mpAudioBmpEx( NULL ) +{ + maChildWindow.Hide(); + + if( mpMediaWindowControl ) + { + mpMediaWindowControl->SetSizePixel( mpMediaWindowControl->getMinSizePixel() ); + mpMediaWindowControl->Show(); + } +} + +// --------------------------------------------------------------------- + +MediaWindowImpl::~MediaWindowImpl() +{ + delete mpEmptyBmpEx; + delete mpAudioBmpEx; + delete mpMediaWindowControl; +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::cleanUp() +{ + uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayerWindow() ); + + mpEvents->cleanUp(); + + if( xPlayerWindow.is() ) + { + xPlayerWindow->removeKeyListener( uno::Reference< awt::XKeyListener >( mxEventsIf, uno::UNO_QUERY ) ); + xPlayerWindow->removeMouseListener( uno::Reference< awt::XMouseListener >( mxEventsIf, uno::UNO_QUERY ) ); + xPlayerWindow->removeMouseMotionListener( uno::Reference< awt::XMouseMotionListener >( mxEventsIf, uno::UNO_QUERY ) ); + + uno::Reference< lang::XComponent > xComponent( xPlayerWindow, uno::UNO_QUERY ); + + if( xComponent.is() ) + xComponent->dispose(); + } + + MediaWindowBaseImpl::cleanUp(); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::onURLChanged() +{ + if( getPlayer().is() ) + { + uno::Sequence< uno::Any > aArgs( 2 ); + const Point aPoint; + const Size aSize( maChildWindow.GetSizePixel() ); + + + aArgs[ 0 ] = uno::makeAny( (sal_Int32) maChildWindow.getParentWindowHandleForJava() ); + aArgs[ 1 ] = uno::makeAny( awt::Rectangle( aPoint.X(), aPoint.Y(), aSize.Width(), aSize.Height() ) ); + + uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayer()->createPlayerWindow( aArgs ) ); + setPlayerWindow( xPlayerWindow ); + + if( xPlayerWindow.is() ) + { + xPlayerWindow->addKeyListener( uno::Reference< awt::XKeyListener >( mxEventsIf, uno::UNO_QUERY ) ); + xPlayerWindow->addMouseListener( uno::Reference< awt::XMouseListener >( mxEventsIf, uno::UNO_QUERY ) ); + xPlayerWindow->addMouseMotionListener( uno::Reference< awt::XMouseMotionListener >( mxEventsIf, uno::UNO_QUERY ) ); + xPlayerWindow->addFocusListener( uno::Reference< awt::XFocusListener >( mxEventsIf, uno::UNO_QUERY ) ); + } + } + else + setPlayerWindow( NULL ); + + if( getPlayerWindow().is() ) + maChildWindow.Show(); + else + maChildWindow.Hide(); + + if( mpMediaWindowControl ) + { + MediaItem aItem; + + updateMediaItem( aItem ); + mpMediaWindowControl->setState( aItem ); + } + + Invalidate(); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::update() +{ + uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayerWindow() ); + + if( xPlayerWindow.is() ) + xPlayerWindow->update(); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::setPosSize( const Rectangle& rRect ) +{ + SetPosSizePixel( rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight() ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::setPointer( const Pointer& rPointer ) +{ + uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayerWindow() ); + + SetPointer( rPointer ); + maChildWindow.SetPointer( rPointer ); + + if( xPlayerWindow.is() ) + { + + long nPointer; + + switch( rPointer.GetStyle() ) + { + case( POINTER_CROSS ): nPointer = awt::SystemPointer::CROSS; break; + case( POINTER_HAND ): nPointer = awt::SystemPointer::HAND; break; + case( POINTER_MOVE ): nPointer = awt::SystemPointer::MOVE; break; + case( POINTER_WAIT ): nPointer = awt::SystemPointer::WAIT; break; + + default: nPointer = awt::SystemPointer::ARROW; break; + } + + xPlayerWindow->setPointerType( nPointer ); + } +} + +// --------------------------------------------------------------------- + +const Pointer& MediaWindowImpl::getPointer() const +{ + return GetPointer(); +} + +// --------------------------------------------------------------------- + +bool MediaWindowImpl::hasInternalMediaControl() const +{ + return( mpMediaWindowControl != NULL ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::Resize() +{ + uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayerWindow() ); + const Size aCurSize( GetOutputSizePixel() ); + const sal_Int32 nOffset( mpMediaWindowControl ? AVMEDIA_CONTROLOFFSET : 0 ); + Size aPlayerWindowSize( aCurSize.Width() - ( nOffset << 1 ), + aCurSize.Height() - ( nOffset << 1 ) ); + + if( mpMediaWindowControl ) + { + const sal_Int32 nControlHeight = mpMediaWindowControl->GetSizePixel().Height(); + const sal_Int32 nControlY = ::std::max( aCurSize.Height() - nControlHeight - nOffset, 0L ); + + aPlayerWindowSize.Height() = ( nControlY - ( nOffset << 1 ) ); + mpMediaWindowControl->SetPosSizePixel( Point( nOffset, nControlY ), Size( aCurSize.Width() - ( nOffset << 1 ), nControlHeight ) ); + } + + maChildWindow.SetPosSizePixel( Point( nOffset, nOffset ), aPlayerWindowSize ); + + if( xPlayerWindow.is() ) + xPlayerWindow->setPosSize( 0, 0, aPlayerWindowSize.Width(), aPlayerWindowSize.Height(), 0 ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::StateChanged( StateChangedType eType ) +{ + uno::Reference< media::XPlayerWindow > xPlayerWindow( getPlayerWindow() ); + + if( xPlayerWindow.is() ) + { + // stop playing when going disabled or hidden + switch( eType ) + { + case STATE_CHANGE_VISIBLE: + { + stopPlayingInternal( !IsVisible() ); + xPlayerWindow->setVisible( IsVisible() ); + } + break; + + case STATE_CHANGE_ENABLE: + { + stopPlayingInternal( !IsEnabled() ); + xPlayerWindow->setEnable( IsEnabled() ); + } + break; + + default: + break; + } + } +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::Paint( const Rectangle& ) +{ + BitmapEx* pLogo = NULL; + + if( !getPlayer().is() ) + { + if( !mpEmptyBmpEx ) + mpEmptyBmpEx = new BitmapEx( AVMEDIA_RESID( AVMEDIA_BMP_EMPTYLOGO ) ); + + pLogo = mpEmptyBmpEx; + } + else if ( !getPlayerWindow().is() ) + { + if( !mpAudioBmpEx ) + mpAudioBmpEx = new BitmapEx( AVMEDIA_RESID( AVMEDIA_BMP_AUDIOLOGO ) ); + + pLogo = mpAudioBmpEx; + } + + const Point aBasePos( maChildWindow.GetPosPixel() ); + const Rectangle aVideoRect( aBasePos, maChildWindow.GetSizePixel() ); + + if( pLogo && !pLogo->IsEmpty() && ( aVideoRect.GetWidth() > 0 ) && ( aVideoRect.GetHeight() > 0 ) ) + { + Size aLogoSize( pLogo->GetSizePixel() ); + const Color aBackgroundColor( 67, 67, 67 ); + + SetLineColor( aBackgroundColor ); + SetFillColor( aBackgroundColor ); + DrawRect( aVideoRect ); + + if( ( aLogoSize.Width() > aVideoRect.GetWidth() || aLogoSize.Height() > aVideoRect.GetHeight() ) && + ( aLogoSize.Height() > 0 ) ) + { + const double fLogoWH = (double) aLogoSize.Width() / aLogoSize.Height(); + + if( fLogoWH < ( (double) aVideoRect.GetWidth() / aVideoRect.GetHeight() ) ) + { + aLogoSize.Width() = (long) ( aVideoRect.GetHeight() * fLogoWH ); + aLogoSize.Height()= aVideoRect.GetHeight(); + } + else + { + aLogoSize.Width() = aVideoRect.GetWidth(); + aLogoSize.Height()= (long) ( aVideoRect.GetWidth() / fLogoWH ); + } + } + + DrawBitmapEx( Point( aBasePos.X() + ( ( aVideoRect.GetWidth() - aLogoSize.Width() ) >> 1 ), + aBasePos.Y() + ( ( aVideoRect.GetHeight() - aLogoSize.Height() ) >> 1 ) ), + aLogoSize, *pLogo ); + } + + update(); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::GetFocus() +{ +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::MouseMove( const MouseEvent& rMEvt ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + + if( pMediaWindow ) + pMediaWindow->MouseMove( rMEvt ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::MouseButtonDown( const MouseEvent& rMEvt ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + + if( pMediaWindow ) + pMediaWindow->MouseButtonDown( rMEvt ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::MouseButtonUp( const MouseEvent& rMEvt ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + + if( pMediaWindow ) + pMediaWindow->MouseButtonUp( rMEvt ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::KeyInput( const KeyEvent& rKEvt ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + + if( pMediaWindow ) + pMediaWindow->KeyInput( rKEvt ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::KeyUp( const KeyEvent& rKEvt ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + + if( pMediaWindow ) + pMediaWindow->KeyUp( rKEvt ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::Command( const CommandEvent& rCEvt ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + + if( pMediaWindow ) + pMediaWindow->Command( rCEvt ); +} + +// --------------------------------------------------------------------- + +sal_Int8 MediaWindowImpl::AcceptDrop( const AcceptDropEvent& rEvt ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + return( pMediaWindow ? pMediaWindow->AcceptDrop( rEvt ) : 0 ); +} + +// --------------------------------------------------------------------- + +sal_Int8 MediaWindowImpl::ExecuteDrop( const ExecuteDropEvent& rEvt ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + return( pMediaWindow ? pMediaWindow->ExecuteDrop( rEvt ) : 0 ); +} + +// --------------------------------------------------------------------- + +void MediaWindowImpl::StartDrag( sal_Int8 nAction, const Point& rPosPixel ) +{ + MediaWindow* pMediaWindow = getMediaWindow(); + + if( pMediaWindow ) + pMediaWindow->StartDrag( nAction, rPosPixel ); +} + +} // namespace priv +} // namespace avmedia diff --git a/avmedia/source/viewer/mediawindow_impl.hxx b/avmedia/source/viewer/mediawindow_impl.hxx new file mode 100644 index 000000000000..f75b05601fe4 --- /dev/null +++ b/avmedia/source/viewer/mediawindow_impl.hxx @@ -0,0 +1,179 @@ +/************************************************************************* + * + * $RCSfile: mediawindow_impl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _AVMEDIA_MEDIAWINDOW_IMPL_HXX +#define _AVMEDIA_MEDIAWINDOW_IMPL_HXX + +#include <svtools/transfer.hxx> +#include <vcl/javachild.hxx> + +#include "mediawindowbase_impl.hxx" +#include "mediacontrol.hxx" + +class BitmapEx; + +namespace avmedia +{ + namespace priv + { + // ---------------------- + // - MediaWindowControl - + // ---------------------- + + class MediaWindowControl : public MediaControl + { + public: + + MediaWindowControl( Window* pParent ); + ~MediaWindowControl(); + + protected: + + void update(); + void execute( const MediaItem& rItem ); + }; + + // -------------------- + // - MediaChildWindow - + // -------------------- + + class MediaChildWindow : public JavaChildWindow + { + public: + + MediaChildWindow( Window* pParent ); + ~MediaChildWindow(); + + protected: + + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void KeyUp( const KeyEvent& rKEvt ); + virtual void Command( const CommandEvent& rCEvt ); + }; + + // ------------------. + // - MediaWindowImpl - + // ------------------- + + class MediaEventListenersImpl; + + class MediaWindowImpl : public Control, + public MediaWindowBaseImpl, + public DropTargetHelper, + public DragSourceHelper + + { + public: + + MediaWindowImpl( Window* parent, MediaWindow* pMediaWindow, bool bInternalMediaControl ); + virtual ~MediaWindowImpl(); + + virtual void cleanUp(); + virtual void onURLChanged(); + + public: + + void update(); + + void setPosSize( const Rectangle& rRect ); + + void setPointer( const Pointer& rPointer ); + const Pointer& getPointer() const; + + bool hasInternalMediaControl() const; + + protected: + + // Window + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void KeyUp( const KeyEvent& rKEvt ); + virtual void Command( const CommandEvent& rCEvt ); + virtual void Resize(); + virtual void StateChanged( StateChangedType ); + virtual void Paint( const Rectangle& ); // const + virtual void GetFocus(); + + // DropTargetHelper + virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); + virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); + + // DragSourceHelper + virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ); + + private: + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxEventsIf; + MediaEventListenersImpl* mpEvents; + MediaChildWindow maChildWindow; + MediaWindowControl* mpMediaWindowControl; + BitmapEx* mpEmptyBmpEx; + BitmapEx* mpAudioBmpEx; + }; + } +} + +#endif diff --git a/avmedia/source/viewer/mediawindowbase_impl.cxx b/avmedia/source/viewer/mediawindowbase_impl.cxx new file mode 100644 index 000000000000..5196e3339439 --- /dev/null +++ b/avmedia/source/viewer/mediawindowbase_impl.cxx @@ -0,0 +1,478 @@ +/************************************************************************* + * + * $RCSfile: mediawindowbase_impl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "mediawindowbase_impl.hxx" +#include "mediaitem.hxx" +#include "mediamisc.hxx" +#include "mediawindow.hrc" +#include <tools/urlobj.hxx> + +#ifndef _COMPHELPER_PROCESSFACTORY_HXX_ +#include <comphelper/processfactory.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_MEDIA_XMANAGER_HPP_ +#include <com/sun/star/media/XManager.hpp> +#endif + +#define MEDIA_TIMER_TIMEOUT 100 + +using namespace ::com::sun::star; + +namespace avmedia { namespace priv { + +// ----------------------- +// - MediaWindowBaseImpl - +// ----------------------- + +MediaWindowBaseImpl::MediaWindowBaseImpl( MediaWindow* pMediaWindow ) : + mpMediaWindow( pMediaWindow ) +{ +} + +// --------------------------------------------------------------------- + +MediaWindowBaseImpl::~MediaWindowBaseImpl() +{ + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); +} + +// ------------------------------------------------------------------------- + +uno::Reference< media::XPlayer > MediaWindowBaseImpl::createPlayer( const ::rtl::OUString& rURL ) +{ + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); + uno::Reference< media::XPlayer > xPlayer; + + if( xFactory.is() ) + { + try + { + + uno::Reference< ::com::sun::star::media::XManager > xManager( + xFactory->createInstance( ::rtl::OUString::createFromAscii( AVMEDIA_MANAGER_SERVICE_NAME ) ), + uno::UNO_QUERY ); + + if( xManager.is() ) + { + xPlayer = uno::Reference< ::com::sun::star::media::XPlayer >( + xManager->createPlayer( rURL ), uno::UNO_QUERY ); + } + } + catch( ... ) + { + } + } + + return xPlayer; +} + + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::setURL( const ::rtl::OUString& rURL ) +{ + if( rURL != getURL() ) + { + INetURLObject aURL( maFileURL = rURL ); + + if( mxPlayer.is() ) + mxPlayer->stop(); + + if( mxPlayerWindow.is() ) + { + mxPlayerWindow->setVisible( false ); + mxPlayerWindow.clear(); + } + + mxPlayer.clear(); + + if( aURL.GetProtocol() != INET_PROT_NOT_VALID ) + maFileURL = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ); + + mxPlayer = createPlayer( rURL ); + onURLChanged(); + } +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::onURLChanged() +{ +} + +// --------------------------------------------------------------------- + +const ::rtl::OUString& MediaWindowBaseImpl::getURL() const +{ + return maFileURL; +} + +// --------------------------------------------------------------------- + +bool MediaWindowBaseImpl::isValid() const +{ + return( getPlayer().is() ); +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::stopPlayingInternal( bool bStop ) +{ + if( isPlaying() ) + { + if( bStop ) + mxPlayer->start(); + else + mxPlayer->stop(); + } +} + +// --------------------------------------------------------------------- + +MediaWindow* MediaWindowBaseImpl::getMediaWindow() const +{ + return mpMediaWindow; +} + +// --------------------------------------------------------------------- + +uno::Reference< media::XPlayer > MediaWindowBaseImpl::getPlayer() const +{ + return mxPlayer; +} + +// --------------------------------------------------------------------- + +uno::Reference< media::XPlayerWindow > MediaWindowBaseImpl::getPlayerWindow() const +{ + return mxPlayerWindow; +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::setPlayerWindow( const uno::Reference< media::XPlayerWindow >& rxPlayerWindow ) +{ + mxPlayerWindow = rxPlayerWindow; +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::cleanUp() +{ + if( mxPlayer.is() ) + mxPlayer->stop(); + + if( mxPlayerWindow.is() ) + { + mxPlayerWindow->setVisible( false ); + mxPlayerWindow.clear(); + } + + mxPlayer.clear(); + mpMediaWindow = NULL; +} + +// --------------------------------------------------------------------- + +bool MediaWindowBaseImpl::hasPreferredSize() const +{ + return( mxPlayerWindow.is() ); +} + +// --------------------------------------------------------------------- + +Size MediaWindowBaseImpl::getPreferredSize() const +{ + Size aRet; + + if( mxPlayer.is() ) + { + awt::Size aPrefSize( mxPlayer->getPreferredPlayerWindowSize() ); + + aRet.Width() = aPrefSize.Width; + aRet.Height() = aPrefSize.Height; + } + + return aRet; +} + +// --------------------------------------------------------------------- + +bool MediaWindowBaseImpl::setZoom( ::com::sun::star::media::ZoomLevel eLevel ) +{ + return( mxPlayerWindow.is() ? mxPlayerWindow->setZoomLevel( eLevel ) : false ); +} + +// ------------------------------------------------------------------------- + +::com::sun::star::media::ZoomLevel MediaWindowBaseImpl::getZoom() const +{ + return( mxPlayerWindow.is() ? mxPlayerWindow->getZoomLevel() : ::com::sun::star::media::ZoomLevel_NOT_AVAILABLE ); +} + +// --------------------------------------------------------------------- + +bool MediaWindowBaseImpl::start() +{ + return( mxPlayer.is() ? ( mxPlayer->start(), true ) : false ); +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::stop() +{ + if( mxPlayer.is() ) + mxPlayer->stop(); +} + +// --------------------------------------------------------------------- + +bool MediaWindowBaseImpl::isPlaying() const +{ + return( mxPlayer.is() && mxPlayer->isPlaying() ); +} + +// --------------------------------------------------------------------- + +double MediaWindowBaseImpl::getDuration() const +{ + return( mxPlayer.is() ? mxPlayer->getDuration() : 0.0 ); +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::setMediaTime( double fTime ) +{ + if( mxPlayer.is() ) + mxPlayer->setMediaTime( fTime ); +} + +// --------------------------------------------------------------------- + +double MediaWindowBaseImpl::getMediaTime() const +{ + return( mxPlayer.is() ? mxPlayer->getMediaTime() : 0.0 ); +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::setStopTime( double fTime ) +{ + if( mxPlayer.is() ) + mxPlayer->setStopTime( fTime ); +} + +// --------------------------------------------------------------------- + +double MediaWindowBaseImpl::getStopTime() const +{ + return( mxPlayer.is() ? mxPlayer->getStopTime() : 0.0 ); +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::setRate( double fRate ) +{ + if( mxPlayer.is() ) + mxPlayer->setRate( fRate ); +} + +// --------------------------------------------------------------------- + +double MediaWindowBaseImpl::getRate() const +{ + return( mxPlayer.is() ? mxPlayer->getRate() : 0.0 ); +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::setPlaybackLoop( bool bSet ) +{ + if( mxPlayer.is() ) + mxPlayer->setPlaybackLoop( bSet ); +} + +// --------------------------------------------------------------------- + +bool MediaWindowBaseImpl::isPlaybackLoop() const +{ + return( mxPlayer.is() ? mxPlayer->isPlaybackLoop() : false ); +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::setMute( bool bSet ) +{ + if( mxPlayer.is() ) + mxPlayer->setMute( bSet ); +} + +// --------------------------------------------------------------------- + +bool MediaWindowBaseImpl::isMute() const +{ + return( mxPlayer.is() ? mxPlayer->isMute() : false ); +} + +// --------------------------------------------------------------------- + +void MediaWindowBaseImpl::setVolumeDB( sal_Int16 nVolumeDB ) +{ + if( mxPlayer.is() ) + mxPlayer->setVolumeDB( nVolumeDB ); +} + +// --------------------------------------------------------------------- + +sal_Int16 MediaWindowBaseImpl::getVolumeDB() const +{ + return( mxPlayer.is() ? mxPlayer->getVolumeDB() : 0 ); +} + +// ------------------------------------------------------------------------- + +void MediaWindowBaseImpl::updateMediaItem( MediaItem& rItem ) const +{ + if( isPlaying() ) + rItem.setState( ( getRate() > 1.0 ) ? MEDIASTATE_PLAYFFW : MEDIASTATE_PLAY ); + else + rItem.setState( ( 0.0 == getMediaTime() ) ? MEDIASTATE_STOP : MEDIASTATE_PAUSE ); + + rItem.setDuration( getDuration() ); + rItem.setTime( getMediaTime() ); + rItem.setLoop( isPlaybackLoop() ); + rItem.setMute( isMute() ); + rItem.setVolumeDB( getVolumeDB() ); + rItem.setZoom( getZoom() ); + rItem.setURL( getURL() ); +} + +// ------------------------------------------------------------------------- + +void MediaWindowBaseImpl::executeMediaItem( const MediaItem& rItem ) +{ + const sal_uInt32 nMaskSet = rItem.getMaskSet(); + + // set URL first + if( nMaskSet & AVMEDIA_SETMASK_URL ) + setURL( rItem.getURL() ); + + // set different states next + if( nMaskSet & AVMEDIA_SETMASK_TIME ) + setMediaTime( ::std::min( rItem.getTime(), getDuration() ) ); + + if( nMaskSet & AVMEDIA_SETMASK_LOOP ) + setPlaybackLoop( rItem.isLoop() ); + + if( nMaskSet & AVMEDIA_SETMASK_MUTE ) + setMute( rItem.isMute() ); + + if( nMaskSet & AVMEDIA_SETMASK_VOLUMEDB ) + setVolumeDB( rItem.getVolumeDB() ); + + if( nMaskSet & AVMEDIA_SETMASK_ZOOM ) + setZoom( rItem.getZoom() ); + + // set play state at last + if( nMaskSet & AVMEDIA_SETMASK_STATE ) + { + switch( rItem.getState() ) + { + case( MEDIASTATE_PLAY ): + case( MEDIASTATE_PLAYFFW ): + { +/* + const double fNewRate = ( ( MEDIASTATE_PLAYFFW == rItem.getState() ) ? AVMEDIA_FFW_PLAYRATE : 1.0 ); + + if( getRate() != fNewRate ) + setRate( fNewRate ); +*/ + if( !isPlaying() ) + start(); + } + break; + + case( MEDIASTATE_PAUSE ): + { + if( isPlaying() ) + stop(); + } + break; + + case( MEDIASTATE_STOP ): + { + if( isPlaying() ) + { + setMediaTime( 0.0 ); + stop(); + setMediaTime( 0.0 ); + } + } + break; + } + } +} + +} // namespace priv +} // namespace avemdia diff --git a/avmedia/source/viewer/mediawindowbase_impl.hxx b/avmedia/source/viewer/mediawindowbase_impl.hxx new file mode 100644 index 000000000000..ebcc73fc6189 --- /dev/null +++ b/avmedia/source/viewer/mediawindowbase_impl.hxx @@ -0,0 +1,170 @@ +/************************************************************************* + * + * $RCSfile: mediawindowbase_impl.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _AVMEDIA_MEDIAWINDOWBASE_IMPL_HXX +#define _AVMEDIA_MEDIAWINDOWBASE_IMPL_HXX + +#include "mediawindow.hxx" + +#ifndef _COM_SUN_STAR_MEDIA_XPLAYER_HPP_ +#include <com/sun/star/media/XPlayer.hpp> +#endif +#ifndef _COM_SUN_STAR_MEDIA_XPLAYERWINDOW_HPP_ +#include <com/sun/star/media/XPlayerWindow.hpp> +#endif + +namespace avmedia +{ + namespace priv + { + // -------------- + // - UpdateMode - + // -------------- + + enum UpdateMode + { + UPDATEMODE_SYNC_STATUSBAR = 0, + UPDATEMODE_SYNC_PLAYER = 1, + UPDATEMODE_SYNC_NONE = 2 + }; + + // ----------------------- + // - MediaWindowBaseImpl - + // ----------------------- + + class MediaWindowBaseImpl + { + public: + + MediaWindowBaseImpl( MediaWindow* pMediaWindow ); + virtual ~MediaWindowBaseImpl(); + + virtual void cleanUp(); + virtual void onURLChanged(); + + static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const ::rtl::OUString& rURL ); + + public: + + void setURL( const ::rtl::OUString& rURL ); + const ::rtl::OUString& getURL() const; + + bool isValid() const; + + bool hasPreferredSize() const; + Size getPreferredSize() const; + + bool setZoom( ::com::sun::star::media::ZoomLevel eLevel ); + ::com::sun::star::media::ZoomLevel getZoom() const; + + bool start(); + void stop(); + + bool isPlaying() const; + + double getDuration() const; + + void setMediaTime( double fTime ); + double getMediaTime() const; + + void setStopTime( double fTime ); + double getStopTime() const; + + void setRate( double fRate ); + double getRate() const; + + void setPlaybackLoop( bool bSet ); + bool isPlaybackLoop() const; + + void setFixedAspectRatio( bool bSet ); + bool isFixedAspectRatio() const; + + void setMute( bool bSet ); + bool isMute() const; + + void setVolumeDB( sal_Int16 nVolumeDB ); + sal_Int16 getVolumeDB() const; + + void updateMediaItem( MediaItem& rItem ) const; + void executeMediaItem( const MediaItem& rItem ); + + protected: + + void stopPlayingInternal( bool ); + + MediaWindow* getMediaWindow() const; + + ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > getPlayer() const; + + void setPlayerWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow >& rxPlayerWindow ); + ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > getPlayerWindow() const; + + private: + + ::rtl::OUString maFileURL; + ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > mxPlayer; + ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > mxPlayerWindow; + MediaWindow* mpMediaWindow; + }; + } +} + +#endif diff --git a/avmedia/source/win/exports.dxp b/avmedia/source/win/exports.dxp new file mode 100644 index 000000000000..db9c0a52f288 --- /dev/null +++ b/avmedia/source/win/exports.dxp @@ -0,0 +1,4 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory + diff --git a/avmedia/source/win/makefile.mk b/avmedia/source/win/makefile.mk new file mode 100644 index 000000000000..1fa80e471e85 --- /dev/null +++ b/avmedia/source/win/makefile.mk @@ -0,0 +1,105 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. +PRJNAME=avmediawin +TARGET=avmediawin + +# --- Settings ---------------------------------- + +.INCLUDE : settings.mk + +.IF "$(verbose)"!="" || "$(VERBOSE)"!="" +CDEFS+= -DVERBOSE +.ENDIF + +# --- Files ---------------------------------- + +.IF "$(GUI)" == "WNT" + +SLOFILES= \ + $(SLO)$/winuno.obj \ + $(SLO)$/manager.obj \ + $(SLO)$/window.obj \ + $(SLO)$/player.obj + +EXCEPTIONSFILES= \ + $(SLO)$/winuno.obj + +SHL1TARGET=$(TARGET) +SHL1STDLIBS= $(CPPULIB) $(SALLIB) $(COMPHELPERLIB) $(CPPUHELPERLIB) +SHL1IMPLIB=i$(TARGET) +SHL1LIBS=$(SLB)$/$(TARGET).lib +SHL1DEF=$(MISC)$/$(SHL1TARGET).def + +DEF1NAME=$(SHL1TARGET) +DEF1EXPORTFILE=exports.dxp + +SHL1STDLIBS += strmiids.lib +SHL1STDLIBS += ole32.lib +SHL1STDLIBS += gdi32.lib +SHL1STDLIBS += ddraw.lib +SHL1STDLIBS += dxguid.lib + +.ENDIF + +.INCLUDE : target.mk diff --git a/avmedia/source/win/manager.cxx b/avmedia/source/win/manager.cxx new file mode 100644 index 000000000000..970b0b415540 --- /dev/null +++ b/avmedia/source/win/manager.cxx @@ -0,0 +1,128 @@ +/************************************************************************* + * + * $RCSfile: manager.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "manager.hxx" +#include "player.hxx" + +#define AVMEDIA_WIN_MANAGER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Manager_DirectX" +#define AVMEDIA_WIN_MANAGER_SERVICENAME "com.sun.star.media.Manager" + +using namespace ::com::sun::star; + +namespace avmedia { namespace win { +// ---------------- +// - Manager - +// ---------------- + +Manager::Manager( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) : + mxMgr( rxMgr ) +{ +} + +// ------------------------------------------------------------------------------ + +Manager::~Manager() +{ +} + +// ------------------------------------------------------------------------------ + +uno::Reference< media::XPlayer > SAL_CALL Manager::createPlayer( const ::rtl::OUString& aURL ) + throw (uno::RuntimeException) +{ + Player* pPlayer( new Player ); + uno::Reference< media::XPlayer > xRet( pPlayer ); + + if( !pPlayer->create( aURL ) ) + xRet = uno::Reference< media::XPlayer >(); + + return xRet; +} + +// ------------------------------------------------------------------------------ + +::rtl::OUString SAL_CALL Manager::getImplementationName( ) + throw (uno::RuntimeException) +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_WIN_MANAGER_IMPLEMENTATIONNAME ) ); +} + +// ------------------------------------------------------------------------------ + +sal_Bool SAL_CALL Manager::supportsService( const ::rtl::OUString& ServiceName ) + throw (uno::RuntimeException) +{ + return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_WIN_MANAGER_SERVICENAME ) ); +} + +// ------------------------------------------------------------------------------ + +uno::Sequence< ::rtl::OUString > SAL_CALL Manager::getSupportedServiceNames( ) + throw (uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aRet(1); + aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_WIN_MANAGER_SERVICENAME ) ); + + return aRet; +} + +} // namespace win +} // namespace avmedia diff --git a/avmedia/source/win/manager.hxx b/avmedia/source/win/manager.hxx new file mode 100644 index 000000000000..b6619ef5462a --- /dev/null +++ b/avmedia/source/win/manager.hxx @@ -0,0 +1,100 @@ +/************************************************************************* + * + * $RCSfile: manager.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _MANAGER_HXX +#define _MANAGER_HXX + +#include "wincommon.hxx" + +#ifndef _COM_SUN_STAR_MEDIA_XMANAGER_HDL_ +#include "com/sun/star/media/XManager.hdl" +#endif + +// ----------- +// - Manager - +// ----------- + +namespace avmedia { namespace win { + +class Manager : public ::cppu::WeakImplHelper2 < ::com::sun::star::media::XManager, + ::com::sun::star::lang::XServiceInfo > +{ +public: + + Manager( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxMgr ); + ~Manager(); + + // XManager + virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > SAL_CALL createPlayer( const ::rtl::OUString& aURL ) throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); +private: + + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMgr; +}; + +} // namespace win +} // namespace avmedia + +#endif // _MANAGER_HXX diff --git a/avmedia/source/win/player.cxx b/avmedia/source/win/player.cxx new file mode 100644 index 000000000000..08b35d88f25f --- /dev/null +++ b/avmedia/source/win/player.cxx @@ -0,0 +1,470 @@ +/************************************************************************* + * + * $RCSfile: player.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <tools/prewin.h> +#include <windows.h> +#include <objbase.h> +#include <strmif.h> +#include <control.h> +#include <uuids.h> +#include <evcode.h> +#include <tools/postwin.h> + +#include "player.hxx" +#include "window.hxx" + +#define AVMEDIA_WIN_PLAYER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Player_DirectX" +#define AVMEDIA_WIN_PLAYER_SERVICENAME "com.sun.star.media.Player_DirectX" + +using namespace ::com::sun::star; + +namespace avmedia { namespace win { + +// ---------------- +// - Player - +// ---------------- + +Player::Player() : + mpGB( NULL ), + mpOMF( NULL ), + mpMC( NULL ), + mpME( NULL ), + mpMS( NULL ), + mpMP( NULL ), + mpBA( NULL ), + mpBV( NULL ), + mpVW( NULL ), + mpEV( NULL ), + mnUnmutedVolume( 0 ), + mbMuted( false ), + mbLooping( false ) +{ + ::CoInitialize( NULL ); +} + +// ------------------------------------------------------------------------------ + +Player::~Player() +{ + if( mpBA ) + mpBA->Release(); + + if( mpBV ) + mpBV->Release(); + + if( mpVW ) + mpVW->Release(); + + if( mpMP ) + mpMP->Release(); + + if( mpMS ) + mpMS->Release(); + + if( mpME ) + mpME->Release(); + + if( mpMC ) + mpMC->Release(); + + if( mpEV ) + mpEV->Release(); + + if( mpOMF ) + mpOMF->Release(); + + if( mpGB ) + mpGB->Release(); + + ::CoUninitialize(); +} + +// ------------------------------------------------------------------------------ + +bool Player::create( const ::rtl::OUString& rURL ) +{ + HRESULT hR; + bool bRet = false; + + if( SUCCEEDED( hR = CoCreateInstance( CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**) &mpGB ) ) ) + { + // use overlays, if possible + if( SUCCEEDED( CoCreateInstance( CLSID_OverlayMixer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**) &mpOMF ) ) ) + { + mpGB->AddFilter( mpOMF, L"com_sun_star_media_OverlayMixerFilter" ); + + if( !SUCCEEDED( mpOMF->QueryInterface( IID_IDDrawExclModeVideo, (void**) &mpEV ) ) ) + mpEV = NULL; + } + + if( SUCCEEDED( hR = mpGB->RenderFile( rURL, NULL ) ) & + SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaControl, (void**) &mpMC ) ) && + SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaEventEx, (void**) &mpME ) ) && + SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaSeeking, (void**) &mpMS ) ) && + SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaPosition, (void**) &mpMP ) ) ) + { + // Video interfaces + mpGB->QueryInterface( IID_IVideoWindow, (void**) &mpVW ); + mpGB->QueryInterface( IID_IBasicVideo, (void**) &mpBV ); + + // Audio interface + mpGB->QueryInterface( IID_IBasicAudio, (void**) &mpBA ); + + if( mpBA ) + mpBA->put_Volume( mnUnmutedVolume ); + + bRet = true; + } + } + + return bRet; +} + +// ------------------------------------------------------------------------------ + +const IVideoWindow* Player::getVideoWindow() const +{ + return mpVW; +} + +// ------------------------------------------------------------------------------ + +void Player::setNotifyWnd( int nNotifyWnd ) +{ + if( mpME ) + mpME->SetNotifyWindow( (OAHWND) nNotifyWnd, WM_GRAPHNOTIFY, reinterpret_cast< LONG_PTR>( this ) ); +} + +// ------------------------------------------------------------------------------ + +void Player::setDDrawParams( IDirectDraw* pDDraw, IDirectDrawSurface* pDDrawSurface ) +{ + if( mpEV && pDDraw && pDDrawSurface ) + { + mpEV->SetDDrawObject( pDDraw ); + mpEV->SetDDrawSurface( pDDrawSurface ); + } +} + +// ------------------------------------------------------------------------------ + +long Player::processEvent() +{ + long nCode, nParam1, nParam2; + + if( mpME && SUCCEEDED( mpME->GetEvent( &nCode, &nParam1, &nParam2, 0 ) ) ) + { + if( EC_COMPLETE == nCode ) + { + if( mbLooping ) + { + setMediaTime( 0.0 ); + start(); + } + else + { + setMediaTime( getDuration() ); + stop(); + } + } + + mpME->FreeEventParams( nCode, nParam1, nParam2 ); + } + + return 0; +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Player::start( ) + throw (uno::RuntimeException) +{ + if( mpMC ) + mpMC->Run(); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Player::stop( ) + throw (uno::RuntimeException) +{ + if( mpMC ) + mpMC->Stop(); +} + +// ------------------------------------------------------------------------------ + +sal_Bool SAL_CALL Player::isPlaying() + throw (uno::RuntimeException) +{ + OAFilterState eFilterState; + bool bRet = false; + + if( mpMC && SUCCEEDED( mpMC->GetState( 10, &eFilterState ) ) ) + bRet = ( State_Running == eFilterState ); + + return bRet; +} + +// ------------------------------------------------------------------------------ + +double SAL_CALL Player::getDuration( ) + throw (uno::RuntimeException) +{ + REFTIME aRefTime( 0.0 ); + + if( mpMP ) + mpMP->get_Duration( &aRefTime ); + + return aRefTime; +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Player::setMediaTime( double fTime ) + throw (uno::RuntimeException) +{ + if( mpMP ) + mpMP->put_CurrentPosition( fTime ); +} + +// ------------------------------------------------------------------------------ + +double SAL_CALL Player::getMediaTime( ) + throw (uno::RuntimeException) +{ + REFTIME aRefTime( 0.0 ); + + if( mpMP ) + mpMP->get_CurrentPosition( &aRefTime ); + + return aRefTime; +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Player::setStopTime( double fTime ) + throw (uno::RuntimeException) +{ + if( mpMP ) + mpMP->put_StopTime( fTime ); +} + +// ------------------------------------------------------------------------------ + +double SAL_CALL Player::getStopTime( ) + throw (uno::RuntimeException) +{ + REFTIME aRefTime( 0.0 ); + + if( mpMP ) + mpMP->get_StopTime( &aRefTime ); + + return aRefTime; +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Player::setRate( double fRate ) + throw (uno::RuntimeException) +{ + if( mpMP ) + mpMP->put_Rate( fRate ); +} + +// ------------------------------------------------------------------------------ + +double SAL_CALL Player::getRate( ) + throw (uno::RuntimeException) +{ + double fRet( 0.0 ); + + if( mpMP ) + mpMP->get_Rate( &fRet ); + + return fRet; +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet ) + throw (uno::RuntimeException) +{ + mbLooping = bSet; +} + +// ------------------------------------------------------------------------------ + +sal_Bool SAL_CALL Player::isPlaybackLoop( ) + throw (uno::RuntimeException) +{ + return mbLooping; +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Player::setMute( sal_Bool bSet ) + throw (uno::RuntimeException) +{ + if( mpBA && ( mbMuted != bSet ) ) + { + mpBA->put_Volume( ( mbMuted = bSet ) ? -10000 : mnUnmutedVolume ); + } +} + +// ------------------------------------------------------------------------------ + +sal_Bool SAL_CALL Player::isMute( ) + throw (uno::RuntimeException) +{ + return mbMuted; +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB ) + throw (uno::RuntimeException) +{ + mnUnmutedVolume = static_cast< long >( nVolumeDB ) * 100; + + if( !mbMuted && mpBA ) + mpBA->put_Volume( mnUnmutedVolume ); +} + +// ------------------------------------------------------------------------------ + +sal_Int16 SAL_CALL Player::getVolumeDB( ) + throw (uno::RuntimeException) +{ + return( mnUnmutedVolume / 100 ); + + return 0; +} + +// ------------------------------------------------------------------------------ + +awt::Size SAL_CALL Player::getPreferredPlayerWindowSize( ) + throw (uno::RuntimeException) +{ + awt::Size aSize( 0, 0 ); + + if( mpBV ) + { + long nWidth = 0, nHeight = 0; + + mpBV->GetVideoSize( &nWidth, &nHeight ); + aSize.Width = nWidth; + aSize.Height = nHeight; + } + + return aSize; +} + +// ------------------------------------------------------------------------------ + +uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( const uno::Sequence< uno::Any >& aArguments ) + throw (uno::RuntimeException) +{ + uno::Reference< ::media::XPlayerWindow > xRet; + awt::Size aSize( getPreferredPlayerWindowSize() ); + + if( mpVW && aSize.Width > 0 && aSize.Height > 0 ) + { + ::avmedia::win::Window* pWindow = new ::avmedia::win::Window( *this ); + + xRet = pWindow; + + if( !pWindow->create( aArguments ) ) + xRet = uno::Reference< ::media::XPlayerWindow >(); + } + + return xRet; +} + +// ------------------------------------------------------------------------------ + +::rtl::OUString SAL_CALL Player::getImplementationName( ) + throw (uno::RuntimeException) +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_WIN_PLAYER_IMPLEMENTATIONNAME ) ); +} + +// ------------------------------------------------------------------------------ + +sal_Bool SAL_CALL Player::supportsService( const ::rtl::OUString& ServiceName ) + throw (uno::RuntimeException) +{ + return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_WIN_PLAYER_SERVICENAME ) ); +} + +// ------------------------------------------------------------------------------ + +uno::Sequence< ::rtl::OUString > SAL_CALL Player::getSupportedServiceNames( ) + throw (uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aRet(1); + aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_WIN_PLAYER_SERVICENAME ) ); + + return aRet; +} + +} // namespace win +} // namespace avmedia diff --git a/avmedia/source/win/player.hxx b/avmedia/source/win/player.hxx new file mode 100644 index 000000000000..e7b41ddde3c6 --- /dev/null +++ b/avmedia/source/win/player.hxx @@ -0,0 +1,153 @@ +/************************************************************************* + * + * $RCSfile: player.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _PLAYER_HXX +#define _PLAYER_HXX + +#include "wincommon.hxx" + +#ifndef _COM_SUN_STAR_MEDIA_XPLAYER_HDL_ +#include "com/sun/star/media/XPlayer.hdl" +#endif + +struct IGraphBuilder; +struct IBaseFilter; +struct IMediaControl; +struct IMediaEventEx; +struct IMediaSeeking; +struct IMediaPosition; +struct IBasicAudio; +struct IBasicVideo; +struct IVideoWindow; +struct IDDrawExclModeVideo; +struct IDirectDraw; +struct IDirectDrawSurface; + +namespace avmedia { namespace win { + +// ---------- +// - Player - +// ---------- + +class Player : public ::cppu::WeakImplHelper2< ::com::sun::star::media::XPlayer, + ::com::sun::star::lang::XServiceInfo > +{ +public: + + Player(); + ~Player(); + + bool create( const ::rtl::OUString& rURL ); + + void setNotifyWnd( int nNotifyWnd ); + void setDDrawParams( IDirectDraw* pDDraw, IDirectDrawSurface* pDDrawSurface ); + long processEvent(); + + const IVideoWindow* getVideoWindow() const; + + // XPlayer + virtual void SAL_CALL start( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL stop( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isPlaying( ) throw (::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getDuration( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setMediaTime( double fTime ) throw (::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getMediaTime( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setStopTime( double fTime ) throw (::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getStopTime( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRate( double fRate ) throw (::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getRate( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPlaybackLoop( sal_Bool bSet ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isPlaybackLoop( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setMute( sal_Bool bSet ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isMute( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setVolumeDB( sal_Int16 nVolumeDB ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getVolumeDB( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Size SAL_CALL getPreferredPlayerWindowSize( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > SAL_CALL createPlayerWindow( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); + +private: + + IGraphBuilder* mpGB; + IBaseFilter* mpOMF; + IMediaControl* mpMC; + IMediaEventEx* mpME; + IMediaSeeking* mpMS; + IMediaPosition* mpMP; + IBasicAudio* mpBA; + IBasicVideo* mpBV; + IVideoWindow* mpVW; + IDDrawExclModeVideo* mpEV; + long mnUnmutedVolume; + sal_Bool mbMuted; + sal_Bool mbLooping; + + void ImplLayoutVideoWindow(); +}; + +} // namespace win +} // namespace avmedia + +#endif // _PLAYER_HXX diff --git a/avmedia/source/win/wincommon.hxx b/avmedia/source/win/wincommon.hxx new file mode 100644 index 000000000000..349469338fe4 --- /dev/null +++ b/avmedia/source/win/wincommon.hxx @@ -0,0 +1,110 @@ +/************************************************************************* + * + * $RCSfile: wincommon.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _WINCOMMON_HXX +#define _WINCOMMON_HXX + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif +#ifndef __RTL_USTRING_ +#include <rtl/ustring> +#endif +#ifndef _DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef _STREAM_HXX +#include <tools/stream.hxx> +#endif +#ifndef _STRING_HXX +#include <tools/string.hxx> +#endif +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include <cppuhelper/implbase2.hxx> +#endif +#ifndef _CPPUHELPER_WEAK_HXX_ +#include <cppuhelper/weak.hxx> +#endif +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include <cppuhelper/factory.hxx> +#endif + +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/RuntimeException.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/registry/XRegistryKey.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/awt/Rectangle.hpp> +#include <com/sun/star/awt/KeyModifier.hpp> +#include <com/sun/star/awt/MouseButton.hpp> +#include <com/sun/star/media/XManager.hpp> + +#define WM_GRAPHNOTIFY (WM_USER + 567) + +#endif // _WINCOMMOM_HXX diff --git a/avmedia/source/win/window.cxx b/avmedia/source/win/window.cxx new file mode 100644 index 000000000000..e40abfdcc799 --- /dev/null +++ b/avmedia/source/win/window.cxx @@ -0,0 +1,755 @@ +/************************************************************************* + * + * $RCSfile: window.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <tools/prewin.h> +#include <windows.h> +#include <objbase.h> +#include <strmif.h> +#include <control.h> +#include <dshow.h> +#include <tools/postwin.h> +#include <com/sun/star/awt/SystemPointer.hdl> + +#include "window.hxx" +#include "player.hxx" + +#define AVMEDIA_WIN_WINDOW_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Window_DirectX" +#define AVMEDIA_WIN_WINDOW_SERVICENAME "com.sun.star.media.Window_DirectX" + +using namespace ::com::sun::star; + +namespace avmedia { namespace win { + +// ----------- +// - statics - +// ----------- + +static ::osl::Mutex& ImplGetOwnStaticMutex() +{ + static ::osl::Mutex* pMutex = NULL; + + if( pMutex == NULL ) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + + if( pMutex == NULL ) + { + static ::osl::Mutex aMutex; + pMutex = &aMutex; + } + } + + return *pMutex; +} + +// ----------- +// - WndProc - +// ----------- + +LRESULT CALLBACK MediaPlayerWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 ) +{ + Window* pWindow = (Window*) ::GetWindowLong( hWnd, 0 ); + bool bProcessed = true; + + if( pWindow ) + { + switch( nMsg ) + { + case( WM_SETCURSOR ): + pWindow->updatePointer(); + break; + + case( WM_GRAPHNOTIFY ): + pWindow->processGraphEvent(); + break; + + case( WM_MOUSEMOVE ): + case( WM_LBUTTONDOWN ): + case( WM_MBUTTONDOWN ): + case( WM_RBUTTONDOWN ): + case( WM_LBUTTONUP ): + case( WM_MBUTTONUP ): + case( WM_RBUTTONUP ): + { + awt::MouseEvent aUNOEvt; + POINT aWinPoint; + + if( !::GetCursorPos( &aWinPoint ) || !::ScreenToClient( hWnd, &aWinPoint ) ) + { + aWinPoint.x = GET_X_LPARAM( nPar2 ); + aWinPoint.y = GET_Y_LPARAM( nPar2 ); + } + aUNOEvt.Modifiers = 0; + aUNOEvt.Buttons = 0; + aUNOEvt.X = aWinPoint.x; + aUNOEvt.Y = aWinPoint.y; + aUNOEvt.PopupTrigger = false; + + // Modifiers + if( nPar1 & MK_SHIFT ) + aUNOEvt.Modifiers |= awt::KeyModifier::SHIFT; + + if( nPar1 & MK_CONTROL ) + aUNOEvt.Modifiers |= awt::KeyModifier::MOD1; + + // Buttons + if( WM_LBUTTONDOWN == nMsg || WM_LBUTTONUP == nMsg ) + aUNOEvt.Buttons |= awt::MouseButton::LEFT; + + if( WM_MBUTTONDOWN == nMsg || WM_MBUTTONUP == nMsg ) + aUNOEvt.Buttons |= awt::MouseButton::MIDDLE; + + if( WM_RBUTTONDOWN == nMsg || WM_RBUTTONUP == nMsg ) + aUNOEvt.Buttons |= awt::MouseButton::RIGHT; + + // event type + if( WM_LBUTTONDOWN == nMsg || + WM_MBUTTONDOWN == nMsg || + WM_RBUTTONDOWN == nMsg ) + { + aUNOEvt.ClickCount = 1; + pWindow->fireMousePressedEvent( aUNOEvt ); + } + else if( WM_LBUTTONUP == nMsg || + WM_MBUTTONUP == nMsg || + WM_RBUTTONUP == nMsg ) + { + aUNOEvt.ClickCount = 1; + pWindow->fireMouseReleasedEvent( aUNOEvt ); + } + else if( WM_MOUSEMOVE == nMsg ) + { + aUNOEvt.ClickCount = 0; + pWindow->fireMouseMovedEvent( aUNOEvt ); + pWindow->updatePointer(); + } + } + break; + + case( WM_SETFOCUS ): + { + const awt::FocusEvent aUNOEvt; + pWindow->fireSetFocusEvent( aUNOEvt ); + } + break; + + default: + bProcessed = false; + break; + } + } + else + bProcessed = false; + + return( bProcessed ? 0 : DefWindowProc( hWnd, nMsg, nPar1, nPar2 ) ); +} + +// --------------- +// - Window - +// --------------- + +WNDCLASS* Window::mpWndClass = NULL; + +// ------------------------------------------------------------------------------ + +Window::Window( Player& rPlayer ) : + mrPlayer( rPlayer ), + meZoomLevel( media::ZoomLevel_NOT_AVAILABLE ), + mnParentWnd( 0 ), + mnFrameWnd( 0 ), + maListeners( maMutex ), + mnPointerType( awt::SystemPointer::ARROW ) +{ + ::osl::MutexGuard aGuard( ImplGetOwnStaticMutex() ); + + if( !mpWndClass ) + { + mpWndClass = new WNDCLASS; + + memset( mpWndClass, 0, sizeof( *mpWndClass ) ); + mpWndClass->hInstance = GetModuleHandle( NULL ); + mpWndClass->cbWndExtra = sizeof( DWORD ); + mpWndClass->lpfnWndProc = MediaPlayerWndProc; + mpWndClass->lpszClassName = "com_sun_star_media_PlayerWnd"; + mpWndClass->hbrBackground = (HBRUSH) ::GetStockObject( BLACK_BRUSH ); + mpWndClass->hCursor = ::LoadCursor( NULL, IDC_ARROW ); + + ::RegisterClass( mpWndClass ); + } +} + +// ------------------------------------------------------------------------------ + +Window::~Window() +{ + if( mnFrameWnd ) + ::DestroyWindow( (HWND) mnFrameWnd ); +} + +// ------------------------------------------------------------------------------ + +void Window::ImplLayoutVideoWindow() +{ + if( media::ZoomLevel_NOT_AVAILABLE != meZoomLevel ) + { + awt::Size aPrefSize( mrPlayer.getPreferredPlayerWindowSize() ); + awt::Rectangle aRect = getPosSize(); + int nW = aRect.Width, nH = aRect.Height; + int nVideoW = nW, nVideoH = nH; + int nX = 0, nY = 0, nWidth = 0, nHeight = 0; + bool bDone = false, bZoom = false; + + if( media::ZoomLevel_ORIGINAL == meZoomLevel ) + { + bZoom = true; + } + else if( media::ZoomLevel_ZOOM_1_TO_4 == meZoomLevel ) + { + aPrefSize.Width >>= 2; + aPrefSize.Height >>= 2; + bZoom = true; + } + else if( media::ZoomLevel_ZOOM_1_TO_2 == meZoomLevel ) + { + aPrefSize.Width >>= 1; + aPrefSize.Height >>= 1; + bZoom = true; + } + else if( media::ZoomLevel_ZOOM_2_TO_1 == meZoomLevel ) + { + aPrefSize.Width <<= 1; + aPrefSize.Height <<= 1; + bZoom = true; + } + else if( media::ZoomLevel_ZOOM_4_TO_1 == meZoomLevel ) + { + aPrefSize.Width <<= 2; + aPrefSize.Height <<= 2; + bZoom = true; + } + else if( media::ZoomLevel_FIT_TO_WINDOW == meZoomLevel ) + { + nWidth = nVideoW; + nHeight = nVideoH; + bDone = true; + } + + if( bZoom ) + { + if( ( aPrefSize.Width <= nVideoW ) && ( aPrefSize.Height <= nVideoH ) ) + { + nX = ( nVideoW - aPrefSize.Width ) >> 1; + nY = ( nVideoH - aPrefSize.Height ) >> 1; + nWidth = aPrefSize.Width; + nHeight = aPrefSize.Height; + bDone = true; + } + } + + if( !bDone ) + { + if( aPrefSize.Width > 0 && aPrefSize.Height > 0 && nVideoW > 0 && nVideoH > 0 ) + { + double fPrefWH = (double) aPrefSize.Width / aPrefSize.Height; + + if( fPrefWH < ( (double) nVideoW / nVideoH ) ) + nVideoW = (int)( nVideoH * fPrefWH ); + else + nVideoH = (int)( nVideoW / fPrefWH ); + + nX = ( nW - nVideoW ) >> 1; + nY = ( nH - nVideoH ) >> 1; + nWidth = nVideoW; + nHeight = nVideoH; + } + else + nX = nY = nWidth = nHeight = 0; + } + + IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() ); + + if( pVideoWindow ) + pVideoWindow->SetWindowPosition( nX, nY, nWidth, nHeight ); + } +} + +// ------------------------------------------------------------------------------ + +bool Window::create( const uno::Sequence< uno::Any >& rArguments ) +{ + IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() ); + + if( !mnFrameWnd && pVideoWindow && mpWndClass ) + { + awt::Rectangle aRect; + sal_Int32 nWnd; + + rArguments[ 0 ] >>= nWnd; + rArguments[ 1 ] >>= aRect; + + mnParentWnd = nWnd; + mnFrameWnd = (int) ::CreateWindow( mpWndClass->lpszClassName, NULL, + WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + aRect.X, aRect.Y, aRect.Width, aRect.Height, + (HWND) mnParentWnd, NULL, mpWndClass->hInstance, 0 ); + + if( mnFrameWnd ) + { + ::SetWindowLong( (HWND) mnFrameWnd, 0, (DWORD) this ); + +#ifdef DDRAW_TEST_OUTPUT + IDirectDraw7* pDDraw; + IDirectDrawSurface7* pDDSurface; + IDirectDrawClipper* pDDClipper; + + if( DD_OK == DirectDrawCreateEx( NULL, (void**) &pDDraw, IID_IDirectDraw7, NULL ) ) + { + if( DD_OK == pDDraw->SetCooperativeLevel( (HWND) mnParentWnd, DDSCL_NORMAL ) ) + { + DDSURFACEDESC2 aDDDesc; + + memset( &aDDDesc, 0, sizeof( aDDDesc ) ); + aDDDesc.dwSize = sizeof( aDDDesc ); + aDDDesc.dwFlags = DDSD_CAPS; + aDDDesc.ddsCaps.dwCaps |= DDSCAPS_PRIMARYSURFACE; + + if( DD_OK == pDDraw->CreateSurface( &aDDDesc, &pDDSurface, NULL ) ) + { + if( DD_OK == pDDraw->CreateClipper( 0, &pDDClipper, NULL ) ) + { + pDDClipper->SetHWnd( 0, (HWND) mnFrameWnd ); + pDDSurface->SetClipper( pDDClipper ); + } + + mrPlayer.setDDrawParams( (IDirectDraw*) pDDraw, (IDirectDrawSurface*) pDDSurface ); +#endif + + pVideoWindow->put_Owner( (OAHWND) mnFrameWnd ); + pVideoWindow->put_MessageDrain( (OAHWND) mnFrameWnd ); + pVideoWindow->put_WindowStyle( WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN ); + + mrPlayer.setNotifyWnd( mnFrameWnd ); + + meZoomLevel = media::ZoomLevel_ORIGINAL; + ImplLayoutVideoWindow(); +#ifdef DDRAW_TEST_OUTPUT + } + } + } +#endif + } + } + + return( mnFrameWnd != 0 ); +} + +// ------------------------------------------------------------------------------ + +void Window::processGraphEvent() +{ + mrPlayer.processEvent(); +} + +// ------------------------------------------------------------------------------ + +void Window::updatePointer() +{ + char* pCursorName; + + switch( mnPointerType ) + { + case( awt::SystemPointer::CROSS ): pCursorName = IDC_CROSS; break; + //case( awt::SystemPointer::HAND ): pCursorName = IDC_HAND; break; + case( awt::SystemPointer::MOVE ): pCursorName = IDC_SIZEALL; break; + case( awt::SystemPointer::WAIT ): pCursorName = IDC_WAIT; break; + + default: + pCursorName = IDC_ARROW; + break; + } + + ::SetCursor( ::LoadCursor( NULL, pCursorName ) ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::update( ) + throw (uno::RuntimeException) +{ + ::RedrawWindow( (HWND) mnFrameWnd, NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE ); +} + +// ------------------------------------------------------------------------------ + +sal_Bool SAL_CALL Window::setZoomLevel( media::ZoomLevel eZoomLevel ) + throw (uno::RuntimeException) +{ + boolean bRet = false; + + if( media::ZoomLevel_NOT_AVAILABLE != meZoomLevel && + media::ZoomLevel_NOT_AVAILABLE != eZoomLevel ) + { + if( eZoomLevel != meZoomLevel ) + { + meZoomLevel = eZoomLevel; + ImplLayoutVideoWindow(); + } + + bRet = true; + } + + return bRet; +} + +// ------------------------------------------------------------------------------ + +media::ZoomLevel SAL_CALL Window::getZoomLevel( ) + throw (uno::RuntimeException) +{ + return meZoomLevel; +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::setPointerType( sal_Int32 nPointerType ) + throw (uno::RuntimeException) +{ + mnPointerType = nPointerType; +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) + throw (uno::RuntimeException) +{ + if( mnFrameWnd ) + { + ::SetWindowPos( (HWND) mnFrameWnd, HWND_TOP, X, Y, Width, Height, 0 ); + ImplLayoutVideoWindow(); + } +} + +// ------------------------------------------------------------------------------ + +awt::Rectangle SAL_CALL Window::getPosSize() + throw (uno::RuntimeException) +{ + awt::Rectangle aRet; + + if( mnFrameWnd ) + { + ::RECT aWndRect; + long nX = 0, nY = 0, nWidth = 0, nHeight = 0; + + if( ::GetClientRect( (HWND) mnFrameWnd, &aWndRect ) ) + { + aRet.X = aWndRect.left; + aRet.Y = aWndRect.top; + aRet.Width = aWndRect.right - aWndRect.left + 1; + aRet.Height = aWndRect.bottom - aWndRect.top + 1; + } + } + + return aRet; +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::setVisible( sal_Bool bVisible ) + throw (uno::RuntimeException) +{ + if( mnFrameWnd ) + { + IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() ); + + if( pVideoWindow ) + pVideoWindow->put_Visible( bVisible ? OATRUE : OAFALSE ); + + ::ShowWindow( (HWND) mnFrameWnd, bVisible ? SW_SHOW : SW_HIDE ); + } +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::setEnable( sal_Bool bEnable ) + throw (uno::RuntimeException) +{ + if( mnFrameWnd ) + ::EnableWindow( (HWND) mnFrameWnd, bEnable ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::setFocus( ) + throw (uno::RuntimeException) +{ + if( mnFrameWnd ) + ::SetFocus( (HWND) mnFrameWnd ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::addWindowListener( const uno::Reference< awt::XWindowListener >& xListener ) + throw (uno::RuntimeException) +{ + maListeners.addInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::removeWindowListener( const uno::Reference< awt::XWindowListener >& xListener ) + throw (uno::RuntimeException) +{ + maListeners.removeInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) + throw (uno::RuntimeException) +{ + maListeners.addInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) + throw (uno::RuntimeException) +{ + maListeners.removeInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::addKeyListener( const uno::Reference< awt::XKeyListener >& xListener ) + throw (uno::RuntimeException) +{ + maListeners.addInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::removeKeyListener( const uno::Reference< awt::XKeyListener >& xListener ) + throw (uno::RuntimeException) +{ + maListeners.removeInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::addMouseListener( const uno::Reference< awt::XMouseListener >& xListener ) + throw (uno::RuntimeException) +{ + maListeners.addInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::removeMouseListener( const uno::Reference< awt::XMouseListener >& xListener ) + throw (uno::RuntimeException) +{ + maListeners.removeInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener ) + throw (uno::RuntimeException) +{ + maListeners.addInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener ) + throw (uno::RuntimeException) +{ + maListeners.removeInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::addPaintListener( const uno::Reference< awt::XPaintListener >& xListener ) + throw (uno::RuntimeException) +{ + maListeners.addInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::removePaintListener( const uno::Reference< awt::XPaintListener >& xListener ) + throw (uno::RuntimeException) +{ + maListeners.removeInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::dispose( ) + throw (uno::RuntimeException) +{ +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) + throw (uno::RuntimeException) +{ + maListeners.addInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void SAL_CALL Window::removeEventListener( const uno::Reference< lang::XEventListener >& xListener ) + throw (uno::RuntimeException) +{ + maListeners.removeInterface( getCppuType( &xListener ), xListener ); +} + +// ------------------------------------------------------------------------------ + +void Window::fireMousePressedEvent( const ::com::sun::star::awt::MouseEvent& rEvt ) +{ + ::cppu::OInterfaceContainerHelper* pContainer = maListeners.getContainer( getCppuType( (uno::Reference< awt::XMouseListener >*) 0 ) ); + + if( pContainer ) + { + ::cppu::OInterfaceIteratorHelper aIter( *pContainer ); + + while( aIter.hasMoreElements() ) + uno::Reference< awt::XMouseListener >( aIter.next(), uno::UNO_QUERY )->mousePressed( rEvt ); + } +} + +// ----------------------------------------------------------------------------- + +void Window::fireMouseReleasedEvent( const ::com::sun::star::awt::MouseEvent& rEvt ) +{ + ::cppu::OInterfaceContainerHelper* pContainer = maListeners.getContainer( getCppuType( (uno::Reference< awt::XMouseListener >*) 0 ) ); + + if( pContainer ) + { + ::cppu::OInterfaceIteratorHelper aIter( *pContainer ); + + while( aIter.hasMoreElements() ) + uno::Reference< awt::XMouseListener >( aIter.next(), uno::UNO_QUERY )->mouseReleased( rEvt ); + } +} + +// ----------------------------------------------------------------------------- + +void Window::fireMouseMovedEvent( const ::com::sun::star::awt::MouseEvent& rEvt ) +{ + ::cppu::OInterfaceContainerHelper* pContainer = maListeners.getContainer( getCppuType( (uno::Reference< awt::XMouseMotionListener >*) 0 ) ); + + if( pContainer ) + { + ::cppu::OInterfaceIteratorHelper aIter( *pContainer ); + + while( aIter.hasMoreElements() ) + uno::Reference< awt::XMouseMotionListener >( aIter.next(), uno::UNO_QUERY )->mouseMoved( rEvt ); + } +} + +// ----------------------------------------------------------------------------- + +void Window::fireSetFocusEvent( const ::com::sun::star::awt::FocusEvent& rEvt ) +{ + ::cppu::OInterfaceContainerHelper* pContainer = maListeners.getContainer( getCppuType( (uno::Reference< awt::XFocusListener >*) 0 ) ); + + if( pContainer ) + { + ::cppu::OInterfaceIteratorHelper aIter( *pContainer ); + + while( aIter.hasMoreElements() ) + uno::Reference< awt::XFocusListener >( aIter.next(), uno::UNO_QUERY )->focusGained( rEvt ); + } +} + +// ------------------------------------------------------------------------------ + +::rtl::OUString SAL_CALL Window::getImplementationName( ) + throw (uno::RuntimeException) +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_WIN_WINDOW_IMPLEMENTATIONNAME ) ); +} + +// ------------------------------------------------------------------------------ + +sal_Bool SAL_CALL Window::supportsService( const ::rtl::OUString& ServiceName ) + throw (uno::RuntimeException) +{ + return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_WIN_WINDOW_SERVICENAME ) ); +} + +// ------------------------------------------------------------------------------ + +uno::Sequence< ::rtl::OUString > SAL_CALL Window::getSupportedServiceNames( ) + throw (uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aRet(1); + aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_WIN_WINDOW_SERVICENAME ) ); + + return aRet; +} + +} // namespace win +} // namespace avmedia diff --git a/avmedia/source/win/window.hxx b/avmedia/source/win/window.hxx new file mode 100644 index 000000000000..0c8599a7725d --- /dev/null +++ b/avmedia/source/win/window.hxx @@ -0,0 +1,156 @@ +/************************************************************************* + * + * $RCSfile: window.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _WINDOW_HXX +#define _WINDOW_HXX + +#include "wincommon.hxx" +#include <cppuhelper/interfacecontainer.h> + +#ifndef _COM_SUN_STAR_MEDIA_XPLAYERWINDOW_HDL_ +#include "com/sun/star/media/XPlayerWindow.hdl" +#endif + +struct IVideoWindow; + +namespace avmedia { namespace win { + +// --------------- +// - Window - +// --------------- + +class Player; + +class Window : public ::cppu::WeakImplHelper2 < ::com::sun::star::media::XPlayerWindow, + ::com::sun::star::lang::XServiceInfo > +{ +public: + + Window( Player& rPlayer ); + ~Window(); + + bool create( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ); + void processGraphEvent(); + void updatePointer(); + + // XPlayerWindow + virtual void SAL_CALL update( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL setZoomLevel( ::com::sun::star::media::ZoomLevel ZoomLevel ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::media::ZoomLevel SAL_CALL getZoomLevel( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPointerType( sal_Int32 nPointerType ) throw (::com::sun::star::uno::RuntimeException); + + // XWindow + virtual void SAL_CALL setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Rectangle SAL_CALL getPosSize( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setVisible( sal_Bool Visible ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setEnable( sal_Bool Enable ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFocus( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); + +public: + + void fireMousePressedEvent( const ::com::sun::star::awt::MouseEvent& rEvt ); + void fireMouseReleasedEvent( const ::com::sun::star::awt::MouseEvent& rEvt ); + void fireMouseMovedEvent( const ::com::sun::star::awt::MouseEvent& rEvt ); + void fireKeyPressedEvent( const ::com::sun::star::awt::KeyEvent& rEvt ); + void fireKeyReleasedEvent( const ::com::sun::star::awt::KeyEvent& rEvt ); + void fireSetFocusEvent( const ::com::sun::star::awt::FocusEvent& rEvt ); + +private: + + ::osl::Mutex maMutex; + ::cppu::OMultiTypeInterfaceContainerHelper maListeners; + ::com::sun::star::media::ZoomLevel meZoomLevel; + Player& mrPlayer; + int mnFrameWnd; + int mnParentWnd; + int mnPointerType; + + static WNDCLASS* mpWndClass; + + void ImplLayoutVideoWindow(); +}; + +} // namespace win +} // namespace avmedia + +#endif // _WINDOW_HXX diff --git a/avmedia/source/win/winuno.cxx b/avmedia/source/win/winuno.cxx new file mode 100644 index 000000000000..768c4849b109 --- /dev/null +++ b/avmedia/source/win/winuno.cxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * $RCSfile: winuno.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "wincommon.hxx" +#include "manager.hxx" + +using namespace ::com::sun::star; + +// ------------------- +// - factory methods - +// ------------------- + +static uno::Reference< uno::XInterface > SAL_CALL create_MediaPlayer( const uno::Reference< lang::XMultiServiceFactory >& rxFact ) +{ + return uno::Reference< uno::XInterface >( *new ::avmedia::win::Manager( rxFact ) ); +} + +// ------------------------------------------ +// - component_getImplementationEnvironment - +// ------------------------------------------ + +extern "C" void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +// ----------------------- +// - component_writeInfo - +// ----------------------- + +extern "C" sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey ) +{ + sal_Bool bRet = sal_False; + + if( pRegistryKey ) + { + try + { + uno::Reference< registry::XRegistryKey > xNewKey1( + static_cast< registry::XRegistryKey* >( pRegistryKey )->createKey( + ::rtl::OUString::createFromAscii( "/com.sun.star.comp.media.Manager_DirectX/UNO/SERVICES/com.sun.star.media.Manager_DirectX" ) ) ); + + bRet = sal_True; + } + catch( registry::InvalidRegistryException& ) + { + OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); + } + } + + return bRet; +} + +// ------------------------ +// - component_getFactory - +// ------------------------ + +extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* pRegistryKey ) +{ + uno::Reference< lang::XSingleServiceFactory > xFactory; + void* pRet = 0; + + if( rtl_str_compare( pImplName, "com.sun.star.comp.media.Manager_DirectX" ) == 0 ) + { + const ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( "com.sun.star.media.Manager_DirectX" ) ); + + xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory( + reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ), + ::rtl::OUString::createFromAscii( "com.sun.star.comp.media.Manager_DirectX" ), + create_MediaPlayer, uno::Sequence< ::rtl::OUString >( &aServiceName, 1 ) ) ); + } + + if( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + + return pRet; +} diff --git a/avmedia/util/makefile.mk b/avmedia/util/makefile.mk new file mode 100644 index 000000000000..123c6dc328d5 --- /dev/null +++ b/avmedia/util/makefile.mk @@ -0,0 +1,112 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: ka $ $Date: 2004-08-23 09:04:41 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=.. +PRJNAME=avmedia +TARGET=avmedia + +# --- Settings ---------------------------------- + +.INCLUDE : settings.mk + +# --- Resources --------------------------------- + +RESLIB1NAME=$(TARGET) +RESLIB1IMAGES=$(PRJ)$/res +RESLIB1SRSFILES= \ + $(SRS)$/viewer.srs \ + $(SRS)$/framework.srs + +# --- Files ------------------------------------- + +LIB1TARGET=$(SLB)$/$(TARGET).lib +LIB1FILES=\ + $(SLB)$/viewer.lib \ + $(SLB)$/framework.lib + +# ========================================================================== + +SHL1TARGET=$(TARGET)$(UPD)$(DLLPOSTFIX) +SHL1IMPLIB=i$(TARGET) +SHL1STDLIBS=$(TOOLSLIB) $(CPPULIB) $(CPPUHELPERLIB) $(SALLIB) $(VCLLIB) $(COMPHELPERLIB) $(SVTOOLLIB) $(SVLLIB) $(SFXLIB) $(SOTLIB) $(VOSLIB) +SHL1DEF=$(MISC)$/$(SHL1TARGET).def +SHL1LIBS=$(SLB)$/$(TARGET).lib + +DEF1NAME=$(SHL1TARGET) +DEF1DEPN=$(MISC)$/$(SHL1TARGET).flt $(LIB1TARGET) +DEF1DES=Avmedia +DEFLIB1NAME =$(TARGET) + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk + +.IF "$(depend)"=="" +$(MISC)$/$(SHL1TARGET).flt: makefile.mk + @echo ------------------------------ + @echo Making: $@ + @echo Impl>$@ + @echo WEP>>$@ + @echo LIBMAIN>>$@ + @echo LibMain>>$@ + @echo CT>>$@ +.ENDIF |