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>
25 #include <com/sun/star/ucb/CommandFailedException.hpp>
27 #include <vcl/virdev.hxx>
28 #include <svx/svdoole2.hxx>
29 #include <svx/svdomedia.hxx>
30 #include <svx/svdpool.hxx>
31 #include <comphelper/classids.hxx>
32 #include <sfx2/frmdescr.hxx>
33 #include <vcl/svapp.hxx>
34 #include <osl/mutex.hxx>
36 #include <toolkit/helper/vclunohelper.hxx>
37 #include <sfx2/objsh.hxx>
38 #include <sfx2/docfile.hxx>
40 #include <sot/storage.hxx>
41 #include <sot/exchange.hxx>
42 #include <vcl/FilterConfigItem.hxx>
44 #include <svx/svdmodel.hxx>
45 #include "shapeimpl.hxx"
47 #include <svx/unoshprp.hxx>
49 #include "svx/unoapi.hxx"
50 #include "svx/svdpagv.hxx"
51 #include "svx/svdview.hxx"
52 #include "svdglob.hxx"
53 #include "svx/svdstr.hrc"
54 #include <svdoopengl.hxx>
55 #include <vcl/wmf.hxx>
56 #include <svtools/embedhlp.hxx>
59 using namespace ::osl
;
60 using namespace ::cppu
;
61 using namespace ::com::sun::star
;
62 using namespace ::com::sun::star::uno
;
63 using namespace ::com::sun::star::lang
;
64 using namespace ::com::sun::star::container
;
65 using namespace ::com::sun::star::beans
;
68 SvxOle2Shape::SvxOle2Shape( SdrObject
* pObject
) throw()
69 : SvxShapeText( pObject
, getSvxMapProvider().GetMap(SVXMAP_OLE2
),
70 getSvxMapProvider().GetPropertySet(SVXMAP_OLE2
,SdrObject::GetGlobalDrawObjectItemPool()) )
74 SvxOle2Shape::SvxOle2Shape( SdrObject
* pObject
, const SfxItemPropertyMapEntry
* pPropertyMap
, const SvxItemPropertySet
* pPropertySet
) throw ()
75 : SvxShapeText( pObject
, pPropertyMap
, pPropertySet
)
79 SvxOle2Shape::~SvxOle2Shape() throw()
83 ::com::sun::star::uno::Any SAL_CALL
SvxOle2Shape::queryAggregation( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
85 return SvxShapeText::queryAggregation( rType
);
89 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
, std::exception
)
91 switch( pProperty
->nWID
)
93 case OWN_ATTR_OLE_VISAREA
:
95 // TODO/LATER: seems to make no sense for iconified object
97 awt::Rectangle aVisArea
;
98 if( (rValue
>>= aVisArea
) && mpObj
->ISA(SdrOle2Obj
))
100 Size
aTmp( aVisArea
.X
+ aVisArea
.Width
, aVisArea
.Y
+ aVisArea
.Height
);
101 uno::Reference
< embed::XEmbeddedObject
> xObj
= static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef();
106 MapUnit
aMapUnit( MAP_100TH_MM
); // the API handles with MAP_100TH_MM map mode
107 MapUnit aObjUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj
->getMapUnit( embed::Aspects::MSOLE_CONTENT
) );
108 aTmp
= OutputDevice::LogicToLogic( aTmp
, aMapUnit
, aObjUnit
);
109 xObj
->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT
, awt::Size( aTmp
.Width(), aTmp
.Height() ) );
111 catch( uno::Exception
& )
113 OSL_FAIL( "Couldn't set the visual area for the object!\n" );
121 case OWN_ATTR_OLE_ASPECT
:
123 sal_Int64 nAspect
= 0;
124 if( rValue
>>= nAspect
)
126 static_cast<SdrOle2Obj
*>(mpObj
.get())->SetAspect( nAspect
);
134 if( rValue
>>= aCLSID
)
136 // init a ole object with a global name
137 SvGlobalName aClassName
;
138 if( aClassName
.MakeId( aCLSID
) )
140 if( createObject( aClassName
) )
146 case OWN_ATTR_THUMBNAIL
:
149 if( rValue
>>= aURL
)
151 GraphicObject
aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL
) );
152 static_cast<SdrOle2Obj
*>(mpObj
.get())->SetGraphic( &aGrafObj
.GetGraphic() );
157 case OWN_ATTR_VALUE_GRAPHIC
:
159 uno::Reference
< graphic::XGraphic
> xGraphic( rValue
, uno::UNO_QUERY
);
162 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
165 GraphicObject
aGrafObj( xGraphic
);
166 const Graphic
aGraphic( aGrafObj
.GetGraphic() );
167 pOle
->SetGraphicToObj( aGraphic
, OUString() );
173 case OWN_ATTR_PERSISTNAME
:
175 OUString aPersistName
;
176 if( rValue
>>= aPersistName
)
179 #if OSL_DEBUG_LEVEL > 0
180 pOle
= dynamic_cast<SdrOle2Obj
*>(mpObj
.get());
183 pOle
= static_cast<SdrOle2Obj
*>(mpObj
.get());
185 pOle
->SetPersistName( aPersistName
);
190 case OWN_ATTR_OLE_LINKURL
:
193 if( rValue
>>= aLinkURL
)
195 createLink( aLinkURL
);
201 return SvxShapeText::setPropertyValueImpl( rName
, pProperty
, rValue
);
204 throw IllegalArgumentException();
207 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
, std::exception
)
209 switch( pProperty
->nWID
)
214 SvGlobalName aClassName
= GetClassName_Impl(aCLSID
);
219 case OWN_ATTR_INTERNAL_OLE
:
222 rValue
<<= SotExchange::IsInternal( GetClassName_Impl(sCLSID
) );
226 case OWN_ATTR_METAFILE
:
228 SdrOle2Obj
* pObj
= dynamic_cast<SdrOle2Obj
*>(mpObj
.get());
231 const Graphic
* pGraphic
= pObj
->GetGraphic();
235 if ( pGraphic
->IsLink() )
237 GfxLink aLnk
= pGraphic
->GetLink();
238 if ( aLnk
.GetType() == GFX_LINK_TYPE_NATIVE_WMF
)
241 uno::Sequence
<sal_Int8
> aSeq(reinterpret_cast<sal_Int8
const *>(aLnk
.GetData()), (sal_Int32
) aLnk
.GetDataSize());
247 // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
248 GDIMetaFile
aMtf(pObj
->GetGraphic()->GetGDIMetaFile());
249 SvMemoryStream
aDestStrm( 65535, 65535 );
250 ConvertGDIMetaFileToWMF( aMtf
, aDestStrm
, NULL
, false );
251 const uno::Sequence
<sal_Int8
> aSeq(
252 static_cast< const sal_Int8
* >(aDestStrm
.GetData()),
253 aDestStrm
.GetEndOfData());
260 rValue
= GetBitmap( true );
265 case OWN_ATTR_OLE_VISAREA
:
267 awt::Rectangle aVisArea
;
268 if( mpObj
->ISA(SdrOle2Obj
))
270 MapMode
aMapMode( MAP_100TH_MM
); // the API uses this map mode
271 Size aTmp
= static_cast<SdrOle2Obj
*>(mpObj
.get())->GetOrigObjSize( &aMapMode
); // get the size in the requested map mode
272 aVisArea
= awt::Rectangle( 0, 0, aTmp
.Width(), aTmp
.Height() );
279 case OWN_ATTR_OLESIZE
:
281 Size
aTmp( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetOrigObjSize() );
282 rValue
<<= awt::Size( aTmp
.Width(), aTmp
.Height() );
286 case OWN_ATTR_OLE_ASPECT
:
288 rValue
<<= static_cast<SdrOle2Obj
*>(mpObj
.get())->GetAspect();
292 case OWN_ATTR_OLEMODEL
:
293 case OWN_ATTR_OLE_EMBEDDED_OBJECT
:
294 case OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT
:
296 SdrOle2Obj
* pObj
= dynamic_cast<SdrOle2Obj
*>( mpObj
.get() );
299 uno::Reference
< embed::XEmbeddedObject
> xObj( pObj
->GetObjRef() );
301 && ( pProperty
->nWID
== OWN_ATTR_OLE_EMBEDDED_OBJECT
|| pProperty
->nWID
== OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT
|| svt::EmbeddedObjectRef::TryRunningState( xObj
) ) )
303 // Discussed with CL fue to the before GetPaintingPageView
304 // usage. Removed it, former fallback is used now
305 if ( pProperty
->nWID
== OWN_ATTR_OLEMODEL
|| pProperty
->nWID
== OWN_ATTR_OLE_EMBEDDED_OBJECT
)
307 #if OSL_DEBUG_LEVEL > 0
308 const bool bSuccess(pObj
->AddOwnLightClient());
309 OSL_ENSURE( bSuccess
, "An object without client is provided!" );
311 pObj
->AddOwnLightClient();
315 if ( pProperty
->nWID
== OWN_ATTR_OLEMODEL
)
316 rValue
<<= pObj
->GetObjRef()->getComponent();
324 case OWN_ATTR_VALUE_GRAPHIC
:
326 uno::Reference
< graphic::XGraphic
> xGraphic
;
327 const Graphic
* pGraphic
= static_cast<SdrOle2Obj
*>( mpObj
.get() )->GetGraphic();
329 xGraphic
= pGraphic
->GetXGraphic();
334 case OWN_ATTR_THUMBNAIL
:
337 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
340 const Graphic
* pGraphic
= pOle
->GetGraphic();
342 // if there isn't already a preview graphic set, check if we need to generate
343 // one if model says so
344 if( pGraphic
== NULL
&& !pOle
->IsEmptyPresObj() && mpModel
->IsSaveOLEPreview() )
345 pGraphic
= pOle
->GetGraphic();
349 GraphicObject
aObj( *pGraphic
);
350 aURL
= UNO_NAME_GRAPHOBJ_URLPREFIX
;
351 aURL
+= OStringToOUString(aObj
.GetUniqueID(),
352 RTL_TEXTENCODING_ASCII_US
);
358 case OWN_ATTR_PERSISTNAME
:
360 OUString aPersistName
;
361 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
365 aPersistName
= pOle
->GetPersistName();
366 if( !aPersistName
.isEmpty() )
368 ::comphelper::IEmbeddedHelper
*pPersist
= mpObj
->GetModel()->GetPersist();
369 if( (NULL
== pPersist
) || !pPersist
->getEmbeddedObjectContainer().HasEmbeddedObject( pOle
->GetPersistName() ) )
370 aPersistName
.clear();
374 rValue
<<= aPersistName
;
377 case OWN_ATTR_OLE_LINKURL
:
380 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
384 uno::Reference
< embed::XLinkageSupport
> xLink( pOle
->GetObjRef(), uno::UNO_QUERY
);
385 if ( xLink
.is() && xLink
->isLink() )
386 aLinkURL
= xLink
->getLinkURL();
393 return SvxShapeText::getPropertyValueImpl( rName
, pProperty
, rValue
);
399 bool SvxOle2Shape::createObject( const SvGlobalName
&aClassName
)
401 DBG_TESTSOLARMUTEX();
403 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
404 if ( !pOle2Obj
|| !pOle2Obj
->IsEmpty() )
407 // create storage and inplace object
408 ::comphelper::IEmbeddedHelper
* pPersist
= mpModel
->GetPersist();
409 OUString aPersistName
;
411 if( SvxShape::getPropertyValue( UNO_NAME_OLE2_PERSISTNAME
) >>= aTmpStr
)
412 aPersistName
= aTmpStr
;
414 //TODO/LATER: how to cope with creation failure?!
415 uno::Reference
< embed::XEmbeddedObject
> xObj( pPersist
->getEmbeddedObjectContainer().CreateEmbeddedObject( aClassName
.GetByteSequence(), aPersistName
) );
418 Rectangle aRect
= pOle2Obj
->GetLogicRect();
419 if ( aRect
.GetWidth() == 100 && aRect
.GetHeight() == 100 )
421 // TODO/LATER: is it possible that this method is used to create an iconified object?
425 awt::Size aSz
= xObj
->getVisualAreaSize( pOle2Obj
->GetAspect() );
426 aRect
.SetSize( Size( aSz
.Width
, aSz
.Height
) );
428 catch( embed::NoVisualAreaSizeException
& )
430 pOle2Obj
->SetLogicRect( aRect
);
435 Size aSize
= aRect
.GetSize();
436 aSz
.Width
= aSize
.Width();
437 aSz
.Height
= aSize
.Height();
438 if (aSz
.Width
!= 0 || aSz
.Height
!= 0)
440 //HACK: can aSz legally be empty?
441 xObj
->setVisualAreaSize( pOle2Obj
->GetAspect(), aSz
);
445 // connect the object after the visual area is set
446 SvxShape::setPropertyValue( UNO_NAME_OLE2_PERSISTNAME
, Any( aTmpStr
= aPersistName
) );
448 // the object is inserted during setting of PersistName property usually
449 if( pOle2Obj
->IsEmpty() )
450 pOle2Obj
->SetObjRef( xObj
);
456 bool SvxOle2Shape::createLink( const OUString
& aLinkURL
)
458 DBG_TESTSOLARMUTEX();
460 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
461 if ( !pOle2Obj
|| !pOle2Obj
->IsEmpty() )
464 OUString aPersistName
;
466 ::comphelper::IEmbeddedHelper
* pPersist
= mpModel
->GetPersist();
468 uno::Sequence
< beans::PropertyValue
> aMediaDescr( 1 );
469 aMediaDescr
[0].Name
= "URL";
470 aMediaDescr
[0].Value
<<= aLinkURL
;
472 uno::Reference
< task::XInteractionHandler
> xInteraction
= pPersist
->getInteractionHandler();
473 if ( xInteraction
.is() )
475 aMediaDescr
.realloc( 2 );
476 aMediaDescr
[1].Name
= "InteractionHandler";
477 aMediaDescr
[1].Value
<<= xInteraction
;
480 //TODO/LATER: how to cope with creation failure?!
481 uno::Reference
< embed::XEmbeddedObject
> xObj
=
482 pPersist
->getEmbeddedObjectContainer().InsertEmbeddedLink( aMediaDescr
, aPersistName
);
486 Rectangle aRect
= pOle2Obj
->GetLogicRect();
487 if ( aRect
.GetWidth() == 100 && aRect
.GetHeight() == 100 )
492 awt::Size aSz
= xObj
->getVisualAreaSize( pOle2Obj
->GetAspect() );
493 aRect
.SetSize( Size( aSz
.Width
, aSz
.Height
) );
495 catch( embed::NoVisualAreaSizeException
& )
497 pOle2Obj
->SetLogicRect( aRect
);
502 Size aSize
= pOle2Obj
->GetLogicRect().GetSize();
503 aSz
.Width
= aSize
.Width();
504 aSz
.Height
= aSize
.Height();
505 xObj
->setVisualAreaSize( pOle2Obj
->GetAspect(), aSz
);
508 // connect the object after the visual area is set
509 SvxShape::setPropertyValue( UNO_NAME_OLE2_PERSISTNAME
, uno::makeAny( aPersistName
) );
511 // the object is inserted during setting of PersistName property usually
512 if ( pOle2Obj
->IsEmpty() )
513 pOle2Obj
->SetObjRef( xObj
);
519 void SvxOle2Shape::resetModifiedState()
521 ::comphelper::IEmbeddedHelper
* pPersist
= mpModel
? mpModel
->GetPersist() : 0;
522 if( pPersist
&& !pPersist
->isEnableSetModified() )
524 SdrOle2Obj
* pOle
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
525 if( pOle
&& !pOle
->IsEmpty() )
527 uno::Reference
< util::XModifiable
> xMod( pOle
->GetObjRef(), uno::UNO_QUERY
);
529 // TODO/MBA: what's this?!
530 xMod
->setModified( sal_False
);
535 const SvGlobalName
SvxOle2Shape::GetClassName_Impl(OUString
& rHexCLSID
)
537 DBG_TESTSOLARMUTEX();
538 SvGlobalName aClassName
;
539 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( mpObj
.get() );
545 if( pOle2Obj
->IsEmpty() )
547 ::comphelper::IEmbeddedHelper
* pPersist
= mpModel
->GetPersist();
550 uno::Reference
< embed::XEmbeddedObject
> xObj
=
551 pPersist
->getEmbeddedObjectContainer().GetEmbeddedObject( pOle2Obj
->GetPersistName() );
554 aClassName
= SvGlobalName( xObj
->getClassID() );
555 rHexCLSID
= aClassName
.GetHexName();
560 if (rHexCLSID
.isEmpty())
562 uno::Reference
< embed::XEmbeddedObject
> xObj( pOle2Obj
->GetObjRef() );
565 aClassName
= SvGlobalName( xObj
->getClassID() );
566 rHexCLSID
= aClassName
.GetHexName();
576 SvxAppletShape::SvxAppletShape( SdrObject
* pObject
) throw()
577 : SvxOle2Shape( pObject
, getSvxMapProvider().GetMap(SVXMAP_APPLET
), getSvxMapProvider().GetPropertySet(SVXMAP_APPLET
, SdrObject::GetGlobalDrawObjectItemPool()) )
579 SetShapeType( OUString( "com.sun.star.drawing.AppletShape" ) );
582 SvxAppletShape::~SvxAppletShape() throw()
586 void SvxAppletShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
)
588 SvxShape::Create( pNewObj
, pNewPage
);
589 const SvGlobalName
aAppletClassId( SO3_APPLET_CLASSID
);
590 createObject(aAppletClassId
);
591 SetShapeType( OUString( "com.sun.star.drawing.AppletShape" ) );
594 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
, std::exception
)
596 SvxShape::setPropertyValue( aPropertyName
, rValue
);
597 resetModifiedState();
600 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
, std::exception
)
602 SvxShape::setPropertyValues( aPropertyNames
, rValues
);
603 resetModifiedState();
606 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
, std::exception
)
608 if( (pProperty
->nWID
>= OWN_ATTR_APPLET_DOCBASE
) && (pProperty
->nWID
<= OWN_ATTR_APPLET_ISSCRIPT
) )
610 if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
612 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
615 // allow exceptions to pass through
616 xSet
->setPropertyValue( rName
, rValue
);
623 return SvxOle2Shape::setPropertyValueImpl( rName
, pProperty
, rValue
);
627 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
, std::exception
)
629 if( (pProperty
->nWID
>= OWN_ATTR_APPLET_DOCBASE
) && (pProperty
->nWID
<= OWN_ATTR_APPLET_ISSCRIPT
) )
631 if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
633 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
636 rValue
= xSet
->getPropertyValue( rName
);
643 return SvxOle2Shape::getPropertyValueImpl( rName
, pProperty
, rValue
);
649 SvxPluginShape::SvxPluginShape( SdrObject
* pObject
) throw()
650 : SvxOle2Shape( pObject
, getSvxMapProvider().GetMap(SVXMAP_PLUGIN
), getSvxMapProvider().GetPropertySet(SVXMAP_PLUGIN
, SdrObject::GetGlobalDrawObjectItemPool()) )
652 SetShapeType( OUString( "com.sun.star.drawing.PluginShape" ) );
655 SvxPluginShape::~SvxPluginShape() throw()
659 void SvxPluginShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
)
661 SvxShape::Create( pNewObj
, pNewPage
);
662 const SvGlobalName
aPluginClassId( SO3_PLUGIN_CLASSID
);
663 createObject(aPluginClassId
);
664 SetShapeType( OUString( "com.sun.star.drawing.PluginShape" ) );
667 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
, std::exception
)
669 SvxShape::setPropertyValue( aPropertyName
, rValue
);
670 resetModifiedState();
673 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
, std::exception
)
675 SvxShape::setPropertyValues( aPropertyNames
, rValues
);
676 resetModifiedState();
679 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
, std::exception
)
681 if( (pProperty
->nWID
>= OWN_ATTR_PLUGIN_MIMETYPE
) && (pProperty
->nWID
<= OWN_ATTR_PLUGIN_COMMANDS
) )
683 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
685 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
688 // allow exceptions to pass through
689 xSet
->setPropertyValue( rName
, rValue
);
696 return SvxOle2Shape::setPropertyValueImpl( rName
, pProperty
, rValue
);
700 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
, std::exception
)
702 if( (pProperty
->nWID
>= OWN_ATTR_PLUGIN_MIMETYPE
) && (pProperty
->nWID
<= OWN_ATTR_PLUGIN_COMMANDS
) )
704 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
706 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
709 rValue
<<= xSet
->getPropertyValue( rName
);
716 return SvxOle2Shape::getPropertyValueImpl( rName
, pProperty
, rValue
);
722 SvxFrameShape::SvxFrameShape( SdrObject
* pObject
) throw()
723 : SvxOle2Shape( pObject
, getSvxMapProvider().GetMap(SVXMAP_FRAME
), getSvxMapProvider().GetPropertySet(SVXMAP_FRAME
, SdrObject::GetGlobalDrawObjectItemPool()) )
725 SetShapeType( OUString( "com.sun.star.drawing.FrameShape" ) );
728 SvxFrameShape::~SvxFrameShape() throw()
732 void SvxFrameShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
) throw (uno::RuntimeException
)
734 SvxShape::Create( pNewObj
, pNewPage
);
735 const SvGlobalName
aIFrameClassId( SO3_IFRAME_CLASSID
);
736 createObject(aIFrameClassId
);
737 SetShapeType( OUString( "com.sun.star.drawing.FrameShape" ) );
740 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
, std::exception
)
742 SvxShape::setPropertyValue( aPropertyName
, rValue
);
743 resetModifiedState();
746 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
, std::exception
)
748 SvxShape::setPropertyValues( aPropertyNames
, rValues
);
749 resetModifiedState();
752 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
, std::exception
)
754 if( (pProperty
->nWID
>= OWN_ATTR_FRAME_URL
) && (pProperty
->nWID
<= OWN_ATTR_FRAME_MARGIN_HEIGHT
) )
756 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
758 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
761 // allow exceptions to pass through
762 xSet
->setPropertyValue( rName
, rValue
);
769 return SvxOle2Shape::setPropertyValueImpl( rName
, pProperty
, rValue
);
773 bool SvxFrameShape::getPropertyValueImpl(const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
,
774 css::uno::Any
& rValue
)
775 throw (css::beans::UnknownPropertyException
,
776 css::lang::WrappedTargetException
,
777 css::uno::RuntimeException
,
780 if( (pProperty
->nWID
>= OWN_ATTR_FRAME_URL
) && (pProperty
->nWID
<= OWN_ATTR_FRAME_MARGIN_HEIGHT
) )
782 if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef() ) )
784 uno::Reference
< beans::XPropertySet
> xSet( static_cast<SdrOle2Obj
*>(mpObj
.get())->GetObjRef()->getComponent(), uno::UNO_QUERY
);
787 rValue
<<= xSet
->getPropertyValue( rName
);
794 return SvxOle2Shape::getPropertyValueImpl( rName
, pProperty
, rValue
);
797 SvxMediaShape::SvxMediaShape( SdrObject
* pObj
, OUString
const & referer
) throw()
798 : SvxShape( pObj
, getSvxMapProvider().GetMap(SVXMAP_MEDIA
), getSvxMapProvider().GetPropertySet(SVXMAP_MEDIA
, SdrObject::GetGlobalDrawObjectItemPool()) ),
801 SetShapeType( OUString( "com.sun.star.drawing.MediaShape" ) );
805 SvxMediaShape::~SvxMediaShape() throw()
811 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
)
813 if( ((pProperty
->nWID
>= OWN_ATTR_MEDIA_URL
) && (pProperty
->nWID
<= OWN_ATTR_MEDIA_ZOOM
))
814 || (pProperty
->nWID
== OWN_ATTR_MEDIA_STREAM
)
815 || (pProperty
->nWID
== OWN_ATTR_MEDIA_MIMETYPE
) )
817 SdrMediaObj
* pMedia
= static_cast< SdrMediaObj
* >( mpObj
.get() );
818 ::avmedia::MediaItem aItem
;
821 switch( pProperty
->nWID
)
823 case OWN_ATTR_MEDIA_URL
:
826 if( rValue
>>= aURL
)
829 aItem
.setURL( aURL
, "", referer_
);
834 case( OWN_ATTR_MEDIA_LOOP
):
838 if( rValue
>>= bLoop
)
841 aItem
.setLoop( bLoop
);
846 case( OWN_ATTR_MEDIA_MUTE
):
850 if( rValue
>>= bMute
)
853 aItem
.setMute( bMute
);
858 case( OWN_ATTR_MEDIA_VOLUMEDB
):
860 sal_Int16 nVolumeDB
= sal_Int16();
862 if( rValue
>>= nVolumeDB
)
865 aItem
.setVolumeDB( nVolumeDB
);
870 case( OWN_ATTR_MEDIA_ZOOM
):
872 ::com::sun::star::media::ZoomLevel eLevel
;
874 if( rValue
>>= eLevel
)
877 aItem
.setZoom( eLevel
);
882 case OWN_ATTR_MEDIA_MIMETYPE
:
885 if( rValue
>>= sMimeType
)
888 aItem
.setMimeType( sMimeType
);
893 case OWN_ATTR_MEDIA_STREAM
:
896 uno::Reference
<io::XInputStream
> xStream
;
897 if (rValue
>>= xStream
)
899 pMedia
->SetInputStream(xStream
);
902 catch (const css::ucb::ContentCreationException
& e
)
904 throw css::lang::WrappedTargetException(
905 "ContentCreationException Setting InputStream!",
906 static_cast<OWeakObject
*>(this),
909 catch (const css::ucb::CommandFailedException
& e
)
911 throw css::lang::WrappedTargetException(
912 "CommandFailedException Setting InputStream!",
913 static_cast<OWeakObject
*>(this),
919 OSL_FAIL("SvxMediaShape::setPropertyValueImpl(), unknown argument!");
924 pMedia
->setMediaProperties( aItem
);
930 return SvxShape::setPropertyValueImpl( rName
, pProperty
, rValue
);
933 throw IllegalArgumentException();
938 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
, std::exception
)
940 if ( ((pProperty
->nWID
>= OWN_ATTR_MEDIA_URL
) &&
941 (pProperty
->nWID
<= OWN_ATTR_MEDIA_ZOOM
))
942 || (pProperty
->nWID
== OWN_ATTR_MEDIA_STREAM
)
943 || (pProperty
->nWID
== OWN_ATTR_MEDIA_TEMPFILEURL
)
944 || (pProperty
->nWID
== OWN_ATTR_MEDIA_MIMETYPE
)
945 || (pProperty
->nWID
== OWN_ATTR_FALLBACK_GRAPHIC
))
947 SdrMediaObj
* pMedia
= static_cast< SdrMediaObj
* >( mpObj
.get() );
948 const ::avmedia::MediaItem
aItem( pMedia
->getMediaProperties() );
950 switch( pProperty
->nWID
)
952 case OWN_ATTR_MEDIA_URL
:
953 rValue
<<= aItem
.getURL();
956 case( OWN_ATTR_MEDIA_LOOP
):
957 rValue
<<= aItem
.isLoop();
960 case( OWN_ATTR_MEDIA_MUTE
):
961 rValue
<<= aItem
.isMute();
964 case( OWN_ATTR_MEDIA_VOLUMEDB
):
965 rValue
<<= (sal_Int16
) aItem
.getVolumeDB();
968 case( OWN_ATTR_MEDIA_ZOOM
):
969 rValue
<<= aItem
.getZoom();
972 case OWN_ATTR_MEDIA_STREAM
:
975 rValue
<<= pMedia
->GetInputStream();
977 catch (const css::ucb::ContentCreationException
& e
)
979 throw css::lang::WrappedTargetException(
980 "ContentCreationException Getting InputStream!",
981 static_cast < OWeakObject
* > ( this ),
984 catch (const css::ucb::CommandFailedException
& e
)
986 throw css::lang::WrappedTargetException(
987 "CommandFailedException Getting InputStream!",
988 static_cast < OWeakObject
* > ( this ),
994 case OWN_ATTR_MEDIA_TEMPFILEURL
:
995 rValue
<<= aItem
.getTempURL();
998 case OWN_ATTR_MEDIA_MIMETYPE
:
999 rValue
<<= aItem
.getMimeType();
1002 case OWN_ATTR_FALLBACK_GRAPHIC
:
1003 rValue
<<= pMedia
->getSnapshot();
1007 OSL_FAIL("SvxMediaShape::getPropertyValueImpl(), unknown property!");
1013 return SvxShape::getPropertyValueImpl( rName
, pProperty
, rValue
);
1017 SvxDummyShapeContainer::SvxDummyShapeContainer(uno::Reference
< drawing::XShapes
> xObject
):
1018 m_xDummyObject(xObject
)
1022 SvxDummyShapeContainer::~SvxDummyShapeContainer() throw()
1026 void SvxOpenGLObject::setRenderer(IOpenGLRenderer
* pRenderer
)
1028 static_cast<SdrOpenGLObj
*>(GetSdrObject())->setRenderer(pRenderer
);
1031 IOpenGLRenderer
* SvxOpenGLObject::getRenderer()
1033 return static_cast<SdrOpenGLObj
*>(GetSdrObject())->getRenderer();
1036 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */