1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef INCLUDED_SLIDESHOW_VIEWMEDIASHAPE_HXX 29 #define INCLUDED_SLIDESHOW_VIEWMEDIASHAPE_HXX 30 31 #include <basegfx/range/b2drectangle.hxx> 32 #include <com/sun/star/awt/Point.hpp> 33 34 #include <boost/shared_ptr.hpp> 35 #include <boost/utility.hpp> 36 37 #include "viewlayer.hxx" 38 39 class SystemChildWindow; 40 41 namespace com { namespace sun { namespace star { namespace drawing { 42 class XShape; 43 } 44 namespace media { 45 class XPlayer; 46 class XPlayerWindow; 47 } 48 namespace uno { 49 class XComponentContext; 50 } 51 namespace beans{ 52 class XPropertySet; 53 } } } } 54 55 namespace slideshow 56 { 57 namespace internal 58 { 59 /** This class is the viewable representation of a draw 60 document's media object, associated to a specific View 61 62 The class is able to render the associated media shape on 63 View implementations. 64 */ 65 class ViewMediaShape : private boost::noncopyable 66 { 67 public: 68 /** Create a ViewMediaShape for the given View 69 70 @param rView 71 The associated View object. 72 */ 73 ViewMediaShape( const ViewLayerSharedPtr& rViewLayer, 74 const ::com::sun::star::uno::Reference< 75 ::com::sun::star::drawing::XShape >& rxShape, 76 const ::com::sun::star::uno::Reference< 77 ::com::sun::star::uno::XComponentContext >& rxContext ); 78 79 /** destroy the object 80 */ 81 virtual ~ViewMediaShape(); 82 83 /** Query the associated view layer of this shape 84 */ 85 ViewLayerSharedPtr getViewLayer() const; 86 87 // animation methods 88 //------------------------------------------------------------------ 89 90 /** Notify the ViewShape that an animation starts now 91 92 This method enters animation mode on the associate 93 target view. The shape can be animated in parallel on 94 different views. 95 96 @return whether the mode change finished successfully. 97 */ 98 bool startMedia(); 99 100 /** Notify the ViewShape that it is no longer animated 101 102 This methods ends animation mode on the associate 103 target view 104 */ 105 void endMedia(); 106 107 /** Notify the ViewShape that it should pause playback 108 109 This methods pauses animation on the associate 110 target view. The content stays visible (for video) 111 */ 112 void pauseMedia(); 113 114 /** Set current time of media. 115 116 @param fTime 117 Local media time that should now be presented, in seconds. 118 */ 119 void setMediaTime(double fTime); 120 121 // render methods 122 //------------------------------------------------------------------ 123 124 /** Render the ViewShape 125 126 This method renders the ViewMediaShape on the associated view. 127 128 @param rBounds 129 The current media shape bounds 130 131 @return whether the rendering finished successfully. 132 */ 133 bool render( const ::basegfx::B2DRectangle& rBounds ) const; 134 135 /** Resize the ViewShape 136 137 This method updates the ViewMediaShape size on the 138 associated view. It does not render. 139 140 @param rBounds 141 The current media shape bounds 142 143 @return whether the resize finished successfully. 144 */ 145 bool resize( const ::basegfx::B2DRectangle& rNewBounds ) const; 146 147 private: 148 149 bool implInitialize( const ::basegfx::B2DRectangle& rBounds ); 150 void implSetMediaProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rxProps ); 151 void implInitializeMediaPlayer( const ::rtl::OUString& rMediaURL ); 152 bool implInitializeVCLBasedPlayerWindow( const ::basegfx::B2DRectangle& rBounds, 153 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rVCLDeviceParams ); 154 bool implInitializeDXBasedPlayerWindow( const ::basegfx::B2DRectangle& rBounds, 155 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rDXDeviceParams ); 156 157 ViewLayerSharedPtr mpViewLayer; 158 ::std::auto_ptr< SystemChildWindow > mpMediaWindow; 159 mutable ::com::sun::star::awt::Point maWindowOffset; 160 mutable ::basegfx::B2DRectangle maBounds; 161 162 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mxShape; 163 ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > mxPlayer; 164 ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > mxPlayerWindow; 165 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> mxComponentContext; 166 bool mbIsSoundEnabled; 167 }; 168 169 typedef ::boost::shared_ptr< ViewMediaShape > ViewMediaShapeSharedPtr; 170 171 } 172 } 173 174 #endif /* INCLUDED_SLIDESHOW_VIEWMEDIASHAPE_HXX */ 175