21#include <com/sun/star/util/DateTime.hpp>
73uno::Any ContentProperties::m_aEmptyAny;
75ContentProperties::ContentProperties(
const DAVResource& rResource )
77 m_bTrailingSlash( false )
79 assert(!rResource.
uri.isEmpty() &&
80 "ContentProperties ctor - Empty resource URI!");
88 (*m_xProps)[ OUString(
"Title" ) ]
94 (*m_xProps)[ OUString(
"Title" ) ]
97 OUString(
"*** unknown ***" ) ),
101 for (
const auto& rProp : rResource.
properties )
106 if ( rResource.
uri.endsWith(
"/") )
112 const OUString & rTitle,
bool bFolder )
114 m_bTrailingSlash( false )
116 (*m_xProps)[ OUString(
"Title" ) ]
118 (*m_xProps)[ OUString(
"IsFolder" ) ]
120 (*m_xProps)[ OUString(
"IsDocument" ) ]
127 m_bTrailingSlash( false )
129 (*m_xProps)[ OUString(
"Title" ) ]
136 m_bTrailingSlash( false )
142: m_aEscapedTitle( rOther.m_aEscapedTitle ),
146 m_bTrailingSlash( rOther.m_bTrailingSlash )
161 const OUString & rName )
const
165 return pProp->
value();
172 const OUString & rName )
const
174 PropertyValueMap::const_iterator it =
m_xProps->find( rName );
175 const PropertyValueMap::const_iterator
end =
m_xProps->end();
180 [&rName](
const PropertyValueMap::value_type& rEntry) {
181 return rEntry.first.equalsIgnoreAsciiCase( rName );
184 return &(*it).second;
189 return &(*it).second;
195 const uno::Sequence< beans::Property > & rProps,
196 std::vector< OUString > & propertyNames )
211 bool bCreationDate =
false;
212 bool bLastModified =
false;
213 bool bContentType =
false;
214 bool bContentLength =
false;
215 bool bResourceType =
false;
217 sal_Int32
nCount = rProps.getLength();
220 const beans::Property & rProp = rProps[
n ];
222 if ( rProp.Name ==
"Title" )
227 else if ( rProp.Name ==
"DateCreated" ||
230 if ( !bCreationDate )
233 bCreationDate =
true;
236 else if ( rProp.Name ==
"DateModified" ||
239 if ( !bLastModified )
241 propertyNames.push_back(
243 bLastModified =
true;
246 else if ( rProp.Name ==
"MediaType" ||
251 propertyNames.push_back(
256 else if ( rProp.Name ==
"Size" ||
259 if ( !bContentLength )
261 propertyNames.push_back(
263 bContentLength =
true;
266 else if ( rProp.Name ==
"ContentType" ||
267 rProp.Name ==
"IsDocument" ||
268 rProp.Name ==
"IsFolder" ||
271 if ( !bResourceType )
274 bResourceType =
true;
279 propertyNames.push_back( rProp.Name );
287 const uno::Sequence< beans::Property > & rProps,
288 std::vector< OUString > & propertyNames )
300 sal_Int32
nCount = rProps.getLength();
303 const beans::Property & rProp = rProps[
n ];
305 if ( rProp.Name ==
"DateModified" )
307 propertyNames.push_back( OUString(
"Last-Modified" ) );
309 else if ( rProp.Name ==
"MediaType" )
311 propertyNames.push_back( OUString(
"Content-Type" ) );
313 else if ( rProp.Name ==
"Size" )
315 propertyNames.push_back( OUString(
"Content-Length" ) );
319 propertyNames.push_back( rProp.Name );
326 const uno::Sequence< beans::Property >& rProps,
327 std::vector< OUString > & rNamesNotContained )
const
329 rNamesNotContained.clear();
331 sal_Int32
nCount = rProps.getLength();
334 const OUString & rName = rProps[
n ].Name;
338 rNamesNotContained.push_back( rName );
342 return ( rNamesNotContained.size() == 0 );
347 const std::vector< OUString > & rProps,
350 for (
const OUString & rName : rProps )
375 const css::uno::Any & rValue,
376 bool bIsCaseSensitive )
383 util::DateTime aDate;
386 (*m_xProps)[ OUString(
"DateCreated" ) ]
401 (*m_xProps)[ OUString(
"Size" ) ]
404 else if ( rName.equalsIgnoreAsciiCase(
"Content-Length" ) )
413 (*m_xProps)[ OUString(
"Size" ) ]
419 (*m_xProps)[ OUString(
"MediaType" ) ]
422 else if ( rName.equalsIgnoreAsciiCase(
"Content-Type" ) )
428 (*m_xProps)[ OUString(
"MediaType" ) ]
439 util::DateTime aDate;
442 (*m_xProps)[ OUString(
"DateModified" ) ]
445 else if ( rName.equalsIgnoreAsciiCase(
"Last-Modified" ) )
453 util::DateTime aDate;
456 (*m_xProps)[ OUString(
"DateModified" ) ]
469 aValue.equalsIgnoreAsciiCase(
"collection" );
471 (*m_xProps)[ OUString(
"IsFolder" ) ]
473 (*m_xProps)[ OUString(
"IsDocument" ) ]
475 (*m_xProps)[ OUString(
"ContentType" ) ]
485 (*m_xProps)[ rName ] =
PropertyValue( rValue, bIsCaseSensitive );
494 bool isCachable( std::u16string_view rName,
bool isCaseSensitive )
496 const OUString aNonCachableProps [] =
503 OUString(
"DateModified" ),
504 OUString(
"Last-Modified" ),
508 OUString(
"Content-Length" ),
514 for ( sal_uInt32 n = 0;
515 n < (
sizeof( aNonCachableProps )
516 /
sizeof( aNonCachableProps[ 0 ] ) );
519 if ( isCaseSensitive )
521 if ( rName == aNonCachableProps[ n ] )
546 for (
const auto& rProp : *
props )
548 if ( isCachable( rProp.first, rProp.second.isCaseSensitive() ) )
550 rProp.second.value(),
551 rProp.second.isCaseSensitive() );
557 const std::vector< DAVPropertyValue > & rProps )
559 for (
const auto& rProp : rProps )
561 if ( isCachable( rProp.Name, rProp.IsCaseSensitive ) )
CachableContentProperties(const CachableContentProperties &)
ContentProperties m_aProps
void addProperties(const ContentProperties &rProps)
void addProperty(const OUString &rName, const css::uno::Any &rValue, bool bIsCaseSensitive)
bool contains(const OUString &rName) const
const std::unique_ptr< PropertyValueMap > & getProperties() const
const PropertyValue * get(const OUString &rName) const
void addProperties(const std::vector< OUString > &rProps, const ContentProperties &rContentProps)
std::unique_ptr< PropertyValueMap > m_xProps
static css::uno::Any m_aEmptyAny
bool containsAllNames(const css::uno::Sequence< css::beans::Property > &rProps, std::vector< OUString > &rNamesNotContained) const
static void UCBNamesToDAVNames(const css::uno::Sequence< css::beans::Property > &rProps, std::vector< OUString > &resources)
const css::uno::Any & getValue(const OUString &rName) const
static void UCBNamesToHTTPNames(const css::uno::Sequence< css::beans::Property > &rProps, std::vector< OUString > &resources)
OUString GetPathBaseName() const
OUString GetPathBaseNameUnescaped() const
static bool convert(std::u16string_view, css::util::DateTime &)
const css::uno::Any & value() const
bool isCaseSensitive() const
std::unordered_map< OUString, PropertyValue > PropertyValueMap
constexpr OUStringLiteral WEBDAV_COLLECTION_TYPE
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
static constexpr OUStringLiteral GETCONTENTTYPE
static constexpr OUStringLiteral CREATIONDATE
static constexpr OUStringLiteral GETETAG
static constexpr OUStringLiteral LOCKDISCOVERY
static constexpr OUStringLiteral RESOURCETYPE
static constexpr OUStringLiteral GETCONTENTLENGTH
static constexpr OUStringLiteral GETLASTMODIFIED
std::vector< DAVPropertyValue > properties
#define WEBDAV_CONTENT_TYPE