Kaydet (Commit) f3b44f63 authored tarafından Andreas Bille's avatar Andreas Bille

#98767# now using ucbhelper::cancelCommandExcecution;…

#98767# now using ucbhelper::cancelCommandExcecution; UnsupportedCommandException instead of CommandAborted
üst 5622d56f
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: content.cxx,v $ * $RCSfile: content.cxx,v $
* *
* $Revision: 1.14 $ * $Revision: 1.15 $
* *
* last change: $Author: vg $ $Date: 2001-10-02 11:48:26 $ * last change: $Author: abi $ $Date: 2002-10-30 09:59:17 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -89,6 +89,9 @@ ...@@ -89,6 +89,9 @@
#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_ #ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
#include <com/sun/star/io/XOutputStream.hpp> #include <com/sun/star/io/XOutputStream.hpp>
#endif #endif
#ifndef _COM_SUN_STAR_LANG_ILLEGALACCESSEXCEPTION_HPP_
#include <com/sun/star/lang/IllegalAccessException.hpp>
#endif
#ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDDATASINKEXCEPTION_HPP_ #ifndef _COM_SUN_STAR_UCB_UNSUPPORTEDDATASINKEXCEPTION_HPP_
#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp> #include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
#endif #endif
...@@ -107,7 +110,9 @@ ...@@ -107,7 +110,9 @@
#ifndef _UCBHELPER_PROPERTYVALUESET_HXX #ifndef _UCBHELPER_PROPERTYVALUESET_HXX
#include <ucbhelper/propertyvalueset.hxx> #include <ucbhelper/propertyvalueset.hxx>
#endif #endif
#ifndef _UCBHELPER_CANCELCOMMANDEXECUTION_HXX
#include <ucbhelper/cancelcommandexecution.hxx>
#endif
#ifndef _CONTENT_HXX #ifndef _CONTENT_HXX
#include <provider/content.hxx> #include <provider/content.hxx>
#endif #endif
...@@ -396,15 +401,34 @@ Any SAL_CALL Content::execute( const Command& aCommand, ...@@ -396,15 +401,34 @@ Any SAL_CALL Content::execute( const Command& aCommand,
Sequence< Property > Properties; Sequence< Property > Properties;
if ( !( aCommand.Argument >>= Properties ) ) if ( !( aCommand.Argument >>= Properties ) )
{ {
VOS_ENSURE( sal_False, "Wrong argument type!" ); aRet <<= IllegalArgumentException();
return aRet; ucbhelper::cancelCommandExecution(aRet,Environment);
} }
aRet <<= getPropertyValues( Properties ); aRet <<= getPropertyValues( Properties );
} }
else if ( aCommand.Name.compareToAscii( "setPropertyValues" ) == 0 ) else if ( aCommand.Name.compareToAscii( "setPropertyValues" ) == 0 )
{ {
Sequence<PropertyValue> propertyValues;
if( ! ( aCommand.Argument >>= propertyValues ) ) {
aRet <<= IllegalArgumentException();
ucbhelper::cancelCommandExecution(aRet,Environment);
}
Sequence<Any> ret(propertyValues.getLength());
Sequence< Property > props(getProperties(Environment));
// No properties can be set // No properties can be set
for(sal_Int32 i = 0; i < ret.getLength(); ++i) {
ret[i] <<= UnknownPropertyException();
for(sal_Int32 j = 0; j < props.getLength(); ++j)
if(props[j].Name == propertyValues[i].Name) {
ret[i] <<= IllegalAccessException();
break;
}
}
aRet <<= ret;
} }
else if ( aCommand.Name.compareToAscii( "getPropertySetInfo" ) == 0 ) else if ( aCommand.Name.compareToAscii( "getPropertySetInfo" ) == 0 )
{ {
...@@ -421,47 +445,66 @@ Any SAL_CALL Content::execute( const Command& aCommand, ...@@ -421,47 +445,66 @@ Any SAL_CALL Content::execute( const Command& aCommand,
OpenCommandArgument2 aOpenCommand; OpenCommandArgument2 aOpenCommand;
if ( !( aCommand.Argument >>= aOpenCommand ) ) if ( !( aCommand.Argument >>= aOpenCommand ) )
{ {
VOS_ENSURE( sal_False, aRet <<= IllegalArgumentException();
"Content::execute - invalid parameter!" ); ucbhelper::cancelCommandExecution(aRet,Environment);
throw IllegalArgumentException();
} }
Reference< XActiveDataSink > xActiveDataSink( aOpenCommand.Sink,UNO_QUERY ); Reference< XActiveDataSink > xActiveDataSink(
if( xActiveDataSink.is() ) aOpenCommand.Sink,UNO_QUERY);
m_aURLParameter.open( m_xSMgr,aCommand,CommandId,Environment,xActiveDataSink );
if(xActiveDataSink.is())
m_aURLParameter.open(m_xSMgr,
aCommand,
CommandId,
Environment,
xActiveDataSink);
Reference< XActiveDataStreamer > activeDataStreamer( aOpenCommand.Sink,UNO_QUERY ); Reference< XActiveDataStreamer > xActiveDataStreamer(
if( activeDataStreamer.is() ) aOpenCommand.Sink,UNO_QUERY);
throw UnsupportedDataSinkException();
if(xActiveDataStreamer.is()) {
aRet <<= UnsupportedDataSinkException();
ucbhelper::cancelCommandExecution(aRet,Environment);
}
Reference< XOutputStream > xOutputStream( aOpenCommand.Sink,UNO_QUERY ); Reference< XOutputStream > xOutputStream(
if( xOutputStream.is() ) aOpenCommand.Sink,UNO_QUERY);
m_aURLParameter.open( m_xSMgr,aCommand,CommandId,Environment,xOutputStream );
if(xOutputStream.is() )
m_aURLParameter.open(m_xSMgr,
aCommand,
CommandId,
Environment,
xOutputStream);
if( m_aURLParameter.isRoot() ) if( m_aURLParameter.isRoot() )
{ {
Reference< XDynamicResultSet > xSet Reference< XDynamicResultSet > xSet
= new DynamicResultSet( m_xSMgr, = new DynamicResultSet(
m_xSMgr,
this, this,
aOpenCommand, aOpenCommand,
Environment, Environment,
new ResultSetForRootFactory( m_xSMgr, new ResultSetForRootFactory(
m_xSMgr,
m_xProvider.getBodyPtr(), m_xProvider.getBodyPtr(),
aOpenCommand.Mode, aOpenCommand.Mode,
aOpenCommand.Properties, aOpenCommand.Properties,
aOpenCommand.SortingInfo, aOpenCommand.SortingInfo,
m_aURLParameter, m_aURLParameter,
m_pDatabases ) ); m_pDatabases));
aRet <<= xSet; aRet <<= xSet;
} }
else if( m_aURLParameter.isQuery() ) else if( m_aURLParameter.isQuery() )
{ {
Reference< XDynamicResultSet > xSet Reference< XDynamicResultSet > xSet
= new DynamicResultSet( m_xSMgr, = new DynamicResultSet(
m_xSMgr,
this, this,
aOpenCommand, aOpenCommand,
Environment, Environment,
new ResultSetForQueryFactory( m_xSMgr, new ResultSetForQueryFactory(
m_xSMgr,
m_xProvider.getBodyPtr(), m_xProvider.getBodyPtr(),
aOpenCommand.Mode, aOpenCommand.Mode,
aOpenCommand.Properties, aOpenCommand.Properties,
...@@ -476,9 +519,8 @@ Any SAL_CALL Content::execute( const Command& aCommand, ...@@ -476,9 +519,8 @@ Any SAL_CALL Content::execute( const Command& aCommand,
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
// Unsupported command // Unsupported command
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
aRet <<= UnsupportedCommandException();
// VOS_ENSURE( sal_False, "Content::execute - unsupported command!" ); ucbhelper::cancelCommandExecution(aRet,Environment);
throw CommandAbortedException();
} }
return aRet; return aRet;
...@@ -492,39 +534,55 @@ Reference< XRow > Content::getPropertyValues( const Sequence< Property >& rPrope ...@@ -492,39 +534,55 @@ Reference< XRow > Content::getPropertyValues( const Sequence< Property >& rPrope
{ {
osl::MutexGuard aGuard( m_aMutex ); osl::MutexGuard aGuard( m_aMutex );
vos::ORef< ::ucb::PropertyValueSet > xRow = new ::ucb::PropertyValueSet( m_xSMgr ); vos::ORef< ::ucb::PropertyValueSet > xRow =
new ::ucb::PropertyValueSet( m_xSMgr );
for ( sal_Int32 n = 0; n < rProperties.getLength(); ++n ) for ( sal_Int32 n = 0; n < rProperties.getLength(); ++n )
{ {
const Property& rProp = rProperties[n]; const Property& rProp = rProperties[n];
if ( rProp.Name.compareToAscii( "ContentType" ) == 0 ) if ( rProp.Name.compareToAscii( "ContentType" ) == 0 )
xRow->appendString( rProp,rtl::OUString::createFromAscii( "application/vnd.sun.star.help" ) ); xRow->appendString(
rProp,
rtl::OUString::createFromAscii(
"application/vnd.sun.star.help" ) );
else if( rProp.Name.compareToAscii( "Title" ) == 0 ) else if( rProp.Name.compareToAscii( "Title" ) == 0 )
xRow->appendString ( rProp,m_aURLParameter.get_title() ); xRow->appendString ( rProp,m_aURLParameter.get_title() );
else if( rProp.Name.compareToAscii( "IsReadOnly" ) == 0 ) else if( rProp.Name.compareToAscii( "IsReadOnly" ) == 0 )
xRow->appendBoolean( rProp,true ); xRow->appendBoolean( rProp,true );
else if( rProp.Name.compareToAscii( "IsDocument" ) == 0 ) else if( rProp.Name.compareToAscii( "IsDocument" ) == 0 )
xRow->appendBoolean( rProp,m_aURLParameter.isFile() || m_aURLParameter.isRoot() ); xRow->appendBoolean(
rProp,
m_aURLParameter.isFile() || m_aURLParameter.isRoot() );
else if( rProp.Name.compareToAscii( "IsFolder" ) == 0 ) else if( rProp.Name.compareToAscii( "IsFolder" ) == 0 )
xRow->appendBoolean( rProp, ! m_aURLParameter.isFile() || m_aURLParameter.isRoot() ); xRow->appendBoolean(
rProp,
! m_aURLParameter.isFile() || m_aURLParameter.isRoot() );
else if( rProp.Name.compareToAscii( "IsErrorDocument" ) == 0 ) else if( rProp.Name.compareToAscii( "IsErrorDocument" ) == 0 )
xRow->appendBoolean( rProp, m_aURLParameter.isErrorDocument() ); xRow->appendBoolean( rProp, m_aURLParameter.isErrorDocument() );
else if( rProp.Name.compareToAscii( "MediaType" ) == 0 ) else if( rProp.Name.compareToAscii( "MediaType" ) == 0 )
if( m_aURLParameter.isPicture() ) if( m_aURLParameter.isPicture() )
xRow->appendString( rProp,rtl::OUString::createFromAscii( "image/gif" ) ); xRow->appendString(
rProp,
rtl::OUString::createFromAscii( "image/gif" ) );
else if( m_aURLParameter.isActive() ) else if( m_aURLParameter.isActive() )
xRow->appendString( rProp,rtl::OUString::createFromAscii( "text/plain" ) ); xRow->appendString(
rProp,
rtl::OUString::createFromAscii( "text/plain" ) );
else if( m_aURLParameter.isFile() ) else if( m_aURLParameter.isFile() )
xRow->appendString( rProp,rtl::OUString::createFromAscii( "text/html" ) ); xRow->appendString(
rProp,rtl::OUString::createFromAscii( "text/html" ) );
else if( m_aURLParameter.isRoot() ) else if( m_aURLParameter.isRoot() )
xRow->appendString( rProp,rtl::OUString::createFromAscii( "text/css" ) ); xRow->appendString(
rProp,
rtl::OUString::createFromAscii( "text/css" ) );
else else
xRow->appendVoid( rProp ); xRow->appendVoid( rProp );
else if( m_aURLParameter.isModule() ) else if( m_aURLParameter.isModule() )
if( rProp.Name.compareToAscii( "KeywordList" ) == 0 ) if( rProp.Name.compareToAscii( "KeywordList" ) == 0 )
{ {
KeywordInfo *inf = m_pDatabases->getKeyword( m_aURLParameter.get_module(), KeywordInfo *inf =
m_pDatabases->getKeyword( m_aURLParameter.get_module(),
m_aURLParameter.get_language() ); m_aURLParameter.get_language() );
Any aAny; Any aAny;
...@@ -534,7 +592,8 @@ Reference< XRow > Content::getPropertyValues( const Sequence< Property >& rPrope ...@@ -534,7 +592,8 @@ Reference< XRow > Content::getPropertyValues( const Sequence< Property >& rPrope
} }
else if( rProp.Name.compareToAscii( "KeywordRef" ) == 0 ) else if( rProp.Name.compareToAscii( "KeywordRef" ) == 0 )
{ {
KeywordInfo *inf = m_pDatabases->getKeyword( m_aURLParameter.get_module(), KeywordInfo *inf =
m_pDatabases->getKeyword( m_aURLParameter.get_module(),
m_aURLParameter.get_language() ); m_aURLParameter.get_language() );
Any aAny; Any aAny;
...@@ -544,7 +603,8 @@ Reference< XRow > Content::getPropertyValues( const Sequence< Property >& rPrope ...@@ -544,7 +603,8 @@ Reference< XRow > Content::getPropertyValues( const Sequence< Property >& rPrope
} }
else if( rProp.Name.compareToAscii( "KeywordAnchorForRef" ) == 0 ) else if( rProp.Name.compareToAscii( "KeywordAnchorForRef" ) == 0 )
{ {
KeywordInfo *inf = m_pDatabases->getKeyword( m_aURLParameter.get_module(), KeywordInfo *inf =
m_pDatabases->getKeyword( m_aURLParameter.get_module(),
m_aURLParameter.get_language() ); m_aURLParameter.get_language() );
Any aAny; Any aAny;
...@@ -554,7 +614,8 @@ Reference< XRow > Content::getPropertyValues( const Sequence< Property >& rPrope ...@@ -554,7 +614,8 @@ Reference< XRow > Content::getPropertyValues( const Sequence< Property >& rPrope
} }
else if( rProp.Name.compareToAscii( "KeywordTitleForRef" ) == 0 ) else if( rProp.Name.compareToAscii( "KeywordTitleForRef" ) == 0 )
{ {
KeywordInfo *inf = m_pDatabases->getKeyword( m_aURLParameter.get_module(), KeywordInfo *inf =
m_pDatabases->getKeyword( m_aURLParameter.get_module(),
m_aURLParameter.get_language() ); m_aURLParameter.get_language() );
Any aAny; Any aAny;
...@@ -573,7 +634,8 @@ Reference< XRow > Content::getPropertyValues( const Sequence< Property >& rPrope ...@@ -573,7 +634,8 @@ Reference< XRow > Content::getPropertyValues( const Sequence< Property >& rPrope
} }
else if( rProp.Name.compareToAscii( "Order" ) == 0 ) else if( rProp.Name.compareToAscii( "Order" ) == 0 )
{ {
StaticModuleInformation *inf = m_pDatabases->getStaticInformationForModule( StaticModuleInformation *inf =
m_pDatabases->getStaticInformationForModule(
m_aURLParameter.get_module(), m_aURLParameter.get_module(),
m_aURLParameter.get_language() ); m_aURLParameter.get_language() );
...@@ -584,7 +646,8 @@ Reference< XRow > Content::getPropertyValues( const Sequence< Property >& rPrope ...@@ -584,7 +646,8 @@ Reference< XRow > Content::getPropertyValues( const Sequence< Property >& rPrope
} }
else else
xRow->appendVoid( rProp ); xRow->appendVoid( rProp );
else if( rProp.Name.compareToAscii( "AnchorName" ) == 0 && m_aURLParameter.isFile() ) else if( rProp.Name.compareToAscii( "AnchorName" ) == 0 &&
m_aURLParameter.isFile() )
xRow->appendString( rProp,m_aURLParameter.get_tag() ); xRow->appendString( rProp,m_aURLParameter.get_tag() );
else else
xRow->appendVoid( rProp ); xRow->appendVoid( rProp );
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: provider.cxx,v $ * $RCSfile: provider.cxx,v $
* *
* $Revision: 1.13 $ * $Revision: 1.14 $
* *
* last change: $Author: kso $ $Date: 2002-08-02 15:19:00 $ * last change: $Author: abi $ $Date: 2002-10-30 09:59:17 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -295,7 +295,7 @@ void ContentProvider::init() ...@@ -295,7 +295,7 @@ void ContentProvider::init()
aAny >>= m_xContainer; aAny >>= m_xContainer;
if(m_xContainer.is()) if(m_xContainer.is())
m_xContainer->addContainerListener(this); m_xContainer->addContainerListener(this);
} catch(const com::sun::star::uno::Exception& e) { } catch(const com::sun::star::uno::Exception&) {
} }
/** /**
...@@ -367,10 +367,12 @@ Reference< XMultiServiceFactory > ContentProvider::getConfiguration() const ...@@ -367,10 +367,12 @@ Reference< XMultiServiceFactory > ContentProvider::getConfiguration() const
try try
{ {
rtl::OUString sProviderService = rtl::OUString sProviderService =
rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" ); rtl::OUString::createFromAscii(
"com.sun.star.configuration.ConfigurationProvider" );
sProvider = sProvider =
Reference< XMultiServiceFactory >( Reference< XMultiServiceFactory >(
m_xSMgr->createInstanceWithArguments( sProviderService,seq ), m_xSMgr->createInstanceWithArguments(
sProviderService,seq ),
UNO_QUERY ); UNO_QUERY );
} }
catch( const com::sun::star::uno::Exception& ) catch( const com::sun::star::uno::Exception& )
...@@ -416,8 +418,9 @@ ContentProvider::getHierAccess( const Reference< XMultiServiceFactory >& sProvid ...@@ -416,8 +418,9 @@ ContentProvider::getHierAccess( const Reference< XMultiServiceFactory >& sProvid
rtl::OUString rtl::OUString
ContentProvider::getKey( const Reference< XHierarchicalNameAccess >& xHierAccess, ContentProvider::getKey(const Reference<
const char* key ) const XHierarchicalNameAccess >& xHierAccess,
const char* key) const
{ {
rtl::OUString instPath; rtl::OUString instPath;
if( xHierAccess.is() ) if( xHierAccess.is() )
...@@ -426,7 +429,8 @@ ContentProvider::getKey( const Reference< XHierarchicalNameAccess >& xHierAccess ...@@ -426,7 +429,8 @@ ContentProvider::getKey( const Reference< XHierarchicalNameAccess >& xHierAccess
try try
{ {
aAny = aAny =
xHierAccess->getByHierarchicalName( rtl::OUString::createFromAscii( key ) ); xHierAccess->getByHierarchicalName(
rtl::OUString::createFromAscii(key));
} }
catch( const com::sun::star::container::NoSuchElementException& ) catch( const com::sun::star::container::NoSuchElementException& )
{ {
...@@ -450,7 +454,7 @@ void ContentProvider::subst( rtl::OUString& instpath ) const ...@@ -450,7 +454,7 @@ void ContentProvider::subst( rtl::OUString& instpath ) const
m_xSMgr->createInstance( rtl::OUString::createFromAscii( "com.sun.star.config.SpecialConfigManager" ) ), m_xSMgr->createInstance( rtl::OUString::createFromAscii( "com.sun.star.config.SpecialConfigManager" ) ),
UNO_QUERY ); UNO_QUERY );
} }
catch( const com::sun::star::uno::Exception& e ) catch( const com::sun::star::uno::Exception&)
{ {
OSL_ENSURE( xCfgMgr.is()," cant instantiate the special config manager " ); OSL_ENSURE( xCfgMgr.is()," cant instantiate the special config manager " );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment