workaround segfault in compiler on macos-clang-intel
[LibreOffice.git] / include / avmedia / mediaitem.hxx
blobf8b3c7c689c321302b8346155ae62bc9bfea5f75
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <svl/poolitem.hxx>
23 #include <com/sun/star/media/ZoomLevel.hpp>
24 #include <avmedia/avmediadllapi.h>
25 #include <memory>
26 #include <string_view>
28 #include <o3tl/typed_flags_set.hxx>
29 #include <utility>
31 namespace com::sun::star::embed { class XStorage; }
32 namespace com::sun::star::frame { class XModel; }
33 namespace com::sun::star::io { class XInputStream; }
34 namespace com::sun::star::io { class XStream; }
35 namespace com::sun::star::text { struct GraphicCrop; }
36 class Graphic;
38 enum class AVMediaSetMask
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,
54 namespace o3tl
56 template<> struct typed_flags<AVMediaSetMask> : is_typed_flags<AVMediaSetMask, 0x7ff> {};
60 namespace avmedia
64 enum class MediaState
66 Stop, Play, Pause
70 class AVMEDIA_DLLPUBLIC MediaItem final : public SfxPoolItem
72 public:
73 static SfxPoolItem* CreateDefault();
75 explicit MediaItem( sal_uInt16 i_nWhich = 0,
76 AVMediaSetMask nMaskSet = AVMediaSetMask::NONE );
77 MediaItem( const MediaItem& rMediaItem );
78 virtual ~MediaItem() override;
80 virtual bool operator==( const SfxPoolItem& ) const override;
81 virtual MediaItem* Clone( SfxItemPool* pPool = nullptr ) const override;
82 virtual bool GetPresentation( SfxItemPresentation ePres,
83 MapUnit eCoreUnit,
84 MapUnit ePresUnit,
85 OUString& rText,
86 const IntlWrapper& rIntl ) const override;
87 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
88 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
90 bool merge(const MediaItem& rMediaItem);
92 AVMediaSetMask getMaskSet() const;
94 bool setState(MediaState eState);
95 MediaState getState() const;
97 bool setDuration(double fDuration);
98 double getDuration() const;
100 bool setTime(double fTime);
101 double getTime() const;
103 bool setLoop(bool bLoop);
104 bool isLoop() const;
106 bool setMute(bool bMute);
107 bool isMute() const;
109 bool setVolumeDB(sal_Int16 nDB);
110 sal_Int16 getVolumeDB() const;
112 bool setZoom(css::media::ZoomLevel eZoom);
113 ::css::media::ZoomLevel getZoom() const;
115 bool setURL(const OUString& rURL,
116 const OUString& rTempURL,
117 const OUString& rReferer);
118 const OUString& getURL() const;
120 bool setMimeType(const OUString& rMimeType);
121 OUString getMimeType() const;
122 bool setGraphic(const Graphic& rGraphic);
123 const Graphic & getGraphic() const;
124 bool setCrop(const css::text::GraphicCrop& rCrop);
125 const css::text::GraphicCrop& getCrop() const;
126 const OUString& getTempURL() const;
128 const OUString& getReferer() const;
130 private:
132 struct Impl;
133 std::unique_ptr<Impl> m_pImpl;
136 typedef ::avmedia::MediaItem avmedia_MediaItem;
138 bool AVMEDIA_DLLPUBLIC EmbedMedia(
139 const ::css::uno::Reference< ::css::frame::XModel>& xModel,
140 const OUString& rSourceURL,
141 OUString & o_rEmbeddedURL,
142 ::css::uno::Reference<::css::io::XInputStream> const& xInputStream =
143 ::css::uno::Reference<::css::io::XInputStream>());
145 bool AVMEDIA_DLLPUBLIC CreateMediaTempFile(
146 ::css::uno::Reference<::css::io::XInputStream> const& xInStream,
147 OUString& o_rTempFileURL,
148 std::u16string_view rDesiredExtension);
150 OUString GetFilename(OUString const& rSourceURL);
152 ::css::uno::Reference< ::css::io::XStream> CreateStream(
153 const ::css::uno::Reference< ::css::embed::XStorage>& xStorage, const OUString& rFilename);
155 struct AVMEDIA_DLLPUBLIC MediaTempFile
157 OUString const m_TempFileURL;
158 MediaTempFile(OUString aURL)
159 : m_TempFileURL(std::move(aURL))
161 ~MediaTempFile();
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */