diff options
author | Kai Sommerfeld <kso@openoffice.org> | 2009-12-21 15:53:33 +0100 |
---|---|---|
committer | Kai Sommerfeld <kso@openoffice.org> | 2009-12-21 15:53:33 +0100 |
commit | ee2ecbf89b002fa8f60316b4266b96dfca8b4591 (patch) | |
tree | 2be9d3aa751f3d2e69106ba3bd78b0da3f053a6b /ucb/source/ucp/tdoc | |
parent | 22652581ffbb7b795f3ed5ee9dc4a85b24bac25f (diff) |
#i61429#, deprecated css.ucb.XContentCreator, implemented replacement.
Diffstat (limited to 'ucb/source/ucp/tdoc')
-rw-r--r-- | ucb/source/ucp/tdoc/tdoc_content.cxx | 217 | ||||
-rw-r--r-- | ucb/source/ucp/tdoc/tdoc_content.hxx | 10 | ||||
-rw-r--r-- | ucb/source/ucp/tdoc/tdoc_contentcaps.cxx | 83 |
3 files changed, 221 insertions, 89 deletions
diff --git a/ucb/source/ucp/tdoc/tdoc_content.cxx b/ucb/source/ucp/tdoc/tdoc_content.cxx index 2f940e9715c9..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 ) @@ -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 c994d9911064..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; @@ -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 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 ); } } |