loplugin:flatten in various

Change-Id: I42dca691ffadbddad38a7e8f978b1da9d5d9a7b0
Reviewed-on: https://gerrit.libreoffice.org/42842
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2017-09-27 09:11:35 +02:00
parent b50f595b34
commit cc1ed7fbce
23 changed files with 693 additions and 775 deletions

View File

@ -344,7 +344,7 @@ std::string Flatten::getSourceAsString(SourceRange range)
return std::string( p1, p2 - p1); return std::string( p1, p2 - p1);
} }
loplugin::Plugin::Registration< Flatten > X("flatten", false); loplugin::Plugin::Registration< Flatten > X("flatten", true);
} }

View File

@ -293,34 +293,29 @@ void SAL_CALL ODummyEmbeddedObject::setPersistentEntry(
if ( m_bWaitSaveCompleted ) if ( m_bWaitSaveCompleted )
{ {
if ( nEntryConnectionMode == embed::EntryInitModes::NO_INIT ) if ( nEntryConnectionMode != embed::EntryInitModes::NO_INIT )
saveCompleted( m_xParentStorage != xStorage || m_aEntryName != sEntName );
else
throw embed::WrongStateException( throw embed::WrongStateException(
"The object waits for saveCompleted() call!", "The object waits for saveCompleted() call!",
static_cast< ::cppu::OWeakObject* >(this) ); static_cast< ::cppu::OWeakObject* >(this) );
saveCompleted( m_xParentStorage != xStorage || m_aEntryName != sEntName );
} }
if ( nEntryConnectionMode == embed::EntryInitModes::DEFAULT_INIT if ( nEntryConnectionMode != embed::EntryInitModes::DEFAULT_INIT
|| nEntryConnectionMode == embed::EntryInitModes::NO_INIT ) && nEntryConnectionMode != embed::EntryInitModes::NO_INIT )
{ throw lang::IllegalArgumentException( "Wrong connection mode is provided!",
if ( xStorage->hasByName( sEntName ) ) static_cast< ::cppu::OWeakObject* >(this),
3 );
{ if ( !xStorage->hasByName( sEntName ) )
m_xParentStorage = xStorage;
m_aEntryName = sEntName;
m_nObjectState = embed::EmbedStates::LOADED;
}
else
throw lang::IllegalArgumentException( "Wrong entry is provided!", throw lang::IllegalArgumentException( "Wrong entry is provided!",
static_cast< ::cppu::OWeakObject* >(this), static_cast< ::cppu::OWeakObject* >(this),
2 ); 2 );
} m_xParentStorage = xStorage;
else m_aEntryName = sEntName;
throw lang::IllegalArgumentException( "Wrong connection mode is provided!", m_nObjectState = embed::EmbedStates::LOADED;
static_cast< ::cppu::OWeakObject* >(this),
3 );
} }

View File

@ -903,8 +903,12 @@ void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID )
else else
#endif #endif
{ {
if ( nVerbID == -9 ) if ( nVerbID != -9 )
{ {
throw embed::UnreachableStateException();
}
// the workaround verb to show the object in case no server is available // the workaround verb to show the object in case no server is available
// if it is possible, the object will be converted to OOo format // if it is possible, the object will be converted to OOo format
@ -957,21 +961,15 @@ void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID )
if (m_aTempDumpURL.isEmpty()) if (m_aTempDumpURL.isEmpty())
m_aTempDumpURL = lcl_ExtractObject(m_xFactory, m_xObjectStream); m_aTempDumpURL = lcl_ExtractObject(m_xFactory, m_xObjectStream);
if (!m_aTempDumpURL.isEmpty()) if (m_aTempDumpURL.isEmpty())
{ throw embed::UnreachableStateException();
uno::Reference< css::system::XSystemShellExecute > xSystemShellExecute( uno::Reference< css::system::XSystemShellExecute > xSystemShellExecute(
css::system::SystemShellExecute::create(comphelper::getComponentContext(m_xFactory)) ); css::system::SystemShellExecute::create(comphelper::getComponentContext(m_xFactory)) );
xSystemShellExecute->execute(m_aTempDumpURL, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY); xSystemShellExecute->execute(m_aTempDumpURL, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY);
}
else
throw embed::UnreachableStateException();
}
}
else
{
throw embed::UnreachableStateException();
} }
} }
} }

View File

@ -120,16 +120,13 @@ OUString GetNewFilledTempFile_Impl( const uno::Reference< io::XInputStream >& xI
ucb::SimpleFileAccess::create( comphelper::getComponentContext(xFactory) ) ); ucb::SimpleFileAccess::create( comphelper::getComponentContext(xFactory) ) );
uno::Reference< io::XOutputStream > xTempOutStream = xTempAccess->openFileWrite( aResult ); uno::Reference< io::XOutputStream > xTempOutStream = xTempAccess->openFileWrite( aResult );
if ( xTempOutStream.is() ) if ( !xTempOutStream.is() )
{ throw io::IOException(); // TODO:
// copy stream contents to the file // copy stream contents to the file
::comphelper::OStorageHelper::CopyInputToOutput( xInStream, xTempOutStream ); ::comphelper::OStorageHelper::CopyInputToOutput( xInStream, xTempOutStream );
xTempOutStream->closeOutput(); xTempOutStream->closeOutput();
xTempOutStream.clear(); xTempOutStream.clear();
} }
else
throw io::IOException(); // TODO:
}
catch( const packages::WrongPasswordException& ) catch( const packages::WrongPasswordException& )
{ {
KillFile_Impl( aResult, xFactory ); KillFile_Impl( aResult, xFactory );
@ -267,14 +264,10 @@ uno::Reference< io::XStream > OleEmbeddedObject::GetNewFilledTempStream_Impl( co
uno::UNO_QUERY_THROW ); uno::UNO_QUERY_THROW );
uno::Reference< io::XOutputStream > xTempOutStream = xTempFile->getOutputStream(); uno::Reference< io::XOutputStream > xTempOutStream = xTempFile->getOutputStream();
if ( xTempOutStream.is() ) if ( !xTempOutStream.is() )
{ throw io::IOException(); // TODO:
::comphelper::OStorageHelper::CopyInputToOutput( xInStream, xTempOutStream ); ::comphelper::OStorageHelper::CopyInputToOutput( xInStream, xTempOutStream );
xTempOutStream->flush(); xTempOutStream->flush();
}
else
throw io::IOException(); // TODO:
return xTempFile; return xTempFile;
} }
@ -388,8 +381,9 @@ void OleEmbeddedObject::InsertVisualCache_Impl( const uno::Reference< io::XStrea
uno::Reference< io::XSeekable > xTempSeek( xTempFile, uno::UNO_QUERY_THROW ); uno::Reference< io::XSeekable > xTempSeek( xTempFile, uno::UNO_QUERY_THROW );
uno::Reference< io::XOutputStream > xTempOutStream = xTempFile->getOutputStream(); uno::Reference< io::XOutputStream > xTempOutStream = xTempFile->getOutputStream();
if ( xTempOutStream.is() ) if ( !xTempOutStream.is() )
{ throw io::IOException(); // TODO:
// the OlePres stream must have additional header // the OlePres stream must have additional header
// TODO/LATER: might need to be extended in future (actually makes sense only for SO7 format) // TODO/LATER: might need to be extended in future (actually makes sense only for SO7 format)
uno::Reference< io::XInputStream > xInCacheStream = xCachedVisualRepresentation->getInputStream(); uno::Reference< io::XInputStream > xInCacheStream = xCachedVisualRepresentation->getInputStream();
@ -489,9 +483,6 @@ void OleEmbeddedObject::InsertVisualCache_Impl( const uno::Reference< io::XStrea
xTempSeek->seek( 0 ); xTempSeek->seek( 0 );
if ( xCachedSeek.is() ) if ( xCachedSeek.is() )
xCachedSeek->seek( 0 ); xCachedSeek->seek( 0 );
}
else
throw io::IOException(); // TODO:
// insert the result file as replacement image // insert the result file as replacement image
OUString aCacheName = "\002OlePres000"; OUString aCacheName = "\002OlePres000";
@ -1164,7 +1155,7 @@ void OleEmbeddedObject::StoreToLocation_Impl(
} }
} }
#endif #endif
else else if (true) // loplugin:flatten
{ {
throw io::IOException(); // TODO throw io::IOException(); // TODO
} }
@ -1304,12 +1295,11 @@ void SAL_CALL OleEmbeddedObject::setPersistentEntry(
if ( m_bWaitSaveCompleted ) if ( m_bWaitSaveCompleted )
{ {
if ( nEntryConnectionMode == embed::EntryInitModes::NO_INIT ) if ( nEntryConnectionMode != embed::EntryInitModes::NO_INIT )
saveCompleted( m_xParentStorage != xStorage || m_aEntryName != sEntName );
else
throw embed::WrongStateException( throw embed::WrongStateException(
"The object waits for saveCompleted() call!", "The object waits for saveCompleted() call!",
static_cast< ::cppu::OWeakObject* >(this) ); static_cast< ::cppu::OWeakObject* >(this) );
saveCompleted( m_xParentStorage != xStorage || m_aEntryName != sEntName );
} }
uno::Reference< container::XNameAccess > xNameAccess( xStorage, uno::UNO_QUERY_THROW ); uno::Reference< container::XNameAccess > xNameAccess( xStorage, uno::UNO_QUERY_THROW );

View File

@ -127,13 +127,11 @@ public:
const css::uno::Any& aElement ) override const css::uno::Any& aElement ) override
{ {
T aItem; T aItem;
if( aElement >>= aItem ) if( !(aElement >>= aItem) )
if( hasByName( rName ) )
replace( rName, aItem );
else
throw css::container::NoSuchElementException();
else
throw css::lang::IllegalArgumentException(); throw css::lang::IllegalArgumentException();
if( !hasByName( rName ) )
throw css::container::NoSuchElementException();
replace( rName, aItem );
} }
@ -145,22 +143,19 @@ public:
const css::uno::Any& aElement ) override const css::uno::Any& aElement ) override
{ {
T aItem; T aItem;
if( aElement >>= aItem ) if( !(aElement >>= aItem) )
if( ! hasByName( rName ) )
insert( rName, aItem );
else
throw css::container::ElementExistException();
else
throw css::lang::IllegalArgumentException(); throw css::lang::IllegalArgumentException();
if( hasByName( rName ) )
throw css::container::ElementExistException();
insert( rName, aItem );
} }
virtual void SAL_CALL removeByName( virtual void SAL_CALL removeByName(
const OUString& rName ) override const OUString& rName ) override
{ {
if( hasByName( rName ) ) if( !hasByName( rName ) )
remove( rName );
else
throw css::container::NoSuchElementException(); throw css::container::NoSuchElementException();
remove( rName );
} }
}; };

View File

@ -1028,21 +1028,19 @@ void Binding::setValue( const css::uno::Any& aValue )
if( ! supportsType( aValue.getValueType() ) ) if( ! supportsType( aValue.getValueType() ) )
throw IncompatibleTypesException( EXCEPT( "type unsupported" ) ); throw IncompatibleTypesException( EXCEPT( "type unsupported" ) );
if( maBindingExpression.hasValue() ) if( !maBindingExpression.hasValue() )
{ throw InvalidBindingStateException( EXCEPT( "no suitable node found" ) );
css::uno::Reference<css::xml::dom::XNode> xNode = maBindingExpression.getNode(); css::uno::Reference<css::xml::dom::XNode> xNode = maBindingExpression.getNode();
if( xNode.is() ) if( !xNode.is() )
{ throw InvalidBindingStateException( EXCEPT( "no suitable node found" ) );
OUString sValue = Convert::get().toXSD( aValue ); OUString sValue = Convert::get().toXSD( aValue );
bool bSuccess = getModelImpl()->setSimpleContent( xNode, sValue ); bool bSuccess = getModelImpl()->setSimpleContent( xNode, sValue );
if( ! bSuccess ) if( ! bSuccess )
throw InvalidBindingStateException( EXCEPT( "can't set value" ) ); throw InvalidBindingStateException( EXCEPT( "can't set value" ) );
}
else
throw InvalidBindingStateException( EXCEPT( "no suitable node found" ) );
}
else
throw InvalidBindingStateException( EXCEPT( "no suitable node found" ) );
} }

View File

@ -162,10 +162,9 @@ public:
virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) override virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) override
{ {
if( isValidIndex( nIndex ) ) if( !isValidIndex( nIndex ) )
return css::uno::makeAny( getItem( nIndex ) );
else
throw css::lang::IndexOutOfBoundsException(); throw css::lang::IndexOutOfBoundsException();
return css::uno::makeAny( getItem( nIndex ) );
} }
// XIndexReplace : XIndexAccess // XIndexReplace : XIndexAccess
@ -173,13 +172,11 @@ public:
const css::uno::Any& aElement ) override const css::uno::Any& aElement ) override
{ {
T t; T t;
if( isValidIndex( nIndex) ) if( !isValidIndex( nIndex) )
if( ( aElement >>= t ) && isValid( t ) )
setItem( nIndex, t );
else
throw css::lang::IllegalArgumentException();
else
throw css::lang::IndexOutOfBoundsException(); throw css::lang::IndexOutOfBoundsException();
if( !( aElement >>= t ) || !isValid( t ) )
throw css::lang::IllegalArgumentException();
setItem( nIndex, t );
} }
// XEnumerationAccess : XElementAccess // XEnumerationAccess : XElementAccess
@ -199,25 +196,21 @@ public:
virtual void SAL_CALL insert( const css::uno::Any& aElement ) override virtual void SAL_CALL insert( const css::uno::Any& aElement ) override
{ {
T t; T t;
if( ( aElement >>= t ) && isValid( t ) ) if( !( aElement >>= t ) || !isValid( t ) )
if( ! hasItem( t ) )
addItem( t );
else
throw css::container::ElementExistException();
else
throw css::lang::IllegalArgumentException(); throw css::lang::IllegalArgumentException();
if( hasItem( t ) )
throw css::container::ElementExistException();
addItem( t );
} }
virtual void SAL_CALL remove( const css::uno::Any& aElement ) override virtual void SAL_CALL remove( const css::uno::Any& aElement ) override
{ {
T t; T t;
if( aElement >>= t ) if( !(aElement >>= t) )
if( hasItem( t ) )
removeItem( t );
else
throw css::container::NoSuchElementException();
else
throw css::lang::IllegalArgumentException(); throw css::lang::IllegalArgumentException();
if( !hasItem( t ) )
throw css::container::NoSuchElementException();
removeItem( t );
} }

View File

@ -98,11 +98,9 @@ public:
virtual css::uno::Any SAL_CALL getByName( virtual css::uno::Any SAL_CALL getByName(
const OUString& aName ) override const OUString& aName ) override
{ {
if( hasItem( aName ) ) if( !hasItem( aName ) )
return css::uno::makeAny( getItem( aName ) );
else
throw css::container::NoSuchElementException(); throw css::container::NoSuchElementException();
return css::uno::makeAny( getItem( aName ) );
} }
virtual css::uno::Sequence<OUString> SAL_CALL getElementNames() override virtual css::uno::Sequence<OUString> SAL_CALL getElementNames() override

View File

@ -79,12 +79,18 @@ void SAL_CALL PropertySetContainer::insertByIndex( sal_Int32 Index, const css::u
sal_Int32 nSize = m_aPropertySetVector.size(); sal_Int32 nSize = m_aPropertySetVector.size();
if ( nSize >= Index ) if ( nSize < Index )
{ throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
Reference< XPropertySet > aPropertySetElement; Reference< XPropertySet > aPropertySetElement;
if ( Element >>= aPropertySetElement ) if ( !(Element >>= aPropertySetElement) )
{ {
throw IllegalArgumentException(
WRONG_TYPE_EXCEPTION,
static_cast<OWeakObject *>(this), 2 );
}
if ( nSize == Index ) if ( nSize == Index )
m_aPropertySetVector.push_back( aPropertySetElement ); m_aPropertySetVector.push_back( aPropertySetElement );
else else
@ -93,50 +99,34 @@ void SAL_CALL PropertySetContainer::insertByIndex( sal_Int32 Index, const css::u
aIter += Index; aIter += Index;
m_aPropertySetVector.insert( aIter, aPropertySetElement ); m_aPropertySetVector.insert( aIter, aPropertySetElement );
} }
}
else
{
throw IllegalArgumentException(
WRONG_TYPE_EXCEPTION,
static_cast<OWeakObject *>(this), 2 );
}
}
else
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
} }
void SAL_CALL PropertySetContainer::removeByIndex( sal_Int32 nIndex ) void SAL_CALL PropertySetContainer::removeByIndex( sal_Int32 nIndex )
{ {
SolarMutexGuard g; SolarMutexGuard g;
if ( (sal_Int32)m_aPropertySetVector.size() > nIndex ) if ( !((sal_Int32)m_aPropertySetVector.size() > nIndex) )
{
m_aPropertySetVector.erase(m_aPropertySetVector.begin() + nIndex);
}
else
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
m_aPropertySetVector.erase(m_aPropertySetVector.begin() + nIndex);
} }
// XIndexReplace // XIndexReplace
void SAL_CALL PropertySetContainer::replaceByIndex( sal_Int32 Index, const css::uno::Any& Element ) void SAL_CALL PropertySetContainer::replaceByIndex( sal_Int32 Index, const css::uno::Any& Element )
{ {
if ( (sal_Int32)m_aPropertySetVector.size() > Index ) if ( !((sal_Int32)m_aPropertySetVector.size() > Index) )
{ throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
Reference< XPropertySet > aPropertySetElement; Reference< XPropertySet > aPropertySetElement;
if ( Element >>= aPropertySetElement ) if ( !(Element >>= aPropertySetElement) )
{
m_aPropertySetVector[ Index ] = aPropertySetElement;
}
else
{ {
throw IllegalArgumentException( throw IllegalArgumentException(
WRONG_TYPE_EXCEPTION, WRONG_TYPE_EXCEPTION,
static_cast<OWeakObject *>(this), 2 ); static_cast<OWeakObject *>(this), 2 );
} }
}
else m_aPropertySetVector[ Index ] = aPropertySetElement;
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
} }
// XIndexAccess // XIndexAccess
@ -151,15 +141,10 @@ Any SAL_CALL PropertySetContainer::getByIndex( sal_Int32 Index )
{ {
SolarMutexGuard g; SolarMutexGuard g;
if ( (sal_Int32)m_aPropertySetVector.size() > Index ) if ( (sal_Int32)m_aPropertySetVector.size() <= Index )
{
Any a;
a <<= m_aPropertySetVector[ Index ];
return a;
}
else
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
return Any(m_aPropertySetVector[ Index ]);
} }
// XElementAccess // XElementAccess

View File

@ -166,18 +166,20 @@ sal_Int32 SAL_CALL ItemContainer::getCount()
Any SAL_CALL ItemContainer::getByIndex( sal_Int32 Index ) Any SAL_CALL ItemContainer::getByIndex( sal_Int32 Index )
{ {
ShareGuard aLock( m_aShareMutex ); ShareGuard aLock( m_aShareMutex );
if ( sal_Int32( m_aItemVector.size()) > Index ) if ( sal_Int32( m_aItemVector.size()) <= Index )
return makeAny( m_aItemVector[Index] );
else
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
return makeAny( m_aItemVector[Index] );
} }
// XIndexContainer // XIndexContainer
void SAL_CALL ItemContainer::insertByIndex( sal_Int32 Index, const Any& aItem ) void SAL_CALL ItemContainer::insertByIndex( sal_Int32 Index, const Any& aItem )
{ {
Sequence< PropertyValue > aSeq; Sequence< PropertyValue > aSeq;
if ( aItem >>= aSeq ) if ( !(aItem >>= aSeq) )
{ throw IllegalArgumentException( WRONG_TYPE_EXCEPTION,
static_cast<OWeakObject *>(this), 2 );
ShareGuard aLock( m_aShareMutex ); ShareGuard aLock( m_aShareMutex );
if ( sal_Int32( m_aItemVector.size()) == Index ) if ( sal_Int32( m_aItemVector.size()) == Index )
m_aItemVector.push_back( aSeq ); m_aItemVector.push_back( aSeq );
@ -189,37 +191,29 @@ void SAL_CALL ItemContainer::insertByIndex( sal_Int32 Index, const Any& aItem )
} }
else else
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
}
else
throw IllegalArgumentException( WRONG_TYPE_EXCEPTION,
static_cast<OWeakObject *>(this), 2 );
} }
void SAL_CALL ItemContainer::removeByIndex( sal_Int32 nIndex ) void SAL_CALL ItemContainer::removeByIndex( sal_Int32 nIndex )
{ {
ShareGuard aLock( m_aShareMutex ); ShareGuard aLock( m_aShareMutex );
if ( (sal_Int32)m_aItemVector.size() > nIndex ) if ( (sal_Int32)m_aItemVector.size() <= nIndex )
{
m_aItemVector.erase(m_aItemVector.begin() + nIndex);
}
else
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
m_aItemVector.erase(m_aItemVector.begin() + nIndex);
} }
void SAL_CALL ItemContainer::replaceByIndex( sal_Int32 Index, const Any& aItem ) void SAL_CALL ItemContainer::replaceByIndex( sal_Int32 Index, const Any& aItem )
{ {
Sequence< PropertyValue > aSeq; Sequence< PropertyValue > aSeq;
if ( aItem >>= aSeq ) if ( !(aItem >>= aSeq) )
{
ShareGuard aLock( m_aShareMutex );
if ( sal_Int32( m_aItemVector.size()) > Index )
m_aItemVector[Index] = aSeq;
else
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
}
else
throw IllegalArgumentException( WRONG_TYPE_EXCEPTION, throw IllegalArgumentException( WRONG_TYPE_EXCEPTION,
static_cast<OWeakObject *>(this), 2 ); static_cast<OWeakObject *>(this), 2 );
ShareGuard aLock( m_aShareMutex );
if ( !(sal_Int32( m_aItemVector.size()) > Index) )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
m_aItemVector[Index] = aSeq;
} }
} // namespace framework } // namespace framework

View File

@ -182,18 +182,19 @@ sal_Int32 SAL_CALL RootItemContainer::getCount()
Any SAL_CALL RootItemContainer::getByIndex( sal_Int32 Index ) Any SAL_CALL RootItemContainer::getByIndex( sal_Int32 Index )
{ {
ShareGuard aLock( m_aShareMutex ); ShareGuard aLock( m_aShareMutex );
if ( sal_Int32( m_aItemVector.size()) > Index ) if ( sal_Int32( m_aItemVector.size()) <= Index )
return makeAny( m_aItemVector[Index] );
else
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
return makeAny( m_aItemVector[Index] );
} }
// XIndexContainer // XIndexContainer
void SAL_CALL RootItemContainer::insertByIndex( sal_Int32 Index, const Any& aItem ) void SAL_CALL RootItemContainer::insertByIndex( sal_Int32 Index, const Any& aItem )
{ {
Sequence< PropertyValue > aSeq; Sequence< PropertyValue > aSeq;
if ( aItem >>= aSeq ) if ( !(aItem >>= aSeq) )
{ throw IllegalArgumentException( WRONG_TYPE_EXCEPTION, static_cast<OWeakObject *>(this), 2 );
ShareGuard aLock( m_aShareMutex ); ShareGuard aLock( m_aShareMutex );
if ( sal_Int32( m_aItemVector.size()) == Index ) if ( sal_Int32( m_aItemVector.size()) == Index )
m_aItemVector.push_back( aSeq ); m_aItemVector.push_back( aSeq );
@ -205,35 +206,28 @@ void SAL_CALL RootItemContainer::insertByIndex( sal_Int32 Index, const Any& aIte
} }
else else
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
}
else
throw IllegalArgumentException( WRONG_TYPE_EXCEPTION, static_cast<OWeakObject *>(this), 2 );
} }
void SAL_CALL RootItemContainer::removeByIndex( sal_Int32 nIndex ) void SAL_CALL RootItemContainer::removeByIndex( sal_Int32 nIndex )
{ {
ShareGuard aLock( m_aShareMutex ); ShareGuard aLock( m_aShareMutex );
if ( (sal_Int32)m_aItemVector.size() > nIndex ) if ( (sal_Int32)m_aItemVector.size() <= nIndex )
{
m_aItemVector.erase(m_aItemVector.begin() + nIndex);
}
else
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
m_aItemVector.erase(m_aItemVector.begin() + nIndex);
} }
void SAL_CALL RootItemContainer::replaceByIndex( sal_Int32 Index, const Any& aItem ) void SAL_CALL RootItemContainer::replaceByIndex( sal_Int32 Index, const Any& aItem )
{ {
Sequence< PropertyValue > aSeq; Sequence< PropertyValue > aSeq;
if ( aItem >>= aSeq ) if ( !(aItem >>= aSeq) )
{
ShareGuard aLock( m_aShareMutex );
if ( sal_Int32( m_aItemVector.size()) > Index )
m_aItemVector[Index] = aSeq;
else
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
}
else
throw IllegalArgumentException( WRONG_TYPE_EXCEPTION, static_cast<OWeakObject *>(this), 2 ); throw IllegalArgumentException( WRONG_TYPE_EXCEPTION, static_cast<OWeakObject *>(this), 2 );
ShareGuard aLock( m_aShareMutex );
if ( !(sal_Int32( m_aItemVector.size()) > Index) )
throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) );
m_aItemVector[Index] = aSeq;
} }
Reference< XInterface > SAL_CALL RootItemContainer::createInstanceWithContext( const Reference< XComponentContext >& ) Reference< XInterface > SAL_CALL RootItemContainer::createInstanceWithContext( const Reference< XComponentContext >& )

