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/embed/XEmbedObjectFactory.hpp>
32 : : #include <com/sun/star/embed/XLinkFactory.hpp>
33 : : #include <com/sun/star/document/XTypeDetection.hpp>
34 : : #include <com/sun/star/beans/PropertyValue.hpp>
35 : : #include <com/sun/star/beans/XPropertySet.hpp>
36 : : #include <com/sun/star/container/XNameAccess.hpp>
37 : : #include <com/sun/star/lang/XComponent.hpp>
38 : :
39 : : #include <rtl/logfile.hxx>
40 : :
41 : :
42 : : #include <xcreator.hxx>
43 : : #include <dummyobject.hxx>
44 : :
45 : :
46 : : using namespace ::com::sun::star;
47 : :
48 : :
49 : : //-------------------------------------------------------------------------
50 : 25 : uno::Sequence< ::rtl::OUString > SAL_CALL UNOEmbeddedObjectCreator::impl_staticGetSupportedServiceNames()
51 : : {
52 : 25 : uno::Sequence< ::rtl::OUString > aRet(2);
53 [ + - ][ + - ]: 25 : aRet[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.EmbeddedObjectCreator"));
54 [ + - ][ + - ]: 25 : aRet[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.embed.EmbeddedObjectCreator"));
55 : 25 : return aRet;
56 : : }
57 : :
58 : : //-------------------------------------------------------------------------
59 : 50 : ::rtl::OUString SAL_CALL UNOEmbeddedObjectCreator::impl_staticGetImplementationName()
60 : : {
61 : 50 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.embed.EmbeddedObjectCreator"));
62 : : }
63 : :
64 : : //-------------------------------------------------------------------------
65 : 25 : uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::impl_staticCreateSelfInstance(
66 : : const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
67 : : {
68 [ + - ]: 25 : return uno::Reference< uno::XInterface >( *new UNOEmbeddedObjectCreator( xServiceManager ) );
69 : : }
70 : :
71 : : //-------------------------------------------------------------------------
72 : 450 : uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInstanceInitNew(
73 : : const uno::Sequence< sal_Int8 >& aClassID,
74 : : const ::rtl::OUString& aClassName,
75 : : const uno::Reference< embed::XStorage >& xStorage,
76 : : const ::rtl::OUString& sEntName,
77 : : const uno::Sequence< beans::PropertyValue >& lObjArgs )
78 : : throw ( lang::IllegalArgumentException,
79 : : io::IOException,
80 : : uno::Exception,
81 : : uno::RuntimeException)
82 : : {
83 : : RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) UNOEmbeddedObjectCreator::createInstanceInitNew" );
84 : :
85 : 450 : uno::Reference< uno::XInterface > xResult;
86 : :
87 [ - + ]: 450 : if ( !xStorage.is() )
88 : : throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "No parent storage is provided!\n" )),
89 : : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
90 [ # # ][ # # ]: 0 : 3 );
[ # # ]
91 : :
92 [ - + ]: 450 : if ( sEntName.isEmpty() )
93 : : throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Empty element name is provided!\n" )),
94 : : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
95 [ # # ][ # # ]: 0 : 4 );
[ # # ]
96 : :
97 [ + - ]: 450 : ::rtl::OUString aEmbedFactory = m_aConfigHelper.GetFactoryNameByClassID( aClassID );
98 [ - + ]: 450 : if ( aEmbedFactory.isEmpty() )
99 : : {
100 : : // use system fallback
101 : : // TODO: in future users factories can be tested
102 [ # # ]: 0 : aEmbedFactory = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.OLEEmbeddedObjectFactory" ));
103 : : }
104 : :
105 [ + - ][ + - ]: 450 : uno::Reference < uno::XInterface > xFact( m_xFactory->createInstance( aEmbedFactory ) );
106 [ + - ]: 450 : uno::Reference< embed::XEmbedObjectCreator > xEmbCreator( xFact, uno::UNO_QUERY );
107 [ + - ]: 450 : if ( xEmbCreator.is() )
108 [ + - ][ + - ]: 450 : return xEmbCreator->createInstanceInitNew( aClassID, aClassName, xStorage, sEntName, lObjArgs );
109 : :
110 [ # # ]: 0 : uno::Reference < embed::XEmbedObjectFactory > xEmbFact( xFact, uno::UNO_QUERY );
111 [ # # ]: 0 : if ( !xEmbFact.is() )
112 [ # # ]: 0 : throw uno::RuntimeException();
113 [ # # ][ # # ]: 450 : return xEmbFact->createInstanceUserInit( aClassID, aClassName, xStorage, sEntName, embed::EntryInitModes::TRUNCATE_INIT, uno::Sequence < beans::PropertyValue >(), lObjArgs);
[ # # ][ # # ]
114 : : }
115 : :
116 : : //-------------------------------------------------------------------------
117 : 13 : uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInstanceInitFromEntry(
118 : : const uno::Reference< embed::XStorage >& xStorage,
119 : : const ::rtl::OUString& sEntName,
120 : : const uno::Sequence< beans::PropertyValue >& aMedDescr,
121 : : const uno::Sequence< beans::PropertyValue >& lObjArgs )
122 : : throw ( lang::IllegalArgumentException,
123 : : container::NoSuchElementException,
124 : : io::IOException,
125 : : uno::Exception,
126 : : uno::RuntimeException)
127 : : {
128 : : RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) UNOEmbeddedObjectCreator::createInstanceInitFromEntry" );
129 : :
130 [ - + ]: 13 : if ( !xStorage.is() )
131 : : throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "No parent storage is provided!\n" )),
132 : : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
133 [ # # ][ # # ]: 0 : 1 );
[ # # ]
134 : :
135 [ + + ]: 13 : if ( sEntName.isEmpty() )
136 : : throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Empty element name is provided!\n" )),
137 : : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
138 [ + - ][ + - ]: 2 : 2 );
[ + - ]
139 : :
140 [ + - ]: 11 : uno::Reference< container::XNameAccess > xNameAccess( xStorage, uno::UNO_QUERY );
141 [ - + ]: 11 : if ( !xNameAccess.is() )
142 [ # # ]: 0 : throw uno::RuntimeException(); //TODO
143 : :
144 : : // detect entry existence
145 [ + - ][ + - ]: 11 : if ( !xNameAccess->hasByName( sEntName ) )
[ - + ]
146 [ # # ]: 0 : throw container::NoSuchElementException();
147 : :
148 : 11 : ::rtl::OUString aMediaType;
149 : 11 : ::rtl::OUString aEmbedFactory;
150 [ + - ][ + + ]: 11 : if ( xStorage->isStorageElement( sEntName ) )
[ + - ]
151 : : {
152 : : // the object must be based on storage
153 : : uno::Reference< embed::XStorage > xSubStorage =
154 [ + - ][ + - ]: 2 : xStorage->openStorageElement( sEntName, embed::ElementModes::READ );
155 : :
156 [ + - ]: 2 : uno::Reference< beans::XPropertySet > xPropSet( xSubStorage, uno::UNO_QUERY );
157 [ - + ]: 2 : if ( !xPropSet.is() )
158 [ # # ]: 0 : throw uno::RuntimeException();
159 : :
160 : : try {
161 [ + - ][ + - ]: 2 : uno::Any aAny = xPropSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ));
[ + - ][ # # ]
162 : 2 : aAny >>= aMediaType;
163 : : }
164 [ # # ]: 0 : catch ( const uno::Exception& )
165 : : {
166 : : }
167 : :
168 : : try {
169 [ + - ]: 2 : uno::Reference< lang::XComponent > xComp( xSubStorage, uno::UNO_QUERY );
170 [ + - ]: 2 : if ( xComp.is() )
171 [ + - ][ + - ]: 2 : xComp->dispose();
[ # # ]
172 : : }
173 [ # # ]: 0 : catch ( const uno::Exception& )
174 : : {
175 : 2 : }
176 : : }
177 : : else
178 : : {
179 : : // the object must be based on stream
180 : : // it means for now that this is an OLE object
181 : :
182 : : // the object will be created as embedded object
183 : : // after it is loaded it can detect that it is a link
184 : :
185 : : uno::Reference< io::XStream > xSubStream =
186 [ + - ][ + - ]: 9 : xStorage->openStreamElement( sEntName, embed::ElementModes::READ );
187 : :
188 [ + - ]: 9 : uno::Reference< beans::XPropertySet > xPropSet( xSubStream, uno::UNO_QUERY );
189 [ - + ]: 9 : if ( !xPropSet.is() )
190 [ # # ]: 0 : throw uno::RuntimeException();
191 : :
192 : : try {
193 [ + - ][ + - ]: 9 : uno::Any aAny = xPropSet->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ));
[ + - ]
194 : 9 : aAny >>= aMediaType;
195 [ + - ]: 9 : if ( aMediaType == "application/vnd.sun.star.oleobject" )
196 [ + - ][ # # ]: 9 : aEmbedFactory = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.OLEEmbeddedObjectFactory" ) );
197 : : }
198 [ # # ]: 0 : catch ( const uno::Exception& )
199 : : {
200 : : }
201 : :
202 : : try {
203 [ + - ]: 9 : uno::Reference< lang::XComponent > xComp( xSubStream, uno::UNO_QUERY );
204 [ + - ]: 9 : if ( xComp.is() )
205 [ + - ][ + - ]: 9 : xComp->dispose();
[ # # ]
206 : : }
207 [ # # ]: 0 : catch ( const uno::Exception& )
208 : : {
209 : 9 : }
210 : : }
211 : :
212 : : OSL_ENSURE( !aMediaType.isEmpty(), "No media type is specified for the object!" );
213 [ + - ][ + + ]: 11 : if ( !aMediaType.isEmpty() && aEmbedFactory.isEmpty() )
[ + + ]
214 [ + - ]: 2 : aEmbedFactory = m_aConfigHelper.GetFactoryNameByMediaType( aMediaType );
215 : :
216 [ + - ]: 11 : if ( !aEmbedFactory.isEmpty() )
217 : : {
218 [ + - ][ + - ]: 11 : uno::Reference< uno::XInterface > xFact = m_xFactory->createInstance( aEmbedFactory );
219 : :
220 [ + - ]: 11 : uno::Reference< embed::XEmbedObjectCreator > xEmbCreator( xFact, uno::UNO_QUERY );
221 [ + + ]: 11 : if ( xEmbCreator.is() )
222 [ + - ][ + - ]: 2 : return xEmbCreator->createInstanceInitFromEntry( xStorage, sEntName, aMedDescr, lObjArgs );
223 : :
224 [ + - ]: 9 : uno::Reference < embed::XEmbedObjectFactory > xEmbFact( xFact, uno::UNO_QUERY );
225 [ - + ]: 9 : if ( xEmbFact.is() )
226 [ # # ][ # # ]: 11 : return xEmbFact->createInstanceUserInit( uno::Sequence< sal_Int8 >(), ::rtl::OUString(), xStorage, sEntName, embed::EntryInitModes::DEFAULT_INIT, aMedDescr, lObjArgs);
[ # # ][ # # ]
[ - + ][ + + ]
[ + + ]
227 : : }
228 : :
229 : : // the default object should be created, it will allow to store the contents on the next saving
230 [ + - ][ + - ]: 9 : uno::Reference< uno::XInterface > xResult( static_cast< cppu::OWeakObject* >( new ODummyEmbeddedObject() ) );
231 [ + - ]: 9 : uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW );
232 [ + - ][ + - ]: 9 : xPersist->setPersistentEntry( xStorage, sEntName, embed::EntryInitModes::DEFAULT_INIT, aMedDescr, lObjArgs );
233 : 13 : return xResult;
234 : : }
235 : :
236 : : //-------------------------------------------------------------------------
237 : 18 : uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInstanceInitFromMediaDescriptor(
238 : : const uno::Reference< embed::XStorage >& xStorage,
239 : : const ::rtl::OUString& sEntName,
240 : : const uno::Sequence< beans::PropertyValue >& aMediaDescr,
241 : : const uno::Sequence< beans::PropertyValue >& lObjArgs )
242 : : throw ( lang::IllegalArgumentException,
243 : : io::IOException,
244 : : uno::Exception,
245 : : uno::RuntimeException)
246 : : {
247 : : RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) UNOEmbeddedObjectCreator::createInstanceInitFromMediaDescriptor" );
248 : :
249 : : // TODO: use lObjArgs
250 : :
251 [ - + ]: 18 : if ( !xStorage.is() )
252 : : throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "No parent storage is provided!\n" )),
253 : : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
254 [ # # ][ # # ]: 0 : 1 );
[ # # ]
255 : :
256 [ - + ]: 18 : if ( sEntName.isEmpty() )
257 : : throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Empty element name is provided!\n" )),
258 : : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
259 [ # # ][ # # ]: 0 : 2 );
[ # # ]
260 : :
261 : 18 : uno::Reference< uno::XInterface > xResult;
262 [ + - ]: 18 : uno::Sequence< beans::PropertyValue > aTempMedDescr( aMediaDescr );
263 : :
264 : : // check if there is FilterName
265 [ + - ]: 18 : ::rtl::OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, sal_False );
266 : :
267 [ + + ]: 18 : if ( !aFilterName.isEmpty() )
268 : : {
269 : : // the object can be loaded by one of the office application
270 : : uno::Reference< embed::XEmbedObjectCreator > xOOoEmbCreator(
271 [ + - ]: 9 : m_xFactory->createInstance(
272 : 9 : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.OOoEmbeddedObjectFactory" ) )),
273 [ + - ][ + - ]: 9 : uno::UNO_QUERY );
[ + - ]
274 [ - + ]: 9 : if ( !xOOoEmbCreator.is() )
275 [ # # ]: 0 : throw uno::RuntimeException(); // TODO:
276 : :
277 [ + - ]: 9 : xResult = xOOoEmbCreator->createInstanceInitFromMediaDescriptor( xStorage,
278 : : sEntName,
279 : : aTempMedDescr,
280 [ - + ][ # # ]: 9 : lObjArgs );
281 : : }
282 : : else
283 : : {
284 : : // must be an OLE object
285 : :
286 : : // TODO: in future, when more object types are possible this place seems
287 : : // to be a weak one, probably configuration must provide a type detection service
288 : : // for every factory, so any file could go through services until it is recognized
289 : : // or there is no more services
290 : : // Or for example the typename can be used to detect object type if typedetection
291 : : // was also extended.
292 : :
293 : : uno::Reference< embed::XEmbedObjectCreator > xOleEmbCreator(
294 [ + - ]: 9 : m_xFactory->createInstance(
295 : 9 : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.OLEEmbeddedObjectFactory" ) )),
296 [ + - ][ + - ]: 9 : uno::UNO_QUERY );
[ + - ]
297 [ + - ]: 9 : if ( !xOleEmbCreator.is() )
298 [ + - ]: 9 : throw uno::RuntimeException(); // TODO:
299 : :
300 [ # # ][ # # ]: 9 : xResult = xOleEmbCreator->createInstanceInitFromMediaDescriptor( xStorage, sEntName, aTempMedDescr, lObjArgs );
[ # # ]
301 : : }
302 : :
303 [ # # ]: 18 : return xResult;
304 : : }
305 : :
306 : : //-------------------------------------------------------------------------
307 : 0 : uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInstanceUserInit(
308 : : const uno::Sequence< sal_Int8 >& aClassID,
309 : : const ::rtl::OUString& sClassName,
310 : : const uno::Reference< embed::XStorage >& xStorage,
311 : : const ::rtl::OUString& sEntName,
312 : : sal_Int32 nEntryConnectionMode,
313 : : const uno::Sequence< beans::PropertyValue >& aArgs,
314 : : const uno::Sequence< beans::PropertyValue >& aObjectArgs )
315 : : throw ( lang::IllegalArgumentException,
316 : : io::IOException,
317 : : uno::Exception,
318 : : uno::RuntimeException)
319 : : {
320 : : RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) UNOEmbeddedObjectCreator::createInstanceUserInit" );
321 : :
322 : 0 : uno::Reference< uno::XInterface > xResult;
323 : :
324 [ # # ]: 0 : if ( !xStorage.is() )
325 : : throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "No parent storage is provided!\n" )),
326 : : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
327 [ # # ][ # # ]: 0 : 3 );
[ # # ]
328 : :
329 [ # # ]: 0 : if ( sEntName.isEmpty() )
330 : : throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Empty element name is provided!\n" )),
331 : : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
332 [ # # ][ # # ]: 0 : 4 );
[ # # ]
333 : :
334 [ # # ]: 0 : ::rtl::OUString aEmbedFactory = m_aConfigHelper.GetFactoryNameByClassID( aClassID );
335 : : uno::Reference< embed::XEmbedObjectFactory > xEmbFactory(
336 [ # # ]: 0 : m_xFactory->createInstance( aEmbedFactory ),
337 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
338 [ # # ]: 0 : if ( !xEmbFactory.is() )
339 [ # # ]: 0 : throw uno::RuntimeException(); // TODO:
340 : :
341 [ # # ]: 0 : return xEmbFactory->createInstanceUserInit( aClassID,
342 : : sClassName,
343 : : xStorage,
344 : : sEntName,
345 : : nEntryConnectionMode,
346 : : aArgs,
347 [ # # ]: 0 : aObjectArgs );
348 : : }
349 : :
350 : : //-------------------------------------------------------------------------
351 : 0 : uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInstanceLink(
352 : : const uno::Reference< embed::XStorage >& xStorage,
353 : : const ::rtl::OUString& sEntName,
354 : : const uno::Sequence< beans::PropertyValue >& aMediaDescr,
355 : : const uno::Sequence< beans::PropertyValue >& lObjArgs )
356 : : throw ( lang::IllegalArgumentException,
357 : : io::IOException,
358 : : uno::Exception,
359 : : uno::RuntimeException )
360 : : {
361 : : RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) UNOEmbeddedObjectCreator::createInstanceLink" );
362 : :
363 : 0 : uno::Reference< uno::XInterface > xResult;
364 : :
365 [ # # ]: 0 : uno::Sequence< beans::PropertyValue > aTempMedDescr( aMediaDescr );
366 : :
367 : : // check if there is URL, URL must exist
368 : 0 : ::rtl::OUString aURL;
369 [ # # ]: 0 : for ( sal_Int32 nInd = 0; nInd < aTempMedDescr.getLength(); nInd++ )
370 [ # # ][ # # ]: 0 : if ( aTempMedDescr[nInd].Name == "URL" )
371 [ # # ]: 0 : aTempMedDescr[nInd].Value >>= aURL;
372 : :
373 [ # # ]: 0 : if ( aURL.isEmpty() )
374 : : throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "No URL for the link is provided!\n" )),
375 : : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
376 [ # # ][ # # ]: 0 : 3 );
[ # # ]
377 : :
378 [ # # ]: 0 : ::rtl::OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, sal_False );
379 : :
380 [ # # ]: 0 : if ( !aFilterName.isEmpty() )
381 : : {
382 : : // the object can be loaded by one of the office application
383 : : uno::Reference< embed::XLinkCreator > xOOoLinkCreator(
384 [ # # ]: 0 : m_xFactory->createInstance(
385 : 0 : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.OOoEmbeddedObjectFactory" ) )),
386 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
[ # # ]
387 [ # # ]: 0 : if ( !xOOoLinkCreator.is() )
388 [ # # ]: 0 : throw uno::RuntimeException(); // TODO:
389 : :
390 [ # # ]: 0 : xResult = xOOoLinkCreator->createInstanceLink( xStorage,
391 : : sEntName,
392 : : aTempMedDescr,
393 [ # # ][ # # ]: 0 : lObjArgs );
394 : : }
395 : : else
396 : : {
397 : : // must be an OLE link
398 : :
399 : : // TODO: in future, when more object types are possible this place seems
400 : : // to be a weak one, probably configuration must provide a type detection service
401 : : // for every factory, so any file could go through services until it is recognized
402 : : // or there is no more services
403 : : // Or for example the typename can be used to detect object type if typedetection
404 : : // was also extended.
405 : :
406 [ # # ]: 0 : if ( !xStorage.is() )
407 : : throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "No parent storage is provided!\n" )),
408 : : uno::Reference< uno::XInterface >(
409 : : static_cast< ::cppu::OWeakObject* >(this) ),
410 [ # # ][ # # ]: 0 : 3 );
[ # # ]
411 : :
412 [ # # ]: 0 : if ( sEntName.isEmpty() )
413 : : throw lang::IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Empty element name is provided!\n" )),
414 : : uno::Reference< uno::XInterface >(
415 : : static_cast< ::cppu::OWeakObject* >(this) ),
416 [ # # ][ # # ]: 0 : 4 );
[ # # ]
417 : :
418 : : uno::Reference< embed::XLinkCreator > xLinkCreator(
419 [ # # ]: 0 : m_xFactory->createInstance(
420 : 0 : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.OLEEmbeddedObjectFactory" ) )),
421 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
[ # # ]
422 [ # # ]: 0 : if ( !xLinkCreator.is() )
423 [ # # ]: 0 : throw uno::RuntimeException(); // TODO:
424 : :
425 [ # # ][ # # ]: 0 : xResult = xLinkCreator->createInstanceLink( xStorage, sEntName, aTempMedDescr, lObjArgs );
[ # # ]
426 : : }
427 : :
428 [ # # ]: 0 : return xResult;
429 : : }
430 : :
431 : : //-------------------------------------------------------------------------
432 : 0 : uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInstanceLinkUserInit(
433 : : const uno::Sequence< sal_Int8 >& aClassID,
434 : : const ::rtl::OUString& aClassName,
435 : : const uno::Reference< embed::XStorage >& xStorage,
436 : : const ::rtl::OUString& sEntName,
437 : : const uno::Sequence< beans::PropertyValue >& lArguments,
438 : : const uno::Sequence< beans::PropertyValue >& lObjArgs )
439 : : throw ( lang::IllegalArgumentException,
440 : : io::IOException,
441 : : uno::Exception,
442 : : uno::RuntimeException )
443 : : {
444 : : RTL_LOGFILE_CONTEXT( aLog, "embeddedobj (mv76033) UNOEmbeddedObjectCreator::createInstanceLinkUserInit" );
445 : :
446 : 0 : uno::Reference< uno::XInterface > xResult;
447 : :
448 [ # # ]: 0 : ::rtl::OUString aEmbedFactory = m_aConfigHelper.GetFactoryNameByClassID( aClassID );
449 : : uno::Reference< embed::XLinkFactory > xLinkFactory(
450 [ # # ]: 0 : m_xFactory->createInstance( aEmbedFactory ),
451 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
452 [ # # ]: 0 : if ( !xLinkFactory.is() )
453 [ # # ]: 0 : throw uno::RuntimeException(); // TODO:
454 : :
455 [ # # ]: 0 : return xLinkFactory->createInstanceLinkUserInit( aClassID,
456 : : aClassName,
457 : : xStorage,
458 : : sEntName,
459 : : lArguments,
460 [ # # ]: 0 : lObjArgs );
461 : :
462 : : }
463 : :
464 : : //-------------------------------------------------------------------------
465 : 0 : ::rtl::OUString SAL_CALL UNOEmbeddedObjectCreator::getImplementationName()
466 : : throw ( uno::RuntimeException )
467 : : {
468 : 0 : return impl_staticGetImplementationName();
469 : : }
470 : :
471 : : //-------------------------------------------------------------------------
472 : 0 : sal_Bool SAL_CALL UNOEmbeddedObjectCreator::supportsService( const ::rtl::OUString& ServiceName )
473 : : throw ( uno::RuntimeException )
474 : : {
475 [ # # ]: 0 : uno::Sequence< ::rtl::OUString > aSeq = impl_staticGetSupportedServiceNames();
476 : :
477 [ # # ]: 0 : for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
478 [ # # ][ # # ]: 0 : if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
479 : 0 : return sal_True;
480 : :
481 [ # # ]: 0 : return sal_False;
482 : : }
483 : :
484 : : //-------------------------------------------------------------------------
485 : 0 : uno::Sequence< ::rtl::OUString > SAL_CALL UNOEmbeddedObjectCreator::getSupportedServiceNames()
486 : : throw ( uno::RuntimeException )
487 : : {
488 : 0 : return impl_staticGetSupportedServiceNames();
489 : : }
490 : :
491 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|