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/XLinkageSupport.hpp>
22 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
23 #include <com/sun/star/embed/Aspects.hpp>
24 #include <com/sun/star/task/XInteractionHandler.hpp>
26 #include <vcl/virdev.hxx>
27 #include <svx/svdoole2.hxx>
28 #include <svx/svdomedia.hxx>
29 #include <svx/svdpool.hxx>
30 #include <comphelper/classids.hxx>
31 #include <sfx2/frmdescr.hxx>
32 #include <vcl/svapp.hxx>
33 #include <osl/mutex.hxx>
35 #include <toolkit/helper/vclunohelper.hxx>
36 #include <sfx2/objsh.hxx>
37 #include <sfx2/docfile.hxx>
39 #include <sot/storage.hxx>
40 #include <sot/exchange.hxx>
41 #include <vcl/FilterConfigItem.hxx>
43 #include <svx/svdmodel.hxx>
44 #include "shapeimpl.hxx"
46 #include <svx/unoshprp.hxx>
48 #include "svx/unoapi.hxx"
49 #include "svx/svdpagv.hxx"
50 #include "svx/svdview.hxx"
51 #include "svx/svdglob.hxx"
52 #include "svx/svdstr.hrc"
53 #include <vcl/wmf.hxx>
55 ///////////////////////////////////////////////////////////////////////
57 using namespace ::osl
;
58 using namespace ::rtl
;
59 using namespace ::cppu
;
60 using namespace ::com::sun::star
;
61 using namespace ::com::sun::star::uno
;
62 using namespace ::com::sun::star::lang
;
63 using namespace ::com::sun::star::container
;
64 using namespace ::com::sun::star::beans
;
66 ///////////////////////////////////////////////////////////////////////
67 SvxOle2Shape::SvxOle2Shape( SdrObject
* pObject
) throw()
68 : SvxShapeText( pObject
, getSvxMapProvider().GetMap(SVXMAP_OLE2
),
69 getSvxMapProvider().GetPropertySet(SVXMAP_OLE2
,SdrObject::GetGlobalDrawObjectItemPool()) )
73 SvxOle2Shape::SvxOle2Shape( SdrObject
* pObject
, const SfxItemPropertyMapEntry
* pPropertyMap
, const SvxItemPropertySet
* pPropertySet
) throw ()
74 : SvxShapeText( pObject
, pPropertyMap
, pPropertySet
)
78 SvxOle2Shape::~SvxOle2Shape() throw()
82 ::com::sun::star::uno::Any SAL_CALL
SvxOle2Shape::queryAggregation( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
84 return SvxShapeText::queryAggregation( rType
);
88 bool SvxOle2Shape::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, const ::com::sun::star::uno::Any
& rValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
90 switch( pProperty
->nWID
)
92 case OWN_ATTR_OLE_VISAREA
:
94 // TODO/LATER: seems to make no sence for iconified object
96 awt::Rectangle aVisArea
;
97 if( (rValue
>>= aVisArea
) && mpObj
->ISA(SdrOle2Obj
))
99 Size
aTmp( aVisArea
.X
+ aVisArea
.Width
, aVisArea
.Y
+ aVisArea
.Height
);
100 uno::Reference
< embed::XEmbeddedObject
> xObj
= ((SdrOle2Obj
*)mpObj
.get())->GetObjRef();
105 MapUnit
aMapUnit( MAP_100TH_MM
); // the API handles with MAP_100TH_MM map mode
106 MapUnit aObjUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj
->getMapUnit( embed::Aspects::MSOLE_CONTENT
) );
107 aTmp
= OutputDevice::LogicToLogic( aTmp
, aMapUnit
, aObjUnit
);
108 xObj
->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT
, awt::Size( aTmp
.Width(), aTmp
.Height() ) );
110 catch( uno::Exception
& )
112 OSL_FAIL( "Couldn't set the visual area for the object!\n" );
120 case OWN_ATTR_OLE_ASPECT
:
122 sal_Int64 nAspect
= 0;
123 if( rValue
>>= nAspect
)
125 static_cast<SdrOle2Obj
*>(mpObj
.get())->SetAspect( nAspect
);
133 if( rValue
>>= aCLSID
)
135 // init a ole object with a global name
136 SvGlobalName aClassName
;
137 if( aClassName
.MakeId( aCLSID
) )
139 if( createObject( aClassName
) )
145 case OWN_ATTR_THUMBNAIL
:
148 if( rValue
>>= aURL
)
150 GraphicObject
aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL
) );
151 static_cast<SdrOle2Obj
*>(mpObj
.get())->SetGraphic( &aGrafObj
.GetGraphic() );
156 case OWN_ATTR_VALUE_GRAPHIC
:
158 uno::Reference
< graphic::XGraphic
> xGraphic( rValue
, uno::UNO_QUERY
);
161 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
164 GraphicObject
aGrafObj( xGraphic
);
165 const Graphic
aGraphic( aGrafObj
.GetGraphic() );
166 pOle
->SetGraphicToObj( aGraphic
, OUString() );
172 case OWN_ATTR_PERSISTNAME
:
174 OUString aPersistName
;
175 if( rValue
>>= aPersistName
)
177 static_cast<SdrOle2Obj
*>(mpObj
.get())->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 SfxItemPropertySimpleEntry
* pProperty
, ::com::sun::star::uno::Any
& rValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
201 switch( pProperty
->nWID
)
206 SvGlobalName aClassName
= 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
*>(mpObj
.get());
223 const Graphic
* pGraphic
= pObj
->GetGraphic();
227 if ( pGraphic
->IsLink() )
229 GfxLink aLnk
= pGraphic
->GetLink();
230 if ( aLnk
.GetType() == GFX_LINK_TYPE_NATIVE_WMF
)
233 uno::Sequence
<sal_Int8
> aSeq((sal_Int8
*)aLnk
.GetData(), (sal_Int32
) aLnk
.GetDataSize());
239 // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
240 GDIMetaFile
aMtf(pObj
->GetGraphic()->GetGDIMetaFile());
241 SvMemoryStream
aDestStrm( 65535, 65535 );
242 ConvertGDIMetaFileToWMF( aMtf
, aDestStrm
, NULL
, sal_False
);
243 const uno::Sequence
<sal_Int8
> aSeq(
244 static_cast< const sal_Int8
* >(aDestStrm
.GetData()),
245 aDestStrm
.GetEndOfData());
252 rValue
= GetBitmap( sal_True
);
257 case OWN_ATTR_OLE_VISAREA
:
259 awt::Rectangle aVisArea
;
260 if( mpObj
->ISA(SdrOle2Obj
))
262 MapMode
aMapMode( MAP_100TH_MM
); // the API uses this map mode
263 Size aTmp
= ((SdrOle2Obj
*)mpObj
.get())->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
*>(mpObj
.get())->GetOrigObjSize() );
274 rValue
<<= awt::Size( aTmp
.Width(), aTmp
.Height() );
278 case OWN_ATTR_OLE_ASPECT
:
280 rValue
<<= static_cast<SdrOle2Obj
*>(mpObj
.get())->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
*>( mpObj
.get() );
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 #if OSL_DEBUG_LEVEL > 0
300 const sal_Bool
bSuccess(pObj
->AddOwnLightClient());
301 OSL_ENSURE( bSuccess
, "An object without client is provided!" );
303 pObj
->AddOwnLightClient();
307 if ( pProperty
->nWID
== OWN_ATTR_OLEMODEL
)
308 rValue
<<= pObj
->GetObjRef()->getComponent();
316 case OWN_ATTR_VALUE_GRAPHIC
:
318 uno::Reference
< graphic::XGraphic
> xGraphic
;
319 const Graphic
* pGraphic
= static_cast<SdrOle2Obj
*>( mpObj
.get() )->GetGraphic();
321 xGraphic
= pGraphic
->GetXGraphic();
326 case OWN_ATTR_THUMBNAIL
:
329 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
332 const Graphic
* pGraphic
= pOle
->GetGraphic();
334 // if there isn't already a preview graphic set, check if we need to generate
335 // one if model says so
336 if( pGraphic
== NULL
&& !pOle
->IsEmptyPresObj() && mpModel
->IsSaveOLEPreview() )
337 pGraphic
= pOle
->GetGraphic();
341 GraphicObject
aObj( *pGraphic
);
342 aURL
= OUString( UNO_NAME_GRAPHOBJ_URLPREFIX
);
343 aURL
+= OStringToOUString(aObj
.GetUniqueID(),
344 RTL_TEXTENCODING_ASCII_US
);
350 case OWN_ATTR_PERSISTNAME
:
352 OUString aPersistName
;
353 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
357 aPersistName
= pOle
->GetPersistName();
358 if( !aPersistName
.isEmpty() )
360 ::comphelper::IEmbeddedHelper
*pPersist
= mpObj
->GetModel()->GetPersist();
361 if( (NULL
== pPersist
) || !pPersist
->getEmbeddedObjectContainer().HasEmbeddedObject( pOle
->GetPersistName() ) )
362 aPersistName
= OUString();
366 rValue
<<= aPersistName
;
369 case OWN_ATTR_OLE_LINKURL
:
372 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
376 uno::Reference
< embed::XLinkageSupport
> xLink( pOle
->GetObjRef(), uno::UNO_QUERY
);
377 if ( xLink
.is() && xLink
->isLink() )
378 aLinkURL
= xLink
->getLinkURL();
385 return SvxShapeText::getPropertyValueImpl( rName
, pProperty
, rValue
);
391 sal_Bool
SvxOle2Shape::createObject( const SvGlobalName
&aClassName
)
393 DBG_TESTSOLARMUTEX();
395 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
396 if ( !pOle2Obj
|| !pOle2Obj
->IsEmpty() )
399 // create storage and inplace object
400 ::comphelper::IEmbeddedHelper
* pPersist
= mpModel
->GetPersist();
401 OUString aPersistName
;
403 if( SvxShape::getPropertyValue( UNO_NAME_OLE2_PERSISTNAME
) >>= aTmpStr
)
404 aPersistName
= aTmpStr
;
406 //TODO/LATER: how to cope with creation failure?!
407 uno::Reference
< embed::XEmbeddedObject
> xObj( pPersist
->getEmbeddedObjectContainer().CreateEmbeddedObject( aClassName
.GetByteSequence(), aPersistName
) );
410 Rectangle aRect
= pOle2Obj
->GetLogicRect();
411 if ( aRect
.GetWidth() == 100 && aRect
.GetHeight() == 100 )
413 // TODO/LATER: is it possible that this method is used to create an iconified object?
417 awt::Size aSz
= xObj
->getVisualAreaSize( pOle2Obj
->GetAspect() );
418 aRect
.SetSize( Size( aSz
.Width
, aSz
.Height
) );
420 catch( embed::NoVisualAreaSizeException
& )
422 pOle2Obj
->SetLogicRect( aRect
);
427 Size aSize
= pOle2Obj
->GetLogicRect().GetSize();
428 aSz
.Width
= aSize
.Width();
429 aSz
.Height
= aSize
.Height();
430 xObj
->setVisualAreaSize( pOle2Obj
->GetAspect(), aSz
);
433 // connect the object after the visual area is set
434 SvxShape::setPropertyValue( UNO_NAME_OLE2_PERSISTNAME
, Any( aTmpStr
= aPersistName
) );
436 // the object is inserted during setting of PersistName property usually
437 if( pOle2Obj
->IsEmpty() )
438 pOle2Obj
->SetObjRef( xObj
);
444 sal_Bool
SvxOle2Shape::createLink( const OUString
& aLinkURL
)
446 DBG_TESTSOLARMUTEX();
448 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
449 if ( !pOle2Obj
|| !pOle2Obj
->IsEmpty() )
452 OUString aPersistName
;
454 ::comphelper::IEmbeddedHelper
* pPersist
= mpModel
->GetPersist();
456 uno::Sequence
< beans::PropertyValue
> aMediaDescr( 1 );
457 aMediaDescr
[0].Name
= OUString("URL");
458 aMediaDescr
[0].Value
<<= aLinkURL
;
460 uno::Reference
< task::XInteractionHandler
> xInteraction
= pPersist
->getInteractionHandler();
461 if ( xInteraction
.is() )
463 aMediaDescr
.realloc( 2 );
464 aMediaDescr
[1].Name
= OUString( "InteractionHandler" );
465 aMediaDescr
[1].Value
<<= xInteraction
;
468 //TODO/LATER: how to cope with creation failure?!
469 uno::Reference
< embed::XEmbeddedObject
> xObj
=
470 pPersist
->getEmbeddedObjectContainer().InsertEmbeddedLink( aMediaDescr
, aPersistName
);
474 Rectangle aRect
= pOle2Obj
->GetLogicRect();
475 if ( aRect
.GetWidth() == 100 && aRect
.GetHeight() == 100 )
480 awt::Size aSz
= xObj
->getVisualAreaSize( pOle2Obj
->GetAspect() );
481 aRect
.SetSize( Size( aSz
.Width
, aSz
.Height
) );
483 catch( embed::NoVisualAreaSizeException
& )
485 pOle2Obj
->SetLogicRect( aRect
);
490 Size aSize
= pOle2Obj
->GetLogicRect().GetSize();
491 aSz
.Width
= aSize
.Width();
492 aSz
.Height
= aSize
.Height();
493 xObj
->setVisualAreaSize( pOle2Obj
->GetAspect(), aSz
);
496 // connect the object after the visual area is set
497 SvxShape::setPropertyValue( UNO_NAME_OLE2_PERSISTNAME
, uno::makeAny( aPersistName
) );
499 // the object is inserted during setting of PersistName property usually
500 if ( pOle2Obj
->IsEmpty() )
501 pOle2Obj
->SetObjRef( xObj
);
507 void SvxOle2Shape::resetModifiedState()
509 ::comphelper::IEmbeddedHelper
* pPersist
= mpModel
? mpModel
->GetPersist() : 0;
510 if( pPersist
&& !pPersist
->isEnableSetModified() )
512 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
513 if( pOle
&& !pOle
->IsEmpty() )
515 uno::Reference
< util::XModifiable
> xMod( pOle
->GetObjRef(), uno::UNO_QUERY
);
517 // TODO/MBA: what's this?!
518 xMod
->setModified( sal_False
);
523 const SvGlobalName
SvxOle2Shape::GetClassName_Impl(OUString
& rHexCLSID
)
525 DBG_TESTSOLARMUTEX();
526 SvGlobalName aClassName
;
527 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
531 rHexCLSID
= OUString();
533 if( pOle2Obj
->IsEmpty() )
535 ::comphelper::IEmbeddedHelper
* pPersist
= mpModel
->GetPersist();
538 uno::Reference
< embed::XEmbeddedObject
> xObj
=
539 pPersist
->getEmbeddedObjectContainer().GetEmbeddedObject( pOle2Obj
->GetPersistName() );
542 aClassName
= SvGlobalName( xObj
->getClassID() );
543 rHexCLSID
= aClassName
.GetHexName();
548 if (rHexCLSID
.isEmpty())
550 uno::Reference
< embed::XEmbeddedObject
> xObj( pOle2Obj
->GetObjRef() );
553 aClassName
= SvGlobalName( xObj
->getClassID() );
554 rHexCLSID
= aClassName
.GetHexName();
562 ///////////////////////////////////////////////////////////////////////
564 SvxAppletShape::SvxAppletShape( SdrObject
* pObject
) throw()
565 : SvxOle2Shape( pObject
, getSvxMapProvider().GetMap(SVXMAP_APPLET
), getSvxMapProvider().GetPropertySet(SVXMAP_APPLET
, SdrObject::GetGlobalDrawObjectItemPool()) )
567 SetShapeType( OUString( "com.sun.star.drawing.AppletShape" ) );
570 SvxAppletShape::~SvxAppletShape() throw()
574 void SvxAppletShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
)
576 SvxShape::Create( pNewObj
, pNewPage
);
577 const SvGlobalName
aAppletClassId( SO3_APPLET_CLASSID
);
578 createObject(aAppletClassId
);
579 SetShapeType( OUString( "com.sun.star.drawing.AppletShape" ) );
582 void SAL_CALL
SvxAppletShape::setPropertyValue( const OUString
& aPropertyName
, const ::com::sun::star::uno::Any
& rValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
584 SvxShape::setPropertyValue( aPropertyName
, rValue
);
585 resetModifiedState();
588 void SAL_CALL
SvxAppletShape::setPropertyValues( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& rValues
) throw (::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
590 SvxShape::setPropertyValues( aPropertyNames
, rValues
);
591 resetModifiedState();
594 bool SvxAppletShape::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, const ::com::sun::star::uno::Any
& rValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
596 if( (pProperty
->nWID
>= OWN_ATTR_APPLET_DOCBASE
) && (pProperty
->nWID
<= OWN_ATTR_APPLET_ISSCRIPT
) )
598 if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
600 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
603 // allow exceptions to pass through
604 xSet
->setPropertyValue( rName
, rValue
);
611 return SvxOle2Shape::setPropertyValueImpl( rName
, pProperty
, rValue
);
615 bool SvxAppletShape::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, ::com::sun::star::uno::Any
& rValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
617 if( (pProperty
->nWID
>= OWN_ATTR_APPLET_DOCBASE
) && (pProperty
->nWID
<= OWN_ATTR_APPLET_ISSCRIPT
) )
619 if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
621 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
624 rValue
= xSet
->getPropertyValue( rName
);
631 return SvxOle2Shape::getPropertyValueImpl( rName
, pProperty
, rValue
);
635 ///////////////////////////////////////////////////////////////////////
637 SvxPluginShape::SvxPluginShape( SdrObject
* pObject
) throw()
638 : SvxOle2Shape( pObject
, getSvxMapProvider().GetMap(SVXMAP_PLUGIN
), getSvxMapProvider().GetPropertySet(SVXMAP_PLUGIN
, SdrObject::GetGlobalDrawObjectItemPool()) )
640 SetShapeType( OUString( "com.sun.star.drawing.PluginShape" ) );
643 SvxPluginShape::~SvxPluginShape() throw()
647 void SvxPluginShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
)
649 SvxShape::Create( pNewObj
, pNewPage
);
650 const SvGlobalName
aPluginClassId( SO3_PLUGIN_CLASSID
);
651 createObject(aPluginClassId
);
652 SetShapeType( OUString( "com.sun.star.drawing.PluginShape" ) );
655 void SAL_CALL
SvxPluginShape::setPropertyValue( const OUString
& aPropertyName
, const ::com::sun::star::uno::Any
& rValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
657 SvxShape::setPropertyValue( aPropertyName
, rValue
);
658 resetModifiedState();
661 void SAL_CALL
SvxPluginShape::setPropertyValues( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& rValues
) throw (::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
663 SvxShape::setPropertyValues( aPropertyNames
, rValues
);
664 resetModifiedState();
667 bool SvxPluginShape::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, const ::com::sun::star::uno::Any
& rValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
669 if( (pProperty
->nWID
>= OWN_ATTR_PLUGIN_MIMETYPE
) && (pProperty
->nWID
<= OWN_ATTR_PLUGIN_COMMANDS
) )
671 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
673 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
676 // allow exceptions to pass through
677 xSet
->setPropertyValue( rName
, rValue
);
684 return SvxOle2Shape::setPropertyValueImpl( rName
, pProperty
, rValue
);
688 bool SvxPluginShape::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, ::com::sun::star::uno::Any
& rValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
690 if( (pProperty
->nWID
>= OWN_ATTR_PLUGIN_MIMETYPE
) && (pProperty
->nWID
<= OWN_ATTR_PLUGIN_COMMANDS
) )
692 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
694 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
697 rValue
<<= xSet
->getPropertyValue( rName
);
704 return SvxOle2Shape::getPropertyValueImpl( rName
, pProperty
, rValue
);
708 ///////////////////////////////////////////////////////////////////////
710 SvxFrameShape::SvxFrameShape( SdrObject
* pObject
) throw()
711 : SvxOle2Shape( pObject
, getSvxMapProvider().GetMap(SVXMAP_FRAME
), getSvxMapProvider().GetPropertySet(SVXMAP_FRAME
, SdrObject::GetGlobalDrawObjectItemPool()) )
713 SetShapeType( OUString( "com.sun.star.drawing.FrameShape" ) );
716 SvxFrameShape::~SvxFrameShape() throw()
720 void SvxFrameShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
) throw ()
722 SvxShape::Create( pNewObj
, pNewPage
);
723 const SvGlobalName
aIFrameClassId( SO3_IFRAME_CLASSID
);
724 createObject(aIFrameClassId
);
725 SetShapeType( OUString( "com.sun.star.drawing.FrameShape" ) );
728 void SAL_CALL
SvxFrameShape::setPropertyValue( const OUString
& aPropertyName
, const ::com::sun::star::uno::Any
& rValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
730 SvxShape::setPropertyValue( aPropertyName
, rValue
);
731 resetModifiedState();
734 void SAL_CALL
SvxFrameShape::setPropertyValues( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& rValues
) throw (::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
736 SvxShape::setPropertyValues( aPropertyNames
, rValues
);
737 resetModifiedState();
740 bool SvxFrameShape::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, const ::com::sun::star::uno::Any
& rValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
742 if( (pProperty
->nWID
>= OWN_ATTR_FRAME_URL
) && (pProperty
->nWID
<= OWN_ATTR_FRAME_MARGIN_HEIGHT
) )
744 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
746 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
749 // allow exceptions to pass through
750 xSet
->setPropertyValue( rName
, rValue
);
757 return SvxOle2Shape::setPropertyValueImpl( rName
, pProperty
, rValue
);
761 bool SvxFrameShape::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, ::com::sun::star::uno::Any
& rValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
763 if( (pProperty
->nWID
>= OWN_ATTR_FRAME_URL
) && (pProperty
->nWID
<= OWN_ATTR_FRAME_MARGIN_HEIGHT
) )
765 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
767 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
770 rValue
<<= xSet
->getPropertyValue( rName
);
777 return SvxOle2Shape::getPropertyValueImpl( rName
, pProperty
, rValue
);
781 /***********************************************************************
783 ***********************************************************************/
785 SvxMediaShape::SvxMediaShape( SdrObject
* pObj
) throw()
786 : SvxShape( pObj
, getSvxMapProvider().GetMap(SVXMAP_MEDIA
), getSvxMapProvider().GetPropertySet(SVXMAP_MEDIA
, SdrObject::GetGlobalDrawObjectItemPool()) )
788 SetShapeType( OUString( "com.sun.star.drawing.MediaShape" ) );
791 //----------------------------------------------------------------------
792 SvxMediaShape::~SvxMediaShape() throw()
796 //----------------------------------------------------------------------
798 bool SvxMediaShape::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, const ::com::sun::star::uno::Any
& rValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
800 if( (pProperty
->nWID
>= OWN_ATTR_MEDIA_URL
) && (pProperty
->nWID
<= OWN_ATTR_MEDIA_ZOOM
) )
802 SdrMediaObj
* pMedia
= static_cast< SdrMediaObj
* >( mpObj
.get() );
803 ::avmedia::MediaItem aItem
;
806 switch( pProperty
->nWID
)
808 case OWN_ATTR_MEDIA_URL
:
811 if( rValue
>>= aURL
)
814 aItem
.setURL( aURL
, 0 );
819 case( OWN_ATTR_MEDIA_LOOP
):
821 sal_Bool bLoop
= sal_Bool();
823 if( rValue
>>= bLoop
)
826 aItem
.setLoop( bLoop
);
831 case( OWN_ATTR_MEDIA_MUTE
):
833 sal_Bool bMute
= sal_Bool();
835 if( rValue
>>= bMute
)
838 aItem
.setMute( bMute
);
843 case( OWN_ATTR_MEDIA_VOLUMEDB
):
845 sal_Int16 nVolumeDB
= sal_Int16();
847 if( rValue
>>= nVolumeDB
)
850 aItem
.setVolumeDB( nVolumeDB
);
855 case( OWN_ATTR_MEDIA_ZOOM
):
857 ::com::sun::star::media::ZoomLevel eLevel
;
859 if( rValue
>>= eLevel
)
862 aItem
.setZoom( eLevel
);
868 OSL_FAIL("SvxMediaShape::setPropertyValueImpl(), unknown argument!");
873 pMedia
->setMediaProperties( aItem
);
879 return SvxShape::setPropertyValueImpl( rName
, pProperty
, rValue
);
882 throw IllegalArgumentException();
885 //----------------------------------------------------------------------
887 bool SvxMediaShape::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, ::com::sun::star::uno::Any
& rValue
) throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
889 if ( ((pProperty
->nWID
>= OWN_ATTR_MEDIA_URL
) &&
890 (pProperty
->nWID
<= OWN_ATTR_MEDIA_ZOOM
))
891 || (pProperty
->nWID
== OWN_ATTR_MEDIA_STREAM
)
892 || (pProperty
->nWID
== OWN_ATTR_MEDIA_TEMPFILEURL
))
894 SdrMediaObj
* pMedia
= static_cast< SdrMediaObj
* >( mpObj
.get() );
895 const ::avmedia::MediaItem
aItem( pMedia
->getMediaProperties() );
897 switch( pProperty
->nWID
)
899 case OWN_ATTR_MEDIA_URL
:
900 rValue
<<= aItem
.getURL();
903 case( OWN_ATTR_MEDIA_LOOP
):
904 rValue
<<= (sal_Bool
) aItem
.isLoop();
907 case( OWN_ATTR_MEDIA_MUTE
):
908 rValue
<<= (sal_Bool
) aItem
.isMute();
911 case( OWN_ATTR_MEDIA_VOLUMEDB
):
912 rValue
<<= (sal_Int16
) aItem
.getVolumeDB();
915 case( OWN_ATTR_MEDIA_ZOOM
):
916 rValue
<<= aItem
.getZoom();
919 case OWN_ATTR_MEDIA_STREAM
:
920 rValue
<<= pMedia
->GetInputStream();
923 case OWN_ATTR_MEDIA_TEMPFILEURL
:
924 rValue
<<= aItem
.getTempURL();
928 OSL_FAIL("SvxMediaShape::getPropertyValueImpl(), unknown property!");
934 return SvxShape::getPropertyValueImpl( rName
, pProperty
, rValue
);
938 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */