summaryrefslogtreecommitdiff
path: root/ucbhelper/source/client/content.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'ucbhelper/source/client/content.cxx')
-rw-r--r--ucbhelper/source/client/content.cxx171
1 files changed, 117 insertions, 54 deletions
diff --git a/ucbhelper/source/client/content.cxx b/ucbhelper/source/client/content.cxx
index c82a0bc19b77..28eef297e85f 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 );
@@ -587,7 +586,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 );
@@ -602,7 +601,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 );
@@ -674,8 +673,8 @@ Reference< XRow > Content::getPropertyValuesInterface(
rProp.Name = pNames[ n ];
rProp.Handle = -1; // n/a
-// rProp.Type =
-// rProp.Attributes = ;
+// rProp.Type =
+// rProp.Attributes = ;
}
Command aCommand;
@@ -707,8 +706,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;
@@ -726,7 +725,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() )
@@ -756,7 +755,7 @@ Sequence< Any > Content::setPropertyValues(
rProp.Name = pNames[ n ];
rProp.Handle = -1; // n/a
rProp.Value = pValues[ n ];
-// rProp.State = ;
+// rProp.State = ;
}
Command aCommand;
@@ -774,7 +773,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() )
@@ -804,7 +803,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;
@@ -934,7 +933,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;
@@ -964,7 +963,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;
@@ -1008,7 +1007,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 )
@@ -1043,7 +1042,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 )
@@ -1078,7 +1077,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 )
@@ -1132,7 +1131,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 )
@@ -1331,7 +1330,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;
@@ -1349,11 +1348,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,
@@ -1367,8 +1386,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,
@@ -1382,29 +1401,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 );
@@ -1423,29 +1464,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 );
@@ -1464,7 +1527,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();
@@ -1578,8 +1641,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 ),