1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #include <com/sun/star/util/XModifiable.hpp>
21 #include <com/sun/star/embed/XEmbeddedObject.hpp>
22 #include <com/sun/star/embed/XLinkageSupport.hpp>
23 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
24 #include <com/sun/star/embed/Aspects.hpp>
25 #include <com/sun/star/task/XInteractionHandler.hpp>
26 #include <com/sun/star/ucb/CommandFailedException.hpp>
27 #include <com/sun/star/ucb/ContentCreationException.hpp>
29 #include <svx/svdoole2.hxx>
30 #include <svx/svdomedia.hxx>
31 #include <svx/svdpool.hxx>
32 #include <comphelper/classids.hxx>
33 #include <comphelper/embeddedobjectcontainer.hxx>
34 #include <comphelper/propertysequence.hxx>
35 #include <cppuhelper/exc_hlp.hxx>
37 #include <toolkit/helper/vclunohelper.hxx>
39 #include <sot/exchange.hxx>
41 #include <svx/svdmodel.hxx>
42 #include "shapeimpl.hxx"
44 #include <svx/unoshprp.hxx>
46 #include <vcl/gdimtf.hxx>
47 #include <vcl/wmf.hxx>
48 #include <svtools/embedhlp.hxx>
49 #include <sal/log.hxx>
50 #include <tools/debug.hxx>
51 #include <tools/globname.hxx>
52 #include <tools/stream.hxx>
54 #include <config_features.h>
57 using namespace ::cppu
;
58 using namespace ::com::sun::star
;
59 using namespace ::com::sun::star::uno
;
60 using namespace ::com::sun::star::lang
;
61 using namespace ::com::sun::star::container
;
62 using namespace ::com::sun::star::beans
;
65 SvxOle2Shape::SvxOle2Shape(SdrObject
* pObject
)
66 : SvxShapeText( pObject
, getSvxMapProvider().GetMap(SVXMAP_OLE2
),
67 getSvxMapProvider().GetPropertySet(SVXMAP_OLE2
,SdrObject::GetGlobalDrawObjectItemPool()) )
71 SvxOle2Shape::SvxOle2Shape(SdrObject
* pObject
, const SfxItemPropertyMapEntry
* pPropertyMap
, const SvxItemPropertySet
* pPropertySet
)
72 : SvxShapeText( pObject
, pPropertyMap
, pPropertySet
)
76 SvxOle2Shape::~SvxOle2Shape() noexcept
81 bool SvxOle2Shape::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, const css::uno::Any
& rValue
)
83 switch( pProperty
->nWID
)
85 case OWN_ATTR_OLE_VISAREA
:
87 // TODO/LATER: seems to make no sense for iconified object
89 awt::Rectangle aVisArea
;
90 if( (rValue
>>= aVisArea
) && dynamic_cast<const SdrOle2Obj
* >(GetSdrObject()) != nullptr)
92 Size
aTmp( aVisArea
.X
+ aVisArea
.Width
, aVisArea
.Y
+ aVisArea
.Height
);
93 uno::Reference
< embed::XEmbeddedObject
> xObj
= static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef();
98 // the API handles with MapUnit::Map100thMM map mode
99 MapUnit aObjUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj
->getMapUnit( embed::Aspects::MSOLE_CONTENT
) );
100 aTmp
= OutputDevice::LogicToLogic(aTmp
, MapMode(MapUnit::Map100thMM
), MapMode(aObjUnit
));
101 xObj
->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT
, awt::Size( aTmp
.Width(), aTmp
.Height() ) );
103 catch( uno::Exception
& )
105 OSL_FAIL( "Couldn't set the visual area for the object!" );
113 case OWN_ATTR_OLE_ASPECT
:
115 sal_Int64 nAspect
= 0;
116 if( rValue
>>= nAspect
)
118 static_cast<SdrOle2Obj
*>(GetSdrObject())->SetAspect( nAspect
);
126 if( rValue
>>= aCLSID
)
128 // init an OLE object with a global name
129 SvGlobalName aClassName
;
130 if( aClassName
.MakeId( aCLSID
) )
132 if( createObject( aClassName
) )
138 case OWN_ATTR_THUMBNAIL
:
140 uno::Reference
< graphic::XGraphic
> xGraphic( rValue
, uno::UNO_QUERY
);
143 const Graphic
aGraphic(xGraphic
);
144 static_cast<SdrOle2Obj
*>(GetSdrObject())->SetGraphic(aGraphic
);
149 case OWN_ATTR_VALUE_GRAPHIC
:
151 uno::Reference
< graphic::XGraphic
> xGraphic( rValue
, uno::UNO_QUERY
);
154 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( GetSdrObject() );
157 GraphicObject
aGrafObj( xGraphic
);
158 const Graphic
& aGraphic( aGrafObj
.GetGraphic() );
159 pOle
->SetGraphicToObj( aGraphic
);
165 case OWN_ATTR_PERSISTNAME
:
167 OUString aPersistName
;
168 if( rValue
>>= aPersistName
)
171 #if OSL_DEBUG_LEVEL > 0
172 pOle
= dynamic_cast<SdrOle2Obj
*>(GetSdrObject());
175 pOle
= static_cast<SdrOle2Obj
*>(GetSdrObject());
177 pOle
->SetPersistName( aPersistName
);
182 case OWN_ATTR_OLE_LINKURL
:
185 if( rValue
>>= aLinkURL
)
187 createLink( aLinkURL
);
193 return SvxShapeText::setPropertyValueImpl( rName
, pProperty
, rValue
);
196 throw IllegalArgumentException();
199 bool SvxOle2Shape::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, css::uno::Any
& rValue
)
201 switch( pProperty
->nWID
)
206 GetClassName_Impl(aCLSID
);
211 case OWN_ATTR_INTERNAL_OLE
:
214 rValue
<<= SotExchange::IsInternal( GetClassName_Impl(sCLSID
) );
218 case OWN_ATTR_METAFILE
:
220 SdrOle2Obj
* pObj
= dynamic_cast<SdrOle2Obj
*>(GetSdrObject());
223 const Graphic
* pGraphic
= pObj
->GetGraphic();
227 if ( pGraphic
->IsGfxLink() )
229 GfxLink aLnk
= pGraphic
->GetGfxLink();
230 if ( aLnk
.GetType() == GfxLinkType::NativeWmf
)
233 uno::Sequence
<sal_Int8
> aSeq(reinterpret_cast<sal_Int8
const *>(aLnk
.GetData()), static_cast<sal_Int32
>(aLnk
.GetDataSize()));
239 // #i119735# just use GetGDIMetaFile, it will create a buffered version of contained bitmap now automatically
240 GDIMetaFile
aMtf(pObj
->GetGraphic()->GetGDIMetaFile());
241 SvMemoryStream
aDestStrm( 65535, 65535 );
242 ConvertGDIMetaFileToWMF( aMtf
, aDestStrm
, nullptr, false );
243 const uno::Sequence
<sal_Int8
> aSeq(
244 static_cast< const sal_Int8
* >(aDestStrm
.GetData()),
245 aDestStrm
.GetEndOfData());
252 rValue
= GetBitmap( true );
257 case OWN_ATTR_OLE_VISAREA
:
259 awt::Rectangle aVisArea
;
260 if( dynamic_cast<const SdrOle2Obj
* >(GetSdrObject()) != nullptr)
262 MapMode
aMapMode( MapUnit::Map100thMM
); // the API uses this map mode
263 Size aTmp
= static_cast<SdrOle2Obj
*>(GetSdrObject())->GetOrigObjSize( &aMapMode
); // get the size in the requested map mode
264 aVisArea
= awt::Rectangle( 0, 0, aTmp
.Width(), aTmp
.Height() );
271 case OWN_ATTR_OLESIZE
:
273 Size
aTmp( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetOrigObjSize() );
274 rValue
<<= awt::Size( aTmp
.Width(), aTmp
.Height() );
278 case OWN_ATTR_OLE_ASPECT
:
280 rValue
<<= static_cast<SdrOle2Obj
*>(GetSdrObject())->GetAspect();
284 case OWN_ATTR_OLEMODEL
:
285 case OWN_ATTR_OLE_EMBEDDED_OBJECT
:
286 case OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT
:
288 SdrOle2Obj
* pObj
= dynamic_cast<SdrOle2Obj
*>( GetSdrObject() );
291 uno::Reference
< embed::XEmbeddedObject
> xObj( pObj
->GetObjRef() );
293 && ( pProperty
->nWID
== OWN_ATTR_OLE_EMBEDDED_OBJECT
|| pProperty
->nWID
== OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT
|| svt::EmbeddedObjectRef::TryRunningState( xObj
) ) )
295 // Discussed with CL fue to the before GetPaintingPageView
296 // usage. Removed it, former fallback is used now
297 if ( pProperty
->nWID
== OWN_ATTR_OLEMODEL
|| pProperty
->nWID
== OWN_ATTR_OLE_EMBEDDED_OBJECT
)
299 const bool bSuccess(pObj
->AddOwnLightClient());
300 SAL_WARN_IF(!bSuccess
, "svx.svdraw", "An object without client is provided!");
303 if ( pProperty
->nWID
== OWN_ATTR_OLEMODEL
)
304 rValue
<<= pObj
->GetObjRef()->getComponent();
312 case OWN_ATTR_VALUE_GRAPHIC
:
314 uno::Reference
< graphic::XGraphic
> xGraphic
;
315 const Graphic
* pGraphic
= static_cast<SdrOle2Obj
*>( GetSdrObject() )->GetGraphic();
317 xGraphic
= pGraphic
->GetXGraphic();
322 case OWN_ATTR_THUMBNAIL
:
324 uno::Reference
< graphic::XGraphic
> xGraphic
;
325 const Graphic
* pGraphic
= static_cast<SdrOle2Obj
*>( GetSdrObject() )->GetGraphic();
327 xGraphic
= pGraphic
->GetXGraphic();
331 case OWN_ATTR_PERSISTNAME
:
333 OUString aPersistName
;
334 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( GetSdrObject() );
338 aPersistName
= pOle
->GetPersistName();
339 if( !aPersistName
.isEmpty() )
341 ::comphelper::IEmbeddedHelper
* pPersist(GetSdrObject()->getSdrModelFromSdrObject().GetPersist());
342 if( (nullptr == pPersist
) || !pPersist
->getEmbeddedObjectContainer().HasEmbeddedObject( pOle
->GetPersistName() ) )
343 aPersistName
.clear();
347 rValue
<<= aPersistName
;
350 case OWN_ATTR_OLE_LINKURL
:
353 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( GetSdrObject() );
357 uno::Reference
< embed::XLinkageSupport
> xLink( pOle
->GetObjRef(), uno::UNO_QUERY
);
358 if ( xLink
.is() && xLink
->isLink() )
359 aLinkURL
= xLink
->getLinkURL();
366 return SvxShapeText::getPropertyValueImpl( rName
, pProperty
, rValue
);
372 bool SvxOle2Shape::createObject( const SvGlobalName
&aClassName
)
374 DBG_TESTSOLARMUTEX();
376 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( GetSdrObject() );
377 if ( !pOle2Obj
|| !pOle2Obj
->IsEmpty() )
380 // create storage and inplace object
381 ::comphelper::IEmbeddedHelper
* pPersist
= GetSdrObject()->getSdrModelFromSdrObject().GetPersist();
382 OUString aPersistName
;
384 if( SvxShape::getPropertyValue( UNO_NAME_OLE2_PERSISTNAME
) >>= aTmpStr
)
385 aPersistName
= aTmpStr
;
387 uno::Sequence
<beans::PropertyValue
> objArgs( comphelper::InitPropertySequence({
388 { "DefaultParentBaseURL", Any(pPersist
->getDocumentBaseURL()) }
390 //TODO/LATER: how to cope with creation failure?!
391 uno::Reference
<embed::XEmbeddedObject
> xObj(
392 pPersist
->getEmbeddedObjectContainer().CreateEmbeddedObject(
393 aClassName
.GetByteSequence(), objArgs
, aPersistName
));
396 tools::Rectangle aRect
= pOle2Obj
->GetLogicRect();
397 if ( aRect
.GetWidth() == 101 && aRect
.GetHeight() == 101 )
399 // TODO/LATER: is it possible that this method is used to create an iconified object?
403 awt::Size aSz
= xObj
->getVisualAreaSize( pOle2Obj
->GetAspect() );
404 aRect
.SetSize( Size( aSz
.Width
, aSz
.Height
) );
406 catch( embed::NoVisualAreaSizeException
& )
408 pOle2Obj
->SetLogicRect( aRect
);
413 Size aSize
= aRect
.GetSize();
414 aSz
.Width
= aSize
.Width();
415 aSz
.Height
= aSize
.Height();
416 if (aSz
.Width
!= 0 || aSz
.Height
!= 0)
418 //HACK: can aSz legally be empty?
419 xObj
->setVisualAreaSize( pOle2Obj
->GetAspect(), aSz
);
423 // connect the object after the visual area is set
424 aTmpStr
= aPersistName
;
425 SvxShape::setPropertyValue( UNO_NAME_OLE2_PERSISTNAME
, Any( aTmpStr
) );
427 // the object is inserted during setting of PersistName property usually
428 if( pOle2Obj
->IsEmpty() )
429 pOle2Obj
->SetObjRef( xObj
);
435 void SvxOle2Shape::createLink( const OUString
& aLinkURL
)
437 DBG_TESTSOLARMUTEX();
439 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( GetSdrObject() );
440 if ( !pOle2Obj
|| !pOle2Obj
->IsEmpty() )
443 OUString aPersistName
;
445 ::comphelper::IEmbeddedHelper
* pPersist
= GetSdrObject()->getSdrModelFromSdrObject().GetPersist();
447 uno::Sequence
< beans::PropertyValue
> aMediaDescr( 1 );
448 aMediaDescr
[0].Name
= "URL";
449 aMediaDescr
[0].Value
<<= aLinkURL
;
451 uno::Reference
< task::XInteractionHandler
> xInteraction
= pPersist
->getInteractionHandler();
452 if ( xInteraction
.is() )
454 aMediaDescr
.realloc( 2 );
455 aMediaDescr
[1].Name
= "InteractionHandler";
456 aMediaDescr
[1].Value
<<= xInteraction
;
459 //TODO/LATER: how to cope with creation failure?!
460 uno::Reference
< embed::XEmbeddedObject
> xObj
=
461 pPersist
->getEmbeddedObjectContainer().InsertEmbeddedLink( aMediaDescr
, aPersistName
);
466 tools::Rectangle aRect
= pOle2Obj
->GetLogicRect();
467 if ( aRect
.GetWidth() == 101 && aRect
.GetHeight() == 101 )
472 awt::Size aSz
= xObj
->getVisualAreaSize( pOle2Obj
->GetAspect() );
473 aRect
.SetSize( Size( aSz
.Width
, aSz
.Height
) );
475 catch( embed::NoVisualAreaSizeException
& )
477 pOle2Obj
->SetLogicRect( aRect
);
482 Size aSize
= pOle2Obj
->GetLogicRect().GetSize();
483 aSz
.Width
= aSize
.Width();
484 aSz
.Height
= aSize
.Height();
485 xObj
->setVisualAreaSize( pOle2Obj
->GetAspect(), aSz
);
488 // connect the object after the visual area is set
489 SvxShape::setPropertyValue( UNO_NAME_OLE2_PERSISTNAME
, uno::makeAny( aPersistName
) );
491 // the object is inserted during setting of PersistName property usually
492 if ( pOle2Obj
->IsEmpty() )
493 pOle2Obj
->SetObjRef( xObj
);
496 void SvxOle2Shape::resetModifiedState()
498 ::comphelper::IEmbeddedHelper
* pPersist
= GetSdrObject()->getSdrModelFromSdrObject().GetPersist();
499 if( pPersist
&& !pPersist
->isEnableSetModified() )
501 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( GetSdrObject() );
502 if( pOle
&& !pOle
->IsEmpty() )
504 uno::Reference
< util::XModifiable
> xMod( pOle
->GetObjRef(), uno::UNO_QUERY
);
506 // TODO/MBA: what's this?!
507 xMod
->setModified( false );
512 SvGlobalName
SvxOle2Shape::GetClassName_Impl(OUString
& rHexCLSID
)
514 DBG_TESTSOLARMUTEX();
515 SvGlobalName aClassName
;
516 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( GetSdrObject() );
522 if( pOle2Obj
->IsEmpty() )
524 ::comphelper::IEmbeddedHelper
* pPersist
= GetSdrObject()->getSdrModelFromSdrObject().GetPersist();
527 uno::Reference
< embed::XEmbeddedObject
> xObj
=
528 pPersist
->getEmbeddedObjectContainer().GetEmbeddedObject( pOle2Obj
->GetPersistName() );
531 aClassName
= SvGlobalName( xObj
->getClassID() );
532 rHexCLSID
= aClassName
.GetHexName();
537 if (rHexCLSID
.isEmpty())
539 const uno::Reference
< embed::XEmbeddedObject
>& xObj( pOle2Obj
->GetObjRef() );
542 aClassName
= SvGlobalName( xObj
->getClassID() );
543 rHexCLSID
= aClassName
.GetHexName();
551 SvxAppletShape::SvxAppletShape(SdrObject
* pObject
)
552 : SvxOle2Shape( pObject
, getSvxMapProvider().GetMap(SVXMAP_APPLET
), getSvxMapProvider().GetPropertySet(SVXMAP_APPLET
, SdrObject::GetGlobalDrawObjectItemPool()) )
554 SetShapeType( "com.sun.star.drawing.AppletShape" );
557 SvxAppletShape::~SvxAppletShape() noexcept
561 void SvxAppletShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
)
563 SvxShape::Create( pNewObj
, pNewPage
);
564 const SvGlobalName
aAppletClassId( SO3_APPLET_CLASSID
);
565 createObject(aAppletClassId
);
566 SetShapeType( "com.sun.star.drawing.AppletShape" );
569 void SAL_CALL
SvxAppletShape::setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& rValue
)
571 SvxShape::setPropertyValue( aPropertyName
, rValue
);
572 resetModifiedState();
575 void SAL_CALL
SvxAppletShape::setPropertyValues( const css::uno::Sequence
< OUString
>& aPropertyNames
, const css::uno::Sequence
< css::uno::Any
>& rValues
)
577 SvxShape::setPropertyValues( aPropertyNames
, rValues
);
578 resetModifiedState();
581 bool SvxAppletShape::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, const css::uno::Any
& rValue
)
583 if( (pProperty
->nWID
>= OWN_ATTR_APPLET_DOCBASE
) && (pProperty
->nWID
<= OWN_ATTR_APPLET_ISSCRIPT
) )
585 if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef() ) )
587 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
590 // allow exceptions to pass through
591 xSet
->setPropertyValue( rName
, rValue
);
598 return SvxOle2Shape::setPropertyValueImpl( rName
, pProperty
, rValue
);
602 bool SvxAppletShape::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, css::uno::Any
& rValue
)
604 if( (pProperty
->nWID
>= OWN_ATTR_APPLET_DOCBASE
) && (pProperty
->nWID
<= OWN_ATTR_APPLET_ISSCRIPT
) )
606 if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef() ) )
608 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
611 rValue
= xSet
->getPropertyValue( rName
);
618 return SvxOle2Shape::getPropertyValueImpl( rName
, pProperty
, rValue
);
622 SvxPluginShape::SvxPluginShape(SdrObject
* pObject
)
623 : SvxOle2Shape( pObject
, getSvxMapProvider().GetMap(SVXMAP_PLUGIN
), getSvxMapProvider().GetPropertySet(SVXMAP_PLUGIN
, SdrObject::GetGlobalDrawObjectItemPool()) )
625 SetShapeType( "com.sun.star.drawing.PluginShape" );
628 SvxPluginShape::~SvxPluginShape() noexcept
632 void SvxPluginShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
)
634 SvxShape::Create( pNewObj
, pNewPage
);
635 const SvGlobalName
aPluginClassId( SO3_PLUGIN_CLASSID
);
636 createObject(aPluginClassId
);
637 SetShapeType( "com.sun.star.drawing.PluginShape" );
640 void SAL_CALL
SvxPluginShape::setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& rValue
)
642 SvxShape::setPropertyValue( aPropertyName
, rValue
);
643 resetModifiedState();
646 void SAL_CALL
SvxPluginShape::setPropertyValues( const css::uno::Sequence
< OUString
>& aPropertyNames
, const css::uno::Sequence
< css::uno::Any
>& rValues
)
648 SvxShape::setPropertyValues( aPropertyNames
, rValues
);
649 resetModifiedState();
652 bool SvxPluginShape::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, const css::uno::Any
& rValue
)
654 if( (pProperty
->nWID
>= OWN_ATTR_PLUGIN_MIMETYPE
) && (pProperty
->nWID
<= OWN_ATTR_PLUGIN_COMMANDS
) )
656 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef() ) )
658 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
661 // allow exceptions to pass through
662 xSet
->setPropertyValue( rName
, rValue
);
669 return SvxOle2Shape::setPropertyValueImpl( rName
, pProperty
, rValue
);
673 bool SvxPluginShape::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, css::uno::Any
& rValue
)
675 if( (pProperty
->nWID
>= OWN_ATTR_PLUGIN_MIMETYPE
) && (pProperty
->nWID
<= OWN_ATTR_PLUGIN_COMMANDS
) )
677 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef() ) )
679 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
682 rValue
= xSet
->getPropertyValue( rName
);
689 return SvxOle2Shape::getPropertyValueImpl( rName
, pProperty
, rValue
);
694 SvxFrameShape::SvxFrameShape(SdrObject
* pObject
)
695 : SvxOle2Shape( pObject
, getSvxMapProvider().GetMap(SVXMAP_FRAME
), getSvxMapProvider().GetPropertySet(SVXMAP_FRAME
, SdrObject::GetGlobalDrawObjectItemPool()) )
697 SetShapeType( "com.sun.star.drawing.FrameShape" );
700 SvxFrameShape::~SvxFrameShape() noexcept
704 void SvxFrameShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
)
706 SvxShape::Create( pNewObj
, pNewPage
);
707 const SvGlobalName
aIFrameClassId( SO3_IFRAME_CLASSID
);
708 createObject(aIFrameClassId
);
709 SetShapeType( "com.sun.star.drawing.FrameShape" );
712 void SAL_CALL
SvxFrameShape::setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& rValue
)
714 SvxShape::setPropertyValue( aPropertyName
, rValue
);
715 resetModifiedState();
718 void SAL_CALL
SvxFrameShape::setPropertyValues( const css::uno::Sequence
< OUString
>& aPropertyNames
, const css::uno::Sequence
< css::uno::Any
>& rValues
)
720 SvxShape::setPropertyValues( aPropertyNames
, rValues
);
721 resetModifiedState();
724 bool SvxFrameShape::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, const css::uno::Any
& rValue
)
726 if( (pProperty
->nWID
>= OWN_ATTR_FRAME_URL
) && (pProperty
->nWID
<= OWN_ATTR_FRAME_MARGIN_HEIGHT
) )
728 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef() ) )
730 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
733 // allow exceptions to pass through
734 xSet
->setPropertyValue( rName
, rValue
);
741 return SvxOle2Shape::setPropertyValueImpl( rName
, pProperty
, rValue
);
745 bool SvxFrameShape::getPropertyValueImpl(const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
,
746 css::uno::Any
& rValue
)
748 if( (pProperty
->nWID
>= OWN_ATTR_FRAME_URL
) && (pProperty
->nWID
<= OWN_ATTR_FRAME_MARGIN_HEIGHT
) )
750 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef() ) )
752 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
755 rValue
= xSet
->getPropertyValue( rName
);
762 return SvxOle2Shape::getPropertyValueImpl( rName
, pProperty
, rValue
);
765 SvxMediaShape::SvxMediaShape(SdrObject
* pObj
, OUString
const & referer
)
766 : SvxShape( pObj
, getSvxMapProvider().GetMap(SVXMAP_MEDIA
), getSvxMapProvider().GetPropertySet(SVXMAP_MEDIA
, SdrObject::GetGlobalDrawObjectItemPool()) ),
769 SetShapeType( "com.sun.star.drawing.MediaShape" );
773 SvxMediaShape::~SvxMediaShape() noexcept
778 bool SvxMediaShape::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, const css::uno::Any
& rValue
)
780 if( ((pProperty
->nWID
>= OWN_ATTR_MEDIA_URL
) && (pProperty
->nWID
<= OWN_ATTR_MEDIA_ZOOM
))
781 || (pProperty
->nWID
== OWN_ATTR_MEDIA_STREAM
)
782 || (pProperty
->nWID
== OWN_ATTR_MEDIA_MIMETYPE
)
783 || (pProperty
->nWID
== OWN_ATTR_VALUE_GRAPHIC
))
785 SdrMediaObj
* pMedia
= static_cast< SdrMediaObj
* >( GetSdrObject() );
786 ::avmedia::MediaItem aItem
;
789 switch( pProperty
->nWID
)
791 case OWN_ATTR_MEDIA_URL
:
792 #if HAVE_FEATURE_AVMEDIA
795 if( rValue
>>= aURL
)
798 aItem
.setURL( aURL
, "", referer_
);
804 case OWN_ATTR_MEDIA_LOOP
:
805 #if HAVE_FEATURE_AVMEDIA
809 if( rValue
>>= bLoop
)
812 aItem
.setLoop( bLoop
);
818 case OWN_ATTR_MEDIA_MUTE
:
819 #if HAVE_FEATURE_AVMEDIA
823 if( rValue
>>= bMute
)
826 aItem
.setMute( bMute
);
832 case OWN_ATTR_MEDIA_VOLUMEDB
:
833 #if HAVE_FEATURE_AVMEDIA
835 sal_Int16 nVolumeDB
= sal_Int16();
837 if( rValue
>>= nVolumeDB
)
840 aItem
.setVolumeDB( nVolumeDB
);
846 case OWN_ATTR_MEDIA_ZOOM
:
847 #if HAVE_FEATURE_AVMEDIA
849 css::media::ZoomLevel eLevel
;
851 if( rValue
>>= eLevel
)
854 aItem
.setZoom( eLevel
);
860 case OWN_ATTR_MEDIA_MIMETYPE
:
861 #if HAVE_FEATURE_AVMEDIA
864 if( rValue
>>= sMimeType
)
867 aItem
.setMimeType( sMimeType
);
873 case OWN_ATTR_VALUE_GRAPHIC
:
874 #if HAVE_FEATURE_AVMEDIA
876 uno::Reference
<graphic::XGraphic
> xGraphic(rValue
, uno::UNO_QUERY
);
880 aItem
.setGraphic(Graphic(xGraphic
));
886 case OWN_ATTR_MEDIA_STREAM
:
887 #if HAVE_FEATURE_AVMEDIA
890 uno::Reference
<io::XInputStream
> xStream
;
891 if (rValue
>>= xStream
)
893 pMedia
->SetInputStream(xStream
);
896 catch (const css::ucb::ContentCreationException
&)
898 css::uno::Any exc
= cppu::getCaughtException();
899 throw css::lang::WrappedTargetException(
900 "ContentCreationException Setting InputStream!",
901 static_cast<OWeakObject
*>(this),
904 catch (const css::ucb::CommandFailedException
&)
906 css::uno::Any anyEx
= cppu::getCaughtException();
907 throw css::lang::WrappedTargetException(
908 "CommandFailedException Setting InputStream!",
909 static_cast<OWeakObject
*>(this),
916 OSL_FAIL("SvxMediaShape::setPropertyValueImpl(), unknown argument!");
921 pMedia
->setMediaProperties( aItem
);
927 return SvxShape::setPropertyValueImpl( rName
, pProperty
, rValue
);
930 throw IllegalArgumentException();
934 bool SvxMediaShape::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, css::uno::Any
& rValue
)
936 if ( ((pProperty
->nWID
>= OWN_ATTR_MEDIA_URL
) &&
937 (pProperty
->nWID
<= OWN_ATTR_MEDIA_ZOOM
))
938 || (pProperty
->nWID
== OWN_ATTR_MEDIA_STREAM
)
939 || (pProperty
->nWID
== OWN_ATTR_MEDIA_TEMPFILEURL
)
940 || (pProperty
->nWID
== OWN_ATTR_MEDIA_MIMETYPE
)
941 || (pProperty
->nWID
== OWN_ATTR_FALLBACK_GRAPHIC
)
942 || (pProperty
->nWID
== OWN_ATTR_VALUE_GRAPHIC
))
944 SdrMediaObj
* pMedia
= static_cast< SdrMediaObj
* >( GetSdrObject() );
945 const ::avmedia::MediaItem
aItem( pMedia
->getMediaProperties() );
947 switch( pProperty
->nWID
)
949 case OWN_ATTR_MEDIA_URL
:
950 #if HAVE_FEATURE_AVMEDIA
951 rValue
<<= aItem
.getURL();
955 case OWN_ATTR_MEDIA_LOOP
:
956 #if HAVE_FEATURE_AVMEDIA
957 rValue
<<= aItem
.isLoop();
961 case OWN_ATTR_MEDIA_MUTE
:
962 #if HAVE_FEATURE_AVMEDIA
963 rValue
<<= aItem
.isMute();
967 case OWN_ATTR_MEDIA_VOLUMEDB
:
968 #if HAVE_FEATURE_AVMEDIA
969 rValue
<<= aItem
.getVolumeDB();
973 case OWN_ATTR_MEDIA_ZOOM
:
974 #if HAVE_FEATURE_AVMEDIA
975 rValue
<<= aItem
.getZoom();
979 case OWN_ATTR_MEDIA_STREAM
:
982 rValue
<<= pMedia
->GetInputStream();
984 catch (const css::ucb::ContentCreationException
&)
986 css::uno::Any anyEx
= cppu::getCaughtException();
987 throw css::lang::WrappedTargetException(
988 "ContentCreationException Getting InputStream!",
989 static_cast < OWeakObject
* > ( this ), anyEx
);
991 catch (const css::ucb::CommandFailedException
&)
993 css::uno::Any anyEx
= cppu::getCaughtException();
994 throw css::lang::WrappedTargetException(
995 "CommandFailedException Getting InputStream!",
996 static_cast < OWeakObject
* > ( this ), anyEx
);
1001 case OWN_ATTR_MEDIA_TEMPFILEURL
:
1002 #if HAVE_FEATURE_AVMEDIA
1003 rValue
<<= aItem
.getTempURL();
1007 case OWN_ATTR_MEDIA_MIMETYPE
:
1008 #if HAVE_FEATURE_AVMEDIA
1009 rValue
<<= aItem
.getMimeType();
1013 case OWN_ATTR_VALUE_GRAPHIC
:
1014 #if HAVE_FEATURE_AVMEDIA
1016 Graphic aGraphic
= aItem
.getGraphic();
1017 if (!aGraphic
.IsNone())
1019 rValue
<<= aGraphic
.GetXGraphic();
1025 case OWN_ATTR_FALLBACK_GRAPHIC
:
1026 rValue
<<= pMedia
->getSnapshot();
1030 OSL_FAIL("SvxMediaShape::getPropertyValueImpl(), unknown property!");
1036 return SvxShape::getPropertyValueImpl( rName
, pProperty
, rValue
);
1040 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */