1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_SLIDESHOW_VIEWMEDIASHAPE_HXX
25 #define INCLUDED_SLIDESHOW_VIEWMEDIASHAPE_HXX
26 
27 #include <basegfx/range/b2drectangle.hxx>
28 #include <com/sun/star/awt/Point.hpp>
29 
30 #include <boost/shared_ptr.hpp>
31 #include <boost/utility.hpp>
32 
33 #include "viewlayer.hxx"
34 
35 class SystemChildWindow;
36 
37 namespace com { namespace sun { namespace star { namespace drawing {
38     class XShape;
39 }
40 namespace media {
41     class XPlayer;
42     class XPlayerWindow;
43 }
44 namespace uno {
45     class XComponentContext;
46 }
47 namespace beans{
48     class XPropertySet;
49 } } } }
50 
51 namespace slideshow
52 {
53     namespace internal
54     {
55         /** This class is the viewable representation of a draw
56             document's media object, associated to a specific View
57 
58             The class is able to render the associated media shape on
59             View implementations.
60          */
61         class ViewMediaShape : private boost::noncopyable
62         {
63         public:
64             /** Create a ViewMediaShape for the given View
65 
66             	@param rView
67                 The associated View object.
68              */
69             ViewMediaShape( const ViewLayerSharedPtr&                          rViewLayer,
70                             const ::com::sun::star::uno::Reference<
71                                   ::com::sun::star::drawing::XShape >&         rxShape,
72                              const ::com::sun::star::uno::Reference<
73                                    ::com::sun::star::uno::XComponentContext >& rxContext );
74 
75             /** destroy the object
76              */
77             virtual ~ViewMediaShape();
78 
79             /** Query the associated view layer of this shape
80              */
81             ViewLayerSharedPtr getViewLayer() const;
82 
83             // animation methods
84             //------------------------------------------------------------------
85 
86             /** Notify the ViewShape that an animation starts now
87 
88 				This method enters animation mode on the associate
89 				target view. The shape can be animated in parallel on
90 				different views.
91 
92 	            @return whether the mode change finished successfully.
93              */
94             bool startMedia();
95 
96             /** Notify the ViewShape that it is no longer animated
97 
98 				This methods ends animation mode on the associate
99 				target view
100              */
101             void endMedia();
102 
103             /** Notify the ViewShape that it should pause playback
104 
105 				This methods pauses animation on the associate
106 				target view. The content stays visible (for video)
107              */
108             void pauseMedia();
109 
110             /** Set current time of media.
111 
112             @param fTime
113             Local media time that should now be presented, in seconds.
114              */
115             void setMediaTime(double fTime);
116 
117             // render methods
118             //------------------------------------------------------------------
119 
120             /** Render the ViewShape
121 
122 				This method renders the ViewMediaShape on the associated view.
123 
124                 @param rBounds
125                 The current media shape bounds
126 
127 	            @return whether the rendering finished successfully.
128             */
129             bool render( const ::basegfx::B2DRectangle&	rBounds ) const;
130 
131             /** Resize the ViewShape
132 
133 				This method updates the ViewMediaShape size on the
134 				associated view. It does not render.
135 
136                 @param rBounds
137                 The current media shape bounds
138 
139 	            @return whether the resize finished successfully.
140             */
141             bool resize( const ::basegfx::B2DRectangle&	rNewBounds ) const;
142 
143         private:
144 
145 			bool implInitialize( const ::basegfx::B2DRectangle& rBounds );
146 			void implSetMediaProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rxProps );
147 			void implInitializeMediaPlayer( const ::rtl::OUString& rMediaURL );
148 			bool implInitializeVCLBasedPlayerWindow( const ::basegfx::B2DRectangle& rBounds,
149 													 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rVCLDeviceParams );
150 			bool implInitializeDXBasedPlayerWindow( const ::basegfx::B2DRectangle& rBounds,
151 													const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rDXDeviceParams );
152 
153 			ViewLayerSharedPtr					  mpViewLayer;
154 			::std::auto_ptr< SystemChildWindow >    mpMediaWindow;
155 			mutable ::com::sun::star::awt::Point  maWindowOffset;
156             mutable ::basegfx::B2DRectangle       maBounds;
157 
158 			::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >		mxShape;
159 			::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer >		mxPlayer;
160 			::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow >	mxPlayerWindow;
161             ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>	mxComponentContext;
162             bool mbIsSoundEnabled;
163 		};
164 
165         typedef ::boost::shared_ptr< ViewMediaShape > ViewMediaShapeSharedPtr;
166 
167     }
168 }
169 
170 #endif /* INCLUDED_SLIDESHOW_VIEWMEDIASHAPE_HXX */
171