1*f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f6e50924SAndrew Rist * distributed with this work for additional information 6*f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9*f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10*f6e50924SAndrew Rist * 11*f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*f6e50924SAndrew Rist * 13*f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f6e50924SAndrew Rist * software distributed under the License is distributed on an 15*f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17*f6e50924SAndrew Rist * specific language governing permissions and limitations 18*f6e50924SAndrew Rist * under the License. 19*f6e50924SAndrew Rist * 20*f6e50924SAndrew Rist *************************************************************/ 21*f6e50924SAndrew Rist 22*f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir #include <com/sun/star/util/XModifiable.hpp> 27cdf0e10cSrcweir #include <com/sun/star/embed/XLinkageSupport.hpp> 28cdf0e10cSrcweir #include <com/sun/star/embed/NoVisualAreaSizeException.hpp> 29cdf0e10cSrcweir #include <com/sun/star/task/XInteractionHandler.hpp> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #define _SVX_USE_UNOGLOBALS_ 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <vcl/virdev.hxx> 34cdf0e10cSrcweir #include <svx/svdoole2.hxx> 35cdf0e10cSrcweir #include <svx/svdomedia.hxx> 36cdf0e10cSrcweir #include <svx/svdpool.hxx> 37cdf0e10cSrcweir #ifndef SVX_LIGHT 38cdf0e10cSrcweir #ifndef _SOT_CLSIDS_HXX 39cdf0e10cSrcweir #include <sot/clsids.hxx> 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir #include <sfx2/frmdescr.hxx> 42cdf0e10cSrcweir #endif 43cdf0e10cSrcweir #include <vcl/svapp.hxx> 44cdf0e10cSrcweir #include <vos/mutex.hxx> 45cdf0e10cSrcweir 46cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 47cdf0e10cSrcweir #include <sfx2/objsh.hxx> 48cdf0e10cSrcweir #include <sfx2/docfile.hxx> 49cdf0e10cSrcweir 50cdf0e10cSrcweir #include <sot/storage.hxx> 51cdf0e10cSrcweir #include <sot/exchange.hxx> 52cdf0e10cSrcweir #include <svtools/FilterConfigItem.hxx> 53cdf0e10cSrcweir 54cdf0e10cSrcweir #include <svx/svdmodel.hxx> 55cdf0e10cSrcweir #include "shapeimpl.hxx" 56cdf0e10cSrcweir 57cdf0e10cSrcweir #include <svx/unoshprp.hxx> 58cdf0e10cSrcweir 59cdf0e10cSrcweir #include "svx/unoapi.hxx" 60cdf0e10cSrcweir #include "svx/svdpagv.hxx" 61cdf0e10cSrcweir #include "svx/svdview.hxx" 62cdf0e10cSrcweir #include "svx/svdglob.hxx" 63cdf0e10cSrcweir #include "svx/svdstr.hrc" 64cdf0e10cSrcweir 65cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 66cdf0e10cSrcweir 67cdf0e10cSrcweir extern sal_Bool ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream, FilterConfigItem* pFilterConfigItem = NULL, sal_Bool bPlaceable = sal_True ); 68cdf0e10cSrcweir 69cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 70cdf0e10cSrcweir 71cdf0e10cSrcweir using namespace ::osl; 72cdf0e10cSrcweir using namespace ::vos; 73cdf0e10cSrcweir using namespace ::rtl; 74cdf0e10cSrcweir using namespace ::cppu; 75cdf0e10cSrcweir using namespace ::com::sun::star; 76cdf0e10cSrcweir using namespace ::com::sun::star::uno; 77cdf0e10cSrcweir using namespace ::com::sun::star::lang; 78cdf0e10cSrcweir using namespace ::com::sun::star::container; 79cdf0e10cSrcweir using namespace ::com::sun::star::beans; 80cdf0e10cSrcweir 81cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 82cdf0e10cSrcweir SvxOle2Shape::SvxOle2Shape( SdrObject* pObject ) throw() 83a5258243SPedro Giffuni : SvxShapeText( pObject, aSvxMapProvider.GetMap(SVXMAP_OLE2), aSvxMapProvider.GetPropertySet(SVXMAP_OLE2, SdrObject::GetGlobalDrawObjectItemPool()) ) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir SvxOle2Shape::SvxOle2Shape( SdrObject* pObject, const SfxItemPropertyMapEntry* pPropertyMap, const SvxItemPropertySet* pPropertySet ) throw () 88a5258243SPedro Giffuni : SvxShapeText( pObject, pPropertyMap, pPropertySet ) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir } 91cdf0e10cSrcweir 92cdf0e10cSrcweir SvxOle2Shape::~SvxOle2Shape() throw() 93cdf0e10cSrcweir { 94cdf0e10cSrcweir } 95cdf0e10cSrcweir 96cdf0e10cSrcweir ::com::sun::star::uno::Any SAL_CALL SvxOle2Shape::queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 97cdf0e10cSrcweir { 98a5258243SPedro Giffuni return SvxShapeText::queryAggregation( rType ); 99cdf0e10cSrcweir } 100cdf0e10cSrcweir 101cdf0e10cSrcweir //XPropertySet 102cdf0e10cSrcweir 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) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir switch( pProperty->nWID ) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir /* 107cdf0e10cSrcweir case OWN_ATTR_CLSID: 108cdf0e10cSrcweir { 109cdf0e10cSrcweir OUString aCLSID; 110cdf0e10cSrcweir if( rValue >>= aCLSID ) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir // init an ole object with a global name 113cdf0e10cSrcweir SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); 114cdf0e10cSrcweir if( pOle2 ) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj = pOle2->GetObjRef(); 117cdf0e10cSrcweir if ( !xObj.is() ) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir SvGlobalName aClassName; 120cdf0e10cSrcweir if( aClassName.MakeId( aCLSID ) ) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir SfxObjectShell* pPersist = mpModel->GetPersist(); 123cdf0e10cSrcweir ::rtl::OUString aPersistName; 124cdf0e10cSrcweir Any aAny( getPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ) ) ); 125cdf0e10cSrcweir aAny >>= aPersistName; 126cdf0e10cSrcweir 127cdf0e10cSrcweir //TODO/LATER: how to cope with creation failure?! 128cdf0e10cSrcweir xObj = pPersist->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClassName.GetByteSequence(), aPersistName ); 129cdf0e10cSrcweir if( xObj.is() ) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir aAny <<= aPersistName; 132cdf0e10cSrcweir setPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ), aAny ); 133cdf0e10cSrcweir pOle2->SetObjRef( xObj ); 134cdf0e10cSrcweir 135cdf0e10cSrcweir Rectangle aRect = pOle2->GetLogicRect(); 136cdf0e10cSrcweir awt::Size aSz; 137cdf0e10cSrcweir Size aSize( pOle2->GetLogicRect().GetSize() ); 138cdf0e10cSrcweir aSz.Width = aSize.Width(); 139cdf0e10cSrcweir aSz.Height = aSize.Height(); 140cdf0e10cSrcweir xObj->setVisualAreaSize( pOle2->GetAspect(), aSz ); 141cdf0e10cSrcweir } 142cdf0e10cSrcweir } 143cdf0e10cSrcweir } 144cdf0e10cSrcweir } 145cdf0e10cSrcweir return true; 146cdf0e10cSrcweir } 147cdf0e10cSrcweir break; 148cdf0e10cSrcweir } 149cdf0e10cSrcweir */ 150cdf0e10cSrcweir case OWN_ATTR_OLE_VISAREA: 151cdf0e10cSrcweir { 152cdf0e10cSrcweir // TODO/LATER: seems to make no sence for iconified object 153cdf0e10cSrcweir 154cdf0e10cSrcweir awt::Rectangle aVisArea; 155cdf0e10cSrcweir if( (rValue >>= aVisArea) && mpObj->ISA(SdrOle2Obj)) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir Size aTmp( aVisArea.X + aVisArea.Width, aVisArea.Y + aVisArea.Height ); 158cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj = ((SdrOle2Obj*)mpObj.get())->GetObjRef(); 159cdf0e10cSrcweir if( xObj.is() ) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir try 162cdf0e10cSrcweir { 163cdf0e10cSrcweir MapUnit aMapUnit( MAP_100TH_MM ); // the API handles with MAP_100TH_MM map mode 164cdf0e10cSrcweir MapUnit aObjUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( embed::Aspects::MSOLE_CONTENT ) ); 165cdf0e10cSrcweir aTmp = OutputDevice::LogicToLogic( aTmp, aMapUnit, aObjUnit ); 166cdf0e10cSrcweir xObj->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT, awt::Size( aTmp.Width(), aTmp.Height() ) ); 167cdf0e10cSrcweir } 168cdf0e10cSrcweir catch( uno::Exception& ) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir OSL_ENSURE( sal_False, "Couldn't set the visual area for the object!\n" ); 171cdf0e10cSrcweir } 172cdf0e10cSrcweir } 173cdf0e10cSrcweir 174cdf0e10cSrcweir return true; 175cdf0e10cSrcweir } 176cdf0e10cSrcweir break; 177cdf0e10cSrcweir } 178cdf0e10cSrcweir case OWN_ATTR_OLE_ASPECT: 179cdf0e10cSrcweir { 180cdf0e10cSrcweir sal_Int64 nAspect = 0; 181cdf0e10cSrcweir if( rValue >>= nAspect ) 182cdf0e10cSrcweir { 183cdf0e10cSrcweir static_cast<SdrOle2Obj*>(mpObj.get())->SetAspect( nAspect ); 184cdf0e10cSrcweir return true; 185cdf0e10cSrcweir } 186cdf0e10cSrcweir break; 187cdf0e10cSrcweir } 188cdf0e10cSrcweir case OWN_ATTR_CLSID: 189cdf0e10cSrcweir { 190cdf0e10cSrcweir OUString aCLSID; 191cdf0e10cSrcweir if( rValue >>= aCLSID ) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir // init a ole object with a global name 194cdf0e10cSrcweir SvGlobalName aClassName; 195cdf0e10cSrcweir if( aClassName.MakeId( aCLSID ) ) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir if( createObject( aClassName ) ) 198cdf0e10cSrcweir return true; 199cdf0e10cSrcweir } 200cdf0e10cSrcweir } 201cdf0e10cSrcweir break; 202cdf0e10cSrcweir } 203cdf0e10cSrcweir case OWN_ATTR_THUMBNAIL: 204cdf0e10cSrcweir { 205cdf0e10cSrcweir OUString aURL; 206cdf0e10cSrcweir if( rValue >>= aURL ) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir GraphicObject aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL ) ); 209cdf0e10cSrcweir static_cast<SdrOle2Obj*>(mpObj.get())->SetGraphic( &aGrafObj.GetGraphic() ); 210cdf0e10cSrcweir return true; 211cdf0e10cSrcweir } 212cdf0e10cSrcweir break; 213cdf0e10cSrcweir } 214cdf0e10cSrcweir case OWN_ATTR_VALUE_GRAPHIC: 215cdf0e10cSrcweir { 216cdf0e10cSrcweir uno::Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY ); 217cdf0e10cSrcweir if( xGraphic.is() ) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); 220cdf0e10cSrcweir if( pOle ) 221cdf0e10cSrcweir { 222cdf0e10cSrcweir GraphicObject aGrafObj( xGraphic ); 223cdf0e10cSrcweir const Graphic aGraphic( aGrafObj.GetGraphic() ); 224cdf0e10cSrcweir pOle->SetGraphicToObj( aGraphic, rtl::OUString() ); 225cdf0e10cSrcweir } 226cdf0e10cSrcweir return true; 227cdf0e10cSrcweir } 228cdf0e10cSrcweir break; 229cdf0e10cSrcweir } 230cdf0e10cSrcweir case OWN_ATTR_PERSISTNAME: 231cdf0e10cSrcweir { 232cdf0e10cSrcweir OUString aPersistName; 233cdf0e10cSrcweir if( rValue >>= aPersistName ) 234cdf0e10cSrcweir { 235cdf0e10cSrcweir static_cast<SdrOle2Obj*>(mpObj.get())->SetPersistName( aPersistName ); 236cdf0e10cSrcweir return true; 237cdf0e10cSrcweir } 238cdf0e10cSrcweir break; 239cdf0e10cSrcweir } 240cdf0e10cSrcweir case OWN_ATTR_OLE_LINKURL: 241cdf0e10cSrcweir { 242cdf0e10cSrcweir OUString aLinkURL; 243cdf0e10cSrcweir if( rValue >>= aLinkURL ) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir createLink( aLinkURL ); 246cdf0e10cSrcweir return true; 247cdf0e10cSrcweir } 248cdf0e10cSrcweir break; 249cdf0e10cSrcweir } 250cdf0e10cSrcweir default: 251a5258243SPedro Giffuni return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue ); 252cdf0e10cSrcweir } 253cdf0e10cSrcweir 254cdf0e10cSrcweir throw IllegalArgumentException(); 255cdf0e10cSrcweir } 256cdf0e10cSrcweir 257cdf0e10cSrcweir 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) 258cdf0e10cSrcweir { 259cdf0e10cSrcweir switch( pProperty->nWID ) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir case OWN_ATTR_CLSID: 262cdf0e10cSrcweir { 263cdf0e10cSrcweir OUString aCLSID; 264cdf0e10cSrcweir SvGlobalName aClassName = GetClassName_Impl(aCLSID); 265cdf0e10cSrcweir rValue <<= aCLSID; 266cdf0e10cSrcweir break; 267cdf0e10cSrcweir } 268cdf0e10cSrcweir 269cdf0e10cSrcweir case OWN_ATTR_INTERNAL_OLE: 270cdf0e10cSrcweir { 271cdf0e10cSrcweir rtl::OUString sCLSID; 272cdf0e10cSrcweir rValue <<= SotExchange::IsInternal( GetClassName_Impl(sCLSID) ); 273cdf0e10cSrcweir break; 274cdf0e10cSrcweir } 275cdf0e10cSrcweir 276cdf0e10cSrcweir case OWN_ATTR_METAFILE: 277cdf0e10cSrcweir { 278cdf0e10cSrcweir SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(mpObj.get()); 279cdf0e10cSrcweir if( pObj ) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir Graphic* pGraphic = pObj->GetGraphic(); 282cdf0e10cSrcweir if( pGraphic ) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir sal_Bool bIsWMF = sal_False; 285cdf0e10cSrcweir if ( pGraphic->IsLink() ) 286cdf0e10cSrcweir { 287cdf0e10cSrcweir GfxLink aLnk = pGraphic->GetLink(); 288cdf0e10cSrcweir if ( aLnk.GetType() == GFX_LINK_TYPE_NATIVE_WMF ) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir bIsWMF = sal_True; 291cdf0e10cSrcweir uno::Sequence<sal_Int8> aSeq((sal_Int8*)aLnk.GetData(), (sal_Int32) aLnk.GetDataSize()); 292cdf0e10cSrcweir rValue <<= aSeq; 293cdf0e10cSrcweir } 294cdf0e10cSrcweir } 295cdf0e10cSrcweir if ( !bIsWMF ) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir GDIMetaFile aMtf; 298cdf0e10cSrcweir if ( pGraphic->GetType() != GRAPHIC_BITMAP ) 299cdf0e10cSrcweir aMtf = pObj->GetGraphic()->GetGDIMetaFile(); 300cdf0e10cSrcweir else 301cdf0e10cSrcweir { 302cdf0e10cSrcweir VirtualDevice aVirDev; 303cdf0e10cSrcweir aMtf.Record( &aVirDev ); 304cdf0e10cSrcweir pGraphic->Draw( &aVirDev, Point(), pGraphic->GetPrefSize() ); 305cdf0e10cSrcweir aMtf.Stop(); 306cdf0e10cSrcweir aMtf.SetPrefSize( pGraphic->GetPrefSize() ); 307cdf0e10cSrcweir aMtf.SetPrefMapMode( pGraphic->GetPrefMapMode() ); 308cdf0e10cSrcweir } 309cdf0e10cSrcweir SvMemoryStream aDestStrm( 65535, 65535 ); 310cdf0e10cSrcweir ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False ); 311cdf0e10cSrcweir const uno::Sequence<sal_Int8> aSeq( 312cdf0e10cSrcweir static_cast< const sal_Int8* >(aDestStrm.GetData()), 313cdf0e10cSrcweir aDestStrm.GetEndOfData()); 314cdf0e10cSrcweir rValue <<= aSeq; 315cdf0e10cSrcweir } 316cdf0e10cSrcweir } 317cdf0e10cSrcweir } 318cdf0e10cSrcweir else 319cdf0e10cSrcweir { 320cdf0e10cSrcweir rValue = GetBitmap( sal_True ); 321cdf0e10cSrcweir } 322cdf0e10cSrcweir break; 323cdf0e10cSrcweir } 324cdf0e10cSrcweir 325cdf0e10cSrcweir case OWN_ATTR_OLE_VISAREA: 326cdf0e10cSrcweir { 327cdf0e10cSrcweir awt::Rectangle aVisArea; 328cdf0e10cSrcweir if( mpObj->ISA(SdrOle2Obj)) 329cdf0e10cSrcweir { 330cdf0e10cSrcweir MapMode aMapMode( MAP_100TH_MM ); // the API uses this map mode 331cdf0e10cSrcweir Size aTmp = ((SdrOle2Obj*)mpObj.get())->GetOrigObjSize( &aMapMode ); // get the size in the requested map mode 332cdf0e10cSrcweir aVisArea = awt::Rectangle( 0, 0, aTmp.Width(), aTmp.Height() ); 333cdf0e10cSrcweir } 334cdf0e10cSrcweir 335cdf0e10cSrcweir rValue <<= aVisArea; 336cdf0e10cSrcweir break; 337cdf0e10cSrcweir } 338cdf0e10cSrcweir 339cdf0e10cSrcweir case OWN_ATTR_OLESIZE: 340cdf0e10cSrcweir { 341cdf0e10cSrcweir Size aTmp( static_cast<SdrOle2Obj*>(mpObj.get())->GetOrigObjSize() ); 342cdf0e10cSrcweir rValue <<= awt::Size( aTmp.Width(), aTmp.Height() ); 343cdf0e10cSrcweir break; 344cdf0e10cSrcweir } 345cdf0e10cSrcweir 346cdf0e10cSrcweir case OWN_ATTR_OLE_ASPECT: 347cdf0e10cSrcweir { 348cdf0e10cSrcweir rValue <<= static_cast<SdrOle2Obj*>(mpObj.get())->GetAspect(); 349cdf0e10cSrcweir break; 350cdf0e10cSrcweir } 351cdf0e10cSrcweir 352cdf0e10cSrcweir case OWN_ATTR_OLEMODEL: 353cdf0e10cSrcweir case OWN_ATTR_OLE_EMBEDDED_OBJECT: 354cdf0e10cSrcweir case OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT: 355cdf0e10cSrcweir { 356cdf0e10cSrcweir SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>( mpObj.get() ); 357cdf0e10cSrcweir if( pObj ) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj( pObj->GetObjRef() ); 360cdf0e10cSrcweir if ( xObj.is() 361cdf0e10cSrcweir && ( pProperty->nWID == OWN_ATTR_OLE_EMBEDDED_OBJECT || pProperty->nWID == OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT || svt::EmbeddedObjectRef::TryRunningState( xObj ) ) ) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir // Discussed with CL fue to the before GetPaintingPageView 364cdf0e10cSrcweir // usage. Removed it, former fallback is used now 365cdf0e10cSrcweir if ( pProperty->nWID == OWN_ATTR_OLEMODEL || pProperty->nWID == OWN_ATTR_OLE_EMBEDDED_OBJECT ) 366cdf0e10cSrcweir { 367cdf0e10cSrcweir #ifdef DBG_UTIL 368cdf0e10cSrcweir const sal_Bool bSuccess(pObj->AddOwnLightClient()); 369cdf0e10cSrcweir OSL_ENSURE( bSuccess, "An object without client is provided!" ); 370cdf0e10cSrcweir #else 371cdf0e10cSrcweir pObj->AddOwnLightClient(); 372cdf0e10cSrcweir #endif 373cdf0e10cSrcweir } 374cdf0e10cSrcweir 375cdf0e10cSrcweir if ( pProperty->nWID == OWN_ATTR_OLEMODEL ) 376cdf0e10cSrcweir rValue <<= pObj->GetObjRef()->getComponent(); 377cdf0e10cSrcweir else 378cdf0e10cSrcweir rValue <<= xObj; 379cdf0e10cSrcweir } 380cdf0e10cSrcweir } 381cdf0e10cSrcweir break; 382cdf0e10cSrcweir } 383cdf0e10cSrcweir 384cdf0e10cSrcweir case OWN_ATTR_VALUE_GRAPHIC: 385cdf0e10cSrcweir { 386cdf0e10cSrcweir uno::Reference< graphic::XGraphic > xGraphic; 387cdf0e10cSrcweir Graphic* pGraphic = static_cast<SdrOle2Obj*>( mpObj.get() )->GetGraphic(); 388cdf0e10cSrcweir if( pGraphic ) 389cdf0e10cSrcweir xGraphic = pGraphic->GetXGraphic(); 390cdf0e10cSrcweir rValue <<= xGraphic; 391cdf0e10cSrcweir break; 392cdf0e10cSrcweir } 393cdf0e10cSrcweir 394cdf0e10cSrcweir case OWN_ATTR_THUMBNAIL: 395cdf0e10cSrcweir { 396cdf0e10cSrcweir OUString aURL; 397cdf0e10cSrcweir SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); 398cdf0e10cSrcweir if( pOle ) 399cdf0e10cSrcweir { 400cdf0e10cSrcweir Graphic* pGraphic = pOle->GetGraphic(); 401cdf0e10cSrcweir 402cdf0e10cSrcweir // if there isn't already a preview graphic set, check if we need to generate 403cdf0e10cSrcweir // one if model says so 404cdf0e10cSrcweir if( pGraphic == NULL && !pOle->IsEmptyPresObj() && mpModel->IsSaveOLEPreview() ) 405cdf0e10cSrcweir pGraphic = pOle->GetGraphic(); 406cdf0e10cSrcweir 407cdf0e10cSrcweir if( pGraphic ) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir GraphicObject aObj( *pGraphic ); 410cdf0e10cSrcweir aURL = OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX)); 411cdf0e10cSrcweir aURL += OUString::createFromAscii( aObj.GetUniqueID().GetBuffer() ); 412cdf0e10cSrcweir } 413cdf0e10cSrcweir } 414cdf0e10cSrcweir rValue <<= aURL; 415cdf0e10cSrcweir break; 416cdf0e10cSrcweir } 417cdf0e10cSrcweir case OWN_ATTR_PERSISTNAME: 418cdf0e10cSrcweir { 419cdf0e10cSrcweir OUString aPersistName; 420cdf0e10cSrcweir SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); 421cdf0e10cSrcweir 422cdf0e10cSrcweir if( pOle ) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir aPersistName = pOle->GetPersistName(); 425cdf0e10cSrcweir if( aPersistName.getLength() ) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir ::comphelper::IEmbeddedHelper *pPersist = mpObj->GetModel()->GetPersist(); 428cdf0e10cSrcweir if( (NULL == pPersist) || !pPersist->getEmbeddedObjectContainer().HasEmbeddedObject( pOle->GetPersistName() ) ) 429cdf0e10cSrcweir aPersistName = OUString(); 430cdf0e10cSrcweir } 431cdf0e10cSrcweir } 432cdf0e10cSrcweir 433cdf0e10cSrcweir rValue <<= aPersistName; 434cdf0e10cSrcweir break; 435cdf0e10cSrcweir } 436cdf0e10cSrcweir case OWN_ATTR_OLE_LINKURL: 437cdf0e10cSrcweir { 438cdf0e10cSrcweir OUString aLinkURL; 439cdf0e10cSrcweir SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); 440cdf0e10cSrcweir 441cdf0e10cSrcweir if( pOle ) 442cdf0e10cSrcweir { 443cdf0e10cSrcweir uno::Reference< embed::XLinkageSupport > xLink( pOle->GetObjRef(), uno::UNO_QUERY ); 444cdf0e10cSrcweir if ( xLink.is() && xLink->isLink() ) 445cdf0e10cSrcweir aLinkURL = xLink->getLinkURL(); 446cdf0e10cSrcweir } 447cdf0e10cSrcweir 448cdf0e10cSrcweir rValue <<= aLinkURL; 449cdf0e10cSrcweir break; 450cdf0e10cSrcweir } 451cdf0e10cSrcweir default: 452a5258243SPedro Giffuni return SvxShapeText::getPropertyValueImpl( rName, pProperty, rValue ); 453cdf0e10cSrcweir } 454cdf0e10cSrcweir 455cdf0e10cSrcweir return true; 456cdf0e10cSrcweir } 457cdf0e10cSrcweir 458cdf0e10cSrcweir sal_Bool SvxOle2Shape::createObject( const SvGlobalName &aClassName ) 459cdf0e10cSrcweir { 460cdf0e10cSrcweir DBG_TESTSOLARMUTEX(); 461cdf0e10cSrcweir 462cdf0e10cSrcweir SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); 463cdf0e10cSrcweir if ( !pOle2Obj || !pOle2Obj->IsEmpty() ) 464cdf0e10cSrcweir return sal_False; 465cdf0e10cSrcweir 466cdf0e10cSrcweir // create storage and inplace object 467cdf0e10cSrcweir ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist(); 468cdf0e10cSrcweir ::rtl::OUString aPersistName; 469cdf0e10cSrcweir OUString aTmpStr; 470cdf0e10cSrcweir if( getPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ) ) >>= aTmpStr ) 471cdf0e10cSrcweir aPersistName = aTmpStr; 472cdf0e10cSrcweir 473cdf0e10cSrcweir //TODO/LATER: how to cope with creation failure?! 474cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj( pPersist->getEmbeddedObjectContainer().CreateEmbeddedObject( aClassName.GetByteSequence(), aPersistName ) ); 475cdf0e10cSrcweir if( xObj.is() ) 476cdf0e10cSrcweir { 477cdf0e10cSrcweir Rectangle aRect = pOle2Obj->GetLogicRect(); 478cdf0e10cSrcweir if ( aRect.GetWidth() == 100 && aRect.GetHeight() == 100 ) 479cdf0e10cSrcweir { 480cdf0e10cSrcweir // TODO/LATER: is it possible that this method is used to create an iconified object? 481cdf0e10cSrcweir // default size 482cdf0e10cSrcweir try 483cdf0e10cSrcweir { 484cdf0e10cSrcweir awt::Size aSz = xObj->getVisualAreaSize( pOle2Obj->GetAspect() ); 485cdf0e10cSrcweir aRect.SetSize( Size( aSz.Width, aSz.Height ) ); 486cdf0e10cSrcweir } 487cdf0e10cSrcweir catch( embed::NoVisualAreaSizeException& ) 488cdf0e10cSrcweir {} 489cdf0e10cSrcweir pOle2Obj->SetLogicRect( aRect ); 490cdf0e10cSrcweir } 491cdf0e10cSrcweir else 492cdf0e10cSrcweir { 493cdf0e10cSrcweir awt::Size aSz; 494cdf0e10cSrcweir Size aSize = pOle2Obj->GetLogicRect().GetSize(); 495cdf0e10cSrcweir aSz.Width = aSize.Width(); 496cdf0e10cSrcweir aSz.Height = aSize.Height(); 497cdf0e10cSrcweir xObj->setVisualAreaSize( pOle2Obj->GetAspect(), aSz ); 498cdf0e10cSrcweir } 499cdf0e10cSrcweir 500cdf0e10cSrcweir // connect the object after the visual area is set 501cdf0e10cSrcweir setPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ), Any( aTmpStr = aPersistName ) ); 502cdf0e10cSrcweir 503cdf0e10cSrcweir // the object is inserted during setting of PersistName property usually 504cdf0e10cSrcweir if( pOle2Obj->IsEmpty() ) 505cdf0e10cSrcweir pOle2Obj->SetObjRef( xObj ); 506cdf0e10cSrcweir } 507cdf0e10cSrcweir 508cdf0e10cSrcweir return xObj.is(); 509cdf0e10cSrcweir } 510cdf0e10cSrcweir 511cdf0e10cSrcweir sal_Bool SvxOle2Shape::createLink( const ::rtl::OUString& aLinkURL ) 512cdf0e10cSrcweir { 513cdf0e10cSrcweir DBG_TESTSOLARMUTEX(); 514cdf0e10cSrcweir 515cdf0e10cSrcweir SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); 516cdf0e10cSrcweir if ( !pOle2Obj || !pOle2Obj->IsEmpty() ) 517cdf0e10cSrcweir return sal_False; 518cdf0e10cSrcweir 519cdf0e10cSrcweir ::rtl::OUString aPersistName; 520cdf0e10cSrcweir 521cdf0e10cSrcweir ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist(); 522cdf0e10cSrcweir 523cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aMediaDescr( 1 ); 524cdf0e10cSrcweir aMediaDescr[0].Name = ::rtl::OUString::createFromAscii( "URL" ); 525cdf0e10cSrcweir aMediaDescr[0].Value <<= aLinkURL; 526cdf0e10cSrcweir 527cdf0e10cSrcweir uno::Reference< task::XInteractionHandler > xInteraction = pPersist->getInteractionHandler(); 528cdf0e10cSrcweir if ( xInteraction.is() ) 529cdf0e10cSrcweir { 530cdf0e10cSrcweir aMediaDescr.realloc( 2 ); 531cdf0e10cSrcweir aMediaDescr[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InteractionHandler" ) ); 532cdf0e10cSrcweir aMediaDescr[1].Value <<= xInteraction; 533cdf0e10cSrcweir } 534cdf0e10cSrcweir 535cdf0e10cSrcweir //TODO/LATER: how to cope with creation failure?! 536cdf0e10cSrcweir uno::Reference< embed::XEmbeddedObject > xObj = 537cdf0e10cSrcweir pPersist->getEmbeddedObjectContainer().InsertEmbeddedLink( aMediaDescr , aPersistName ); 538cdf0e10cSrcweir 539cdf0e10cSrcweir if( xObj.is() ) 540cdf0e10cSrcweir { 541cdf0e10cSrcweir Rectangle aRect = pOle2Obj->GetLogicRect(); 542cdf0e10cSrcweir if ( aRect.GetWidth() == 100 && aRect.GetHeight() == 100 ) 543cdf0e10cSrcweir { 544cdf0e10cSrcweir // default size 545cdf0e10cSrcweir try 546cdf0e10cSrcweir { 547cdf0e10cSrcweir awt::Size aSz = xObj->getVisualAreaSize( pOle2Obj->GetAspect() ); 548cdf0e10cSrcweir aRect.SetSize( Size( aSz.Width, aSz.Height ) ); 549cdf0e10cSrcweir } 550cdf0e10cSrcweir catch( embed::NoVisualAreaSizeException& ) 551cdf0e10cSrcweir {} 552cdf0e10cSrcweir pOle2Obj->SetLogicRect( aRect ); 553cdf0e10cSrcweir } 554cdf0e10cSrcweir else 555cdf0e10cSrcweir { 556cdf0e10cSrcweir awt::Size aSz; 557cdf0e10cSrcweir Size aSize = pOle2Obj->GetLogicRect().GetSize(); 558cdf0e10cSrcweir aSz.Width = aSize.Width(); 559cdf0e10cSrcweir aSz.Height = aSize.Height(); 560cdf0e10cSrcweir xObj->setVisualAreaSize( pOle2Obj->GetAspect(), aSz ); 561cdf0e10cSrcweir } 562cdf0e10cSrcweir 563cdf0e10cSrcweir // connect the object after the visual area is set 564cdf0e10cSrcweir setPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ), uno::makeAny( aPersistName ) ); 565cdf0e10cSrcweir 566cdf0e10cSrcweir // the object is inserted during setting of PersistName property usually 567cdf0e10cSrcweir if ( pOle2Obj->IsEmpty() ) 568cdf0e10cSrcweir pOle2Obj->SetObjRef( xObj ); 569cdf0e10cSrcweir } 570cdf0e10cSrcweir 571cdf0e10cSrcweir return xObj.is(); 572cdf0e10cSrcweir } 573cdf0e10cSrcweir 574cdf0e10cSrcweir void SvxOle2Shape::resetModifiedState() 575cdf0e10cSrcweir { 576cdf0e10cSrcweir ::comphelper::IEmbeddedHelper* pPersist = mpModel ? mpModel->GetPersist() : 0; 577cdf0e10cSrcweir if( pPersist && !pPersist->isEnableSetModified() ) 578cdf0e10cSrcweir { 579cdf0e10cSrcweir SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); 580cdf0e10cSrcweir if( pOle && !pOle->IsEmpty() ) 581cdf0e10cSrcweir { 582cdf0e10cSrcweir uno::Reference < util::XModifiable > xMod( pOle->GetObjRef(), uno::UNO_QUERY ); 583cdf0e10cSrcweir if( xMod.is() ) 584cdf0e10cSrcweir // TODO/MBA: what's this?! 585cdf0e10cSrcweir xMod->setModified( sal_False ); 586cdf0e10cSrcweir } 587cdf0e10cSrcweir } 588cdf0e10cSrcweir } 589cdf0e10cSrcweir 590cdf0e10cSrcweir const SvGlobalName SvxOle2Shape::GetClassName_Impl(rtl::OUString& rHexCLSID) 591cdf0e10cSrcweir { 592cdf0e10cSrcweir DBG_TESTSOLARMUTEX(); 593cdf0e10cSrcweir SvGlobalName aClassName; 594cdf0e10cSrcweir SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() ); 595cdf0e10cSrcweir 596cdf0e10cSrcweir if( pOle2Obj ) 597cdf0e10cSrcweir { 598cdf0e10cSrcweir rHexCLSID = rtl::OUString(); 599cdf0e10cSrcweir 600cdf0e10cSrcweir if( pOle2Obj->IsEmpty() ) 601cdf0e10cSrcweir { 602cdf0e10cSrcweir ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist(); 603cdf0e10cSrcweir if( pPersist ) 604cdf0e10cSrcweir { 605cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj = 606cdf0e10cSrcweir pPersist->getEmbeddedObjectContainer().GetEmbeddedObject( pOle2Obj->GetPersistName() ); 607cdf0e10cSrcweir if ( xObj.is() ) 608cdf0e10cSrcweir { 609cdf0e10cSrcweir aClassName = SvGlobalName( xObj->getClassID() ); 610cdf0e10cSrcweir rHexCLSID = aClassName.GetHexName(); 611cdf0e10cSrcweir } 612cdf0e10cSrcweir } 613cdf0e10cSrcweir } 614cdf0e10cSrcweir 615cdf0e10cSrcweir if (!rHexCLSID.getLength()) 616cdf0e10cSrcweir { 617cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj( pOle2Obj->GetObjRef() ); 618cdf0e10cSrcweir if ( xObj.is() ) 619cdf0e10cSrcweir { 620cdf0e10cSrcweir aClassName = SvGlobalName( xObj->getClassID() ); 621cdf0e10cSrcweir rHexCLSID = aClassName.GetHexName(); 622cdf0e10cSrcweir } 623cdf0e10cSrcweir } 624cdf0e10cSrcweir } 625cdf0e10cSrcweir 626cdf0e10cSrcweir return aClassName; 627cdf0e10cSrcweir } 628cdf0e10cSrcweir 629cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 630cdf0e10cSrcweir 631cdf0e10cSrcweir SvxAppletShape::SvxAppletShape( SdrObject* pObject ) throw() 632cdf0e10cSrcweir : SvxOle2Shape( pObject, aSvxMapProvider.GetMap(SVXMAP_APPLET), aSvxMapProvider.GetPropertySet(SVXMAP_APPLET, SdrObject::GetGlobalDrawObjectItemPool()) ) 633cdf0e10cSrcweir { 634cdf0e10cSrcweir SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.AppletShape" ) ) ); 635cdf0e10cSrcweir } 636cdf0e10cSrcweir 637cdf0e10cSrcweir SvxAppletShape::~SvxAppletShape() throw() 638cdf0e10cSrcweir { 639cdf0e10cSrcweir } 640cdf0e10cSrcweir 641cdf0e10cSrcweir void SvxAppletShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) 642cdf0e10cSrcweir { 643cdf0e10cSrcweir SvxShape::Create( pNewObj, pNewPage ); 644cdf0e10cSrcweir const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID ); 645cdf0e10cSrcweir createObject(aAppletClassId); 646cdf0e10cSrcweir SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.AppletShape" ) ) ); 647cdf0e10cSrcweir } 648cdf0e10cSrcweir 649cdf0e10cSrcweir 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) 650cdf0e10cSrcweir { 651cdf0e10cSrcweir SvxShape::setPropertyValue( aPropertyName, rValue ); 652cdf0e10cSrcweir resetModifiedState(); 653cdf0e10cSrcweir } 654cdf0e10cSrcweir 655cdf0e10cSrcweir 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) 656cdf0e10cSrcweir { 657cdf0e10cSrcweir SvxShape::setPropertyValues( aPropertyNames, rValues ); 658cdf0e10cSrcweir resetModifiedState(); 659cdf0e10cSrcweir } 660cdf0e10cSrcweir 661cdf0e10cSrcweir 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) 662cdf0e10cSrcweir { 663cdf0e10cSrcweir if( (pProperty->nWID >= OWN_ATTR_APPLET_DOCBASE) && (pProperty->nWID <= OWN_ATTR_APPLET_ISSCRIPT) ) 664cdf0e10cSrcweir { 665cdf0e10cSrcweir if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) ) 666cdf0e10cSrcweir { 667cdf0e10cSrcweir uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); 668cdf0e10cSrcweir if( xSet.is() ) 669cdf0e10cSrcweir { 670cdf0e10cSrcweir // allow exceptions to pass through 671cdf0e10cSrcweir xSet->setPropertyValue( rName, rValue ); 672cdf0e10cSrcweir } 673cdf0e10cSrcweir } 674cdf0e10cSrcweir return true; 675cdf0e10cSrcweir } 676cdf0e10cSrcweir else 677cdf0e10cSrcweir { 678cdf0e10cSrcweir return SvxOle2Shape::setPropertyValueImpl( rName, pProperty, rValue ); 679cdf0e10cSrcweir } 680cdf0e10cSrcweir } 681cdf0e10cSrcweir 682cdf0e10cSrcweir 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) 683cdf0e10cSrcweir { 684cdf0e10cSrcweir if( (pProperty->nWID >= OWN_ATTR_APPLET_DOCBASE) && (pProperty->nWID <= OWN_ATTR_APPLET_ISSCRIPT) ) 685cdf0e10cSrcweir { 686cdf0e10cSrcweir if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) ) 687cdf0e10cSrcweir { 688cdf0e10cSrcweir uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); 689cdf0e10cSrcweir if( xSet.is() ) 690cdf0e10cSrcweir { 691cdf0e10cSrcweir rValue = xSet->getPropertyValue( rName ); 692cdf0e10cSrcweir } 693cdf0e10cSrcweir } 694cdf0e10cSrcweir return true; 695cdf0e10cSrcweir } 696cdf0e10cSrcweir else 697cdf0e10cSrcweir { 698cdf0e10cSrcweir return SvxOle2Shape::getPropertyValueImpl( rName, pProperty, rValue ); 699cdf0e10cSrcweir } 700cdf0e10cSrcweir } 701cdf0e10cSrcweir 702cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 703cdf0e10cSrcweir 704cdf0e10cSrcweir SvxPluginShape::SvxPluginShape( SdrObject* pObject ) throw() 705cdf0e10cSrcweir : SvxOle2Shape( pObject, aSvxMapProvider.GetMap(SVXMAP_PLUGIN), aSvxMapProvider.GetPropertySet(SVXMAP_PLUGIN, SdrObject::GetGlobalDrawObjectItemPool()) ) 706cdf0e10cSrcweir { 707cdf0e10cSrcweir SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.PluginShape" ) ) ); 708cdf0e10cSrcweir } 709cdf0e10cSrcweir 710cdf0e10cSrcweir SvxPluginShape::~SvxPluginShape() throw() 711cdf0e10cSrcweir { 712cdf0e10cSrcweir } 713cdf0e10cSrcweir 714cdf0e10cSrcweir void SvxPluginShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) 715cdf0e10cSrcweir { 716cdf0e10cSrcweir SvxShape::Create( pNewObj, pNewPage ); 717cdf0e10cSrcweir const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID ); 718cdf0e10cSrcweir createObject(aPluginClassId); 719cdf0e10cSrcweir SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.PluginShape" ) ) ); 720cdf0e10cSrcweir } 721cdf0e10cSrcweir 722cdf0e10cSrcweir 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) 723cdf0e10cSrcweir { 724cdf0e10cSrcweir SvxShape::setPropertyValue( aPropertyName, rValue ); 725cdf0e10cSrcweir resetModifiedState(); 726cdf0e10cSrcweir } 727cdf0e10cSrcweir 728cdf0e10cSrcweir 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) 729cdf0e10cSrcweir { 730a5258243SPedro Giffuni SvxShape::setPropertyValues( aPropertyNames, rValues ); 731cdf0e10cSrcweir resetModifiedState(); 732cdf0e10cSrcweir } 733cdf0e10cSrcweir 734cdf0e10cSrcweir 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) 735cdf0e10cSrcweir { 736cdf0e10cSrcweir if( (pProperty->nWID >= OWN_ATTR_PLUGIN_MIMETYPE) && (pProperty->nWID <= OWN_ATTR_PLUGIN_COMMANDS) ) 737cdf0e10cSrcweir { 738cdf0e10cSrcweir if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) ) 739cdf0e10cSrcweir { 740cdf0e10cSrcweir uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); 741cdf0e10cSrcweir if( xSet.is() ) 742cdf0e10cSrcweir { 743cdf0e10cSrcweir // allow exceptions to pass through 744cdf0e10cSrcweir xSet->setPropertyValue( rName, rValue ); 745cdf0e10cSrcweir } 746cdf0e10cSrcweir } 747cdf0e10cSrcweir return true; 748cdf0e10cSrcweir } 749cdf0e10cSrcweir else 750cdf0e10cSrcweir { 751cdf0e10cSrcweir return SvxOle2Shape::setPropertyValueImpl( rName, pProperty, rValue ); 752cdf0e10cSrcweir } 753cdf0e10cSrcweir } 754cdf0e10cSrcweir 755cdf0e10cSrcweir 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) 756cdf0e10cSrcweir { 757cdf0e10cSrcweir if( (pProperty->nWID >= OWN_ATTR_PLUGIN_MIMETYPE) && (pProperty->nWID <= OWN_ATTR_PLUGIN_COMMANDS) ) 758cdf0e10cSrcweir { 759cdf0e10cSrcweir if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) ) 760cdf0e10cSrcweir { 761cdf0e10cSrcweir uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); 762cdf0e10cSrcweir if( xSet.is() ) 763cdf0e10cSrcweir { 764cdf0e10cSrcweir rValue <<= xSet->getPropertyValue( rName ); 765cdf0e10cSrcweir } 766cdf0e10cSrcweir } 767cdf0e10cSrcweir return true; 768cdf0e10cSrcweir } 769cdf0e10cSrcweir else 770cdf0e10cSrcweir { 771cdf0e10cSrcweir return SvxOle2Shape::getPropertyValueImpl( rName, pProperty, rValue ); 772cdf0e10cSrcweir } 773cdf0e10cSrcweir } 774cdf0e10cSrcweir 775cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 776cdf0e10cSrcweir 777cdf0e10cSrcweir SvxFrameShape::SvxFrameShape( SdrObject* pObject ) throw() 778cdf0e10cSrcweir : SvxOle2Shape( pObject, aSvxMapProvider.GetMap(SVXMAP_FRAME), aSvxMapProvider.GetPropertySet(SVXMAP_FRAME, SdrObject::GetGlobalDrawObjectItemPool()) ) 779cdf0e10cSrcweir { 780cdf0e10cSrcweir SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.FrameShape" ) ) ); 781cdf0e10cSrcweir } 782cdf0e10cSrcweir 783cdf0e10cSrcweir SvxFrameShape::~SvxFrameShape() throw() 784cdf0e10cSrcweir { 785cdf0e10cSrcweir } 786cdf0e10cSrcweir 787cdf0e10cSrcweir void SvxFrameShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) throw () 788cdf0e10cSrcweir { 789cdf0e10cSrcweir SvxShape::Create( pNewObj, pNewPage ); 790cdf0e10cSrcweir const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID ); 791cdf0e10cSrcweir createObject(aIFrameClassId); 792cdf0e10cSrcweir SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.FrameShape" ) ) ); 793cdf0e10cSrcweir } 794cdf0e10cSrcweir 795cdf0e10cSrcweir 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) 796cdf0e10cSrcweir { 797cdf0e10cSrcweir SvxShape::setPropertyValue( aPropertyName, rValue ); 798cdf0e10cSrcweir resetModifiedState(); 799cdf0e10cSrcweir } 800cdf0e10cSrcweir 801cdf0e10cSrcweir 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) 802cdf0e10cSrcweir { 803a5258243SPedro Giffuni SvxShape::setPropertyValues( aPropertyNames, rValues ); 804cdf0e10cSrcweir resetModifiedState(); 805cdf0e10cSrcweir } 806cdf0e10cSrcweir 807cdf0e10cSrcweir 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) 808cdf0e10cSrcweir { 809cdf0e10cSrcweir if( (pProperty->nWID >= OWN_ATTR_FRAME_URL) && (pProperty->nWID <= OWN_ATTR_FRAME_MARGIN_HEIGHT) ) 810cdf0e10cSrcweir { 811cdf0e10cSrcweir if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) ) 812cdf0e10cSrcweir { 813cdf0e10cSrcweir uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); 814cdf0e10cSrcweir if( xSet.is() ) 815cdf0e10cSrcweir { 816cdf0e10cSrcweir // allow exceptions to pass through 817cdf0e10cSrcweir xSet->setPropertyValue( rName, rValue ); 818cdf0e10cSrcweir } 819cdf0e10cSrcweir } 820cdf0e10cSrcweir return true; 821cdf0e10cSrcweir } 822cdf0e10cSrcweir else 823cdf0e10cSrcweir { 824cdf0e10cSrcweir return SvxOle2Shape::setPropertyValueImpl( rName, pProperty, rValue ); 825cdf0e10cSrcweir } 826cdf0e10cSrcweir } 827cdf0e10cSrcweir 828cdf0e10cSrcweir 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) 829cdf0e10cSrcweir { 830cdf0e10cSrcweir if( (pProperty->nWID >= OWN_ATTR_FRAME_URL) && (pProperty->nWID <= OWN_ATTR_FRAME_MARGIN_HEIGHT) ) 831cdf0e10cSrcweir { 832cdf0e10cSrcweir if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) ) 833cdf0e10cSrcweir { 834cdf0e10cSrcweir uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY ); 835cdf0e10cSrcweir if( xSet.is() ) 836cdf0e10cSrcweir { 837cdf0e10cSrcweir rValue <<= xSet->getPropertyValue( rName ); 838cdf0e10cSrcweir } 839cdf0e10cSrcweir } 840cdf0e10cSrcweir return true; 841cdf0e10cSrcweir } 842cdf0e10cSrcweir else 843cdf0e10cSrcweir { 844cdf0e10cSrcweir return SvxOle2Shape::getPropertyValueImpl( rName, pProperty, rValue ); 845cdf0e10cSrcweir } 846cdf0e10cSrcweir } 847cdf0e10cSrcweir 848cdf0e10cSrcweir /*********************************************************************** 849cdf0e10cSrcweir * * 850cdf0e10cSrcweir ***********************************************************************/ 851cdf0e10cSrcweir 852cdf0e10cSrcweir SvxMediaShape::SvxMediaShape( SdrObject* pObj ) throw() 853cdf0e10cSrcweir : SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_MEDIA), aSvxMapProvider.GetPropertySet(SVXMAP_MEDIA, SdrObject::GetGlobalDrawObjectItemPool()) ) 854cdf0e10cSrcweir { 855cdf0e10cSrcweir SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.MediaShape" ) ) ); 856cdf0e10cSrcweir } 857cdf0e10cSrcweir 858cdf0e10cSrcweir //---------------------------------------------------------------------- 859cdf0e10cSrcweir SvxMediaShape::~SvxMediaShape() throw() 860cdf0e10cSrcweir { 861cdf0e10cSrcweir } 862cdf0e10cSrcweir 863cdf0e10cSrcweir //---------------------------------------------------------------------- 864cdf0e10cSrcweir 865cdf0e10cSrcweir 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) 866cdf0e10cSrcweir { 867cdf0e10cSrcweir if( (pProperty->nWID >= OWN_ATTR_MEDIA_URL) && (pProperty->nWID <= OWN_ATTR_MEDIA_ZOOM) ) 868cdf0e10cSrcweir { 869cdf0e10cSrcweir SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( mpObj.get() ); 870cdf0e10cSrcweir ::avmedia::MediaItem aItem; 871cdf0e10cSrcweir bool bOk = false; 872cdf0e10cSrcweir 873cdf0e10cSrcweir switch( pProperty->nWID ) 874cdf0e10cSrcweir { 875cdf0e10cSrcweir case OWN_ATTR_MEDIA_URL: 876cdf0e10cSrcweir { 877cdf0e10cSrcweir OUString aURL; 878cdf0e10cSrcweir if( rValue >>= aURL ) 879cdf0e10cSrcweir { 880cdf0e10cSrcweir bOk = true; 881cdf0e10cSrcweir aItem.setURL( aURL ); 882cdf0e10cSrcweir } 883cdf0e10cSrcweir } 884cdf0e10cSrcweir break; 885cdf0e10cSrcweir 886cdf0e10cSrcweir case( OWN_ATTR_MEDIA_LOOP ): 887cdf0e10cSrcweir { 888cdf0e10cSrcweir sal_Bool bLoop = sal_Bool(); 889cdf0e10cSrcweir 890cdf0e10cSrcweir if( rValue >>= bLoop ) 891cdf0e10cSrcweir { 892cdf0e10cSrcweir bOk = true; 893cdf0e10cSrcweir aItem.setLoop( bLoop ); 894cdf0e10cSrcweir } 895cdf0e10cSrcweir } 896cdf0e10cSrcweir break; 897cdf0e10cSrcweir 898cdf0e10cSrcweir case( OWN_ATTR_MEDIA_MUTE ): 899cdf0e10cSrcweir { 900cdf0e10cSrcweir sal_Bool bMute = sal_Bool(); 901cdf0e10cSrcweir 902cdf0e10cSrcweir if( rValue >>= bMute ) 903cdf0e10cSrcweir { 904cdf0e10cSrcweir bOk = true; 905cdf0e10cSrcweir aItem.setMute( bMute ); 906cdf0e10cSrcweir } 907cdf0e10cSrcweir } 908cdf0e10cSrcweir break; 909cdf0e10cSrcweir 910cdf0e10cSrcweir case( OWN_ATTR_MEDIA_VOLUMEDB ): 911cdf0e10cSrcweir { 912cdf0e10cSrcweir sal_Int16 nVolumeDB = sal_Int16(); 913cdf0e10cSrcweir 914cdf0e10cSrcweir if( rValue >>= nVolumeDB ) 915cdf0e10cSrcweir { 916cdf0e10cSrcweir bOk = true; 917cdf0e10cSrcweir aItem.setVolumeDB( nVolumeDB ); 918cdf0e10cSrcweir } 919cdf0e10cSrcweir } 920cdf0e10cSrcweir break; 921cdf0e10cSrcweir 922cdf0e10cSrcweir case( OWN_ATTR_MEDIA_ZOOM ): 923cdf0e10cSrcweir { 924cdf0e10cSrcweir ::com::sun::star::media::ZoomLevel eLevel; 925cdf0e10cSrcweir 926cdf0e10cSrcweir if( rValue >>= eLevel ) 927cdf0e10cSrcweir { 928cdf0e10cSrcweir bOk = true; 929cdf0e10cSrcweir aItem.setZoom( eLevel ); 930cdf0e10cSrcweir } 931cdf0e10cSrcweir } 932cdf0e10cSrcweir break; 933cdf0e10cSrcweir 934cdf0e10cSrcweir default: 935cdf0e10cSrcweir DBG_ERROR("SvxMediaShape::setPropertyValueImpl(), unknown argument!"); 936cdf0e10cSrcweir } 937cdf0e10cSrcweir 938cdf0e10cSrcweir if( bOk ) 939cdf0e10cSrcweir { 940cdf0e10cSrcweir pMedia->setMediaProperties( aItem ); 941cdf0e10cSrcweir return true; 942cdf0e10cSrcweir } 943cdf0e10cSrcweir } 944cdf0e10cSrcweir else 945cdf0e10cSrcweir { 946cdf0e10cSrcweir return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); 947cdf0e10cSrcweir } 948cdf0e10cSrcweir 949cdf0e10cSrcweir throw IllegalArgumentException(); 950cdf0e10cSrcweir } 951cdf0e10cSrcweir 952cdf0e10cSrcweir //---------------------------------------------------------------------- 953cdf0e10cSrcweir 954cdf0e10cSrcweir 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) 955cdf0e10cSrcweir { 956cdf0e10cSrcweir if( ( pProperty->nWID >= OWN_ATTR_MEDIA_URL ) && ( pProperty->nWID <= OWN_ATTR_MEDIA_ZOOM ) ) 957cdf0e10cSrcweir { 958cdf0e10cSrcweir SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( mpObj.get() ); 959cdf0e10cSrcweir const ::avmedia::MediaItem aItem( pMedia->getMediaProperties() ); 960cdf0e10cSrcweir 961cdf0e10cSrcweir switch( pProperty->nWID ) 962cdf0e10cSrcweir { 963cdf0e10cSrcweir case OWN_ATTR_MEDIA_URL: 964cdf0e10cSrcweir rValue <<= aItem.getURL(); 965cdf0e10cSrcweir break; 966cdf0e10cSrcweir 967cdf0e10cSrcweir case( OWN_ATTR_MEDIA_LOOP ): 968cdf0e10cSrcweir rValue <<= (sal_Bool) aItem.isLoop(); 969cdf0e10cSrcweir break; 970cdf0e10cSrcweir 971cdf0e10cSrcweir case( OWN_ATTR_MEDIA_MUTE ): 972cdf0e10cSrcweir rValue <<= (sal_Bool) aItem.isMute(); 973cdf0e10cSrcweir break; 974cdf0e10cSrcweir 975cdf0e10cSrcweir case( OWN_ATTR_MEDIA_VOLUMEDB ): 976cdf0e10cSrcweir rValue <<= (sal_Int16) aItem.getVolumeDB(); 977cdf0e10cSrcweir break; 978cdf0e10cSrcweir 979cdf0e10cSrcweir case( OWN_ATTR_MEDIA_ZOOM ): 980cdf0e10cSrcweir rValue <<= aItem.getZoom(); 981cdf0e10cSrcweir break; 982cdf0e10cSrcweir 983cdf0e10cSrcweir default: 984cdf0e10cSrcweir DBG_ERROR("SvxMediaShape::getPropertyValueImpl(), unknown property!"); 985cdf0e10cSrcweir } 986cdf0e10cSrcweir return true; 987cdf0e10cSrcweir } 988cdf0e10cSrcweir else 989cdf0e10cSrcweir { 990cdf0e10cSrcweir return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); 991cdf0e10cSrcweir } 992cdf0e10cSrcweir } 993