1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <avmedia/mediaplayer.hxx>
21 #include <avmedia/mediawindow.hxx>
22 #include <avmedia/mediaitem.hxx>
23 #include "mediamisc.hxx"
24 #include "mediacontrol.hrc"
25 #include "helpids.hrc"
27 #include <svl/stritem.hxx>
28 #include <sfx2/app.hxx>
29 #include <sfx2/sfxsids.hrc>
30 #include <sfx2/bindings.hxx>
31 #include <sfx2/dispatch.hxx>
40 MediaPlayer::MediaPlayer( Window
* _pParent
, sal_uInt16 nId
, SfxBindings
* _pBindings
, SfxChildWinInfo
* pInfo
) :
41 SfxChildWindow( _pParent
, nId
)
43 pWindow
= new MediaFloater( _pBindings
, this, _pParent
);
44 eChildAlignment
= SFX_ALIGN_NOALIGNMENT
;
45 static_cast< MediaFloater
* >( pWindow
)->Initialize( pInfo
);
48 // -----------------------------------------------------------------------------
50 MediaPlayer::~MediaPlayer()
54 // -----------------------------------------------------------------------------
56 SFX_IMPL_DOCKINGWINDOW_WITHID( MediaPlayer
, SID_AVMEDIA_PLAYER
)
62 MediaFloater::MediaFloater( SfxBindings
* _pBindings
, SfxChildWindow
* pCW
, Window
* pParent
) :
63 SfxDockingWindow( _pBindings
, pCW
, pParent
, WB_CLOSEABLE
| WB_MOVEABLE
| WB_SIZEABLE
| WB_DOCKABLE
),
64 mpMediaWindow( new MediaWindow( this, true ) )
66 const Size
aSize( 378, 256 );
68 SetPosSizePixel( Point( 0, 0 ), aSize
);
69 SetMinOutputSizePixel( aSize
);
70 SetText( String( AVMEDIA_RESID( AVMEDIA_STR_MEDIAPLAYER
) ) );
72 mpMediaWindow
->show();
75 // -----------------------------------------------------------------------------
77 MediaFloater::~MediaFloater()
83 // -----------------------------------------------------------------------------
85 void MediaFloater::implInit()
89 // -------------------------------------------------------------------------
91 void MediaFloater::Resize()
93 SfxDockingWindow::Resize();
96 mpMediaWindow
->setPosSize( Rectangle( Point(), GetOutputSizePixel() ) );
99 // -----------------------------------------------------------------------------
101 void MediaFloater::ToggleFloatingMode()
103 ::avmedia::MediaItem aRestoreItem
;
105 mpMediaWindow
->updateMediaItem( aRestoreItem
);
106 delete mpMediaWindow
;
107 mpMediaWindow
= NULL
;
109 SfxDockingWindow::ToggleFloatingMode();
111 mpMediaWindow
= new MediaWindow( this, true );
113 mpMediaWindow
->setPosSize( Rectangle( Point(), GetOutputSizePixel() ) );
114 mpMediaWindow
->executeMediaItem( aRestoreItem
);
116 Window
* pWindow
= mpMediaWindow
->getWindow();
119 pWindow
->SetHelpId( HID_AVMEDIA_PLAYERWINDOW
);
121 mpMediaWindow
->show();
124 // -----------------------------------------------------------------------------
126 void MediaFloater::setURL( const OUString
& rURL
, bool bPlayImmediately
)
130 mpMediaWindow
->setURL( rURL
);
132 if( mpMediaWindow
->isValid() && bPlayImmediately
)
133 mpMediaWindow
->start();
137 // -----------------------------------------------------------------------------
139 const OUString
& MediaFloater::getURL() const
141 static const OUString aEmptyStr
;
142 return( mpMediaWindow
? mpMediaWindow
->getURL() : aEmptyStr
);
145 // -----------------------------------------------------------------------------
147 void MediaFloater::dispatchCurrentURL()
149 SfxDispatcher
* pDispatcher
= GetBindings().GetDispatcher();
153 const SfxStringItem
aMediaURLItem( SID_INSERT_AVMEDIA
, getURL() );
154 pDispatcher
->Execute( SID_INSERT_AVMEDIA
, SFX_CALLMODE_RECORD
, &aMediaURLItem
, 0L );
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */