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