#i61429# - Adapted UCB clients to deprecated XContentCreator interface.
This commit is contained in:
parent
cdb8601188
commit
31a763ce50
4 changed files with 133 additions and 64 deletions
|
@ -48,7 +48,7 @@
|
|||
#include <com/sun/star/sdbc/XRow.hpp>
|
||||
#include <com/sun/star/ucb/CommandAbortedException.hpp>
|
||||
#include <com/sun/star/datatransfer/DataFlavor.hpp>
|
||||
#include <com/sun/star/ucb/XContentCreator.hpp>
|
||||
#include <com/sun/star/ucb/ContentInfo.hpp>
|
||||
#include <com/sun/star/ucb/ContentInfoAttribute.hpp>
|
||||
#include <com/sun/star/beans/Property.hpp>
|
||||
#include <com/sun/star/packages/manifest/XManifestWriter.hpp>
|
||||
|
@ -2277,13 +2277,10 @@ BOOL UCBStorage_Impl::Insert( ::ucbhelper::Content *pContent )
|
|||
// a new substorage is inserted into a UCBStorage ( given by the parameter pContent )
|
||||
// it must be inserted with a title and a type
|
||||
BOOL bRet = FALSE;
|
||||
Reference< XContentCreator > xCreator = Reference< XContentCreator >( pContent->get(), UNO_QUERY );
|
||||
if ( !xCreator.is() )
|
||||
return sal_False;
|
||||
|
||||
try
|
||||
{
|
||||
Sequence< ContentInfo > aInfo = xCreator->queryCreatableContentsInfo();
|
||||
Sequence< ContentInfo > aInfo = pContent->queryCreatableContentsInfo();
|
||||
sal_Int32 nCount = aInfo.getLength();
|
||||
if ( nCount == 0 )
|
||||
return sal_False;
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace com { namespace sun { namespace star { namespace ucb {
|
|||
class XContentIdentifier;
|
||||
class XDynamicResultSet;
|
||||
class XAnyCompareFactory;
|
||||
struct ContentInfo;
|
||||
struct NumberedSortingInfo;
|
||||
} } } }
|
||||
|
||||
|
@ -70,7 +71,7 @@ namespace ucbhelper
|
|||
|
||||
/**
|
||||
* These are the possible values for the parameter eMode of method
|
||||
* ucb::Content::createCursor.
|
||||
* ucbhelper::Content::createCursor.
|
||||
*/
|
||||
enum ResultSetInclude
|
||||
{
|
||||
|
@ -81,7 +82,7 @@ enum ResultSetInclude
|
|||
|
||||
/**
|
||||
* These are the possible values for the parameter eOperation of method
|
||||
* ucb::Content::insertNewContent.
|
||||
* ucbhelper::Content::insertNewContent.
|
||||
*/
|
||||
enum InsertOperation
|
||||
{
|
||||
|
@ -821,16 +822,31 @@ public:
|
|||
throw( ::com::sun::star::ucb::CommandAbortedException,
|
||||
::com::sun::star::uno::RuntimeException,
|
||||
::com::sun::star::uno::Exception );
|
||||
|
||||
/**
|
||||
* This method returns the different types of contents this content
|
||||
* can create.
|
||||
*
|
||||
* @return the content types or an empty sequence if no contents can be
|
||||
* created by this content.
|
||||
*/
|
||||
::com::sun::star::uno::Sequence< ::com::sun::star::ucb::ContentInfo >
|
||||
queryCreatableContentsInfo()
|
||||
throw( ::com::sun::star::ucb::CommandAbortedException,
|
||||
::com::sun::star::uno::RuntimeException,
|
||||
::com::sun::star::uno::Exception );
|
||||
|
||||
/**
|
||||
* This method creates, initializes and inserts ( commits ) a new content
|
||||
* (i.e. it could be used to create a new file system folder).
|
||||
* Internally this method does a XContentCreator::createNewContent(...)-
|
||||
* XCommandProcessor::execute( "setPropertyValues", ... )-
|
||||
* XCommandProcessor::execute( "insert", ... ) calling sequence.
|
||||
* Internally this method does a
|
||||
* XCommandProcessor::execute( "createNewContent", ... );
|
||||
* XCommandProcessor::execute( "setPropertyValues", ... );
|
||||
* XCommandProcessor::execute( "insert", ... ); calling sequence.
|
||||
*
|
||||
* @param rContentType is the type for the new UCB content. Each content
|
||||
* provider implementation may introduce own types for its contnt
|
||||
* objects.
|
||||
* provider implementation may introduce own types for its content
|
||||
* objects (See queryCreatableContentsInfo()).
|
||||
* @param rPropertyNames is a sequence of names of properties for that
|
||||
* values are to set at the new content before it will be inserted
|
||||
* ( commited ).
|
||||
|
@ -856,13 +872,14 @@ public:
|
|||
/**
|
||||
* This method creates, initializes and inserts ( commits ) a new content
|
||||
* (i.e. it could be used to create a new file system folder).
|
||||
* Internally this method does a XContentCreator::createNewContent(...)-
|
||||
* XCommandProcessor::execute( "setPropertyValues", ... )-
|
||||
* XCommandProcessor::execute( "insert", ... ) calling sequence.
|
||||
* Internally this method does a
|
||||
* XCommandProcessor::execute( "createNewContent", ... );
|
||||
* XCommandProcessor::execute( "setPropertyValues", ... );
|
||||
* XCommandProcessor::execute( "insert", ... ); calling sequence.
|
||||
*
|
||||
* @param rContentType is the type for the new UCB content. Each content
|
||||
* provider implementation may introduce own types for its contnt
|
||||
* objects.
|
||||
* provider implementation may introduce own types for its content
|
||||
* objects (See queryCreatableContentsInfo()).
|
||||
* @param nPropertyHandes is a sequence of handles of properties for that
|
||||
* values are to set at the new content before it will be inserted
|
||||
* ( commited ).
|
||||
|
@ -888,14 +905,15 @@ public:
|
|||
/**
|
||||
* This method creates, initializes and inserts (commits) a new content
|
||||
* inside this (the target folder) content. For example, it can be used to
|
||||
* create a new file system folder.
|
||||
* Internally this method does a XContentCreator::createNewContent(...)-
|
||||
* XCommandProcessor::execute( "setPropertyValues", ... )-
|
||||
* XCommandProcessor::execute( "insert", ... ) calling sequence.
|
||||
* create a new file system file.
|
||||
* Internally this method does a
|
||||
* XCommandProcessor::execute( "createNewContent", ... );
|
||||
* XCommandProcessor::execute( "setPropertyValues", ... );
|
||||
* XCommandProcessor::execute( "insert", ... ); calling sequence.
|
||||
*
|
||||
* @param rContentType is the type for the new UCB content. Each content
|
||||
* provider implementation may introduce own types for its contnt
|
||||
* objects.
|
||||
* provider implementation may introduce own types for its content
|
||||
* objects (See queryCreatableContentsInfo()).
|
||||
* @param rPropertyNames is a sequence of names of properties for that
|
||||
* values are to set at the new content before it will be inserted
|
||||
* ( commited ).
|
||||
|
@ -925,14 +943,15 @@ public:
|
|||
/**
|
||||
* This method creates, initializes and inserts (commits) a new content
|
||||
* inside this (the target folder) content. For example, it can be used to
|
||||
* create a new file system folder.
|
||||
* Internally this method does a XContentCreator::createNewContent(...)-
|
||||
* XCommandProcessor::execute( "setPropertyValues", ... )-
|
||||
* XCommandProcessor::execute( "insert", ... ) calling sequence.
|
||||
* create a new file system file.
|
||||
* Internally this method does a
|
||||
* XCommandProcessor::execute( "createNewContent", ... );
|
||||
* XCommandProcessor::execute( "setPropertyValues", ... );
|
||||
* XCommandProcessor::execute( "insert", ... ); calling sequence.
|
||||
*
|
||||
* @param rContentType is the type for the new UCB content. Each content
|
||||
* provider implementation may introduce own types for its contnt
|
||||
* objects.
|
||||
* provider implementation may introduce own types for its content
|
||||
* objects (See queryCreatableContentsInfo()).
|
||||
* @param nPropertyHandes is a sequence of handles of properties for that
|
||||
* values are to set at the new content before it will be inserted
|
||||
* ( commited ).
|
||||
|
|
|
@ -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;
|
||||
|
@ -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 );
|
||||
|
@ -1348,6 +1347,26 @@ void Content::writeStream( const Reference< XInputStream >& rStream,
|
|||
m_xImpl->inserted();
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
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 >&
|
||||
|
@ -1390,21 +1409,43 @@ sal_Bool Content::insertNewContent( const rtl::OUString& rContentType,
|
|||
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 );
|
||||
|
@ -1431,21 +1472,43 @@ sal_Bool Content::insertNewContent( const rtl::OUString& rContentType,
|
|||
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 );
|
||||
|
|
|
@ -46,15 +46,13 @@
|
|||
#include <com/sun/star/ucb/XAnyCompareFactory.hpp>
|
||||
#include <com/sun/star/ucb/XCommandInfo.hpp>
|
||||
#include <com/sun/star/ucb/XContentAccess.hpp>
|
||||
#include <com/sun/star/ucb/ContentInfo.hpp>
|
||||
#include <com/sun/star/ucb/ContentInfoAttribute.hpp>
|
||||
#include <com/sun/star/ucb/XContentCreator.hpp>
|
||||
#include <com/sun/star/ucb/XDynamicResultSet.hpp>
|
||||
#include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
|
||||
#include <com/sun/star/util/DateTime.hpp>
|
||||
#include <com/sun/star/container/XChild.hpp>
|
||||
#ifndef _COM_SUN_STAR_UCB_INTERACTIVEIODEXCEPTION_HPP_
|
||||
#include <com/sun/star/ucb/InteractiveIOException.hpp>
|
||||
#endif
|
||||
#include <com/sun/star/task/XInteractionHandler.hpp>
|
||||
#include <ucbhelper/commandenvironment.hxx>
|
||||
#include <ucbhelper/content.hxx>
|
||||
|
@ -489,11 +487,7 @@ sal_Bool UCBContentHelper::CanMakeFolder( const String& rFolder )
|
|||
try
|
||||
{
|
||||
Content aCnt( rFolder, uno::Reference< XCommandEnvironment > () );
|
||||
uno::Reference< XContentCreator > xCreator = uno::Reference< XContentCreator >( aCnt.get(), UNO_QUERY );
|
||||
if ( !xCreator.is() )
|
||||
return sal_False;
|
||||
|
||||
Sequence< ContentInfo > aInfo = xCreator->queryCreatableContentsInfo();
|
||||
Sequence< ContentInfo > aInfo = aCnt.queryCreatableContentsInfo();
|
||||
sal_Int32 nCount = aInfo.getLength();
|
||||
if ( nCount == 0 )
|
||||
return sal_False;
|
||||
|
@ -538,11 +532,7 @@ sal_Bool UCBContentHelper::MakeFolder( Content& aCnt, const String& aTitle, Cont
|
|||
|
||||
try
|
||||
{
|
||||
uno::Reference< XContentCreator > xCreator( aCnt.get(), UNO_QUERY );
|
||||
if ( !xCreator.is() )
|
||||
return sal_False;
|
||||
|
||||
Sequence< ContentInfo > aInfo = xCreator->queryCreatableContentsInfo();
|
||||
Sequence< ContentInfo > aInfo = aCnt.queryCreatableContentsInfo();
|
||||
sal_Int32 nCount = aInfo.getLength();
|
||||
if ( nCount == 0 )
|
||||
return sal_False;
|
||||
|
|
Loading…
Reference in a new issue