Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/avmedia/source/framework/mediaplayer.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
20
#include <avmedia/mediaplayer.hxx>
21
#include <avmedia/mediawindow.hxx>
22
#include <avmedia/mediaitem.hxx>
23
#include <mediamisc.hxx>
24
#include <strings.hrc>
25
#include <helpids.h>
26
27
#include <svl/stritem.hxx>
28
#include <svl/itemset.hxx>
29
#include <sfx2/sfxsids.hrc>
30
#include <sfx2/bindings.hxx>
31
#include <sfx2/dispatch.hxx>
32
33
namespace avmedia
34
{
35
36
MediaPlayer::MediaPlayer(vcl::Window* _pParent, sal_uInt16 nId, SfxBindings& rBindings,
37
                         SfxChildWinInfo& rInfo)
38
0
    : SfxChildWindow(_pParent, nId)
39
0
{
40
0
    SetWindow(VclPtr<MediaFloater>::Create(rBindings, this, _pParent));
41
0
    static_cast<MediaFloater*>(GetWindow())->Initialize(rInfo);
42
0
};
43
44
45
MediaPlayer::~MediaPlayer()
46
0
{
47
0
}
48
49
50
SFX_IMPL_DOCKINGWINDOW_WITHID( MediaPlayer, SID_AVMEDIA_PLAYER )
51
52
MediaFloater::MediaFloater(SfxBindings& rBindings, SfxChildWindow* pCW, vcl::Window* pParent)
53
0
    : SfxDockingWindow(rBindings, pCW, pParent,
54
0
                       WB_CLOSEABLE | WB_MOVEABLE | WB_SIZEABLE | WB_DOCKABLE)
55
0
    , mpMediaWindow(new MediaWindow(this, true))
56
0
{
57
0
    const Size aSize( mpMediaWindow->getPreferredSize() );
58
59
0
    SetPosSizePixel( Point( 0, 0 ), aSize );
60
0
    SetMinOutputSizePixel( aSize );
61
0
    SetText( AvmResId( AVMEDIA_STR_MEDIAPLAYER ) );
62
0
    mpMediaWindow->show();
63
0
}
Unexecuted instantiation: avmedia::MediaFloater::MediaFloater(SfxBindings&, SfxChildWindow*, vcl::Window*)
Unexecuted instantiation: avmedia::MediaFloater::MediaFloater(SfxBindings&, SfxChildWindow*, vcl::Window*)
64
65
66
MediaFloater::~MediaFloater()
67
0
{
68
0
    disposeOnce();
69
0
}
70
71
void MediaFloater::dispose()
72
0
{
73
0
    if (IsFloatingMode())
74
0
    {
75
0
        Show(false, ShowFlags::NoFocusChange);
76
0
        SetFloatingMode(false);
77
0
    }
78
0
    mpMediaWindow.reset();
79
0
    SfxDockingWindow::dispose();
80
0
}
81
82
void MediaFloater::Resize()
83
0
{
84
0
    SfxDockingWindow::Resize();
85
86
0
    if( mpMediaWindow )
87
0
        mpMediaWindow->setPosSize( tools::Rectangle( Point(), GetOutputSizePixel() ) );
88
0
}
89
90
void MediaFloater::ToggleFloatingMode()
91
0
{
92
0
    ::avmedia::MediaItem aRestoreItem;
93
94
0
    if (mpMediaWindow)
95
0
        mpMediaWindow->updateMediaItem( aRestoreItem );
96
0
    mpMediaWindow.reset();
97
98
0
    SfxDockingWindow::ToggleFloatingMode();
99
100
0
    if (isDisposed())
101
0
        return;
102
103
0
    mpMediaWindow.reset( new MediaWindow( this, true ) );
104
105
0
    mpMediaWindow->setPosSize( tools::Rectangle( Point(), GetOutputSizePixel() ) );
106
0
    mpMediaWindow->executeMediaItem( aRestoreItem );
107
108
0
    vcl::Window* pWindow = mpMediaWindow->getWindow();
109
110
0
    if( pWindow )
111
0
        pWindow->SetHelpId( HID_AVMEDIA_PLAYERWINDOW );
112
113
0
    mpMediaWindow->show();
114
0
}
115
116
117
void MediaFloater::setURL( const OUString& rURL, const OUString& rReferer, bool bPlayImmediately )
118
0
{
119
0
    if( mpMediaWindow )
120
0
    {
121
0
        mpMediaWindow->setURL( rURL, rReferer );
122
123
0
        if( mpMediaWindow->isValid() && bPlayImmediately )
124
0
            mpMediaWindow->start();
125
0
    }
126
0
}
127
128
129
void MediaFloater::dispatchCurrentURL()
130
0
{
131
0
    SfxDispatcher* pDispatcher = GetBindings().GetDispatcher();
132
133
0
    if( pDispatcher )
134
0
    {
135
0
        OUString url;
136
0
        if (mpMediaWindow != nullptr) {
137
0
            url = mpMediaWindow->getURL();
138
0
        }
139
0
        const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, url );
140
0
        pDispatcher->ExecuteList(SID_INSERT_AVMEDIA, SfxCallMode::RECORD,
141
0
                { &aMediaURLItem });
142
0
    }
143
0
}
144
145
} // namespace avmedia
146
147
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */