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