merge the formfield patch from ooo-build
[ooovba.git] / svx / source / unodraw / unoshap4.cxx
blob96c2caec15b30e253c13186b6cd7fff8ac730924
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoshap4.cxx,v $
10 * $Revision: 1.38 $
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>
44 #ifndef SVX_LIGHT
45 #ifndef _SOT_CLSIDS_HXX
46 #include <sot/clsids.hxx>
47 #endif
48 #include <sfx2/frmdescr.hxx>
49 #endif
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>
66 #include "unoapi.hxx"
67 #include "svx/svdpagv.hxx"
68 #include "svx/svdview.hxx"
69 #include "svdglob.hxx"
70 #include "svdstr.hrc"
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 );
108 //XPropertySet
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 )
114 case OWN_ATTR_CLSID:
116 OUString aCLSID;
117 if( rValue >>= aCLSID )
119 // init an ole object with a global name
120 SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
121 if( pOle2 )
123 uno::Reference < embed::XEmbeddedObject > xObj = pOle2->GetObjRef();
124 if ( !xObj.is() )
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 );
136 if( xObj.is() )
138 aAny <<= aPersistName;
139 setPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ), aAny );
140 pOle2->SetObjRef( xObj );
142 Rectangle aRect = pOle2->GetLogicRect();
143 awt::Size aSz;
144 Size aSize( pOle2->GetLogicRect().GetSize() );
145 aSz.Width = aSize.Width();
146 aSz.Height = aSize.Height();
147 xObj->setVisualAreaSize( pOle2->GetAspect(), aSz );
152 return true;
154 break;
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();
166 if( xObj.is() )
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" );
181 return true;
183 break;
185 case OWN_ATTR_OLE_ASPECT:
187 sal_Int64 nAspect = 0;
188 if( rValue >>= nAspect )
190 static_cast<SdrOle2Obj*>(mpObj.get())->SetAspect( nAspect );
191 return true;
193 break;
195 case OWN_ATTR_CLSID:
197 OUString aCLSID;
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 ) )
205 return true;
208 break;
210 case OWN_ATTR_THUMBNAIL:
212 OUString aURL;
213 if( rValue >>= aURL )
215 GraphicObject aGrafObj( CreateGraphicObjectFromURL( aURL ) );
216 static_cast<SdrOle2Obj*>(mpObj.get())->SetGraphic( &aGrafObj.GetGraphic() );
217 return true;
219 break;
221 case OWN_ATTR_VALUE_GRAPHIC:
223 uno::Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY );
224 if( xGraphic.is() )
226 SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
227 if( pOle )
229 GraphicObject aGrafObj( xGraphic );
230 const Graphic aGraphic( aGrafObj.GetGraphic() );
231 pOle->SetGraphicToObj( aGraphic, rtl::OUString() );
233 return true;
235 break;
237 case OWN_ATTR_PERSISTNAME:
239 OUString aPersistName;
240 if( rValue >>= aPersistName )
242 static_cast<SdrOle2Obj*>(mpObj.get())->SetPersistName( aPersistName );
243 return true;
245 break;
247 case OWN_ATTR_OLE_LINKURL:
249 OUString aLinkURL;
250 if( rValue >>= aLinkURL )
252 createLink( aLinkURL );
253 return true;
255 break;
257 default:
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 )
268 case OWN_ATTR_CLSID:
270 OUString aCLSID;
271 SvGlobalName aClassName = GetClassName_Impl(aCLSID);
272 rValue <<= aCLSID;
273 break;
276 case OWN_ATTR_INTERNAL_OLE:
278 rtl::OUString sCLSID;
279 rValue <<= SotExchange::IsInternal( GetClassName_Impl(sCLSID) );
280 break;
283 case OWN_ATTR_METAFILE:
285 SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(mpObj.get());
286 if( pObj )
288 Graphic* pGraphic = pObj->GetGraphic();
289 if( pGraphic )
291 BOOL bIsWMF = FALSE;
292 if ( pGraphic->IsLink() )
294 GfxLink aLnk = pGraphic->GetLink();
295 if ( aLnk.GetType() == GFX_LINK_TYPE_NATIVE_WMF )
297 bIsWMF = TRUE;
298 uno::Sequence<sal_Int8> aSeq((sal_Int8*)aLnk.GetData(), (sal_Int32) aLnk.GetDataSize());
299 rValue <<= aSeq;
302 if ( !bIsWMF )
304 GDIMetaFile aMtf;
305 if ( pGraphic->GetType() != GRAPHIC_BITMAP )
306 aMtf = pObj->GetGraphic()->GetGDIMetaFile();
307 else
309 VirtualDevice aVirDev;
310 aMtf.Record( &aVirDev );
311 pGraphic->Draw( &aVirDev, Point(), pGraphic->GetPrefSize() );
312 aMtf.Stop();
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());
319 rValue <<= aSeq;
323 else
325 rValue = GetBitmap( sal_True );
327 break;
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() );
340 rValue <<= aVisArea;
341 break;
344 case OWN_ATTR_OLESIZE:
346 Size aTmp( static_cast<SdrOle2Obj*>(mpObj.get())->GetOrigObjSize() );
347 rValue <<= awt::Size( aTmp.Width(), aTmp.Height() );
348 break;
351 case OWN_ATTR_OLE_ASPECT:
353 rValue <<= static_cast<SdrOle2Obj*>(mpObj.get())->GetAspect();
354 break;
357 case OWN_ATTR_OLEMODEL:
358 case OWN_ATTR_OLE_EMBEDDED_OBJECT:
360 SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>( mpObj.get() );
361 if( pObj )
363 uno::Reference < embed::XEmbeddedObject > xObj( pObj->GetObjRef() );
364 if ( xObj.is()
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
369 #ifdef DBG_UTIL
370 const sal_Bool bSuccess(pObj->AddOwnLightClient());
371 OSL_ENSURE( bSuccess, "An object without client is provided!" );
372 #else
373 pObj->AddOwnLightClient();
374 #endif
376 if ( pProperty->nWID == OWN_ATTR_OLEMODEL )
377 rValue <<= pObj->GetObjRef()->getComponent();
378 else
379 rValue <<= xObj;
382 break;
385 case OWN_ATTR_VALUE_GRAPHIC:
387 uno::Reference< graphic::XGraphic > xGraphic;
388 Graphic* pGraphic = static_cast<SdrOle2Obj*>( mpObj.get() )->GetGraphic();
389 if( pGraphic )
390 xGraphic = pGraphic->GetXGraphic();
391 rValue <<= xGraphic;
392 break;
395 case OWN_ATTR_THUMBNAIL:
397 OUString aURL;
398 SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
399 if( pOle )
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();
408 if( pGraphic )
410 GraphicObject aObj( *pGraphic );
411 aURL = OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
412 aURL += OUString::createFromAscii( aObj.GetUniqueID().GetBuffer() );
415 rValue <<= aURL;
416 break;
418 case OWN_ATTR_PERSISTNAME:
420 OUString aPersistName;
421 SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
423 if( pOle )
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;
435 break;
437 case OWN_ATTR_OLE_LINKURL:
439 OUString aLinkURL;
440 SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
442 if( pOle )
444 uno::Reference< embed::XLinkageSupport > xLink( pOle->GetObjRef(), uno::UNO_QUERY );
445 if ( xLink.is() && xLink->isLink() )
446 aLinkURL = xLink->getLinkURL();
449 rValue <<= aLinkURL;
450 break;
452 default:
453 return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
456 return true;
459 sal_Bool SvxOle2Shape::createObject( const SvGlobalName &aClassName )
461 DBG_TESTSOLARMUTEX();
463 SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
464 if ( !pOle2Obj || !pOle2Obj->IsEmpty() )
465 return sal_False;
467 // create storage and inplace object
468 ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist();
469 ::rtl::OUString aPersistName;
470 OUString aTmpStr;
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 ) );
476 if( xObj.is() )
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?
482 // default size
485 awt::Size aSz = xObj->getVisualAreaSize( pOle2Obj->GetAspect() );
486 aRect.SetSize( Size( aSz.Width, aSz.Height ) );
488 catch( embed::NoVisualAreaSizeException& )
490 pOle2Obj->SetLogicRect( aRect );
492 else
494 awt::Size aSz;
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 );
509 return xObj.is();
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() )
518 return sal_False;
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 );
540 if( xObj.is() )
542 Rectangle aRect = pOle2Obj->GetLogicRect();
543 if ( aRect.GetWidth() == 100 && aRect.GetHeight() == 100 )
545 // default size
548 awt::Size aSz = xObj->getVisualAreaSize( pOle2Obj->GetAspect() );
549 aRect.SetSize( Size( aSz.Width, aSz.Height ) );
551 catch( embed::NoVisualAreaSizeException& )
553 pOle2Obj->SetLogicRect( aRect );
555 else
557 awt::Size aSz;
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 );
572 return xObj.is();
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 );
584 if( xMod.is() )
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() );
597 if( pOle2Obj )
599 rHexCLSID = rtl::OUString();
601 if( pOle2Obj->IsEmpty() )
603 ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist();
604 if( pPersist )
606 uno::Reference < embed::XEmbeddedObject > xObj =
607 pPersist->getEmbeddedObjectContainer().GetEmbeddedObject( pOle2Obj->GetPersistName() );
608 if ( xObj.is() )
610 aClassName = SvGlobalName( xObj->getClassID() );
611 rHexCLSID = aClassName.GetHexName();
616 if (!rHexCLSID.getLength())
618 uno::Reference < embed::XEmbeddedObject > xObj( pOle2Obj->GetObjRef() );
619 if ( xObj.is() )
621 aClassName = SvGlobalName( xObj->getClassID() );
622 rHexCLSID = aClassName.GetHexName();
627 return aClassName;
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 );
669 if( xSet.is() )
671 // allow exceptions to pass through
672 xSet->setPropertyValue( rName, rValue );
675 return true;
677 else
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 );
690 if( xSet.is() )
692 rValue = xSet->getPropertyValue( rName );
695 return true;
697 else
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 );
742 if( xSet.is() )
744 // allow exceptions to pass through
745 xSet->setPropertyValue( rName, rValue );
748 return true;
750 else
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 );
763 if( xSet.is() )
765 rValue <<= xSet->getPropertyValue( rName );
768 return true;
770 else
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 );
815 if( xSet.is() )
817 // allow exceptions to pass through
818 xSet->setPropertyValue( rName, rValue );
821 return true;
823 else
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 );
836 if( xSet.is() )
838 rValue <<= xSet->getPropertyValue( rName );
841 return true;
843 else
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;
872 bool bOk = false;
874 switch( pProperty->nWID )
876 case OWN_ATTR_MEDIA_URL:
878 OUString aURL;
879 if( rValue >>= aURL )
881 bOk = true;
882 aItem.setURL( aURL );
885 break;
887 case( OWN_ATTR_MEDIA_LOOP ):
889 sal_Bool bLoop = sal_Bool();
891 if( rValue >>= bLoop )
893 bOk = true;
894 aItem.setLoop( bLoop );
897 break;
899 case( OWN_ATTR_MEDIA_MUTE ):
901 sal_Bool bMute = sal_Bool();
903 if( rValue >>= bMute )
905 bOk = true;
906 aItem.setMute( bMute );
909 break;
911 case( OWN_ATTR_MEDIA_VOLUMEDB ):
913 sal_Int16 nVolumeDB = sal_Int16();
915 if( rValue >>= nVolumeDB )
917 bOk = true;
918 aItem.setVolumeDB( nVolumeDB );
921 break;
923 case( OWN_ATTR_MEDIA_ZOOM ):
925 ::com::sun::star::media::ZoomLevel eLevel;
927 if( rValue >>= eLevel )
929 bOk = true;
930 aItem.setZoom( eLevel );
933 break;
935 default:
936 DBG_ERROR("SvxMediaShape::setPropertyValueImpl(), unknown argument!");
939 if( bOk )
941 pMedia->setMediaProperties( aItem );
942 return true;
945 else
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();
966 break;
968 case( OWN_ATTR_MEDIA_LOOP ):
969 rValue <<= (sal_Bool) aItem.isLoop();
970 break;
972 case( OWN_ATTR_MEDIA_MUTE ):
973 rValue <<= (sal_Bool) aItem.isMute();
974 break;
976 case( OWN_ATTR_MEDIA_VOLUMEDB ):
977 rValue <<= (sal_Int16) aItem.getVolumeDB();
978 break;
980 case( OWN_ATTR_MEDIA_ZOOM ):
981 rValue <<= aItem.getZoom();
982 break;
984 default:
985 DBG_ERROR("SvxMediaShape::getPropertyValueImpl(), unknown property!");
987 return true;
989 else
991 return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );