36 #include <com/sun/star/util/DateTime.hpp>
87 uno::Any ContentProperties::m_aEmptyAny;
89 ContentProperties::ContentProperties(
const DAVResource& rResource )
91 m_bTrailingSlash( false )
93 assert( !rResource.
uri.isEmpty() &&
"ContentProperties ctor - Empty resource URI!" );
101 (*m_xProps)[ OUString(
"Title") ]
107 (*m_xProps)[ OUString(
"Title") ]
111 "*** unknown ***" ) ),
115 for (
const auto& rProp : rResource.
properties )
120 if ( rResource.
uri.endsWith(
"/") )
126 const OUString & rTitle,
bool bFolder )
128 m_bTrailingSlash( false )
130 (*m_xProps)[ OUString(
"Title") ]
132 (*m_xProps)[ OUString(
"IsFolder") ]
134 (*m_xProps)[ OUString(
"IsDocument") ]
141 m_bTrailingSlash( false )
143 (*m_xProps)[ OUString(
"Title") ]
150 m_bTrailingSlash( false )
155 : m_aEscapedTitle(rOther.m_aEscapedTitle)
157 , m_bTrailingSlash(rOther.m_bTrailingSlash)
164 return get( rName ) !=
nullptr;
169 const OUString & rName )
const
173 return pProp->
value();
180 const OUString & rName )
const
182 PropertyValueMap::const_iterator it =
m_xProps->find( rName );
183 const PropertyValueMap::const_iterator
end =
m_xProps->end();
187 it = std::find_if(
m_xProps->cbegin(), end,
188 [&rName](
const PropertyValueMap::value_type& rEntry) {
189 return rEntry.first.equalsIgnoreAsciiCase( rName );
192 return &(*it).second;
197 return &(*it).second;
203 const uno::Sequence< beans::Property > & rProps,
204 std::vector< OUString > & propertyNames )
219 bool bCreationDate =
false;
220 bool bLastModified =
false;
221 bool bContentType =
false;
222 bool bContentLength =
false;
223 bool bResourceType =
false;
225 for (
const beans::Property & rProp : rProps )
227 if ( rProp.Name ==
"Title" )
234 if ( !bCreationDate )
237 bCreationDate =
true;
242 if ( !bLastModified )
245 bLastModified =
true;
258 if ( !bContentLength )
261 bContentLength =
true;
264 else if ( rProp.Name ==
"ContentType" || rProp.Name ==
"IsDocument" || rProp.Name ==
"IsFolder" || rProp.Name ==
DAVProperties::RESOURCETYPE )
266 if ( !bResourceType )
269 bResourceType =
true;
274 propertyNames.push_back( rProp.Name );
282 const uno::Sequence< beans::Property > & rProps,
283 std::vector< OUString > & propertyNames )
295 for (
const beans::Property & rProp : rProps )
297 if ( rProp.Name ==
"DateModified" )
299 propertyNames.emplace_back(
"Last-Modified" );
301 else if ( rProp.Name ==
"MediaType" )
303 propertyNames.emplace_back(
"Content-Type" );
305 else if ( rProp.Name ==
"Size" )
307 propertyNames.emplace_back(
"Content-Length" );
311 propertyNames.push_back( rProp.Name );
318 const uno::Sequence< beans::Property >& rProps,
319 std::vector< OUString > & rNamesNotContained )
const
321 rNamesNotContained.clear();
323 for (
const auto& rProp : rProps )
325 const OUString & rName = rProp.Name;
329 rNamesNotContained.push_back( rName );
333 return rNamesNotContained.empty();
338 const std::vector< OUString > & rProps,
341 for (
const OUString & rName : rProps )
367 const css::uno::Any & rValue,
368 bool bIsCaseSensitive )
375 util::DateTime aDate;
378 (*m_xProps)[ OUString(
"DateCreated") ]
393 (*m_xProps)[ OUString(
"Size") ]
396 else if ( rName.equalsIgnoreAsciiCase(
"Content-Length" ) )
405 (*m_xProps)[ OUString(
"Size") ]
411 (*m_xProps)[ OUString(
"MediaType") ]
414 else if ( rName.equalsIgnoreAsciiCase(
"Content-Type" ) )
420 (*m_xProps)[ OUString(
"MediaType") ]
431 util::DateTime aDate;
434 (*m_xProps)[ OUString(
"DateModified") ]
437 else if ( rName.equalsIgnoreAsciiCase(
"Last-Modified" ) )
445 util::DateTime aDate;
448 (*m_xProps)[ OUString(
"DateModified") ]
460 bool bFolder = aValue.equalsIgnoreAsciiCase(
"collection" );
462 (*m_xProps)[ OUString(
"IsFolder") ]
464 (*m_xProps)[ OUString(
"IsDocument") ]
466 (*m_xProps)[ OUString(
"ContentType") ]
479 (*m_xProps)[ rName ] =
PropertyValue( rValue, bIsCaseSensitive );
488 bool isCachable( OUString
const & rName,
489 bool isCaseSensitive )
491 static const OUString aNonCachableProps [] =
498 OUString(
"DateModified" ),
499 OUString(
"Last-Modified" ),
503 OUString(
"Content-Length" ),
509 for (
const auto & rNonCachableProp : aNonCachableProps)
511 if ( isCaseSensitive )
513 if ( rName == rNonCachableProp )
517 if ( rName.equalsIgnoreAsciiCase( rNonCachableProp ) )
538 for (
const auto& rProp : *props )
540 if ( isCachable( rProp.first, rProp.second.isCaseSensitive() ) )
542 rProp.second.value(),
543 rProp.second.isCaseSensitive() );
549 const std::vector< DAVPropertyValue > & rProps )
551 for (
const auto& rProp : rProps )
553 if ( isCachable( rProp.Name, rProp.IsCaseSensitive ) )
#define WEBDAV_COLLECTION_TYPE
static constexpr OUStringLiteral RESOURCETYPE
static constexpr OUStringLiteral GETCONTENTTYPE
bool containsAllNames(const css::uno::Sequence< css::beans::Property > &rProps, std::vector< OUString > &rNamesNotContained) const
static bool convert(const OUString &, css::util::DateTime &)
CachableContentProperties(const CachableContentProperties &)=delete
OUString GetPathBaseNameUnescaped() const
bool contains(const OUString &rName) const
bool isCaseSensitive() const
const css::uno::Any & value() const
static constexpr OUStringLiteral LOCKDISCOVERY
ContentProperties m_aProps
static void UCBNamesToHTTPNames(const css::uno::Sequence< css::beans::Property > &rProps, std::vector< OUString > &resources)
OUString GetPathBaseName() const
#define WEBDAV_CONTENT_TYPE
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
const std::unique_ptr< PropertyValueMap > & getProperties() const
std::unordered_map< OUString, PropertyValue > PropertyValueMap
static css::uno::Any m_aEmptyAny
static constexpr OUStringLiteral GETCONTENTLENGTH
enumrange< T >::Iterator end(enumrange< T >)
static constexpr OUStringLiteral CREATIONDATE
void addProperties(const ContentProperties &rProps)
void addProperty(const OUString &rName, const css::uno::Any &rValue, bool bIsCaseSensitive)
const css::uno::Any & getValue(const OUString &rName) const
std::vector< DAVPropertyValue > properties
static constexpr OUStringLiteral GETETAG
std::unique_ptr< PropertyValueMap > m_xProps
static void UCBNamesToDAVNames(const css::uno::Sequence< css::beans::Property > &rProps, std::vector< OUString > &resources)
const PropertyValue * get(const OUString &rName) const
void addProperties(const std::vector< OUString > &rProps, const ContentProperties &rContentProps)
static constexpr OUStringLiteral GETLASTMODIFIED