Kaydet (Commit) 24f19e7e authored tarafından Kai Sommerfeld's avatar Kai Sommerfeld

#102945# - Added support for new property "BaseURI".

üst 9d99bc95
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: ContentProperties.cxx,v $ * $RCSfile: ContentProperties.cxx,v $
* *
* $Revision: 1.5 $ * $Revision: 1.6 $
* *
* last change: $Author: kso $ $Date: 2002-09-16 14:37:09 $ * last change: $Author: kso $ $Date: 2002-09-24 14:15:49 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -288,10 +288,7 @@ ContentProperties::ContentProperties( const DAVResource& rResource ) ...@@ -288,10 +288,7 @@ ContentProperties::ContentProperties( const DAVResource& rResource )
if ( rResource.uri.getStr()[ rResource.uri.getLength() - 1 ] if ( rResource.uri.getStr()[ rResource.uri.getLength() - 1 ]
== sal_Unicode( '/' ) ) == sal_Unicode( '/' ) )
{ m_bTrailingSlash = sal_True;
// if ( pIsFolder && *pIsFolder )
m_bTrailingSlash = sal_True;
}
} }
//========================================================================= //=========================================================================
...@@ -320,10 +317,11 @@ ContentProperties::ContentProperties( const rtl::OUString & rTitle ) ...@@ -320,10 +317,11 @@ ContentProperties::ContentProperties( const rtl::OUString & rTitle )
//========================================================================= //=========================================================================
ContentProperties::ContentProperties( const ContentProperties & rOther ) ContentProperties::ContentProperties( const ContentProperties & rOther )
: m_aEscapedTitle( rOther.m_aEscapedTitle ), : m_aEscapedTitle( rOther.m_aEscapedTitle ),
m_xProps( rOther.m_xProps.get()
? new PropertyValueMap( *rOther.m_xProps )
: new PropertyValueMap ),
m_bTrailingSlash( rOther.m_bTrailingSlash ) m_bTrailingSlash( rOther.m_bTrailingSlash )
{ {
if ( rOther.m_xProps.get() )
m_xProps.reset( new PropertyValueMap( *rOther.m_xProps ) );
} }
//========================================================================= //=========================================================================
...@@ -505,18 +503,27 @@ void ContentProperties::UCBNamesToHTTPNames( ...@@ -505,18 +503,27 @@ void ContentProperties::UCBNamesToHTTPNames(
void ContentProperties::getMappableHTTPHeaders( void ContentProperties::getMappableHTTPHeaders(
std::vector< rtl::OUString > & rHeaderNames ) std::vector< rtl::OUString > & rHeaderNames )
{ {
// -> DateModified
rHeaderNames.push_back( rHeaderNames.push_back(
rtl::OUString::createFromAscii( "Last-Modified" ) ); rtl::OUString::createFromAscii( "Last-Modified" ) );
// -> MediaType
rHeaderNames.push_back( rHeaderNames.push_back(
rtl::OUString::createFromAscii( "Content-Type" ) ); rtl::OUString::createFromAscii( "Content-Type" ) );
// -> Size
rHeaderNames.push_back( rHeaderNames.push_back(
rtl::OUString::createFromAscii( "Content-Length" ) ); rtl::OUString::createFromAscii( "Content-Length" ) );
// -> BaseURI
rHeaderNames.push_back(
rtl::OUString::createFromAscii( "Content-Location" ) );
} }
//========================================================================= //=========================================================================
bool ContentProperties::containsAllNames( bool ContentProperties::containsAllNames(
const uno::Sequence< beans::Property >& rProps, const uno::Sequence< beans::Property >& rProps,
std::vector< rtl::OUString > & rNamesNotContained ) std::vector< rtl::OUString > & rNamesNotContained ) const
{ {
rNamesNotContained.clear(); rNamesNotContained.clear();
...@@ -535,8 +542,9 @@ bool ContentProperties::containsAllNames( ...@@ -535,8 +542,9 @@ bool ContentProperties::containsAllNames(
} }
//========================================================================= //=========================================================================
void ContentProperties::add( const std::vector< rtl::OUString > & rProps, void ContentProperties::addProperties(
const ContentProperties & rContentProps ) const std::vector< rtl::OUString > & rProps,
const ContentProperties & rContentProps )
{ {
std::vector< rtl::OUString >::const_iterator it = rProps.begin(); std::vector< rtl::OUString >::const_iterator it = rProps.begin();
std::vector< rtl::OUString >::const_iterator end = rProps.end(); std::vector< rtl::OUString >::const_iterator end = rProps.end();
...@@ -559,3 +567,10 @@ void ContentProperties::add( const std::vector< rtl::OUString > & rProps, ...@@ -559,3 +567,10 @@ void ContentProperties::add( const std::vector< rtl::OUString > & rProps,
} }
} }
//=========================================================================
void ContentProperties::addProperty( const rtl::OUString & rName,
const com::sun::star::uno::Any & rValue )
{
(*m_xProps)[ rName ] = rValue;
}
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: ContentProperties.hxx,v $ * $RCSfile: ContentProperties.hxx,v $
* *
* $Revision: 1.6 $ * $Revision: 1.7 $
* *
* last change: $Author: kso $ $Date: 2002-09-18 16:01:07 $ * last change: $Author: kso $ $Date: 2002-09-24 14:15:49 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -173,20 +173,27 @@ public: ...@@ -173,20 +173,27 @@ public:
// return true, if all properties contained in rProps are contained in // return true, if all properties contained in rProps are contained in
// this ContentProperties instance. Otherwiese, false will be returned. // this ContentProperties instance. Otherwiese, false will be returned.
// rNamesNotContained contain the missing names. // rNamesNotContained contain the missing names.
bool containsAllNames( const com::sun::star::uno::Sequence< bool containsAllNames(
com::sun::star::beans::Property >& rProps, const com::sun::star::uno::Sequence<
std::vector< rtl::OUString > & rNamesNotContained ); com::sun::star::beans::Property >& rProps,
std::vector< rtl::OUString > & rNamesNotContained ) const;
// adds all properties described by rProps that are actually contained in // adds all properties described by rProps that are actually contained in
// rContentProps to this instance. In case of duplicates the value // rContentProps to this instance. In case of duplicates the value
// already contained in this will left anchanged. // already contained in this will left anchanged.
void add( const std::vector< rtl::OUString > & rProps, void addProperties( const std::vector< rtl::OUString > & rProps,
const ContentProperties & rContentProps ); const ContentProperties & rContentProps );
// overwrites probably existing entry.
void addProperty( const rtl::OUString & rName,
const com::sun::star::uno::Any & rValue );
bool isTrailingSlash() const { return m_bTrailingSlash; } bool isTrailingSlash() const { return m_bTrailingSlash; }
const rtl::OUString & getEscapedTitle() const { return m_aEscapedTitle; } const rtl::OUString & getEscapedTitle() const { return m_aEscapedTitle; }
// Not good to expose implementation details, but this is actually an
// internal class.
const std::auto_ptr< PropertyValueMap > & getProperties() const const std::auto_ptr< PropertyValueMap > & getProperties() const
{ return m_xProps; } { return m_xProps; }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: DAVRequestEnvironment.hxx,v $ * $RCSfile: DAVRequestEnvironment.hxx,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: kso $ $Date: 2002-09-24 13:20:37 $ * last change: $Author: kso $ $Date: 2002-09-24 14:15:49 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -61,8 +61,6 @@ ...@@ -61,8 +61,6 @@
#ifndef _DAVREQUESTENVIRONMENT_HXX_ #ifndef _DAVREQUESTENVIRONMENT_HXX_
#define _DAVREQUESTENVIRONMENT_HXX_ #define _DAVREQUESTENVIRONMENT_HXX_
#include <memory>
#ifndef _RTL_REF_HXX_ #ifndef _RTL_REF_HXX_
#include <rtl/ref.hxx> #include <rtl/ref.hxx>
#endif #endif
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: webdavcontent.cxx,v $ * $RCSfile: webdavcontent.cxx,v $
* *
* $Revision: 1.35 $ * $Revision: 1.36 $
* *
* last change: $Author: kso $ $Date: 2002-09-23 10:16:10 $ * last change: $Author: kso $ $Date: 2002-09-24 14:15:49 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -70,6 +70,9 @@ ...@@ -70,6 +70,9 @@
#ifndef _OSL_DIAGNOSE_H_ #ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h> #include <osl/diagnose.h>
#endif #endif
#ifndef _RTL_URI_HXX_
#include <rtl/uri.hxx>
#endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp>
...@@ -1397,7 +1400,33 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( ...@@ -1397,7 +1400,33 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
if ( !xProps->containsAllNames( rProperties, aMissingProps ) ) if ( !xProps->containsAllNames( rProperties, aMissingProps ) )
{ {
// Add props contained in cache... // Add props contained in cache...
xProps->add( aMissingProps, *m_xCachedProps ); xProps->addProperties( aMissingProps, *m_xCachedProps );
}
}
// Add BaseURI property, if requested.
if ( !xProps->contains(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BaseURI" ) ) ) )
{
sal_Int32 nCount = rProperties.getLength();
if ( nCount )
{
const beans::Property* pProps = rProperties.getConstArray();
for ( sal_Int32 n = 0; n < nCount; ++n )
{
const rtl::OUString & rName = pProps[ n ].Name;
if ( rName.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "BaseURI" ) ) )
{
// BaseURI requested! Append value.
xProps->addProperty( rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"BaseURI" ) ),
uno::makeAny( getBaseURI() ) );
break;
}
}
} }
} }
...@@ -2487,3 +2516,36 @@ void Content::cancelCommandExecution( ...@@ -2487,3 +2516,36 @@ void Content::cancelCommandExecution(
// Unreachable // Unreachable
} }
//=========================================================================
const rtl::OUString Content::getBaseURI()
{
// First, try to obtain value of response header "Content-Location".
if ( m_xCachedProps.get() )
{
rtl::OUString aLocation;
m_xCachedProps->getValue( rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"Content-Location" ) ) ) >>= aLocation;
if ( aLocation.getLength() )
{
#if 0
// @@@ rtl::Uri::convertRelToAbs not yet available, will be after release
// of 6.1 EA2.
try
{
// Do not use m_xIdentifier->getContentIdentifier() because it
// for example does not reflect redirects applied to requests
// done using the original URI but m_xResAccess' URI does.
return rtl::Uri::convertRelToAbs( m_xResAccess->getURL(),
aLocation );
}
catch ( rtl::MalformedUriException const & )
{
}
#endif
}
}
return rtl::OUString( m_xResAccess->getURL() );
}
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: webdavcontent.hxx,v $ * $RCSfile: webdavcontent.hxx,v $
* *
* $Revision: 1.15 $ * $Revision: 1.16 $
* *
* last change: $Author: kso $ $Date: 2002-09-16 14:37:14 $ * last change: $Author: kso $ $Date: 2002-09-24 14:15:50 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -164,6 +164,8 @@ private: ...@@ -164,6 +164,8 @@ private:
const ::com::sun::star::uno::Reference< const ::com::sun::star::uno::Reference<
::com::sun::star::ucb::XContentIdentifier >& xNewId ); ::com::sun::star::ucb::XContentIdentifier >& xNewId );
const rtl::OUString getBaseURI();
// Command "insert" // Command "insert"
void insert( const ::com::sun::star::uno::Reference< void insert( const ::com::sun::star::uno::Reference<
::com::sun::star::io::XInputStream > & xInputStream, ::com::sun::star::io::XInputStream > & xInputStream,
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: webdavcontentcaps.cxx,v $ * $RCSfile: webdavcontentcaps.cxx,v $
* *
* $Revision: 1.11 $ * $Revision: 1.12 $
* *
* last change: $Author: kso $ $Date: 2002-09-23 10:16:10 $ * last change: $Author: kso $ $Date: 2002-09-24 14:15:50 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -213,6 +213,14 @@ bool ContentProvider::getProperty( ...@@ -213,6 +213,14 @@ bool ContentProvider::getProperty(
beans::PropertyAttribute::BOUND beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY ) ); | beans::PropertyAttribute::READONLY ) );
m_pProps->insert(
beans::Property(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BaseURI" ) ),
-1,
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY ) );
// Standard DAV properties. // Standard DAV properties.
m_pProps->insert( m_pProps->insert(
...@@ -384,6 +392,7 @@ uno::Sequence< beans::Property > Content::getProperties( ...@@ -384,6 +392,7 @@ uno::Sequence< beans::Property > Content::getProperties(
sal_Bool bHasIsDocument = sal_False; sal_Bool bHasIsDocument = sal_False;
sal_Bool bHasIsFolder = sal_False; sal_Bool bHasIsFolder = sal_False;
sal_Bool bHasTitle = sal_False; sal_Bool bHasTitle = sal_False;
sal_Bool bHasBaseURI = sal_False;
sal_Bool bHasDateCreated = sal_False; sal_Bool bHasDateCreated = sal_False;
sal_Bool bHasDateModified = sal_False; sal_Bool bHasDateModified = sal_False;
sal_Bool bHasMediaType = sal_False; sal_Bool bHasMediaType = sal_False;
...@@ -438,6 +447,12 @@ uno::Sequence< beans::Property > Content::getProperties( ...@@ -438,6 +447,12 @@ uno::Sequence< beans::Property > Content::getProperties(
{ {
bHasTitle = sal_True; bHasTitle = sal_True;
} }
else if ( !bHasBaseURI &&
(*it).equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "BaseURI" ) ) )
{
bHasBaseURI = sal_True;
}
else if ( !bHasDateCreated && else if ( !bHasDateCreated &&
(*it).equalsAsciiL( (*it).equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "DateCreated" ) ) ) RTL_CONSTASCII_STRINGPARAM( "DateCreated" ) ) )
...@@ -481,10 +496,21 @@ uno::Sequence< beans::Property > Content::getProperties( ...@@ -481,10 +496,21 @@ uno::Sequence< beans::Property > Content::getProperties(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ) ); rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ) );
if ( !bHasTitle ) if ( !bHasTitle )
{
// Always present since it can be calculated from content's URI.
aPropSet.insert( aPropSet.insert(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ) ); rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ) );
}
// Add optional properties. // Add optional properties.
if ( !bHasBaseURI )
{
// Always present since it can be calculated from content's URI.
aPropSet.insert(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BaseURI" ) ) );
}
if ( !bHasDateCreated && bHasCreationDate ) if ( !bHasDateCreated && bHasCreationDate )
aPropSet.insert( aPropSet.insert(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ) ); rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment