21 #include <com/sun/star/util/DateTime.hpp>
72 uno::Any ContentProperties::m_aEmptyAny;
74 ContentProperties::ContentProperties(
const DAVResource& rResource )
76 m_bTrailingSlash(
false )
78 assert(!rResource.
uri.isEmpty() &&
79 "ContentProperties ctor - Empty resource URI!");
87 (*m_xProps)[ OUString(
"Title" ) ]
93 (*m_xProps)[ OUString(
"Title" ) ]
96 OUString(
"*** unknown ***" ) ),
100 for (
const auto& rProp : rResource.
properties )
105 if ( rResource.
uri.endsWith(
"/") )
111 const OUString & rTitle,
bool bFolder )
113 m_bTrailingSlash(
false )
115 (*m_xProps)[ OUString(
"Title" ) ]
117 (*m_xProps)[ OUString(
"IsFolder" ) ]
119 (*m_xProps)[ OUString(
"IsDocument" ) ]
126 m_bTrailingSlash(
false )
128 (*m_xProps)[ OUString(
"Title" ) ]
135 m_bTrailingSlash(
false )
141 : m_aEscapedTitle( rOther.m_aEscapedTitle ),
145 m_bTrailingSlash( rOther.m_bTrailingSlash )
160 const OUString & rName )
const
164 return pProp->
value();
171 const OUString & rName )
const
173 PropertyValueMap::const_iterator it =
m_xProps->find( rName );
174 const PropertyValueMap::const_iterator
end =
m_xProps->end();
178 it = std::find_if(
m_xProps->cbegin(), end,
179 [&rName](
const PropertyValueMap::value_type& rEntry) {
180 return rEntry.first.equalsIgnoreAsciiCase( rName );
183 return &(*it).second;
188 return &(*it).second;
194 const uno::Sequence< beans::Property > & rProps,
195 std::vector< OUString > & propertyNames )
210 bool bCreationDate =
false;
211 bool bLastModified =
false;
212 bool bContentType =
false;
213 bool bContentLength =
false;
214 bool bResourceType =
false;
216 sal_Int32
nCount = rProps.getLength();
217 for ( sal_Int32
n = 0;
n < nCount; ++
n )
219 const beans::Property & rProp = rProps[
n ];
221 if ( rProp.Name ==
"Title" )
226 else if ( rProp.Name ==
"DateCreated" ||
229 if ( !bCreationDate )
232 bCreationDate =
true;
235 else if ( rProp.Name ==
"DateModified" ||
238 if ( !bLastModified )
240 propertyNames.push_back(
242 bLastModified =
true;
245 else if ( rProp.Name ==
"MediaType" ||
250 propertyNames.push_back(
255 else if ( rProp.Name ==
"Size" ||
258 if ( !bContentLength )
260 propertyNames.push_back(
262 bContentLength =
true;
265 else if ( rProp.Name ==
"ContentType" ||
266 rProp.Name ==
"IsDocument" ||
267 rProp.Name ==
"IsFolder" ||
270 if ( !bResourceType )
273 bResourceType =
true;
278 propertyNames.push_back( rProp.Name );
286 const uno::Sequence< beans::Property > & rProps,
287 std::vector< OUString > & propertyNames )
299 sal_Int32
nCount = rProps.getLength();
300 for ( sal_Int32
n = 0;
n < nCount; ++
n )
302 const beans::Property & rProp = rProps[
n ];
304 if ( rProp.Name ==
"DateModified" )
306 propertyNames.push_back( OUString(
"Last-Modified" ) );
308 else if ( rProp.Name ==
"MediaType" )
310 propertyNames.push_back( OUString(
"Content-Type" ) );
312 else if ( rProp.Name ==
"Size" )
314 propertyNames.push_back( OUString(
"Content-Length" ) );
318 propertyNames.push_back( rProp.Name );
325 const uno::Sequence< beans::Property >& rProps,
326 std::vector< OUString > & rNamesNotContained )
const
328 rNamesNotContained.clear();
330 sal_Int32
nCount = rProps.getLength();
331 for ( sal_Int32
n = 0;
n < nCount; ++
n )
333 const OUString & rName = rProps[
n ].Name;
337 rNamesNotContained.push_back( rName );
341 return ( rNamesNotContained.size() == 0 );
346 const std::vector< OUString > & rProps,
349 for (
const OUString & rName : rProps )
374 const css::uno::Any & rValue,
375 bool bIsCaseSensitive )
382 util::DateTime aDate;
385 (*m_xProps)[ OUString(
"DateCreated" ) ]
400 (*m_xProps)[ OUString(
"Size" ) ]
403 else if ( rName.equalsIgnoreAsciiCase(
"Content-Length" ) )
412 (*m_xProps)[ OUString(
"Size" ) ]
418 (*m_xProps)[ OUString(
"MediaType" ) ]
421 else if ( rName.equalsIgnoreAsciiCase(
"Content-Type" ) )
427 (*m_xProps)[ OUString(
"MediaType" ) ]
438 util::DateTime aDate;
441 (*m_xProps)[ OUString(
"DateModified" ) ]
444 else if ( rName.equalsIgnoreAsciiCase(
"Last-Modified" ) )
452 util::DateTime aDate;
455 (*m_xProps)[ OUString(
"DateModified" ) ]
468 aValue.equalsIgnoreAsciiCase(
"collection" );
470 (*m_xProps)[ OUString(
"IsFolder" ) ]
472 (*m_xProps)[ OUString(
"IsDocument" ) ]
474 (*m_xProps)[ OUString(
"ContentType" ) ]
484 (*m_xProps)[ rName ] =
PropertyValue( rValue, bIsCaseSensitive );
493 bool isCachable( OUString
const & rName,
494 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.equals( aNonCachableProps[ n ] ) )
525 if ( rName.equalsIgnoreAsciiCase( 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 &)
bool isCaseSensitive() const
OUString GetPathBaseName() const
void addProperties(const ContentProperties &rProps)
void addProperty(const OUString &rName, const css::uno::Any &rValue, bool bIsCaseSensitive)
std::unordered_map< OUString, PropertyValue > PropertyValueMap
void addProperties(const std::vector< OUString > &rProps, const ContentProperties &rContentProps)
static constexpr OUStringLiteral GETLASTMODIFIED
static void UCBNamesToDAVNames(const css::uno::Sequence< css::beans::Property > &rProps, std::vector< OUString > &resources)
#define WEBDAV_CONTENT_TYPE
std::unique_ptr< PropertyValueMap > m_xProps
const css::uno::Any & getValue(const OUString &rName) const
static void UCBNamesToHTTPNames(const css::uno::Sequence< css::beans::Property > &rProps, std::vector< OUString > &resources)
constexpr OUStringLiteral WEBDAV_COLLECTION_TYPE
static bool convert(const OUString &, css::util::DateTime &)
static constexpr OUStringLiteral RESOURCETYPE
ContentProperties m_aProps
OUString GetPathBaseNameUnescaped() const
static css::uno::Any m_aEmptyAny
static constexpr OUStringLiteral CREATIONDATE
bool containsAllNames(const css::uno::Sequence< css::beans::Property > &rProps, std::vector< OUString > &rNamesNotContained) const
enumrange< T >::Iterator end(enumrange< T >)
static constexpr OUStringLiteral LOCKDISCOVERY
static constexpr OUStringLiteral GETCONTENTLENGTH
static constexpr OUStringLiteral GETCONTENTTYPE
const PropertyValue * get(const OUString &rName) const
std::vector< DAVPropertyValue > properties
const std::unique_ptr< PropertyValueMap > & getProperties() const
static constexpr OUStringLiteral GETETAG
bool contains(const OUString &rName) const
const css::uno::Any & value() const
bool m_bDetectedRangeSegmentation false