/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "shapeimpl.hxx" #include #include "svx/unoapi.hxx" #include "svx/svdpagv.hxx" #include "svx/svdview.hxx" #include "svx/svdglob.hxx" #include "svx/svdstr.hrc" #include /////////////////////////////////////////////////////////////////////// using namespace ::osl; using namespace ::rtl; using namespace ::cppu; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::container; using namespace ::com::sun::star::beans; /////////////////////////////////////////////////////////////////////// SvxOle2Shape::SvxOle2Shape( SdrObject* pObject ) throw() : SvxShapeText( pObject, getSvxMapProvider().GetMap(SVXMAP_OLE2), getSvxMapProvider().GetPropertySet(SVXMAP_OLE2,SdrObject::GetGlobalDrawObjectItemPool()) ) { } SvxOle2Shape::SvxOle2Shape( SdrObject* pObject, const SfxItemPropertyMapEntry* pPropertyMap, const SvxItemPropertySet* pPropertySet ) throw () : SvxShapeText( pObject, pPropertyMap, pPropertySet ) { } SvxOle2Shape::~SvxOle2Shape() throw() { } ::com::sun::star::uno::Any SAL_CALL SvxOle2Shape::queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return SvxShapeText::queryAggregation( rType ); } //XPropertySet 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) { switch( pProperty->nWID ) { case OWN_ATTR_OLE_VISAREA: { // TODO/LATER: seems to make no sence for iconified object awt::Rectangle aVisArea; if( (rValue >>= aVisArea) && mpObj->ISA(SdrOle2Obj)) { Size aTmp( aVisArea.X + aVisArea.Width, aVisArea.Y + aVisArea.Height ); uno::Reference < embed::XEmbeddedObject > xObj = ((SdrOle2Obj*)mpObj.get())->GetObjRef(); if( xObj.is() ) { try { MapUnit aMapUnit( MAP_100TH_MM ); // the API handles with MAP_100TH_MM map mode MapUnit aObjUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( embed::Aspects::MSOLE_CONTENT ) ); aTmp = OutputDevice::LogicToLogic( aTmp, aMapUnit, aObjUnit ); xObj->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT, awt::Size( aTmp.Width(), aTmp.Height() ) ); } catch( uno::Exception& ) { OSL_FAIL( "Couldn't set the visual area for the object!\n" ); } } return true; } break; } case OWN_ATTR_OLE_ASPECT: { sal_Int64 nAspect = 0; if( rValue >>= nAspect ) { static_cast(mpObj.get())->SetAspect( nAspect ); return true; } break; } case OWN_ATTR_CLSID: { OUString aCLSID; if( rValue >>= aCLSID ) { // init a ole object with a global name SvGlobalName aClassName; if( aClassName.MakeId( aCLSID ) ) { if( createObject( aClassName ) ) return true; } } break; } case OWN_ATTR_THUMBNAIL: { OUString aURL; if( rValue >>= aURL ) { GraphicObject aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL ) ); static_cast(mpObj.get())->SetGraphic( &aGrafObj.GetGraphic() ); return true; } break; } case OWN_ATTR_VALUE_GRAPHIC: { uno::Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY ); if( xGraphic.is() ) { SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); if( pOle ) { GraphicObject aGrafObj( xGraphic ); const Graphic aGraphic( aGrafObj.GetGraphic() ); pOle->SetGraphicToObj( aGraphic, OUString() ); } return true; } break; } case OWN_ATTR_PERSISTNAME: { OUString aPersistName; if( rValue >>= aPersistName ) { static_cast(mpObj.get())->SetPersistName( aPersistName ); return true; } break; } case OWN_ATTR_OLE_LINKURL: { OUString aLinkURL; if( rValue >>= aLinkURL ) { createLink( aLinkURL ); return true; } break; } default: return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue ); } throw IllegalArgumentException(); } 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) { switch( pProperty->nWID ) { case OWN_ATTR_CLSID: { OUString aCLSID; SvGlobalName aClassName = GetClassName_Impl(aCLSID); rValue <<= aCLSID; break; } case OWN_ATTR_INTERNAL_OLE: { OUString sCLSID; rValue <<= SotExchange::IsInternal( GetClassName_Impl(sCLSID) ); break; } case OWN_ATTR_METAFILE: { SdrOle2Obj* pObj = dynamic_cast(mpObj.get()); if( pObj ) { const Graphic* pGraphic = pObj->GetGraphic(); if( pGraphic ) { bool bIsWMF = false; if ( pGraphic->IsLink() ) { GfxLink aLnk = pGraphic->GetLink(); if ( aLnk.GetType() == GFX_LINK_TYPE_NATIVE_WMF ) { bIsWMF = true; uno::Sequence aSeq((sal_Int8*)aLnk.GetData(), (sal_Int32) aLnk.GetDataSize()); rValue <<= aSeq; } } if ( !bIsWMF ) { // #i119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically GDIMetaFile aMtf(pObj->GetGraphic()->GetGDIMetaFile()); SvMemoryStream aDestStrm( 65535, 65535 ); ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, false ); const uno::Sequence aSeq( static_cast< const sal_Int8* >(aDestStrm.GetData()), aDestStrm.GetEndOfData()); rValue <<= aSeq; } } } else { rValue = GetBitmap( sal_True ); } break; } case OWN_ATTR_OLE_VISAREA: { awt::Rectangle aVisArea; if( mpObj->ISA(SdrOle2Obj)) { MapMode aMapMode( MAP_100TH_MM ); // the API uses this map mode Size aTmp = ((SdrOle2Obj*)mpObj.get())->GetOrigObjSize( &aMapMode ); // get the size in the requested map mode aVisArea = awt::Rectangle( 0, 0, aTmp.Width(), aTmp.Height() ); } rValue <<= aVisArea; break; } case OWN_ATTR_OLESIZE: { Size aTmp( static_cast(mpObj.get())->GetOrigObjSize() ); rValue <<= awt::Size( aTmp.Width(), aTmp.Height() ); break; } case OWN_ATTR_OLE_ASPECT: { rValue <<= static_cast(mpObj.get())->GetAspect(); break; } case OWN_ATTR_OLEMODEL: case OWN_ATTR_OLE_EMBEDDED_OBJECT: case OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT: { SdrOle2Obj* pObj = dynamic_cast( mpObj.get() ); if( pObj ) { uno::Reference < embed::XEmbeddedObject > xObj( pObj->GetObjRef() ); if ( xObj.is() && ( pProperty->nWID == OWN_ATTR_OLE_EMBEDDED_OBJECT || pProperty->nWID == OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT || svt::EmbeddedObjectRef::TryRunningState( xObj ) ) ) { // Discussed with CL fue to the before GetPaintingPageView // usage. Removed it, former fallback is used now if ( pProperty->nWID == OWN_ATTR_OLEMODEL || pProperty->nWID == OWN_ATTR_OLE_EMBEDDED_OBJECT ) { #if OSL_DEBUG_LEVEL > 0 const sal_Bool bSuccess(pObj->AddOwnLightClient()); OSL_ENSURE( bSuccess, "An object without client is provided!" ); #else pObj->AddOwnLightClient(); #endif } if ( pProperty->nWID == OWN_ATTR_OLEMODEL ) rValue <<= pObj->GetObjRef()->getComponent(); else rValue <<= xObj; } } break; } case OWN_ATTR_VALUE_GRAPHIC: { uno::Reference< graphic::XGraphic > xGraphic; const Graphic* pGraphic = static_cast( mpObj.get() )->GetGraphic(); if( pGraphic ) xGraphic = pGraphic->GetXGraphic(); rValue <<= xGraphic; break; } case OWN_ATTR_THUMBNAIL: { OUString aURL; SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); if( pOle ) { const Graphic* pGraphic = pOle->GetGraphic(); // if there isn't already a preview graphic set, check if we need to generate // one if model says so if( pGraphic == NULL && !pOle->IsEmptyPresObj() && mpModel->IsSaveOLEPreview() ) pGraphic = pOle->GetGraphic(); if( pGraphic ) { GraphicObject aObj( *pGraphic ); aURL = OUString( UNO_NAME_GRAPHOBJ_URLPREFIX); aURL += OStringToOUString(aObj.GetUniqueID(), RTL_TEXTENCODING_ASCII_US); } } rValue <<= aURL; break; } case OWN_ATTR_PERSISTNAME: { OUString aPersistName; SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); if( pOle ) { aPersistName = pOle->GetPersistName(); if( !aPersistName.isEmpty() ) { ::comphelper::IEmbeddedHelper *pPersist = mpObj->GetModel()->GetPersist(); if( (NULL == pPersist) || !pPersist->getEmbeddedObjectContainer().HasEmbeddedObject( pOle->GetPersistName() ) ) aPersistName = OUString(); } } rValue <<= aPersistName; break; } case OWN_ATTR_OLE_LINKURL: { OUString aLinkURL; SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); if( pOle ) { uno::Reference< embed::XLinkageSupport > xLink( pOle->GetObjRef(), uno::UNO_QUERY ); if ( xLink.is() && xLink->isLink() ) aLinkURL = xLink->getLinkURL(); } rValue <<= aLinkURL; break; } default: return SvxShapeText::getPropertyValueImpl( rName, pProperty, rValue ); } return true; } sal_Bool SvxOle2Shape::createObject( const SvGlobalName &aClassName ) { DBG_TESTSOLARMUTEX(); SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); if ( !pOle2Obj || !pOle2Obj->IsEmpty() ) return sal_False; // create storage and inplace object ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist(); OUString aPersistName; OUString aTmpStr; if( SvxShape::getPropertyValue( UNO_NAME_OLE2_PERSISTNAME ) >>= aTmpStr ) aPersistName = aTmpStr; //TODO/LATER: how to cope with creation failure?! uno::Reference < embed::XEmbeddedObject > xObj( pPersist->getEmbeddedObjectContainer().CreateEmbeddedObject( aClassName.GetByteSequence(), aPersistName ) ); if( xObj.is() ) { Rectangle aRect = pOle2Obj->GetLogicRect(); if ( aRect.GetWidth() == 100 && aRect.GetHeight() == 100 ) { // TODO/LATER: is it possible that this method is used to create an iconified object? // default size try { awt::Size aSz = xObj->getVisualAreaSize( pOle2Obj->GetAspect() ); aRect.SetSize( Size( aSz.Width, aSz.Height ) ); } catch( embed::NoVisualAreaSizeException& ) {} pOle2Obj->SetLogicRect( aRect ); } else { awt::Size aSz; Size aSize = pOle2Obj->GetLogicRect().GetSize(); aSz.Width = aSize.Width(); aSz.Height = aSize.Height(); xObj->setVisualAreaSize( pOle2Obj->GetAspect(), aSz ); } // connect the object after the visual area is set SvxShape::setPropertyValue( UNO_NAME_OLE2_PERSISTNAME, Any( aTmpStr = aPersistName ) ); // the object is inserted during setting of PersistName property usually if( pOle2Obj->IsEmpty() ) pOle2Obj->SetObjRef( xObj ); } return xObj.is(); } sal_Bool SvxOle2Shape::createLink( const OUString& aLinkURL ) { DBG_TESTSOLARMUTEX(); SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); if ( !pOle2Obj || !pOle2Obj->IsEmpty() ) return sal_False; OUString aPersistName; ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist(); uno::Sequence< beans::PropertyValue > aMediaDescr( 1 ); aMediaDescr[0].Name = OUString("URL"); aMediaDescr[0].Value <<= aLinkURL; uno::Reference< task::XInteractionHandler > xInteraction = pPersist->getInteractionHandler(); if ( xInteraction.is() ) { aMediaDescr.realloc( 2 ); aMediaDescr[1].Name = OUString( "InteractionHandler" ); aMediaDescr[1].Value <<= xInteraction; } //TODO/LATER: how to cope with creation failure?! uno::Reference< embed::XEmbeddedObject > xObj = pPersist->getEmbeddedObjectContainer().InsertEmbeddedLink( aMediaDescr , aPersistName ); if( xObj.is() ) { Rectangle aRect = pOle2Obj->GetLogicRect(); if ( aRect.GetWidth() == 100 && aRect.GetHeight() == 100 ) { // default size try { awt::Size aSz = xObj->getVisualAreaSize( pOle2Obj->GetAspect() ); aRect.SetSize( Size( aSz.Width, aSz.Height ) ); } catch( embed::NoVisualAreaSizeException& ) {} pOle2Obj->SetLogicRect( aRect ); } else { awt::Size aSz; Size aSize = pOle2Obj->GetLogicRect().GetSize(); aSz.Width = aSize.Width(); aSz.Height = aSize.Height(); xObj->setVisualAreaSize( pOle2Obj->GetAspect(), aSz ); } // connect the object after the visual area is set SvxShape::setPropertyValue( UNO_NAME_OLE2_PERSISTNAME, uno::makeAny( aPersistName ) ); // the object is inserted during setting of PersistName property usually if ( pOle2Obj->IsEmpty() ) pOle2Obj->SetObjRef( xObj ); } return xObj.is(); } void SvxOle2Shape::resetModifiedState() { ::comphelper::IEmbeddedHelper* pPersist = mpModel ? mpModel->GetPersist() : 0; if( pPersist && !pPersist->isEnableSetModified() ) { SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); if( pOle && !pOle->IsEmpty() ) { uno::Reference < util::XModifiable > xMod( pOle->GetObjRef(), uno::UNO_QUERY ); if( xMod.is() ) // TODO/MBA: what's this?! xMod->setModified( sal_False ); } } } const SvGlobalName SvxOle2Shape::GetClassName_Impl(OUString& rHexCLSID) { DBG_TESTSOLARMUTEX(); SvGlobalName aClassName; SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); if( pOle2Obj ) { rHexCLSID = OUString(); if( pOle2Obj->IsEmpty() ) { ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist(); if( pPersist ) { uno::Reference < embed::XEmbeddedObject > xObj = pPersist->getEmbeddedObjectContainer().GetEmbeddedObject( pOle2Obj->GetPersistName() ); if ( xObj.is() ) { aClassName = SvGlobalName( xObj->getClassID() ); rHexCLSID = aClassName.GetHexName(); } } } if (rHexCLSID.isEmpty()) { uno::Reference < embed::XEmbeddedObject > xObj( pOle2Obj->GetObjRef() ); if ( xObj.is() ) { aClassName = SvGlobalName( xObj->getClassID() ); rHexCLSID = aClassName.GetHexName(); } } } return aClassName; } /////////////////////////////////////////////////////////////////////// SvxAppletShape::SvxAppletShape( SdrObject* pObject ) throw() : SvxOle2Shape( pObject, getSvxMapProvider().GetMap(SVXMAP_APPLET), getSvxMapProvider().GetPropertySet(SVXMAP_APPLET, SdrObject::GetGlobalDrawObjectItemPool()) ) { SetShapeType( OUString( "com.sun.star.drawing.AppletShape" ) ); } SvxAppletShape::~SvxAppletShape() throw() { } void SvxAppletShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) { SvxShape::Create( pNewObj, pNewPage ); const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID ); createObject(aAppletClassId); SetShapeType( OUString( "com.sun.star.drawing.AppletShape" ) ); } 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) { SvxShape::setPropertyValue( aPropertyName, rValue ); resetModifiedState(); } 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) { SvxShape::setPropertyValues( aPropertyNames, rValues ); resetModifiedState(); } 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) { if( (pProperty->nWID >= OWN_ATTR_APPLET_DOCBASE) && (pProperty->nWID <= OWN_ATTR_APPLET_ISSCRIPT) ) { if ( svt::EmbeddedObjectRef::TryRunningState( static_cast(mpObj.get())->GetObjRef() ) ) { uno::Reference < beans::XPropertySet > xSet( static_cast(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); if( xSet.is() ) { // allow exceptions to pass through xSet->setPropertyValue( rName, rValue ); } } return true; } else { return SvxOle2Shape::setPropertyValueImpl( rName, pProperty, rValue ); } } 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) { if( (pProperty->nWID >= OWN_ATTR_APPLET_DOCBASE) && (pProperty->nWID <= OWN_ATTR_APPLET_ISSCRIPT) ) { if ( svt::EmbeddedObjectRef::TryRunningState( static_cast(mpObj.get())->GetObjRef() ) ) { uno::Reference < beans::XPropertySet > xSet( static_cast(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); if( xSet.is() ) { rValue = xSet->getPropertyValue( rName ); } } return true; } else { return SvxOle2Shape::getPropertyValueImpl( rName, pProperty, rValue ); } } /////////////////////////////////////////////////////////////////////// SvxPluginShape::SvxPluginShape( SdrObject* pObject ) throw() : SvxOle2Shape( pObject, getSvxMapProvider().GetMap(SVXMAP_PLUGIN), getSvxMapProvider().GetPropertySet(SVXMAP_PLUGIN, SdrObject::GetGlobalDrawObjectItemPool()) ) { SetShapeType( OUString( "com.sun.star.drawing.PluginShape" ) ); } SvxPluginShape::~SvxPluginShape() throw() { } void SvxPluginShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) { SvxShape::Create( pNewObj, pNewPage ); const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID ); createObject(aPluginClassId); SetShapeType( OUString( "com.sun.star.drawing.PluginShape" ) ); } 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) { SvxShape::setPropertyValue( aPropertyName, rValue ); resetModifiedState(); } 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) { SvxShape::setPropertyValues( aPropertyNames, rValues ); resetModifiedState(); } 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) { if( (pProperty->nWID >= OWN_ATTR_PLUGIN_MIMETYPE) && (pProperty->nWID <= OWN_ATTR_PLUGIN_COMMANDS) ) { if( svt::EmbeddedObjectRef::TryRunningState( static_cast(mpObj.get())->GetObjRef() ) ) { uno::Reference < beans::XPropertySet > xSet( static_cast(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); if( xSet.is() ) { // allow exceptions to pass through xSet->setPropertyValue( rName, rValue ); } } return true; } else { return SvxOle2Shape::setPropertyValueImpl( rName, pProperty, rValue ); } } 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) { if( (pProperty->nWID >= OWN_ATTR_PLUGIN_MIMETYPE) && (pProperty->nWID <= OWN_ATTR_PLUGIN_COMMANDS) ) { if( svt::EmbeddedObjectRef::TryRunningState( static_cast(mpObj.get())->GetObjRef() ) ) { uno::Reference < beans::XPropertySet > xSet( static_cast(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); if( xSet.is() ) { rValue <<= xSet->getPropertyValue( rName ); } } return true; } else { return SvxOle2Shape::getPropertyValueImpl( rName, pProperty, rValue ); } } /////////////////////////////////////////////////////////////////////// SvxFrameShape::SvxFrameShape( SdrObject* pObject ) throw() : SvxOle2Shape( pObject, getSvxMapProvider().GetMap(SVXMAP_FRAME), getSvxMapProvider().GetPropertySet(SVXMAP_FRAME, SdrObject::GetGlobalDrawObjectItemPool()) ) { SetShapeType( OUString( "com.sun.star.drawing.FrameShape" ) ); } SvxFrameShape::~SvxFrameShape() throw() { } void SvxFrameShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) throw () { SvxShape::Create( pNewObj, pNewPage ); const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID ); createObject(aIFrameClassId); SetShapeType( OUString( "com.sun.star.drawing.FrameShape" ) ); } 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) { SvxShape::setPropertyValue( aPropertyName, rValue ); resetModifiedState(); } 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) { SvxShape::setPropertyValues( aPropertyNames, rValues ); resetModifiedState(); } 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) { if( (pProperty->nWID >= OWN_ATTR_FRAME_URL) && (pProperty->nWID <= OWN_ATTR_FRAME_MARGIN_HEIGHT) ) { if( svt::EmbeddedObjectRef::TryRunningState( static_cast(mpObj.get())->GetObjRef() ) ) { uno::Reference < beans::XPropertySet > xSet( static_cast(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); if( xSet.is() ) { // allow exceptions to pass through xSet->setPropertyValue( rName, rValue ); } } return true; } else { return SvxOle2Shape::setPropertyValueImpl( rName, pProperty, rValue ); } } 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) { if( (pProperty->nWID >= OWN_ATTR_FRAME_URL) && (pProperty->nWID <= OWN_ATTR_FRAME_MARGIN_HEIGHT) ) { if( svt::EmbeddedObjectRef::TryRunningState( static_cast(mpObj.get())->GetObjRef() ) ) { uno::Reference < beans::XPropertySet > xSet( static_cast(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); if( xSet.is() ) { rValue <<= xSet->getPropertyValue( rName ); } } return true; } else { return SvxOle2Shape::getPropertyValueImpl( rName, pProperty, rValue ); } } /*********************************************************************** * * ***********************************************************************/ SvxMediaShape::SvxMediaShape( SdrObject* pObj ) throw() : SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_MEDIA), getSvxMapProvider().GetPropertySet(SVXMAP_MEDIA, SdrObject::GetGlobalDrawObjectItemPool()) ) { SetShapeType( OUString( "com.sun.star.drawing.MediaShape" ) ); } //---------------------------------------------------------------------- SvxMediaShape::~SvxMediaShape() throw() { } //---------------------------------------------------------------------- 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) { if( (pProperty->nWID >= OWN_ATTR_MEDIA_URL) && (pProperty->nWID <= OWN_ATTR_MEDIA_ZOOM) ) { SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( mpObj.get() ); ::avmedia::MediaItem aItem; bool bOk = false; switch( pProperty->nWID ) { case OWN_ATTR_MEDIA_URL: { OUString aURL; if( rValue >>= aURL ) { bOk = true; aItem.setURL( aURL, 0 ); } } break; case( OWN_ATTR_MEDIA_LOOP ): { sal_Bool bLoop = sal_Bool(); if( rValue >>= bLoop ) { bOk = true; aItem.setLoop( bLoop ); } } break; case( OWN_ATTR_MEDIA_MUTE ): { sal_Bool bMute = sal_Bool(); if( rValue >>= bMute ) { bOk = true; aItem.setMute( bMute ); } } break; case( OWN_ATTR_MEDIA_VOLUMEDB ): { sal_Int16 nVolumeDB = sal_Int16(); if( rValue >>= nVolumeDB ) { bOk = true; aItem.setVolumeDB( nVolumeDB ); } } break; case( OWN_ATTR_MEDIA_ZOOM ): { ::com::sun::star::media::ZoomLevel eLevel; if( rValue >>= eLevel ) { bOk = true; aItem.setZoom( eLevel ); } } break; default: OSL_FAIL("SvxMediaShape::setPropertyValueImpl(), unknown argument!"); } if( bOk ) { pMedia->setMediaProperties( aItem ); return true; } } else { return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); } throw IllegalArgumentException(); } //---------------------------------------------------------------------- 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) { if ( ((pProperty->nWID >= OWN_ATTR_MEDIA_URL) && (pProperty->nWID <= OWN_ATTR_MEDIA_ZOOM)) || (pProperty->nWID == OWN_ATTR_MEDIA_STREAM) || (pProperty->nWID == OWN_ATTR_MEDIA_TEMPFILEURL)) { SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( mpObj.get() ); const ::avmedia::MediaItem aItem( pMedia->getMediaProperties() ); switch( pProperty->nWID ) { case OWN_ATTR_MEDIA_URL: rValue <<= aItem.getURL(); break; case( OWN_ATTR_MEDIA_LOOP ): rValue <<= (sal_Bool) aItem.isLoop(); break; case( OWN_ATTR_MEDIA_MUTE ): rValue <<= (sal_Bool) aItem.isMute(); break; case( OWN_ATTR_MEDIA_VOLUMEDB ): rValue <<= (sal_Int16) aItem.getVolumeDB(); break; case( OWN_ATTR_MEDIA_ZOOM ): rValue <<= aItem.getZoom(); break; case OWN_ATTR_MEDIA_STREAM: rValue <<= pMedia->GetInputStream(); break; case OWN_ATTR_MEDIA_TEMPFILEURL: rValue <<= aItem.getTempURL(); break; default: OSL_FAIL("SvxMediaShape::getPropertyValueImpl(), unknown property!"); } return true; } else { return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */