summaryrefslogtreecommitdiff
path: root/ucb/source/ucp/tdoc
diff options
context:
space:
mode:
authorsb <sb@openoffice.org>2010-02-08 09:18:14 +0100
committersb <sb@openoffice.org>2010-02-08 09:18:14 +0100
commit07b4fe3375e516f4bba9fef195a130b0533170b7 (patch)
tree2d73ab201e756f0a6c4a7ccbbf1585c6b9c4e3cf /ucb/source/ucp/tdoc
parent9052c35863c67ed02f7f2129a3262dadfd74d843 (diff)
parent3c550e9f7bdd8c9f1f75f4148f516ddc94290f92 (diff)
sb118: merged in DEV300_m71
Diffstat (limited to 'ucb/source/ucp/tdoc')
-rw-r--r--ucb/source/ucp/tdoc/tdoc_content.cxx223
-rw-r--r--ucb/source/ucp/tdoc/tdoc_content.hxx16
-rw-r--r--ucb/source/ucp/tdoc/tdoc_contentcaps.cxx83
3 files changed, 227 insertions, 95 deletions
diff --git a/ucb/source/ucp/tdoc/tdoc_content.cxx b/ucb/source/ucp/tdoc/tdoc_content.cxx
index 908d7310889b..52d5e917bdb9 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 )
@@ -1219,10 +1219,10 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
beans::PropertyChangeEvent aEvent;
aEvent.Source = static_cast< cppu::OWeakObject * >( this );
aEvent.Further = sal_False;
-// aEvent.PropertyName =
+ // aEvent.PropertyName =
aEvent.PropertyHandle = -1;
-// aEvent.OldValue =
-// aEvent.NewValue =
+ // aEvent.OldValue =
+ // aEvent.NewValue =
const beans::PropertyValue* pValues = rValues.getConstArray();
sal_Int32 nCount = rValues.getLength();
@@ -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 c1ff14928496..4f4d692e676d 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;
@@ -106,7 +112,7 @@ class Content : public ::ucbhelper::ContentImplHelper,
public com::sun::star::ucb::XContentCreator
{
enum ContentState { TRANSIENT, // created via createNewContent,
- // but did not process "insert" yet
+ // but did not process "insert" yet
PERSISTENT, // processed "insert"
DEAD // processed "delete" / document was closed
};
@@ -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 ); }
@@ -173,7 +177,7 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
getPropertyValues( const ::com::sun::star::uno::Sequence<
- ::com::sun::star::beans::Property >& rProperties );
+ ::com::sun::star::beans::Property >& rProperties );
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
setPropertyValues(
const ::com::sun::star::uno::Sequence<
@@ -294,7 +298,7 @@ public:
execute( const com::sun::star::ucb::Command& aCommand,
sal_Int32 CommandId,
const com::sun::star::uno::Reference<
- com::sun::star::ucb::XCommandEnvironment >& Environment )
+ com::sun::star::ucb::XCommandEnvironment >& Environment )
throw( com::sun::star::uno::Exception,
com::sun::star::ucb::CommandAbortedException,
com::sun::star::uno::RuntimeException );
diff --git a/ucb/source/ucp/tdoc/tdoc_contentcaps.cxx b/ucb/source/ucp/tdoc/tdoc_contentcaps.cxx
index 792d693ab194..9d026ce7426b 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 );
}
}