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 <vcl/virdev.hxx>
30 #include <svx/svdoole2.hxx>
31 #include <svx/svdomedia.hxx>
32 #include <svx/svdpool.hxx>
33 #include <comphelper/classids.hxx>
34 #include <comphelper/propertysequence.hxx>
35 #include <cppuhelper/exc_hlp.hxx>
36 #include <sfx2/frmdescr.hxx>
37 #include <vcl/svapp.hxx>
39 #include <toolkit/helper/vclunohelper.hxx>
40 #include <sfx2/objsh.hxx>
41 #include <sfx2/docfile.hxx>
43 #include <sot/storage.hxx>
44 #include <sot/exchange.hxx>
45 #include <vcl/FilterConfigItem.hxx>
47 #include <svx/svdmodel.hxx>
48 #include "shapeimpl.hxx"
50 #include <svx/unoshprp.hxx>
52 #include <svx/unoapi.hxx>
53 #include <svx/svdpagv.hxx>
54 #include <svx/svdview.hxx>
55 #include <vcl/wmf.hxx>
56 #include <svtools/embedhlp.hxx>
57 #include <sal/log.hxx>
58 #include <tools/debug.hxx>
60 #include <config_features.h>
63 using namespace ::cppu
;
64 using namespace ::com::sun::star
;
65 using namespace ::com::sun::star::uno
;
66 using namespace ::com::sun::star::lang
;
67 using namespace ::com::sun::star::container
;
68 using namespace ::com::sun::star::beans
;
71 SvxOle2Shape::SvxOle2Shape(SdrObject
* pObject
)
72 : SvxShapeText( pObject
, getSvxMapProvider().GetMap(SVXMAP_OLE2
),
73 getSvxMapProvider().GetPropertySet(SVXMAP_OLE2
,SdrObject::GetGlobalDrawObjectItemPool()) )
77 SvxOle2Shape::SvxOle2Shape(SdrObject
* pObject
, const SfxItemPropertyMapEntry
* pPropertyMap
, const SvxItemPropertySet
* pPropertySet
)
78 : SvxShapeText( pObject
, pPropertyMap
, pPropertySet
)
82 SvxOle2Shape::~SvxOle2Shape() throw()
87 bool SvxOle2Shape::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, const css::uno::Any
& rValue
)
89 switch( pProperty
->nWID
)
91 case OWN_ATTR_OLE_VISAREA
:
93 // TODO/LATER: seems to make no sense for iconified object
95 awt::Rectangle aVisArea
;
96 if( (rValue
>>= aVisArea
) && dynamic_cast<const SdrOle2Obj
* >(GetSdrObject()) != nullptr)
98 Size
aTmp( aVisArea
.X
+ aVisArea
.Width
, aVisArea
.Y
+ aVisArea
.Height
);
99 uno::Reference
< embed::XEmbeddedObject
> xObj
= static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef();
104 // the API handles with MapUnit::Map100thMM map mode
105 MapUnit aObjUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj
->getMapUnit( embed::Aspects::MSOLE_CONTENT
) );
106 aTmp
= OutputDevice::LogicToLogic(aTmp
, MapMode(MapUnit::Map100thMM
), MapMode(aObjUnit
));
107 xObj
->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT
, awt::Size( aTmp
.Width(), aTmp
.Height() ) );
109 catch( uno::Exception
& )
111 OSL_FAIL( "Couldn't set the visual area for the object!" );
119 case OWN_ATTR_OLE_ASPECT
:
121 sal_Int64 nAspect
= 0;
122 if( rValue
>>= nAspect
)
124 static_cast<SdrOle2Obj
*>(GetSdrObject())->SetAspect( nAspect
);
132 if( rValue
>>= aCLSID
)
134 // init an OLE object with a global name
135 SvGlobalName aClassName
;
136 if( aClassName
.MakeId( aCLSID
) )
138 if( createObject( aClassName
) )
144 case OWN_ATTR_THUMBNAIL
:
146 uno::Reference
< graphic::XGraphic
> xGraphic( rValue
, uno::UNO_QUERY
);
149 const Graphic
aGraphic(xGraphic
);
150 static_cast<SdrOle2Obj
*>(GetSdrObject())->SetGraphic(aGraphic
);
155 case OWN_ATTR_VALUE_GRAPHIC
:
157 uno::Reference
< graphic::XGraphic
> xGraphic( rValue
, uno::UNO_QUERY
);
160 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( GetSdrObject() );
163 GraphicObject
aGrafObj( xGraphic
);
164 const Graphic
& aGraphic( aGrafObj
.GetGraphic() );
165 pOle
->SetGraphicToObj( aGraphic
);
171 case OWN_ATTR_PERSISTNAME
:
173 OUString aPersistName
;
174 if( rValue
>>= aPersistName
)
177 #if OSL_DEBUG_LEVEL > 0
178 pOle
= dynamic_cast<SdrOle2Obj
*>(GetSdrObject());
181 pOle
= static_cast<SdrOle2Obj
*>(GetSdrObject());
183 pOle
->SetPersistName( aPersistName
);
188 case OWN_ATTR_OLE_LINKURL
:
191 if( rValue
>>= aLinkURL
)
193 createLink( aLinkURL
);
199 return SvxShapeText::setPropertyValueImpl( rName
, pProperty
, rValue
);
202 throw IllegalArgumentException();
205 bool SvxOle2Shape::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, css::uno::Any
& rValue
)
207 switch( pProperty
->nWID
)
212 GetClassName_Impl(aCLSID
);
217 case OWN_ATTR_INTERNAL_OLE
:
220 rValue
<<= SotExchange::IsInternal( GetClassName_Impl(sCLSID
) );
224 case OWN_ATTR_METAFILE
:
226 SdrOle2Obj
* pObj
= dynamic_cast<SdrOle2Obj
*>(GetSdrObject());
229 const Graphic
* pGraphic
= pObj
->GetGraphic();
233 if ( pGraphic
->IsGfxLink() )
235 GfxLink aLnk
= pGraphic
->GetGfxLink();
236 if ( aLnk
.GetType() == GfxLinkType::NativeWmf
)
239 uno::Sequence
<sal_Int8
> aSeq(reinterpret_cast<sal_Int8
const *>(aLnk
.GetData()), static_cast<sal_Int32
>(aLnk
.GetDataSize()));
245 // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
246 GDIMetaFile
aMtf(pObj
->GetGraphic()->GetGDIMetaFile());
247 SvMemoryStream
aDestStrm( 65535, 65535 );
248 ConvertGDIMetaFileToWMF( aMtf
, aDestStrm
, nullptr, false );
249 const uno::Sequence
<sal_Int8
> aSeq(
250 static_cast< const sal_Int8
* >(aDestStrm
.GetData()),
251 aDestStrm
.GetEndOfData());
258 rValue
= GetBitmap( true );
263 case OWN_ATTR_OLE_VISAREA
:
265 awt::Rectangle aVisArea
;
266 if( dynamic_cast<const SdrOle2Obj
* >(GetSdrObject()) != nullptr)
268 MapMode
aMapMode( MapUnit::Map100thMM
); // the API uses this map mode
269 Size aTmp
= static_cast<SdrOle2Obj
*>(GetSdrObject())->GetOrigObjSize( &aMapMode
); // get the size in the requested map mode
270 aVisArea
= awt::Rectangle( 0, 0, aTmp
.Width(), aTmp
.Height() );
277 case OWN_ATTR_OLESIZE
:
279 Size
aTmp( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetOrigObjSize() );
280 rValue
<<= awt::Size( aTmp
.Width(), aTmp
.Height() );
284 case OWN_ATTR_OLE_ASPECT
:
286 rValue
<<= static_cast<SdrOle2Obj
*>(GetSdrObject())->GetAspect();
290 case OWN_ATTR_OLEMODEL
:
291 case OWN_ATTR_OLE_EMBEDDED_OBJECT
:
292 case OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT
:
294 SdrOle2Obj
* pObj
= dynamic_cast<SdrOle2Obj
*>( GetSdrObject() );
297 uno::Reference
< embed::XEmbeddedObject
> xObj( pObj
->GetObjRef() );
299 && ( pProperty
->nWID
== OWN_ATTR_OLE_EMBEDDED_OBJECT
|| pProperty
->nWID
== OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT
|| svt::EmbeddedObjectRef::TryRunningState( xObj
) ) )
301 // Discussed with CL fue to the before GetPaintingPageView
302 // usage. Removed it, former fallback is used now
303 if ( pProperty
->nWID
== OWN_ATTR_OLEMODEL
|| pProperty
->nWID
== OWN_ATTR_OLE_EMBEDDED_OBJECT
)
305 const bool bSuccess(pObj
->AddOwnLightClient());
306 SAL_WARN_IF(!bSuccess
, "svx.svdraw", "An object without client is provided!");
309 if ( pProperty
->nWID
== OWN_ATTR_OLEMODEL
)
310 rValue
<<= pObj
->GetObjRef()->getComponent();
318 case OWN_ATTR_VALUE_GRAPHIC
:
320 uno::Reference
< graphic::XGraphic
> xGraphic
;
321 const Graphic
* pGraphic
= static_cast<SdrOle2Obj
*>( GetSdrObject() )->GetGraphic();
323 xGraphic
= pGraphic
->GetXGraphic();
328 case OWN_ATTR_THUMBNAIL
:
330 uno::Reference
< graphic::XGraphic
> xGraphic
;
331 const Graphic
* pGraphic
= static_cast<SdrOle2Obj
*>( GetSdrObject() )->GetGraphic();
333 xGraphic
= pGraphic
->GetXGraphic();
337 case OWN_ATTR_PERSISTNAME
:
339 OUString aPersistName
;
340 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( GetSdrObject() );
344 aPersistName
= pOle
->GetPersistName();
345 if( !aPersistName
.isEmpty() )
347 ::comphelper::IEmbeddedHelper
* pPersist(GetSdrObject()->getSdrModelFromSdrObject().GetPersist());
348 if( (nullptr == pPersist
) || !pPersist
->getEmbeddedObjectContainer().HasEmbeddedObject( pOle
->GetPersistName() ) )
349 aPersistName
.clear();
353 rValue
<<= aPersistName
;
356 case OWN_ATTR_OLE_LINKURL
:
359 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( GetSdrObject() );
363 uno::Reference
< embed::XLinkageSupport
> xLink( pOle
->GetObjRef(), uno::UNO_QUERY
);
364 if ( xLink
.is() && xLink
->isLink() )
365 aLinkURL
= xLink
->getLinkURL();
372 return SvxShapeText::getPropertyValueImpl( rName
, pProperty
, rValue
);
378 bool SvxOle2Shape::createObject( const SvGlobalName
&aClassName
)
380 DBG_TESTSOLARMUTEX();
382 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( GetSdrObject() );
383 if ( !pOle2Obj
|| !pOle2Obj
->IsEmpty() )
386 // create storage and inplace object
387 ::comphelper::IEmbeddedHelper
* pPersist
= GetSdrObject()->getSdrModelFromSdrObject().GetPersist();
388 OUString aPersistName
;
390 if( SvxShape::getPropertyValue( UNO_NAME_OLE2_PERSISTNAME
) >>= aTmpStr
)
391 aPersistName
= aTmpStr
;
393 uno::Sequence
<beans::PropertyValue
> objArgs( comphelper::InitPropertySequence({
394 { "DefaultParentBaseURL", Any(pPersist
->getDocumentBaseURL()) }
396 //TODO/LATER: how to cope with creation failure?!
397 uno::Reference
<embed::XEmbeddedObject
> xObj(
398 pPersist
->getEmbeddedObjectContainer().CreateEmbeddedObject(
399 aClassName
.GetByteSequence(), objArgs
, aPersistName
));
402 tools::Rectangle aRect
= pOle2Obj
->GetLogicRect();
403 if ( aRect
.GetWidth() == 101 && aRect
.GetHeight() == 101 )
405 // TODO/LATER: is it possible that this method is used to create an iconified object?
409 awt::Size aSz
= xObj
->getVisualAreaSize( pOle2Obj
->GetAspect() );
410 aRect
.SetSize( Size( aSz
.Width
, aSz
.Height
) );
412 catch( embed::NoVisualAreaSizeException
& )
414 pOle2Obj
->SetLogicRect( aRect
);
419 Size aSize
= aRect
.GetSize();
420 aSz
.Width
= aSize
.Width();
421 aSz
.Height
= aSize
.Height();
422 if (aSz
.Width
!= 0 || aSz
.Height
!= 0)
424 //HACK: can aSz legally be empty?
425 xObj
->setVisualAreaSize( pOle2Obj
->GetAspect(), aSz
);
429 // connect the object after the visual area is set
430 aTmpStr
= aPersistName
;
431 SvxShape::setPropertyValue( UNO_NAME_OLE2_PERSISTNAME
, Any( aTmpStr
) );
433 // the object is inserted during setting of PersistName property usually
434 if( pOle2Obj
->IsEmpty() )
435 pOle2Obj
->SetObjRef( xObj
);
441 void SvxOle2Shape::createLink( const OUString
& aLinkURL
)
443 DBG_TESTSOLARMUTEX();
445 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( GetSdrObject() );
446 if ( !pOle2Obj
|| !pOle2Obj
->IsEmpty() )
449 OUString aPersistName
;
451 ::comphelper::IEmbeddedHelper
* pPersist
= GetSdrObject()->getSdrModelFromSdrObject().GetPersist();
453 uno::Sequence
< beans::PropertyValue
> aMediaDescr( 1 );
454 aMediaDescr
[0].Name
= "URL";
455 aMediaDescr
[0].Value
<<= aLinkURL
;
457 uno::Reference
< task::XInteractionHandler
> xInteraction
= pPersist
->getInteractionHandler();
458 if ( xInteraction
.is() )
460 aMediaDescr
.realloc( 2 );
461 aMediaDescr
[1].Name
= "InteractionHandler";
462 aMediaDescr
[1].Value
<<= xInteraction
;
465 //TODO/LATER: how to cope with creation failure?!
466 uno::Reference
< embed::XEmbeddedObject
> xObj
=
467 pPersist
->getEmbeddedObjectContainer().InsertEmbeddedLink( aMediaDescr
, aPersistName
);
471 tools::Rectangle aRect
= pOle2Obj
->GetLogicRect();
472 if ( aRect
.GetWidth() == 101 && aRect
.GetHeight() == 101 )
477 awt::Size aSz
= xObj
->getVisualAreaSize( pOle2Obj
->GetAspect() );
478 aRect
.SetSize( Size( aSz
.Width
, aSz
.Height
) );
480 catch( embed::NoVisualAreaSizeException
& )
482 pOle2Obj
->SetLogicRect( aRect
);
487 Size aSize
= pOle2Obj
->GetLogicRect().GetSize();
488 aSz
.Width
= aSize
.Width();
489 aSz
.Height
= aSize
.Height();
490 xObj
->setVisualAreaSize( pOle2Obj
->GetAspect(), aSz
);
493 // connect the object after the visual area is set
494 SvxShape::setPropertyValue( UNO_NAME_OLE2_PERSISTNAME
, uno::makeAny( aPersistName
) );
496 // the object is inserted during setting of PersistName property usually
497 if ( pOle2Obj
->IsEmpty() )
498 pOle2Obj
->SetObjRef( xObj
);
502 void SvxOle2Shape::resetModifiedState()
504 ::comphelper::IEmbeddedHelper
* pPersist
= GetSdrObject()->getSdrModelFromSdrObject().GetPersist();
505 if( pPersist
&& !pPersist
->isEnableSetModified() )
507 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( GetSdrObject() );
508 if( pOle
&& !pOle
->IsEmpty() )
510 uno::Reference
< util::XModifiable
> xMod( pOle
->GetObjRef(), uno::UNO_QUERY
);
512 // TODO/MBA: what's this?!
513 xMod
->setModified( false );
518 SvGlobalName
SvxOle2Shape::GetClassName_Impl(OUString
& rHexCLSID
)
520 DBG_TESTSOLARMUTEX();
521 SvGlobalName aClassName
;
522 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( GetSdrObject() );
528 if( pOle2Obj
->IsEmpty() )
530 ::comphelper::IEmbeddedHelper
* pPersist
= GetSdrObject()->getSdrModelFromSdrObject().GetPersist();
533 uno::Reference
< embed::XEmbeddedObject
> xObj
=
534 pPersist
->getEmbeddedObjectContainer().GetEmbeddedObject( pOle2Obj
->GetPersistName() );
537 aClassName
= SvGlobalName( xObj
->getClassID() );
538 rHexCLSID
= aClassName
.GetHexName();
543 if (rHexCLSID
.isEmpty())
545 const uno::Reference
< embed::XEmbeddedObject
>& xObj( pOle2Obj
->GetObjRef() );
548 aClassName
= SvGlobalName( xObj
->getClassID() );
549 rHexCLSID
= aClassName
.GetHexName();
557 SvxAppletShape::SvxAppletShape(SdrObject
* pObject
)
558 : SvxOle2Shape( pObject
, getSvxMapProvider().GetMap(SVXMAP_APPLET
), getSvxMapProvider().GetPropertySet(SVXMAP_APPLET
, SdrObject::GetGlobalDrawObjectItemPool()) )
560 SetShapeType( "com.sun.star.drawing.AppletShape" );
563 SvxAppletShape::~SvxAppletShape() throw()
567 void SvxAppletShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
)
569 SvxShape::Create( pNewObj
, pNewPage
);
570 const SvGlobalName
aAppletClassId( SO3_APPLET_CLASSID
);
571 createObject(aAppletClassId
);
572 SetShapeType( "com.sun.star.drawing.AppletShape" );
575 void SAL_CALL
SvxAppletShape::setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& rValue
)
577 SvxShape::setPropertyValue( aPropertyName
, rValue
);
578 resetModifiedState();
581 void SAL_CALL
SvxAppletShape::setPropertyValues( const css::uno::Sequence
< OUString
>& aPropertyNames
, const css::uno::Sequence
< css::uno::Any
>& rValues
)
583 SvxShape::setPropertyValues( aPropertyNames
, rValues
);
584 resetModifiedState();
587 bool SvxAppletShape::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, const css::uno::Any
& rValue
)
589 if( (pProperty
->nWID
>= OWN_ATTR_APPLET_DOCBASE
) && (pProperty
->nWID
<= OWN_ATTR_APPLET_ISSCRIPT
) )
591 if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef() ) )
593 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
596 // allow exceptions to pass through
597 xSet
->setPropertyValue( rName
, rValue
);
604 return SvxOle2Shape::setPropertyValueImpl( rName
, pProperty
, rValue
);
608 bool SvxAppletShape::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, css::uno::Any
& rValue
)
610 if( (pProperty
->nWID
>= OWN_ATTR_APPLET_DOCBASE
) && (pProperty
->nWID
<= OWN_ATTR_APPLET_ISSCRIPT
) )
612 if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef() ) )
614 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
617 rValue
= xSet
->getPropertyValue( rName
);
624 return SvxOle2Shape::getPropertyValueImpl( rName
, pProperty
, rValue
);
628 SvxPluginShape::SvxPluginShape(SdrObject
* pObject
)
629 : SvxOle2Shape( pObject
, getSvxMapProvider().GetMap(SVXMAP_PLUGIN
), getSvxMapProvider().GetPropertySet(SVXMAP_PLUGIN
, SdrObject::GetGlobalDrawObjectItemPool()) )
631 SetShapeType( "com.sun.star.drawing.PluginShape" );
634 SvxPluginShape::~SvxPluginShape() throw()
638 void SvxPluginShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
)
640 SvxShape::Create( pNewObj
, pNewPage
);
641 const SvGlobalName
aPluginClassId( SO3_PLUGIN_CLASSID
);
642 createObject(aPluginClassId
);
643 SetShapeType( "com.sun.star.drawing.PluginShape" );
646 void SAL_CALL
SvxPluginShape::setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& rValue
)
648 SvxShape::setPropertyValue( aPropertyName
, rValue
);
649 resetModifiedState();
652 void SAL_CALL
SvxPluginShape::setPropertyValues( const css::uno::Sequence
< OUString
>& aPropertyNames
, const css::uno::Sequence
< css::uno::Any
>& rValues
)
654 SvxShape::setPropertyValues( aPropertyNames
, rValues
);
655 resetModifiedState();
658 bool SvxPluginShape::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, const css::uno::Any
& rValue
)
660 if( (pProperty
->nWID
>= OWN_ATTR_PLUGIN_MIMETYPE
) && (pProperty
->nWID
<= OWN_ATTR_PLUGIN_COMMANDS
) )
662 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef() ) )
664 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
667 // allow exceptions to pass through
668 xSet
->setPropertyValue( rName
, rValue
);
675 return SvxOle2Shape::setPropertyValueImpl( rName
, pProperty
, rValue
);
679 bool SvxPluginShape::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, css::uno::Any
& rValue
)
681 if( (pProperty
->nWID
>= OWN_ATTR_PLUGIN_MIMETYPE
) && (pProperty
->nWID
<= OWN_ATTR_PLUGIN_COMMANDS
) )
683 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef() ) )
685 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
688 rValue
= xSet
->getPropertyValue( rName
);
695 return SvxOle2Shape::getPropertyValueImpl( rName
, pProperty
, rValue
);
700 SvxFrameShape::SvxFrameShape(SdrObject
* pObject
)
701 : SvxOle2Shape( pObject
, getSvxMapProvider().GetMap(SVXMAP_FRAME
), getSvxMapProvider().GetPropertySet(SVXMAP_FRAME
, SdrObject::GetGlobalDrawObjectItemPool()) )
703 SetShapeType( "com.sun.star.drawing.FrameShape" );
706 SvxFrameShape::~SvxFrameShape() throw()
710 void SvxFrameShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
)
712 SvxShape::Create( pNewObj
, pNewPage
);
713 const SvGlobalName
aIFrameClassId( SO3_IFRAME_CLASSID
);
714 createObject(aIFrameClassId
);
715 SetShapeType( "com.sun.star.drawing.FrameShape" );
718 void SAL_CALL
SvxFrameShape::setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& rValue
)
720 SvxShape::setPropertyValue( aPropertyName
, rValue
);
721 resetModifiedState();
724 void SAL_CALL
SvxFrameShape::setPropertyValues( const css::uno::Sequence
< OUString
>& aPropertyNames
, const css::uno::Sequence
< css::uno::Any
>& rValues
)
726 SvxShape::setPropertyValues( aPropertyNames
, rValues
);
727 resetModifiedState();
730 bool SvxFrameShape::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, const css::uno::Any
& rValue
)
732 if( (pProperty
->nWID
>= OWN_ATTR_FRAME_URL
) && (pProperty
->nWID
<= OWN_ATTR_FRAME_MARGIN_HEIGHT
) )
734 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef() ) )
736 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
739 // allow exceptions to pass through
740 xSet
->setPropertyValue( rName
, rValue
);
747 return SvxOle2Shape::setPropertyValueImpl( rName
, pProperty
, rValue
);
751 bool SvxFrameShape::getPropertyValueImpl(const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
,
752 css::uno::Any
& rValue
)
754 if( (pProperty
->nWID
>= OWN_ATTR_FRAME_URL
) && (pProperty
->nWID
<= OWN_ATTR_FRAME_MARGIN_HEIGHT
) )
756 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef() ) )
758 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
761 rValue
= xSet
->getPropertyValue( rName
);
768 return SvxOle2Shape::getPropertyValueImpl( rName
, pProperty
, rValue
);
771 SvxMediaShape::SvxMediaShape(SdrObject
* pObj
, OUString
const & referer
)
772 : SvxShape( pObj
, getSvxMapProvider().GetMap(SVXMAP_MEDIA
), getSvxMapProvider().GetPropertySet(SVXMAP_MEDIA
, SdrObject::GetGlobalDrawObjectItemPool()) ),
775 SetShapeType( "com.sun.star.drawing.MediaShape" );
779 SvxMediaShape::~SvxMediaShape() throw()
784 bool SvxMediaShape::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, const css::uno::Any
& rValue
)
786 if( ((pProperty
->nWID
>= OWN_ATTR_MEDIA_URL
) && (pProperty
->nWID
<= OWN_ATTR_MEDIA_ZOOM
))
787 || (pProperty
->nWID
== OWN_ATTR_MEDIA_STREAM
)
788 || (pProperty
->nWID
== OWN_ATTR_MEDIA_MIMETYPE
) )
790 SdrMediaObj
* pMedia
= static_cast< SdrMediaObj
* >( GetSdrObject() );
791 ::avmedia::MediaItem aItem
;
794 switch( pProperty
->nWID
)
796 case OWN_ATTR_MEDIA_URL
:
797 #if HAVE_FEATURE_AVMEDIA
800 if( rValue
>>= aURL
)
803 aItem
.setURL( aURL
, "", referer_
);
809 case OWN_ATTR_MEDIA_LOOP
:
810 #if HAVE_FEATURE_AVMEDIA
814 if( rValue
>>= bLoop
)
817 aItem
.setLoop( bLoop
);
823 case OWN_ATTR_MEDIA_MUTE
:
824 #if HAVE_FEATURE_AVMEDIA
828 if( rValue
>>= bMute
)
831 aItem
.setMute( bMute
);
837 case OWN_ATTR_MEDIA_VOLUMEDB
:
838 #if HAVE_FEATURE_AVMEDIA
840 sal_Int16 nVolumeDB
= sal_Int16();
842 if( rValue
>>= nVolumeDB
)
845 aItem
.setVolumeDB( nVolumeDB
);
851 case OWN_ATTR_MEDIA_ZOOM
:
852 #if HAVE_FEATURE_AVMEDIA
854 css::media::ZoomLevel eLevel
;
856 if( rValue
>>= eLevel
)
859 aItem
.setZoom( eLevel
);
865 case OWN_ATTR_MEDIA_MIMETYPE
:
866 #if HAVE_FEATURE_AVMEDIA
869 if( rValue
>>= sMimeType
)
872 aItem
.setMimeType( sMimeType
);
878 case OWN_ATTR_MEDIA_STREAM
:
879 #if HAVE_FEATURE_AVMEDIA
882 uno::Reference
<io::XInputStream
> xStream
;
883 if (rValue
>>= xStream
)
885 pMedia
->SetInputStream(xStream
);
888 catch (const css::ucb::ContentCreationException
&)
890 css::uno::Any exc
= cppu::getCaughtException();
891 throw css::lang::WrappedTargetException(
892 "ContentCreationException Setting InputStream!",
893 static_cast<OWeakObject
*>(this),
896 catch (const css::ucb::CommandFailedException
&)
898 css::uno::Any anyEx
= cppu::getCaughtException();
899 throw css::lang::WrappedTargetException(
900 "CommandFailedException Setting InputStream!",
901 static_cast<OWeakObject
*>(this),
908 OSL_FAIL("SvxMediaShape::setPropertyValueImpl(), unknown argument!");
913 pMedia
->setMediaProperties( aItem
);
919 return SvxShape::setPropertyValueImpl( rName
, pProperty
, rValue
);
922 throw IllegalArgumentException();
926 bool SvxMediaShape::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, css::uno::Any
& rValue
)
928 if ( ((pProperty
->nWID
>= OWN_ATTR_MEDIA_URL
) &&
929 (pProperty
->nWID
<= OWN_ATTR_MEDIA_ZOOM
))
930 || (pProperty
->nWID
== OWN_ATTR_MEDIA_STREAM
)
931 || (pProperty
->nWID
== OWN_ATTR_MEDIA_TEMPFILEURL
)
932 || (pProperty
->nWID
== OWN_ATTR_MEDIA_MIMETYPE
)
933 || (pProperty
->nWID
== OWN_ATTR_FALLBACK_GRAPHIC
))
935 SdrMediaObj
* pMedia
= static_cast< SdrMediaObj
* >( GetSdrObject() );
936 const ::avmedia::MediaItem
aItem( pMedia
->getMediaProperties() );
938 switch( pProperty
->nWID
)
940 case OWN_ATTR_MEDIA_URL
:
941 #if HAVE_FEATURE_AVMEDIA
942 rValue
<<= aItem
.getURL();
946 case OWN_ATTR_MEDIA_LOOP
:
947 #if HAVE_FEATURE_AVMEDIA
948 rValue
<<= aItem
.isLoop();
952 case OWN_ATTR_MEDIA_MUTE
:
953 #if HAVE_FEATURE_AVMEDIA
954 rValue
<<= aItem
.isMute();
958 case OWN_ATTR_MEDIA_VOLUMEDB
:
959 #if HAVE_FEATURE_AVMEDIA
960 rValue
<<= aItem
.getVolumeDB();
964 case OWN_ATTR_MEDIA_ZOOM
:
965 #if HAVE_FEATURE_AVMEDIA
966 rValue
<<= aItem
.getZoom();
970 case OWN_ATTR_MEDIA_STREAM
:
973 rValue
<<= pMedia
->GetInputStream();
975 catch (const css::ucb::ContentCreationException
&)
977 css::uno::Any anyEx
= cppu::getCaughtException();
978 throw css::lang::WrappedTargetException(
979 "ContentCreationException Getting InputStream!",
980 static_cast < OWeakObject
* > ( this ), anyEx
);
982 catch (const css::ucb::CommandFailedException
&)
984 css::uno::Any anyEx
= cppu::getCaughtException();
985 throw css::lang::WrappedTargetException(
986 "CommandFailedException Getting InputStream!",
987 static_cast < OWeakObject
* > ( this ), anyEx
);
992 case OWN_ATTR_MEDIA_TEMPFILEURL
:
993 #if HAVE_FEATURE_AVMEDIA
994 rValue
<<= aItem
.getTempURL();
998 case OWN_ATTR_MEDIA_MIMETYPE
:
999 #if HAVE_FEATURE_AVMEDIA
1000 rValue
<<= aItem
.getMimeType();
1004 case OWN_ATTR_FALLBACK_GRAPHIC
:
1005 rValue
<<= pMedia
->getSnapshot();
1009 OSL_FAIL("SvxMediaShape::getPropertyValueImpl(), unknown property!");
1015 return SvxShape::getPropertyValueImpl( rName
, pProperty
, rValue
);
1019 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */