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 <osl/security.hxx>
30 : : #include <osl/file.hxx>
31 : : #include <osl/socket.h>
32 : : #include <cppuhelper/factory.hxx>
33 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
34 : : #include <com/sun/star/ucb/FileSystemNotation.hpp>
35 : : #include <com/sun/star/beans/PropertyState.hpp>
36 : : #include "filglob.hxx"
37 : : #include "filid.hxx"
38 : : #include "shell.hxx"
39 : : #include "bc.hxx"
40 : : #include "prov.hxx"
41 : :
42 : :
43 : : using namespace fileaccess;
44 : : using namespace com::sun::star;
45 : : using namespace com::sun::star::uno;
46 : : using namespace com::sun::star::lang;
47 : : using namespace com::sun::star::beans;
48 : : using namespace com::sun::star::ucb;
49 : : using namespace com::sun::star::container;
50 : :
51 : : //=========================================================================
52 : 242 : extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL ucpfile_component_getFactory(
53 : : const sal_Char * pImplName, void * pServiceManager, void * )
54 : : {
55 : 242 : void * pRet = 0;
56 : :
57 : : Reference< XMultiServiceFactory > xSMgr(
58 [ + - ]: 242 : reinterpret_cast< XMultiServiceFactory * >( pServiceManager ) );
59 : 242 : Reference< XSingleServiceFactory > xFactory;
60 : :
61 : : //////////////////////////////////////////////////////////////////////
62 : : // File Content Provider.
63 : : //////////////////////////////////////////////////////////////////////
64 : :
65 [ + - ]: 242 : if ( fileaccess::shell::getImplementationName_static().
66 [ + - ]: 242 : compareToAscii( pImplName ) == 0 )
67 : : {
68 [ + - ][ + - ]: 242 : xFactory = FileProvider::createServiceFactory( xSMgr );
69 : : }
70 : :
71 : : //////////////////////////////////////////////////////////////////////
72 : :
73 [ + - ]: 242 : if ( xFactory.is() )
74 : : {
75 [ + - ]: 242 : xFactory->acquire();
76 [ + - ]: 242 : pRet = xFactory.get();
77 : : }
78 : :
79 : 242 : return pRet;
80 : : }
81 : :
82 : : /****************************************************************************/
83 : : /* */
84 : : /* */
85 : : /* FileProvider */
86 : : /* */
87 : : /* */
88 : : /****************************************************************************/
89 : :
90 : :
91 : :
92 : 1050 : FileProvider::FileProvider( const Reference< XMultiServiceFactory >& xMultiServiceFactory )
93 : : : m_xMultiServiceFactory( xMultiServiceFactory ),
94 [ + - ]: 1050 : m_pMyShell( 0 )
95 : : {
96 : 1050 : }
97 : :
98 : :
99 [ + - ]: 936 : FileProvider::~FileProvider()
100 : : {
101 [ + + ]: 936 : if( m_pMyShell )
102 [ + - ][ + - ]: 638 : delete m_pMyShell;
103 [ - + ]: 1872 : }
104 : :
105 : :
106 : : //////////////////////////////////////////////////////////////////////////
107 : : // XInterface
108 : : //////////////////////////////////////////////////////////////////////////
109 : :
110 : : void SAL_CALL
111 : 703107 : FileProvider::acquire(
112 : : void )
113 : : throw()
114 : : {
115 : 703107 : OWeakObject::acquire();
116 : 703107 : }
117 : :
118 : :
119 : : void SAL_CALL
120 : 702677 : FileProvider::release(
121 : : void )
122 : : throw()
123 : : {
124 : 702677 : OWeakObject::release();
125 : 702677 : }
126 : :
127 : :
128 : : Any SAL_CALL
129 : 120143 : FileProvider::queryInterface(
130 : : const Type& rType )
131 : : throw( RuntimeException )
132 : : {
133 : : Any aRet = cppu::queryInterface(
134 : : rType,
135 : : (static_cast< XContentProvider* >(this)),
136 : : (static_cast< XInitialization* >(this)),
137 : : (static_cast< XContentIdentifierFactory* >(this)),
138 : : (static_cast< XServiceInfo* >(this)),
139 : : (static_cast< XTypeProvider* >(this)),
140 : : (static_cast< XFileIdentifierConverter* >(this)),
141 [ + - ]: 120143 : (static_cast< XPropertySet* >(this)) );
142 [ + + ][ + - ]: 120143 : return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
143 : : }
144 : :
145 : : ///////////////////////////////////////////////////////////////////////////////
146 : : // XInitialization
147 : :
148 : 189694 : void SAL_CALL FileProvider::init()
149 : : {
150 [ + + ]: 189694 : if( ! m_pMyShell )
151 [ + - ]: 752 : m_pMyShell = new shell( m_xMultiServiceFactory, this, sal_True );
152 : 189694 : }
153 : :
154 : :
155 : : void SAL_CALL
156 : 0 : FileProvider::initialize(
157 : : const Sequence< Any >& aArguments )
158 : : throw (Exception, RuntimeException)
159 : : {
160 [ # # ]: 0 : if( ! m_pMyShell ) {
161 : 0 : rtl::OUString config;
162 [ # # ][ # # : 0 : if( aArguments.getLength() > 0 &&
# # # # ]
163 : 0 : (aArguments[0] >>= config) &&
164 : 0 : config.compareToAscii("NoConfig") == 0 )
165 [ # # ][ # # ]: 0 : m_pMyShell = new shell( m_xMultiServiceFactory, this, sal_False );
166 : : else
167 [ # # ][ # # ]: 0 : m_pMyShell = new shell( m_xMultiServiceFactory, this, sal_True );
168 : : }
169 : 0 : }
170 : :
171 : :
172 : : ////////////////////////////////////////////////////////////////////////////////
173 : : //
174 : : // XTypeProvider methods.
175 : :
176 : :
177 [ # # ][ # # ]: 0 : XTYPEPROVIDER_IMPL_7( FileProvider,
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
178 : : XTypeProvider,
179 : : XServiceInfo,
180 : : XInitialization,
181 : : XContentIdentifierFactory,
182 : : XPropertySet,
183 : : XFileIdentifierConverter,
184 : : XContentProvider )
185 : :
186 : :
187 : : ////////////////////////////////////////////////////////////////////////////////
188 : : // XServiceInfo methods.
189 : :
190 : : rtl::OUString SAL_CALL
191 : 2 : FileProvider::getImplementationName()
192 : : throw( RuntimeException )
193 : : {
194 : 2 : return fileaccess::shell::getImplementationName_static();
195 : : }
196 : :
197 : :
198 : : sal_Bool SAL_CALL
199 : 0 : FileProvider::supportsService(
200 : : const rtl::OUString& ServiceName )
201 : : throw( RuntimeException )
202 : : {
203 : 0 : return ServiceName == rtl::OUString("com.sun.star.ucb.FileContentProvider");
204 : : }
205 : :
206 : :
207 : : Sequence< rtl::OUString > SAL_CALL
208 : 0 : FileProvider::getSupportedServiceNames(
209 : : void )
210 : : throw( RuntimeException )
211 : : {
212 : 0 : return fileaccess::shell::getSupportedServiceNames_static();
213 : : }
214 : :
215 : :
216 : :
217 : : Reference< XSingleServiceFactory > SAL_CALL
218 : 242 : FileProvider::createServiceFactory(
219 : : const Reference< XMultiServiceFactory >& rxServiceMgr )
220 : : {
221 : : /**
222 : : * Create a single service factory.<BR>
223 : : * Note: The function pointer ComponentInstantiation points to a function throws Exception.
224 : : *
225 : : * @param rServiceManager the service manager used by the implementation.
226 : : * @param rImplementationName the implementation name. An empty string is possible.
227 : : * @param ComponentInstantiation the function pointer to create an object.
228 : : * @param rServiceNames the service supported by the implementation.
229 : : * @return a factory that support the interfaces XServiceProvider, XServiceInfo
230 : : * XSingleServiceFactory and XComponent.
231 : : *
232 : : * @see createOneInstanceFactory
233 : : */
234 : : /*
235 : : * Reference< ::com::sun::star::XSingleServiceFactory > createSingleFactory
236 : : * (
237 : : * const ::com::sun::star::Reference< ::com::sun::star::XMultiServiceFactory > & rServiceManager,
238 : : * const ::rtl::OUString & rImplementationName,
239 : : * ComponentInstantiation pCreateFunction,
240 : :
241 : : * const ::com::sun::star::Sequence< ::rtl::OUString > & rServiceNames
242 : : * );
243 : : */
244 : :
245 : : return Reference< XSingleServiceFactory > ( cppu::createSingleFactory(
246 : : rxServiceMgr,
247 : : fileaccess::shell::getImplementationName_static(),
248 : : FileProvider::CreateInstance,
249 [ + - ][ + - ]: 242 : fileaccess::shell::getSupportedServiceNames_static() ) );
250 : : }
251 : :
252 : : Reference< XInterface > SAL_CALL
253 : 1050 : FileProvider::CreateInstance(
254 : : const Reference< XMultiServiceFactory >& xMultiServiceFactory )
255 : : {
256 [ + - ][ + - ]: 1050 : XServiceInfo* xP = (XServiceInfo*) new FileProvider( xMultiServiceFactory );
257 : 1050 : return Reference< XInterface >::query( xP );
258 : : }
259 : :
260 : :
261 : :
262 : : ////////////////////////////////////////////////////////////////////////////////
263 : : // XContent
264 : : ////////////////////////////////////////////////////////////////////////////////
265 : :
266 : :
267 : : Reference< XContent > SAL_CALL
268 : 93404 : FileProvider::queryContent(
269 : : const Reference< XContentIdentifier >& xIdentifier )
270 : : throw( IllegalIdentifierException,
271 : : RuntimeException)
272 : : {
273 [ + - ]: 93404 : init();
274 : 93404 : rtl::OUString aUnc;
275 [ + - ]: 93404 : sal_Bool err = m_pMyShell->getUnqFromUrl( xIdentifier->getContentIdentifier(),
276 [ + - ][ + - ]: 93404 : aUnc );
277 : :
278 [ - + ]: 93404 : if( err )
279 [ # # ]: 0 : throw IllegalIdentifierException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
280 : :
281 [ + - ][ + - ]: 93404 : return Reference< XContent >( new BaseContent( m_pMyShell,xIdentifier,aUnc ) );
[ + - ]
282 : : }
283 : :
284 : :
285 : :
286 : : sal_Int32 SAL_CALL
287 : 2230 : FileProvider::compareContentIds(
288 : : const Reference< XContentIdentifier >& Id1,
289 : : const Reference< XContentIdentifier >& Id2 )
290 : : throw( RuntimeException )
291 : : {
292 [ + - ]: 2230 : init();
293 [ + - ][ + - ]: 2230 : rtl::OUString aUrl1 = Id1->getContentIdentifier();
294 [ + - ][ + - ]: 2230 : rtl::OUString aUrl2 = Id2->getContentIdentifier();
295 : :
296 : 2230 : sal_Int32 iComp = aUrl1.compareTo( aUrl2 );
297 : :
298 [ + + ]: 2230 : if ( 0 != iComp )
299 : : {
300 : 2228 : rtl::OUString aPath1, aPath2;
301 : :
302 [ + - ]: 2228 : m_pMyShell->getUnqFromUrl( aUrl1, aPath1 );
303 [ + - ]: 2228 : m_pMyShell->getUnqFromUrl( aUrl2, aPath2 );
304 : :
305 : : osl::FileBase::RC error;
306 : 2228 : osl::DirectoryItem aItem1, aItem2;
307 : :
308 [ + - ]: 2228 : error = osl::DirectoryItem::get( aPath1, aItem1 );
309 [ + - ]: 2228 : if ( error == osl::FileBase::E_None )
310 [ + - ]: 2228 : error = osl::DirectoryItem::get( aPath2, aItem2 );
311 : :
312 [ + + ]: 2228 : if ( error != osl::FileBase::E_None )
313 : 24 : return iComp;
314 : :
315 : 2204 : osl::FileStatus aStatus1( osl_FileStatus_Mask_FileURL );
316 : 2204 : osl::FileStatus aStatus2( osl_FileStatus_Mask_FileURL );
317 [ + - ]: 2204 : error = aItem1.getFileStatus( aStatus1 );
318 [ + - ]: 2204 : if ( error == osl::FileBase::E_None )
319 [ + - ]: 2204 : error = aItem2.getFileStatus( aStatus2 );
320 : :
321 [ + - ]: 2204 : if ( error == osl::FileBase::E_None )
322 : : {
323 [ + - ][ + - ]: 2204 : iComp = aStatus1.getFileURL().compareTo( aStatus2.getFileURL() );
324 : :
325 : : // Quick hack for Windows to threat all file systems as case insensitive
326 : : #ifdef WNT
327 : : if ( 0 != iComp )
328 : : {
329 : : error = osl::FileBase::getSystemPathFromFileURL( aStatus1.getFileURL(), aPath1 );
330 : : if ( error == osl::FileBase::E_None )
331 : : error = osl::FileBase::getSystemPathFromFileURL( aStatus2.getFileURL(), aPath2 );
332 : :
333 : : if ( error == osl::FileBase::E_None )
334 : : iComp = rtl_ustr_compareIgnoreAsciiCase( aPath1.getStr(), aPath2.getStr() );
335 : : }
336 : : #endif
337 [ + - ][ + + ]: 2228 : }
[ + - ][ + + ]
[ + + ][ + + ]
338 : : }
339 : :
340 : 2230 : return iComp;
341 : : }
342 : :
343 : :
344 : :
345 : : Reference< XContentIdentifier > SAL_CALL
346 : 94060 : FileProvider::createContentIdentifier(
347 : : const rtl::OUString& ContentId )
348 : : throw( RuntimeException )
349 : : {
350 : 94060 : init();
351 [ + - ]: 94060 : FileContentIdentifier* p = new FileContentIdentifier( m_pMyShell,ContentId,false );
352 [ + - ]: 94060 : return Reference< XContentIdentifier >( p );
353 : : }
354 : :
355 : :
356 : :
357 : : //XPropertySetInfoImpl
358 : :
359 : : class XPropertySetInfoImpl2
360 : : : public cppu::OWeakObject,
361 : : public XPropertySetInfo
362 : : {
363 : : public:
364 : : XPropertySetInfoImpl2();
365 : : ~XPropertySetInfoImpl2();
366 : :
367 : : // XInterface
368 : : virtual Any SAL_CALL
369 : : queryInterface(
370 : : const Type& aType )
371 : : throw( RuntimeException);
372 : :
373 : : virtual void SAL_CALL
374 : : acquire(
375 : : void )
376 : : throw();
377 : :
378 : : virtual void SAL_CALL
379 : : release(
380 : : void )
381 : : throw();
382 : :
383 : :
384 : : virtual Sequence< Property > SAL_CALL
385 : : getProperties(
386 : : void )
387 : : throw( RuntimeException );
388 : :
389 : : virtual Property SAL_CALL
390 : : getPropertyByName(
391 : : const rtl::OUString& aName )
392 : : throw( UnknownPropertyException,
393 : : RuntimeException);
394 : :
395 : : virtual sal_Bool SAL_CALL
396 : : hasPropertyByName( const rtl::OUString& Name )
397 : : throw( RuntimeException );
398 : :
399 : :
400 : : private:
401 : : Sequence< Property > m_seq;
402 : : };
403 : :
404 : :
405 : 2 : XPropertySetInfoImpl2::XPropertySetInfoImpl2()
406 [ + - ]: 2 : : m_seq( 3 )
407 : : {
408 [ + - ]: 2 : m_seq[0] = Property( rtl::OUString("HostName"),
409 : : -1,
410 [ + - ]: 2 : getCppuType( static_cast< rtl::OUString* >( 0 ) ),
411 : 4 : PropertyAttribute::READONLY );
412 : :
413 [ + - ]: 2 : m_seq[1] = Property( rtl::OUString("HomeDirectory"),
414 : : -1,
415 [ + - ]: 2 : getCppuType( static_cast< rtl::OUString* >( 0 ) ),
416 : 4 : PropertyAttribute::READONLY );
417 : :
418 [ + - ]: 2 : m_seq[2] = Property( rtl::OUString("FileSystemNotation"),
419 : : -1,
420 [ + - ]: 2 : getCppuType( static_cast< sal_Int32* >( 0 ) ),
421 : 4 : PropertyAttribute::READONLY );
422 : 2 : }
423 : :
424 : :
425 [ + - ]: 2 : XPropertySetInfoImpl2::~XPropertySetInfoImpl2()
426 : : {
427 : : // nothing
428 [ - + ]: 4 : }
429 : :
430 : :
431 : : void SAL_CALL
432 : 14 : XPropertySetInfoImpl2::acquire(
433 : : void )
434 : : throw()
435 : : {
436 : 14 : OWeakObject::acquire();
437 : 14 : }
438 : :
439 : :
440 : : void SAL_CALL
441 : 14 : XPropertySetInfoImpl2::release(
442 : : void )
443 : : throw()
444 : : {
445 : 14 : OWeakObject::release();
446 : 14 : }
447 : :
448 : :
449 : : Any SAL_CALL
450 : 2 : XPropertySetInfoImpl2::queryInterface(
451 : : const Type& rType )
452 : : throw( RuntimeException )
453 : : {
454 : : Any aRet = cppu::queryInterface( rType,
455 [ + - ]: 2 : (static_cast< XPropertySetInfo* >(this)) );
456 [ - + ][ + - ]: 2 : return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
457 : : }
458 : :
459 : :
460 : : Property SAL_CALL
461 : 0 : XPropertySetInfoImpl2::getPropertyByName(
462 : : const rtl::OUString& aName )
463 : : throw( UnknownPropertyException,
464 : : RuntimeException)
465 : : {
466 [ # # ]: 0 : for( sal_Int32 i = 0; i < m_seq.getLength(); ++i )
467 [ # # ]: 0 : if( m_seq[i].Name == aName )
468 : 0 : return m_seq[i];
469 : :
470 [ # # ]: 0 : throw UnknownPropertyException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
471 : : }
472 : :
473 : :
474 : :
475 : : Sequence< Property > SAL_CALL
476 : 4 : XPropertySetInfoImpl2::getProperties(
477 : : void )
478 : : throw( RuntimeException )
479 : : {
480 : 4 : return m_seq;
481 : : }
482 : :
483 : :
484 : : sal_Bool SAL_CALL
485 : 0 : XPropertySetInfoImpl2::hasPropertyByName(
486 : : const rtl::OUString& aName )
487 : : throw( RuntimeException )
488 : : {
489 [ # # ]: 0 : for( sal_Int32 i = 0; i < m_seq.getLength(); ++i )
490 [ # # ]: 0 : if( m_seq[i].Name == aName )
491 : 0 : return true;
492 : 0 : return false;
493 : : }
494 : :
495 : :
496 : :
497 : :
498 : :
499 : 6 : void SAL_CALL FileProvider::initProperties( void )
500 : : {
501 [ + - ]: 6 : osl::MutexGuard aGuard( m_aMutex );
502 [ + + ]: 6 : if( ! m_xPropertySetInfo.is() )
503 : : {
504 [ + - ]: 2 : osl_getLocalHostname( &m_HostName.pData );
505 : :
506 : : #if defined ( UNX )
507 : 2 : m_FileSystemNotation = FileSystemNotation::UNIX_NOTATION;
508 : : #elif defined( WNT )
509 : : m_FileSystemNotation = FileSystemNotation::DOS_NOTATION;
510 : : #else
511 : : m_FileSystemNotation = FileSystemNotation::UNKNOWN_NOTATION;
512 : : #endif
513 [ + - ]: 2 : osl::Security aSecurity;
514 [ + - ]: 2 : aSecurity.getHomeDir( m_HomeDirectory );
515 : :
516 : : // static const sal_Int32 UNKNOWN_NOTATION = (sal_Int32)0;
517 : : // static const sal_Int32 UNIX_NOTATION = (sal_Int32)1;
518 : : // static const sal_Int32 DOS_NOTATION = (sal_Int32)2;
519 : : // static const sal_Int32 MAC_NOTATION = (sal_Int32)3;
520 : :
521 [ + - ]: 2 : XPropertySetInfoImpl2* p = new XPropertySetInfoImpl2();
522 [ + - ][ + - ]: 2 : m_xPropertySetInfo = Reference< XPropertySetInfo >( p );
[ + - ][ + - ]
523 [ + - ]: 6 : }
524 : 6 : }
525 : :
526 : :
527 : : // XPropertySet
528 : :
529 : : Reference< XPropertySetInfo > SAL_CALL
530 : 4 : FileProvider::getPropertySetInfo( )
531 : : throw( RuntimeException )
532 : : {
533 : 4 : initProperties();
534 : 4 : return m_xPropertySetInfo;
535 : : }
536 : :
537 : :
538 : : void SAL_CALL
539 : 0 : FileProvider::setPropertyValue( const rtl::OUString& aPropertyName,
540 : : const Any& )
541 : : throw( UnknownPropertyException,
542 : : PropertyVetoException,
543 : : IllegalArgumentException,
544 : : WrappedTargetException,
545 : : RuntimeException )
546 : : {
547 [ # # # # : 0 : if( aPropertyName.compareToAscii( "FileSystemNotation" ) == 0 ||
# # ][ # # ]
548 : 0 : aPropertyName.compareToAscii( "HomeDirectory" ) == 0 ||
549 : 0 : aPropertyName.compareToAscii( "HostName" ) == 0 )
550 : 0 : return;
551 : : else
552 [ # # ]: 0 : throw UnknownPropertyException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
553 : : }
554 : :
555 : :
556 : :
557 : : Any SAL_CALL
558 : 2 : FileProvider::getPropertyValue(
559 : : const rtl::OUString& aPropertyName )
560 : : throw( UnknownPropertyException,
561 : : WrappedTargetException,
562 : : RuntimeException )
563 : : {
564 : 2 : initProperties();
565 [ - + ]: 2 : if( aPropertyName.compareToAscii( "FileSystemNotation" ) == 0 )
566 : : {
567 : 0 : Any aAny;
568 [ # # ]: 0 : aAny <<= m_FileSystemNotation;
569 : 0 : return aAny;
570 : : }
571 [ - + ]: 2 : else if( aPropertyName.compareToAscii( "HomeDirectory" ) == 0 )
572 : : {
573 : 0 : Any aAny;
574 [ # # ]: 0 : aAny <<= m_HomeDirectory;
575 : 0 : return aAny;
576 : : }
577 [ + - ]: 2 : else if( aPropertyName.compareToAscii( "HostName" ) == 0 )
578 : : {
579 : 2 : Any aAny;
580 [ + - ]: 2 : aAny <<= m_HostName;
581 : 2 : return aAny;
582 : : }
583 : : else
584 [ # # ]: 2 : throw UnknownPropertyException( ::rtl::OUString( OSL_LOG_PREFIX ), uno::Reference< uno::XInterface >() );
585 : : }
586 : :
587 : :
588 : : void SAL_CALL
589 : 0 : FileProvider::addPropertyChangeListener(
590 : : const rtl::OUString&,
591 : : const Reference< XPropertyChangeListener >& )
592 : : throw( UnknownPropertyException,
593 : : WrappedTargetException,
594 : : RuntimeException)
595 : : {
596 : 0 : return;
597 : : }
598 : :
599 : :
600 : : void SAL_CALL
601 : 0 : FileProvider::removePropertyChangeListener(
602 : : const rtl::OUString&,
603 : : const Reference< XPropertyChangeListener >& )
604 : : throw( UnknownPropertyException,
605 : : WrappedTargetException,
606 : : RuntimeException )
607 : : {
608 : 0 : return;
609 : : }
610 : :
611 : : void SAL_CALL
612 : 0 : FileProvider::addVetoableChangeListener(
613 : : const rtl::OUString&,
614 : : const Reference< XVetoableChangeListener >& )
615 : : throw( UnknownPropertyException,
616 : : WrappedTargetException,
617 : : RuntimeException )
618 : : {
619 : 0 : return;
620 : : }
621 : :
622 : :
623 : : void SAL_CALL
624 : 0 : FileProvider::removeVetoableChangeListener(
625 : : const rtl::OUString&,
626 : : const Reference< XVetoableChangeListener >& )
627 : : throw( UnknownPropertyException,
628 : : WrappedTargetException,
629 : : RuntimeException)
630 : : {
631 : 0 : return;
632 : : }
633 : :
634 : :
635 : :
636 : : // XFileIdentifierConverter
637 : :
638 : : sal_Int32 SAL_CALL
639 : 2 : FileProvider::getFileProviderLocality( const rtl::OUString& BaseURL )
640 : : throw( RuntimeException )
641 : : {
642 : : // If the base URL is a 'file' URL, return 10 (very 'local'), otherwise
643 : : // return -1 (missmatch). What is missing is a fast comparison to ASCII,
644 : : // ignoring case:
645 : 2 : return BaseURL.getLength() >= 5
646 : 4 : && (BaseURL[0] == 'F' || BaseURL[0] == 'f')
647 : 4 : && (BaseURL[1] == 'I' || BaseURL[1] == 'i')
648 : 4 : && (BaseURL[2] == 'L' || BaseURL[2] == 'l')
649 : 4 : && (BaseURL[3] == 'E' || BaseURL[3] == 'e')
650 : 2 : && BaseURL[4] == ':' ?
651 [ + - + - : 20 : 10 : -1;
+ - + - +
- + - + -
+ - + - +
- ]
652 : : }
653 : :
654 : 13496 : rtl::OUString SAL_CALL FileProvider::getFileURLFromSystemPath( const rtl::OUString&,
655 : : const rtl::OUString& SystemPath )
656 : : throw( RuntimeException )
657 : : {
658 : 13496 : rtl::OUString aNormalizedPath;
659 [ - + ][ + - ]: 13496 : if ( osl::FileBase::getFileURLFromSystemPath( SystemPath,aNormalizedPath ) != osl::FileBase::E_None )
660 : 0 : return rtl::OUString();
661 : :
662 : 13496 : return aNormalizedPath;
663 : : }
664 : :
665 : 9721 : rtl::OUString SAL_CALL FileProvider::getSystemPathFromFileURL( const rtl::OUString& URL )
666 : : throw( RuntimeException )
667 : : {
668 : 9721 : rtl::OUString aSystemPath;
669 [ - + ][ + - ]: 9721 : if (osl::FileBase::getSystemPathFromFileURL( URL,aSystemPath ) != osl::FileBase::E_None )
670 : 0 : return rtl::OUString();
671 : :
672 : 9721 : return aSystemPath;
673 : : }
674 : :
675 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|