LibreOffice Module avmedia (master) 1
mediawindow.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <vector>
23#include <tools/gen.hxx>
24#include <com/sun/star/awt/Size.hpp>
25#include <com/sun/star/uno/Reference.hxx>
26#include <com/sun/star/media/XPlayerListener.hpp>
29#include <vcl/vclptr.hxx>
31
32#define AVMEDIA_FRAMEGRABBER_DEFAULTFRAME -1.0
33
35namespace com::sun::star::graphic { class XGraphic; }
36namespace com::sun::star::media {
37 class XPlayer;
38 class XPlayerNotifier;
39}
40
41namespace vcl { class Window; }
42namespace weld { class Window; }
43class KeyEvent;
44class MouseEvent;
45class CommandEvent;
46struct AcceptDropEvent;
47struct ExecuteDropEvent;
48enum class PointerStyle;
49
50namespace avmedia
51{
52 typedef ::std::vector< ::std::pair< OUString, OUString > > FilterNameVector;
53
54 class MediaItem;
55
56 namespace priv { class MediaWindowImpl; }
57
58 typedef cppu::WeakComponentImplHelper<css::media::XPlayerListener> PlayerListener_BASE;
59
61 {
62 private:
63 css::uno::Reference<css::media::XPlayerNotifier> m_xNotifier;
64 std::function<void(const css::uno::Reference<css::media::XPlayer>&)> m_aFn;
65
66 using WeakComponentImplHelperBase::disposing;
67 public:
68 PlayerListener(std::function<void(const css::uno::Reference<css::media::XPlayer>&)> fn);
69 virtual void SAL_CALL dispose() override;
70 virtual ~PlayerListener() override;
71
72 virtual void SAL_CALL preferredPlayerWindowSizeAvailable(const css::lang::EventObject& rSource) override;
73 virtual void SAL_CALL disposing(const css::lang::EventObject& rSource) override;
74
75 void startListening(const css::uno::Reference<css::media::XPlayerNotifier>& rNotifier);
76 void stopListening();
77
78 void callPlayerWindowSizeAvailable(const css::uno::Reference<css::media::XPlayer>& rPlayer) { m_aFn(rPlayer); }
79 };
80
82 {
83 public:
84 MediaWindow( vcl::Window* parent, bool bInternalMediaControl );
85 virtual ~MediaWindow();
86
87 void setURL( const OUString& rURL, const OUString& rReferer );
88 const OUString& getURL() const;
89
90 bool isValid() const;
91 Size getPreferredSize() const;
92
93 vcl::Window* getWindow() const;
94
95 void setPosSize( const tools::Rectangle& rNewRect );
96
97 void setPointer( PointerStyle aPointer );
98
99 bool start();
100
101 void updateMediaItem( MediaItem& rItem ) const;
102 void executeMediaItem( const MediaItem& rItem );
103
104 void show();
105 void hide();
106 bool isVisible() const;
107
108 public:
109
110 virtual void MouseMove( const MouseEvent& rMEvt );
111 virtual void MouseButtonDown( const MouseEvent& rMEvt );
112 virtual void MouseButtonUp( const MouseEvent& rMEvt );
113
114 virtual void KeyInput( const KeyEvent& rKEvt );
115 virtual void KeyUp( const KeyEvent& rKEvt );
116
117 virtual void Command( const CommandEvent& rCEvt );
118
119 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
120 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
121
122 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
123
124 public:
125
126 static FilterNameVector getMediaFilters();
129 static bool executeMediaURLDialog(weld::Window* pParent, OUString& rURL, bool *const o_pbLink);
130 static void executeFormatErrorBox(weld::Window* pParent);
131 static bool isMediaURL(std::u16string_view rURL, const OUString& rReferer, bool bDeep = false,
132 rtl::Reference<PlayerListener> xPreferredPixelSizeListener = nullptr);
133
134 static css::uno::Reference< css::media::XPlayer > createPlayer( const OUString& rURL, const OUString& rReferer, const OUString* pMimeType = nullptr );
135
136 static css::uno::Reference<css::graphic::XGraphic>
137 grabFrame(const css::uno::Reference<css::media::XPlayer>& rPlayer,
138 const css::uno::Reference<css::graphic::XGraphic>& rGraphic = nullptr);
139
140 static css::uno::Reference< css::graphic::XGraphic > grabFrame(const OUString& rURL, const OUString& rReferer,
141 const OUString& sMimeType, rtl::Reference<PlayerListener> xPreferredPixelSizeListener);
142
143 static void dispatchInsertAVMedia(const css::uno::Reference<css::frame::XDispatchProvider>&,
144 const css::awt::Size& rSize, const OUString& rURL, bool bLink);
145
146 private:
147 MediaWindow(const MediaWindow&) = delete;
148 MediaWindow& operator =( const MediaWindow& ) = delete;
149
151 };
152
153}
154
155/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define AVMEDIA_DLLPUBLIC
Definition: avmediadllapi.h:27
VclPtr< priv::MediaWindowImpl > mpImpl
MediaWindow(const MediaWindow &)=delete
static css::uno::Reference< css::graphic::XGraphic > grabFrame(const css::uno::Reference< css::media::XPlayer > &rPlayer, const css::uno::Reference< css::graphic::XGraphic > &rGraphic=nullptr)
css::uno::Reference< css::media::XPlayerNotifier > m_xNotifier
Definition: mediawindow.hxx:63
std::function< void(const css::uno::Reference< css::media::XPlayer > &)> m_aFn
Definition: mediawindow.hxx:64
void callPlayerWindowSizeAvailable(const css::uno::Reference< css::media::XPlayer > &rPlayer)
Definition: mediawindow.hxx:78
::std::vector< ::std::pair< OUString, OUString > > FilterNameVector
Definition: mediawindow.hxx:52
cppu::WeakComponentImplHelper< css::media::XPlayerListener > PlayerListener_BASE
Definition: mediawindow.hxx:58
void dispose()
PointerStyle
@ MouseButtonDown
signed char sal_Int8