lok: avoid expensive fetching of a property.
[LibreOffice.git] / include / avmedia / mediaitem.hxx
blob9e3fb4cd4530a5a85139aa78b5baf9d07e465c28
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 #ifndef INCLUDED_AVMEDIA_MEDIAITEM_HXX
21 #define INCLUDED_AVMEDIA_MEDIAITEM_HXX
23 #include <svl/poolitem.hxx>
24 #include <com/sun/star/media/ZoomLevel.hpp>
25 #include <avmedia/avmediadllapi.h>
26 #include <memory>
27 #include <string_view>
29 #include <o3tl/typed_flags_set.hxx>
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 class Graphic;
37 enum class AVMediaSetMask
39 NONE = 0x000,
40 STATE = 0x001,
41 DURATION = 0x002,
42 TIME = 0x004,
43 LOOP = 0x008,
44 MUTE = 0x010,
45 VOLUMEDB = 0x020,
46 ZOOM = 0x040,
47 URL = 0x080,
48 MIME_TYPE = 0x100,
49 GRAPHIC = 0x200,
50 ALL = 0x3ff,
52 namespace o3tl
54 template<> struct typed_flags<AVMediaSetMask> : is_typed_flags<AVMediaSetMask, 0x3ff> {};
58 namespace avmedia
62 enum class MediaState
64 Stop, Play, Pause
68 class AVMEDIA_DLLPUBLIC MediaItem final : public SfxPoolItem
70 public:
71 static SfxPoolItem* CreateDefault();
73 explicit MediaItem( sal_uInt16 i_nWhich = 0,
74 AVMediaSetMask nMaskSet = AVMediaSetMask::NONE );
75 MediaItem( const MediaItem& rMediaItem );
76 virtual ~MediaItem() override;
78 virtual bool operator==( const SfxPoolItem& ) const override;
79 virtual MediaItem* Clone( SfxItemPool* pPool = nullptr ) const override;
80 virtual bool GetPresentation( SfxItemPresentation ePres,
81 MapUnit eCoreUnit,
82 MapUnit ePresUnit,
83 OUString& rText,
84 const IntlWrapper& rIntl ) const override;
85 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
86 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
88 void merge( const MediaItem& rMediaItem );
90 AVMediaSetMask getMaskSet() const;
92 void setState( MediaState eState );
93 MediaState getState() const;
95 void setDuration( double fDuration );
96 double getDuration() const;
98 void setTime( double fTime );
99 double getTime() const;
101 void setLoop( bool bLoop );
102 bool isLoop() const;
104 void setMute( bool bMute );
105 bool isMute() const;
107 void setVolumeDB( sal_Int16 nDB );
108 sal_Int16 getVolumeDB() const;
110 void setZoom( ::css::media::ZoomLevel eZoom );
111 ::css::media::ZoomLevel getZoom() const;
113 void setURL( const OUString& rURL,
114 const OUString& rTempURL,
115 const OUString& rReferer);
116 const OUString& getURL() const;
118 void setMimeType( const OUString& rMimeType );
119 OUString getMimeType() const;
120 void setGraphic(const Graphic& rGraphic);
121 Graphic getGraphic() const;
122 const OUString& getTempURL() const;
124 const OUString& getReferer() const;
126 private:
128 struct Impl;
129 std::unique_ptr<Impl> m_pImpl;
132 typedef ::avmedia::MediaItem avmedia_MediaItem;
134 bool AVMEDIA_DLLPUBLIC EmbedMedia(
135 const ::css::uno::Reference< ::css::frame::XModel>& xModel,
136 const OUString& rSourceURL,
137 OUString & o_rEmbeddedURL,
138 ::css::uno::Reference<::css::io::XInputStream> const& xInputStream =
139 ::css::uno::Reference<::css::io::XInputStream>());
141 bool AVMEDIA_DLLPUBLIC CreateMediaTempFile(
142 ::css::uno::Reference<::css::io::XInputStream> const& xInStream,
143 OUString& o_rTempFileURL,
144 std::u16string_view rDesiredExtension);
146 OUString GetFilename(OUString const& rSourceURL);
148 ::css::uno::Reference< ::css::io::XStream> CreateStream(
149 const ::css::uno::Reference< ::css::embed::XStorage>& xStorage, const OUString& rFilename);
151 struct AVMEDIA_DLLPUBLIC MediaTempFile
153 OUString const m_TempFileURL;
154 MediaTempFile(OUString const& rURL)
155 : m_TempFileURL(rURL)
157 ~MediaTempFile();
162 #endif
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */