26 #include <com/sun/star/ucb/OpenMode.hpp>
34 #include <com/sun/star/ucb/IllegalIdentifierException.hpp>
35 #include <com/sun/star/ucb/ResultSetException.hpp>
49 struct ResultListEntry
52 uno::Reference< ucb::XContentIdentifier >
xId;
54 uno::Reference< sdbc::XRow >
xRow;
55 std::unique_ptr<ContentProperties>
pData;
57 explicit ResultListEntry( std::unique_ptr<ContentProperties> && pEntry ) : pData(
std::move(pEntry) ) {}
82 const uno::Reference< uno::XComponentContext >& rxContext,
85 : m_xContent( rContent ), m_xContext( rxContext ), m_nOpenMode( nOpenMode ),
86 m_bCountFinal( false ), m_bThrowException( false ) {}
91 DataSupplier_Impl::~DataSupplier_Impl()
93 for (
auto& rResultPtr : m_aResults )
105 DataSupplier::DataSupplier(
106 const uno::Reference< uno::XComponentContext >& rxContext,
108 sal_Int32 nOpenMode )
122 osl::Guard< osl::Mutex > aGuard(
m_pImpl->m_aMutex );
124 if ( nIndex < m_pImpl->m_aResults.size() )
126 OUString
aId =
m_pImpl->m_aResults[ nIndex ]->aId;
127 if ( aId.getLength() )
136 OUString
aId =
m_pImpl->m_xContent->getResourceAccess().getURL();
139 = *(
m_pImpl->m_aResults[ nIndex ]->pData );
141 if ( ( aId.lastIndexOf(
'/' ) + 1 ) != aId.getLength() )
157 uno::Reference< ucb::XContentIdentifier >
160 osl::Guard< osl::Mutex > aGuard(
m_pImpl->m_aMutex );
162 if ( nIndex < m_pImpl->m_aResults.size() )
164 uno::Reference< ucb::XContentIdentifier >
xId
165 =
m_pImpl->m_aResults[ nIndex ]->xId;
174 if ( aId.getLength() )
176 uno::Reference< ucb::XContentIdentifier >
xId
177 = new ::ucbhelper::ContentIdentifier( aId );
181 return uno::Reference< ucb::XContentIdentifier >();
186 uno::Reference< ucb::XContent >
189 osl::Guard< osl::Mutex > aGuard(
m_pImpl->m_aMutex );
191 if ( nIndex < m_pImpl->m_aResults.size() )
193 uno::Reference< ucb::XContent >
xContent
194 =
m_pImpl->m_aResults[ nIndex ]->xContent;
202 uno::Reference< ucb::XContentIdentifier >
xId
208 uno::Reference< ucb::XContent >
xContent
209 =
m_pImpl->m_xContent->getProvider()->queryContent( xId );
214 catch ( ucb::IllegalIdentifierException& )
218 return uno::Reference< ucb::XContent >();
225 osl::ClearableGuard< osl::Mutex > aGuard(
m_pImpl->m_aMutex );
227 if (
m_pImpl->m_aResults.size() > nIndex )
236 if (
m_pImpl->m_aResults.size() > nIndex )
253 return m_pImpl->m_aResults.size();
260 return m_pImpl->m_aResults.size();
275 osl::Guard< osl::Mutex > aGuard(
m_pImpl->m_aMutex );
277 if ( nIndex < m_pImpl->m_aResults.size() )
279 uno::Reference< sdbc::XRow >
xRow =
m_pImpl->m_aResults[ nIndex ]->xRow;
289 uno::Reference< sdbc::XRow >
xRow
293 *(
m_pImpl->m_aResults[ nIndex ]->pData),
295 m_pImpl->m_xContent->getProvider().get() ),
301 return uno::Reference< sdbc::XRow >();
308 osl::Guard< osl::Mutex > aGuard(
m_pImpl->m_aMutex );
310 if ( nIndex < m_pImpl->m_aResults.size() )
311 m_pImpl->m_aResults[ nIndex ]->xRow.clear();
324 if (
m_pImpl->m_bThrowException )
325 throw ucb::ResultSetException();
330 osl::ClearableGuard< osl::Mutex > aGuard(
m_pImpl->m_aMutex );
334 std::vector< OUString > propertyNames;
342 bool isNoResourceType = std::none_of(propertyNames.begin(), propertyNames.end(),
345 if ( isNoResourceType )
348 std::vector< DAVResource > resources;
353 m_pImpl->m_xContent->getResourceAccess()
362 m_pImpl->m_bThrowException =
true;
365 if ( !
m_pImpl->m_bThrowException )
370 m_pImpl->m_xContent->getResourceAccess().getURL() );
371 OUString aPath = aURI.
GetPath();
373 if ( aPath.endsWith(
"/") )
374 aPath = aPath.copy( 0, aPath.getLength() - 1 );
377 bool bFoundParent =
false;
379 for (
size_t n = 0;
n < resources.size(); ++
n )
390 OUString aCurrPath = aCurrURI.
GetPath();
391 if ( aCurrPath.endsWith(
"/") )
395 aCurrPath.getLength() - 1 );
398 if ( aPath == aCurrPath )
410 std::unique_ptr<ContentProperties> pContentProperties
411 = std::make_unique<ContentProperties>( rRes );
414 switch (
m_pImpl->m_nOpenMode )
416 case ucb::OpenMode::FOLDERS:
418 bool bFolder =
false;
421 = pContentProperties->getValue(
"IsFolder" );
430 case ucb::OpenMode::DOCUMENTS:
432 bool bDocument =
false;
435 = pContentProperties->getValue(
"IsDocument" );
436 rValue >>= bDocument;
444 case ucb::OpenMode::ALL:
450 new ResultListEntry( std::move(pContentProperties) ) );
464 return !
m_pImpl->m_bThrowException;
css::uno::Environment getEnvironment(OUString const &name, OUString const &implementation)
static const OUString RESOURCETYPE
std::unique_ptr< ContentProperties > pData
uno::Reference< uno::XComponentContext > m_xContext
virtual css::uno::Reference< css::sdbc::XRow > queryPropertyValues(sal_uInt32 nIndex) override
static void UCBNamesToDAVNames(const css::uno::Sequence< css::beans::Property > &rProps, std::vector< OUString > &resources, bool bIncludeUnmatched=true)
virtual void releasePropertyValues(sal_uInt32 nIndex) override
virtual ~DataSupplier() override
virtual bool isCountFinal() override
css::uno::Any const & rValue
virtual bool getResult(sal_uInt32 nIndex) override
bool isTrailingSlash() const
std::unique_ptr< DataSupplier_Impl > m_pImpl
const OUString & getEscapedTitle() const
#define TOOLS_WARN_EXCEPTION(area, stream)
DataSupplier_Impl(const uno::Reference< uno::XComponentContext > &rxContext, const rtl::Reference< Content > &rContent, sal_Int32 nOpenMode)
rtl::Reference< Content > m_xContent
virtual sal_uInt32 totalCount() override
uno::Reference< sdbc::XRow > xRow
virtual sal_uInt32 currentCount() override
virtual css::uno::Reference< css::ucb::XContentIdentifier > queryContentIdentifier(sal_uInt32 nIndex) override
const OUString & GetPath() const
rtl::Reference< ResultSet > getResultSet() const
uno::Reference< ucb::XContentIdentifier > xId
virtual void close() override
virtual css::uno::Reference< css::ucb::XContent > queryContent(sal_uInt32 nIndex) override
virtual OUString queryContentIdentifierString(sal_uInt32 nIndex) override
css::uno::Reference< css::sdbc::XRow > getPropertyValues(const css::uno::Sequence< css::beans::Property > &rProperties, const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual void validate() override
uno::Reference< ucb::XContent > xContent
std::vector< ResultListEntry * > ResultList
static OUString unescape(const OUString &string)