Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/avmedia/mediaitem.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 <svl/poolitem.hxx>
23
#include <avmedia/avmediadllapi.h>
24
#include <memory>
25
#include <string_view>
26
27
#include <o3tl/typed_flags_set.hxx>
28
#include <utility>
29
30
namespace com::sun::star::embed { class XStorage; }
31
namespace com::sun::star::frame { class XModel; }
32
namespace com::sun::star::io { class XInputStream; }
33
namespace com::sun::star::io { class XStream; }
34
namespace com::sun::star::media { enum class ZoomLevel; }
35
namespace com::sun::star::text { struct GraphicCrop; }
36
class Graphic;
37
38
enum class AVMediaSetMask
39
{
40
    NONE        = 0x000,
41
    STATE       = 0x001,
42
    DURATION    = 0x002,
43
    TIME        = 0x004,
44
    LOOP        = 0x008,
45
    MUTE        = 0x010,
46
    VOLUMEDB    = 0x020,
47
    ZOOM        = 0x040,
48
    URL         = 0x080,
49
    MIME_TYPE   = 0x100,
50
    GRAPHIC     = 0x200,
51
    CROP        = 0x400,
52
    ALL         = 0x7ff,
53
};
54
namespace o3tl
55
{
56
    template<> struct typed_flags<AVMediaSetMask> : is_typed_flags<AVMediaSetMask, 0x7ff> {};
57
}
58
59
60
namespace avmedia
61
{
62
63
64
enum class MediaState
65
{
66
    Stop, Play, Pause
67
};
68
69
70
class AVMEDIA_DLLPUBLIC MediaItem final : public SfxPoolItem
71
{
72
public:
73
                            static SfxPoolItem* CreateDefault();
74
75
    DECLARE_ITEM_TYPE_FUNCTION(MediaItem)
76
    explicit                MediaItem( sal_uInt16 i_nWhich = 0,
77
                                       AVMediaSetMask nMaskSet = AVMediaSetMask::NONE );
78
                            MediaItem( const MediaItem& rMediaItem );
79
    virtual                 ~MediaItem() override;
80
81
    virtual bool            operator==( const SfxPoolItem& ) const override;
82
    virtual MediaItem*      Clone( SfxItemPool* pPool = nullptr ) const override;
83
    virtual bool            GetPresentation( SfxItemPresentation ePres,
84
                                                 MapUnit eCoreUnit,
85
                                                 MapUnit ePresUnit,
86
                                                 OUString&  rText,
87
                                                 const IntlWrapper& rIntl ) const override;
88
    virtual bool            QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
89
    virtual bool            PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
90
91
    bool                    merge(const MediaItem& rMediaItem);
92
93
    AVMediaSetMask          getMaskSet() const;
94
95
    bool                    setState(MediaState eState);
96
    MediaState              getState() const;
97
98
    bool                    setDuration(double fDuration);
99
    double                  getDuration() const;
100
101
    bool                    setTime(double fTime);
102
    double                  getTime() const;
103
104
    bool                    setLoop(bool bLoop);
105
    bool                    isLoop() const;
106
107
    bool                    setMute(bool bMute);
108
    bool                    isMute() const;
109
110
    bool                    setVolumeDB(sal_Int16 nDB);
111
    sal_Int16               getVolumeDB() const;
112
113
    bool                    setZoom(css::media::ZoomLevel eZoom);
114
    ::css::media::ZoomLevel getZoom() const;
115
116
    bool                    setURL(const OUString& rURL,
117
                                   const OUString& rTempURL,
118
                                   const OUString& rReferer);
119
    const OUString&         getURL() const;
120
121
    bool                    setFallbackURL(const OUString& rURL);
122
    const OUString&         getFallbackURL() const;
123
124
    bool                    setMimeType(const OUString& rMimeType);
125
    const OUString&         getMimeType() const;
126
    bool setGraphic(const Graphic& rGraphic);
127
    const Graphic & getGraphic() const;
128
    bool setCrop(const css::text::GraphicCrop& rCrop);
129
    const css::text::GraphicCrop& getCrop() const;
130
    const OUString&         getTempURL() const;
131
132
    const OUString&         getReferer() const;
133
134
private:
135
136
    struct Impl;
137
    std::unique_ptr<Impl> m_pImpl;
138
};
139
140
typedef ::avmedia::MediaItem avmedia_MediaItem;
141
142
bool AVMEDIA_DLLPUBLIC EmbedMedia(
143
        const ::css::uno::Reference< ::css::frame::XModel>& xModel,
144
        const OUString& rSourceURL,
145
        OUString & o_rEmbeddedURL,
146
        ::css::uno::Reference<::css::io::XInputStream> const& xInputStream =
147
            ::css::uno::Reference<::css::io::XInputStream>());
148
149
bool AVMEDIA_DLLPUBLIC CreateMediaTempFile(
150
        ::css::uno::Reference<::css::io::XInputStream> const& xInStream,
151
        OUString& o_rTempFileURL,
152
        std::u16string_view rDesiredExtension);
153
154
OUString GetFilename(OUString const& rSourceURL);
155
156
::css::uno::Reference< ::css::io::XStream> CreateStream(
157
    const ::css::uno::Reference< ::css::embed::XStorage>& xStorage, const OUString& rFilename);
158
159
struct AVMEDIA_DLLPUBLIC MediaTempFile
160
{
161
    OUString const m_TempFileURL;
162
    MediaTempFile(OUString aURL)
163
0
        : m_TempFileURL(std::move(aURL))
164
0
    {}
165
    ~MediaTempFile();
166
};
167
168
}
169
170
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */