21 #include <com/sun/star/util/DateTime.hpp>
74 uno::Any ContentProperties::m_aEmptyAny;
76 ContentProperties::ContentProperties(
const DAVResource& rResource )
78 m_bTrailingSlash( false )
81 "ContentProperties ctor - Empty resource URI!" );
89 (*m_xProps)[ OUString(
"Title" ) ]
95 (*m_xProps)[ OUString(
"Title" ) ]
98 OUString(
"*** unknown ***" ) ),
102 for (
const auto& rProp : rResource.
properties )
107 if ( rResource.
uri.endsWith(
"/") )
113 const OUString & rTitle,
bool bFolder )
115 m_bTrailingSlash( false )
117 (*m_xProps)[ OUString(
"Title" ) ]
119 (*m_xProps)[ OUString(
"IsFolder" ) ]
121 (*m_xProps)[ OUString(
"IsDocument" ) ]
128 m_bTrailingSlash( false )
130 (*m_xProps)[ OUString(
"Title" ) ]
137 m_bTrailingSlash( false )
143 : m_aEscapedTitle( rOther.m_aEscapedTitle ),
147 m_bTrailingSlash( rOther.m_bTrailingSlash )
162 const OUString & rName )
const
166 return pProp->
value();
173 const OUString & rName )
const
175 PropertyValueMap::const_iterator it =
m_xProps->find( rName );
176 const PropertyValueMap::const_iterator
end =
m_xProps->end();
180 it = std::find_if(
m_xProps->cbegin(), end,
181 [&rName](
const PropertyValueMap::value_type& rEntry) {
182 return rEntry.first.equalsIgnoreAsciiCase( rName );
185 return &(*it).second;
190 return &(*it).second;
196 const uno::Sequence< beans::Property > & rProps,
197 std::vector< OUString > & propertyNames,
198 bool bIncludeUnmatched )
213 bool bCreationDate =
false;
214 bool bLastModified =
false;
215 bool bContentType =
false;
216 bool bContentLength =
false;
217 bool bResourceType =
false;
219 sal_Int32
nCount = rProps.getLength();
220 for ( sal_Int32 n = 0;
n < nCount; ++
n )
222 const beans::Property & rProp = rProps[
n ];
224 if ( rProp.Name ==
"Title" )
229 else if ( rProp.Name ==
"DateCreated" ||
232 if ( !bCreationDate )
235 bCreationDate =
true;
238 else if ( rProp.Name ==
"DateModified" ||
241 if ( !bLastModified )
243 propertyNames.push_back(
245 bLastModified =
true;
248 else if ( rProp.Name ==
"MediaType" ||
253 propertyNames.push_back(
258 else if ( rProp.Name ==
"Size" ||
261 if ( !bContentLength )
263 propertyNames.push_back(
265 bContentLength =
true;
268 else if ( rProp.Name ==
"ContentType" ||
269 rProp.Name ==
"IsDocument" ||
270 rProp.Name ==
"IsFolder" ||
273 if ( !bResourceType )
276 bResourceType =
true;
281 if ( bIncludeUnmatched )
282 propertyNames.push_back( rProp.Name );
290 const uno::Sequence< beans::Property > & rProps,
291 std::vector< OUString > & propertyNames,
292 bool bIncludeUnmatched )
304 sal_Int32 nCount = rProps.getLength();
305 for ( sal_Int32 n = 0;
n < nCount; ++
n )
307 const beans::Property & rProp = rProps[
n ];
309 if ( rProp.Name ==
"DateModified" )
311 propertyNames.push_back( OUString(
"Last-Modified" ) );
313 else if ( rProp.Name ==
"MediaType" )
315 propertyNames.push_back( OUString(
"Content-Type" ) );
317 else if ( rProp.Name ==
"Size" )
319 propertyNames.push_back( OUString(
"Content-Length" ) );
323 if ( bIncludeUnmatched )
324 propertyNames.push_back( rProp.Name );
331 const uno::Sequence< beans::Property >& rProps,
332 std::vector< OUString > & rNamesNotContained )
const
334 rNamesNotContained.clear();
336 sal_Int32 nCount = rProps.getLength();
337 for ( sal_Int32 n = 0;
n < nCount; ++
n )
339 const OUString & rName = rProps[
n ].Name;
343 rNamesNotContained.push_back( rName );
347 return ( rNamesNotContained.size() == 0 );
352 const std::vector< OUString > & rProps,
355 for (
const OUString & rName : rProps )
376 for (
const auto& rProp : *rProps.
m_xProps )
379 rProp.first, rProp.second.value(), rProp.second.isCaseSensitive() );
385 const std::vector< DAVPropertyValue > & rProps )
387 for (
const auto& rProp : rProps )
401 const css::uno::Any & rValue,
402 bool bIsCaseSensitive )
409 util::DateTime aDate;
412 (*m_xProps)[ OUString(
"DateCreated" ) ]
427 (*m_xProps)[ OUString(
"Size" ) ]
430 else if ( rName ==
"Content-Length" )
439 (*m_xProps)[ OUString(
"Size" ) ]
445 (*m_xProps)[ OUString(
"MediaType" ) ]
448 else if ( rName ==
"Content-Type" )
454 (*m_xProps)[ OUString(
"MediaType" ) ]
465 util::DateTime aDate;
468 (*m_xProps)[ OUString(
"DateModified" ) ]
471 else if ( rName ==
"Last-Modified" )
479 util::DateTime aDate;
482 (*m_xProps)[ OUString(
"DateModified" ) ]
495 aValue.equalsIgnoreAsciiCase(
"collection" );
497 (*m_xProps)[ OUString(
"IsFolder" ) ]
499 (*m_xProps)[ OUString(
"IsDocument" ) ]
501 (*m_xProps)[ OUString(
"ContentType" ) ]
511 (*m_xProps)[ rName ] =
PropertyValue( rValue, bIsCaseSensitive );
520 bool isCachable( OUString
const & rName,
521 bool isCaseSensitive )
523 const OUString aNonCachableProps [] =
530 OUString(
"DateModified" ),
531 OUString(
"Last-Modified" ),
535 OUString(
"Content-Length" ),
541 for ( sal_uInt32 n = 0;
542 n < (
sizeof( aNonCachableProps )
543 /
sizeof( aNonCachableProps[ 0 ] ) );
546 if ( isCaseSensitive )
548 if ( rName.equals( aNonCachableProps[ n ] ) )
552 if ( rName.equalsIgnoreAsciiCase( aNonCachableProps[ n ] ) )
573 for (
const auto& rProp : *props )
575 if ( isCachable( rProp.first, rProp.second.isCaseSensitive() ) )
577 rProp.second.value(),
578 rProp.second.isCaseSensitive() );
584 const std::vector< DAVPropertyValue > & rProps )
586 for (
const auto& rProp : rProps )
588 if ( isCachable( rProp.Name, rProp.IsCaseSensitive ) )
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
#define WEBDAV_COLLECTION_TYPE
CachableContentProperties(const CachableContentProperties &)
static const OUString GETCONTENTTYPE
static const OUString RESOURCETYPE
OUString GetPathBaseName() const
bool isCaseSensitive() const
void addProperties(const ContentProperties &rProps)
static void UCBNamesToHTTPNames(const css::uno::Sequence< css::beans::Property > &rProps, std::vector< OUString > &resources, bool bIncludeUnmatched=true)
static const OUString GETLASTMODIFIED
static const OUString CREATIONDATE
void addProperty(const OUString &rName, const css::uno::Any &rValue, bool bIsCaseSensitive)
std::unordered_map< OUString, PropertyValue > PropertyValueMap
static void UCBNamesToDAVNames(const css::uno::Sequence< css::beans::Property > &rProps, std::vector< OUString > &resources, bool bIncludeUnmatched=true)
void addProperties(const std::vector< OUString > &rProps, const ContentProperties &rContentProps)
#define WEBDAV_CONTENT_TYPE
std::unique_ptr< PropertyValueMap > m_xProps
const css::uno::Any & getValue(const OUString &rName) const
static const OUString GETETAG
bool containsAllNames(const css::uno::Sequence< css::beans::Property > &rProps, std::vector< OUString > &rNamesNotContained) const
static const OUString LOCKDISCOVERY
static bool convert(const OUString &, css::util::DateTime &)
ContentProperties m_aProps
static const OUString GETCONTENTLENGTH
static css::uno::Any m_aEmptyAny
enumrange< T >::Iterator end(enumrange< T >)
#define SAL_WARN_IF(condition, area, stream)
const PropertyValue * get(const OUString &rName) const
std::vector< DAVPropertyValue > properties
const std::unique_ptr< PropertyValueMap > & getProperties() const
OUString GetPathBaseNameUnescaped() const
bool contains(const OUString &rName) const
const css::uno::Any & value() const