20 #include <config_features.h>
24 #include <rtl/ustring.hxx>
35 #include <svx/strings.hrc>
46 #if HAVE_FEATURE_AVMEDIA
50 std::shared_ptr< ::avmedia::MediaTempFile > m_pTempFile;
67 #if HAVE_FEATURE_AVMEDIA
97 return std::make_unique<sdr::contact::ViewContactOfSdrMediaObj>( *this );
133 if (!aName.isEmpty())
134 sName +=
" '" + aName +
"'";
141 return SvxResId(STR_ObjNamePluralMEDIA);
151 #if HAVE_FEATURE_AVMEDIA
152 if( !
m_xImpl->m_xCachedSnapshot.is() )
154 OUString aRealURL =
m_xImpl->m_MediaProperties.getTempURL();
155 if( aRealURL.isEmpty() )
156 aRealURL =
m_xImpl->m_MediaProperties.getURL();
157 OUString sReferer =
m_xImpl->m_MediaProperties.getReferer();
158 OUString sMimeType =
m_xImpl->m_MediaProperties.getMimeType();
159 uno::Reference<graphic::XGraphic> xCachedSnapshot =
m_xImpl->m_xCachedSnapshot;
162 [
this, xCachedSnapshot, aRealURL, sReferer, sMimeType](
const css::uno::Reference<css::media::XPlayer>& rPlayer){
171 return m_xImpl->m_xCachedSnapshot;
177 static_cast< sdr::contact::ViewContactOfSdrMediaObj& >(
GetViewContact() ).getPreferredSize(),
178 MapMode(MapUnit::Map100thMM)) );
187 if ( (!bShrinkOnly ||
188 ( aSize.
Height() > aMaxSize.Height() ) ||
189 ( aSize.
Width() > aMaxSize.Width() ) )&&
190 aSize.
Height() && aMaxSize.Height() )
192 float fGrfWH =
static_cast<float>(aSize.
Width()) /
193 static_cast<float>(aSize.
Height());
194 float fWinWH =
static_cast<float>(aMaxSize.Width()) /
195 static_cast<float>(aMaxSize.Height());
198 if ( fGrfWH < fWinWH )
200 aSize.
setWidth( static_cast<tools::Long>(aMaxSize.Height() * fGrfWH) );
203 else if ( fGrfWH > 0.
F )
206 aSize.
setHeight( static_cast<tools::Long>(aMaxSize.Width() / fGrfWH) );
215 aPos.AdjustX( -(aSize.
Width() / 2) );
216 aPos.AdjustY( -(aSize.
Height() / 2) );
223 #if HAVE_FEATURE_AVMEDIA
224 if( !rMimeType.isEmpty() )
225 m_xImpl->m_MediaProperties.setMimeType(rMimeType);
226 aURLItem.
setURL( rURL,
"", rReferer );
237 #if HAVE_FEATURE_AVMEDIA
238 return m_xImpl->m_MediaProperties.getURL();
253 return m_xImpl->m_MediaProperties;
258 #if HAVE_FEATURE_AVMEDIA
261 SAL_WARN(
"svx",
"this is only intended for embedded media");
265 uno::Reference<ucb::XCommandEnvironment>(),
275 #if !HAVE_FEATURE_AVMEDIA
278 if (
m_xImpl->m_pTempFile ||
m_xImpl->m_LastFailedPkgURL.isEmpty())
280 SAL_WARN(
"svx",
"this is only intended for embedded media");
284 OUString tempFileURL;
293 m_xImpl->m_pTempFile = std::make_shared<::avmedia::MediaTempFile>(tempFileURL);
294 m_xImpl->m_MediaProperties.setURL(
295 m_xImpl->m_LastFailedPkgURL, tempFileURL,
"");
297 m_xImpl->m_LastFailedPkgURL.clear();
302 #if HAVE_FEATURE_AVMEDIA
303 static bool lcl_HandlePackageURL(
304 OUString
const & rURL,
306 OUString & o_rTempFileURL)
309 uno::Reference<io::XInputStream> xInStream;
313 catch (container::NoSuchElementException
const&)
315 SAL_INFO(
"svx",
"not found: '" << rURL <<
"'");
318 catch (uno::Exception
const&)
331 sal_Int32 nLastDot = rURL.lastIndexOf(
'.');
332 sal_Int32 nLastSlash = rURL.lastIndexOf(
'/');
333 OUString sDesiredExtension;
334 if (nLastDot > nLastSlash && nLastDot+1 < rURL.getLength())
335 sDesiredExtension = rURL.copy(nLastDot);
336 return ::avmedia::CreateMediaTempFile(xInStream, o_rTempFileURL, sDesiredExtension);
342 bool bBroadcastChanged =
false;
343 #if HAVE_FEATURE_AVMEDIA
347 if( AVMediaSetMask::MIME_TYPE & nMaskSet )
348 m_xImpl->m_MediaProperties.setMimeType( rNewProperties.getMimeType() );
350 if (nMaskSet & AVMediaSetMask::GRAPHIC)
352 m_xImpl->m_MediaProperties.setGraphic(rNewProperties.getGraphic());
355 if( ( AVMediaSetMask::URL & nMaskSet ) &&
356 ( rNewProperties.getURL() !=
getURL() ))
358 m_xImpl->m_xCachedSnapshot.clear();
359 m_xImpl->m_xPlayerListener.clear();
360 OUString
const& url(rNewProperties.getURL());
361 if (url.startsWithIgnoreAsciiCase(
"vnd.sun.star.Package:"))
364 || (
m_xImpl->m_pTempFile->m_TempFileURL !=
365 rNewProperties.getTempURL()))
367 OUString tempFileURL;
369 lcl_HandlePackageURL(
377 std::make_shared<::avmedia::MediaTempFile>(tempFileURL);
378 m_xImpl->m_MediaProperties.setURL(url, tempFileURL,
"");
383 m_xImpl->m_MediaProperties.setURL(
"",
"",
"");
386 m_xImpl->m_LastFailedPkgURL = url;
391 m_xImpl->m_MediaProperties.setURL(url,
392 rNewProperties.getTempURL(),
"");
398 m_xImpl->m_MediaProperties.setURL(url,
"", rNewProperties.getReferer());
400 bBroadcastChanged =
true;
403 if( AVMediaSetMask::LOOP & nMaskSet )
404 m_xImpl->m_MediaProperties.setLoop( rNewProperties.isLoop() );
406 if( AVMediaSetMask::MUTE & nMaskSet )
407 m_xImpl->m_MediaProperties.setMute( rNewProperties.isMute() );
409 if( AVMediaSetMask::VOLUMEDB & nMaskSet )
410 m_xImpl->m_MediaProperties.setVolumeDB( rNewProperties.getVolumeDB() );
412 if( AVMediaSetMask::ZOOM & nMaskSet )
413 m_xImpl->m_MediaProperties.setZoom( rNewProperties.getZoom() );
415 (
void) rNewProperties;
418 if( bBroadcastChanged )
void setWidth(tools::Long nWidth)
sdr::contact::ViewContact & GetViewContact() const
Rectangle objects (rectangle, circle, ...)
static OutputDevice * GetDefaultDevice()
constexpr tools::Long Width() const
void EnableUndo(bool bEnable)
enables (true) or disables (false) recording of undo actions If undo actions are added while undo is ...
OUString SvxResId(TranslateId aId)
#define TOOLS_WARN_EXCEPTION(area, stream)
bool IsUndoEnabled() const
returns true if undo is currently enabled This returns false if undo was disabled using EnableUndo( f...
void BroadcastObjectChange() const
void ActionChanged() const
SdrModel & getSdrModelFromSdrObject() const
virtual void SetLogicRect(const tools::Rectangle &rRect)
css::uno::Reference< css::io::XInputStream > openStream()
constexpr tools::Long Height() const
#define SAL_INFO(area, stream)
Reference< XComponentContext > getProcessComponentContext()
void setHeight(tools::Long nHeight)
#define SAL_WARN(area, stream)
virtual void SetChanged()
const OUString & GetName() const
css::uno::Reference< css::io::XInputStream > GetDocumentStream(OUString const &rURL,::comphelper::LifecycleProxy const &rProxy) const