prov.cxx (421ed02e) prov.cxx (3adbb628)
1/**************************************************************
1/**************************************************************
2 *
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
19 *
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_file.hxx"
26#include <osl/security.hxx>
27#include <osl/file.hxx>

--- 85 unchanged lines hidden (view full) ---

113// XInterface
114//////////////////////////////////////////////////////////////////////////
115
116void SAL_CALL
117FileProvider::acquire(
118 void )
119 throw()
120{
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_file.hxx"
26#include <osl/security.hxx>
27#include <osl/file.hxx>

--- 85 unchanged lines hidden (view full) ---

113// XInterface
114//////////////////////////////////////////////////////////////////////////
115
116void SAL_CALL
117FileProvider::acquire(
118 void )
119 throw()
120{
121 OWeakObject::acquire();
121 OWeakObject::acquire();
122}
123
124
125void SAL_CALL
126FileProvider::release(
127 void )
122}
123
124
125void SAL_CALL
126FileProvider::release(
127 void )
128 throw()
128 throw()
129{
129{
130 OWeakObject::release();
130 OWeakObject::release();
131}
132
133
134Any SAL_CALL
135FileProvider::queryInterface(
136 const Type& rType )
137 throw( RuntimeException )
138{
131}
132
133
134Any SAL_CALL
135FileProvider::queryInterface(
136 const Type& rType )
137 throw( RuntimeException )
138{
139 Any aRet = cppu::queryInterface(
140 rType,
141 SAL_STATIC_CAST( XContentProvider*, this ),
142 SAL_STATIC_CAST( XInitialization*, this ),
143 SAL_STATIC_CAST( XContentIdentifierFactory*, this ),
144 SAL_STATIC_CAST( XServiceInfo*, this ),
145 SAL_STATIC_CAST( XTypeProvider*, this ),
146 SAL_STATIC_CAST( XFileIdentifierConverter*,this ),
147 SAL_STATIC_CAST( XPropertySet*, this ) );
139 Any aRet = cppu::queryInterface(
140 rType,
141 SAL_STATIC_CAST( XContentProvider*, this ),
142 SAL_STATIC_CAST( XInitialization*, this ),
143 SAL_STATIC_CAST( XContentIdentifierFactory*, this ),
144 SAL_STATIC_CAST( XServiceInfo*, this ),
145 SAL_STATIC_CAST( XTypeProvider*, this ),
146 SAL_STATIC_CAST( XFileIdentifierConverter*,this ),
147 SAL_STATIC_CAST( XPropertySet*, this ) );
148 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
149}
150
151///////////////////////////////////////////////////////////////////////////////
152// XInitialization
153
154void SAL_CALL FileProvider::init()
155{
148 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
149}
150
151///////////////////////////////////////////////////////////////////////////////
152// XInitialization
153
154void SAL_CALL FileProvider::init()
155{
156 if( ! m_pMyShell )
157 m_pMyShell = new shell( m_xMultiServiceFactory, this, sal_True );
156 if( ! m_pMyShell )
157 m_pMyShell = new shell( m_xMultiServiceFactory, this, sal_True );
158}
159
160
161void SAL_CALL
158}
159
160
161void SAL_CALL
162FileProvider::initialize(
163 const Sequence< Any >& aArguments )
164 throw (Exception, RuntimeException)
162FileProvider::initialize(
163 const Sequence< Any >& aArguments )
164 throw (Exception, RuntimeException)
165{
165{
166 if( ! m_pMyShell ) {
167 rtl::OUString config;
168 if( aArguments.getLength() > 0 &&
169 (aArguments[0] >>= config) &&
170 config.compareToAscii("NoConfig") == 0 )
171 m_pMyShell = new shell( m_xMultiServiceFactory, this, sal_False );
172 else
173 m_pMyShell = new shell( m_xMultiServiceFactory, this, sal_True );
174 }
166 if( ! m_pMyShell ) {
167 rtl::OUString config;
168 if( aArguments.getLength() > 0 &&
169 (aArguments[0] >>= config) &&
170 config.compareToAscii("NoConfig") == 0 )
171 m_pMyShell = new shell( m_xMultiServiceFactory, this, sal_False );
172 else
173 m_pMyShell = new shell( m_xMultiServiceFactory, this, sal_True );
174 }
175}
176
177
178////////////////////////////////////////////////////////////////////////////////
179//
180// XTypeProvider methods.
181
182
183XTYPEPROVIDER_IMPL_7( FileProvider,
175}
176
177
178////////////////////////////////////////////////////////////////////////////////
179//
180// XTypeProvider methods.
181
182
183XTYPEPROVIDER_IMPL_7( FileProvider,
184 XTypeProvider,
185 XServiceInfo,
186 XInitialization,
187 XContentIdentifierFactory,
184 XTypeProvider,
185 XServiceInfo,
186 XInitialization,
187 XContentIdentifierFactory,
188 XPropertySet,
188 XPropertySet,
189 XFileIdentifierConverter,
190 XContentProvider )
189 XFileIdentifierConverter,
190 XContentProvider )
191
192
193////////////////////////////////////////////////////////////////////////////////
194// XServiceInfo methods.
195
196rtl::OUString SAL_CALL
197FileProvider::getImplementationName()
198 throw( RuntimeException )
199{
200 return fileaccess::shell::getImplementationName_static();
201}
202
203
204sal_Bool SAL_CALL
205FileProvider::supportsService(
206 const rtl::OUString& ServiceName )
191
192
193////////////////////////////////////////////////////////////////////////////////
194// XServiceInfo methods.
195
196rtl::OUString SAL_CALL
197FileProvider::getImplementationName()
198 throw( RuntimeException )
199{
200 return fileaccess::shell::getImplementationName_static();
201}
202
203
204sal_Bool SAL_CALL
205FileProvider::supportsService(
206 const rtl::OUString& ServiceName )
207 throw( RuntimeException )
207 throw( RuntimeException )
208{
208{
209 return ServiceName == rtl::OUString::createFromAscii( "com.sun.star.ucb.FileContentProvider" );
209 return ServiceName == rtl::OUString::createFromAscii( "com.sun.star.ucb.FileContentProvider" );
210}
211
212
213Sequence< rtl::OUString > SAL_CALL
214FileProvider::getSupportedServiceNames(
215 void )
210}
211
212
213Sequence< rtl::OUString > SAL_CALL
214FileProvider::getSupportedServiceNames(
215 void )
216 throw( RuntimeException )
216 throw( RuntimeException )
217{
218 return fileaccess::shell::getSupportedServiceNames_static();
219}
220
221
222
223Reference< XSingleServiceFactory > SAL_CALL
224FileProvider::createServiceFactory(

--- 46 unchanged lines hidden (view full) ---

271
272
273Reference< XContent > SAL_CALL
274FileProvider::queryContent(
275 const Reference< XContentIdentifier >& xIdentifier )
276 throw( IllegalIdentifierException,
277 RuntimeException)
278{
217{
218 return fileaccess::shell::getSupportedServiceNames_static();
219}
220
221
222
223Reference< XSingleServiceFactory > SAL_CALL
224FileProvider::createServiceFactory(

--- 46 unchanged lines hidden (view full) ---

271
272
273Reference< XContent > SAL_CALL
274FileProvider::queryContent(
275 const Reference< XContentIdentifier >& xIdentifier )
276 throw( IllegalIdentifierException,
277 RuntimeException)
278{
279 init();
279 init();
280 rtl::OUString aUnc;
281 sal_Bool err = m_pMyShell->getUnqFromUrl( xIdentifier->getContentIdentifier(),
282 aUnc );
283
280 rtl::OUString aUnc;
281 sal_Bool err = m_pMyShell->getUnqFromUrl( xIdentifier->getContentIdentifier(),
282 aUnc );
283
284 if( err )
284 if( err )
285 throw IllegalIdentifierException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
286
285 throw IllegalIdentifierException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
286
287 return Reference< XContent >( new BaseContent( m_pMyShell,xIdentifier,aUnc ) );
287 return Reference< XContent >( new BaseContent( m_pMyShell,xIdentifier,aUnc ) );
288}
289
290
291
292sal_Int32 SAL_CALL
293FileProvider::compareContentIds(
294 const Reference< XContentIdentifier >& Id1,
295 const Reference< XContentIdentifier >& Id2 )
288}
289
290
291
292sal_Int32 SAL_CALL
293FileProvider::compareContentIds(
294 const Reference< XContentIdentifier >& Id1,
295 const Reference< XContentIdentifier >& Id2 )
296 throw( RuntimeException )
296 throw( RuntimeException )
297{
297{
298 init();
298 init();
299 rtl::OUString aUrl1 = Id1->getContentIdentifier();
300 rtl::OUString aUrl2 = Id2->getContentIdentifier();
301
302 sal_Int32 iComp = aUrl1.compareTo( aUrl2 );
303
304 if ( 0 != iComp )
305 {
299 rtl::OUString aUrl1 = Id1->getContentIdentifier();
300 rtl::OUString aUrl2 = Id2->getContentIdentifier();
301
302 sal_Int32 iComp = aUrl1.compareTo( aUrl2 );
303
304 if ( 0 != iComp )
305 {
306 rtl::OUString aPath1, aPath2;
306 rtl::OUString aPath1, aPath2;
307
307
308 m_pMyShell->getUnqFromUrl( aUrl1, aPath1 );
309 m_pMyShell->getUnqFromUrl( aUrl2, aPath2 );
308 m_pMyShell->getUnqFromUrl( aUrl1, aPath1 );
309 m_pMyShell->getUnqFromUrl( aUrl2, aPath2 );
310
311 osl::FileBase::RC error;
312 osl::DirectoryItem aItem1, aItem2;
313
314 error = osl::DirectoryItem::get( aPath1, aItem1 );
315 if ( error == osl::FileBase::E_None )
316 error = osl::DirectoryItem::get( aPath2, aItem2 );
317

--- 5 unchanged lines hidden (view full) ---

323 error = aItem1.getFileStatus( aStatus1 );
324 if ( error == osl::FileBase::E_None )
325 error = aItem2.getFileStatus( aStatus2 );
326
327 if ( error == osl::FileBase::E_None )
328 {
329 iComp = aStatus1.getFileURL().compareTo( aStatus2.getFileURL() );
330
310
311 osl::FileBase::RC error;
312 osl::DirectoryItem aItem1, aItem2;
313
314 error = osl::DirectoryItem::get( aPath1, aItem1 );
315 if ( error == osl::FileBase::E_None )
316 error = osl::DirectoryItem::get( aPath2, aItem2 );
317

--- 5 unchanged lines hidden (view full) ---

323 error = aItem1.getFileStatus( aStatus1 );
324 if ( error == osl::FileBase::E_None )
325 error = aItem2.getFileStatus( aStatus2 );
326
327 if ( error == osl::FileBase::E_None )
328 {
329 iComp = aStatus1.getFileURL().compareTo( aStatus2.getFileURL() );
330
331// Quick hack for Windows to threat all file systems as case insensitive
331// Quick hack for Windows to treat all file systems as case insensitive
332#ifdef WNT
333 if ( 0 != iComp )
334 {
335 error = osl::FileBase::getSystemPathFromFileURL( aStatus1.getFileURL(), aPath1 );
336 if ( error == osl::FileBase::E_None )
337 error = osl::FileBase::getSystemPathFromFileURL( aStatus2.getFileURL(), aPath2 );
338
339 if ( error == osl::FileBase::E_None )

--- 6 unchanged lines hidden (view full) ---

346 return iComp;
347}
348
349
350
351Reference< XContentIdentifier > SAL_CALL
352FileProvider::createContentIdentifier(
353 const rtl::OUString& ContentId )
332#ifdef WNT
333 if ( 0 != iComp )
334 {
335 error = osl::FileBase::getSystemPathFromFileURL( aStatus1.getFileURL(), aPath1 );
336 if ( error == osl::FileBase::E_None )
337 error = osl::FileBase::getSystemPathFromFileURL( aStatus2.getFileURL(), aPath2 );
338
339 if ( error == osl::FileBase::E_None )

--- 6 unchanged lines hidden (view full) ---

346 return iComp;
347}
348
349
350
351Reference< XContentIdentifier > SAL_CALL
352FileProvider::createContentIdentifier(
353 const rtl::OUString& ContentId )
354 throw( RuntimeException )
354 throw( RuntimeException )
355{
355{
356 init();
356 init();
357 FileContentIdentifier* p = new FileContentIdentifier( m_pMyShell,ContentId,false );
358 return Reference< XContentIdentifier >( p );
359}
360
361
362
363//XPropertySetInfoImpl
364

--- 146 unchanged lines hidden (view full) ---

511
512#if defined ( UNX )
513 m_FileSystemNotation = FileSystemNotation::UNIX_NOTATION;
514#elif defined( WNT ) || defined( OS2 )
515 m_FileSystemNotation = FileSystemNotation::DOS_NOTATION;
516#else
517 m_FileSystemNotation = FileSystemNotation::UNKNOWN_NOTATION;
518#endif
357 FileContentIdentifier* p = new FileContentIdentifier( m_pMyShell,ContentId,false );
358 return Reference< XContentIdentifier >( p );
359}
360
361
362
363//XPropertySetInfoImpl
364

--- 146 unchanged lines hidden (view full) ---

511
512#if defined ( UNX )
513 m_FileSystemNotation = FileSystemNotation::UNIX_NOTATION;
514#elif defined( WNT ) || defined( OS2 )
515 m_FileSystemNotation = FileSystemNotation::DOS_NOTATION;
516#else
517 m_FileSystemNotation = FileSystemNotation::UNKNOWN_NOTATION;
518#endif
519 osl::Security aSecurity;
520 aSecurity.getHomeDir( m_HomeDirectory );
519 osl::Security aSecurity;
520 aSecurity.getHomeDir( m_HomeDirectory );
521
522 // static const sal_Int32 UNKNOWN_NOTATION = (sal_Int32)0;
523 // static const sal_Int32 UNIX_NOTATION = (sal_Int32)1;
524 // static const sal_Int32 DOS_NOTATION = (sal_Int32)2;
525 // static const sal_Int32 MAC_NOTATION = (sal_Int32)3;
526
527 XPropertySetInfoImpl2* p = new XPropertySetInfoImpl2();
528 m_xPropertySetInfo = Reference< XPropertySetInfo >( p );

--- 112 unchanged lines hidden (view full) ---

641
642// XFileIdentifierConverter
643
644sal_Int32 SAL_CALL
645FileProvider::getFileProviderLocality( const rtl::OUString& BaseURL )
646 throw( RuntimeException )
647{
648 // If the base URL is a 'file' URL, return 10 (very 'local'), otherwise
521
522 // static const sal_Int32 UNKNOWN_NOTATION = (sal_Int32)0;
523 // static const sal_Int32 UNIX_NOTATION = (sal_Int32)1;
524 // static const sal_Int32 DOS_NOTATION = (sal_Int32)2;
525 // static const sal_Int32 MAC_NOTATION = (sal_Int32)3;
526
527 XPropertySetInfoImpl2* p = new XPropertySetInfoImpl2();
528 m_xPropertySetInfo = Reference< XPropertySetInfo >( p );

--- 112 unchanged lines hidden (view full) ---

641
642// XFileIdentifierConverter
643
644sal_Int32 SAL_CALL
645FileProvider::getFileProviderLocality( const rtl::OUString& BaseURL )
646 throw( RuntimeException )
647{
648 // If the base URL is a 'file' URL, return 10 (very 'local'), otherwise
649 // return -1 (missmatch). What is missing is a fast comparison to ASCII,
649 // return -1 (mismatch). What is missing is a fast comparison to ASCII,
650 // ignoring case:
651 return BaseURL.getLength() >= 5
652 && (BaseURL[0] == 'F' || BaseURL[0] == 'f')
653 && (BaseURL[1] == 'I' || BaseURL[1] == 'i')
654 && (BaseURL[2] == 'L' || BaseURL[2] == 'l')
655 && (BaseURL[3] == 'E' || BaseURL[3] == 'e')
656 && BaseURL[4] == ':' ?
657 10 : -1;
658}
659
660rtl::OUString SAL_CALL FileProvider::getFileURLFromSystemPath( const rtl::OUString&,
661 const rtl::OUString& SystemPath )
662 throw( RuntimeException )
663{
664 rtl::OUString aNormalizedPath;
665 if ( osl::FileBase::getFileURLFromSystemPath( SystemPath,aNormalizedPath ) != osl::FileBase::E_None )
666 return rtl::OUString();
650 // ignoring case:
651 return BaseURL.getLength() >= 5
652 && (BaseURL[0] == 'F' || BaseURL[0] == 'f')
653 && (BaseURL[1] == 'I' || BaseURL[1] == 'i')
654 && (BaseURL[2] == 'L' || BaseURL[2] == 'l')
655 && (BaseURL[3] == 'E' || BaseURL[3] == 'e')
656 && BaseURL[4] == ':' ?
657 10 : -1;
658}
659
660rtl::OUString SAL_CALL FileProvider::getFileURLFromSystemPath( const rtl::OUString&,
661 const rtl::OUString& SystemPath )
662 throw( RuntimeException )
663{
664 rtl::OUString aNormalizedPath;
665 if ( osl::FileBase::getFileURLFromSystemPath( SystemPath,aNormalizedPath ) != osl::FileBase::E_None )
666 return rtl::OUString();
667
668 return aNormalizedPath;
667
668 return aNormalizedPath;
669}
670
671rtl::OUString SAL_CALL FileProvider::getSystemPathFromFileURL( const rtl::OUString& URL )
672 throw( RuntimeException )
673{
674 rtl::OUString aSystemPath;
669}
670
671rtl::OUString SAL_CALL FileProvider::getSystemPathFromFileURL( const rtl::OUString& URL )
672 throw( RuntimeException )
673{
674 rtl::OUString aSystemPath;
675 if (osl::FileBase::getSystemPathFromFileURL( URL,aSystemPath ) != osl::FileBase::E_None )
675 if (osl::FileBase::getSystemPathFromFileURL( URL,aSystemPath ) != osl::FileBase::E_None )
676 return rtl::OUString();
677
678 return aSystemPath;
679}
680
676 return rtl::OUString();
677
678 return aSystemPath;
679}
680