summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorKai Sommerfeld <kso@openoffice.org>2009-12-21 15:53:33 +0100
committerKai Sommerfeld <kso@openoffice.org>2009-12-21 15:53:33 +0100
commit6d2db594f034831a346f0a700bbd2940004902db (patch)
tree840f604dc828edea7a3fec0bc240462798391032 /ucb
parenta0767c49a62d35ea0eba567aaffbce603cb2b684 (diff)
#i61429#, deprecated css.ucb.XContentCreator, implemented replacement.
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/core/ucbcmds.cxx257
-rw-r--r--ucb/source/ucp/file/bc.cxx32
-rw-r--r--ucb/source/ucp/file/filerror.hxx24
-rw-r--r--ucb/source/ucp/file/filglob.cxx3
-rw-r--r--ucb/source/ucp/file/shell.cxx132
-rw-r--r--ucb/source/ucp/file/shell.hxx12
-rw-r--r--ucb/source/ucp/ftp/ftpcontent.cxx208
-rw-r--r--ucb/source/ucp/ftp/ftpcontent.hxx18
-rw-r--r--ucb/source/ucp/ftp/ftpcontentcaps.cxx28
-rw-r--r--ucb/source/ucp/ftp/ftpresultsetI.cxx6
-rw-r--r--ucb/source/ucp/ftp/ftpurl.cxx6
-rw-r--r--ucb/source/ucp/gio/gio_content.cxx196
-rw-r--r--ucb/source/ucp/gio/gio_content.hxx24
-rw-r--r--ucb/source/ucp/gio/gio_datasupplier.cxx12
-rw-r--r--ucb/source/ucp/gvfs/gvfs_content.cxx103
-rw-r--r--ucb/source/ucp/gvfs/gvfs_content.hxx7
-rw-r--r--ucb/source/ucp/hierarchy/hierarchycontent.cxx187
-rw-r--r--ucb/source/ucp/hierarchy/hierarchycontent.hxx3
-rw-r--r--ucb/source/ucp/hierarchy/hierarchycontentcaps.cxx107
-rw-r--r--ucb/source/ucp/package/pkgcontent.cxx165
-rw-r--r--ucb/source/ucp/package/pkgcontent.hxx10
-rw-r--r--ucb/source/ucp/package/pkgcontentcaps.cxx65
-rw-r--r--ucb/source/ucp/tdoc/tdoc_content.cxx217
-rw-r--r--ucb/source/ucp/tdoc/tdoc_content.hxx10
-rw-r--r--ucb/source/ucp/tdoc/tdoc_contentcaps.cxx83
-rw-r--r--ucb/source/ucp/webdav/webdavcontent.cxx71
-rw-r--r--ucb/source/ucp/webdav/webdavcontentcaps.cxx36
27 files changed, 1342 insertions, 680 deletions
diff --git a/ucb/source/core/ucbcmds.cxx b/ucb/source/core/ucbcmds.cxx
index 0db14ca73f..d514ffcaa8 100644
--- a/ucb/source/core/ucbcmds.cxx
+++ b/ucb/source/core/ucbcmds.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -41,11 +41,10 @@
#include <cppuhelper/exc_hlp.hxx>
#include <rtl/ustring.h>
#include <rtl/ustring.hxx>
-#ifndef __COM_SUN_STAR_LANG_XINTERFACE_HPP_
#include <com/sun/star/uno/XInterface.hpp>
-#endif
#include <com/sun/star/beans/PropertyState.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <com/sun/star/io/XActiveDataSink.hpp>
@@ -53,13 +52,12 @@
#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/ucb/CommandEnvironment.hpp>
#include <com/sun/star/ucb/CommandFailedException.hpp>
#include <com/sun/star/ucb/ContentInfoAttribute.hpp>
#include <com/sun/star/ucb/GlobalTransferCommandArgument.hpp>
#include <com/sun/star/ucb/InsertCommandArgument.hpp>
-#ifndef _COM_SUN_STAR_UCB_INTERACTIVEBADTRANSFRERURLEXCEPTION_HPP_
#include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
-#endif
#include <com/sun/star/ucb/NameClash.hpp>
#include <com/sun/star/ucb/NameClashException.hpp>
#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
@@ -79,7 +77,7 @@
using namespace com::sun::star;
-namespace ucb_commands
+namespace
{
//=========================================================================
@@ -182,51 +180,6 @@ void SAL_CALL InteractionHandlerProxy::handle(
//=========================================================================
//
-// class CommandEnvironment.
-//
-//=========================================================================
-
-class CommandEnvironment :
- public cppu::WeakImplHelper1< ucb::XCommandEnvironment >
-{
- uno::Reference< task::XInteractionHandler > m_xIH;
- uno::Reference< ucb::XProgressHandler > m_xPH;
-
-public:
- CommandEnvironment(
- const uno::Reference< task::XInteractionHandler > & xIH,
- const uno::Reference< ucb::XProgressHandler > & xPH )
- : m_xIH( xIH ), m_xPH( xPH ) {}
-
- // XCommandEnvironment methods.
- virtual uno::Reference< task::XInteractionHandler > SAL_CALL
- getInteractionHandler()
- throw ( uno::RuntimeException );
- virtual uno::Reference< ucb::XProgressHandler > SAL_CALL
- getProgressHandler()
- throw ( uno::RuntimeException );
-};
-
-//=========================================================================
-// virtual
-uno::Reference< task::XInteractionHandler > SAL_CALL
-CommandEnvironment::getInteractionHandler()
- throw ( uno::RuntimeException )
-{
- return m_xIH;
-}
-
-//=========================================================================
-// virtual
-uno::Reference< ucb::XProgressHandler > SAL_CALL
-CommandEnvironment::getProgressHandler()
- throw ( uno::RuntimeException )
-{
- return m_xPH;
-}
-
-//=========================================================================
-//
// class ActiveDataSink.
//
//=========================================================================
@@ -389,7 +342,7 @@ sal_Bool SAL_CALL CommandProcessorInfo::hasCommandByHandle( sal_Int32 Handle )
//=========================================================================
//=========================================================================
-static rtl::OUString createDesiredName(
+rtl::OUString createDesiredName(
const rtl::OUString & rSourceURL, const rtl::OUString & rNewTitle )
{
rtl::OUString aName( rNewTitle );
@@ -438,13 +391,13 @@ static rtl::OUString createDesiredName(
return rtl::OUString( aName );
}
-static rtl::OUString createDesiredName(
+rtl::OUString createDesiredName(
const ucb::GlobalTransferCommandArgument & rArg )
{
return createDesiredName( rArg.SourceURL, rArg.NewTitle );
}
-static rtl::OUString createDesiredName(
+rtl::OUString createDesiredName(
const ucb::TransferInfo & rArg )
{
return createDesiredName( rArg.SourceURL, rArg.NewTitle );
@@ -453,7 +406,7 @@ static rtl::OUString createDesiredName(
//=========================================================================
enum NameClashContinuation { NOT_HANDLED, ABORT, OVERWRITE, NEW_NAME, UNKNOWN };
-static NameClashContinuation interactiveNameClashResolve(
+NameClashContinuation interactiveNameClashResolve(
const uno::Reference< ucb::XCommandEnvironment > & xEnv,
const rtl::OUString & rTargetURL,
const rtl::OUString & rClashingName,
@@ -528,7 +481,7 @@ static NameClashContinuation interactiveNameClashResolve(
}
//=========================================================================
-static bool setTitle(
+bool setTitle(
const uno::Reference< ucb::XCommandProcessor > & xCommandProcessor,
const uno::Reference< ucb::XCommandEnvironment > & xEnv,
const rtl::OUString & rNewTitle )
@@ -576,7 +529,7 @@ static bool setTitle(
}
//=========================================================================
-static uno::Reference< ucb::XContent > createNew(
+uno::Reference< ucb::XContent > createNew(
const TransferCommandContext & rContext,
const uno::Reference< ucb::XContent > & xTarget,
sal_Bool bSourceIsFolder,
@@ -590,10 +543,12 @@ static uno::Reference< ucb::XContent > createNew(
//
//////////////////////////////////////////////////////////////////////
- uno::Reference< ucb::XContentCreator > xCreator(
- xTarget, uno::UNO_QUERY );
+ // First, try it using "CreatabeleContentsInfo" property and
+ // "createNewContent" command -> the "new" way.
- if ( !xCreator.is() )
+ uno::Reference< ucb::XCommandProcessor > xCommandProcessorT(
+ xTarget, uno::UNO_QUERY );
+ if ( !xCommandProcessorT.is() )
{
uno::Any aProps
= uno::makeAny(beans::PropertyValue(
@@ -606,24 +561,77 @@ static uno::Reference< ucb::XContent > createNew(
ucb::IOErrorCode_CANT_CREATE,
uno::Sequence< uno::Any >(&aProps, 1),
rContext.xOrigEnv,
- rtl::OUString::createFromAscii( "Target is no XContentCreator!" ),
+ rtl::OUString::createFromAscii( "Target is no XCommandProcessor!" ),
rContext.xProcessor );
// Unreachable
}
- uno::Sequence< ucb::ContentInfo > aTypesInfo
- = xCreator->queryCreatableContentsInfo();
+ uno::Sequence< beans::Property > aPropsToObtain( 1 );
+ aPropsToObtain[ 0 ].Name
+ = rtl::OUString::createFromAscii( "CreatableContentsInfo" );
+ aPropsToObtain[ 0 ].Handle
+ = -1;
- sal_Int32 nCount = aTypesInfo.getLength();
- if ( !nCount )
+ ucb::Command aGetPropsCommand(
+ rtl::OUString::createFromAscii( "getPropertyValues" ),
+ -1,
+ uno::makeAny( aPropsToObtain ) );
+
+ uno::Reference< sdbc::XRow > xRow;
+ xCommandProcessorT->execute( aGetPropsCommand, 0, rContext.xEnv ) >>= xRow;
+
+ uno::Sequence< ucb::ContentInfo > aTypesInfo;
+ bool bGotTypesInfo = false;
+
+ if ( xRow.is() )
{
- uno::Any aProps
- = uno::makeAny(beans::PropertyValue(
+ uno::Any aValue = xRow->getObject(
+ 1, uno::Reference< container::XNameAccess >() );
+ if ( aValue.hasValue() && ( aValue >>= aTypesInfo ) )
+ {
+ bGotTypesInfo = true;
+ }
+ }
+
+ uno::Reference< ucb::XContentCreator > xCreator;
+
+ if ( !bGotTypesInfo )
+ {
+ // Second, try it using XContentCreator interface -> the "old" way (not
+ // providing the chance to supply an XCommandEnvironment.
+
+ xCreator.set( xTarget, uno::UNO_QUERY );
+
+ if ( !xCreator.is() )
+ {
+ uno::Any aProps
+ = uno::makeAny(beans::PropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"Folder")),
-1,
uno::makeAny(rContext.aArg.TargetURL),
beans::PropertyState_DIRECT_VALUE));
+ ucbhelper::cancelCommandExecution(
+ ucb::IOErrorCode_CANT_CREATE,
+ uno::Sequence< uno::Any >(&aProps, 1),
+ rContext.xOrigEnv,
+ rtl::OUString::createFromAscii( "Target is no XContentCreator!" ),
+ rContext.xProcessor );
+ // Unreachable
+ }
+
+ aTypesInfo = xCreator->queryCreatableContentsInfo();
+ }
+
+ sal_Int32 nCount = aTypesInfo.getLength();
+ if ( !nCount )
+ {
+ uno::Any aProps
+ = uno::makeAny(beans::PropertyValue(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Folder")),
+ -1,
+ uno::makeAny(rContext.aArg.TargetURL),
+ beans::PropertyState_DIRECT_VALUE));
ucbhelper::cancelCommandExecution(
ucb::IOErrorCode_CANT_CREATE,
uno::Sequence< uno::Any >(&aProps, 1),
@@ -673,14 +681,14 @@ static uno::Reference< ucb::XContent > createNew(
}
else
{
- // (not a and not b) or (a and b)
+ // (not a and not b) or (a and b)
// not( a or b) or (a and b)
- //
+ //
if ( ( !!bSourceIsFolder ==
!!( nAttribs
& ucb::ContentInfoAttribute::KIND_FOLDER ) )
&&
- ( !!bSourceIsDocument ==
+ ( !!bSourceIsDocument ==
!!( nAttribs
& ucb::ContentInfoAttribute::KIND_DOCUMENT ) )
)
@@ -710,7 +718,25 @@ static uno::Reference< ucb::XContent > createNew(
//
//////////////////////////////////////////////////////////////
- xNew = xCreator->createNewContent( aTypesInfo[ n ] );
+ if ( !xCreator.is() )
+ {
+ // First, try it using "CreatabeleContentsInfo" property and
+ // "createNewContent" command -> the "new" way.
+ ucb::Command aCreateNewCommand(
+ rtl::OUString::createFromAscii( "createNewContent" ),
+ -1,
+ uno::makeAny( aTypesInfo[ n ] ) );
+
+ xCommandProcessorT->execute( aCreateNewCommand, 0, rContext.xEnv )
+ >>= xNew;
+ }
+ else
+ {
+ // Second, try it using XContentCreator interface -> the "old"
+ // way (not providing the chance to supply an XCommandEnvironment.
+
+ xNew = xCreator->createNewContent( aTypesInfo[ n ] );
+ }
if ( !xNew.is() )
{
@@ -739,7 +765,7 @@ static uno::Reference< ucb::XContent > createNew(
}
//=========================================================================
-static void transferProperties(
+void transferProperties(
const TransferCommandContext & rContext,
const uno::Reference< ucb::XCommandProcessor > & xCommandProcessorS,
const uno::Reference< ucb::XCommandProcessor > & xCommandProcessorN )
@@ -859,7 +885,7 @@ static void transferProperties(
rCurrValue.Name = rCurrProp.Name;
rCurrValue.Handle = rCurrProp.Handle;
rCurrValue.Value = aValue;
-// rCurrValue.State =
+// rCurrValue.State =
nWritePos++;
}
@@ -904,7 +930,7 @@ static void transferProperties(
}
//=========================================================================
-static uno::Reference< io::XInputStream > getInputStream(
+uno::Reference< io::XInputStream > getInputStream(
const TransferCommandContext & rContext,
const uno::Reference< ucb::XCommandProcessor > & xCommandProcessorS )
throw( uno::Exception )
@@ -923,7 +949,7 @@ static uno::Reference< io::XInputStream > getInputStream(
ucb::OpenCommandArgument2 aArg;
aArg.Mode = ucb::OpenMode::DOCUMENT;
- aArg.Priority = 0; // unused
+ aArg.Priority = 0; // unused
aArg.Sink = xSink;
aArg.Properties = uno::Sequence< beans::Property >( 0 ); // unused
@@ -963,7 +989,7 @@ static uno::Reference< io::XInputStream > getInputStream(
{
ucb::OpenCommandArgument2 aArg;
aArg.Mode = ucb::OpenMode::DOCUMENT;
- aArg.Priority = 0; // unused
+ aArg.Priority = 0; // unused
aArg.Sink = xOutputStream;
aArg.Properties = uno::Sequence< beans::Property >( 0 );
@@ -992,7 +1018,7 @@ static uno::Reference< io::XInputStream > getInputStream(
}
//=========================================================================
-static uno::Reference< sdbc::XResultSet > getResultSet(
+uno::Reference< sdbc::XResultSet > getResultSet(
const TransferCommandContext & rContext,
const uno::Reference< ucb::XCommandProcessor > & xCommandProcessorS )
throw( uno::Exception )
@@ -1010,7 +1036,7 @@ static uno::Reference< sdbc::XResultSet > getResultSet(
ucb::OpenCommandArgument2 aArg;
aArg.Mode = ucb::OpenMode::ALL;
- aArg.Priority = 0; // unused
+ aArg.Priority = 0; // unused
aArg.Sink = 0;
aArg.Properties = aProps;
@@ -1038,7 +1064,7 @@ static uno::Reference< sdbc::XResultSet > getResultSet(
}
//=========================================================================
-static void handleNameClashRename(
+void handleNameClashRename(
const TransferCommandContext & rContext,
const uno::Reference< ucb::XContent > & xNew,
const uno::Reference<
@@ -1217,7 +1243,7 @@ static void handleNameClashRename(
}
//=========================================================================
-static void globalTransfer(
+void globalTransfer_(
const TransferCommandContext & rContext,
const uno::Reference< ucb::XContent > & xSource,
const uno::Reference< ucb::XContent > & xTarget,
@@ -1632,7 +1658,7 @@ static void globalTransfer(
rtl::OUString(), // NewTitle;
rContext.aArg.NameClash ); // NameClash
- ucb_commands::TransferCommandContext aSubCtx(
+ TransferCommandContext aSubCtx(
rContext.xSMgr,
rContext.xProcessor,
rContext.xEnv,
@@ -1649,10 +1675,10 @@ static void globalTransfer(
aSubCtx.aArg.SourceURL
= xChild->getIdentifier()->getContentIdentifier();
- ucb_commands::globalTransfer( aSubCtx,
- xChild,
- xNew,
- xChildRow );
+ globalTransfer_( aSubCtx,
+ xChild,
+ xNew,
+ xChildRow );
}
}
while ( xResultSet->next() );
@@ -1662,11 +1688,11 @@ static void globalTransfer(
{
}
}
-
+
try {
uno::Reference< ucb::XCommandProcessor > xcp(
xTarget, uno::UNO_QUERY );
-
+
uno::Any aAny;
uno::Reference< ucb::XCommandInfo > xci;
if(xcp.is())
@@ -1678,7 +1704,7 @@ static void globalTransfer(
uno::Any()),
0,
rContext.xEnv );
-
+
const rtl::OUString cmdName =
rtl::OUString::createFromAscii("flush");
if((aAny >>= xci) && xci->hasCommandByName(cmdName))
@@ -1695,7 +1721,7 @@ static void globalTransfer(
}
}
-} /* namescpace ucb_commands */
+} /* namescpace */
//=========================================================================
//
@@ -1706,8 +1732,7 @@ static void globalTransfer(
uno::Reference< ucb::XCommandInfo >
UniversalContentBroker::getCommandInfo()
{
- return uno::Reference< ucb::XCommandInfo >(
- new ucb_commands::CommandProcessorInfo() );
+ return uno::Reference< ucb::XCommandInfo >( new CommandProcessorInfo() );
}
//=========================================================================
@@ -1717,14 +1742,24 @@ void UniversalContentBroker::globalTransfer(
throw( uno::Exception )
{
// Use own command environment with own interaction handler intercepting
- // some interaction requests that shell not be handled by the user-supplied
+ // some interaction requests that shall not be handled by the user-supplied
// interaction handler.
uno::Reference< ucb::XCommandEnvironment > xLocalEnv;
if (xEnv.is())
- xLocalEnv.set( new ucb_commands::CommandEnvironment(
- new ucb_commands::InteractionHandlerProxy(
- xEnv->getInteractionHandler() ),
- xEnv->getProgressHandler() ) );
+ {
+ uno::Reference< beans::XPropertySet > const xProps(
+ m_xSMgr, uno::UNO_QUERY_THROW );
+ uno::Reference< uno::XComponentContext > xCtx;
+ xCtx.set( xProps->getPropertyValue(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ),
+ uno::UNO_QUERY_THROW );
+
+ xLocalEnv.set( ucb::CommandEnvironment::create(
+ xCtx,
+ new InteractionHandlerProxy( xEnv->getInteractionHandler() ),
+ xEnv->getProgressHandler() ) );
+ }
//////////////////////////////////////////////////////////////////////
//
@@ -1862,27 +1897,27 @@ void UniversalContentBroker::globalTransfer(
uno::Any aExc;
rtl::OUString aNewTitle;
- ucb_commands::NameClashContinuation eCont
- = ucb_commands::interactiveNameClashResolve(
+ NameClashContinuation eCont
+ = interactiveNameClashResolve(
xEnv, // always use original environment!
rArg.TargetURL, // target folder URL
- ucb_commands::createDesiredName(
- aTransferArg ), // clashing name
+ createDesiredName(
+ aTransferArg ), // clashing name
aExc,
aNewTitle );
switch ( eCont )
{
- case ucb_commands::NOT_HANDLED:
+ case NOT_HANDLED:
// Not handled.
cppu::throwException( aExc );
// break;
- case ucb_commands::UNKNOWN:
+ case UNKNOWN:
// Handled, but not clear, how...
// fall-thru intended.
- case ucb_commands::ABORT:
+ case ABORT:
throw ucb::CommandFailedException(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
@@ -1892,13 +1927,13 @@ void UniversalContentBroker::globalTransfer(
aExc );
// break;
- case ucb_commands::OVERWRITE:
+ case OVERWRITE:
aTransferArg.NameClash
= ucb::NameClash::OVERWRITE;
bRetry = true;
break;
- case ucb_commands::NEW_NAME:
+ case NEW_NAME:
aTransferArg.NewTitle = aNewTitle;
bRetry = true;
break;
@@ -2015,7 +2050,7 @@ void UniversalContentBroker::globalTransfer(
// Unreachable
}
- ucb_commands::TransferCommandContext aTransferCtx(
+ TransferCommandContext aTransferCtx(
m_xSMgr, this, xLocalEnv, xEnv, rArg );
if ( rArg.NewTitle.getLength() == 0 )
@@ -2024,13 +2059,13 @@ void UniversalContentBroker::globalTransfer(
rtl::OUString aBaseURI( xRow->getString( 4 ) );
if ( aBaseURI.getLength() )
{
- aTransferCtx.aArg.NewTitle
- = ucb_commands::createDesiredName( aBaseURI, rtl::OUString() );
+ aTransferCtx.aArg.NewTitle
+ = createDesiredName( aBaseURI, rtl::OUString() );
}
}
// Do it!
- ucb_commands::globalTransfer( aTransferCtx, xSource, xTarget, xRow );
+ globalTransfer_( aTransferCtx, xSource, xTarget, xRow );
//////////////////////////////////////////////////////////////////////
//
@@ -2044,8 +2079,8 @@ void UniversalContentBroker::globalTransfer(
{
ucb::Command aCommand(
rtl::OUString::createFromAscii( "delete" ), // Name
- -1, // Handle
- uno::makeAny( sal_Bool( sal_True ) ) ); // Argument
+ -1, // Handle
+ uno::makeAny( sal_Bool( sal_True ) ) ); // Argument
xCommandProcessor->execute( aCommand, 0, xLocalEnv );
}
diff --git a/ucb/source/ucp/file/bc.cxx b/ucb/source/ucp/file/bc.cxx
index d8f3d4afb4..2221966376 100644
--- a/ucb/source/ucp/file/bc.cxx
+++ b/ucb/source/ucp/file/bc.cxx
@@ -49,7 +49,6 @@
#include <com/sun/star/beans/PropertySetInfoChange.hpp>
#include <com/sun/star/ucb/ContentAction.hpp>
#include <com/sun/star/ucb/NameClash.hpp>
-#include <com/sun/star/ucb/ContentInfoAttribute.hpp>
#include "filglob.hxx"
#include "filid.hxx"
#include "filrow.hxx"
@@ -437,6 +436,15 @@ BaseContent::execute( const Command& aCommand,
if(!xRow->wasNull())
aAny <<= CasePreservingURL;
}
+ else if( ! aCommand.Name.compareToAscii( "createNewContent" ) )
+ {
+ ucb::ContentInfo aArg;
+ if ( !( aCommand.Argument >>= aArg ) )
+ m_pMyShell->installError( CommandId,
+ TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT );
+ else
+ aAny <<= createNewContent( aArg );
+ }
else
m_pMyShell->installError( CommandId,
TASKHANDLER_UNSUPPORTED_COMMAND );
@@ -637,27 +645,7 @@ BaseContent::queryCreatableContentsInfo(
void )
throw( RuntimeException )
{
- Sequence< ContentInfo > seq(2);
-
- // file
- seq[0].Type = m_pMyShell->FileContentType;
- seq[0].Attributes = ContentInfoAttribute::INSERT_WITH_INPUTSTREAM
- | ContentInfoAttribute::KIND_DOCUMENT;
-
- Sequence< beans::Property > props( 1 );
- props[0] = beans::Property(
- rtl::OUString::createFromAscii( "Title" ),
- -1,
- getCppuType( static_cast< rtl::OUString* >( 0 ) ),
- beans::PropertyAttribute::MAYBEVOID
- | beans::PropertyAttribute::BOUND );
- seq[0].Properties = props;
-
- // folder
- seq[1].Type = m_pMyShell->FolderContentType;
- seq[1].Attributes = ContentInfoAttribute::KIND_FOLDER;
- seq[1].Properties = props;
- return seq;
+ return m_pMyShell->queryCreatableContentsInfo();
}
diff --git a/ucb/source/ucp/file/filerror.hxx b/ucb/source/ucp/file/filerror.hxx
index 0ae47da562..e773e5a506 100644
--- a/ucb/source/ucp/file/filerror.hxx
+++ b/ucb/source/ucp/file/filerror.hxx
@@ -42,21 +42,21 @@ namespace fileaccess {
#define TASKHANDLING_WRONG_DELETE_ARGUMENT 5
#define TASKHANDLING_WRONG_TRANSFER_ARGUMENT 6
#define TASKHANDLING_WRONG_INSERT_ARGUMENT 7
+#define TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT 8
+#define TASKHANDLING_UNSUPPORTED_OPEN_MODE 9
-#define TASKHANDLING_UNSUPPORTED_OPEN_MODE 8
+#define TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND 10
+#define TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND 11
-#define TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND 9
-#define TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND 10
+#define TASKHANDLING_OPEN_FILE_FOR_PAGING 12
+#define TASKHANDLING_NOTCONNECTED_FOR_PAGING 13
+#define TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING 14
+#define TASKHANDLING_IOEXCEPTION_FOR_PAGING 15
+#define TASKHANDLING_READING_FILE_FOR_PAGING 16
-#define TASKHANDLING_OPEN_FILE_FOR_PAGING 11
-#define TASKHANDLING_NOTCONNECTED_FOR_PAGING 12
-#define TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING 13
-#define TASKHANDLING_IOEXCEPTION_FOR_PAGING 14
-#define TASKHANDLING_READING_FILE_FOR_PAGING 15
-
-#define TASKHANDLING_OPEN_FOR_INPUTSTREAM 16
-#define TASKHANDLING_OPEN_FOR_STREAM 17
-#define TASKHANDLING_OPEN_FOR_DIRECTORYLISTING 18
+#define TASKHANDLING_OPEN_FOR_INPUTSTREAM 17
+#define TASKHANDLING_OPEN_FOR_STREAM 18
+#define TASKHANDLING_OPEN_FOR_DIRECTORYLISTING 19
#define TASKHANDLING_NOFRESHINSERT_IN_INSERT_COMMAND 22
#define TASKHANDLING_NONAMESET_INSERT_COMMAND 23
diff --git a/ucb/source/ucp/file/filglob.cxx b/ucb/source/ucp/file/filglob.cxx
index 8be222343c..2aa5bf94c9 100644
--- a/ucb/source/ucp/file/filglob.cxx
+++ b/ucb/source/ucp/file/filglob.cxx
@@ -286,7 +286,8 @@ namespace fileaccess {
errorCode == TASKHANDLING_WRONG_OPEN_ARGUMENT ||
errorCode == TASKHANDLING_WRONG_DELETE_ARGUMENT ||
errorCode == TASKHANDLING_WRONG_TRANSFER_ARGUMENT ||
- errorCode == TASKHANDLING_WRONG_INSERT_ARGUMENT )
+ errorCode == TASKHANDLING_WRONG_INSERT_ARGUMENT ||
+ errorCode == TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT )
{
IllegalArgumentException excep;
excep.ArgumentPosition = 0;
diff --git a/ucb/source/ucp/file/shell.cxx b/ucb/source/ucp/file/shell.cxx
index 6f00050089..b7ad11c052 100644
--- a/ucb/source/ucp/file/shell.cxx
+++ b/ucb/source/ucp/file/shell.cxx
@@ -46,23 +46,18 @@
#include <com/sun/star/ucb/NameClash.hpp>
#include <com/sun/star/ucb/XContentIdentifier.hpp>
#include <com/sun/star/lang/XComponent.hpp>
-#ifndef _COM_SUN_STAR_UCB_XCONTENTACCESS_
#include <com/sun/star/ucb/XContentAccess.hpp>
-#endif
-#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBBUTE_HPP_
#include <com/sun/star/beans/PropertyAttribute.hpp>
-#endif
#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/io/XTruncate.hpp>
#include <com/sun/star/ucb/OpenCommandArgument.hpp>
#include <com/sun/star/ucb/XPropertySetRegistryFactory.hpp>
#include <com/sun/star/ucb/TransferInfo.hpp>
+#include <com/sun/star/ucb/ContentInfoAttribute.hpp>
#include <com/sun/star/beans/PropertyChangeEvent.hpp>
#include <com/sun/star/beans/XPropertiesChangeListener.hpp>
#include <rtl/string.hxx>
-#ifndef _FILERROR_HXX_
#include "filerror.hxx"
-#endif
#include "filglob.hxx"
#include "filcmd.hxx"
#include "filinpstr.hxx"
@@ -188,9 +183,10 @@ shell::shell( const uno::Reference< lang::XMultiServiceFactory >& xMultiServiceF
IsHidden( rtl::OUString::createFromAscii( "IsHidden" ) ),
ContentType( rtl::OUString::createFromAscii( "ContentType" ) ),
IsReadOnly( rtl::OUString::createFromAscii( "IsReadOnly" ) ),
+ CreatableContentsInfo( rtl::OUString::createFromAscii( "CreatableContentsInfo" ) ),
FolderContentType( rtl::OUString::createFromAscii( "application/vnd.sun.staroffice.fsys-folder" ) ),
FileContentType( rtl::OUString::createFromAscii( "application/vnd.sun.staroffice.fsys-file" ) ),
- m_sCommandInfo( 8 )
+ m_sCommandInfo( 9 )
{
// Title
m_aDefaultProperties.insert( MyProperty( true,
@@ -294,7 +290,7 @@ shell::shell( const uno::Reference< lang::XMultiServiceFactory >& xMultiServiceF
| beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY ) );
- // Remote
+ // Hidden
m_aDefaultProperties.insert(
MyProperty(
true,
@@ -357,6 +353,17 @@ shell::shell( const uno::Reference< lang::XMultiServiceFactory >& xMultiServiceF
| beans::PropertyAttribute::BOUND ) );
+ // CreatableContentsInfo
+ m_aDefaultProperties.insert( MyProperty( true,
+ CreatableContentsInfo,
+ -1 ,
+ getCppuType( static_cast< const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ uno::Any(),
+ beans::PropertyState_DEFAULT_VALUE,
+ beans::PropertyAttribute::MAYBEVOID
+ | beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY ) );
+
// Commands
m_sCommandInfo[0].Name = rtl::OUString::createFromAscii( "getCommandInfo" );
m_sCommandInfo[0].Handle = -1;
@@ -390,6 +397,9 @@ shell::shell( const uno::Reference< lang::XMultiServiceFactory >& xMultiServiceF
m_sCommandInfo[7].Handle = -1;
m_sCommandInfo[7].ArgType = getCppuType( static_cast< InsertCommandArgument* > ( 0 ) );
+ m_sCommandInfo[7].Name = rtl::OUString::createFromAscii( "createNewContent" );
+ m_sCommandInfo[7].Handle = -1;
+ m_sCommandInfo[7].ArgType = getCppuType( static_cast< ucb::ContentInfo * > ( 0 ) );
if(m_bWithConfig)
{
@@ -2296,9 +2306,9 @@ shell::commit( const shell::ContentMap::iterator& it,
sal_Bool isDirectory,isFile,isVolume,isRemoveable,isRemote,isFloppy,isCompactDisc;
- sal_Int64 dirSize = 0;
-
- if( aFileStatus.isValid( FileStatusMask_FileSize ) )
+ sal_Int64 dirSize = 0;
+
+ if( aFileStatus.isValid( FileStatusMask_FileSize ) )
dirSize = aFileStatus.getFileSize();
if( aFileStatus.isValid( FileStatusMask_Type ) )
@@ -2319,7 +2329,7 @@ shell::commit( const shell::ContentMap::iterator& it,
isFile =
osl::FileStatus::Regular == aFileStatus2.getFileType();
- if( aFileStatus2.isValid( FileStatusMask_FileSize ) )
+ if( aFileStatus2.isValid( FileStatusMask_FileSize ) )
dirSize = aFileStatus2.getFileSize();
}
else
@@ -2345,17 +2355,17 @@ shell::commit( const shell::ContentMap::iterator& it,
osl::FileStatus::Regular == aFileStatus.getFileType();
}
- aAny <<= isVolume;
it1 = properties.find( MyProperty( IsVolume ) );
- if( it1 != properties.end() ) it1->setValue( aAny );
+ if( it1 != properties.end() )
+ it1->setValue( uno::makeAny( isVolume ) );
- aAny <<= isDirectory;
it1 = properties.find( MyProperty( IsFolder ) );
- if( it1 != properties.end() ) it1->setValue( aAny );
+ if( it1 != properties.end() )
+ it1->setValue( uno::makeAny( isDirectory ) );
- aAny <<= isFile;
it1 = properties.find( MyProperty( IsDocument ) );
- if( it1 != properties.end() ) it1->setValue( aAny );
+ if( it1 != properties.end() )
+ it1->setValue( uno::makeAny( isFile ) );
osl::VolumeInfo aVolumeInfo( VolumeInfoMask_Attributes );
if( isVolume &&
@@ -2368,44 +2378,47 @@ shell::commit( const shell::ContentMap::iterator& it,
isCompactDisc = aVolumeInfo.getCompactDiscFlag();
isFloppy = aVolumeInfo.getFloppyDiskFlag();
- aAny <<= isRemote;
it1 = properties.find( MyProperty( IsRemote ) );
- if( it1 != properties.end() ) it1->setValue( aAny );
+ if( it1 != properties.end() )
+ it1->setValue( uno::makeAny( isRemote ) );
- aAny <<= isRemoveable;
it1 = properties.find( MyProperty( IsRemoveable ) );
- if( it1 != properties.end() ) it1->setValue( aAny );
+ if( it1 != properties.end() )
+ it1->setValue( uno::makeAny( isRemoveable ) );
- aAny <<= isCompactDisc;
it1 = properties.find( MyProperty( IsCompactDisc ) );
- if( it1 != properties.end() ) it1->setValue( aAny );
+ if( it1 != properties.end() )
+ it1->setValue( uno::makeAny( isCompactDisc ) );
- aAny <<= isFloppy;
it1 = properties.find( MyProperty( IsFloppy ) );
- if( it1 != properties.end() ) it1->setValue( aAny );
+ if( it1 != properties.end() )
+ it1->setValue( uno::makeAny( isFloppy ) );
}
else
{
sal_Bool dummy = false;
aAny <<= dummy;
it1 = properties.find( MyProperty( IsRemote ) );
- if( it1 != properties.end() ) it1->setValue( aAny );
+ if( it1 != properties.end() )
+ it1->setValue( aAny );
+
it1 = properties.find( MyProperty( IsRemoveable ) );
- if( it1 != properties.end() ) it1->setValue( aAny );
+ if( it1 != properties.end() )
+ it1->setValue( aAny );
+
it1 = properties.find( MyProperty( IsCompactDisc ) );
- if( it1 != properties.end() ) it1->setValue( aAny );
+ if( it1 != properties.end() )
+ it1->setValue( aAny );
+
it1 = properties.find( MyProperty( IsFloppy ) );
- if( it1 != properties.end() ) it1->setValue( aAny );
+ if( it1 != properties.end() )
+ it1->setValue( aAny );
}
}
it1 = properties.find( MyProperty( Size ) );
if( it1 != properties.end() )
- {
- aAny <<= dirSize;
- it1->setValue( aAny );
- }
-
+ it1->setValue( uno::makeAny( dirSize ) );
it1 = properties.find( MyProperty( IsReadOnly ) );
if( it1 != properties.end() )
@@ -2414,8 +2427,7 @@ shell::commit( const shell::ContentMap::iterator& it,
{
sal_uInt64 Attr = aFileStatus.getAttributes();
sal_Bool readonly = ( Attr & Attribute_ReadOnly ) != 0;
- aAny <<= readonly;
- it1->setValue( aAny );
+ it1->setValue( uno::makeAny( readonly ) );
}
}
@@ -2426,13 +2438,11 @@ shell::commit( const shell::ContentMap::iterator& it,
{
sal_uInt64 Attr = aFileStatus.getAttributes();
sal_Bool ishidden = ( Attr & Attribute_Hidden ) != 0;
- aAny <<= ishidden;
- it1->setValue( aAny );
+ it1->setValue( uno::makeAny( ishidden ) );
}
}
it1 = properties.find( MyProperty( DateModified ) );
-
if( it1 != properties.end() )
{
if( aFileStatus.isValid( FileStatusMask_ModifyTime ) )
@@ -2440,7 +2450,7 @@ shell::commit( const shell::ContentMap::iterator& it,
TimeValue temp = aFileStatus.getModifyTime();
// Convert system time to local time (for EA)
- TimeValue myLocalTime;
+ TimeValue myLocalTime;
osl_getLocalTimeFromSystemTime( &temp, &myLocalTime );
oslDateTime myDateTime;
@@ -2454,11 +2464,16 @@ shell::commit( const shell::ContentMap::iterator& it,
aDateTime.Day = myDateTime.Day;
aDateTime.Month = myDateTime.Month;
aDateTime.Year = myDateTime.Year;
- aAny <<= aDateTime;
- it1->setValue( aAny );
+ it1->setValue( uno::makeAny( aDateTime ) );
}
}
+ it1 = properties.find( MyProperty( CreatableContentsInfo ) );
+ if( it1 != properties.end() )
+ it1->setValue( uno::makeAny(
+ isDirectory || !aFileStatus.isValid( FileStatusMask_Type )
+ ? queryCreatableContentsInfo()
+ : uno::Sequence< ucb::ContentInfo >() ) );
}
@@ -2493,12 +2508,12 @@ shell::getv(
{
// Assume failure
aIsRegular = false;
- osl::FileBase::RC result = osl::FileBase::E_INVAL;
- osl::DirectoryItem aTargetItem;
+ osl::FileBase::RC result = osl::FileBase::E_INVAL;
+ osl::DirectoryItem aTargetItem;
osl::DirectoryItem::get( aFileStatus.getLinkTargetURL(), aTargetItem );
if ( aTargetItem.is() )
{
- osl::FileStatus aTargetStatus( FileStatusMask_Type );
+ osl::FileStatus aTargetStatus( FileStatusMask_Type );
if ( osl::FileBase::E_None ==
( result = aTargetItem.getFileStatus( aTargetStatus ) ) )
@@ -2999,6 +3014,31 @@ shell::copyPersistentSet( const rtl::OUString& srcUnqPath,
} // end for( sal_Int...
}
+uno::Sequence< ucb::ContentInfo > shell::queryCreatableContentsInfo()
+{
+ uno::Sequence< ucb::ContentInfo > seq(2);
+
+ // file
+ seq[0].Type = FileContentType;
+ seq[0].Attributes = ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM
+ | ucb::ContentInfoAttribute::KIND_DOCUMENT;
+
+ uno::Sequence< beans::Property > props( 1 );
+ props[0] = beans::Property(
+ rtl::OUString::createFromAscii( "Title" ),
+ -1,
+ getCppuType( static_cast< rtl::OUString* >( 0 ) ),
+ beans::PropertyAttribute::MAYBEVOID
+ | beans::PropertyAttribute::BOUND );
+ seq[0].Properties = props;
+
+ // folder
+ seq[1].Type = FolderContentType;
+ seq[1].Attributes = ucb::ContentInfoAttribute::KIND_FOLDER;
+ seq[1].Properties = props;
+ return seq;
+}
+
/*******************************************************************************/
/* */
/* some misceancellous static functions */
diff --git a/ucb/source/ucp/file/shell.hxx b/ucb/source/ucp/file/shell.hxx
index 811cdce531..80ffd38f55 100644
--- a/ucb/source/ucp/file/shell.hxx
+++ b/ucb/source/ucp/file/shell.hxx
@@ -54,21 +54,18 @@
#include <com/sun/star/ucb/XCommandProcessor.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/io/XInputStream.hpp>
-#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_protected
#include <com/sun/star/beans/XPropertySetInfo.hpp>
-#endif
#include <com/sun/star/beans/XPropertiesChangeNotifier.hpp>
#include <com/sun/star/ucb/NumberedSortingInfo.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ucb/XContentProvider.hpp>
-#ifndef _COM_SUN_STAR_UCB_XDYNAMICRESULTSET_HPP__
#include <com/sun/star/ucb/XDynamicResultSet.hpp>
-#endif
#include <com/sun/star/beans/XPropertyContainer.hpp>
#include <com/sun/star/beans/XPropertyAccess.hpp>
#include <com/sun/star/ucb/XPropertySetRegistryFactory.hpp>
#include <com/sun/star/ucb/TransferInfo.hpp>
+#include <com/sun/star/ucb/ContentInfo.hpp>
#include "filtask.hxx"
#include "filnot.hxx"
@@ -307,7 +304,7 @@ namespace fileaccess {
/********************************************************************************/
- /* transfer-commandos */
+ /* transfer-commands */
/********************************************************************************/
/**
@@ -398,6 +395,9 @@ namespace fileaccess {
void SAL_CALL insertDefaultProperties( const rtl::OUString& aUnqPath );
+ com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
+ queryCreatableContentsInfo();
+
/******************************************************************************/
/* */
@@ -416,7 +416,6 @@ namespace fileaccess {
com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xMultiServiceFactory;
com::sun::star::uno::Reference< com::sun::star::ucb::XPropertySetRegistry > m_xFileRegistry;
-
private:
/********************************************************************************/
@@ -580,6 +579,7 @@ namespace fileaccess {
const rtl::OUString IsHidden;
const rtl::OUString ContentType;
const rtl::OUString IsReadOnly;
+ const rtl::OUString CreatableContentsInfo;
public:
diff --git a/ucb/source/ucp/ftp/ftpcontent.cxx b/ucb/source/ucp/ftp/ftpcontent.cxx
index 08335217b3..73300c1684 100644
--- a/ucb/source/ucp/ftp/ftpcontent.cxx
+++ b/ucb/source/ucp/ftp/ftpcontent.cxx
@@ -218,7 +218,7 @@ void SAL_CALL FTPContent::abort( sal_Int32 /*CommandId*/ )
/***************************************************************************/
/* */
-/* Interne Implklasse */
+/* Internal implementation class. */
/* */
/***************************************************************************/
@@ -363,66 +363,85 @@ Any SAL_CALL FTPContent::execute(
// return aRet;
// }
- if(action == THROWAUTHENTICATIONREQUEST) {
+ switch (action)
+ {
+ case NOACTION:
+ break;
+
+ case THROWAUTHENTICATIONREQUEST:
ucbhelper::cancelCommandExecution(
aRet,
Reference<XCommandEnvironment>(0));
- } else if(action == THROWACCESSDENIED) {
- Sequence<Any> seq(1);
- PropertyValue value;
- value.Name =
- rtl::OUString::createFromAscii("Uri");
- value.Handle = -1;
- value.Value <<= m_aFTPURL.ident(false,false);
- value.State = PropertyState_DIRECT_VALUE;
- seq[0] <<= value;
- ucbhelper::cancelCommandExecution(
- IOErrorCode_ACCESS_DENIED,
- seq,
- Environment);
- } else if(action == THROWINTERACTIVECONNECT) {
- InteractiveNetworkConnectException
- excep;
- excep.Server = m_aFTPURL.host();
- aRet <<= excep;
- ucbhelper::cancelCommandExecution(
- aRet,
- Environment);
- } else if(action == THROWRESOLVENAME) {
- InteractiveNetworkResolveNameException
- excep;
- excep.Server = m_aFTPURL.host();
- aRet <<= excep;
- ucbhelper::cancelCommandExecution(
- aRet,
- Environment);
- } else if(action == THROWNOFILE) {
- Sequence<Any> seq(1);
- PropertyValue value;
- value.Name =
- rtl::OUString::createFromAscii("Uri");
- value.Handle = -1;
- value.Value <<= m_aFTPURL.ident(false,false);
- value.State = PropertyState_DIRECT_VALUE;
- seq[0] <<= value;
- ucbhelper::cancelCommandExecution(
- IOErrorCode_NO_FILE,
- seq,
- Environment);
- } else if(action == THROWQUOTE ||
- action == THROWGENERAL) {
+ break;
+
+ case THROWACCESSDENIED:
+ {
+ Sequence<Any> seq(1);
+ PropertyValue value;
+ value.Name = rtl::OUString::createFromAscii("Uri");
+ value.Handle = -1;
+ value.Value <<= m_aFTPURL.ident(false,false);
+ value.State = PropertyState_DIRECT_VALUE;
+ seq[0] <<= value;
+ ucbhelper::cancelCommandExecution(
+ IOErrorCode_ACCESS_DENIED,
+ seq,
+ Environment);
+ break;
+ }
+ case THROWINTERACTIVECONNECT:
+ {
+ InteractiveNetworkConnectException excep;
+ excep.Server = m_aFTPURL.host();
+ aRet <<= excep;
+ ucbhelper::cancelCommandExecution(
+ aRet,
+ Environment);
+ break;
+ }
+ case THROWRESOLVENAME:
+ {
+ InteractiveNetworkResolveNameException excep;
+ excep.Server = m_aFTPURL.host();
+ aRet <<= excep;
+ ucbhelper::cancelCommandExecution(
+ aRet,
+ Environment);
+ break;
+ }
+ case THROWNOFILE:
+ {
+ Sequence<Any> seq(1);
+ PropertyValue value;
+ value.Name = rtl::OUString::createFromAscii("Uri");
+ value.Handle = -1;
+ value.Value <<= m_aFTPURL.ident(false,false);
+ value.State = PropertyState_DIRECT_VALUE;
+ seq[0] <<= value;
+ ucbhelper::cancelCommandExecution(
+ IOErrorCode_NO_FILE,
+ seq,
+ Environment);
+ break;
+ }
+ case THROWQUOTE:
+ case THROWGENERAL:
ucbhelper::cancelCommandExecution(
IOErrorCode_GENERAL,
Sequence<Any>(0),
Environment);
+ break;
}
-
if(aCommand.Name.compareToAscii("getPropertyValues") == 0) {
Sequence<Property> Properties;
if(!(aCommand.Argument >>= Properties))
{
- aRet <<= IllegalArgumentException();
+ aRet <<= IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Wrong argument type!" ),
+ static_cast< cppu::OWeakObject * >(this),
+ -1);
ucbhelper::cancelCommandExecution(aRet,Environment);
}
@@ -433,7 +452,11 @@ Any SAL_CALL FTPContent::execute(
Sequence<PropertyValue> propertyValues;
if( ! ( aCommand.Argument >>= propertyValues ) ) {
- aRet <<= IllegalArgumentException();
+ aRet <<= IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Wrong argument type!" ),
+ static_cast< cppu::OWeakObject * >(this),
+ -1);
ucbhelper::cancelCommandExecution(aRet,Environment);
}
@@ -451,7 +474,11 @@ Any SAL_CALL FTPContent::execute(
{
InsertCommandArgument aInsertArgument;
if ( ! ( aCommand.Argument >>= aInsertArgument ) ) {
- aRet <<= IllegalArgumentException();
+ aRet <<= IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Wrong argument type!" ),
+ static_cast< cppu::OWeakObject * >(this),
+ -1);
ucbhelper::cancelCommandExecution(aRet,Environment);
}
insert(aInsertArgument,Environment);
@@ -463,7 +490,12 @@ Any SAL_CALL FTPContent::execute(
else if(aCommand.Name.compareToAscii( "open" ) == 0) {
OpenCommandArgument2 aOpenCommand;
if ( !( aCommand.Argument >>= aOpenCommand ) ) {
- aRet <<= IllegalArgumentException();
+ aRet <<= IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Wrong argument type!" ),
+ static_cast< cppu::OWeakObject * >(this),
+ -1);
+
ucbhelper::cancelCommandExecution(aRet,Environment);
}
@@ -516,7 +548,10 @@ Any SAL_CALL FTPContent::execute(
}
}
else {
- aRet <<= UnsupportedDataSinkException();
+ aRet <<= UnsupportedDataSinkException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >(this),
+ aOpenCommand.Sink);
ucbhelper::cancelCommandExecution(aRet,Environment);
}
}
@@ -544,17 +579,39 @@ Any SAL_CALL FTPContent::execute(
aOpenCommand.Mode ==
OpenMode::DOCUMENT_SHARE_DENY_WRITE) {
// Unsupported OpenMode
- aRet <<= UnsupportedOpenModeException();
+ aRet <<= UnsupportedOpenModeException(
+ rtl::OUString(),
+ static_cast< cppu::OWeakObject * >(this),
+ static_cast< sal_Int16 >(aOpenCommand.Mode));
ucbhelper::cancelCommandExecution(aRet,Environment);
}
else {
- // IllegalArgumentException:: No OpenMode
- aRet <<= IllegalArgumentException();
+ aRet <<= IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Unexpected OpenMode!" ),
+ static_cast< cppu::OWeakObject * >(this),
+ -1);
+
ucbhelper::cancelCommandExecution(aRet,Environment);
}
- }
- else {
- aRet <<= UnsupportedCommandException();
+ } else if(aCommand.Name.compareToAscii("createNewContent") == 0) {
+ ContentInfo aArg;
+ if (!(aCommand.Argument >>= aArg)) {
+ ucbhelper::cancelCommandExecution(
+ makeAny(
+ IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Wrong argument type!" ),
+ static_cast< cppu::OWeakObject * >(this),
+ -1)),
+ Environment);
+ // Unreachable
+ }
+ aRet <<= createNewContent(aArg);
+ } else {
+ aRet <<= UnsupportedCommandException(
+ aCommand.Name,
+ static_cast< cppu::OWeakObject * >(this));
ucbhelper::cancelCommandExecution(aRet,Environment);
}
@@ -565,8 +622,11 @@ Any SAL_CALL FTPContent::execute(
else if(e.code() == CURLE_COULDNT_RESOLVE_HOST )
action = THROWRESOLVENAME;
else if(e.code() == CURLE_FTP_USER_PASSWORD_INCORRECT ||
+#if LIBCURL_VERSION_NUM>=0x070d01 /* 7.13.1 */
+ e.code() == CURLE_LOGIN_DENIED ||
+#endif
e.code() == CURLE_BAD_PASSWORD_ENTERED ||
- e.code() == CURLE_FTP_WEIRD_PASS_REPLY )
+ e.code() == CURLE_FTP_WEIRD_PASS_REPLY)
action = THROWAUTHENTICATIONREQUEST;
else if(e.code() == CURLE_FTP_ACCESS_DENIED)
action = THROWACCESSDENIED;
@@ -575,7 +635,7 @@ Any SAL_CALL FTPContent::execute(
else if(e.code() == CURLE_FTP_COULDNT_RETR_FILE)
action = THROWNOFILE;
else
- // nothing known about the course of the error
+ // nothing known about the cause of the error
action = THROWGENERAL;
}
}
@@ -592,6 +652,14 @@ Sequence<ContentInfo > SAL_CALL
FTPContent::queryCreatableContentsInfo( )
throw (RuntimeException)
{
+ return queryCreatableContentsInfo_Static();
+}
+
+// static
+Sequence<ContentInfo >
+FTPContent::queryCreatableContentsInfo_Static( )
+ throw (RuntimeException)
+{
Sequence< ContentInfo > seq(2);
seq[0].Type = FTP_FILE;
@@ -614,7 +682,6 @@ FTPContent::queryCreatableContentsInfo( )
return seq;
}
-
Reference<XContent > SAL_CALL
FTPContent::createNewContent( const ContentInfo& Info )
throw (RuntimeException)
@@ -785,6 +852,9 @@ Reference< XRow > FTPContent::getPropertyValues(
const rtl::OUString& Name = seqProp[i].Name;
if(Name.compareToAscii("Title") == 0)
xRow->appendString(seqProp[i],aDirEntry.m_aName);
+ else if(Name.compareToAscii("CreatableContentsInfo") == 0)
+ xRow->appendObject(seqProp[i],
+ makeAny(queryCreatableContentsInfo()));
else if(aDirEntry.m_nMode != INETCOREFTP_FILEMODE_UNKNOWN) {
if(Name.compareToAscii("ContentType") == 0)
xRow->appendString(seqProp[i],
@@ -825,9 +895,6 @@ Reference< XRow > FTPContent::getPropertyValues(
Sequence<Any> FTPContent::setPropertyValues(
const Sequence<PropertyValue>& seqPropVal)
{
- Sequence<Property> props =
- getProperties(Reference<XCommandEnvironment>(0));
-
Sequence<Any> ret(seqPropVal.getLength());
Sequence<PropertyChangeEvent > evt;
@@ -866,11 +933,20 @@ Sequence<Any> FTPContent::setPropertyValues(
ret[i] <<= excep;
}
} else {
- // either not unknown or illegal
+ Sequence<Property> props =
+ getProperties(Reference<XCommandEnvironment>(0));
+
+ // either unknown or read-only
ret[i] <<= UnknownPropertyException();
for(sal_Int32 j = 0; j < props.getLength(); ++j)
if(props[j].Name == seqPropVal[i].Name) {
- ret[i] <<= IllegalAccessException();
+ ret[i] <<= IllegalAccessException(
+ rtl::OUString::createFromAscii(
+ "Property is read-only!"),
+ //props[j].Attributes & PropertyAttribute::READONLY
+ // ? "Property is read-only!"
+ // : "Access denied!"),
+ static_cast< cppu::OWeakObject * >( this ));
break;
}
}
diff --git a/ucb/source/ucp/ftp/ftpcontent.hxx b/ucb/source/ucp/ftp/ftpcontent.hxx
index 361274e0b7..0b41c9be1d 100644
--- a/ucb/source/ucp/ftp/ftpcontent.hxx
+++ b/ucb/source/ucp/ftp/ftpcontent.hxx
@@ -57,19 +57,6 @@ namespace ftp
//=========================================================================
- struct ContentProperties
- {
- ::rtl::OUString aTitle; // Title
- ::rtl::OUString aContentType; // ContentType
- sal_Bool bIsDocument; // IsDocument
- sal_Bool bIsFolder; // IsFolder
-
- ContentProperties()
- : bIsDocument( sal_True ), bIsFolder( sal_False ) {}
- };
-
-//=========================================================================
-
class FTPContentProvider;
//=========================================================================
@@ -150,6 +137,11 @@ namespace ftp
::com::sun::star::uno::RuntimeException);
+ static com::sun::star::uno::Sequence<
+ com::sun::star::ucb::ContentInfo >
+ queryCreatableContentsInfo_Static( )
+ throw (com::sun::star::uno::RuntimeException);
+
private:
FTPContentProvider *m_pFCP;
diff --git a/ucb/source/ucp/ftp/ftpcontentcaps.cxx b/ucb/source/ucp/ftp/ftpcontentcaps.cxx
index 9855b2a4a3..874bb9bbd0 100644
--- a/ucb/source/ucp/ftp/ftpcontentcaps.cxx
+++ b/ucb/source/ucp/ftp/ftpcontentcaps.cxx
@@ -49,7 +49,7 @@ using namespace ftp;
uno::Sequence< beans::Property > FTPContent::getProperties(
const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/)
{
- #define PROPS_COUNT 7
+ #define PROPS_COUNT 8
static const beans::Property aPropsInfoTable[] =
{
@@ -91,7 +91,7 @@ uno::Sequence< beans::Property > FTPContent::getProperties(
beans::Property(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ),
-1,
- getCppuType( static_cast< util::DateTime* >( 0 ) ),
+ getCppuType( static_cast< util::DateTime * >( 0 ) ),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY
),
@@ -101,10 +101,19 @@ uno::Sequence< beans::Property > FTPContent::getProperties(
getCppuBooleanType(),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY
+ ),
+ beans::Property(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "CreatableContentsInfo" ) ),
+ -1,
+ getCppuType(
+ static_cast< const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY
)
};
- return uno::Sequence< beans::Property >( aPropsInfoTable,PROPS_COUNT);
+ return uno::Sequence< beans::Property >( aPropsInfoTable, PROPS_COUNT );
}
//=========================================================================
@@ -112,7 +121,7 @@ uno::Sequence< beans::Property > FTPContent::getProperties(
uno::Sequence< ucb::CommandInfo > FTPContent::getCommands(
const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
{
-// osl::MutexGuard aGuard( m_aMutex );
+// osl::MutexGuard aGuard( m_aMutex );
//=================================================================
//
@@ -120,7 +129,7 @@ uno::Sequence< ucb::CommandInfo > FTPContent::getCommands(
//
//=================================================================
- #define COMMAND_COUNT 7
+ #define COMMAND_COUNT 8
static const ucb::CommandInfo aCommandInfoTable[] =
{
@@ -167,10 +176,15 @@ uno::Sequence< ucb::CommandInfo > FTPContent::getCommands(
ucb::CommandInfo(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
-1,
- getCppuType( static_cast< sal_Bool * >( 0 ) )
+ getCppuBooleanType()
+ ),
+ ucb::CommandInfo(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ),
+ -1,
+ getCppuType( static_cast< ucb::ContentInfo * >( 0 ) )
)
};
- return uno::Sequence<ucb::CommandInfo>(aCommandInfoTable,COMMAND_COUNT);
+ return uno::Sequence< ucb::CommandInfo >( aCommandInfoTable, COMMAND_COUNT );
}
diff --git a/ucb/source/ucp/ftp/ftpresultsetI.cxx b/ucb/source/ucp/ftp/ftpresultsetI.cxx
index ab18061de3..6961072383 100644
--- a/ucb/source/ucp/ftp/ftpresultsetI.cxx
+++ b/ucb/source/ucp/ftp/ftpresultsetI.cxx
@@ -38,7 +38,7 @@
#include "com/sun/star/ucb/XCommandProcessor.hpp"
#include "com/sun/star/sdbc/XRow.hpp"
#include "ftpresultsetI.hxx"
-
+#include "ftpcontent.hxx"
using namespace std;
@@ -96,6 +96,10 @@ ResultSetI::ResultSetI(const Reference<XMultiServiceFactory>& xMSF,
else if(Name.compareToAscii("DateCreated") == 0)
xRow->appendTimestamp(seqProp[i],
dirvec[n].m_aDate);
+ else if(Name.compareToAscii("CreatableContentsInfo") == 0)
+ xRow->appendObject(
+ seqProp[i],
+ makeAny(FTPContent::queryCreatableContentsInfo_Static()));
else
xRow->appendVoid(seqProp[i]);
}
diff --git a/ucb/source/ucp/ftp/ftpurl.cxx b/ucb/source/ucp/ftp/ftpurl.cxx
index a0dfbc1b6f..52615e79f9 100644
--- a/ucb/source/ucp/ftp/ftpurl.cxx
+++ b/ucb/source/ucp/ftp/ftpurl.cxx
@@ -589,6 +589,12 @@ rtl::OUString FTPURL::net_title() const
// the client should retry after getting the correct
// username + password
throw curl_exception(err);
+#if LIBCURL_VERSION_NUM>=0x070d01 /* 7.13.1 */
+ else if(err == CURLE_LOGIN_DENIED)
+ // the client should retry after getting the correct
+ // username + password
+ throw curl_exception(err);
+#endif
else if(try_more && err == CURLE_FTP_ACCESS_DENIED) {
// We were either denied access when trying to login to
// an FTP server or when trying to change working directory
diff --git a/ucb/source/ucp/gio/gio_content.cxx b/ucb/source/ucp/gio/gio_content.cxx
index fa6d8f74c8..6e214308ae 100644
--- a/ucb/source/ucp/gio/gio_content.cxx
+++ b/ucb/source/ucp/gio/gio_content.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -151,8 +151,8 @@ void SAL_CALL Content::abort( sal_Int32 /*CommandId*/ )
rtl::OUString SAL_CALL Content::getContentType() throw( uno::RuntimeException )
{
- return isFolder(uno::Reference< ucb::XCommandEnvironment >())
- ? rtl::OUString::createFromAscii( GIO_FOLDER_TYPE )
+ return isFolder(uno::Reference< ucb::XCommandEnvironment >())
+ ? rtl::OUString::createFromAscii( GIO_FOLDER_TYPE )
: rtl::OUString::createFromAscii( GIO_FILE_TYPE );
}
@@ -183,17 +183,17 @@ uno::Any convertToException(GError *pError, const uno::Reference< uno::XInterfac
EXCEPT(aExcept); }
break;
case G_IO_ERROR_NOT_MOUNTED:
- { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
+ { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, ucb::IOErrorCode_NOT_EXISTING_PATH, aArgs);
EXCEPT(aExcept); }
break;
case G_IO_ERROR_NOT_FOUND:
- { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
+ { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, ucb::IOErrorCode_NOT_EXISTING, aArgs);
EXCEPT(aExcept); }
break;
case G_IO_ERROR_EXISTS:
- { ucb::NameClashException aExcept(sMessage, rContext,
+ { ucb::NameClashException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, sName);
EXCEPT(aExcept); }
break;
@@ -202,32 +202,32 @@ uno::Any convertToException(GError *pError, const uno::Reference< uno::XInterfac
EXCEPT(aExcept); }
break;
case G_IO_ERROR_PERMISSION_DENIED:
- { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
+ { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, ucb::IOErrorCode_ACCESS_DENIED, aArgs);
EXCEPT(aExcept); }
break;
case G_IO_ERROR_IS_DIRECTORY:
- { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
+ { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, ucb::IOErrorCode_NO_FILE, aArgs);
EXCEPT(aExcept); }
break;
case G_IO_ERROR_NOT_REGULAR_FILE:
- { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
+ { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, ucb::IOErrorCode_NO_FILE, aArgs);
EXCEPT(aExcept); }
break;
case G_IO_ERROR_NOT_DIRECTORY:
- { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
+ { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, ucb::IOErrorCode_NO_DIRECTORY, aArgs);
EXCEPT(aExcept); }
break;
case G_IO_ERROR_FILENAME_TOO_LONG:
- { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
+ { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, ucb::IOErrorCode_NAME_TOO_LONG, aArgs);
EXCEPT(aExcept); }
break;
case G_IO_ERROR_PENDING:
- { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
+ { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, ucb::IOErrorCode_PENDING, aArgs);
EXCEPT(aExcept); }
break;
@@ -235,50 +235,50 @@ uno::Any convertToException(GError *pError, const uno::Reference< uno::XInterfac
case G_IO_ERROR_CANCELLED:
case G_IO_ERROR_TOO_MANY_LINKS:
case G_IO_ERROR_WRONG_ETAG:
- { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
+ { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, ucb::IOErrorCode_GENERAL, aArgs);
EXCEPT(aExcept); }
break;
case G_IO_ERROR_NOT_SUPPORTED:
case G_IO_ERROR_CANT_CREATE_BACKUP:
case G_IO_ERROR_WOULD_MERGE:
- { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
+ { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, ucb::IOErrorCode_NOT_SUPPORTED, aArgs);
EXCEPT(aExcept); }
break;
case G_IO_ERROR_NO_SPACE:
- { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
+ { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, ucb::IOErrorCode_OUT_OF_DISK_SPACE, aArgs);
EXCEPT(aExcept); }
break;
case G_IO_ERROR_INVALID_FILENAME:
- { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
+ { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, ucb::IOErrorCode_INVALID_CHARACTER, aArgs);
EXCEPT(aExcept); }
break;
case G_IO_ERROR_READ_ONLY:
- { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
+ { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, ucb::IOErrorCode_WRITE_PROTECTED, aArgs);
EXCEPT(aExcept); }
break;
case G_IO_ERROR_TIMED_OUT:
- { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
+ { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, ucb::IOErrorCode_DEVICE_NOT_READY, aArgs);
EXCEPT(aExcept); }
break;
case G_IO_ERROR_WOULD_RECURSE:
- { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
+ { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, ucb::IOErrorCode_RECURSIVE, aArgs);
EXCEPT(aExcept); }
break;
case G_IO_ERROR_BUSY:
case G_IO_ERROR_WOULD_BLOCK:
- { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
+ { ucb::InteractiveAugmentedIOException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, ucb::IOErrorCode_LOCKING_VIOLATION, aArgs);
EXCEPT(aExcept); }
break;
case G_IO_ERROR_HOST_NOT_FOUND:
- { ucb::InteractiveNetworkResolveNameException aExcept(sMessage, rContext,
+ { ucb::InteractiveNetworkResolveNameException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR, sHost);
EXCEPT(aExcept);}
break;
@@ -288,7 +288,7 @@ uno::Any convertToException(GError *pError, const uno::Reference< uno::XInterfac
case G_IO_ERROR_NOT_SYMBOLIC_LINK:
case G_IO_ERROR_NOT_MOUNTABLE_FILE:
case G_IO_ERROR_FAILED_HANDLED:
- { ucb::InteractiveNetworkGeneralException aExcept(sMessage, rContext,
+ { ucb::InteractiveNetworkGeneralException aExcept(sMessage, rContext,
task::InteractionClassification_ERROR);
EXCEPT(aExcept);}
break;
@@ -306,7 +306,7 @@ uno::Any Content::mapGIOError( GError *pError )
uno::Any Content::getBadArgExcept()
{
- return uno::makeAny( lang::IllegalArgumentException(
+ return uno::makeAny( lang::IllegalArgumentException(
rtl::OUString::createFromAscii( "Wrong argument type!" ),
static_cast< cppu::OWeakObject * >( this ), -1) );
}
@@ -402,6 +402,7 @@ static util::DateTime getDateFromUnix (time_t t)
uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *pInfo,
const uno::Reference< lang::XMultiServiceFactory >& rSMgr,
+ const uno::Reference< ucb::XCommandEnvironment > & xEnv,
const uno::Sequence< beans::Property >& rProperties)
{
rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( rSMgr );
@@ -419,7 +420,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) )
{
if (g_file_info_has_attribute(pInfo, G_FILE_ATTRIBUTE_STANDARD_TYPE))
- xRow->appendBoolean( rProp, ( g_file_info_get_file_type( pInfo ) == G_FILE_TYPE_REGULAR ||
+ xRow->appendBoolean( rProp, ( g_file_info_get_file_type( pInfo ) == G_FILE_TYPE_REGULAR ||
g_file_info_get_file_type( pInfo ) == G_FILE_TYPE_UNKNOWN ) );
else
xRow->appendVoid( rProp );
@@ -457,7 +458,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
}
else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DateModified" ) ) )
{
- if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_TIME_CHANGED ) )
+ if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_TIME_CHANGED ) )
xRow->appendTimestamp( rProp, getDateFromUnix(g_file_info_get_attribute_uint64(pInfo, G_FILE_ATTRIBUTE_TIME_CHANGED)) );
else
xRow->appendVoid( rProp );
@@ -499,10 +500,14 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
else
xRow->appendVoid( rProp );
}
+ else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) )
+ {
+ xRow->appendObject( rProp, uno::makeAny( queryCreatableContentsInfo( xEnv ) ) );
+ }
#ifdef DEBUG
else
{
- fprintf(stderr, "Looking for unsupported property %s\n",
+ fprintf(stderr, "Looking for unsupported property %s\n",
rtl::OUStringToOString(rProp.Name, RTL_TEXTENCODING_UTF8).getStr());
}
#endif
@@ -520,10 +525,10 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
if (!pInfo)
ucbhelper::cancelCommandExecution(mapGIOError(pError), xEnv);
- return getPropertyValuesFromGFileInfo(pInfo, m_xSMgr, rProperties);
+ return getPropertyValuesFromGFileInfo(pInfo, m_xSMgr, xEnv, rProperties);
}
-static lang::IllegalAccessException
+static lang::IllegalAccessException
getReadOnlyException( const uno::Reference< uno::XInterface >& rContext )
{
return lang::IllegalAccessException ( rtl::OUString::createFromAscii( "Property is read-only!" ), rContext );
@@ -607,10 +612,10 @@ sal_Bool Content::exchangeIdentity( const uno::Reference< ucb::XContentIdentifie
uno::Reference< ucb::XContentIdentifier > xNewChildId
= new ::ucbhelper::ContentIdentifier( m_xSMgr, aNewChildURL );
-
+
if ( !xChild->exchangeIdentity( xNewChildId ) )
return sal_False;
-
+
++it;
}
return sal_True;
@@ -650,7 +655,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
sal_Int32 nChanged = 0, nTitlePos = -1;
const char *newName = NULL;
uno::Sequence< beans::PropertyChangeEvent > aChanges(nCount);
-
+
uno::Sequence< uno::Any > aRet( nCount );
const beans::PropertyValue* pValues = rValues.getConstArray();
for ( sal_Int32 n = 0; n < nCount; ++n )
@@ -663,7 +668,8 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) ||
rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ||
rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ||
- rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Size" ) ) )
+ rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Size" ) ) ||
+ rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) )
{
aRet[ n ] <<= getReadOnlyException( static_cast< cppu::OWeakObject * >(this) );
}
@@ -703,9 +709,9 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
aEvent.NewValue = uno::makeAny(aNewTitle);
aChanges.getArray()[ nChanged ] = aEvent;
nTitlePos = nChanged++;
-
+
g_file_info_set_name(pNewInfo, newName);
- }
+ }
}
else
{
@@ -737,7 +743,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
aNewURL += rtl::OUString( newName, strlen(newName), RTL_TEXTENCODING_UTF8 );
uno::Reference< ucb::XContentIdentifier > xNewId
= new ::ucbhelper::ContentIdentifier( m_xSMgr, aNewURL );
-
+
if (!exchangeIdentity( xNewId ) )
{
aRet[ nTitlePos ] <<= uno::Exception
@@ -808,7 +814,7 @@ sal_Bool Content::feedSink( uno::Reference< uno::XInterface > xSink,
uno::Reference< io::XOutputStream > xOut = uno::Reference< io::XOutputStream >(xSink, uno::UNO_QUERY );
uno::Reference< io::XActiveDataSink > xDataSink = uno::Reference< io::XActiveDataSink >(xSink, uno::UNO_QUERY );
-
+
if ( !xOut.is() && !xDataSink.is() )
return sal_False;
@@ -820,7 +826,7 @@ sal_Bool Content::feedSink( uno::Reference< uno::XInterface > xSink,
uno::Reference< io::XInputStream > xIn = new ::gio::InputStream(pStream);
if ( !xIn.is() )
return sal_False;
-
+
if ( xOut.is() )
copyData( xIn, xOut );
@@ -840,9 +846,9 @@ uno::Any Content::open(const ucb::OpenCommandArgument2 & rOpenCommand,
{
uno::Sequence< uno::Any > aArgs( 1 );
aArgs[ 0 ] <<= m_xIdentifier->getContentIdentifier();
- uno::Any aErr = uno::makeAny(
+ uno::Any aErr = uno::makeAny(
ucb::InteractiveAugmentedIOException(rtl::OUString(), static_cast< cppu::OWeakObject * >( this ),
- task::InteractionClassification_ERROR,
+ task::InteractionClassification_ERROR,
bIsFolder ? ucb::IOErrorCode_NOT_EXISTING_PATH : ucb::IOErrorCode_NOT_EXISTING, aArgs)
);
@@ -867,12 +873,12 @@ uno::Any Content::open(const ucb::OpenCommandArgument2 & rOpenCommand,
{
if (
( rOpenCommand.Mode == ucb::OpenMode::DOCUMENT_SHARE_DENY_NONE ) ||
- ( rOpenCommand.Mode == ucb::OpenMode::DOCUMENT_SHARE_DENY_WRITE )
+ ( rOpenCommand.Mode == ucb::OpenMode::DOCUMENT_SHARE_DENY_WRITE )
)
{
- ucbhelper::cancelCommandExecution(
- uno::makeAny ( ucb::UnsupportedOpenModeException
- ( rtl::OUString(), static_cast< cppu::OWeakObject * >( this ),
+ ucbhelper::cancelCommandExecution(
+ uno::makeAny ( ucb::UnsupportedOpenModeException
+ ( rtl::OUString(), static_cast< cppu::OWeakObject * >( this ),
sal_Int16( rOpenCommand.Mode ) ) ),
xEnv );
}
@@ -883,7 +889,7 @@ uno::Any Content::open(const ucb::OpenCommandArgument2 & rOpenCommand,
// implementation. Support for this type of
// sink is optional...
#ifdef DEBUG
- g_warning ("Failed to load data from '%s'",
+ g_warning ("Failed to load data from '%s'",
rtl::OUStringToOString(m_xIdentifier->getContentIdentifier(), RTL_TEXTENCODING_UTF8).getStr());
#endif
@@ -944,6 +950,14 @@ uno::Any SAL_CALL Content::execute(
ucbhelper::cancelCommandExecution ( getBadArgExcept (), xEnv );
aRet <<= setPropertyValues( aProperties, xEnv );
}
+ else if (aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "createNewContent" ) )
+ && isFolder( xEnv ) )
+ {
+ ucb::ContentInfo arg;
+ if ( !( aCommand.Argument >>= arg ) )
+ ucbhelper::cancelCommandExecution ( getBadArgExcept (), xEnv );
+ aRet <<= createNewContent( arg );
+ }
else if (aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "insert" ) ))
{
ucb::InsertCommandArgument arg;
@@ -956,8 +970,8 @@ uno::Any SAL_CALL Content::execute(
sal_Bool bDeletePhysical = sal_False;
aCommand.Argument >>= bDeletePhysical;
- //If no delete physical, try and trashcan it, if that doesn't work go
- //ahead and try and delete it anyway
+ //If no delete physical, try and trashcan it, if that doesn't work go
+ //ahead and try and delete it anyway
if (!bDeletePhysical && !g_file_trash(getGFile(), NULL, NULL))
bDeletePhysical = true;
@@ -996,10 +1010,10 @@ void Content::destroy( sal_Bool bDeletePhysical )
::gio::Content::ContentRefList aChildren;
queryChildren( aChildren );
-
+
ContentRefList::const_iterator it = aChildren.begin();
ContentRefList::const_iterator end = aChildren.end();
-
+
while ( it != end )
{
(*it)->destroy( bDeletePhysical );
@@ -1055,7 +1069,7 @@ void Content::insert(const uno::Reference< io::XInputStream > &xInputStream,
}
}
-void Content::transfer( const ucb::TransferInfo& aTransferInfo, const uno::Reference< ucb::XCommandEnvironment >& xEnv )
+void Content::transfer( const ucb::TransferInfo& aTransferInfo, const uno::Reference< ucb::XCommandEnvironment >& xEnv )
throw( uno::Exception )
{
rtl::OUString sDest = m_xIdentifier->getContentIdentifier();
@@ -1079,36 +1093,50 @@ void Content::transfer( const ucb::TransferInfo& aTransferInfo, const uno::Refer
ucbhelper::cancelCommandExecution(mapGIOError(pError), xEnv);
}
-com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > SAL_CALL Content::queryCreatableContentsInfo()
- throw( com::sun::star::uno::RuntimeException )
+uno::Sequence< ucb::ContentInfo > Content::queryCreatableContentsInfo(
+ const uno::Reference< ucb::XCommandEnvironment >& xEnv)
+ throw( uno::RuntimeException )
+{
+ if ( isFolder( xEnv ) )
+ {
+ uno::Sequence< ucb::ContentInfo > seq(2);
+
+ // Minimum set of props we really need
+ uno::Sequence< beans::Property > props( 1 );
+ props[0] = beans::Property(
+ rtl::OUString::createFromAscii( "Title" ),
+ -1,
+ getCppuType( static_cast< rtl::OUString* >( 0 ) ),
+ beans::PropertyAttribute::MAYBEVOID | beans::PropertyAttribute::BOUND );
+
+ // file
+ seq[0].Type = rtl::OUString::createFromAscii( GIO_FILE_TYPE );
+ seq[0].Attributes = ( ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM |
+ ucb::ContentInfoAttribute::KIND_DOCUMENT );
+ seq[0].Properties = props;
+
+ // folder
+ seq[1].Type = rtl::OUString::createFromAscii( GIO_FOLDER_TYPE );
+ seq[1].Attributes = ucb::ContentInfoAttribute::KIND_FOLDER;
+ seq[1].Properties = props;
+
+ return seq;
+ }
+ else
+ {
+ return uno::Sequence< ucb::ContentInfo >();
+ }
+}
+
+uno::Sequence< ucb::ContentInfo > SAL_CALL Content::queryCreatableContentsInfo()
+ throw( uno::RuntimeException )
{
- uno::Sequence< ucb::ContentInfo > seq(2);
-
- // Minimum set of props we really need
- uno::Sequence< beans::Property > props( 1 );
- props[0] = beans::Property(
- rtl::OUString::createFromAscii( "Title" ),
- -1,
- getCppuType( static_cast< rtl::OUString* >( 0 ) ),
- beans::PropertyAttribute::MAYBEVOID | beans::PropertyAttribute::BOUND );
-
- // file
- seq[0].Type = rtl::OUString::createFromAscii( GIO_FILE_TYPE );
- seq[0].Attributes = ( ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM |
- ucb::ContentInfoAttribute::KIND_DOCUMENT );
- seq[0].Properties = props;
-
- // folder
- seq[1].Type = rtl::OUString::createFromAscii( GIO_FOLDER_TYPE );
- seq[1].Attributes = ucb::ContentInfoAttribute::KIND_FOLDER;
- seq[1].Properties = props;
-
- return seq;
+ return queryCreatableContentsInfo( uno::Reference< ucb::XCommandEnvironment >() );
}
-com::sun::star::uno::Reference< com::sun::star::ucb::XContent >
- SAL_CALL Content::createNewContent( const com::sun::star::ucb::ContentInfo& Info )
- throw( com::sun::star::uno::RuntimeException )
+uno::Reference< ucb::XContent >
+ SAL_CALL Content::createNewContent( const ucb::ContentInfo& Info )
+ throw( uno::RuntimeException )
{
bool create_document;
const char *name;
@@ -1120,7 +1148,7 @@ com::sun::star::uno::Reference< com::sun::star::ucb::XContent >
else
{
#ifdef DEBUG
- g_warning( "Failed to create new content '%s'", rtl::OUStringToOString(Info.Type,
+ g_warning( "Failed to create new content '%s'", rtl::OUStringToOString(Info.Type,
RTL_TEXTENCODING_UTF8).getStr() );
#endif
return uno::Reference< ucb::XContent >();
@@ -1223,6 +1251,9 @@ uno::Sequence< beans::Property > Content::getProperties(
beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsHidden" ) ),
-1, getCppuBooleanType(),
+ beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
+ beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CreatableContentsInfo" ) ),
+ -1, getCppuType( static_cast< const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY )
};
@@ -1232,7 +1263,7 @@ uno::Sequence< beans::Property > Content::getProperties(
uno::Sequence< ucb::CommandInfo > Content::getCommands( const uno::Reference< ucb::XCommandEnvironment > & xEnv)
{
- static ucb::CommandInfo aDocumentCommandInfoTable[] =
+ static ucb::CommandInfo aCommandInfoTable[] =
{
// Required commands
ucb::CommandInfo
@@ -1262,11 +1293,14 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands( const uno::Reference< uc
// Folder Only, omitted if not a folder
ucb::CommandInfo
( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
- -1, getCppuType( static_cast<ucb::TransferInfo * >( 0 ) ) )
+ -1, getCppuType( static_cast<ucb::TransferInfo * >( 0 ) ) ),
+ ucb::CommandInfo
+ ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ),
+ -1, getCppuType( static_cast<ucb::ContentInfo * >( 0 ) ) )
};
- const int nProps = sizeof (aDocumentCommandInfoTable) / sizeof (aDocumentCommandInfoTable[0]);
- return uno::Sequence< ucb::CommandInfo >(aDocumentCommandInfoTable, isFolder(xEnv) ? nProps : nProps - 1);
+ const int nProps = sizeof (aCommandInfoTable) / sizeof (aCommandInfoTable[0]);
+ return uno::Sequence< ucb::CommandInfo >(aCommandInfoTable, isFolder(xEnv) ? nProps : nProps - 2);
}
XTYPEPROVIDER_COMMON_IMPL( Content );
diff --git a/ucb/source/ucp/gio/gio_content.hxx b/ucb/source/ucp/gio/gio_content.hxx
index 9b63edf0ba..1cb32e61e9 100644
--- a/ucb/source/ucp/gio/gio_content.hxx
+++ b/ucb/source/ucp/gio/gio_content.hxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -42,11 +42,11 @@
#include <list>
-namespace com { namespace sun { namespace star {
+namespace com { namespace sun { namespace star {
namespace beans {
struct Property;
struct PropertyValue;
- }
+ }
namespace sdbc {
class XRow;
}
@@ -65,7 +65,7 @@ namespace gio
#define GIO_FILE_TYPE "application/vnd.sun.staroffice.gio-file"
#define GIO_FOLDER_TYPE "application/vnd.sun.staroffice.gio-folder"
-com::sun::star::uno::Any convertToException(GError *pError,
+com::sun::star::uno::Any convertToException(GError *pError,
const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& rContext, bool bThrow=true);
class ContentProvider;
@@ -98,7 +98,7 @@ private:
bool doSetFileInfo ( GFileInfo *pNewInfo );
com::sun::star::uno::Any open(const com::sun::star::ucb::OpenCommandArgument2 & rArg,
- const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv )
+ const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv )
throw( com::sun::star::uno::Exception );
void transfer( const com::sun::star::ucb::TransferInfo& rTransferInfo,
@@ -123,7 +123,7 @@ private:
sal_Bool feedSink( com::sun::star::uno::Reference< com::sun::star::uno::XInterface> aSink,
const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv );
- com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
+ com::sun::star::uno::Reference< com::sun::star::io::XInputStream >
createInputStream(const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv )
throw( com::sun::star::uno::Exception );
@@ -144,7 +144,8 @@ public:
virtual ~Content();
static com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > getPropertyValuesFromGFileInfo(
- GFileInfo *pInfo, const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr,
+ GFileInfo *pInfo, const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr,
+ const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv,
const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& rProperties);
virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
@@ -176,10 +177,10 @@ public:
virtual com::sun::star::uno::Any SAL_CALL
execute( const com::sun::star::ucb::Command& aCommand,
sal_Int32 CommandId,
- const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& Environment )
+ const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& Environment )
throw( com::sun::star::uno::Exception, com::sun::star::ucb::CommandAbortedException, com::sun::star::uno::RuntimeException );
- virtual void SAL_CALL abort( sal_Int32 CommandId )
+ virtual void SAL_CALL abort( sal_Int32 CommandId )
throw( com::sun::star::uno::RuntimeException );
virtual com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
@@ -189,6 +190,11 @@ public:
SAL_CALL createNewContent( const com::sun::star::ucb::ContentInfo& Info )
throw( com::sun::star::uno::RuntimeException );
+ com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
+ queryCreatableContentsInfo(
+ const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv)
+ throw( com::sun::star::uno::RuntimeException );
+
GFile* getGFile();
};
diff --git a/ucb/source/ucp/gio/gio_datasupplier.cxx b/ucb/source/ucp/gio/gio_datasupplier.cxx
index 384c5278ac..530456b250 100644
--- a/ucb/source/ucp/gio/gio_datasupplier.cxx
+++ b/ucb/source/ucp/gio/gio_datasupplier.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -51,7 +51,7 @@ namespace gio
typedef std::vector< ResultListEntry* > ResultList;
DataSupplier::DataSupplier( const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
- const uno::Reference< ::gio::Content >& rContent, sal_Int32 nOpenMode )
+ const uno::Reference< ::gio::Content >& rContent, sal_Int32 nOpenMode )
: mxContent(rContent), m_xSMgr(rxSMgr), mnOpenMode(nOpenMode), mbCountFinal(false)
{
}
@@ -92,7 +92,7 @@ bool DataSupplier::getData()
}
mbCountFinal = sal_True;
-
+
g_file_enumerator_close(pEnumerator, NULL, NULL);
return true;
}
@@ -128,14 +128,14 @@ DataSupplier::~DataSupplier()
rtl::OUString aId = rtl::OUString::createFromAscii( parent );
g_free(parent);
- char *escaped_name =
+ char *escaped_name =
g_uri_escape_string( g_file_info_get_name(maResults[ nIndex ]->pInfo) , NULL, false);
if ( ( aId.lastIndexOf( '/' ) + 1 ) != aId.getLength() )
aId += rtl::OUString::createFromAscii( "/" );
aId += rtl::OUString::createFromAscii( escaped_name );
-
+
g_free( escaped_name );
maResults[ nIndex ]->aId = aId;
@@ -240,7 +240,7 @@ uno::Reference< sdbc::XRow > DataSupplier::queryPropertyValues( sal_uInt32 nInde
if ( getResult( nIndex ) )
{
uno::Reference< sdbc::XRow > xRow = Content::getPropertyValuesFromGFileInfo(
- maResults[ nIndex ]->pInfo, m_xSMgr, getResultSet()->getProperties());
+ maResults[ nIndex ]->pInfo, m_xSMgr, getResultSet()->getEnvironment(), getResultSet()->getProperties());
maResults[ nIndex ]->xRow = xRow;
return xRow;
diff --git a/ucb/source/ucp/gvfs/gvfs_content.cxx b/ucb/source/ucp/gvfs/gvfs_content.cxx
index f611b577ae..c902ac71ec 100644
--- a/ucb/source/ucp/gvfs/gvfs_content.cxx
+++ b/ucb/source/ucp/gvfs/gvfs_content.cxx
@@ -390,6 +390,13 @@ uno::Any SAL_CALL Content::execute(
g_warning ("Open falling through ...");
#endif
+ } else if ( COMMAND_IS( aCommand, "createNewContent" ) && isFolder( xEnv ) ) {
+ ucb::ContentInfo arg;
+ if ( !( aCommand.Argument >>= arg ) )
+ ucbhelper::cancelCommandExecution ( getBadArgExcept (), xEnv );
+
+ aRet <<= createNewContent( arg );
+
} else if ( COMMAND_IS( aCommand, "insert" ) ) {
ucb::InsertCommandArgument arg;
if ( !( aCommand.Argument >>= arg ) )
@@ -444,32 +451,45 @@ void SAL_CALL Content::abort( sal_Int32 /*CommandId*/ )
// XContentCreator methods.
//
-uno::Sequence< ucb::ContentInfo > SAL_CALL
-Content::queryCreatableContentsInfo()
- throw( uno::RuntimeException )
+uno::Sequence< ucb::ContentInfo > Content::queryCreatableContentsInfo(
+ const uno::Reference< ucb::XCommandEnvironment >& xEnv)
+ throw( uno::RuntimeException )
+{
+ if ( isFolder( xEnv ) )
+ {
+ uno::Sequence< ucb::ContentInfo > seq(2);
+
+ // Minimum set of props we really need
+ uno::Sequence< beans::Property > props( 1 );
+ props[0] = beans::Property(
+ rtl::OUString::createFromAscii( "Title" ),
+ -1,
+ getCppuType( static_cast< rtl::OUString* >( 0 ) ),
+ beans::PropertyAttribute::MAYBEVOID | beans::PropertyAttribute::BOUND );
+
+ // file
+ seq[0].Type = rtl::OUString::createFromAscii( GVFS_FILE_TYPE );
+ seq[0].Attributes = ( ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM |
+ ucb::ContentInfoAttribute::KIND_DOCUMENT );
+ seq[0].Properties = props;
+
+ // folder
+ seq[1].Type = rtl::OUString::createFromAscii( GVFS_FOLDER_TYPE );
+ seq[1].Attributes = ucb::ContentInfoAttribute::KIND_FOLDER;
+ seq[1].Properties = props;
+
+ return seq;
+ }
+ else
+ {
+ return uno::Sequence< ucb::ContentInfo >();
+ }
+}
+
+uno::Sequence< ucb::ContentInfo > SAL_CALL Content::queryCreatableContentsInfo()
+ throw( uno::RuntimeException )
{
- uno::Sequence< ucb::ContentInfo > seq(2);
-
- // Minimum set of props we really need
- uno::Sequence< beans::Property > props( 1 );
- props[0] = beans::Property(
- rtl::OUString::createFromAscii( "Title" ),
- -1,
- getCppuType( static_cast< rtl::OUString* >( 0 ) ),
- beans::PropertyAttribute::MAYBEVOID | beans::PropertyAttribute::BOUND );
-
- // file
- seq[0].Type = rtl::OUString::createFromAscii( GVFS_FILE_TYPE );
- seq[0].Attributes = ( ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM |
- ucb::ContentInfoAttribute::KIND_DOCUMENT );
- seq[0].Properties = props;
-
- // folder
- seq[1].Type = rtl::OUString::createFromAscii( GVFS_FOLDER_TYPE );
- seq[1].Attributes = ucb::ContentInfoAttribute::KIND_FOLDER;
- seq[1].Properties = props;
-
- return seq;
+ return queryCreatableContentsInfo( uno::Reference< ucb::XCommandEnvironment >() );
}
uno::Reference< ucb::XContent > SAL_CALL
@@ -668,7 +688,10 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
g_warning ("FIXME: Requested mime-type - an expensive op. indeed!");
#endif
xRow->appendVoid( rProp );
- } else {
+ } else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) )
+ xRow->appendObject( rProp, uno::makeAny( queryCreatableContentsInfo( xEnv ) ) );
+
+ else {
xRow->appendVoid( rProp );
}
}
@@ -780,7 +803,8 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) ||
rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) ||
rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) ||
- rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Size" ) ) )
+ rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Size" ) ) ||
+ rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) )
aRet[ n ] <<= getReadOnlyException( this );
else if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) {
@@ -1311,8 +1335,8 @@ uno::Sequence< beans::Property > Content::getProperties(
beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
// FIXME: Too expensive for now (?)
// beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ),
-// -1, getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
-// beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
+// -1, getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
+// beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ),
-1, getCppuType( static_cast< const sal_Int64 * >( 0 ) ),
beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
@@ -1327,6 +1351,9 @@ uno::Sequence< beans::Property > Content::getProperties(
beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsHidden" ) ),
-1, getCppuBooleanType(),
+ beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ),
+ beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CreatableContentsInfo" ) ),
+ -1, getCppuType( static_cast< const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY )
};
@@ -1339,7 +1366,7 @@ uno::Sequence< beans::Property > Content::getProperties(
uno::Sequence< ucb::CommandInfo > Content::getCommands(
const uno::Reference< ucb::XCommandEnvironment > & xEnv )
{
- static ucb::CommandInfo aDocumentCommandInfoTable[] = {
+ static ucb::CommandInfo aCommandInfoTable[] = {
// Required commands
ucb::CommandInfo
( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
@@ -1365,17 +1392,19 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands(
( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
-1, getCppuType( static_cast<ucb::OpenCommandArgument2 * >( 0 ) ) ),
- // Folder only
+ // Folder Only, omitted if not a folder
ucb::CommandInfo
( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
- -1, getCppuType( static_cast<ucb::TransferInfo * >( 0 ) ) )
+ -1, getCppuType( static_cast<ucb::TransferInfo * >( 0 ) ) ),
+ ucb::CommandInfo
+ ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ),
+ -1, getCppuType( static_cast<ucb::ContentInfo * >( 0 ) ) )
};
- int num = 7;
-
- if ( isFolder( xEnv ) )
- num += 1;
- return uno::Sequence< ucb::CommandInfo >(aDocumentCommandInfoTable, num );
+ const int nProps
+ = sizeof( aCommandInfoTable ) / sizeof( aCommandInfoTable[ 0 ] );
+ return uno::Sequence< ucb::CommandInfo >(
+ aCommandInfoTable, isFolder( xEnv ) ? nProps : nProps - 2 );
}
rtl::OUString
diff --git a/ucb/source/ucp/gvfs/gvfs_content.hxx b/ucb/source/ucp/gvfs/gvfs_content.hxx
index 294d572ff1..67425da4df 100644
--- a/ucb/source/ucp/gvfs/gvfs_content.hxx
+++ b/ucb/source/ucp/gvfs/gvfs_content.hxx
@@ -255,6 +255,13 @@ public:
com::sun::star::ucb::XContent > SAL_CALL
createNewContent( const com::sun::star::ucb::ContentInfo& Info )
throw( com::sun::star::uno::RuntimeException );
+
+
+ com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
+ queryCreatableContentsInfo(
+ const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XCommandEnvironment >& xEnv)
+ throw( com::sun::star::uno::RuntimeException );
};
}
diff --git a/ucb/source/ucp/hierarchy/hierarchycontent.cxx b/ucb/source/ucp/hierarchy/hierarchycontent.cxx
index 81b4b13009..8027700a01 100644
--- a/ucb/source/ucp/hierarchy/hierarchycontent.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchycontent.cxx
@@ -457,8 +457,8 @@ uno::Any SAL_CALL HierarchyContent::execute(
aRet <<= getCommandInfo( Environment );
}
- else if ( isFolder() && aCommand.Name.equalsAsciiL(
- RTL_CONSTASCII_STRINGPARAM( "open" ) ) )
+ else if ( aCommand.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "open" ) ) && isFolder() )
{
//////////////////////////////////////////////////////////////////
// open command for a folder content
@@ -481,9 +481,9 @@ uno::Any SAL_CALL HierarchyContent::execute(
= new DynamicResultSet( m_xSMgr, this, aOpenCommand );
aRet <<= xSet;
}
- else if ( ( m_eKind != ROOT ) && !isReadOnly() &&
- aCommand.Name.equalsAsciiL(
- RTL_CONSTASCII_STRINGPARAM( "insert" ) ) )
+ else if ( aCommand.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "insert" ) ) &&
+ ( m_eKind != ROOT ) && !isReadOnly() )
{
//////////////////////////////////////////////////////////////////
// insert
@@ -508,9 +508,9 @@ uno::Any SAL_CALL HierarchyContent::execute(
: ucb::NameClash::ERROR;
insert( nNameClash, Environment );
}
- else if ( ( m_eKind != ROOT ) && !isReadOnly() &&
- aCommand.Name.equalsAsciiL(
- RTL_CONSTASCII_STRINGPARAM( "delete" ) ) )
+ else if ( aCommand.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "delete" ) ) &&
+ ( m_eKind != ROOT ) && !isReadOnly() )
{
//////////////////////////////////////////////////////////////////
// delete
@@ -546,9 +546,9 @@ uno::Any SAL_CALL HierarchyContent::execute(
// Remove own and all children's Additional Core Properties.
removeAdditionalPropertySet( sal_True );
}
- else if ( isFolder() && !isReadOnly() &&
- aCommand.Name.equalsAsciiL(
- RTL_CONSTASCII_STRINGPARAM( "transfer" ) ) )
+ else if ( aCommand.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "transfer" ) ) &&
+ isFolder() && !isReadOnly() )
{
//////////////////////////////////////////////////////////////////
// transfer
@@ -571,6 +571,31 @@ uno::Any SAL_CALL HierarchyContent::execute(
transfer( aInfo, Environment );
}
+ else if ( aCommand.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "createNewContent" ) ) &&
+ isFolder() && !isReadOnly() )
+ {
+ //////////////////////////////////////////////////////////////////
+ // createNewContent
+ // ( Not available at link objects )
+ //////////////////////////////////////////////////////////////////
+
+ ucb::ContentInfo aInfo;
+ if ( !( aCommand.Argument >>= aInfo ) )
+ {
+ OSL_ENSURE( sal_False, "Wrong argument type!" );
+ ucbhelper::cancelCommandExecution(
+ uno::makeAny( lang::IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Wrong argument type!" ),
+ static_cast< cppu::OWeakObject * >( this ),
+ -1 ) ),
+ Environment );
+ // Unreachable
+ }
+
+ aRet <<= createNewContent( aInfo );
+ }
else
{
//////////////////////////////////////////////////////////////////
@@ -607,54 +632,7 @@ uno::Sequence< ucb::ContentInfo > SAL_CALL
HierarchyContent::queryCreatableContentsInfo()
throw( uno::RuntimeException )
{
- if ( isFolder() )
- {
- osl::Guard< osl::Mutex > aGuard( m_aMutex );
-
- uno::Sequence< ucb::ContentInfo > aSeq( 2 );
-
- // Folder.
- aSeq.getArray()[ 0 ].Type
- = rtl::OUString::createFromAscii( HIERARCHY_FOLDER_CONTENT_TYPE );
- aSeq.getArray()[ 0 ].Attributes
- = ucb::ContentInfoAttribute::KIND_FOLDER;
-
- uno::Sequence< beans::Property > aFolderProps( 1 );
- aFolderProps.getArray()[ 0 ] = beans::Property(
- rtl::OUString::createFromAscii( "Title" ),
- -1,
- getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
- beans::PropertyAttribute::BOUND );
- aSeq.getArray()[ 0 ].Properties = aFolderProps;
-
- // Link.
- aSeq.getArray()[ 1 ].Type
- = rtl::OUString::createFromAscii( HIERARCHY_LINK_CONTENT_TYPE );
- aSeq.getArray()[ 1 ].Attributes
- = ucb::ContentInfoAttribute::KIND_LINK;
-
- uno::Sequence< beans::Property > aLinkProps( 2 );
- aLinkProps.getArray()[ 0 ] = beans::Property(
- rtl::OUString::createFromAscii( "Title" ),
- -1,
- getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
- beans::PropertyAttribute::BOUND );
- aLinkProps.getArray()[ 1 ] = beans::Property(
- rtl::OUString::createFromAscii( "TargetURL" ),
- -1,
- getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
- beans::PropertyAttribute::BOUND );
- aSeq.getArray()[ 1 ].Properties = aLinkProps;
-
- return aSeq;
- }
- else
- {
- OSL_ENSURE( sal_False,
- "queryCreatableContentsInfo called on non-folder object!" );
-
- return uno::Sequence< ucb::ContentInfo >( 0 );
- }
+ return m_aProps.getCreatableContentsInfo();
}
//=========================================================================
@@ -1026,7 +1004,7 @@ uno::Reference< sdbc::XRow > HierarchyContent::getPropertyValues(
xRow->appendString ( rProp, rData.getContentType() );
}
else if ( rProp.Name.equalsAsciiL(
- RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
+ RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
{
xRow->appendString ( rProp, rData.getTitle() );
}
@@ -1041,6 +1019,12 @@ uno::Reference< sdbc::XRow > HierarchyContent::getPropertyValues(
xRow->appendBoolean( rProp, rData.getIsFolder() );
}
else if ( rProp.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) )
+ {
+ xRow->appendObject(
+ rProp, uno::makeAny( rData.getCreatableContentsInfo() ) );
+ }
+ else if ( rProp.Name.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "TargetURL" ) ) )
{
// TargetURL is only supported by links.
@@ -1123,6 +1107,15 @@ uno::Reference< sdbc::XRow > HierarchyContent::getPropertyValues(
// @@@ Might actually be read-only!
beans::PropertyAttribute::BOUND ),
rData.getTargetURL() );
+ xRow->appendObject(
+ beans::Property(
+ rtl::OUString::createFromAscii( "CreatableContentsInfo" ),
+ -1,
+ getCppuType( static_cast<
+ const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY ),
+ uno::makeAny( rData.getCreatableContentsInfo() ) );
// Append all Additional Core Properties.
@@ -1161,11 +1154,11 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues(
beans::PropertyChangeEvent aEvent;
aEvent.Source = static_cast< cppu::OWeakObject * >( this );
- aEvent.Further = sal_False;
-// aEvent.PropertyName =
+ aEvent.Further = sal_False;
+// aEvent.PropertyName =
aEvent.PropertyHandle = -1;
-// aEvent.OldValue =
-// aEvent.NewValue =
+// aEvent.OldValue =
+// aEvent.NewValue =
const beans::PropertyValue* pValues = rValues.getConstArray();
sal_Int32 nCount = rValues.getLength();
@@ -1210,6 +1203,15 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues(
static_cast< cppu::OWeakObject * >( this ) );
}
else if ( rValue.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) )
+ {
+ // Read-only property!
+ aRet[ n ] <<= lang::IllegalAccessException(
+ rtl::OUString::createFromAscii(
+ "Property is read-only!" ),
+ static_cast< cppu::OWeakObject * >( this ) );
+ }
+ else if ( rValue.Name.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
{
if ( isReadOnly() )
@@ -1350,7 +1352,7 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues(
rValue.Name, rValue.Value );
aEvent.PropertyName = rValue.Name;
- aEvent.OldValue = aOldValue;
+ aEvent.OldValue = aOldValue;
aEvent.NewValue = rValue.Value;
aChanges.getArray()[ nChanged ] = aEvent;
@@ -1953,3 +1955,58 @@ void HierarchyContent::transfer(
}
}
+//=========================================================================
+//=========================================================================
+//
+// HierarchyContentProperties Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+uno::Sequence< ucb::ContentInfo >
+HierarchyContentProperties::getCreatableContentsInfo() const
+{
+ if ( getIsFolder() )
+ {
+ uno::Sequence< ucb::ContentInfo > aSeq( 2 );
+
+ // Folder.
+ aSeq.getArray()[ 0 ].Type
+ = rtl::OUString::createFromAscii( HIERARCHY_FOLDER_CONTENT_TYPE );
+ aSeq.getArray()[ 0 ].Attributes
+ = ucb::ContentInfoAttribute::KIND_FOLDER;
+
+ uno::Sequence< beans::Property > aFolderProps( 1 );
+ aFolderProps.getArray()[ 0 ] = beans::Property(
+ rtl::OUString::createFromAscii( "Title" ),
+ -1,
+ getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
+ beans::PropertyAttribute::BOUND );
+ aSeq.getArray()[ 0 ].Properties = aFolderProps;
+
+ // Link.
+ aSeq.getArray()[ 1 ].Type
+ = rtl::OUString::createFromAscii( HIERARCHY_LINK_CONTENT_TYPE );
+ aSeq.getArray()[ 1 ].Attributes
+ = ucb::ContentInfoAttribute::KIND_LINK;
+
+ uno::Sequence< beans::Property > aLinkProps( 2 );
+ aLinkProps.getArray()[ 0 ] = beans::Property(
+ rtl::OUString::createFromAscii( "Title" ),
+ -1,
+ getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
+ beans::PropertyAttribute::BOUND );
+ aLinkProps.getArray()[ 1 ] = beans::Property(
+ rtl::OUString::createFromAscii( "TargetURL" ),
+ -1,
+ getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
+ beans::PropertyAttribute::BOUND );
+ aSeq.getArray()[ 1 ].Properties = aLinkProps;
+
+ return aSeq;
+ }
+ else
+ {
+ return uno::Sequence< ucb::ContentInfo >( 0 );
+ }
+}
diff --git a/ucb/source/ucp/hierarchy/hierarchycontent.hxx b/ucb/source/ucp/hierarchy/hierarchycontent.hxx
index 68cd2eed6f..4094d77e4c 100644
--- a/ucb/source/ucp/hierarchy/hierarchycontent.hxx
+++ b/ucb/source/ucp/hierarchy/hierarchycontent.hxx
@@ -101,6 +101,9 @@ public:
sal_Bool getIsDocument() const { return !getIsFolder(); }
+ com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
+ getCreatableContentsInfo() const;
+
const HierarchyEntryData & getHierarchyEntryData() const { return m_aData; }
private:
diff --git a/ucb/source/ucp/hierarchy/hierarchycontentcaps.cxx b/ucb/source/ucp/hierarchy/hierarchycontentcaps.cxx
index cf6e0edd3f..47280ec125 100644
--- a/ucb/source/ucp/hierarchy/hierarchycontentcaps.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchycontentcaps.cxx
@@ -47,17 +47,20 @@
IsFolder x x x x x
Title x x x x x
TargetURL x x
+ CreatableContentsInfo x x x x x
getCommandInfo x x x x x
getPropertySetInfo x x x x x
getPropertyValues x x x x x
setPropertyValues x x x x x
+ createNewContent x x
insert x x
delete x x
open x x
transfer x x
*************************************************************************/
+
#include <com/sun/star/beans/Property.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
@@ -76,6 +79,12 @@ using namespace hierarchy_ucp;
//
//=========================================================================
+#define MAKEPROPSEQUENCE( a ) \
+ uno::Sequence< beans::Property >( a, sizeof( a ) / sizeof( a[ 0 ] ) )
+
+#define MAKECMDSEQUENCE( a ) \
+ uno::Sequence< ucb::CommandInfo >( a, sizeof( a ) / sizeof( a[ 0 ] ) )
+
//=========================================================================
//
// IMPORTENT: If any property data ( name / type / ... ) are changed, then
@@ -143,13 +152,20 @@ uno::Sequence< beans::Property > HierarchyContent::getProperties(
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY
- )
+ ),
+ beans::Property(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "CreatableContentsInfo" ) ),
+ -1,
+ getCppuType( static_cast<
+ const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY )
///////////////////////////////////////////////////////////
// New properties
///////////////////////////////////////////////////////////
};
- return uno::Sequence<
- beans::Property >( aLinkPropertyInfoTable, 5 );
+ return MAKEPROPSEQUENCE( aLinkPropertyInfoTable );
}
else
{
@@ -195,13 +211,20 @@ uno::Sequence< beans::Property > HierarchyContent::getProperties(
-1,
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND
- )
+ ),
+ beans::Property(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "CreatableContentsInfo" ) ),
+ -1,
+ getCppuType( static_cast<
+ const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY )
///////////////////////////////////////////////////////////
// New properties
///////////////////////////////////////////////////////////
};
- return uno::Sequence<
- beans::Property >( aLinkPropertyInfoTable, 5 );
+ return MAKEPROPSEQUENCE( aLinkPropertyInfoTable );
}
}
else if ( m_eKind == FOLDER )
@@ -248,16 +271,23 @@ uno::Sequence< beans::Property > HierarchyContent::getProperties(
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY
- )
+ ),
///////////////////////////////////////////////////////////
// Optional standard properties
///////////////////////////////////////////////////////////
+ beans::Property(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "CreatableContentsInfo" ) ),
+ -1,
+ getCppuType( static_cast<
+ const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY )
///////////////////////////////////////////////////////////
// New properties
///////////////////////////////////////////////////////////
};
- return uno::Sequence<
- beans::Property >( aFolderPropertyInfoTable, 4 );
+ return MAKEPROPSEQUENCE( aFolderPropertyInfoTable );
}
else
{
@@ -294,16 +324,23 @@ uno::Sequence< beans::Property > HierarchyContent::getProperties(
-1,
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND
- )
+ ),
///////////////////////////////////////////////////////////
// Optional standard properties
///////////////////////////////////////////////////////////
+ beans::Property(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "CreatableContentsInfo" ) ),
+ -1,
+ getCppuType( static_cast<
+ const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY )
///////////////////////////////////////////////////////////
// New properties
///////////////////////////////////////////////////////////
};
- return uno::Sequence<
- beans::Property >( aFolderPropertyInfoTable, 4 );
+ return MAKEPROPSEQUENCE( aFolderPropertyInfoTable );
}
}
else
@@ -314,6 +351,9 @@ uno::Sequence< beans::Property > HierarchyContent::getProperties(
//
//=================================================================
+ // Currently no difference between reonly /read-write
+ // -> all props ar read-only
+
static beans::Property aRootFolderPropertyInfoTable[] =
{
///////////////////////////////////////////////////////////////
@@ -346,16 +386,23 @@ uno::Sequence< beans::Property > HierarchyContent::getProperties(
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY
- )
+ ),
///////////////////////////////////////////////////////////////
// Optional standard properties
///////////////////////////////////////////////////////////////
+ beans::Property(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "CreatableContentsInfo" ) ),
+ -1,
+ getCppuType( static_cast<
+ const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY )
///////////////////////////////////////////////////////////////
// New properties
///////////////////////////////////////////////////////////////
};
- return uno::Sequence<
- beans::Property >( aRootFolderPropertyInfoTable, 4 );
+ return MAKEPROPSEQUENCE( aRootFolderPropertyInfoTable );
}
}
@@ -416,8 +463,7 @@ uno::Sequence< ucb::CommandInfo > HierarchyContent::getCommands(
// New commands
///////////////////////////////////////////////////////////
};
- return uno::Sequence<
- ucb::CommandInfo >( aLinkCommandInfoTable, 4 );
+ return MAKECMDSEQUENCE( aLinkCommandInfoTable );
}
else
{
@@ -470,8 +516,7 @@ uno::Sequence< ucb::CommandInfo > HierarchyContent::getCommands(
// New commands
///////////////////////////////////////////////////////////
};
- return uno::Sequence<
- ucb::CommandInfo >( aLinkCommandInfoTable, 6 );
+ return MAKECMDSEQUENCE( aLinkCommandInfoTable );
}
}
else if ( m_eKind == FOLDER )
@@ -529,8 +574,7 @@ uno::Sequence< ucb::CommandInfo > HierarchyContent::getCommands(
// New commands
///////////////////////////////////////////////////////////
};
- return uno::Sequence<
- ucb::CommandInfo >( aFolderCommandInfoTable, 5 );
+ return MAKECMDSEQUENCE( aFolderCommandInfoTable );
}
else
{
@@ -589,13 +633,18 @@ uno::Sequence< ucb::CommandInfo > HierarchyContent::getCommands(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
-1,
getCppuType( static_cast< ucb::TransferInfo * >( 0 ) )
+ ),
+ ucb::CommandInfo(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ),
+ -1,
+ getCppuType( static_cast< ucb::ContentInfo * >( 0 ) )
)
///////////////////////////////////////////////////////////
// New commands
///////////////////////////////////////////////////////////
};
- return uno::Sequence<
- ucb::CommandInfo >( aFolderCommandInfoTable, 8 );
+ return MAKECMDSEQUENCE( aFolderCommandInfoTable );
}
}
else
@@ -653,8 +702,7 @@ uno::Sequence< ucb::CommandInfo > HierarchyContent::getCommands(
// New commands
///////////////////////////////////////////////////////////
};
- return uno::Sequence<
- ucb::CommandInfo >( aRootFolderCommandInfoTable, 5 );
+ return MAKECMDSEQUENCE( aRootFolderCommandInfoTable );
}
else
{
@@ -703,13 +751,18 @@ uno::Sequence< ucb::CommandInfo > HierarchyContent::getCommands(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
-1,
getCppuType( static_cast< ucb::TransferInfo * >( 0 ) )
+ ),
+ ucb::CommandInfo(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ),
+ -1,
+ getCppuType( static_cast< ucb::ContentInfo * >( 0 ) )
)
///////////////////////////////////////////////////////////
// New commands
///////////////////////////////////////////////////////////
};
- return uno::Sequence<
- ucb::CommandInfo >( aRootFolderCommandInfoTable, 6 );
+ return MAKECMDSEQUENCE( aRootFolderCommandInfoTable );
}
}
}
diff --git a/ucb/source/ucp/package/pkgcontent.cxx b/ucb/source/ucp/package/pkgcontent.cxx
index 7fff9871c2..7e8359545e 100644
--- a/ucb/source/ucp/package/pkgcontent.cxx
+++ b/ucb/source/ucp/package/pkgcontent.cxx
@@ -103,17 +103,60 @@ ContentProperties::ContentProperties( const rtl::OUString& rContentType )
bEncrypted( sal_False ),
bHasEncryptedEntries( sal_False )
{
- bIsFolder = rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( PACKAGE_FOLDER_CONTENT_TYPE ) )
- || rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( PACKAGE_ZIP_FOLDER_CONTENT_TYPE ) );
+ bIsFolder = rContentType.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( PACKAGE_FOLDER_CONTENT_TYPE ) )
+ || rContentType.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( PACKAGE_ZIP_FOLDER_CONTENT_TYPE ) );
bIsDocument = !bIsFolder;
OSL_ENSURE( bIsFolder ||
- rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( PACKAGE_STREAM_CONTENT_TYPE ) ) ||
- rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( PACKAGE_ZIP_STREAM_CONTENT_TYPE ) ),
+ rContentType.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( PACKAGE_STREAM_CONTENT_TYPE ) )
+ || rContentType.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( PACKAGE_ZIP_STREAM_CONTENT_TYPE ) ),
"ContentProperties::ContentProperties - Unknown type!" );
}
//=========================================================================
+
+uno::Sequence< ucb::ContentInfo >
+ContentProperties::getCreatableContentsInfo( PackageUri const & rUri ) const
+{
+ if ( bIsFolder )
+ {
+ uno::Sequence< beans::Property > aProps( 1 );
+ aProps.getArray()[ 0 ] = beans::Property(
+ rtl::OUString::createFromAscii( "Title" ),
+ -1,
+ getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
+ beans::PropertyAttribute::BOUND );
+
+ uno::Sequence< ucb::ContentInfo > aSeq( 2 );
+
+ // Folder.
+ aSeq.getArray()[ 0 ].Type
+ = Content::getContentType( rUri.getScheme(), sal_True );
+ aSeq.getArray()[ 0 ].Attributes
+ = ucb::ContentInfoAttribute::KIND_FOLDER;
+ aSeq.getArray()[ 0 ].Properties = aProps;
+
+ // Stream.
+ aSeq.getArray()[ 1 ].Type
+ = Content::getContentType( rUri.getScheme(), sal_False );
+ aSeq.getArray()[ 1 ].Attributes
+ = ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM
+ | ucb::ContentInfoAttribute::KIND_DOCUMENT;
+ aSeq.getArray()[ 1 ].Properties = aProps;
+
+ return aSeq;
+ }
+ else
+ {
+ return uno::Sequence< ucb::ContentInfo >( 0 );
+ }
+}
+
+//=========================================================================
//=========================================================================
//
// Content Implementation.
@@ -164,9 +207,9 @@ Content* Content::create(
ucb::ContentInfo aInfo;
if ( bFolder || aURI.isRootFolder() )
- aInfo.Type = GetContentType( aURI.getScheme(), sal_True );
+ aInfo.Type = getContentType( aURI.getScheme(), sal_True );
else
- aInfo.Type = GetContentType( aURI.getScheme(), sal_False );
+ aInfo.Type = getContentType( aURI.getScheme(), sal_False );
return new Content( rxSMgr, pProvider, xId, xPackage, aURI, aInfo );
}
@@ -186,9 +229,9 @@ Content* Content::create(
PackageUri aURI( Identifier->getContentIdentifier() );
if ( !Info.Type.equalsIgnoreAsciiCase(
- GetContentType( aURI.getScheme(), sal_True ) ) &&
+ getContentType( aURI.getScheme(), sal_True ) ) &&
!Info.Type.equalsIgnoreAsciiCase(
- GetContentType( aURI.getScheme(), sal_False ) ) )
+ getContentType( aURI.getScheme(), sal_False ) ) )
return 0;
uno::Reference< container::XHierarchicalNameAccess > xPackage;
@@ -208,7 +251,7 @@ Content* Content::create(
//=========================================================================
// static
-::rtl::OUString Content::GetContentType(
+::rtl::OUString Content::getContentType(
const ::rtl::OUString& aScheme, sal_Bool bFolder )
{
return ( rtl::OUString::createFromAscii( "application/" )
@@ -626,6 +669,31 @@ uno::Any SAL_CALL Content::execute(
transfer( aInfo, Environment );
}
else if ( aCommand.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "createNewContent" ) ) &&
+ isFolder() )
+ {
+ //////////////////////////////////////////////////////////////////
+ // createNewContent
+ // ( Not available at stream objects )
+ //////////////////////////////////////////////////////////////////
+
+ ucb::ContentInfo aInfo;
+ if ( !( aCommand.Argument >>= aInfo ) )
+ {
+ OSL_ENSURE( sal_False, "Wrong argument type!" );
+ ucbhelper::cancelCommandExecution(
+ uno::makeAny( lang::IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Wrong argument type!" ),
+ static_cast< cppu::OWeakObject * >( this ),
+ -1 ) ),
+ Environment );
+ // Unreachable
+ }
+
+ aRet <<= createNewContent( aInfo );
+ }
+ else if ( aCommand.Name.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "flush" ) ) )
{
//////////////////////////////////////////////////////////////////
@@ -691,43 +759,7 @@ uno::Sequence< ucb::ContentInfo > SAL_CALL
Content::queryCreatableContentsInfo()
throw( uno::RuntimeException )
{
- if ( isFolder() )
- {
- osl::Guard< osl::Mutex > aGuard( m_aMutex );
-
- uno::Sequence< beans::Property > aProps( 1 );
- aProps.getArray()[ 0 ] = beans::Property(
- rtl::OUString::createFromAscii( "Title" ),
- -1,
- getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
- beans::PropertyAttribute::BOUND );
-
- uno::Sequence< ucb::ContentInfo > aSeq( 2 );
-
- // Folder.
- aSeq.getArray()[ 0 ].Type
- = GetContentType( m_aUri.getScheme(), sal_True );
- aSeq.getArray()[ 0 ].Attributes
- = ucb::ContentInfoAttribute::KIND_FOLDER;
- aSeq.getArray()[ 0 ].Properties = aProps;
-
- // Stream.
- aSeq.getArray()[ 1 ].Type
- = GetContentType( m_aUri.getScheme(), sal_False );
- aSeq.getArray()[ 1 ].Attributes
- = ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM
- | ucb::ContentInfoAttribute::KIND_DOCUMENT;
- aSeq.getArray()[ 1 ].Properties = aProps;
-
- return aSeq;
- }
- else
- {
- OSL_ENSURE( sal_False,
- "queryCreatableContentsInfo called on non-folder object!" );
-
- return uno::Sequence< ucb::ContentInfo >( 0 );
- }
+ return m_aProps.getCreatableContentsInfo( m_aUri );
}
//=========================================================================
@@ -744,16 +776,16 @@ Content::createNewContent( const ucb::ContentInfo& Info )
return uno::Reference< ucb::XContent >();
if ( !Info.Type.equalsIgnoreAsciiCase(
- GetContentType( m_aUri.getScheme(), sal_True ) ) &&
+ getContentType( m_aUri.getScheme(), sal_True ) ) &&
!Info.Type.equalsIgnoreAsciiCase(
- GetContentType( m_aUri.getScheme(), sal_False ) ) )
+ getContentType( m_aUri.getScheme(), sal_False ) ) )
return uno::Reference< ucb::XContent >();
rtl::OUString aURL = m_aUri.getUri();
aURL += rtl::OUString::createFromAscii( "/" );
if ( Info.Type.equalsIgnoreAsciiCase(
- GetContentType( m_aUri.getScheme(), sal_True ) ) )
+ getContentType( m_aUri.getScheme(), sal_True ) ) )
aURL += rtl::OUString::createFromAscii( "New_Folder" );
else
aURL += rtl::OUString::createFromAscii( "New_Stream" );
@@ -869,6 +901,14 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
xRow->appendBoolean( rProp, rData.bIsFolder );
}
else if ( rProp.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) )
+ {
+ xRow->appendObject(
+ rProp, uno::makeAny(
+ rData.getCreatableContentsInfo(
+ PackageUri( rContentId ) ) ) );
+ }
+ else if ( rProp.Name.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) )
{
xRow->appendString ( rProp, rData.aMediaType );
@@ -976,6 +1016,16 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY ),
rData.bIsFolder );
+ xRow->appendObject(
+ beans::Property(
+ rtl::OUString::createFromAscii( "CreatableContentsInfo" ),
+ -1,
+ getCppuType( static_cast<
+ const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY ),
+ uno::makeAny(
+ rData.getCreatableContentsInfo( PackageUri( rContentId ) ) ) );
xRow->appendString(
beans::Property(
rtl::OUString::createFromAscii( "MediaType" ),
@@ -1114,6 +1164,15 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
static_cast< cppu::OWeakObject * >( this ) );
}
else if ( rValue.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) )
+ {
+ // Read-only property!
+ aRet[ n ] <<= lang::IllegalAccessException(
+ rtl::OUString::createFromAscii(
+ "Property is read-only!" ),
+ static_cast< cppu::OWeakObject * >( this ) );
+ }
+ else if ( rValue.Name.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
{
if ( m_aUri.isRootFolder() )
@@ -1929,8 +1988,8 @@ void Content::transfer(
//////////////////////////////////////////////////////////////////////
rtl::OUString aType = xSource->isFolder()
- ? GetContentType( m_aUri.getScheme(), sal_True )
- : GetContentType( m_aUri.getScheme(), sal_False );
+ ? getContentType( m_aUri.getScheme(), sal_True )
+ : getContentType( m_aUri.getScheme(), sal_False );
ucb::ContentInfo aContentInfo;
aContentInfo.Type = aType;
aContentInfo.Attributes = 0;
@@ -2411,14 +2470,14 @@ sal_Bool Content::loadData(
if ( xEnumAccess.is() )
{
// folder
- rProps.aContentType = GetContentType( rURI.getScheme(), sal_True );
+ rProps.aContentType = getContentType( rURI.getScheme(), sal_True );
rProps.bIsDocument = sal_False;
rProps.bIsFolder = sal_True;
}
else
{
// stream
- rProps.aContentType = GetContentType( rURI.getScheme(), sal_False );
+ rProps.aContentType = getContentType( rURI.getScheme(), sal_False );
rProps.bIsDocument = sal_True;
rProps.bIsFolder = sal_False;
}
diff --git a/ucb/source/ucp/package/pkgcontent.hxx b/ucb/source/ucp/package/pkgcontent.hxx
index f04e7ad54f..1886d72470 100644
--- a/ucb/source/ucp/package/pkgcontent.hxx
+++ b/ucb/source/ucp/package/pkgcontent.hxx
@@ -98,6 +98,9 @@ struct ContentProperties
bHasEncryptedEntries( sal_False ) {}
ContentProperties( const ::rtl::OUString& rContentType );
+
+ com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
+ getCreatableContentsInfo( PackageUri const & rUri ) const;
};
//=========================================================================
@@ -190,10 +193,6 @@ private:
com::sun::star::container::XHierarchicalNameAccess > &
rxPackage );
- static ::rtl::OUString
- GetContentType( const ::rtl::OUString& aScheme,
- sal_Bool bFolder );
-
sal_Bool
hasData( const PackageUri& rURI );
sal_Bool
@@ -329,6 +328,9 @@ public:
::com::sun::star::uno::Reference<
::com::sun::star::container::XEnumeration >
getIterator();
+
+ static ::rtl::OUString
+ getContentType( const ::rtl::OUString& aScheme, sal_Bool bFolder );
};
}
diff --git a/ucb/source/ucp/package/pkgcontentcaps.cxx b/ucb/source/ucp/package/pkgcontentcaps.cxx
index 0538d93f87..b2ae1951fb 100644
--- a/ucb/source/ucp/package/pkgcontentcaps.cxx
+++ b/ucb/source/ucp/package/pkgcontentcaps.cxx
@@ -45,6 +45,7 @@
MediaType (w) (w) w
Title r w w
Size - - r
+ CreatableContentsInfo r r r
Compressed - - w
Encrypted - - w
HasEncryptedEntries r - -
@@ -58,6 +59,7 @@
open x x x
transfer x x -
flush x x -
+ createNewContent x x -
*************************************************************************/
#include <com/sun/star/beans/Property.hpp>
@@ -78,6 +80,12 @@ using namespace package_ucp;
//
//=========================================================================
+#define MAKEPROPSEQUENCE( a ) \
+ uno::Sequence< beans::Property >( a, sizeof( a ) / sizeof( a[ 0 ] ) )
+
+#define MAKECMDSEQUENCE( a ) \
+ uno::Sequence< ucb::CommandInfo >( a, sizeof( a ) / sizeof( a[ 0 ] ) )
+
//=========================================================================
//
// IMPORTENT: If any property data ( name / type / ... ) are changed, then
@@ -145,6 +153,15 @@ uno::Sequence< beans::Property > Content::getProperties(
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND
),
+ beans::Property(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "CreatableContentsInfo" ) ),
+ -1,
+ getCppuType( static_cast<
+ const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY
+ ),
///////////////////////////////////////////////////////////////
// New properties
///////////////////////////////////////////////////////////////
@@ -157,8 +174,7 @@ uno::Sequence< beans::Property > Content::getProperties(
| beans::PropertyAttribute::READONLY
)
};
- return uno::Sequence< beans::Property >(
- aRootFolderPropertyInfoTable, 6 );
+ return MAKEPROPSEQUENCE( aRootFolderPropertyInfoTable );
}
else
{
@@ -210,13 +226,21 @@ uno::Sequence< beans::Property > Content::getProperties(
-1,
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND
+ ),
+ beans::Property(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "CreatableContentsInfo" ) ),
+ -1,
+ getCppuType( static_cast<
+ const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY
)
///////////////////////////////////////////////////////////////
// New properties
///////////////////////////////////////////////////////////////
};
- return uno::Sequence< beans::Property >(
- aFolderPropertyInfoTable, 5 );
+ return MAKEPROPSEQUENCE( aFolderPropertyInfoTable );
}
}
else
@@ -275,6 +299,15 @@ uno::Sequence< beans::Property > Content::getProperties(
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY
),
+ beans::Property(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "CreatableContentsInfo" ) ),
+ -1,
+ getCppuType( static_cast<
+ const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY
+ ),
///////////////////////////////////////////////////////////////
// New properties
///////////////////////////////////////////////////////////////
@@ -291,7 +324,7 @@ uno::Sequence< beans::Property > Content::getProperties(
beans::PropertyAttribute::BOUND
)
};
- return uno::Sequence< beans::Property >( aStreamPropertyInfoTable, 8 );
+ return MAKEPROPSEQUENCE( aStreamPropertyInfoTable );
}
}
@@ -360,6 +393,12 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands(
getCppuType(
static_cast< ucb::TransferInfo * >( 0 ) )
),
+ ucb::CommandInfo(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ),
+ -1,
+ getCppuType( static_cast< ucb::ContentInfo * >( 0 ) )
+ ),
///////////////////////////////////////////////////////////
// New commands
///////////////////////////////////////////////////////////
@@ -370,8 +409,7 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands(
)
};
- return uno::Sequence<
- ucb::CommandInfo >( aRootFolderCommandInfoTable, 7 );
+ return MAKECMDSEQUENCE( aRootFolderCommandInfoTable );
}
else
{
@@ -439,6 +477,12 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands(
getCppuType(
static_cast< ucb::TransferInfo * >( 0 ) )
),
+ ucb::CommandInfo(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ),
+ -1,
+ getCppuType( static_cast< ucb::ContentInfo * >( 0 ) )
+ ),
///////////////////////////////////////////////////////////
// New commands
///////////////////////////////////////////////////////////
@@ -449,8 +493,7 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands(
)
};
- return uno::Sequence<
- ucb::CommandInfo >( aFolderCommandInfoTable, 9 );
+ return MAKECMDSEQUENCE( aFolderCommandInfoTable );
}
}
else
@@ -517,8 +560,6 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands(
///////////////////////////////////////////////////////////////
};
- return uno::Sequence< ucb::CommandInfo >(
- aStreamCommandInfoTable, 7 );
+ return MAKECMDSEQUENCE( aStreamCommandInfoTable );
}
}
-
diff --git a/ucb/source/ucp/tdoc/tdoc_content.cxx b/ucb/source/ucp/tdoc/tdoc_content.cxx
index 2f940e9715..52d5e917bd 100644
--- a/ucb/source/ucp/tdoc/tdoc_content.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_content.cxx
@@ -226,7 +226,7 @@ uno::Any SAL_CALL Content::queryInterface( const uno::Type & rType )
rType, static_cast< ucb::XContentCreator * >( this ) );
if ( aRet.hasValue() )
{
- if ( !isContentCreator() )
+ if ( !m_aProps.isContentCreator() )
return uno::Any();
}
}
@@ -249,7 +249,7 @@ uno::Sequence< uno::Type > SAL_CALL Content::getTypes()
{
cppu::OTypeCollection * pCollection = 0;
- if ( isContentCreator() )
+ if ( m_aProps.isContentCreator() )
{
static cppu::OTypeCollection* pFolderTypes = 0;
@@ -660,6 +660,49 @@ uno::Any SAL_CALL Content::execute(
transfer( aInfo, Environment );
}
+ else if ( aCommand.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "createNewContent" ) ) )
+ {
+ //////////////////////////////////////////////////////////////////
+ // createNewContent ( Supported by document and folders only )
+ //////////////////////////////////////////////////////////////////
+
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+
+ ContentType eType = m_aProps.getType();
+ if ( ( eType != FOLDER ) && ( eType != DOCUMENT ) )
+ {
+ ucbhelper::cancelCommandExecution(
+ uno::makeAny( ucb::UnsupportedCommandException(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "createNewContent command only "
+ "supported by folders and "
+ "documents!" ) ),
+ static_cast< cppu::OWeakObject * >(
+ this ) ) ),
+ Environment );
+ // Unreachable
+ }
+ }
+
+ ucb::ContentInfo aInfo;
+ if ( !( aCommand.Argument >>= aInfo ) )
+ {
+ OSL_ENSURE( sal_False, "Wrong argument type!" );
+ ucbhelper::cancelCommandExecution(
+ uno::makeAny( lang::IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Wrong argument type!" ),
+ static_cast< cppu::OWeakObject * >( this ),
+ -1 ) ),
+ Environment );
+ // Unreachable
+ }
+
+ aRet <<= createNewContent( aInfo );
+ }
else
{
//////////////////////////////////////////////////////////////////
@@ -695,65 +738,7 @@ uno::Sequence< ucb::ContentInfo > SAL_CALL
Content::queryCreatableContentsInfo()
throw( uno::RuntimeException )
{
- if ( isContentCreator() )
- {
- osl::Guard< osl::Mutex > aGuard( m_aMutex );
-
- uno::Sequence< beans::Property > aProps( 1 );
- aProps.getArray()[ 0 ] = beans::Property(
- rtl::OUString::createFromAscii( "Title" ),
- -1,
- getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
- beans::PropertyAttribute::BOUND );
-
-#ifdef NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT
- if ( m_aProps.getType() == DOCUMENT )
- {
- // streams cannot be created as direct children of document root
- uno::Sequence< ucb::ContentInfo > aSeq( 1 );
-
- // Folder.
- aSeq.getArray()[ 0 ].Type
- = rtl::OUString::createFromAscii( TDOC_FOLDER_CONTENT_TYPE );
- aSeq.getArray()[ 0 ].Attributes
- = ucb::ContentInfoAttribute::KIND_FOLDER;
- aSeq.getArray()[ 0 ].Properties = aProps;
-
- return aSeq;
- }
- else
- {
-#endif
- uno::Sequence< ucb::ContentInfo > aSeq( 2 );
-
- // Folder.
- aSeq.getArray()[ 0 ].Type
- = rtl::OUString::createFromAscii( TDOC_FOLDER_CONTENT_TYPE );
- aSeq.getArray()[ 0 ].Attributes
- = ucb::ContentInfoAttribute::KIND_FOLDER;
- aSeq.getArray()[ 0 ].Properties = aProps;
-
- // Stream.
- aSeq.getArray()[ 1 ].Type
- = rtl::OUString::createFromAscii( TDOC_STREAM_CONTENT_TYPE );
- aSeq.getArray()[ 1 ].Attributes
- = ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM
- | ucb::ContentInfoAttribute::KIND_DOCUMENT;
- aSeq.getArray()[ 1 ].Properties = aProps;
-
- return aSeq;
-#ifdef NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT
- }
-#endif
- }
- else
- {
- OSL_ENSURE( sal_False,
- "queryCreatableContentsInfo called on non-contentcreator "
- "object!" );
-
- return uno::Sequence< ucb::ContentInfo >( 0 );
- }
+ return m_aProps.getCreatableContentsInfo();
}
//=========================================================================
@@ -762,7 +747,7 @@ uno::Reference< ucb::XContent > SAL_CALL
Content::createNewContent( const ucb::ContentInfo& Info )
throw( uno::RuntimeException )
{
- if ( isContentCreator() )
+ if ( m_aProps.isContentCreator() )
{
osl::Guard< osl::Mutex > aGuard( m_aMutex );
@@ -1061,6 +1046,12 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
xRow->appendBoolean( rProp, rData.getIsFolder() );
}
else if ( rProp.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) )
+ {
+ xRow->appendObject(
+ rProp, uno::makeAny( rData.getCreatableContentsInfo() ) );
+ }
+ else if ( rProp.Name.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "Storage" ) ) )
{
// Storage is only supported by folders.
@@ -1155,6 +1146,15 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY ),
rData.getIsFolder() );
+ xRow->appendObject(
+ beans::Property(
+ rtl::OUString::createFromAscii( "CreatableContentsInfo" ),
+ -1,
+ getCppuType( static_cast<
+ const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY ),
+ uno::makeAny( rData.getCreatableContentsInfo() ) );
// Storage is only supported by folders.
if ( eType == FOLDER )
@@ -1266,6 +1266,15 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
static_cast< cppu::OWeakObject * >( this ) );
}
else if ( rValue.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) )
+ {
+ // Read-only property!
+ aRet[ n ] <<= lang::IllegalAccessException(
+ rtl::OUString::createFromAscii(
+ "Property is read-only!" ),
+ static_cast< cppu::OWeakObject * >( this ) );
+ }
+ else if ( rValue.Name.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
{
// Title is read-only for root and documents.
@@ -2370,14 +2379,6 @@ void Content::transfer(
}
//=========================================================================
-bool Content::isContentCreator()
-{
- osl::Guard< osl::Mutex > aGuard( m_aMutex );
- return
- ( m_aProps.getType() == FOLDER ) || ( m_aProps.getType() == DOCUMENT );
-}
-
-//=========================================================================
//static
bool Content::hasData( ContentProvider* pProvider, const Uri & rUri )
{
@@ -3059,3 +3060,79 @@ uno::Reference< io::XStream > Content::getStream(
}
}
}
+
+//=========================================================================
+//=========================================================================
+//
+// ContentProperties Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+uno::Sequence< ucb::ContentInfo >
+ContentProperties::getCreatableContentsInfo() const
+{
+ if ( isContentCreator() )
+ {
+ uno::Sequence< beans::Property > aProps( 1 );
+ aProps.getArray()[ 0 ] = beans::Property(
+ rtl::OUString::createFromAscii( "Title" ),
+ -1,
+ getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
+ beans::PropertyAttribute::BOUND );
+
+#ifdef NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT
+ if ( getType() == DOCUMENT )
+ {
+ // streams cannot be created as direct children of document root
+ uno::Sequence< ucb::ContentInfo > aSeq( 1 );
+
+ // Folder.
+ aSeq.getArray()[ 0 ].Type
+ = rtl::OUString::createFromAscii( TDOC_FOLDER_CONTENT_TYPE );
+ aSeq.getArray()[ 0 ].Attributes
+ = ucb::ContentInfoAttribute::KIND_FOLDER;
+ aSeq.getArray()[ 0 ].Properties = aProps;
+
+ return aSeq;
+ }
+ else
+ {
+#endif
+ uno::Sequence< ucb::ContentInfo > aSeq( 2 );
+
+ // Folder.
+ aSeq.getArray()[ 0 ].Type
+ = rtl::OUString::createFromAscii( TDOC_FOLDER_CONTENT_TYPE );
+ aSeq.getArray()[ 0 ].Attributes
+ = ucb::ContentInfoAttribute::KIND_FOLDER;
+ aSeq.getArray()[ 0 ].Properties = aProps;
+
+ // Stream.
+ aSeq.getArray()[ 1 ].Type
+ = rtl::OUString::createFromAscii( TDOC_STREAM_CONTENT_TYPE );
+ aSeq.getArray()[ 1 ].Attributes
+ = ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM
+ | ucb::ContentInfoAttribute::KIND_DOCUMENT;
+ aSeq.getArray()[ 1 ].Properties = aProps;
+
+ return aSeq;
+#ifdef NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT
+ }
+#endif
+ }
+ else
+ {
+ OSL_ENSURE( sal_False,
+ "getCreatableContentsInfo called on non-contentcreator "
+ "object!" );
+
+ return uno::Sequence< ucb::ContentInfo >( 0 );
+ }
+}
+
+//=========================================================================
+bool ContentProperties::isContentCreator() const
+{
+ return ( getType() == FOLDER ) || ( getType() == DOCUMENT );
+}
diff --git a/ucb/source/ucp/tdoc/tdoc_content.hxx b/ucb/source/ucp/tdoc/tdoc_content.hxx
index 12820a0cd9..5f81792cd9 100644
--- a/ucb/source/ucp/tdoc/tdoc_content.hxx
+++ b/ucb/source/ucp/tdoc/tdoc_content.hxx
@@ -43,7 +43,8 @@ namespace com { namespace sun { namespace star {
namespace sdbc { class XRow; }
namespace io { class XInputStream; class XOutputStream; }
namespace beans { struct PropertyValue; }
- namespace ucb { struct OpenCommandArgument2; struct TransferInfo; }
+ namespace ucb { struct OpenCommandArgument2; struct TransferInfo;
+ struct ContentInfo; }
} } }
namespace tdoc_ucp
@@ -94,6 +95,11 @@ public:
const rtl::OUString & getTitle() const { return m_aTitle; }
void setTitle( const rtl::OUString & rTitle ) { m_aTitle = rTitle; }
+ com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
+ getCreatableContentsInfo() const;
+
+ bool isContentCreator() const;
+
private:
ContentType m_eType;
rtl::OUString m_aContentType;
@@ -137,8 +143,6 @@ private:
com::sun::star::ucb::XCommandEnvironment > & xEnv );
virtual ::rtl::OUString getParentURL();
- bool isContentCreator();
-
static bool hasData( ContentProvider* pProvider, const Uri & rUri );
bool hasData( const Uri & rUri ) { return hasData( m_pProvider, rUri ); }
diff --git a/ucb/source/ucp/tdoc/tdoc_contentcaps.cxx b/ucb/source/ucp/tdoc/tdoc_contentcaps.cxx
index 792d693ab1..9d026ce742 100644
--- a/ucb/source/ucp/tdoc/tdoc_contentcaps.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_contentcaps.cxx
@@ -46,6 +46,7 @@
IsDocument r r r r r r
IsFolder r r r r r r
Title r r w w w w
+ CreatableContentsInfo r r r r r r
Storage - - r r - -
DocumentModel - r - - - -
@@ -57,6 +58,7 @@
delete - - x - x -
open x x x - x -
transfer - x x - - -
+ createNewContent - x x - - -
#ifdef NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT
(*) not supported by streams that are direct children of document
@@ -88,6 +90,12 @@ using namespace tdoc_ucp;
//
//=========================================================================
+#define MAKEPROPSEQUENCE( a ) \
+ uno::Sequence< beans::Property >( a, sizeof( a ) / sizeof( a[ 0 ] ) )
+
+#define MAKECMDSEQUENCE( a ) \
+ uno::Sequence< ucb::CommandInfo >( a, sizeof( a ) / sizeof( a[ 0 ] ) )
+
//=========================================================================
//
// IMPORTENT: If any property data ( name / type / ... ) are changed, then
@@ -142,15 +150,24 @@ uno::Sequence< beans::Property > Content::getProperties(
-1,
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND
- )
+ ),
///////////////////////////////////////////////////////////
// Optional standard properties
///////////////////////////////////////////////////////////
+ beans::Property(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "CreatableContentsInfo" ) ),
+ -1,
+ getCppuType( static_cast<
+ const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY
+ )
///////////////////////////////////////////////////////////
// New properties
///////////////////////////////////////////////////////////
};
- return uno::Sequence< beans::Property >( aStreamPropertyInfoTable, 4 );
+ return MAKEPROPSEQUENCE( aStreamPropertyInfoTable );
}
else if ( m_aProps.getType() == FOLDER )
{
@@ -197,6 +214,15 @@ uno::Sequence< beans::Property > Content::getProperties(
///////////////////////////////////////////////////////////
// Optional standard properties
///////////////////////////////////////////////////////////
+ beans::Property(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "CreatableContentsInfo" ) ),
+ -1,
+ getCppuType( static_cast<
+ const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY
+ ),
///////////////////////////////////////////////////////////
// New properties
///////////////////////////////////////////////////////////
@@ -209,7 +235,7 @@ uno::Sequence< beans::Property > Content::getProperties(
| beans::PropertyAttribute::READONLY
)
};
- return uno::Sequence< beans::Property >( aFolderPropertyInfoTable, 5 );
+ return MAKEPROPSEQUENCE( aFolderPropertyInfoTable );
}
else if ( m_aProps.getType() == DOCUMENT )
{
@@ -257,6 +283,15 @@ uno::Sequence< beans::Property > Content::getProperties(
///////////////////////////////////////////////////////////
// Optional standard properties
///////////////////////////////////////////////////////////
+ beans::Property(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "CreatableContentsInfo" ) ),
+ -1,
+ getCppuType( static_cast<
+ const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY
+ ),
///////////////////////////////////////////////////////////
// New properties
///////////////////////////////////////////////////////////
@@ -269,7 +304,7 @@ uno::Sequence< beans::Property > Content::getProperties(
| beans::PropertyAttribute::READONLY
)
};
- return uno::Sequence< beans::Property >( aDocPropertyInfoTable, 5 );
+ return MAKEPROPSEQUENCE( aDocPropertyInfoTable );
}
else
{
@@ -313,15 +348,24 @@ uno::Sequence< beans::Property > Content::getProperties(
getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY
- )
+ ),
///////////////////////////////////////////////////////////////
// Optional standard properties
///////////////////////////////////////////////////////////////
+ beans::Property(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "CreatableContentsInfo" ) ),
+ -1,
+ getCppuType( static_cast<
+ const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY
+ )
///////////////////////////////////////////////////////////////
// New properties
///////////////////////////////////////////////////////////////
};
- return uno::Sequence< beans::Property >( aRootPropertyInfoTable, 4 );
+ return MAKEPROPSEQUENCE( aRootPropertyInfoTable );
}
}
@@ -396,8 +440,7 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands(
// New commands
///////////////////////////////////////////////////////////
};
- return uno::Sequence<
- ucb::CommandInfo >( aStreamCommandInfoTable1, 6 );
+ return MAKECMDSEQUENCE( aStreamCommandInfoTable1 );
}
#endif
//=================================================================
@@ -461,8 +504,7 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands(
// New commands
///////////////////////////////////////////////////////////
};
- return uno::Sequence<
- ucb::CommandInfo >( aStreamCommandInfoTable, 7 );
+ return MAKECMDSEQUENCE( aStreamCommandInfoTable );
}
else if ( m_aProps.getType() == FOLDER )
{
@@ -527,13 +569,18 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
-1,
getCppuType( static_cast< ucb::TransferInfo * >( 0 ) )
+ ),
+ ucb::CommandInfo(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ),
+ -1,
+ getCppuType( static_cast< ucb::ContentInfo * >( 0 ) )
)
///////////////////////////////////////////////////////////
// New commands
///////////////////////////////////////////////////////////
};
- return uno::Sequence<
- ucb::CommandInfo >( aFolderCommandInfoTable, 8 );
+ return MAKECMDSEQUENCE( aFolderCommandInfoTable );
}
else if ( m_aProps.getType() == DOCUMENT )
{
@@ -588,13 +635,18 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
-1,
getCppuType( static_cast< ucb::TransferInfo * >( 0 ) )
+ ),
+ ucb::CommandInfo(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ),
+ -1,
+ getCppuType( static_cast< ucb::ContentInfo * >( 0 ) )
)
///////////////////////////////////////////////////////////
// New commands
///////////////////////////////////////////////////////////
};
- return uno::Sequence<
- ucb::CommandInfo >( aDocCommandInfoTable, 6 );
+ return MAKECMDSEQUENCE( aDocCommandInfoTable );
}
else
{
@@ -651,7 +703,6 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands(
// New commands
///////////////////////////////////////////////////////////
};
- return uno::Sequence<
- ucb::CommandInfo >( aRootCommandInfoTable, 5 );
+ return MAKECMDSEQUENCE( aRootCommandInfoTable );
}
}
diff --git a/ucb/source/ucp/webdav/webdavcontent.cxx b/ucb/source/ucp/webdav/webdavcontent.cxx
index 7adaa88585..def33876eb 100644
--- a/ucb/source/ucp/webdav/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav/webdavcontent.cxx
@@ -641,6 +641,29 @@ uno::Any SAL_CALL Content::execute(
unlock( Environment );
}
+ else if ( aCommand.Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "createNewContent" ) ) &&
+ isFolder( Environment ) )
+ {
+ //////////////////////////////////////////////////////////////////
+ // createNewContent
+ //////////////////////////////////////////////////////////////////
+
+ ucb::ContentInfo aArg;
+ if ( !( aCommand.Argument >>= aArg ) )
+ {
+ ucbhelper::cancelCommandExecution(
+ uno::makeAny( lang::IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Wrong argument type!" ),
+ static_cast< cppu::OWeakObject * >( this ),
+ -1 ) ),
+ Environment );
+ // Unreachable
+ }
+
+ aRet = uno::makeAny( createNewContent( aArg ) );
+ }
else
{
//////////////////////////////////////////////////////////////////
@@ -1165,8 +1188,8 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
std::auto_ptr< DAVResourceAccess > xResAccess;
rtl::OUString aEscapedTitle;
bool bHasAll = false;
- uno::Reference< lang::XMultiServiceFactory > xSMgr;
- uno::Reference< ucb::XContentIdentifier > xIdentifier;
+ uno::Reference< lang::XMultiServiceFactory > xSMgr;
+ uno::Reference< ucb::XContentIdentifier > xIdentifier;
rtl::Reference< ::ucbhelper::ContentProviderImplHelper > xProvider;
{
@@ -1413,14 +1436,35 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
m_bCollection ) );
}
- // Add BaseURI property, if requested.
- if ( !xProps->contains(
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BaseURI" ) ) ) )
+ sal_Int32 nCount = rProperties.getLength();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
{
- xProps->addProperty(
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BaseURI" ) ),
- uno::makeAny( getBaseURI( xResAccess ) ),
- true );
+ const rtl::OUString rName = rProperties[ n ].Name;
+ if ( rName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "BaseURI" ) ) )
+ {
+ // Add BaseURI property, if requested.
+ xProps->addProperty(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BaseURI" ) ),
+ uno::makeAny( getBaseURI( xResAccess ) ),
+ true );
+ }
+ else if ( rName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) )
+ {
+ // Add CreatableContentsInfo property, if requested.
+ sal_Bool bFolder = sal_False;
+ xProps->getValue(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ) )
+ >>= bFolder;
+ xProps->addProperty(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "CreatableContentsInfo" ) ),
+ uno::makeAny( bFolder
+ ? queryCreatableContentsInfo()
+ : uno::Sequence< ucb::ContentInfo >() ),
+ true );
+ }
}
uno::Reference< sdbc::XRow > xResultRow
@@ -1653,6 +1697,15 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
"Property is read-only!" ),
static_cast< cppu::OWeakObject * >( this ) );
}
+ if ( rName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) )
+ {
+ // Read-only property!
+ aRet[ n ] <<= lang::IllegalAccessException(
+ rtl::OUString::createFromAscii(
+ "Property is read-only!" ),
+ static_cast< cppu::OWeakObject * >( this ) );
+ }
else
{
if ( getResourceType( xEnv, xResAccess ) == DAV )
diff --git a/ucb/source/ucp/webdav/webdavcontentcaps.cxx b/ucb/source/ucp/webdav/webdavcontentcaps.cxx
index 338663d9fc..7f3c20eb08 100644
--- a/ucb/source/ucp/webdav/webdavcontentcaps.cxx
+++ b/ucb/source/ucp/webdav/webdavcontentcaps.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -41,6 +41,7 @@
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/ucb/CommandInfo.hpp>
+#include <com/sun/star/ucb/ContentInfo.hpp>
#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
#include <com/sun/star/ucb/InsertCommandArgument.hpp>
#include <com/sun/star/ucb/PostCommandArgument2.hpp>
@@ -156,6 +157,16 @@ bool ContentProvider::getProperty(
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::READONLY ) );
+ m_pProps->insert(
+ beans::Property(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "CreatableContentsInfo" ) ),
+ -1,
+ getCppuType( static_cast<
+ const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY ) );
+
// Standard DAV properties.
m_pProps->insert(
@@ -348,6 +359,7 @@ uno::Sequence< beans::Property > Content::getProperties(
sal_Bool bHasDateModified = sal_False;
sal_Bool bHasMediaType = sal_False;
sal_Bool bHasSize = sal_False;
+ sal_Bool bHasCreatableInfos = sal_False;
{
std::set< rtl::OUString >::const_iterator it = aPropSet.begin();
@@ -428,7 +440,13 @@ uno::Sequence< beans::Property > Content::getProperties(
{
bHasSize = sal_True;
}
-
+ else if ( !bHasCreatableInfos &&
+ (*it).equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM(
+ "CreatableContentsInfo" ) ) )
+ {
+ bHasCreatableInfos = sal_True;
+ }
it++;
}
}
@@ -478,6 +496,11 @@ uno::Sequence< beans::Property > Content::getProperties(
aPropSet.insert(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ) );
+ if ( !bHasCreatableInfos )
+ aPropSet.insert(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "CreatableContentsInfo" ) ) );
+
// Add cached properties, if present and still missing.
if ( xCachedProps.get() )
{
@@ -602,7 +625,7 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands(
sal_Bool bSupportsLocking = supportsExclusiveWriteLock( xEnv );
sal_Int32 nPos = aCmdInfo.getLength();
- sal_Int32 nMoreCmds = ( bFolder ? 1 : 0 ) + ( bSupportsLocking ? 2 : 0 );
+ sal_Int32 nMoreCmds = ( bFolder ? 2 : 0 ) + ( bSupportsLocking ? 2 : 0 );
if ( nMoreCmds )
aCmdInfo.realloc( nPos + nMoreCmds );
else
@@ -620,6 +643,13 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands(
-1,
getCppuType( static_cast< ucb::TransferInfo * >( 0 ) ) );
nPos++;
+ aCmdInfo[ nPos ] =
+ ucb::CommandInfo(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "createNewContent" ) ),
+ -1,
+ getCppuType( static_cast< ucb::ContentInfo * >( 0 ) ) );
+ nPos++;
}
else
{