Kaydet (Commit) 41c05c60 authored tarafından Ariel Constenla-Haile's avatar Ariel Constenla-Haile Kaydeden (comit) Stephan Bergmann

i121935 - UCB: new "addProperty" and "removeProperty" commands

(cherry picked from commit 3d5d6017)
Conflicts:
	offapi/com/sun/star/ucb/Content.idl
	offapi/com/sun/star/ucb/makefile.mk
	ucb/source/ucp/webdav/DAVProperties.cxx
	ucb/source/ucp/webdav/webdavcontent.cxx
plus headerize.pl

Change-Id: I59b270ef5a72271671ae0857d11f557eec829387
üst 6e0d836f
...@@ -3858,6 +3858,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/ucb,\ ...@@ -3858,6 +3858,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/ucb,\
PostCommandArgument \ PostCommandArgument \
PostCommandArgument2 \ PostCommandArgument2 \
Priority \ Priority \
PropertyCommandArgument \
PropertyValueInfo \ PropertyValueInfo \
PropertyValueState \ PropertyValueState \
RecipientInfo \ RecipientInfo \
......
...@@ -448,6 +448,65 @@ published service Content ...@@ -448,6 +448,65 @@ published service Content
</p> </p>
</td> </td>
</tr> </tr>
<tr>
<td>addProperty</td>
<td>void</td>
<td><type>PropertyCommandArgument</type> aCmdArg</td>
<td>
Adds a new properties to the content.
<p>
<member>PropertyCommandArgument::Property</member>
contains information about the property to be added.
<member>PropertyCommandArgument::DefaultValue</member>
may contain the default value for the property. Its type must
match the one specified in <member scope="com::sun::star::beans">Property::Type</member>.
</p>
<p>Note that the dynamic properties must be kept persistent. The
service <type>Store</type> (UCB persistence service) may be used to
implement this.</p>
<p><b>Important:</b> The implementation must at least support
adding properties of the following basic data types:</p>
<p>
<ul>
<li>boolean
<li>char
<li>byte
<li>string
<li>short
<li>long
<li>hyper
<li>float
<li>double
</ul>
</p>
<p>
Raises a <type scope="com::sun::star::beans">PropertyExistException</type>
if a property with the same name already exists;
<type scope="com::sun::star::beans">IllegalTypeException</type>
if the property has an unsupported type;
<type scope="com::sun::star::lang">IllegalArgumentException</type>
if the Name of the property is empty.</p>
<blockquote>
Note: This command replaces the deprecated interface method
<member scope="com::sun::star::beans">XPropertyContainer::addProperty</member>.
</blockquote>
</td>
</tr>
<tr>
<td>removeProperty</td>
<td>void</td>
<td>string PropertyName</td>
<td>Removes the properties from the content.
<p>Raises a <type scope="com::sun::star::beans">UnknownPropertyException</type>
if the property does not exist;
<type scope="com::sun::star::beans">NotRemoveableException</type>
if the property is not removable.</p>
<blockquote>
Note: This command replaces the deprecated interface method
<member scope="com::sun::star::beans">XPropertyContainer::removeProperty</member>.
</blockquote>
</td>
</tr>
</table> </table>
<h3>Properties</h3> <h3>Properties</h3>
...@@ -785,7 +844,7 @@ published service Content ...@@ -785,7 +844,7 @@ published service Content
<td>TargetURL</td> <td>TargetURL</td>
<td>string</td> <td>string</td>
<td>for contents that are links to other contents, contains the URL of <td>for contents that are links to other contents, contains the URL of
the target content</td> the target content</td>
</tr> </tr>
<tr> <tr>
<td>TimeLimitStore</td> <td>TimeLimitStore</td>
...@@ -796,7 +855,7 @@ published service Content ...@@ -796,7 +855,7 @@ published service Content
<td>UserName</td> <td>UserName</td>
<td>string</td> <td>string</td>
<td>contains a user name. (e.g. the user name needed to access a <td>contains a user name. (e.g. the user name needed to access a
POP3-Account)</td> POP3-Account)</td>
</tr> </tr>
<tr> <tr>
<td>VerificationMode</td> <td>VerificationMode</td>
......
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef __com_sun_star_ucb_PropertyCommandArgument_idl__
#define __com_sun_star_ucb_PropertyCommandArgument_idl__
#include <com/sun/star/beans/Property.idl>
module com { module sun { module star { module ucb {
/** The argument for the "addProperty" command.
@see XCommandProcessor
@since Apache OpenOffice 4.0
*/
struct PropertyCommandArgument
{
/** The property that the command has to add.
*/
com::sun::star::beans::Property Property;
/** The default value of the property.
*/
any DefaultValue;
};
}; }; }; };
#endif
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <string.h> #include <string.h>
#include "DAVProperties.hxx" #include "DAVProperties.hxx"
#include <rtl/ustrbuf.hxx>
using namespace http_dav_ucp; using namespace http_dav_ucp;
...@@ -180,4 +181,43 @@ bool DAVProperties::isUCBDeadProperty( const SerfPropName & rName ) ...@@ -180,4 +181,43 @@ bool DAVProperties::isUCBDeadProperty( const SerfPropName & rName )
== 0 ) ); == 0 ) );
} }
bool DAVProperties::isUCBSpecialProperty(const rtl::OUString& rFullName, rtl::OUString& rParsedName)
{
sal_Int32 nLen = rFullName.getLength();
if ( nLen <= 0 ||
!rFullName.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "<prop:" ) ) ||
!rFullName.endsWithAsciiL( RTL_CONSTASCII_STRINGPARAM( "\">" ) ) )
return false;
sal_Int32 nStart = RTL_CONSTASCII_LENGTH( "<prop:" );
sal_Int32 nEnd = rFullName.indexOf( sal_Unicode( ' ' ), nStart );
if ( nEnd == -1 )
return false;
rtl::OUString sPropName = rFullName.copy( nStart, nEnd - nStart );
if ( !sPropName.getLength() )
return false;
// TODO skip whitespaces?
if ( !rFullName.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "xmlns:prop=\"" ), ++nEnd ) )
return false;
nStart = nEnd + RTL_CONSTASCII_LENGTH( "xmlns:prop=\"" );
nEnd = rFullName.indexOf( sal_Unicode( '"' ), nStart );
if ( nEnd != nLen - RTL_CONSTASCII_LENGTH( "\">" ) )
return false;
rtl::OUString sNamesp = rFullName.copy( nStart, nEnd - nStart );
if ( !( nLen = sNamesp.getLength() ) )
return false;
rtl::OUStringBuffer aBuff( sNamesp );
if ( sNamesp[nLen - 1] != '/' )
aBuff.append( sal_Unicode( '/' ) );
aBuff.append( sPropName );
rParsedName = aBuff.makeStringAndClear();
return rParsedName.getLength();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -48,6 +48,8 @@ struct DAVProperties ...@@ -48,6 +48,8 @@ struct DAVProperties
OUString & rFullName ); OUString & rFullName );
static bool isUCBDeadProperty( const SerfPropName & rName ); static bool isUCBDeadProperty( const SerfPropName & rName );
static bool isUCBSpecialProperty( const rtl::OUString & rFullName,
rtl::OUString & rParsedName );
}; };
} // namespace http_dav_ucp } // namespace http_dav_ucp
......
...@@ -46,6 +46,7 @@ namespace com { namespace sun { namespace star { namespace sdbc { ...@@ -46,6 +46,7 @@ namespace com { namespace sun { namespace star { namespace sdbc {
namespace com { namespace sun { namespace star { namespace ucb { namespace com { namespace sun { namespace star { namespace ucb {
struct OpenCommandArgument2; struct OpenCommandArgument2;
struct PropertyCommandArgument;
struct PostCommandArgument2; struct PostCommandArgument2;
struct TransferInfo; struct TransferInfo;
} } } } } } } }
...@@ -190,6 +191,21 @@ private: ...@@ -190,6 +191,21 @@ private:
const com::sun::star::uno::Reference< const com::sun::star::uno::Reference<
com::sun::star::ucb::XCommandEnvironment >& Environment ); com::sun::star::ucb::XCommandEnvironment >& Environment );
// XPropertyContainer replacement
void addProperty( const com::sun::star::ucb::PropertyCommandArgument &aCmdArg,
const com::sun::star::uno::Reference<
com::sun::star::ucb::XCommandEnvironment >& Environment )
throw( com::sun::star::beans::PropertyExistException,
com::sun::star::beans::IllegalTypeException,
com::sun::star::lang::IllegalArgumentException,
com::sun::star::uno::RuntimeException );
void removeProperty( const rtl::OUString& Name,
const com::sun::star::uno::Reference<
com::sun::star::ucb::XCommandEnvironment >& Environment )
throw( com::sun::star::beans::UnknownPropertyException,
com::sun::star::beans::NotRemoveableException,
com::sun::star::uno::RuntimeException );
public: public:
Content( const ::com::sun::star::uno::Reference< Content( const ::com::sun::star::uno::Reference<
::com::sun::star::lang::XMultiServiceFactory >& rxSMgr, ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <com/sun/star/ucb/OpenCommandArgument2.hpp> #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
#include <com/sun/star/ucb/InsertCommandArgument.hpp> #include <com/sun/star/ucb/InsertCommandArgument.hpp>
#include <com/sun/star/ucb/PostCommandArgument2.hpp> #include <com/sun/star/ucb/PostCommandArgument2.hpp>
#include <com/sun/star/ucb/PropertyCommandArgument.hpp>
#include <com/sun/star/ucb/TransferInfo.hpp> #include <com/sun/star/ucb/TransferInfo.hpp>
#include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/util/DateTime.hpp> #include <com/sun/star/util/DateTime.hpp>
...@@ -492,7 +493,7 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands( ...@@ -492,7 +493,7 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands(
{ {
osl::Guard< osl::Mutex > aGuard( m_aMutex ); osl::Guard< osl::Mutex > aGuard( m_aMutex );
uno::Sequence< ucb::CommandInfo > aCmdInfo( 8 ); uno::Sequence< ucb::CommandInfo > aCmdInfo( 10 );
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
// Mandatory commands // Mandatory commands
...@@ -553,6 +554,18 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands( ...@@ -553,6 +554,18 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands(
-1, -1,
getCppuType( static_cast< getCppuType( static_cast<
ucb::PostCommandArgument2 * >( 0 ) ) ); ucb::PostCommandArgument2 * >( 0 ) ) );
aCmdInfo[ 8 ] =
ucb::CommandInfo(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "addProperty" ) ),
-1,
getCppuType( static_cast<
ucb::PropertyCommandArgument * >( 0 ) ) );
aCmdInfo[ 9 ] =
ucb::CommandInfo(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "removeProperty" ) ),
-1,
getCppuType( static_cast<
rtl::OUString * >( 0 ) ) );
sal_Bool bFolder = sal_False; sal_Bool bFolder = sal_False;
......
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