20#include <config_features.h>
24#include <com/sun/star/text/GraphicCrop.hpp>
26#include <rtl/ustring.hxx>
32#include <LibreOfficeKit/LibreOfficeKitEnums.h>
35#include <boost/property_tree/json_parser.hpp>
41#include <svx/strings.hrc>
52#if HAVE_FEATURE_AVMEDIA
56 std::shared_ptr< ::avmedia::MediaTempFile > m_pTempFile;
73#if HAVE_FEATURE_AVMEDIA
107 return std::make_unique<sdr::contact::ViewContactOfSdrMediaObj>( *
this );
143 if (!
aName.isEmpty())
151 return SvxResId(STR_ObjNamePluralMEDIA);
161#if HAVE_FEATURE_AVMEDIA
162 if( !
m_xImpl->m_xCachedSnapshot.is() )
169 const text::GraphicCrop& rCrop =
m_xImpl->m_MediaProperties.getCrop();
170 if (rCrop.Bottom > 0 || rCrop.Left > 0 || rCrop.Right > 0 || rCrop.Top > 0)
178 aGraphic = aBitmapEx;
184 return m_xImpl->m_xCachedSnapshot;
187 OUString aRealURL =
m_xImpl->m_MediaProperties.getTempURL();
188 if( aRealURL.isEmpty() )
189 aRealURL =
m_xImpl->m_MediaProperties.getURL();
190 OUString sReferer =
m_xImpl->m_MediaProperties.getReferer();
191 OUString sMimeType =
m_xImpl->m_MediaProperties.getMimeType();
192 uno::Reference<graphic::XGraphic> xCachedSnapshot =
m_xImpl->m_xCachedSnapshot;
195 [
this, xCachedSnapshot, aRealURL, sReferer, sMimeType](
const css::uno::Reference<css::media::XPlayer>& rPlayer){
197 uno::Reference<graphic::XGraphic> xGraphic
198 =
m_xImpl->m_MediaProperties.getGraphic().GetXGraphic();
206 return m_xImpl->m_xCachedSnapshot;
213 MapMode(MapUnit::Map100thMM)) );
222 if ( (!bShrinkOnly ||
227 float fGrfWH =
static_cast<float>(aSize.
Width()) /
228 static_cast<float>(aSize.
Height());
229 float fWinWH =
static_cast<float>(aMaxSize.
Width()) /
230 static_cast<float>(aMaxSize.
Height());
233 if ( fGrfWH < fWinWH )
238 else if ( fGrfWH > 0.F )
258#if HAVE_FEATURE_AVMEDIA
259 aURLItem.
setURL( rURL,
"", rReferer );
269#if HAVE_FEATURE_AVMEDIA
270 return m_xImpl->m_MediaProperties.getURL();
279#if HAVE_FEATURE_AVMEDIA
280 return m_xImpl->m_MediaProperties.getTempURL();
295 return m_xImpl->m_MediaProperties;
300#if HAVE_FEATURE_AVMEDIA
303 SAL_WARN(
"svx",
"this is only intended for embedded media");
307 uno::Reference<ucb::XCommandEnvironment>(),
317#if !HAVE_FEATURE_AVMEDIA
320 if (
m_xImpl->m_pTempFile ||
m_xImpl->m_LastFailedPkgURL.isEmpty())
322 SAL_WARN(
"svx",
"this is only intended for embedded media");
326 OUString tempFileURL;
328 ::avmedia::CreateMediaTempFile(
335 m_xImpl->m_pTempFile = std::make_shared<::avmedia::MediaTempFile>(tempFileURL);
336 m_xImpl->m_MediaProperties.setURL(
337 m_xImpl->m_LastFailedPkgURL, tempFileURL,
"");
339 m_xImpl->m_LastFailedPkgURL.clear();
344#if HAVE_FEATURE_AVMEDIA
345static bool lcl_HandlePackageURL(
346 OUString
const & rURL,
348 OUString & o_rTempFileURL)
351 uno::Reference<io::XInputStream> xInStream;
355 catch (container::NoSuchElementException
const&)
357 SAL_INFO(
"svx",
"not found: '" << rURL <<
"'");
360 catch (uno::Exception
const&)
373 sal_Int32 nLastDot = rURL.lastIndexOf(
'.');
374 sal_Int32 nLastSlash = rURL.lastIndexOf(
'/');
375 OUString sDesiredExtension;
376 if (nLastDot > nLastSlash && nLastDot+1 < rURL.getLength())
377 sDesiredExtension = rURL.copy(nLastDot);
378 return ::avmedia::CreateMediaTempFile(xInStream, o_rTempFileURL, sDesiredExtension);
384 bool bBroadcastChanged =
false;
385#if HAVE_FEATURE_AVMEDIA
389 if( AVMediaSetMask::MIME_TYPE & nMaskSet )
390 m_xImpl->m_MediaProperties.setMimeType( rNewProperties.getMimeType() );
392 if (nMaskSet & AVMediaSetMask::GRAPHIC)
394 m_xImpl->m_MediaProperties.setGraphic(rNewProperties.getGraphic());
397 if (nMaskSet & AVMediaSetMask::CROP)
399 m_xImpl->m_MediaProperties.setCrop(rNewProperties.getCrop());
402 if( ( AVMediaSetMask::URL & nMaskSet ) &&
403 ( rNewProperties.getURL() !=
getURL() ))
405 m_xImpl->m_xCachedSnapshot.clear();
406 m_xImpl->m_xPlayerListener.clear();
407 OUString
const& url(rNewProperties.getURL());
408 if (url.startsWithIgnoreAsciiCase(
"vnd.sun.star.Package:"))
411 || (
m_xImpl->m_pTempFile->m_TempFileURL !=
412 rNewProperties.getTempURL()))
414 OUString tempFileURL;
416 lcl_HandlePackageURL(
424 std::make_shared<::avmedia::MediaTempFile>(tempFileURL);
425 m_xImpl->m_MediaProperties.setURL(url, tempFileURL,
"");
430 m_xImpl->m_MediaProperties.setURL(
"",
"",
"");
433 m_xImpl->m_LastFailedPkgURL = url;
438 m_xImpl->m_MediaProperties.setURL(url,
439 rNewProperties.getTempURL(),
"");
445 m_xImpl->m_MediaProperties.setURL(url,
"", rNewProperties.getReferer());
447 bBroadcastChanged =
true;
450 if( AVMediaSetMask::LOOP & nMaskSet )
451 m_xImpl->m_MediaProperties.setLoop( rNewProperties.isLoop() );
453 if( AVMediaSetMask::MUTE & nMaskSet )
454 m_xImpl->m_MediaProperties.setMute( rNewProperties.isMute() );
456 if( AVMediaSetMask::VOLUMEDB & nMaskSet )
457 m_xImpl->m_MediaProperties.setVolumeDB( rNewProperties.getVolumeDB() );
459 if( AVMediaSetMask::ZOOM & nMaskSet )
460 m_xImpl->m_MediaProperties.setZoom( rNewProperties.getZoom() );
462 (void) rNewProperties;
465 if( bBroadcastChanged )
static OutputDevice * GetDefaultDevice()
bool Crop(const tools::Rectangle &rRectPixel)
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
Size GetSizePixel(const OutputDevice *pRefDevice=nullptr) const
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
css::uno::Reference< css::io::XInputStream > GetDocumentStream(OUString const &rURL, ::comphelper::LifecycleProxy const &rProxy) const
void EnableUndo(bool bEnable)
enables (true) or disables (false) recording of undo actions If undo actions are added while undo is ...
bool IsUndoEnabled() const
returns true if undo is currently enabled This returns false if undo was disabled using EnableUndo( f...
void ActionChanged() const
void BroadcastObjectChange() const
SdrModel & getSdrModelFromSdrObject() const
virtual void SetLogicRect(const tools::Rectangle &rRect)
virtual const OUString & GetName() const
sdr::contact::ViewContact & GetViewContact() const
virtual void SetChanged()
Rectangle objects (rectangle, circle, ...)
tools::Rectangle const & getRectangle() const
constexpr tools::Long getHeight() const
constexpr tools::Long Height() const
constexpr tools::Long getWidth() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
oslInterlockedCount m_refCount
css::uno::Reference< css::io::XInputStream > openStream()
#define TOOLS_WARN_EXCEPTION(area, stream)
OUString SvxResId(TranslateId aId)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
Reference< XComponentContext > getProcessComponentContext()