22#include <com/sun/star/beans/Property.hpp>
23#include <com/sun/star/beans/PropertyAttribute.hpp>
24#include <com/sun/star/beans/PropertyValue.hpp>
25#include <com/sun/star/ucb/CommandInfo.hpp>
26#include <com/sun/star/ucb/ContentInfo.hpp>
27#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
28#include <com/sun/star/ucb/InsertCommandArgument.hpp>
29#include <com/sun/star/ucb/PostCommandArgument2.hpp>
30#include <com/sun/star/ucb/PropertyCommandArgument.hpp>
31#include <com/sun/star/ucb/TransferInfo.hpp>
32#include <com/sun/star/uno/Sequence.hxx>
33#include <com/sun/star/util/DateTime.hpp>
34#include <com/sun/star/ucb/Lock.hpp>
35#include <com/sun/star/ucb/LockEntry.hpp>
49bool ContentProvider::getProperty(
50 const OUString & rPropName, beans::Property & rProp )
57 m_pProps = std::make_unique<PropertyMap>();
69 beans::PropertyAttribute::BOUND
70 | beans::PropertyAttribute::READONLY ) );
77 beans::PropertyAttribute::BOUND
78 | beans::PropertyAttribute::READONLY ) );
85 beans::PropertyAttribute::BOUND
86 | beans::PropertyAttribute::READONLY ) );
93 beans::PropertyAttribute::BOUND ) );
102 beans::PropertyAttribute::BOUND
103 | beans::PropertyAttribute::READONLY ) );
110 beans::PropertyAttribute::BOUND
111 | beans::PropertyAttribute::READONLY ) );
118 beans::PropertyAttribute::BOUND
119 | beans::PropertyAttribute::READONLY ) );
126 beans::PropertyAttribute::BOUND
127 | beans::PropertyAttribute::READONLY ) );
134 beans::PropertyAttribute::BOUND
135 | beans::PropertyAttribute::READONLY ) );
139 "CreatableContentsInfo",
142 beans::PropertyAttribute::BOUND
143 | beans::PropertyAttribute::READONLY ) );
152 beans::PropertyAttribute::BOUND
153 | beans::PropertyAttribute::READONLY ) );
160 beans::PropertyAttribute::BOUND ) );
167 beans::PropertyAttribute::BOUND
168 | beans::PropertyAttribute::READONLY ) );
175 beans::PropertyAttribute::BOUND
176 | beans::PropertyAttribute::READONLY ) );
183 beans::PropertyAttribute::BOUND
184 | beans::PropertyAttribute::READONLY ) );
191 beans::PropertyAttribute::BOUND
192 | beans::PropertyAttribute::READONLY ) );
199 beans::PropertyAttribute::BOUND
200 | beans::PropertyAttribute::READONLY ) );
207 beans::PropertyAttribute::BOUND
208 | beans::PropertyAttribute::READONLY ) );
215 beans::PropertyAttribute::BOUND
216 | beans::PropertyAttribute::READONLY ) );
223 beans::PropertyAttribute::BOUND
224 | beans::PropertyAttribute::READONLY ) );
231 beans::PropertyAttribute::BOUND ) );
239 beans::Property aProp;
240 aProp.Name = rPropName;
241 const PropertyMap::const_iterator it =
m_pProps->find( aProp );
249 rProp = beans::Property(
253 beans::PropertyAttribute::BOUND );
273 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
276 std::unique_ptr< DAVResourceAccess > xResAccess;
277 std::unique_ptr< ContentProperties > xCachedProps;
281 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
291 std::set< OUString > aPropSet;
305 std::vector< DAVResourceInfo >
props;
306 OUString aTheURL( xResAccess->getURL() );
312 xResAccess->PROPFIND(
DAVZERO, props, xEnv );
313 aPropsNames.setPropertiesNames( props );
319 props = aPropsNames.getPropertiesNames();
324 if (
props.size() == 1)
326 aPropSet.insert( (*
props.begin()).properties.begin(),
327 (*
props.begin()).properties.end() );
337 bool bHasCreationDate =
false;
338 bool bHasGetLastModified =
false;
339 bool bHasGetContentType =
false;
340 bool bHasGetContentLength =
false;
342 bool bHasContentType =
false;
343 bool bHasIsDocument =
false;
344 bool bHasIsFolder =
false;
345 bool bHasTitle =
false;
346 bool bHasBaseURI =
false;
347 bool bHasDateCreated =
false;
348 bool bHasDateModified =
false;
349 bool bHasMediaType =
false;
350 bool bHasSize =
false;
351 bool bHasCreatableInfos =
false;
354 for (
const auto& rProp : aPropSet )
356 if ( !bHasCreationDate &&
359 bHasCreationDate =
true;
361 else if ( !bHasGetLastModified &&
364 bHasGetLastModified =
true;
366 else if ( !bHasGetContentType &&
369 bHasGetContentType =
true;
371 else if ( !bHasGetContentLength &&
374 bHasGetContentLength =
true;
376 else if ( !bHasContentType && rProp ==
"ContentType" )
378 bHasContentType =
true;
380 else if ( !bHasIsDocument && rProp ==
"IsDocument" )
382 bHasIsDocument =
true;
384 else if ( !bHasIsFolder && rProp ==
"IsFolder" )
388 else if ( !bHasTitle && rProp ==
"Title" )
392 else if ( !bHasBaseURI && rProp ==
"BaseURI" )
396 else if ( !bHasDateCreated && rProp ==
"DateCreated" )
398 bHasDateCreated =
true;
400 else if ( !bHasDateModified && rProp ==
"DateModified" )
402 bHasDateModified =
true;
404 else if ( !bHasMediaType && rProp ==
"MediaType" )
406 bHasMediaType =
true;
408 else if ( !bHasSize && rProp ==
"Size" )
412 else if ( !bHasCreatableInfos && rProp ==
"CreatableContentsInfo" )
414 bHasCreatableInfos =
true;
420 if ( !bHasContentType )
422 OUString(
"ContentType" ) );
424 if ( !bHasIsDocument )
426 OUString(
"IsDocument" ) );
430 OUString(
"IsFolder" ) );
436 OUString(
"Title" ) );
445 OUString(
"BaseURI" ) );
448 if ( !bHasDateCreated && bHasCreationDate )
450 OUString(
"DateCreated" ) );
452 if ( !bHasDateModified && bHasGetLastModified )
454 OUString(
"DateModified" ) );
456 if ( !bHasMediaType && bHasGetContentType )
458 OUString(
"MediaType" ) );
460 if ( !bHasSize && bHasGetContentLength )
462 OUString(
"Size" ) );
464 if ( !bHasCreatableInfos )
467 "CreatableContentsInfo" ) );
472 const std::unique_ptr< PropertyValueMap > & xProps
473 = xCachedProps->getProperties();
475 for (
const auto& rEntry : *xProps )
476 aPropSet.insert( rEntry.first );
480 sal_Int32
nCount = aPropSet.size();
481 uno::Sequence< beans::Property >
aProperties( nCount );
482 auto aPropertiesRange = asNonConstRange(aProperties);
484 beans::Property aProp;
487 for (
const auto& rProp : aPropSet )
489 xProvider->getProperty( rProp, aProp );
490 aPropertiesRange[
n++ ] = aProp;
499 const uno::Reference< ucb::XCommandEnvironment > & xEnv )
501 osl::Guard< osl::Mutex > aGuard(
m_aMutex );
503 uno::Sequence< ucb::CommandInfo > aCmdInfo( 10 );
504 auto pCmdInfo = aCmdInfo.getArray();
517 "getPropertySetInfo",
529 cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get());
571 bool bFolder =
false;
577 catch ( uno::Exception
const & )
585 sal_Int32
nPos = aCmdInfo.getLength();
586 sal_Int32 nMoreCmds = ( bFolder ? 2 : 0 ) + ( bSupportsLocking ? 2 : 0 );
588 aCmdInfo.realloc( nPos + nMoreCmds );
592 pCmdInfo = aCmdInfo.getArray();
618 if ( bSupportsLocking )
PropertiesInfo aProperties
std::unique_ptr< PropertyMap > m_pProps
bool isFolder(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv)
virtual css::uno::Sequence< css::ucb::CommandInfo > getCommands(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
static void removeCachedPropertyNames(const OUString &rURL)
virtual css::uno::Sequence< css::beans::Property > getProperties(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv) override
void getResourceOptions(const css::uno::Reference< css::ucb::XCommandEnvironment > &xEnv, DAVOptions &rDAVOptions, const std::unique_ptr< DAVResourceAccess > &rResAccess, bool *networkAccessAllowed=nullptr)
Use OPTIONS method to retrieve the type of the Web resource.
ResourceType resourceTypeForLocks(const css::uno::Reference< css::ucb::XCommandEnvironment > &rEnvironment, const std::unique_ptr< DAVResourceAccess > &rResAccess)
std::unique_ptr< DAVResourceAccess > m_xResAccess
std::unique_ptr< CachableContentProperties > m_xCachedProps
ContentProvider * m_pProvider
void removeCachedPropertyNames(const OUString &URL)
void addCachePropertyNames(PropertyNames &rCacheElement, const sal_uInt32 nLifeTime)
bool getCachedPropertyNames(const OUString &URL, PropertyNames &rCacheElement)
static constexpr OUStringLiteral GETCONTENTTYPE
static constexpr OUStringLiteral SUPPORTEDLOCK
static constexpr OUStringLiteral CREATIONDATE
static constexpr OUStringLiteral DISPLAYNAME
static constexpr OUStringLiteral EXECUTABLE
static constexpr OUStringLiteral GETETAG
static constexpr OUStringLiteral LOCKDISCOVERY
static constexpr OUStringLiteral RESOURCETYPE
static constexpr OUStringLiteral GETCONTENTLENGTH
static constexpr OUStringLiteral GETLASTMODIFIED
static constexpr OUStringLiteral GETCONTENTLANGUAGE
static PropertyNamesCache aStaticPropertyNamesCache