1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoshap4.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <com/sun/star/util/XModifiable.hpp>
34 #include <com/sun/star/embed/XLinkageSupport.hpp>
35 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
36 #include <com/sun/star/task/XInteractionHandler.hpp>
38 #define _SVX_USE_UNOGLOBALS_
40 #include <vcl/virdev.hxx>
41 #include <svx/svdoole2.hxx>
42 #include <svx/svdomedia.hxx>
45 #ifndef _SOT_CLSIDS_HXX
46 #include <sot/clsids.hxx>
48 #include <sfx2/frmdescr.hxx>
50 #include <vcl/svapp.hxx>
51 #include <vos/mutex.hxx>
53 #include <toolkit/helper/vclunohelper.hxx>
54 #include <sfx2/objsh.hxx>
55 #include <sfx2/docfile.hxx>
57 #include <sot/storage.hxx>
58 #include <sot/exchange.hxx>
59 #include <svtools/FilterConfigItem.hxx>
61 #include <svx/svdmodel.hxx>
62 #include "shapeimpl.hxx"
64 #include <svx/unoshprp.hxx>
67 #include "svx/svdpagv.hxx"
68 #include "svx/svdview.hxx"
69 #include "svdglob.hxx"
72 ///////////////////////////////////////////////////////////////////////
74 extern sal_Bool
ConvertGDIMetaFileToWMF( const GDIMetaFile
& rMTF
, SvStream
& rTargetStream
, FilterConfigItem
* pFilterConfigItem
= NULL
, sal_Bool bPlaceable
= sal_True
);
76 ///////////////////////////////////////////////////////////////////////
78 using namespace ::osl
;
79 using namespace ::vos
;
80 using namespace ::rtl
;
81 using namespace ::cppu
;
82 using namespace ::com::sun::star
;
83 using namespace ::com::sun::star::uno
;
84 using namespace ::com::sun::star::lang
;
85 using namespace ::com::sun::star::container
;
86 using namespace ::com::sun::star::beans
;
88 ///////////////////////////////////////////////////////////////////////
89 SvxOle2Shape::SvxOle2Shape( SdrObject
* pObject
) throw()
90 : SvxShape( pObject
, aSvxMapProvider
.GetMap(SVXMAP_OLE2
), aSvxMapProvider
.GetPropertySet(SVXMAP_OLE2
) )
94 SvxOle2Shape::SvxOle2Shape( SdrObject
* pObject
, const SfxItemPropertyMapEntry
* pPropertyMap
, const SvxItemPropertySet
* pPropertySet
) throw ()
95 : SvxShape( pObject
, pPropertyMap
, pPropertySet
)
99 SvxOle2Shape::~SvxOle2Shape() throw()
103 ::com::sun::star::uno::Any SAL_CALL
SvxOle2Shape::queryAggregation( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
)
105 return SvxShape::queryAggregation( rType
);
109 bool SvxOle2Shape::setPropertyValueImpl( const ::rtl::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
)
111 switch( pProperty
->nWID
)
117 if( rValue >>= aCLSID )
119 // init an ole object with a global name
120 SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
123 uno::Reference < embed::XEmbeddedObject > xObj = pOle2->GetObjRef();
126 SvGlobalName aClassName;
127 if( aClassName.MakeId( aCLSID ) )
129 SfxObjectShell* pPersist = mpModel->GetPersist();
130 ::rtl::OUString aPersistName;
131 Any aAny( getPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ) ) );
132 aAny >>= aPersistName;
134 //TODO/LATER: how to cope with creation failure?!
135 xObj = pPersist->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClassName.GetByteSequence(), aPersistName );
138 aAny <<= aPersistName;
139 setPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ), aAny );
140 pOle2->SetObjRef( xObj );
142 Rectangle aRect = pOle2->GetLogicRect();
144 Size aSize( pOle2->GetLogicRect().GetSize() );
145 aSz.Width = aSize.Width();
146 aSz.Height = aSize.Height();
147 xObj->setVisualAreaSize( pOle2->GetAspect(), aSz );
157 case OWN_ATTR_OLE_VISAREA
:
159 // TODO/LATER: seems to make no sence for iconified object
161 awt::Rectangle aVisArea
;
162 if( (rValue
>>= aVisArea
) && mpObj
->ISA(SdrOle2Obj
))
164 Size
aTmp( aVisArea
.X
+ aVisArea
.Width
, aVisArea
.Y
+ aVisArea
.Height
);
165 uno::Reference
< embed::XEmbeddedObject
> xObj
= ((SdrOle2Obj
*)mpObj
.get())->GetObjRef();
170 MapUnit
aMapUnit( MAP_100TH_MM
); // the API handles with MAP_100TH_MM map mode
171 MapUnit aObjUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj
->getMapUnit( embed::Aspects::MSOLE_CONTENT
) );
172 aTmp
= OutputDevice::LogicToLogic( aTmp
, aMapUnit
, aObjUnit
);
173 xObj
->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT
, awt::Size( aTmp
.Width(), aTmp
.Height() ) );
175 catch( uno::Exception
& )
177 OSL_ENSURE( sal_False
, "Couldn't set the visual area for the object!\n" );
185 case OWN_ATTR_OLE_ASPECT
:
187 sal_Int64 nAspect
= 0;
188 if( rValue
>>= nAspect
)
190 static_cast<SdrOle2Obj
*>(mpObj
.get())->SetAspect( nAspect
);
198 if( rValue
>>= aCLSID
)
200 // init a ole object with a global name
201 SvGlobalName aClassName
;
202 if( aClassName
.MakeId( aCLSID
) )
204 if( createObject( aClassName
) )
210 case OWN_ATTR_THUMBNAIL
:
213 if( rValue
>>= aURL
)
215 GraphicObject
aGrafObj( CreateGraphicObjectFromURL( aURL
) );
216 static_cast<SdrOle2Obj
*>(mpObj
.get())->SetGraphic( &aGrafObj
.GetGraphic() );
221 case OWN_ATTR_VALUE_GRAPHIC
:
223 uno::Reference
< graphic::XGraphic
> xGraphic( rValue
, uno::UNO_QUERY
);
226 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
229 GraphicObject
aGrafObj( xGraphic
);
230 const Graphic
aGraphic( aGrafObj
.GetGraphic() );
231 pOle
->SetGraphicToObj( aGraphic
, rtl::OUString() );
237 case OWN_ATTR_PERSISTNAME
:
239 OUString aPersistName
;
240 if( rValue
>>= aPersistName
)
242 static_cast<SdrOle2Obj
*>(mpObj
.get())->SetPersistName( aPersistName
);
247 case OWN_ATTR_OLE_LINKURL
:
250 if( rValue
>>= aLinkURL
)
252 createLink( aLinkURL
);
258 return SvxShape::setPropertyValueImpl( rName
, pProperty
, rValue
);
261 throw IllegalArgumentException();
264 bool SvxOle2Shape::getPropertyValueImpl( const ::rtl::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
)
266 switch( pProperty
->nWID
)
271 SvGlobalName aClassName
= GetClassName_Impl(aCLSID
);
276 case OWN_ATTR_INTERNAL_OLE
:
278 rtl::OUString sCLSID
;
279 rValue
<<= SotExchange::IsInternal( GetClassName_Impl(sCLSID
) );
283 case OWN_ATTR_METAFILE
:
285 SdrOle2Obj
* pObj
= dynamic_cast<SdrOle2Obj
*>(mpObj
.get());
288 Graphic
* pGraphic
= pObj
->GetGraphic();
292 if ( pGraphic
->IsLink() )
294 GfxLink aLnk
= pGraphic
->GetLink();
295 if ( aLnk
.GetType() == GFX_LINK_TYPE_NATIVE_WMF
)
298 uno::Sequence
<sal_Int8
> aSeq((sal_Int8
*)aLnk
.GetData(), (sal_Int32
) aLnk
.GetDataSize());
305 if ( pGraphic
->GetType() != GRAPHIC_BITMAP
)
306 aMtf
= pObj
->GetGraphic()->GetGDIMetaFile();
309 VirtualDevice aVirDev
;
310 aMtf
.Record( &aVirDev
);
311 pGraphic
->Draw( &aVirDev
, Point(), pGraphic
->GetPrefSize() );
313 aMtf
.SetPrefSize( pGraphic
->GetPrefSize() );
314 aMtf
.SetPrefMapMode( pGraphic
->GetPrefMapMode() );
316 SvMemoryStream
aDestStrm( 65535, 65535 );
317 ConvertGDIMetaFileToWMF( aMtf
, aDestStrm
, NULL
, sal_False
);
318 uno::Sequence
<sal_Int8
> aSeq((sal_Int8
*)aDestStrm
.GetData(), aDestStrm
.GetSize());
325 rValue
= GetBitmap( sal_True
);
330 case OWN_ATTR_OLE_VISAREA
:
332 awt::Rectangle aVisArea
;
333 if( mpObj
->ISA(SdrOle2Obj
))
335 MapMode
aMapMode( MAP_100TH_MM
); // the API uses this map mode
336 Size aTmp
= ((SdrOle2Obj
*)mpObj
.get())->GetOrigObjSize( &aMapMode
); // get the size in the requested map mode
337 aVisArea
= awt::Rectangle( 0, 0, aTmp
.Width(), aTmp
.Height() );
344 case OWN_ATTR_OLESIZE
:
346 Size
aTmp( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetOrigObjSize() );
347 rValue
<<= awt::Size( aTmp
.Width(), aTmp
.Height() );
351 case OWN_ATTR_OLE_ASPECT
:
353 rValue
<<= static_cast<SdrOle2Obj
*>(mpObj
.get())->GetAspect();
357 case OWN_ATTR_OLEMODEL
:
358 case OWN_ATTR_OLE_EMBEDDED_OBJECT
:
360 SdrOle2Obj
* pObj
= dynamic_cast<SdrOle2Obj
*>( mpObj
.get() );
363 uno::Reference
< embed::XEmbeddedObject
> xObj( pObj
->GetObjRef() );
365 && ( pProperty
->nWID
== OWN_ATTR_OLE_EMBEDDED_OBJECT
|| svt::EmbeddedObjectRef::TryRunningState( xObj
) ) )
367 // Discussed with CL fue to the before GetPaintingPageView
368 // usage. Removed it, former fallback is used now
370 const sal_Bool
bSuccess(pObj
->AddOwnLightClient());
371 OSL_ENSURE( bSuccess
, "An object without client is provided!" );
373 pObj
->AddOwnLightClient();
376 if ( pProperty
->nWID
== OWN_ATTR_OLEMODEL
)
377 rValue
<<= pObj
->GetObjRef()->getComponent();
385 case OWN_ATTR_VALUE_GRAPHIC
:
387 uno::Reference
< graphic::XGraphic
> xGraphic
;
388 Graphic
* pGraphic
= static_cast<SdrOle2Obj
*>( mpObj
.get() )->GetGraphic();
390 xGraphic
= pGraphic
->GetXGraphic();
395 case OWN_ATTR_THUMBNAIL
:
398 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
401 Graphic
* pGraphic
= pOle
->GetGraphic();
403 // if there isn't already a preview graphic set, check if we need to generate
404 // one if model says so
405 if( pGraphic
== NULL
&& !pOle
->IsEmptyPresObj() && mpModel
->IsSaveOLEPreview() )
406 pGraphic
= pOle
->GetGraphic();
410 GraphicObject
aObj( *pGraphic
);
411 aURL
= OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX
));
412 aURL
+= OUString::createFromAscii( aObj
.GetUniqueID().GetBuffer() );
418 case OWN_ATTR_PERSISTNAME
:
420 OUString aPersistName
;
421 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
425 aPersistName
= pOle
->GetPersistName();
426 if( aPersistName
.getLength() )
428 ::comphelper::IEmbeddedHelper
*pPersist
= mpObj
->GetModel()->GetPersist();
429 if( (NULL
== pPersist
) || !pPersist
->getEmbeddedObjectContainer().HasEmbeddedObject( pOle
->GetPersistName() ) )
430 aPersistName
= OUString();
434 rValue
<<= aPersistName
;
437 case OWN_ATTR_OLE_LINKURL
:
440 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
444 uno::Reference
< embed::XLinkageSupport
> xLink( pOle
->GetObjRef(), uno::UNO_QUERY
);
445 if ( xLink
.is() && xLink
->isLink() )
446 aLinkURL
= xLink
->getLinkURL();
453 return SvxShape::getPropertyValueImpl( rName
, pProperty
, rValue
);
459 sal_Bool
SvxOle2Shape::createObject( const SvGlobalName
&aClassName
)
461 DBG_TESTSOLARMUTEX();
463 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
464 if ( !pOle2Obj
|| !pOle2Obj
->IsEmpty() )
467 // create storage and inplace object
468 ::comphelper::IEmbeddedHelper
* pPersist
= mpModel
->GetPersist();
469 ::rtl::OUString aPersistName
;
471 if( getPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME
) ) >>= aTmpStr
)
472 aPersistName
= aTmpStr
;
474 //TODO/LATER: how to cope with creation failure?!
475 uno::Reference
< embed::XEmbeddedObject
> xObj( pPersist
->getEmbeddedObjectContainer().CreateEmbeddedObject( aClassName
.GetByteSequence(), aPersistName
) );
478 Rectangle aRect
= pOle2Obj
->GetLogicRect();
479 if ( aRect
.GetWidth() == 100 && aRect
.GetHeight() == 100 )
481 // TODO/LATER: is it possible that this method is used to create an iconified object?
485 awt::Size aSz
= xObj
->getVisualAreaSize( pOle2Obj
->GetAspect() );
486 aRect
.SetSize( Size( aSz
.Width
, aSz
.Height
) );
488 catch( embed::NoVisualAreaSizeException
& )
490 pOle2Obj
->SetLogicRect( aRect
);
495 Size aSize
= pOle2Obj
->GetLogicRect().GetSize();
496 aSz
.Width
= aSize
.Width();
497 aSz
.Height
= aSize
.Height();
498 xObj
->setVisualAreaSize( pOle2Obj
->GetAspect(), aSz
);
501 // connect the object after the visual area is set
502 setPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME
), Any( aTmpStr
= aPersistName
) );
504 // the object is inserted during setting of PersistName property usually
505 if( pOle2Obj
->IsEmpty() )
506 pOle2Obj
->SetObjRef( xObj
);
512 sal_Bool
SvxOle2Shape::createLink( const ::rtl::OUString
& aLinkURL
)
514 DBG_TESTSOLARMUTEX();
516 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
517 if ( !pOle2Obj
|| !pOle2Obj
->IsEmpty() )
520 ::rtl::OUString aPersistName
;
522 ::comphelper::IEmbeddedHelper
* pPersist
= mpModel
->GetPersist();
524 uno::Sequence
< beans::PropertyValue
> aMediaDescr( 1 );
525 aMediaDescr
[0].Name
= ::rtl::OUString::createFromAscii( "URL" );
526 aMediaDescr
[0].Value
<<= aLinkURL
;
528 uno::Reference
< task::XInteractionHandler
> xInteraction
= pPersist
->getInteractionHandler();
529 if ( xInteraction
.is() )
531 aMediaDescr
.realloc( 2 );
532 aMediaDescr
[1].Name
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InteractionHandler" ) );
533 aMediaDescr
[1].Value
<<= xInteraction
;
536 //TODO/LATER: how to cope with creation failure?!
537 uno::Reference
< embed::XEmbeddedObject
> xObj
=
538 pPersist
->getEmbeddedObjectContainer().InsertEmbeddedLink( aMediaDescr
, aPersistName
);
542 Rectangle aRect
= pOle2Obj
->GetLogicRect();
543 if ( aRect
.GetWidth() == 100 && aRect
.GetHeight() == 100 )
548 awt::Size aSz
= xObj
->getVisualAreaSize( pOle2Obj
->GetAspect() );
549 aRect
.SetSize( Size( aSz
.Width
, aSz
.Height
) );
551 catch( embed::NoVisualAreaSizeException
& )
553 pOle2Obj
->SetLogicRect( aRect
);
558 Size aSize
= pOle2Obj
->GetLogicRect().GetSize();
559 aSz
.Width
= aSize
.Width();
560 aSz
.Height
= aSize
.Height();
561 xObj
->setVisualAreaSize( pOle2Obj
->GetAspect(), aSz
);
564 // connect the object after the visual area is set
565 setPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME
), uno::makeAny( aPersistName
) );
567 // the object is inserted during setting of PersistName property usually
568 if ( pOle2Obj
->IsEmpty() )
569 pOle2Obj
->SetObjRef( xObj
);
575 void SvxOle2Shape::resetModifiedState()
577 ::comphelper::IEmbeddedHelper
* pPersist
= mpModel
? mpModel
->GetPersist() : 0;
578 if( pPersist
&& !pPersist
->isEnableSetModified() )
580 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
581 if( pOle
&& !pOle
->IsEmpty() )
583 uno::Reference
< util::XModifiable
> xMod( pOle
->GetObjRef(), uno::UNO_QUERY
);
585 // TODO/MBA: what's this?!
586 xMod
->setModified( sal_False
);
591 const SvGlobalName
SvxOle2Shape::GetClassName_Impl(rtl::OUString
& rHexCLSID
)
593 DBG_TESTSOLARMUTEX();
594 SvGlobalName aClassName
;
595 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
599 rHexCLSID
= rtl::OUString();
601 if( pOle2Obj
->IsEmpty() )
603 ::comphelper::IEmbeddedHelper
* pPersist
= mpModel
->GetPersist();
606 uno::Reference
< embed::XEmbeddedObject
> xObj
=
607 pPersist
->getEmbeddedObjectContainer().GetEmbeddedObject( pOle2Obj
->GetPersistName() );
610 aClassName
= SvGlobalName( xObj
->getClassID() );
611 rHexCLSID
= aClassName
.GetHexName();
616 if (!rHexCLSID
.getLength())
618 uno::Reference
< embed::XEmbeddedObject
> xObj( pOle2Obj
->GetObjRef() );
621 aClassName
= SvGlobalName( xObj
->getClassID() );
622 rHexCLSID
= aClassName
.GetHexName();
630 ///////////////////////////////////////////////////////////////////////
632 SvxAppletShape::SvxAppletShape( SdrObject
* pObject
) throw()
633 : SvxOle2Shape( pObject
, aSvxMapProvider
.GetMap(SVXMAP_APPLET
), aSvxMapProvider
.GetPropertySet(SVXMAP_APPLET
) )
635 SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.AppletShape" ) ) );
638 SvxAppletShape::~SvxAppletShape() throw()
642 void SvxAppletShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
)
644 SvxShape::Create( pNewObj
, pNewPage
);
645 const SvGlobalName
aAppletClassId( SO3_APPLET_CLASSID
);
646 createObject(aAppletClassId
);
647 SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.AppletShape" ) ) );
650 void SAL_CALL
SvxAppletShape::setPropertyValue( const ::rtl::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
)
652 SvxShape::setPropertyValue( aPropertyName
, rValue
);
653 resetModifiedState();
656 void SAL_CALL
SvxAppletShape::setPropertyValues( const ::com::sun::star::uno::Sequence
< ::rtl::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
)
658 SvxShape::setPropertyValues( aPropertyNames
, rValues
);
659 resetModifiedState();
662 bool SvxAppletShape::setPropertyValueImpl( const ::rtl::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
)
664 if( (pProperty
->nWID
>= OWN_ATTR_APPLET_DOCBASE
) && (pProperty
->nWID
<= OWN_ATTR_APPLET_ISSCRIPT
) )
666 if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
668 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
671 // allow exceptions to pass through
672 xSet
->setPropertyValue( rName
, rValue
);
679 return SvxOle2Shape::setPropertyValueImpl( rName
, pProperty
, rValue
);
683 bool SvxAppletShape::getPropertyValueImpl( const ::rtl::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
)
685 if( (pProperty
->nWID
>= OWN_ATTR_APPLET_DOCBASE
) && (pProperty
->nWID
<= OWN_ATTR_APPLET_ISSCRIPT
) )
687 if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
689 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
692 rValue
= xSet
->getPropertyValue( rName
);
699 return SvxOle2Shape::getPropertyValueImpl( rName
, pProperty
, rValue
);
703 ///////////////////////////////////////////////////////////////////////
705 SvxPluginShape::SvxPluginShape( SdrObject
* pObject
) throw()
706 : SvxOle2Shape( pObject
, aSvxMapProvider
.GetMap(SVXMAP_PLUGIN
), aSvxMapProvider
.GetPropertySet(SVXMAP_PLUGIN
) )
708 SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.PluginShape" ) ) );
711 SvxPluginShape::~SvxPluginShape() throw()
715 void SvxPluginShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
)
717 SvxShape::Create( pNewObj
, pNewPage
);
718 const SvGlobalName
aPluginClassId( SO3_PLUGIN_CLASSID
);
719 createObject(aPluginClassId
);
720 SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.PluginShape" ) ) );
723 void SAL_CALL
SvxPluginShape::setPropertyValue( const ::rtl::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
)
725 SvxShape::setPropertyValue( aPropertyName
, rValue
);
726 resetModifiedState();
729 void SAL_CALL
SvxPluginShape::setPropertyValues( const ::com::sun::star::uno::Sequence
< ::rtl::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
)
731 SvxOle2Shape::setPropertyValues( aPropertyNames
, rValues
);
732 resetModifiedState();
735 bool SvxPluginShape::setPropertyValueImpl( const ::rtl::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
)
737 if( (pProperty
->nWID
>= OWN_ATTR_PLUGIN_MIMETYPE
) && (pProperty
->nWID
<= OWN_ATTR_PLUGIN_COMMANDS
) )
739 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
741 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
744 // allow exceptions to pass through
745 xSet
->setPropertyValue( rName
, rValue
);
752 return SvxOle2Shape::setPropertyValueImpl( rName
, pProperty
, rValue
);
756 bool SvxPluginShape::getPropertyValueImpl( const ::rtl::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
)
758 if( (pProperty
->nWID
>= OWN_ATTR_PLUGIN_MIMETYPE
) && (pProperty
->nWID
<= OWN_ATTR_PLUGIN_COMMANDS
) )
760 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
762 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
765 rValue
<<= xSet
->getPropertyValue( rName
);
772 return SvxOle2Shape::getPropertyValueImpl( rName
, pProperty
, rValue
);
776 ///////////////////////////////////////////////////////////////////////
778 SvxFrameShape::SvxFrameShape( SdrObject
* pObject
) throw()
779 : SvxOle2Shape( pObject
, aSvxMapProvider
.GetMap(SVXMAP_FRAME
), aSvxMapProvider
.GetPropertySet(SVXMAP_FRAME
) )
781 SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.FrameShape" ) ) );
784 SvxFrameShape::~SvxFrameShape() throw()
788 void SvxFrameShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
) throw ()
790 SvxShape::Create( pNewObj
, pNewPage
);
791 const SvGlobalName
aIFrameClassId( SO3_IFRAME_CLASSID
);
792 createObject(aIFrameClassId
);
793 SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.FrameShape" ) ) );
796 void SAL_CALL
SvxFrameShape::setPropertyValue( const ::rtl::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
)
798 SvxShape::setPropertyValue( aPropertyName
, rValue
);
799 resetModifiedState();
802 void SAL_CALL
SvxFrameShape::setPropertyValues( const ::com::sun::star::uno::Sequence
< ::rtl::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
)
804 SvxOle2Shape::setPropertyValues( aPropertyNames
, rValues
);
805 resetModifiedState();
808 bool SvxFrameShape::setPropertyValueImpl( const ::rtl::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
)
810 if( (pProperty
->nWID
>= OWN_ATTR_FRAME_URL
) && (pProperty
->nWID
<= OWN_ATTR_FRAME_MARGIN_HEIGHT
) )
812 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
814 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
817 // allow exceptions to pass through
818 xSet
->setPropertyValue( rName
, rValue
);
825 return SvxOle2Shape::setPropertyValueImpl( rName
, pProperty
, rValue
);
829 bool SvxFrameShape::getPropertyValueImpl( const ::rtl::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
)
831 if( (pProperty
->nWID
>= OWN_ATTR_FRAME_URL
) && (pProperty
->nWID
<= OWN_ATTR_FRAME_MARGIN_HEIGHT
) )
833 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
835 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
838 rValue
<<= xSet
->getPropertyValue( rName
);
845 return SvxOle2Shape::getPropertyValueImpl( rName
, pProperty
, rValue
);
849 /***********************************************************************
851 ***********************************************************************/
853 SvxMediaShape::SvxMediaShape( SdrObject
* pObj
) throw()
854 : SvxShape( pObj
, aSvxMapProvider
.GetMap(SVXMAP_MEDIA
), aSvxMapProvider
.GetPropertySet(SVXMAP_MEDIA
) )
856 SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.MediaShape" ) ) );
859 //----------------------------------------------------------------------
860 SvxMediaShape::~SvxMediaShape() throw()
864 //----------------------------------------------------------------------
866 bool SvxMediaShape::setPropertyValueImpl( const ::rtl::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
)
868 if( (pProperty
->nWID
>= OWN_ATTR_MEDIA_URL
) && (pProperty
->nWID
<= OWN_ATTR_MEDIA_ZOOM
) )
870 SdrMediaObj
* pMedia
= static_cast< SdrMediaObj
* >( mpObj
.get() );
871 ::avmedia::MediaItem aItem
;
874 switch( pProperty
->nWID
)
876 case OWN_ATTR_MEDIA_URL
:
879 if( rValue
>>= aURL
)
882 aItem
.setURL( aURL
);
887 case( OWN_ATTR_MEDIA_LOOP
):
889 sal_Bool bLoop
= sal_Bool();
891 if( rValue
>>= bLoop
)
894 aItem
.setLoop( bLoop
);
899 case( OWN_ATTR_MEDIA_MUTE
):
901 sal_Bool bMute
= sal_Bool();
903 if( rValue
>>= bMute
)
906 aItem
.setMute( bMute
);
911 case( OWN_ATTR_MEDIA_VOLUMEDB
):
913 sal_Int16 nVolumeDB
= sal_Int16();
915 if( rValue
>>= nVolumeDB
)
918 aItem
.setVolumeDB( nVolumeDB
);
923 case( OWN_ATTR_MEDIA_ZOOM
):
925 ::com::sun::star::media::ZoomLevel eLevel
;
927 if( rValue
>>= eLevel
)
930 aItem
.setZoom( eLevel
);
936 DBG_ERROR("SvxMediaShape::setPropertyValueImpl(), unknown argument!");
941 pMedia
->setMediaProperties( aItem
);
947 return SvxShape::setPropertyValueImpl( rName
, pProperty
, rValue
);
950 throw IllegalArgumentException();
953 //----------------------------------------------------------------------
955 bool SvxMediaShape::getPropertyValueImpl( const ::rtl::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
)
957 if( ( pProperty
->nWID
>= OWN_ATTR_MEDIA_URL
) && ( pProperty
->nWID
<= OWN_ATTR_MEDIA_ZOOM
) )
959 SdrMediaObj
* pMedia
= static_cast< SdrMediaObj
* >( mpObj
.get() );
960 const ::avmedia::MediaItem
aItem( pMedia
->getMediaProperties() );
962 switch( pProperty
->nWID
)
964 case OWN_ATTR_MEDIA_URL
:
965 rValue
<<= aItem
.getURL();
968 case( OWN_ATTR_MEDIA_LOOP
):
969 rValue
<<= (sal_Bool
) aItem
.isLoop();
972 case( OWN_ATTR_MEDIA_MUTE
):
973 rValue
<<= (sal_Bool
) aItem
.isMute();
976 case( OWN_ATTR_MEDIA_VOLUMEDB
):
977 rValue
<<= (sal_Int16
) aItem
.getVolumeDB();
980 case( OWN_ATTR_MEDIA_ZOOM
):
981 rValue
<<= aItem
.getZoom();
985 DBG_ERROR("SvxMediaShape::getPropertyValueImpl(), unknown property!");
991 return SvxShape::getPropertyValueImpl( rName
, pProperty
, rValue
);