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