View File

@ -359,8 +359,9 @@ void SAL_CALL ConfigurationAccess_WindowState::insertByName( const OUString& rRe
osl::ResettableMutexGuard g(m_aMutex); osl::ResettableMutexGuard g(m_aMutex);
Sequence< PropertyValue > aPropSet; Sequence< PropertyValue > aPropSet;
if ( aPropertySet >>= aPropSet ) if ( !(aPropertySet >>= aPropSet) )
{ throw IllegalArgumentException();
ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL ); ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
if ( pIter != m_aResourceURLToInfoCache.end() ) if ( pIter != m_aResourceURLToInfoCache.end() )
throw ElementExistException(); throw ElementExistException();
@ -411,9 +412,7 @@ void SAL_CALL ConfigurationAccess_WindowState::insertByName( const OUString& rRe
} }
} }
} }
}
else
throw IllegalArgumentException();
} }
// XNameReplace // XNameReplace
@ -423,8 +422,9 @@ void SAL_CALL ConfigurationAccess_WindowState::replaceByName( const OUString& rR
osl::ResettableMutexGuard g(m_aMutex); osl::ResettableMutexGuard g(m_aMutex);
Sequence< PropertyValue > aPropSet; Sequence< PropertyValue > aPropSet;
if ( aPropertySet >>= aPropSet ) if ( !(aPropertySet >>= aPropSet) )
{ throw IllegalArgumentException();
ResourceURLToInfoCache::iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL ); ResourceURLToInfoCache::iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
if ( pIter != m_aResourceURLToInfoCache.end() ) if ( pIter != m_aResourceURLToInfoCache.end() )
{ {
@ -444,15 +444,14 @@ void SAL_CALL ConfigurationAccess_WindowState::replaceByName( const OUString& rR
Reference< XNameAccess > xNameAccess; Reference< XNameAccess > xNameAccess;
Any a( m_xConfigAccess->getByName( rResourceURL )); Any a( m_xConfigAccess->getByName( rResourceURL ));
if ( a >>= xNameAccess ) if ( !(a >>= xNameAccess) )
{ throw NoSuchElementException();
WindowStateInfo& rWinStateInfo( impl_insertCacheAndReturnWinState( rResourceURL, xNameAccess )); WindowStateInfo& rWinStateInfo( impl_insertCacheAndReturnWinState( rResourceURL, xNameAccess ));
impl_fillStructFromSequence( rWinStateInfo, aPropSet ); impl_fillStructFromSequence( rWinStateInfo, aPropSet );
m_bModified = true; m_bModified = true;
pIter = m_aResourceURLToInfoCache.find( rResourceURL ); pIter = m_aResourceURLToInfoCache.find( rResourceURL );
}
else
throw NoSuchElementException();
} }
if ( m_bModified && pIter != m_aResourceURLToInfoCache.end() ) if ( m_bModified && pIter != m_aResourceURLToInfoCache.end() )
@ -482,9 +481,7 @@ void SAL_CALL ConfigurationAccess_WindowState::replaceByName( const OUString& rR
} }
} }
} }
}
else
throw IllegalArgumentException();
} }
// container.XContainerListener // container.XContainerListener

View File

@ -277,14 +277,12 @@ Any SAL_CALL MenuBarWrapper::getByName(
fillPopupControllerCache(); fillPopupControllerCache();
PopupControllerCache::const_iterator pIter = m_aPopupControllerCache.find( aName ); PopupControllerCache::const_iterator pIter = m_aPopupControllerCache.find( aName );
if ( pIter != m_aPopupControllerCache.end() ) if ( pIter == m_aPopupControllerCache.end() )
{ throw container::NoSuchElementException();
uno::Reference< frame::XDispatchProvider > xDispatchProvider; uno::Reference< frame::XDispatchProvider > xDispatchProvider;
xDispatchProvider = pIter->second.m_xDispatchProvider; xDispatchProvider = pIter->second.m_xDispatchProvider;
return uno::makeAny( xDispatchProvider ); return uno::makeAny( xDispatchProvider );
}
else
throw container::NoSuchElementException();
} }
Sequence< OUString > SAL_CALL MenuBarWrapper::getElementNames() Sequence< OUString > SAL_CALL MenuBarWrapper::getElementNames()

View File

@ -69,8 +69,9 @@ void SAL_CALL StatusBarWrapper::dispose()
m_aListenerContainer.disposeAndClear( aEvent ); m_aListenerContainer.disposeAndClear( aEvent );
SolarMutexGuard g; SolarMutexGuard g;
if ( !m_bDisposed ) if ( m_bDisposed )
{ throw DisposedException();
if ( m_xStatusBarManager.is() ) if ( m_xStatusBarManager.is() )
m_xStatusBarManager->dispose(); m_xStatusBarManager->dispose();
m_xStatusBarManager.clear(); m_xStatusBarManager.clear();
@ -79,9 +80,7 @@ void SAL_CALL StatusBarWrapper::dispose()
m_xContext.clear(); m_xContext.clear();
m_bDisposed = true; m_bDisposed = true;
}
else
throw DisposedException();
} }
// XInitialization // XInitialization

View File

