20#include <osl/security.hxx>
21#include <osl/file.hxx>
22#include <osl/socket.h>
25#include <com/sun/star/beans/PropertyAttribute.hpp>
26#include <com/sun/star/ucb/FileSystemNotation.hpp>
27#include <com/sun/star/ucb/IllegalIdentifierException.hpp>
43#if OSL_DEBUG_LEVEL > 0
44#define THROW_WHERE SAL_WHERE
59 , m_FileSystemNotation(FileSystemNotation::UNKNOWN_NOTATION)
94 return "com.sun.star.comp.ucb.FileProvider";
105 return {
"com.sun.star.ucb.FileContentProvider" };
135 OUString aUrl1 = Id1->getContentIdentifier();
136 OUString aUrl2 = Id2->getContentIdentifier();
138 sal_Int32 iComp = aUrl1.compareTo( aUrl2 );
142 OUString aPath1, aPath2;
147 osl::FileBase::RC error;
148 osl::DirectoryItem aItem1, aItem2;
150 error = osl::DirectoryItem::get( aPath1, aItem1 );
151 if ( error == osl::FileBase::E_None )
152 error = osl::DirectoryItem::get( aPath2, aItem2 );
154 if ( error != osl::FileBase::E_None )
157 osl::FileStatus aStatus1( osl_FileStatus_Mask_FileURL );
158 osl::FileStatus aStatus2( osl_FileStatus_Mask_FileURL );
159 error = aItem1.getFileStatus( aStatus1 );
160 if ( error == osl::FileBase::E_None )
161 error = aItem2.getFileStatus( aStatus2 );
163 if ( error == osl::FileBase::E_None )
165 iComp = aStatus1.getFileURL().compareTo( aStatus2.getFileURL() );
171 error = osl::FileBase::getSystemPathFromFileURL( aStatus1.getFileURL(), aPath1 );
172 if ( error == osl::FileBase::E_None )
173 error = osl::FileBase::getSystemPathFromFileURL( aStatus2.getFileURL(), aPath2 );
175 if ( error == osl::FileBase::E_None )
176 iComp = aPath1.compareToIgnoreAsciiCase( aPath2 );
188 const OUString& ContentId )
199class XPropertySetInfoImpl2
201 public XPropertySetInfo
204 XPropertySetInfoImpl2();
210 virtual void SAL_CALL
214 virtual
void SAL_CALL
219 virtual
Sequence< Property > SAL_CALL
220 getProperties() override;
222 virtual Property SAL_CALL
223 getPropertyByName( const OUString& aName ) override;
226 hasPropertyByName( const OUString& Name ) override;
235XPropertySetInfoImpl2::XPropertySetInfoImpl2()
239 PropertyAttribute::READONLY ),
243 PropertyAttribute::READONLY ),
247 PropertyAttribute::READONLY )}
252XPropertySetInfoImpl2::acquire()
255 OWeakObject::acquire();
260XPropertySetInfoImpl2::release()
263 OWeakObject::release();
268XPropertySetInfoImpl2::queryInterface(
const Type& rType )
271 static_cast< XPropertySetInfo*
>(
this) );
272 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
277XPropertySetInfoImpl2::getPropertyByName(
const OUString& aName )
279 auto pProp = std::find_if(std::cbegin(m_seq), std::cend(m_seq),
280 [&aName](
const Property& rProp) {
return rProp.Name ==
aName; });
281 if (pProp != std::cend(m_seq))
284 throw UnknownPropertyException( aName );
289XPropertySetInfoImpl2::getProperties()
296XPropertySetInfoImpl2::hasPropertyByName(
297 const OUString& aName )
299 return std::any_of(std::cbegin(m_seq), std::cend(m_seq),
300 [&aName](
const Property& rProp) {
return rProp.Name ==
aName; });
306 std::scoped_lock aGuard(
m_aMutex );
307 if( m_xPropertySetInfo.is() )
310 osl_getLocalHostname( &m_HostName.pData );
313 m_FileSystemNotation = FileSystemNotation::UNIX_NOTATION;
314#elif defined( _WIN32 )
315 m_FileSystemNotation = FileSystemNotation::DOS_NOTATION;
317 m_FileSystemNotation = FileSystemNotation::UNKNOWN_NOTATION;
319 osl::Security aSecurity;
320 aSecurity.getHomeDir( m_HomeDirectory );
327 m_xPropertySetInfo =
new XPropertySetInfoImpl2();
337 return m_xPropertySetInfo;
345 if( !(aPropertyName ==
"FileSystemNotation" ||
346 aPropertyName ==
"HomeDirectory" ||
347 aPropertyName ==
"HostName") )
348 throw UnknownPropertyException( aPropertyName );
354 const OUString& aPropertyName )
357 if( aPropertyName ==
"FileSystemNotation" )
359 return Any(m_FileSystemNotation);
361 else if( aPropertyName ==
"HomeDirectory" )
363 return Any(m_HomeDirectory);
365 else if( aPropertyName ==
"HostName" )
367 return Any(m_HostName);
370 throw UnknownPropertyException( aPropertyName );
413 return BaseURL.getLength() >= 5
414 && (BaseURL[0] ==
'F' || BaseURL[0] ==
'f')
415 && (BaseURL[1] ==
'I' || BaseURL[1] ==
'i')
416 && (BaseURL[2] ==
'L' || BaseURL[2] ==
'l')
417 && (BaseURL[3] ==
'E' || BaseURL[3] ==
'e')
418 && BaseURL[4] ==
':' ?
425 OUString aNormalizedPath;
426 if ( osl::FileBase::getFileURLFromSystemPath(
SystemPath,aNormalizedPath ) != osl::FileBase::E_None )
429 return aNormalizedPath;
434 OUString aSystemPath;
435 if (osl::FileBase::getSystemPathFromFileURL(
URL,aSystemPath ) != osl::FileBase::E_None )
441extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
443 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const&)
Reference< XComponentContext > m_xContext
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual OUString SAL_CALL getSystemPathFromFileURL(const OUString &URL) override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
std::unique_ptr< TaskManager > m_pMyShell
virtual sal_Int32 SAL_CALL compareContentIds(const css::uno::Reference< css::ucb::XContentIdentifier > &Id1, const css::uno::Reference< css::ucb::XContentIdentifier > &Id2) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Int32 SAL_CALL getFileProviderLocality(const OUString &BaseURL) override
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual OUString SAL_CALL getImplementationName() override
virtual OUString SAL_CALL getFileURLFromSystemPath(const OUString &BaseURL, const OUString &SystemPath) override
virtual ~FileProvider() override
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent(const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier) override
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL createContentIdentifier(const OUString &ContentId) override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
static bool getUnqFromUrl(const OUString &Url, OUString &Unq)
Sequence< PropertyValue > aArguments
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ucb_file_FileProvider_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)