1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_embeddedobj.hxx"
30 #include <com/sun/star/embed/ElementModes.hpp>
31 #include <com/sun/star/embed/EntryInitModes.hpp>
32 #include <com/sun/star/document/XTypeDetection.hpp>
33 #include <com/sun/star/beans/PropertyValue.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/container/XNameAccess.hpp>
36 
37 #include <rtl/logfile.hxx>
38 
39 
40 #include "xfactory.hxx"
41 #include "commonembobj.hxx"
42 #include "specialobject.hxx"
43 #include "oleembobj.hxx"
44 
45 
46 using namespace ::com::sun::star;
47 
48 //-------------------------------------------------------------------------
49 uno::Sequence< ::rtl::OUString > SAL_CALL OOoEmbeddedObjectFactory::impl_staticGetSupportedServiceNames()
50 {
51     uno::Sequence< ::rtl::OUString > aRet(2);
52     aRet[0] = ::rtl::OUString::createFromAscii("com.sun.star.embed.OOoEmbeddedObjectFactory");
53     aRet[1] = ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.OOoEmbeddedObjectFactory");
54     return aRet;
55 }
56 
57 //-------------------------------------------------------------------------
58 ::rtl::OUString SAL_CALL OOoEmbeddedObjectFactory::impl_staticGetImplementationName()
59 {
60     return ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.OOoEmbeddedObjectFactory");
61 }
62 
63 //-------------------------------------------------------------------------
64 uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::impl_staticCreateSelfInstance(
65 			const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
66 {
67 	return uno::Reference< uno::XInterface >( *new OOoEmbeddedObjectFactory( xServiceManager ) );
68 }
69 
70 //-------------------------------------------------------------------------
71 uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInstanceInitFromEntry(
72 																	const uno::Reference< embed::XStorage >& xStorage,
73 																	const ::rtl::OUString& sEntName,
74 																	const uno::Sequence< beans::PropertyValue >& aMediaDescr,
75 																	const uno::Sequence< beans::PropertyValue >& lObjArgs )
76 	throw ( lang::IllegalArgumentException,
77 			container::NoSuchElementException,
78 			io::IOException,
79 			uno::Exception,
80 			uno::RuntimeException)
81 {
82 	RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OOoEmbeddedObjectFactory::createInstanceInitFromEntry" );
83 
84 	if ( !xStorage.is() )
85 		throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "No parent storage is provided!\n" ),
86 											uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
87 											1 );
88 
89 	if ( !sEntName.getLength() )
90 		throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Empty element name is provided!\n" ),
91 											uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
92 											2 );
93 
94 	uno::Reference< container::XNameAccess > xNameAccess( xStorage, uno::UNO_QUERY );
95 	if ( !xNameAccess.is() )
96 		throw uno::RuntimeException(); //TODO
97 
98 	// detect entry existence
99 	if ( !xNameAccess->hasByName( sEntName ) )
100 		throw container::NoSuchElementException();
101 
102 	uno::Reference< uno::XInterface > xResult;
103 	if ( xStorage->isStorageElement( sEntName ) )
104 	{
105 		// the object must be based on storage
106 		uno::Reference< embed::XStorage > xSubStorage =
107 				xStorage->openStorageElement( sEntName, embed::ElementModes::READ );
108 
109 		uno::Reference< beans::XPropertySet > xPropSet( xSubStorage, uno::UNO_QUERY );
110 		if ( !xPropSet.is() )
111 			throw uno::RuntimeException();
112 
113 		::rtl::OUString aMediaType;
114 		try {
115 			uno::Any aAny = xPropSet->getPropertyValue( ::rtl::OUString::createFromAscii( "MediaType" ) );
116 			aAny >>= aMediaType;
117 		}
118 		catch ( uno::Exception& )
119 		{
120 		}
121 
122 		try {
123 			uno::Reference< lang::XComponent > xComp( xSubStorage, uno::UNO_QUERY );
124 			if ( xComp.is() )
125 				xComp->dispose();
126 		}
127 		catch ( uno::Exception& )
128 		{
129 		}
130 		xSubStorage = uno::Reference< embed::XStorage >();
131 
132 #if 0
133 		::rtl::OUString aDocServiceName = m_aConfigHelper.GetDocumentServiceFromMediaType( aMediaType );
134 		if ( !aDocServiceName.getLength() )
135 		{
136 			// only own document can be based on storage
137 			// in case it is not possible to find related
138 			// document service name the storage entry is invalid
139 
140 			throw io::IOException(); // unexpected mimetype of the storage
141 		}
142 #endif
143 
144 		uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByMediaType( aMediaType );
145 		if ( !aObject.getLength() )
146 			throw io::IOException(); // unexpected mimetype of the storage
147 
148 		xResult = uno::Reference< uno::XInterface >(
149 					static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
150 												m_xFactory,
151 												aObject ) ),
152 #if 0
153 												GetClassIDFromServName( aDocServiceName ),
154 												GetClassNameFromServName( aDocServiceName ),
155 												aDocServiceName ) ),
156 #endif
157 					uno::UNO_QUERY );
158 	}
159 	else
160 	{
161 		// the object must be OOo embedded object, if it is not an exception must be thrown
162 		throw io::IOException(); // TODO:
163 	}
164 
165 	uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY );
166 
167 	if ( !xPersist.is() )
168 		throw uno::RuntimeException(); // TODO: the interface must be supported by own document objects
169 
170 	xPersist->setPersistentEntry( xStorage,
171 									sEntName,
172 									embed::EntryInitModes::DEFAULT_INIT,
173 									aMediaDescr,
174 									lObjArgs );
175 
176 	return xResult;
177 }
178 
179 //-------------------------------------------------------------------------
180 uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInstanceInitFromMediaDescriptor(
181 		const uno::Reference< embed::XStorage >& xStorage,
182 		const ::rtl::OUString& sEntName,
183 		const uno::Sequence< beans::PropertyValue >& aMediaDescr,
184 		const uno::Sequence< beans::PropertyValue >& lObjArgs )
185 	throw ( lang::IllegalArgumentException,
186 			io::IOException,
187 			uno::Exception,
188 			uno::RuntimeException)
189 {
190 	RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OOoEmbeddedObjectFactory::createInstanceInitFromMediaDescriptor" );
191 
192 	if ( !xStorage.is() )
193 		throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "No parent storage is provided!\n" ),
194 											uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
195 											1 );
196 
197 	if ( !sEntName.getLength() )
198 		throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Empty element name is provided!\n" ),
199 											uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
200 											2 );
201 
202 	uno::Sequence< beans::PropertyValue > aTempMedDescr( aMediaDescr );
203 
204 	// check if there is FilterName
205 	::rtl::OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, sal_False );
206 
207 	uno::Reference< uno::XInterface > xResult;
208 
209 	// find document service name
210 	if ( aFilterName.getLength() )
211 	{
212 		uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByFilter( aFilterName );
213 		if ( !aObject.getLength() )
214 			throw io::IOException(); // unexpected mimetype of the storage
215 
216 
217 		xResult = uno::Reference< uno::XInterface >(
218 					static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
219 											m_xFactory,
220 											aObject ) ),
221 					uno::UNO_QUERY );
222 	}
223 	else
224 	{
225 		// the object must be OOo embedded object, if it is not an exception must be thrown
226 		throw io::IOException(); // TODO:
227 	}
228 
229 	uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY );
230 
231 	if ( !xPersist.is() )
232 		throw uno::RuntimeException(); // TODO: the interface must be supported ( what about applets? )
233 
234 	xPersist->setPersistentEntry( xStorage,
235 									sEntName,
236 									embed::EntryInitModes::MEDIA_DESCRIPTOR_INIT,
237 									aTempMedDescr,
238 									lObjArgs );
239 
240 	return xResult;
241 }
242 
243 //-------------------------------------------------------------------------
244 uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInstanceInitNew(
245 											const uno::Sequence< sal_Int8 >& aClassID,
246 											const ::rtl::OUString& /*aClassName*/,
247 											const uno::Reference< embed::XStorage >& xStorage,
248 											const ::rtl::OUString& sEntName,
249 											const uno::Sequence< beans::PropertyValue >& lObjArgs )
250 	throw ( lang::IllegalArgumentException,
251 			io::IOException,
252 			uno::Exception,
253 			uno::RuntimeException)
254 {
255 	RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OOoEmbeddedObjectFactory::createInstanceInitNew" );
256 
257 	uno::Reference< uno::XInterface > xResult;
258 
259 	if ( !xStorage.is() )
260 		throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "No parent storage is provided!\n" ),
261 											uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
262 											3 );
263 
264 	if ( !sEntName.getLength() )
265 		throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Empty element name is provided!\n" ),
266 											uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
267 											4 );
268 
269 	uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByClassID( aClassID );
270 	if ( !aObject.getLength() )
271 		throw io::IOException(); // unexpected mimetype of the storage
272 
273 	xResult = uno::Reference< uno::XInterface >(
274 					static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
275 												m_xFactory,
276 												aObject ) ),
277 					uno::UNO_QUERY );
278 
279 
280 	uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY );
281 
282 	if ( !xPersist.is() )
283 		throw uno::RuntimeException(); // TODO: the interface must be supported by own document objects
284 
285 	xPersist->setPersistentEntry( xStorage,
286 									sEntName,
287 									embed::EntryInitModes::TRUNCATE_INIT,
288 									uno::Sequence< beans::PropertyValue >(),
289 									lObjArgs );
290 
291 	return xResult;
292 }
293 
294 //-------------------------------------------------------------------------
295 uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInstanceUserInit(
296 			const uno::Sequence< sal_Int8 >& aClassID,
297 			const ::rtl::OUString& /*aClassName*/,
298 			const uno::Reference< embed::XStorage >& xStorage,
299 			const ::rtl::OUString& sEntName,
300 			sal_Int32 nEntryConnectionMode,
301 			const uno::Sequence< beans::PropertyValue >& lArguments,
302 			const uno::Sequence< beans::PropertyValue >& lObjArgs )
303 	throw ( lang::IllegalArgumentException,
304 			io::IOException,
305 			uno::Exception,
306 			uno::RuntimeException )
307 {
308 	RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OOoEmbeddedObjectFactory::createInstanceUserInit" );
309 
310 	// the initialization is completelly controlled by user
311 	if ( !xStorage.is() )
312 		throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "No parent storage is provided!\n" ),
313 											uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
314 											1 );
315 
316 	if ( !sEntName.getLength() )
317 		throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Empty element name is provided!\n" ),
318 											uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
319 											2 );
320 
321 	uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByClassID( aClassID );
322 	if ( !aObject.getLength() )
323 		throw io::IOException(); // unexpected mimetype of the storage
324 
325 	uno::Sequence< beans::PropertyValue > aTempMedDescr( lArguments );
326 	if ( nEntryConnectionMode == embed::EntryInitModes::MEDIA_DESCRIPTOR_INIT )
327 	{
328 		::rtl::OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, aObject );
329 		if ( !aFilterName.getLength() )
330 		// the object must be OOo embedded object, if it is not an exception must be thrown
331 			throw io::IOException(); // TODO:
332 	}
333 
334 	uno::Reference< uno::XInterface > xResult = uno::Reference< uno::XInterface > (
335 					static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
336 												m_xFactory,
337 												aObject ) ),
338 					uno::UNO_QUERY );
339 
340 	uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY );
341 	if ( xPersist.is() )
342 	{
343 		xPersist->setPersistentEntry( xStorage,
344 									sEntName,
345 									nEntryConnectionMode,
346 									aTempMedDescr,
347 									lObjArgs );
348 
349 	}
350 	else
351 		throw uno::RuntimeException(); // TODO:
352 
353 	return xResult;
354 }
355 
356 
357 //-------------------------------------------------------------------------
358 uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInstanceLink(
359 											const uno::Reference< embed::XStorage >& /*xStorage*/,
360 											const ::rtl::OUString& /*sEntName*/,
361 											const uno::Sequence< beans::PropertyValue >& aMediaDescr,
362 											const uno::Sequence< beans::PropertyValue >& lObjArgs )
363 		throw ( lang::IllegalArgumentException,
364 				io::IOException,
365 				uno::Exception,
366 				uno::RuntimeException )
367 {
368 	RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OOoEmbeddedObjectFactory::createInstanceLink" );
369 
370 	uno::Reference< uno::XInterface > xResult;
371 
372 	uno::Sequence< beans::PropertyValue > aTempMedDescr( aMediaDescr );
373 
374 	// check if there is URL, URL must exist
375 	::rtl::OUString aURL;
376 	for ( sal_Int32 nInd = 0; nInd < aTempMedDescr.getLength(); nInd++ )
377 		if ( aTempMedDescr[nInd].Name.equalsAscii( "URL" ) )
378 			aTempMedDescr[nInd].Value >>= aURL;
379 
380 	if ( !aURL.getLength() )
381 		throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "No URL for the link is provided!\n" ),
382 										uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
383 										3 );
384 
385 	::rtl::OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, sal_False );
386 
387 	if ( aFilterName.getLength() )
388 	{
389 		uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByFilter( aFilterName );
390 		if ( !aObject.getLength() )
391 			throw io::IOException(); // unexpected mimetype of the storage
392 
393 
394 		xResult = uno::Reference< uno::XInterface >(
395 					static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
396 											m_xFactory,
397 											aObject,
398 											aTempMedDescr,
399 											lObjArgs ) ),
400 					uno::UNO_QUERY );
401 	}
402 	else
403 	{
404 		// the object must be OOo embedded object, if it is not an exception must be thrown
405 		throw io::IOException(); // TODO:
406 	}
407 
408 	return xResult;
409 }
410 
411 //-------------------------------------------------------------------------
412 uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInstanceLinkUserInit(
413 												const uno::Sequence< sal_Int8 >& aClassID,
414 												const ::rtl::OUString& /*aClassName*/,
415 												const uno::Reference< embed::XStorage >& xStorage,
416 												const ::rtl::OUString& sEntName,
417 												const uno::Sequence< beans::PropertyValue >& lArguments,
418 												const uno::Sequence< beans::PropertyValue >& lObjArgs )
419 		throw ( lang::IllegalArgumentException,
420 				io::IOException,
421 				uno::Exception,
422 				uno::RuntimeException )
423 {
424 	RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) OOoEmbeddedObjectFactory::createInstanceLinkUserInit" );
425 
426 	uno::Reference< uno::XInterface > xResult;
427 
428 	// the initialization is completelly controlled by user
429 	if ( !xStorage.is() )
430 		throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "No parent storage is provided!\n" ),
431 											uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
432 											1 );
433 
434 	if ( !sEntName.getLength() )
435 		throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Empty element name is provided!\n" ),
436 											uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
437 											2 );
438 
439 	uno::Sequence< beans::PropertyValue > aTempMedDescr( lArguments );
440 
441 	::rtl::OUString aURL;
442 	for ( sal_Int32 nInd = 0; nInd < aTempMedDescr.getLength(); nInd++ )
443 		if ( aTempMedDescr[nInd].Name.equalsAscii( "URL" ) )
444 			aTempMedDescr[nInd].Value >>= aURL;
445 
446 	if ( !aURL.getLength() )
447 		throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "No URL for the link is provided!\n" ),
448 										uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
449 										3 );
450 
451 	uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByClassID( aClassID );
452 	if ( !aObject.getLength() )
453 		throw io::IOException(); // unexpected mimetype of the storage
454 
455 	::rtl::OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, aObject );
456 
457 	if ( aFilterName.getLength() )
458 	{
459 
460 		xResult = uno::Reference< uno::XInterface >(
461 					static_cast< ::cppu::OWeakObject* > ( new OCommonEmbeddedObject(
462 											m_xFactory,
463 											aObject,
464 											aTempMedDescr,
465 											lObjArgs ) ),
466 					uno::UNO_QUERY );
467 	}
468 	else
469 	{
470 		// the object must be OOo embedded object, if it is not an exception must be thrown
471 		throw io::IOException(); // TODO:
472 	}
473 
474 	return xResult;
475 }
476 
477 //-------------------------------------------------------------------------
478 ::rtl::OUString SAL_CALL OOoEmbeddedObjectFactory::getImplementationName()
479 	throw ( uno::RuntimeException )
480 {
481 	return impl_staticGetImplementationName();
482 }
483 
484 //-------------------------------------------------------------------------
485 sal_Bool SAL_CALL OOoEmbeddedObjectFactory::supportsService( const ::rtl::OUString& ServiceName )
486 	throw ( uno::RuntimeException )
487 {
488 	uno::Sequence< ::rtl::OUString > aSeq = impl_staticGetSupportedServiceNames();
489 
490 	for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
491     	if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
492         	return sal_True;
493 
494 	return sal_False;
495 }
496 
497 //-------------------------------------------------------------------------
498 uno::Sequence< ::rtl::OUString > SAL_CALL OOoEmbeddedObjectFactory::getSupportedServiceNames()
499 	throw ( uno::RuntimeException )
500 {
501 	return impl_staticGetSupportedServiceNames();
502 }
503 
504 //-------------------------------------------------------------------------
505 uno::Sequence< ::rtl::OUString > SAL_CALL OOoSpecialEmbeddedObjectFactory::impl_staticGetSupportedServiceNames()
506 {
507     uno::Sequence< ::rtl::OUString > aRet(2);
508     aRet[0] = ::rtl::OUString::createFromAscii("com.sun.star.embed.OOoSpecialEmbeddedObjectFactory");
509     aRet[1] = ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.OOoSpecialEmbeddedObjectFactory");
510     return aRet;
511 }
512 
513 //-------------------------------------------------------------------------
514 ::rtl::OUString SAL_CALL OOoSpecialEmbeddedObjectFactory::impl_staticGetImplementationName()
515 {
516     return ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.OOoSpecialEmbeddedObjectFactory");
517 }
518 
519 //-------------------------------------------------------------------------
520 uno::Reference< uno::XInterface > SAL_CALL OOoSpecialEmbeddedObjectFactory::impl_staticCreateSelfInstance(
521 			const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
522 {
523     return uno::Reference< uno::XInterface >( *new OOoSpecialEmbeddedObjectFactory( xServiceManager ) );
524 }
525 
526 //-------------------------------------------------------------------------
527 uno::Reference< uno::XInterface > SAL_CALL OOoSpecialEmbeddedObjectFactory::createInstanceUserInit(
528 			const uno::Sequence< sal_Int8 >& aClassID,
529 			const ::rtl::OUString& /*aClassName*/,
530 			const uno::Reference< embed::XStorage >& /*xStorage*/,
531 			const ::rtl::OUString& /*sEntName*/,
532 			sal_Int32 /*nEntryConnectionMode*/,
533 			const uno::Sequence< beans::PropertyValue >& /*lArguments*/,
534 			const uno::Sequence< beans::PropertyValue >& /*lObjArgs*/ )
535 	throw ( lang::IllegalArgumentException,
536 			io::IOException,
537 			uno::Exception,
538 			uno::RuntimeException )
539 {
540 	uno::Sequence< beans::NamedValue > aObject = m_aConfigHelper.GetObjectPropsByClassID( aClassID );
541 	if ( !aObject.getLength() )
542 		throw io::IOException(); // unexpected mimetype of the storage
543 
544 	uno::Reference< uno::XInterface > xResult(
545                     static_cast< ::cppu::OWeakObject* > ( new OSpecialEmbeddedObject(
546 												m_xFactory,
547 												aObject ) ),
548 					uno::UNO_QUERY );
549 	return xResult;
550 }
551 
552 //-------------------------------------------------------------------------
553 ::rtl::OUString SAL_CALL OOoSpecialEmbeddedObjectFactory::getImplementationName()
554 	throw ( uno::RuntimeException )
555 {
556 	return impl_staticGetImplementationName();
557 }
558 
559 //-------------------------------------------------------------------------
560 sal_Bool SAL_CALL OOoSpecialEmbeddedObjectFactory::supportsService( const ::rtl::OUString& ServiceName )
561 	throw ( uno::RuntimeException )
562 {
563 	uno::Sequence< ::rtl::OUString > aSeq = impl_staticGetSupportedServiceNames();
564 
565 	for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
566     	if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
567         	return sal_True;
568 
569 	return sal_False;
570 }
571 
572 //-------------------------------------------------------------------------
573 uno::Sequence< ::rtl::OUString > SAL_CALL OOoSpecialEmbeddedObjectFactory::getSupportedServiceNames()
574 	throw ( uno::RuntimeException )
575 {
576 	return impl_staticGetSupportedServiceNames();
577 }
578 
579 
580