Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <avmedia/mediaplayer.hxx>
30 : : #include <avmedia/mediawindow.hxx>
31 : : #include <avmedia/mediaitem.hxx>
32 : : #include "mediamisc.hxx"
33 : : #include "mediacontrol.hrc"
34 : : #include "helpids.hrc"
35 : :
36 : : #include <svl/stritem.hxx>
37 : : #include <sfx2/app.hxx>
38 : : #include <sfx2/sfxsids.hrc>
39 : : #include <sfx2/bindings.hxx>
40 : : #include <sfx2/dispatch.hxx>
41 : :
42 : : namespace avmedia
43 : : {
44 : :
45 : : // ---------------
46 : : // - MediaPlayer -
47 : : // ---------------
48 : :
49 : 0 : MediaPlayer::MediaPlayer( Window* _pParent, sal_uInt16 nId, SfxBindings* _pBindings, SfxChildWinInfo* pInfo ) :
50 : 0 : SfxChildWindow( _pParent, nId )
51 : : {
52 [ # # ][ # # ]: 0 : pWindow = new MediaFloater( _pBindings, this, _pParent );
53 : 0 : eChildAlignment = SFX_ALIGN_NOALIGNMENT;
54 [ # # ]: 0 : static_cast< MediaFloater* >( pWindow )->Initialize( pInfo );
55 : 0 : };
56 : :
57 : : // -----------------------------------------------------------------------------
58 : :
59 : 0 : MediaPlayer::~MediaPlayer()
60 : : {
61 [ # # ]: 0 : }
62 : :
63 : : // -----------------------------------------------------------------------------
64 : :
65 [ # # ][ + - ]: 221 : SFX_IMPL_DOCKINGWINDOW_WITHID( MediaPlayer, SID_AVMEDIA_PLAYER )
[ # # ]
66 : :
67 : : // ----------------
68 : : // - MediaFloater -
69 : : // ----------------
70 : :
71 : 0 : MediaFloater::MediaFloater( SfxBindings* _pBindings, SfxChildWindow* pCW, Window* pParent ) :
72 : : SfxDockingWindow( _pBindings, pCW, pParent, WB_CLOSEABLE | WB_MOVEABLE | WB_SIZEABLE | WB_DOCKABLE ),
73 [ # # ][ # # ]: 0 : mpMediaWindow( new MediaWindow( this, true ) )
74 : : {
75 : 0 : const Size aSize( 378, 256 );
76 : :
77 [ # # ]: 0 : SetPosSizePixel( Point( 0, 0 ), aSize );
78 [ # # ]: 0 : SetMinOutputSizePixel( aSize );
79 [ # # ][ # # ]: 0 : SetText( String( AVMEDIA_RESID( AVMEDIA_STR_MEDIAPLAYER ) ) );
[ # # ][ # # ]
80 : 0 : implInit();
81 [ # # ]: 0 : mpMediaWindow->show();
82 : 0 : }
83 : :
84 : : // -----------------------------------------------------------------------------
85 : :
86 : 0 : MediaFloater::~MediaFloater()
87 : : {
88 [ # # ][ # # ]: 0 : delete mpMediaWindow;
89 : 0 : mpMediaWindow = NULL;
90 [ # # ]: 0 : }
91 : :
92 : : // -----------------------------------------------------------------------------
93 : :
94 : 0 : void MediaFloater::implInit()
95 : : {
96 : 0 : }
97 : :
98 : : // -------------------------------------------------------------------------
99 : :
100 : 0 : void MediaFloater::Resize()
101 : : {
102 : 0 : SfxDockingWindow::Resize();
103 : :
104 [ # # ]: 0 : if( mpMediaWindow )
105 [ # # ][ # # ]: 0 : mpMediaWindow->setPosSize( Rectangle( Point(), GetOutputSizePixel() ) );
106 : 0 : }
107 : :
108 : : // -----------------------------------------------------------------------------
109 : :
110 : 0 : void MediaFloater::ToggleFloatingMode()
111 : : {
112 [ # # ]: 0 : ::avmedia::MediaItem aRestoreItem;
113 : :
114 [ # # ]: 0 : mpMediaWindow->updateMediaItem( aRestoreItem );
115 [ # # ][ # # ]: 0 : delete mpMediaWindow;
116 : 0 : mpMediaWindow = NULL;
117 : :
118 [ # # ]: 0 : SfxDockingWindow::ToggleFloatingMode();
119 : :
120 [ # # ][ # # ]: 0 : mpMediaWindow = new MediaWindow( this, true );
121 : :
122 [ # # ][ # # ]: 0 : mpMediaWindow->setPosSize( Rectangle( Point(), GetOutputSizePixel() ) );
[ # # ]
123 [ # # ]: 0 : mpMediaWindow->executeMediaItem( aRestoreItem );
124 : :
125 [ # # ]: 0 : Window* pWindow = mpMediaWindow->getWindow();
126 : :
127 [ # # ]: 0 : if( pWindow )
128 [ # # ]: 0 : pWindow->SetHelpId( HID_AVMEDIA_PLAYERWINDOW );
129 : :
130 [ # # ][ # # ]: 0 : mpMediaWindow->show();
131 : 0 : }
132 : :
133 : : // -----------------------------------------------------------------------------
134 : :
135 : 0 : void MediaFloater::setURL( const ::rtl::OUString& rURL, bool bPlayImmediately )
136 : : {
137 [ # # ]: 0 : if( mpMediaWindow )
138 : : {
139 : 0 : mpMediaWindow->setURL( rURL );
140 : :
141 [ # # ][ # # ]: 0 : if( mpMediaWindow->isValid() && bPlayImmediately )
[ # # ]
142 : 0 : mpMediaWindow->start();
143 : : }
144 : 0 : }
145 : :
146 : : // -----------------------------------------------------------------------------
147 : :
148 : 0 : const ::rtl::OUString& MediaFloater::getURL() const
149 : : {
150 [ # # ][ # # ]: 0 : static const ::rtl::OUString aEmptyStr;
151 [ # # ]: 0 : return( mpMediaWindow ? mpMediaWindow->getURL() : aEmptyStr );
152 : : }
153 : :
154 : : // -----------------------------------------------------------------------------
155 : :
156 : 0 : void MediaFloater::dispatchCurrentURL()
157 : : {
158 : 0 : SfxDispatcher* pDispatcher = GetBindings().GetDispatcher();
159 : :
160 [ # # ]: 0 : if( pDispatcher )
161 : : {
162 [ # # ][ # # ]: 0 : const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, getURL() );
[ # # ][ # # ]
163 [ # # ][ # # ]: 0 : pDispatcher->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_RECORD, &aMediaURLItem, 0L );
164 : : }
165 : 0 : }
166 : :
167 : : }
168 : :
169 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|