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