Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : : #include <XTempFile.hxx>
20 : : #include <cppuhelper/factory.hxx>
21 : : #include <cppuhelper/typeprovider.hxx>
22 : : #include <unotools/tempfile.hxx>
23 : : #include <osl/file.hxx>
24 : : #include <unotools/configmgr.hxx>
25 : :
26 : : namespace css = com::sun::star;
27 : :
28 : 4175 : OTempFileService::OTempFileService(::css::uno::Reference< ::css::uno::XComponentContext > const & context)
29 : : : ::cppu::PropertySetMixin< ::css::io::XTempFile >(
30 : : context
31 : : , static_cast< Implements >( IMPLEMENTS_PROPERTY_SET | IMPLEMENTS_FAST_PROPERTY_SET | IMPLEMENTS_PROPERTY_ACCESS )
32 : : , com::sun::star::uno::Sequence< rtl::OUString >() )
33 : : , mpStream( NULL )
34 : : , mbRemoveFile( sal_True )
35 : : , mbInClosed( sal_False )
36 : : , mbOutClosed( sal_False )
37 : : , mnCachedPos( 0 )
38 [ + - ][ + - ]: 4175 : , mbHasCachedPos( sal_False )
[ + - ][ + - ]
39 : :
40 : : {
41 [ + - ][ + - ]: 4175 : mpTempFile = new ::utl::TempFile;
42 : 4175 : mpTempFile->EnableKillingFile ( sal_True );
43 : 4175 : }
44 : :
45 [ + - ][ + - ]: 4090 : OTempFileService::~OTempFileService ()
46 : : {
47 [ + + ]: 4090 : if ( mpTempFile )
48 [ + - ][ + - ]: 3776 : delete mpTempFile;
49 [ - + ]: 8180 : }
50 : :
51 : :
52 : : // XInterface
53 : :
54 : 21357 : ::css::uno::Any SAL_CALL OTempFileService::queryInterface( ::css::uno::Type const & aType )
55 : : throw ( ::css::uno::RuntimeException )
56 : : {
57 : 21357 : ::css::uno::Any aResult( OTempFileBase::queryInterface( aType ) );
58 [ + + ]: 21357 : if (!aResult.hasValue())
59 [ + - ]: 336 : aResult = cppu::PropertySetMixin< ::css::io::XTempFile >::queryInterface( aType ) ;
60 : 21357 : return aResult;
61 : : };
62 : 70409 : void SAL_CALL OTempFileService::acquire( )
63 : : throw ()
64 : : {
65 : 70409 : OTempFileBase::acquire();
66 : 70409 : }
67 : 69984 : void SAL_CALL OTempFileService::release( )
68 : : throw ()
69 : : {
70 : 69984 : OTempFileBase::release();
71 : 69984 : }
72 : :
73 : : // XTypeProvider
74 : :
75 : 0 : ::css::uno::Sequence< ::css::uno::Type > SAL_CALL OTempFileService::getTypes( )
76 : : throw ( ::css::uno::RuntimeException )
77 : : {
78 : : static ::cppu::OTypeCollection* pTypeCollection = NULL;
79 [ # # ]: 0 : if ( pTypeCollection == NULL )
80 : : {
81 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ) ;
82 : :
83 [ # # ]: 0 : if ( pTypeCollection == NULL )
84 : : {
85 : : static ::cppu::OTypeCollection aTypeCollection(
86 [ # # ]: 0 : ::getCppuType( ( const ::css::uno::Reference< ::css::beans::XPropertySet >*)NULL )
87 [ # # ][ # # ]: 0 : ,OTempFileBase::getTypes() );
[ # # ][ # # ]
[ # # ][ # # ]
88 : 0 : pTypeCollection = &aTypeCollection;
89 [ # # ]: 0 : }
90 : : }
91 : 0 : return pTypeCollection->getTypes();
92 : : };
93 : 0 : ::css::uno::Sequence< sal_Int8 > SAL_CALL OTempFileService::getImplementationId( )
94 : : throw ( ::css::uno::RuntimeException )
95 : : {
96 : 0 : return OTempFileBase::getImplementationId();
97 : : }
98 : :
99 : : // XTempFile
100 : :
101 : 0 : sal_Bool SAL_CALL OTempFileService::getRemoveFile()
102 : : throw ( ::css::uno::RuntimeException )
103 : : {
104 [ # # ]: 0 : ::osl::MutexGuard aGuard( maMutex );
105 : :
106 [ # # ]: 0 : if ( !mpTempFile )
107 : : {
108 : : // the stream is already disconnected
109 [ # # ]: 0 : throw ::css::uno::RuntimeException();
110 : : }
111 : :
112 [ # # ]: 0 : return mbRemoveFile;
113 : : };
114 : 97 : void SAL_CALL OTempFileService::setRemoveFile( sal_Bool _removefile )
115 : : throw ( ::css::uno::RuntimeException )
116 : : {
117 [ + - ]: 97 : ::osl::MutexGuard aGuard( maMutex );
118 : :
119 [ - + ]: 97 : if ( !mpTempFile )
120 : : {
121 : : // the stream is already disconnected
122 [ # # ]: 0 : throw ::css::uno::RuntimeException();
123 : : }
124 : :
125 : 97 : mbRemoveFile = _removefile;
126 [ + - ]: 97 : mpTempFile->EnableKillingFile( mbRemoveFile );
127 : 97 : };
128 : 87 : ::rtl::OUString SAL_CALL OTempFileService::getUri()
129 : : throw ( ::css::uno::RuntimeException )
130 : : {
131 [ + - ]: 87 : ::osl::MutexGuard aGuard( maMutex );
132 : :
133 [ - + ]: 87 : if ( !mpTempFile )
134 : : {
135 [ # # ]: 0 : throw ::css::uno::RuntimeException();
136 : : }
137 : :
138 [ + - ][ + - ]: 87 : return ::rtl::OUString( mpTempFile->GetURL() );
[ + - ][ + - ]
139 : :
140 : : };
141 : 2 : ::rtl::OUString SAL_CALL OTempFileService::getResourceName()
142 : : throw ( ::css::uno::RuntimeException )
143 : : {
144 [ + - ]: 2 : ::osl::MutexGuard aGuard( maMutex );
145 : :
146 [ - + ]: 2 : if ( !mpTempFile )
147 : : {
148 [ # # ]: 0 : throw ::css::uno::RuntimeException();
149 : : }
150 : :
151 [ + - ][ + - ]: 2 : return ::rtl::OUString( mpTempFile->GetFileName() );
[ + - ][ + - ]
152 : : };
153 : :
154 : :
155 : :
156 : : // XInputStream
157 : :
158 : 36623 : sal_Int32 SAL_CALL OTempFileService::readBytes( ::css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
159 : : throw (::css::io::NotConnectedException, ::css::io::BufferSizeExceededException, ::css::io::IOException, ::css::uno::RuntimeException )
160 : : {
161 [ + - ]: 36623 : ::osl::MutexGuard aGuard( maMutex );
162 [ - + ]: 36623 : if ( mbInClosed )
163 [ # # ][ # # ]: 0 : throw ::css::io::NotConnectedException ( ::rtl::OUString(), const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * > (this ) ) );
164 : :
165 [ + - ]: 36623 : checkConnected();
166 [ - + ]: 36623 : if (nBytesToRead < 0)
167 [ # # ][ # # ]: 0 : throw ::css::io::BufferSizeExceededException( ::rtl::OUString(), static_cast< ::css::uno::XWeak * >(this));
168 : :
169 [ + - ]: 36623 : aData.realloc(nBytesToRead);
170 : :
171 [ + - ][ + - ]: 36623 : sal_uInt32 nRead = mpStream->Read(static_cast < void* > ( aData.getArray() ), nBytesToRead);
172 [ + - ]: 36623 : checkError();
173 : :
174 [ + + ]: 36623 : if (nRead < static_cast < sal_uInt32 > ( nBytesToRead ) )
175 [ + - ]: 1380 : aData.realloc( nRead );
176 : :
177 [ + + ]: 36623 : if ( sal::static_int_cast<sal_uInt32>(nBytesToRead) > nRead )
178 : : {
179 : : // usually that means that the stream was read till the end
180 : : // TODO/LATER: it is better to get rid of this optimization by avoiding using of multiple temporary files ( there should be only one temporary file? )
181 : 1380 : mnCachedPos = mpStream->Tell();
182 : 1380 : mbHasCachedPos = sal_True;
183 : :
184 : 1380 : mpStream = NULL;
185 [ + - ]: 1380 : if ( mpTempFile )
186 [ + - ]: 1380 : mpTempFile->CloseStream();
187 : : }
188 : :
189 [ + - ]: 36623 : return nRead;
190 : : }
191 : 0 : sal_Int32 SAL_CALL OTempFileService::readSomeBytes( ::css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
192 : : throw ( ::css::io::NotConnectedException, ::css::io::BufferSizeExceededException, ::css::io::IOException, ::css::uno::RuntimeException )
193 : : {
194 [ # # ]: 0 : ::osl::MutexGuard aGuard( maMutex );
195 [ # # ]: 0 : if ( mbInClosed )
196 [ # # ][ # # ]: 0 : throw ::css::io::NotConnectedException ( ::rtl::OUString(), const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * > (this ) ) );
197 : :
198 [ # # ]: 0 : checkConnected();
199 [ # # ]: 0 : checkError();
200 : :
201 [ # # ]: 0 : if (nMaxBytesToRead < 0)
202 [ # # ][ # # ]: 0 : throw ::css::io::BufferSizeExceededException( ::rtl::OUString(), static_cast < ::css::uno::XWeak * >( this ) );
203 : :
204 [ # # ]: 0 : if (mpStream->IsEof())
205 : : {
206 [ # # ]: 0 : aData.realloc(0);
207 : 0 : return 0;
208 : : }
209 : : else
210 [ # # ][ # # ]: 0 : return readBytes(aData, nMaxBytesToRead);
211 : : }
212 : 0 : void SAL_CALL OTempFileService::skipBytes( sal_Int32 nBytesToSkip )
213 : : throw ( ::css::io::NotConnectedException, ::css::io::BufferSizeExceededException, ::css::io::IOException, ::css::uno::RuntimeException )
214 : : {
215 [ # # ]: 0 : ::osl::MutexGuard aGuard( maMutex );
216 [ # # ]: 0 : if ( mbInClosed )
217 [ # # ][ # # ]: 0 : throw ::css::io::NotConnectedException ( ::rtl::OUString(), const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * > (this ) ) );
218 : :
219 [ # # ]: 0 : checkConnected();
220 [ # # ]: 0 : checkError();
221 [ # # ]: 0 : mpStream->SeekRel(nBytesToSkip);
222 [ # # ][ # # ]: 0 : checkError();
223 : 0 : }
224 : 0 : sal_Int32 SAL_CALL OTempFileService::available( )
225 : : throw ( ::css::io::NotConnectedException, ::css::io::IOException, ::css::uno::RuntimeException )
226 : : {
227 [ # # ]: 0 : ::osl::MutexGuard aGuard( maMutex );
228 [ # # ]: 0 : if ( mbInClosed )
229 [ # # ][ # # ]: 0 : throw ::css::io::NotConnectedException ( ::rtl::OUString(), const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * > (this ) ) );
230 : :
231 [ # # ]: 0 : checkConnected();
232 : :
233 : 0 : sal_uInt32 nPos = mpStream->Tell();
234 [ # # ]: 0 : checkError();
235 : :
236 [ # # ]: 0 : mpStream->Seek(STREAM_SEEK_TO_END);
237 [ # # ]: 0 : checkError();
238 : :
239 : 0 : sal_Int32 nAvailable = (sal_Int32)mpStream->Tell() - nPos;
240 [ # # ]: 0 : mpStream->Seek(nPos);
241 [ # # ]: 0 : checkError();
242 : :
243 [ # # ]: 0 : return nAvailable;
244 : : }
245 : 314 : void SAL_CALL OTempFileService::closeInput( )
246 : : throw ( ::css::io::NotConnectedException, ::css::io::IOException, ::css::uno::RuntimeException )
247 : : {
248 [ + - ]: 314 : ::osl::MutexGuard aGuard( maMutex );
249 [ - + ]: 314 : if ( mbInClosed )
250 [ # # ][ # # ]: 0 : throw ::css::io::NotConnectedException ( ::rtl::OUString(), const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * > (this ) ) );
251 : :
252 : 314 : mbInClosed = sal_True;
253 : :
254 [ + + ]: 314 : if ( mbOutClosed )
255 : : {
256 : : // stream will be deleted by TempFile implementation
257 : 304 : mpStream = NULL;
258 : :
259 [ + - ]: 304 : if ( mpTempFile )
260 : : {
261 [ + - ][ + - ]: 304 : delete mpTempFile;
262 : 304 : mpTempFile = NULL;
263 : : }
264 [ + - ]: 314 : }
265 : 314 : }
266 : :
267 : : // XOutputStream
268 : :
269 : 18740 : void SAL_CALL OTempFileService::writeBytes( const ::css::uno::Sequence< sal_Int8 >& aData )
270 : : throw ( ::css::io::NotConnectedException, ::css::io::BufferSizeExceededException, ::css::io::IOException, ::css::uno::RuntimeException )
271 : : {
272 [ + - ]: 18740 : ::osl::MutexGuard aGuard( maMutex );
273 [ - + ]: 18740 : if ( mbOutClosed )
274 [ # # ][ # # ]: 0 : throw ::css::io::NotConnectedException ( ::rtl::OUString(), const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * > (this ) ) );
275 : :
276 [ + - ]: 18740 : checkConnected();
277 [ + - ]: 18740 : sal_uInt32 nWritten = mpStream->Write(aData.getConstArray(),aData.getLength());
278 [ + - ]: 18740 : checkError();
279 [ - + ]: 18740 : if ( nWritten != (sal_uInt32)aData.getLength())
280 [ # # ][ # # ]: 18740 : throw ::css::io::BufferSizeExceededException( ::rtl::OUString(),static_cast < ::css::uno::XWeak * > ( this ) );
[ + - ]
281 : 18740 : }
282 : 805 : void SAL_CALL OTempFileService::flush( )
283 : : throw ( ::css::io::NotConnectedException, ::css::io::BufferSizeExceededException, ::css::io::IOException, ::css::uno::RuntimeException )
284 : : {
285 [ + - ]: 805 : ::osl::MutexGuard aGuard( maMutex );
286 [ + + ]: 805 : if ( mbOutClosed )
287 [ + - ][ + - ]: 8 : throw ::css::io::NotConnectedException ( ::rtl::OUString(), const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * > (this ) ) );
288 : :
289 [ + + ]: 797 : checkConnected();
290 [ + - ]: 795 : mpStream->Flush();
291 [ + - ][ + - ]: 805 : checkError();
292 : 795 : }
293 : 1230 : void SAL_CALL OTempFileService::closeOutput( )
294 : : throw ( ::css::io::NotConnectedException, ::css::io::BufferSizeExceededException, ::css::io::IOException, ::css::uno::RuntimeException )
295 : : {
296 [ + - ]: 1230 : ::osl::MutexGuard aGuard( maMutex );
297 [ - + ]: 1230 : if ( mbOutClosed )
298 [ # # ][ # # ]: 0 : throw ::css::io::NotConnectedException ( ::rtl::OUString(), const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * > (this ) ) );
299 : :
300 : 1230 : mbOutClosed = sal_True;
301 : :
302 : : // TODO/LATER: it is better to get rid of this optimization by avoiding using of multiple temporary files ( there should be only one temporary file? )
303 [ + + ]: 1230 : if ( mpStream )
304 : : {
305 : 1218 : mnCachedPos = mpStream->Tell();
306 : 1218 : mbHasCachedPos = sal_True;
307 : :
308 : 1218 : mpStream = NULL;
309 [ + - ]: 1218 : if ( mpTempFile )
310 [ + - ]: 1218 : mpTempFile->CloseStream();
311 : : }
312 : :
313 [ + + ]: 1230 : if ( mbInClosed )
314 : : {
315 : : // stream will be deleted by TempFile implementation
316 : 10 : mpStream = NULL;
317 : :
318 [ + - ]: 10 : if ( mpTempFile )
319 : : {
320 [ + - ][ + - ]: 10 : delete mpTempFile;
321 : 10 : mpTempFile = NULL;
322 : : }
323 [ + - ]: 1230 : }
324 : 1230 : }
325 : :
326 : :
327 : 88758 : void OTempFileService::checkError () const
328 : : {
329 [ + - ][ - + ]: 88758 : if (!mpStream || mpStream->SvStream::GetError () != ERRCODE_NONE )
[ - + ]
330 [ # # ][ # # ]: 0 : throw ::css::io::NotConnectedException ( ::rtl::OUString(), const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * > (this ) ) );
331 : 88758 : }
332 : 76663 : void OTempFileService::checkConnected ()
333 : : {
334 [ + + ][ + - ]: 76663 : if (!mpStream && mpTempFile)
335 : : {
336 : 5521 : mpStream = mpTempFile->GetStream( STREAM_STD_READWRITE );
337 [ + + ][ + - ]: 5521 : if ( mpStream && mbHasCachedPos )
338 : : {
339 : 1429 : mpStream->Seek( sal::static_int_cast<sal_Size>(mnCachedPos) );
340 [ + + ]: 1429 : if ( mpStream->SvStream::GetError () == ERRCODE_NONE )
341 : : {
342 : 1427 : mbHasCachedPos = sal_False;
343 : 1427 : mnCachedPos = 0;
344 : : }
345 : : else
346 : : {
347 : 2 : mpStream = NULL;
348 : 2 : mpTempFile->CloseStream();
349 : : }
350 : : }
351 : : }
352 : :
353 [ + + ]: 76663 : if (!mpStream)
354 [ + - ][ + - ]: 2 : throw ::css::io::NotConnectedException ( ::rtl::OUString(), const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * > (this ) ) );
355 : 76661 : }
356 : :
357 : : // XSeekable
358 : :
359 : 7560 : void SAL_CALL OTempFileService::seek( sal_Int64 nLocation )
360 : : throw ( ::css::lang::IllegalArgumentException, ::css::io::IOException, ::css::uno::RuntimeException )
361 : : {
362 [ + - ]: 7560 : ::osl::MutexGuard aGuard( maMutex );
363 [ + - ]: 7560 : checkConnected();
364 [ + - ][ + - ]: 7560 : if ( nLocation < 0 || nLocation > getLength() )
[ - + ][ - + ]
365 [ # # ]: 0 : throw ::css::lang::IllegalArgumentException();
366 : :
367 [ + - ]: 7560 : mpStream->Seek((sal_uInt32) nLocation );
368 [ + - ][ + - ]: 7560 : checkError();
369 : 7560 : }
370 : 846 : sal_Int64 SAL_CALL OTempFileService::getPosition( )
371 : : throw ( ::css::io::IOException, ::css::uno::RuntimeException )
372 : : {
373 [ + - ]: 846 : ::osl::MutexGuard aGuard( maMutex );
374 [ + - ]: 846 : checkConnected();
375 : :
376 : 846 : sal_uInt32 nPos = mpStream->Tell();
377 [ + - ]: 846 : checkError();
378 [ + - ]: 846 : return (sal_Int64)nPos;
379 : : }
380 : 12097 : sal_Int64 SAL_CALL OTempFileService::getLength( )
381 : : throw ( ::css::io::IOException, ::css::uno::RuntimeException )
382 : : {
383 [ + - ]: 12097 : ::osl::MutexGuard aGuard( maMutex );
384 [ + - ]: 12097 : checkConnected();
385 : :
386 : 12097 : sal_uInt32 nCurrentPos = mpStream->Tell();
387 [ + - ]: 12097 : checkError();
388 : :
389 [ + - ]: 12097 : mpStream->Seek(STREAM_SEEK_TO_END);
390 : 12097 : sal_uInt32 nEndPos = mpStream->Tell();
391 [ + - ]: 12097 : mpStream->Seek(nCurrentPos);
392 : :
393 [ + - ]: 12097 : checkError();
394 : :
395 [ + - ]: 12097 : return (sal_Int64)nEndPos;
396 : : }
397 : :
398 : :
399 : : // XStream
400 : :
401 : 3935 : ::css::uno::Reference< ::css::io::XInputStream > SAL_CALL OTempFileService::getInputStream()
402 : : throw ( ::css::uno::RuntimeException )
403 : : {
404 [ + - ]: 3935 : return ::css::uno::Reference< ::css::io::XInputStream >( *this, ::css::uno::UNO_QUERY );
405 : : }
406 : :
407 : 4008 : ::css::uno::Reference< ::css::io::XOutputStream > SAL_CALL OTempFileService::getOutputStream()
408 : : throw ( ::css::uno::RuntimeException )
409 : : {
410 [ + - ]: 4008 : return ::css::uno::Reference< ::css::io::XOutputStream >( *this, ::css::uno::UNO_QUERY );
411 : : }
412 : :
413 : : // XTruncate
414 : :
415 : 0 : void SAL_CALL OTempFileService::truncate()
416 : : throw ( ::css::io::IOException, ::css::uno::RuntimeException )
417 : : {
418 [ # # ]: 0 : ::osl::MutexGuard aGuard( maMutex );
419 [ # # ]: 0 : checkConnected();
420 : : // SetStreamSize() call does not change the position
421 [ # # ]: 0 : mpStream->Seek( 0 );
422 [ # # ]: 0 : mpStream->SetStreamSize( 0 );
423 [ # # ][ # # ]: 0 : checkError();
424 : 0 : }
425 : :
426 : : // XServiceInfo
427 : :
428 : 0 : ::rtl::OUString SAL_CALL OTempFileService::getImplementationName()
429 : : throw ( ::css::uno::RuntimeException )
430 : : {
431 : 0 : return getImplementationName_Static();
432 : : }
433 : :
434 : 0 : sal_Bool SAL_CALL OTempFileService::supportsService( ::rtl::OUString const & rServiceName )
435 : : throw ( ::css::uno::RuntimeException )
436 : : {
437 [ # # ]: 0 : ::css::uno::Sequence< ::rtl::OUString > aServices(getSupportedServiceNames_Static());
438 [ # # ][ # # ]: 0 : return rServiceName == aServices[0];
439 : : }
440 : :
441 : 0 : ::css::uno::Sequence < ::rtl::OUString > SAL_CALL OTempFileService::getSupportedServiceNames()
442 : : throw ( ::css::uno::RuntimeException )
443 : : {
444 : 0 : return getSupportedServiceNames_Static();
445 : : }
446 : :
447 : :
448 : :
449 : 342 : ::rtl::OUString OTempFileService::getImplementationName_Static ()
450 : : {
451 : 342 : return ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.io.comp.TempFile" ) );
452 : : }
453 : 171 : ::css::uno::Sequence < ::rtl::OUString > OTempFileService::getSupportedServiceNames_Static()
454 : : {
455 : 171 : ::css::uno::Sequence < ::rtl::OUString > aNames ( 1 );
456 [ + - ][ + - ]: 171 : aNames[0] = ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.io.TempFile" ) );
457 : 171 : return aNames;
458 : : }
459 : 4175 : ::css::uno::Reference < ::css::uno::XInterface >SAL_CALL XTempFile_createInstance(
460 : : css::uno::Reference< ::css::uno::XComponentContext > const & context)
461 : : SAL_THROW( ( css::uno::Exception ) )
462 : : {
463 [ + - ]: 4175 : return static_cast< ::cppu::OWeakObject * >( new OTempFileService(context) );
464 : : }
465 : :
466 : 171 : ::css::uno::Reference < ::css::lang::XSingleComponentFactory > OTempFileService::createServiceFactory_Static()
467 : : {
468 [ + - ][ + - ]: 171 : return ::cppu::createSingleComponentFactory( XTempFile_createInstance, getImplementationName_Static(), getSupportedServiceNames_Static() );
469 : : }
470 : :
471 : : /**
472 : : * This function is called to get service factories for an implementation.
473 : : * @param pImplName name of implementation
474 : : * @param pServiceManager generic uno interface providing a service manager to instantiate components
475 : : * @param pRegistryKey registry data key to read and write component persistent data
476 : : * @return a component factory (generic uno interface)
477 : : */
478 : 171 : extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL utl_component_getFactory(
479 : : const sal_Char * pImplName, void * pServiceManager,
480 : : SAL_UNUSED_PARAMETER void * /*pRegistryKey*/ )
481 : : {
482 : 171 : void * pRet = 0;
483 : : ::css::uno::Reference< ::css::lang::XMultiServiceFactory > xSMgr(
484 [ + - ]: 171 : reinterpret_cast< ::css::lang::XMultiServiceFactory * >( pServiceManager ) );
485 : 171 : ::css::uno::Reference< ::css::lang::XSingleComponentFactory > xFactory;
486 : :
487 [ + - ][ + - ]: 171 : if (OTempFileService::getImplementationName_Static().compareToAscii( pImplName ) == 0)
488 [ + - ][ + - ]: 171 : xFactory = OTempFileService::createServiceFactory_Static();
489 : :
490 [ + - ]: 171 : if ( xFactory.is() )
491 : : {
492 [ + - ]: 171 : xFactory->acquire();
493 [ + - ]: 171 : pRet = xFactory.get();
494 : : }
495 : 171 : return pRet;
496 : : }
497 : :
498 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|