Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/avmedia/source/framework/soundhandler.hxx
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
#pragma once
21
22
#include <com/sun/star/frame/XNotifyingDispatch.hpp>
23
#include <com/sun/star/frame/XStatusListener.hpp>
24
#include <com/sun/star/document/XExtendedFilterDetection.hpp>
25
#include <com/sun/star/media/XPlayer.hpp>
26
#include <com/sun/star/beans/PropertyValue.hpp>
27
#include <com/sun/star/util/URL.hpp>
28
29
#include <com/sun/star/lang/XServiceInfo.hpp>
30
31
#include <comphelper/compbase.hxx>
32
33
#include <vcl/timer.hxx>
34
#include <vcl/idle.hxx>
35
#include <tools/link.hxx>
36
37
namespace avmedia{
38
39
/*-************************************************************************************************************
40
    @short          handler to detect and play sounds ("wav" and "au" only!)
41
    @descr          Register this implementation as a content handler to detect and/or play wav- and au-sounds.
42
                    It doesn't depend from the target platform. But one instance of this class
43
                    can play one sound at the same time only. Means every new dispatch request will stop the
44
                    might still running one. So we support one operation/one URL/one listener at the same time
45
                    only.
46
47
    @devstatus      ready
48
    @threadsafe     yes
49
*//*-*************************************************************************************************************/
50
class SoundHandler : public comphelper::WeakImplHelper<css::lang::XServiceInfo,
51
                                                       css::frame::XNotifyingDispatch, // => XDispatch
52
                                                       css::document::XExtendedFilterDetection>
53
{
54
    // public methods
55
    public:
56
57
        // constructor / destructor
58
                 SoundHandler();
59
        virtual ~SoundHandler(                                                                        ) override;
60
61
        //  XServiceInfo
62
       virtual OUString                                               SAL_CALL getImplementationName              (                                                                               ) override;
63
       virtual sal_Bool                                               SAL_CALL supportsService                    ( const OUString&                                               sServiceName    ) override;
64
       virtual css::uno::Sequence< OUString >                         SAL_CALL getSupportedServiceNames           (                                                                               ) override;
65
66
        //  XNotifyingDispatch
67
        virtual void SAL_CALL dispatchWithNotification(const css::util::URL&                                             aURL      ,
68
                                                       const css::uno::Sequence< css::beans::PropertyValue >&            lArguments,
69
                                                       const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) override;
70
71
        //  XDispatch
72
        virtual void SAL_CALL dispatch              (   const   css::util::URL&                                     aURL        ,
73
                                                        const   css::uno::Sequence< css::beans::PropertyValue >&    lArguments  ) override;
74
        // not supported !
75
        virtual void SAL_CALL addStatusListener     (   const   css::uno::Reference< css::frame::XStatusListener >& /*xListener*/   ,
76
0
                                                        const   css::util::URL&                                     /*aURL*/        ) override {};
77
        virtual void SAL_CALL removeStatusListener  (   const   css::uno::Reference< css::frame::XStatusListener >& /*xListener*/   ,
78
0
                                                        const   css::util::URL&                                     /*aURL*/        ) override {};
79
80
        //  XExtendedFilterDetection
81
        virtual OUString SAL_CALL detect           (           css::uno::Sequence< css::beans::PropertyValue >&    lDescriptor ) override;
82
83
    //  protected methods
84
    protected:
85
86
    //  private methods
87
    private:
88
        DECL_LINK( implts_PlayerNotify, Timer*, void );
89
90
    //  variables
91
    //  (should be private everyway!)
92
    private:
93
94
        bool m_bError;
95
        css::uno::Reference< css::uno::XInterface >                m_xSelfHold         ;   // we must protect us against dying during async(!) dispatch() call!
96
        css::uno::Reference< css::media::XPlayer >                 m_xPlayer           ;   // uses avmedia player to play sounds...
97
98
        css::uno::Reference< css::frame::XDispatchResultListener > m_xListener         ;
99
        Idle m_aUpdateIdle;
100
101
};      //  class SoundHandler
102
103
}       //  namespace avmedia
104
105
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */