diff options
author | sb <sb@openoffice.org> | 2010-02-05 09:17:48 +0100 |
---|---|---|
committer | sb <sb@openoffice.org> | 2010-02-05 09:17:48 +0100 |
commit | eec332142dbfec6a5ab3d8cf4cf1a405cbd3e30c (patch) | |
tree | 55ea7d363745c205a49ebdac6e2b2ccf296eeb37 /ucbhelper/source | |
parent | 08e3d3d8892f40bac9b1c45ecf331e8c0f4ffcbd (diff) | |
parent | da2c680d23b67d4721aa29f740475fd6d40e2e08 (diff) |
sb111: merged in DEV300_m71
Diffstat (limited to 'ucbhelper/source')
-rw-r--r-- | ucbhelper/source/client/content.cxx | 171 |
1 files changed, 117 insertions, 54 deletions
diff --git a/ucbhelper/source/client/content.cxx b/ucbhelper/source/client/content.cxx index 4a620b4b4074..5307fa659d72 100644 --- a/ucbhelper/source/client/content.cxx +++ b/ucbhelper/source/client/content.cxx @@ -73,9 +73,7 @@ #include <ucbhelper/contentbroker.hxx> #include <ucbhelper/activedatasink.hxx> #include <ucbhelper/activedatastreamer.hxx> -#ifndef _UCBHELPER_INTERACTIONREQUEST_HXX #include <ucbhelper/interactionrequest.hxx> -#endif #include <ucbhelper/cancelcommandexecution.hxx> using namespace com::sun::star::container; @@ -149,7 +147,7 @@ void EmptyInputStream::closeInput() //========================================================================= class ContentEventListener_Impl : public cppu::OWeakObject, - public XContentEventListener + public XContentEventListener { Content_Impl& m_rContent; @@ -157,7 +155,7 @@ public: ContentEventListener_Impl( Content_Impl& rContent ) : m_rContent( rContent ) {} - // XInterface + // XInterface XINTERFACE_DECL() // XContentEventListener @@ -184,8 +182,8 @@ friend class ContentEventListener_Impl; mutable rtl::OUString m_aURL; Reference< XMultiServiceFactory > m_xSMgr; Reference< XContent > m_xContent; - Reference< XCommandProcessor > m_xCommandProcessor; - Reference< XCommandEnvironment > m_xEnv; + Reference< XCommandProcessor > m_xCommandProcessor; + Reference< XCommandEnvironment > m_xEnv; Reference< XContentEventListener > m_xContentEventListener; mutable osl::Mutex m_aMutex; sal_Int32 m_nCommandId; @@ -210,6 +208,7 @@ public: Any executeCommand( const Command& rCommand ); void abortCommand(); + inline const Reference< XCommandEnvironment >& getEnvironment() const; inline void setEnvironment( const Reference< XCommandEnvironment >& xNewEnv ); @@ -589,7 +588,7 @@ Any Content::getPropertyValue( sal_Int32 nPropertyHandle ) //========================================================================= Any Content::setPropertyValue( const rtl::OUString& rName, - const Any& rValue ) + const Any& rValue ) throw( CommandAbortedException, RuntimeException, Exception ) { Sequence< rtl::OUString > aNames( 1 ); @@ -604,7 +603,7 @@ Any Content::setPropertyValue( const rtl::OUString& rName, //========================================================================= Any Content::setPropertyValue( const sal_Int32 nPropertyHandle, - const Any& rValue ) + const Any& rValue ) throw( CommandAbortedException, RuntimeException, Exception ) { Sequence< sal_Int32 > aHandles( 1 ); @@ -676,8 +675,8 @@ Reference< XRow > Content::getPropertyValuesInterface( rProp.Name = pNames[ n ]; rProp.Handle = -1; // n/a -// rProp.Type = -// rProp.Attributes = ; +// rProp.Type = +// rProp.Attributes = ; } Command aCommand; @@ -709,8 +708,8 @@ Reference< XRow > Content::getPropertyValuesInterface( rProp.Name = rtl::OUString(); // n/a rProp.Handle = pHandles[ n ]; -// rProp.Type = -// rProp.Attributes = ; +// rProp.Type = +// rProp.Attributes = ; } Command aCommand; @@ -728,7 +727,7 @@ Reference< XRow > Content::getPropertyValuesInterface( //========================================================================= Sequence< Any > Content::setPropertyValues( const Sequence< rtl::OUString >& rPropertyNames, - const Sequence< Any >& rValues ) + const Sequence< Any >& rValues ) throw( CommandAbortedException, RuntimeException, Exception ) { if ( rPropertyNames.getLength() != rValues.getLength() ) @@ -758,7 +757,7 @@ Sequence< Any > Content::setPropertyValues( rProp.Name = pNames[ n ]; rProp.Handle = -1; // n/a rProp.Value = pValues[ n ]; -// rProp.State = ; +// rProp.State = ; } Command aCommand; @@ -776,7 +775,7 @@ Sequence< Any > Content::setPropertyValues( //========================================================================= Sequence< Any > Content::setPropertyValues( const Sequence< sal_Int32 >& nPropertyHandles, - const Sequence< Any >& rValues ) + const Sequence< Any >& rValues ) throw( CommandAbortedException, RuntimeException, Exception ) { if ( nPropertyHandles.getLength() != rValues.getLength() ) @@ -806,7 +805,7 @@ Sequence< Any > Content::setPropertyValues( rProp.Name = rtl::OUString(); // n/a rProp.Handle = pHandles[ n ]; rProp.Value = pValues[ n ]; -// rProp.State = ; +// rProp.State = ; } Command aCommand; @@ -936,7 +935,7 @@ Reference< XResultSet > Content::createCursor( OSL_ENSURE( aResult.is(), "Content::createCursor - no cursor!" ); - if ( !aResult.is() ) + if ( !aResult.is() ) { // Former, the open command directly returned a XResultSet. aCursorAny >>= aResult; @@ -966,7 +965,7 @@ Reference< XResultSet > Content::createCursor( OSL_ENSURE( aResult.is(), "Content::createCursor - no cursor!" ); - if ( !aResult.is() ) + if ( !aResult.is() ) { // Former, the open command directly returned a XResultSet. aCursorAny >>= aResult; @@ -1010,7 +1009,7 @@ Reference< XDynamicResultSet > Content::createDynamicCursor( //========================================================================= Reference< XDynamicResultSet > Content::createSortedDynamicCursor( const Sequence< rtl::OUString >& rPropertyNames, - const ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::NumberedSortingInfo >& rSortInfo, + const Sequence< NumberedSortingInfo >& rSortInfo, Reference< XAnyCompareFactory > rAnyCompareFactory, ResultSetInclude eMode ) throw( CommandAbortedException, RuntimeException, Exception ) @@ -1045,7 +1044,7 @@ Reference< XDynamicResultSet > Content::createSortedDynamicCursor( //========================================================================= Reference< XDynamicResultSet > Content::createSortedDynamicCursor( const Sequence< sal_Int32 >& rPropertyHandles, - const ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::NumberedSortingInfo >& rSortInfo, + const Sequence< NumberedSortingInfo >& rSortInfo, Reference< XAnyCompareFactory > rAnyCompareFactory, ResultSetInclude eMode ) throw( CommandAbortedException, RuntimeException, Exception ) @@ -1080,7 +1079,7 @@ Reference< XDynamicResultSet > Content::createSortedDynamicCursor( //========================================================================= Reference< XResultSet > Content::createSortedCursor( const Sequence< rtl::OUString >& rPropertyNames, - const ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::NumberedSortingInfo >& rSortInfo, + const Sequence< NumberedSortingInfo >& rSortInfo, Reference< XAnyCompareFactory > rAnyCompareFactory, ResultSetInclude eMode ) throw( CommandAbortedException, RuntimeException, Exception ) @@ -1134,7 +1133,7 @@ Reference< XResultSet > Content::createSortedCursor( //========================================================================= Reference< XResultSet > Content::createSortedCursor( const Sequence< sal_Int32 >& rPropertyHandles, - const ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::NumberedSortingInfo >& rSortInfo, + const Sequence< NumberedSortingInfo >& rSortInfo, Reference< XAnyCompareFactory > rAnyCompareFactory, ResultSetInclude eMode ) throw( CommandAbortedException, RuntimeException, Exception ) @@ -1333,7 +1332,7 @@ sal_Bool Content::openStream( const Reference< XOutputStream >& rStream ) //========================================================================= void Content::writeStream( const Reference< XInputStream >& rStream, - sal_Bool bReplaceExisting ) + sal_Bool bReplaceExisting ) throw( CommandAbortedException, RuntimeException, Exception ) { InsertCommandArgument aArg; @@ -1351,11 +1350,31 @@ void Content::writeStream( const Reference< XInputStream >& rStream, } //========================================================================= +Sequence< ContentInfo > Content::queryCreatableContentsInfo() + throw( CommandAbortedException, RuntimeException, Exception ) +{ + // First, try it using "CreatableContentsInfo" property -> the "new" way. + Sequence< ContentInfo > aInfo; + if ( getPropertyValue( + rtl::OUString::createFromAscii( "CreatableContentsInfo" ) ) + >>= aInfo ) + return aInfo; + + // Second, try it using XContentCreator interface -> the "old" way (not + // providing the chance to supply an XCommandEnvironment. + Reference< XContentCreator > xCreator( m_xImpl->getContent(), UNO_QUERY ); + if ( xCreator.is() ) + aInfo = xCreator->queryCreatableContentsInfo(); + + return aInfo; +} + +//========================================================================= sal_Bool Content::insertNewContent( const rtl::OUString& rContentType, const Sequence< rtl::OUString >& rPropertyNames, - const Sequence< Any >& rPropertyValues, - Content& rNewContent ) + const Sequence< Any >& rPropertyValues, + Content& rNewContent ) throw( CommandAbortedException, RuntimeException, Exception ) { return insertNewContent( rContentType, @@ -1369,8 +1388,8 @@ sal_Bool Content::insertNewContent( const rtl::OUString& rContentType, sal_Bool Content::insertNewContent( const rtl::OUString& rContentType, const Sequence< sal_Int32 >& nPropertyHandles, - const Sequence< Any >& rPropertyValues, - Content& rNewContent ) + const Sequence< Any >& rPropertyValues, + Content& rNewContent ) throw( CommandAbortedException, RuntimeException, Exception ) { return insertNewContent( rContentType, @@ -1384,29 +1403,51 @@ sal_Bool Content::insertNewContent( const rtl::OUString& rContentType, sal_Bool Content::insertNewContent( const rtl::OUString& rContentType, const Sequence< rtl::OUString >& rPropertyNames, - const Sequence< Any >& rPropertyValues, + const Sequence< Any >& rPropertyValues, const Reference< XInputStream >& rData, - Content& rNewContent ) + Content& rNewContent ) throw( CommandAbortedException, RuntimeException, Exception ) { if ( rContentType.getLength() == 0 ) return sal_False; - Reference< XContentCreator > xCreator( m_xImpl->getContent(), UNO_QUERY ); - - OSL_ENSURE( xCreator.is(), - "Content::insertNewContent - Not a XContentCreator!" ); - - if ( !xCreator.is() ) - return sal_False; - + // First, try it using "createNewContent" command -> the "new" way. ContentInfo aInfo; aInfo.Type = rContentType; aInfo.Attributes = 0; - Reference< XContent > xNew = xCreator->createNewContent( aInfo ); + Command aCommand; + aCommand.Name = rtl::OUString::createFromAscii( "createNewContent" ); + aCommand.Handle = -1; // n/a + aCommand.Argument <<= aInfo; + + Reference< XContent > xNew; + try + { + m_xImpl->executeCommand( aCommand ) >>= xNew; + } + catch ( RuntimeException const & ) + { + throw; + } + catch ( Exception const & ) + { + } + if ( !xNew.is() ) - return sal_False; + { + // Second, try it using XContentCreator interface -> the "old" + // way (not providing the chance to supply an XCommandEnvironment. + Reference< XContentCreator > xCreator( m_xImpl->getContent(), UNO_QUERY ); + + if ( !xCreator.is() ) + return sal_False; + + xNew = xCreator->createNewContent( aInfo ); + + if ( !xNew.is() ) + return sal_False; + } Content aNewContent( xNew, m_xImpl->getEnvironment() ); aNewContent.setPropertyValues( rPropertyNames, rPropertyValues ); @@ -1425,29 +1466,51 @@ sal_Bool Content::insertNewContent( const rtl::OUString& rContentType, sal_Bool Content::insertNewContent( const rtl::OUString& rContentType, const Sequence< sal_Int32 >& nPropertyHandles, - const Sequence< Any >& rPropertyValues, + const Sequence< Any >& rPropertyValues, const Reference< XInputStream >& rData, - Content& rNewContent ) + Content& rNewContent ) throw( CommandAbortedException, RuntimeException, Exception ) { if ( rContentType.getLength() == 0 ) return sal_False; - Reference< XContentCreator > xCreator( m_xImpl->getContent(), UNO_QUERY ); - - OSL_ENSURE( xCreator.is(), - "Content::insertNewContent - Not a XContentCreator!" ); - - if ( !xCreator.is() ) - return sal_False; - + // First, try it using "createNewContent" command -> the "new" way. ContentInfo aInfo; aInfo.Type = rContentType; aInfo.Attributes = 0; - Reference< XContent > xNew = xCreator->createNewContent( aInfo ); + Command aCommand; + aCommand.Name = rtl::OUString::createFromAscii( "createNewContent" ); + aCommand.Handle = -1; // n/a + aCommand.Argument <<= aInfo; + + Reference< XContent > xNew; + try + { + m_xImpl->executeCommand( aCommand ) >>= xNew; + } + catch ( RuntimeException const & ) + { + throw; + } + catch ( Exception const & ) + { + } + if ( !xNew.is() ) - return sal_False; + { + // Second, try it using XContentCreator interface -> the "old" + // way (not providing the chance to supply an XCommandEnvironment. + Reference< XContentCreator > xCreator( m_xImpl->getContent(), UNO_QUERY ); + + if ( !xCreator.is() ) + return sal_False; + + xNew = xCreator->createNewContent( aInfo ); + + if ( !xNew.is() ) + return sal_False; + } Content aNewContent( xNew, m_xImpl->getEnvironment() ); aNewContent.setPropertyValues( nPropertyHandles, rPropertyValues ); @@ -1466,7 +1529,7 @@ sal_Bool Content::insertNewContent( const rtl::OUString& rContentType, sal_Bool Content::transferContent( const Content& rSourceContent, InsertOperation eOperation, const rtl::OUString & rTitle, - const sal_Int32 nNameClashAction ) + const sal_Int32 nNameClashAction ) throw( CommandAbortedException, RuntimeException, Exception ) { ContentBroker* pBroker = ContentBroker::get(); @@ -1580,8 +1643,8 @@ sal_Bool Content::isDocument() //========================================================================= Content_Impl::Content_Impl( const Reference< XMultiServiceFactory >& rSMgr, - const Reference< XContent >& rContent, - const Reference< XCommandEnvironment >& rEnv ) + const Reference< XContent >& rContent, + const Reference< XCommandEnvironment >& rEnv ) : m_xSMgr( rSMgr ), m_xContent( rContent ), m_xEnv( rEnv ), |