@ -187,15 +187,15 @@ void Index::makeIndexKeys(const lang::Locale &rLocale, const OUString &algorithm
continue; continue;
switch(curr) { switch(curr) {
case u'-': case u'-': {
if (key_count > 0 && i + 1 < len ) { if (key_count <= 0 || i + 1 >= len)
throw RuntimeException();
for (curr = keyStr[++i]; key_count < MAX_KEYS && keys[key_count-1].key < curr; key_count++) { for (curr = keyStr[++i]; key_count < MAX_KEYS && keys[key_count-1].key < curr; key_count++) {
keys[key_count].key = keys[key_count-1].key+1; keys[key_count].key = keys[key_count-1].key+1;
keys[key_count].desc.clear(); keys[key_count].desc.clear();
} }
} else
throw RuntimeException();
break; break;
}
case u'[': case u'[':
for (i++; i < len && keyStr[i] != ']'; i++) { for (i++; i < len && keyStr[i] != ']'; i++) {
if (unicode::isWhiteSpace(keyStr[i])) { if (unicode::isWhiteSpace(keyStr[i])) {
@ -212,8 +212,10 @@ void Index::makeIndexKeys(const lang::Locale &rLocale, const OUString &algorithm
case u'{': case u'{':
close = '}'; close = '}';
SAL_FALLTHROUGH; SAL_FALLTHROUGH;
case u'(': case u'(': {
if (key_count > 0) { if (key_count <= 0)
throw RuntimeException();
sal_Int16 end = i+1; sal_Int16 end = i+1;
for (; end < len && keyStr[end] != close; end++) ; for (; end < len && keyStr[end] != close; end++) ;
@ -228,9 +230,8 @@ void Index::makeIndexKeys(const lang::Locale &rLocale, const OUString &algorithm
keys[key_count++].desc.clear(); keys[key_count++].desc.clear();
} }
i=end+1; i=end+1;
} else
throw RuntimeException();
break; break;
}
default: default:
keys[key_count].key = curr; keys[key_count].key = curr;
keys[key_count++].desc.clear(); keys[key_count++].desc.clear();

View File

@ -221,8 +221,9 @@ TextConversion_ko::getConversions( const OUString& aText, sal_Int32 nStartPos, s
result.Boundary.startPos = result.Boundary.endPos = 0; result.Boundary.startPos = result.Boundary.endPos = 0;
// do conversion only when there are right conversion type and dictionary services. // do conversion only when there are right conversion type and dictionary services.
if (nConversionType == TextConversionType::TO_HANGUL || if (nConversionType != TextConversionType::TO_HANGUL &&
nConversionType == TextConversionType::TO_HANJA) { nConversionType != TextConversionType::TO_HANJA)
throw NoSupportException(); // Conversion type is not supported in this service.
sal_Int32 start, end, length = aText.getLength() - nStartPos; sal_Int32 start, end, length = aText.getLength() - nStartPos;
if (length < 0 || nStartPos < 0) if (length < 0 || nStartPos < 0)
@ -296,8 +297,7 @@ TextConversion_ko::getConversions( const OUString& aText, sal_Int32 nStartPos, s
return result; return result;
} }
} }
} else
throw NoSupportException(); // Conversion type is not supported in this service.
return result; return result;
} }

View File

@ -283,7 +283,8 @@ OUString SAL_CALL
TextConversion_zh::getConversion( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, TextConversion_zh::getConversion( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
const Locale& rLocale, sal_Int16 nConversionType, sal_Int32 nConversionOptions) const Locale& rLocale, sal_Int16 nConversionType, sal_Int32 nConversionOptions)
{ {
if (rLocale.Language == "zh" && ( nConversionType == TextConversionType::TO_SCHINESE || nConversionType == TextConversionType::TO_TCHINESE) ) { if (rLocale.Language != "zh" || ( nConversionType != TextConversionType::TO_SCHINESE && nConversionType != TextConversionType::TO_TCHINESE) )
throw NoSupportException(); // Conversion type is not supported in this service.
aLocale=rLocale; aLocale=rLocale;
bool toSChinese = nConversionType == TextConversionType::TO_SCHINESE; bool toSChinese = nConversionType == TextConversionType::TO_SCHINESE;
@ -296,15 +297,14 @@ TextConversion_zh::getConversion( const OUString& aText, sal_Int32 nStartPos, sa
// word to word dictionary // word to word dictionary
return getWordConversion(aText, nStartPos, nLength, toSChinese, nConversionOptions, offset); return getWordConversion(aText, nStartPos, nLength, toSChinese, nConversionOptions, offset);
} }
} else
throw NoSupportException(); // Conversion type is not supported in this service.
} }
OUString SAL_CALL OUString SAL_CALL
TextConversion_zh::getConversionWithOffset( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, TextConversion_zh::getConversionWithOffset( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
const Locale& rLocale, sal_Int16 nConversionType, sal_Int32 nConversionOptions, Sequence<sal_Int32>& offset) const Locale& rLocale, sal_Int16 nConversionType, sal_Int32 nConversionOptions, Sequence<sal_Int32>& offset)
{ {
if (rLocale.Language == "zh" && ( nConversionType == TextConversionType::TO_SCHINESE || nConversionType == TextConversionType::TO_TCHINESE) ) { if (rLocale.Language != "zh" || ( nConversionType != TextConversionType::TO_SCHINESE && nConversionType != TextConversionType::TO_TCHINESE) )
throw NoSupportException(); // Conversion type is not supported in this service.
aLocale=rLocale; aLocale=rLocale;
bool toSChinese = nConversionType == TextConversionType::TO_SCHINESE; bool toSChinese = nConversionType == TextConversionType::TO_SCHINESE;
@ -319,8 +319,6 @@ TextConversion_zh::getConversionWithOffset( const OUString& aText, sal_Int32 nSt
// word to word dictionary // word to word dictionary
return getWordConversion(aText, nStartPos, nLength, toSChinese, nConversionOptions, offset); return getWordConversion(aText, nStartPos, nLength, toSChinese, nConversionOptions, offset);
} }
} else
throw NoSupportException(); // Conversion type is not supported in this service.
} }
sal_Bool SAL_CALL sal_Bool SAL_CALL

View File

@ -361,8 +361,13 @@ namespace dlgprov
// get input stream provider // get input stream provider
Reference< io::XInputStreamProvider > xISP; Reference< io::XInputStreamProvider > xISP;
if ( xLibContainer.is() ) if ( !xLibContainer.is() )
{ {
throw IllegalArgumentException(
"DialogProviderImpl::getDialog: library container not found!",
Reference< XInterface >(), 1 );
}
// load dialog library // load dialog library
if ( !xLibContainer->isLibraryLoaded( sLibName ) ) if ( !xLibContainer->isLibraryLoaded( sLibName ) )
xLibContainer->loadLibrary( sLibName ); xLibContainer->loadLibrary( sLibName );
@ -374,8 +379,13 @@ namespace dlgprov
aElement >>= xDialogLib; aElement >>= xDialogLib;
} }
if ( xDialogLib.is() ) if ( !xDialogLib.is() )
{ {
throw IllegalArgumentException(
"DialogProviderImpl::getDialogModel: library not found!",
Reference< XInterface >(), 1 );
}
// get input stream provider // get input stream provider
if ( xDialogLib->hasByName( sDlgName ) ) if ( xDialogLib->hasByName( sDlgName ) )
{ {
@ -389,20 +399,8 @@ namespace dlgprov
"DialogProviderImpl::getDialogModel: dialog not found!", "DialogProviderImpl::getDialogModel: dialog not found!",
Reference< XInterface >(), 1 ); Reference< XInterface >(), 1 );
} }
}
else
{
throw IllegalArgumentException(
"DialogProviderImpl::getDialogModel: library not found!",
Reference< XInterface >(), 1 );
}
}
else
{
throw IllegalArgumentException(
"DialogProviderImpl::getDialog: library container not found!",
Reference< XInterface >(), 1 );
}
if ( xISP.is() ) if ( xISP.is() )
xInput = xISP->createInputStream(); xInput = xISP->createInputStream();

View File

@ -117,20 +117,19 @@ void SAL_CALL PresenterTextView::initialize (const Sequence<Any>& rArguments)
{ {
ThrowIfDisposed(); ThrowIfDisposed();
if (rArguments.getLength() == 1) if (!(rArguments.getLength() == 1))
{ {
throw RuntimeException("PresenterTextView: invalid number of arguments",
static_cast<XWeak*>(this));
}
Reference<rendering::XCanvas> xCanvas (rArguments[0], UNO_QUERY_THROW); Reference<rendering::XCanvas> xCanvas (rArguments[0], UNO_QUERY_THROW);
if (xCanvas.is()) if (xCanvas.is())
{ {
mpImplementation->SetCanvas( mpImplementation->SetCanvas(
cppcanvas::VCLFactory::createCanvas(xCanvas)); cppcanvas::VCLFactory::createCanvas(xCanvas));
} }
}
else
{
throw RuntimeException("PresenterTextView: invalid number of arguments",
static_cast<XWeak*>(this));
}
} }
Any PresenterTextView::GetPropertyValue (const OUString& rsPropertyName) Any PresenterTextView::GetPropertyValue (const OUString& rsPropertyName)

View File

@ -511,7 +511,11 @@ readStream(struct DocumentMetadataAccess_Impl & i_rImpl,
try { try {
if (!splitPath(i_rPath, dir, rest)) throw uno::RuntimeException(); if (!splitPath(i_rPath, dir, rest)) throw uno::RuntimeException();
if (dir.isEmpty()) { if (dir.isEmpty()) {
if (i_xStorage->isStreamElement(i_rPath)) { if (!i_xStorage->isStreamElement(i_rPath)) {
throw mkException(
"readStream: is not a stream",
ucb::IOErrorCode_NO_FILE, i_rBaseURI + i_rPath, i_rPath);
}
const uno::Reference<io::XStream> xStream( const uno::Reference<io::XStream> xStream(
i_xStorage->openStreamElement(i_rPath, i_xStorage->openStreamElement(i_rPath,
embed::ElementModes::READ), uno::UNO_SET_THROW); embed::ElementModes::READ), uno::UNO_SET_THROW);
@ -525,12 +529,11 @@ readStream(struct DocumentMetadataAccess_Impl & i_rImpl,
i_rImpl.m_xRepository->importGraph(rdf::FileFormat::RDF_XML, i_rImpl.m_xRepository->importGraph(rdf::FileFormat::RDF_XML,
xInStream, xURI, xBaseURI); xInStream, xURI, xBaseURI);
} else { } else {
if (!i_xStorage->isStorageElement(dir)) {
throw mkException( throw mkException(
"readStream: is not a stream", "readStream: is not a directory",
ucb::IOErrorCode_NO_FILE, i_rBaseURI + i_rPath, i_rPath); ucb::IOErrorCode_NO_DIRECTORY, i_rBaseURI + dir, dir);
} }
} else {
if (i_xStorage->isStorageElement(dir)) {
const uno::Reference<embed::XStorage> xDir( const uno::Reference<embed::XStorage> xDir(
i_xStorage->openStorageElement(dir, i_xStorage->openStorageElement(dir,
embed::ElementModes::READ)); embed::ElementModes::READ));
@ -547,11 +550,6 @@ readStream(struct DocumentMetadataAccess_Impl & i_rImpl,
} }
} catch (const uno::Exception &) { } } catch (const uno::Exception &) { }
readStream(i_rImpl, xDir, rest, i_rBaseURI+dir+"/" ); readStream(i_rImpl, xDir, rest, i_rBaseURI+dir+"/" );
} else {
throw mkException(
"readStream: is not a directory",
ucb::IOErrorCode_NO_DIRECTORY, i_rBaseURI + dir, dir);
}
} }
} catch (const container::NoSuchElementException & e) { } catch (const container::NoSuchElementException & e) {
throw mkException(e.Message, ucb::IOErrorCode_NOT_EXISTING_PATH, throw mkException(e.Message, ucb::IOErrorCode_NOT_EXISTING_PATH,

View File

@ -1408,13 +1408,23 @@ void ImplementationRegistration::prepareRegister(
// set implLoaderUrl // set implLoaderUrl
} }
if( m_xSMgr.is() ) { if( !m_xSMgr.is() ) {
throw CannotRegisterImplementationException(
"ImplementationRegistration::registerImplementation() "
"no componentcontext available to instantiate loader" );
}
try try
{ {
Reference < XImplementationLoader > xAct( Reference < XImplementationLoader > xAct(
m_xSMgr->createInstanceWithContext(activatorName, m_xCtx) , UNO_QUERY ); m_xSMgr->createInstanceWithContext(activatorName, m_xCtx) , UNO_QUERY );
if (xAct.is()) if (!xAct.is())
{ {
throw CannotRegisterImplementationException(
"ImplementationRegistration::registerImplementation() - The service "
+ activatorName + " cannot be instantiated" );
}
Reference < XSimpleRegistry > xRegistry; Reference < XSimpleRegistry > xRegistry;
if (xReg.is()) if (xReg.is())
@ -1432,13 +1442,7 @@ void ImplementationRegistration::prepareRegister(
doRegister(m_xSMgr, m_xCtx, xAct, xRegistry, implementationLoaderUrl, doRegister(m_xSMgr, m_xCtx, xAct, xRegistry, implementationLoaderUrl,
locationUrl, registeredLocationUrl); locationUrl, registeredLocationUrl);
} }
}
else
{
throw CannotRegisterImplementationException(
"ImplementationRegistration::registerImplementation() - The service "
+ activatorName + " cannot be instantiated" );
}
} }
catch( CannotRegisterImplementationException & ) catch( CannotRegisterImplementationException & )
{ {
@ -1456,13 +1460,7 @@ void ImplementationRegistration::prepareRegister(
"ImplementationRegistration::registerImplementation() " "ImplementationRegistration::registerImplementation() "
"MergeConflictException during registration (" + e.Message + ")" ); "MergeConflictException during registration (" + e.Message + ")" );
} }
}
else
{
throw CannotRegisterImplementationException(
"ImplementationRegistration::registerImplementation() "
"no componentcontext available to instantiate loader" );
}
} }
@ -1677,8 +1675,12 @@ void ImplementationRegistration::doRegister(
bool bSuccess = bool bSuccess =
xAct->writeRegistryInfo(xSourceKey, implementationLoaderUrl, locationUrl); xAct->writeRegistryInfo(xSourceKey, implementationLoaderUrl, locationUrl);
if ( bSuccess ) if ( !bSuccess )
{ {
throw CannotRegisterImplementationException(
"ImplementationRegistration::doRegistration() component registration signaled failure" );
}
prepareRegistry(xDest, xSourceKey, implementationLoaderUrl, registeredLocationUrl, xCtx); prepareRegistry(xDest, xSourceKey, implementationLoaderUrl, registeredLocationUrl, xCtx);
xSourceKey->closeKey(); xSourceKey->closeKey();
@ -1688,12 +1690,7 @@ void ImplementationRegistration::doRegister(
stoc_impreg::mergeKeys( xDestKey, xSourceKey ); stoc_impreg::mergeKeys( xDestKey, xSourceKey );
xDestKey->closeKey(); xDestKey->closeKey();
xSourceKey->closeKey(); xSourceKey->closeKey();
}
else
{
throw CannotRegisterImplementationException(
"ImplementationRegistration::doRegistration() component registration signaled failure" );
}
// Cleanup Source registry. // Cleanup Source registry.
if ( xSourceKey->isValid() ) if ( xSourceKey->isValid() )

View File

@ -558,17 +558,16 @@ void SAL_CALL OServiceManagerWrapper::setPropertyValue(
if ( PropertyName == "DefaultContext" ) if ( PropertyName == "DefaultContext" )
{ {
Reference< XComponentContext > xContext; Reference< XComponentContext > xContext;
if (aValue >>= xContext) if (!(aValue >>= xContext))
{
MutexGuard aGuard( m_mutex );
m_xContext = xContext;
}
else
{ {
throw IllegalArgumentException( throw IllegalArgumentException(
"no XComponentContext given!", "no XComponentContext given!",
static_cast<OWeakObject *>(this), 1 ); static_cast<OWeakObject *>(this), 1 );
} }
MutexGuard aGuard( m_mutex );
m_xContext = xContext;
} }
else else
{ {
@ -698,27 +697,23 @@ void OServiceManager::setPropertyValue(
const OUString& PropertyName, const Any& aValue ) const OUString& PropertyName, const Any& aValue )
{ {
check_undisposed(); check_undisposed();
if ( PropertyName == "DefaultContext" ) if ( PropertyName != "DefaultContext" )
{
Reference< XComponentContext > xContext;
if (aValue >>= xContext)
{
MutexGuard aGuard( m_mutex );
m_xContext = xContext;
}
else
{
throw IllegalArgumentException(
"no XComponentContext given!",
static_cast<OWeakObject *>(this), 1 );
}
}
else
{ {
throw UnknownPropertyException( throw UnknownPropertyException(
"unknown property " + PropertyName, "unknown property " + PropertyName,
static_cast<OWeakObject *>(this) ); static_cast<OWeakObject *>(this) );
} }
Reference< XComponentContext > xContext;
if (!(aValue >>= xContext))
{
throw IllegalArgumentException(
"no XComponentContext given!",
static_cast<OWeakObject *>(this), 1 );
}
MutexGuard aGuard( m_mutex );
m_xContext = xContext;
} }
Any OServiceManager::getPropertyValue(const OUString& PropertyName) Any OServiceManager::getPropertyValue(const OUString& PropertyName)

View File

@ -90,14 +90,7 @@ uno::Any PrivateProfileStringListener::getValueEvent()
{ {
// get the private profile string // get the private profile string
OUString sValue; OUString sValue;
if(!maFileName.isEmpty()) if(maFileName.isEmpty())
{
// get key/value from a file
Config aCfg( maFileName );
aCfg.SetGroup( maGroupName );
sValue = OStringToOUString(aCfg.ReadKey(maKey), RTL_TEXTENCODING_DONTKNOW);
}
else
{ {
// get key/value from Windows registry // get key/value from Windows registry
#ifdef _WIN32 #ifdef _WIN32
@ -129,6 +122,12 @@ uno::Any PrivateProfileStringListener::getValueEvent()
#endif #endif
} }
// get key/value from a file
Config aCfg( maFileName );
aCfg.SetGroup( maGroupName );
sValue = OStringToOUString(aCfg.ReadKey(maKey), RTL_TEXTENCODING_DONTKNOW);
return uno::makeAny( sValue ); return uno::makeAny( sValue );
} }
@ -137,14 +136,7 @@ void PrivateProfileStringListener::setValueEvent( const css::uno::Any& value )
// set the private profile string // set the private profile string
OUString aValue; OUString aValue;
value >>= aValue; value >>= aValue;
if(!maFileName.isEmpty()) if(maFileName.isEmpty())
{
// set value into a file
Config aCfg( maFileName );
aCfg.SetGroup( maGroupName );
aCfg.WriteKey( maKey, OUStringToOString(aValue, RTL_TEXTENCODING_DONTKNOW) );
}
else
{ {
//set value into Windows registry //set value into Windows registry
#ifdef _WIN32 #ifdef _WIN32
@ -172,6 +164,12 @@ void PrivateProfileStringListener::setValueEvent( const css::uno::Any& value )
#endif #endif
} }
// set value into a file
Config aCfg( maFileName );
aCfg.SetGroup( maGroupName );
aCfg.WriteKey( maKey, OUStringToOString(aValue, RTL_TEXTENCODING_DONTKNOW) );
} }
SwVbaSystem::SwVbaSystem( uno::Reference<uno::XComponentContext > const & xContext ): SwVbaSystem_BASE( uno::Reference< XHelperInterface >(), xContext ) SwVbaSystem::SwVbaSystem( uno::Reference<uno::XComponentContext > const & xContext ): SwVbaSystem_BASE( uno::Reference< XHelperInterface >(), xContext )