summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-22 12:53:28 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-23 09:02:58 +0200
commita8622c77d26ca7a635afc95bba9a5054dc31eb7c (patch)
treeecb1ce71272291515dec10fc5fe94061f7231b78
parent2684aefcf5d2804351bda01a2d2fe7bbbd351451 (diff)
loplugin:flatten in sdext..stoc
Change-Id: I460e813e20a691c53738373376d3363f553bbab2 Reviewed-on: https://gerrit.libreoffice.org/42636 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sdext/source/presenter/PresenterPaneBase.cxx144
-rw-r--r--sdext/source/presenter/PresenterProtocolHandler.cxx54
-rw-r--r--sfx2/source/control/thumbnailviewacc.cxx21
-rw-r--r--sfx2/source/doc/Metadatable.cxx8
-rw-r--r--sfx2/source/doc/SfxDocumentMetaData.cxx26
-rw-r--r--sfx2/source/doc/guisaveas.cxx16
-rw-r--r--sfx2/source/doc/objserv.cxx17
-rw-r--r--sfx2/source/doc/printhelper.cxx19
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx184
-rw-r--r--sfx2/source/sidebar/UnoDecks.cxx12
-rw-r--r--sfx2/source/sidebar/UnoPanels.cxx12
-rw-r--r--shell/source/unix/sysshell/recently_used_file.cxx52
-rw-r--r--starmath/source/unomodel.cxx108
-rw-r--r--stoc/source/corereflection/crcomp.cxx14
-rw-r--r--stoc/source/corereflection/crefl.cxx8
-rw-r--r--stoc/source/corereflection/criface.cxx5
-rw-r--r--stoc/source/defaultregistry/defaultregistry.cxx60
-rw-r--r--stoc/source/inspect/introspection.cxx5
-rw-r--r--stoc/source/javaloader/javaloader.cxx10
-rw-r--r--stoc/source/security/access_controller.cxx16
-rw-r--r--stoc/source/typeconv/convert.cxx31
21 files changed, 368 insertions, 454 deletions
diff --git a/sdext/source/presenter/PresenterPaneBase.cxx b/sdext/source/presenter/PresenterPaneBase.cxx
index 7e034ee30551..c7bfa0b02fa0 100644
--- a/sdext/source/presenter/PresenterPaneBase.cxx
+++ b/sdext/source/presenter/PresenterPaneBase.cxx
@@ -143,86 +143,84 @@ void SAL_CALL PresenterPaneBase::initialize (const Sequence<Any>& rArguments)
static_cast<XWeak*>(this));
}
- if (rArguments.getLength() == 5 || rArguments.getLength() == 6)
+ if (rArguments.getLength() != 5 && rArguments.getLength() != 6)
{
- try
+ throw RuntimeException(
+ "PresenterSpritePane: invalid number of arguments",
+ static_cast<XWeak*>(this));
+ }
+
+ try
+ {
+ // Get the resource id from the first argument.
+ if ( ! (rArguments[0] >>= mxPaneId))
{
- // Get the resource id from the first argument.
- if ( ! (rArguments[0] >>= mxPaneId))
- {
- throw lang::IllegalArgumentException(
- "PresenterPane: invalid pane id",
- static_cast<XWeak*>(this),
- 0);
- }
-
- if ( ! (rArguments[1] >>= mxParentWindow))
- {
- throw lang::IllegalArgumentException(
- "PresenterPane: invalid parent window",
- static_cast<XWeak*>(this),
- 1);
- }
-
- Reference<rendering::XSpriteCanvas> xParentCanvas;
- if ( ! (rArguments[2] >>= xParentCanvas))
- {
- throw lang::IllegalArgumentException(
- "PresenterPane: invalid parent canvas",
- static_cast<XWeak*>(this),
- 2);
- }
-
- if ( ! (rArguments[3] >>= msTitle))
- {
- throw lang::IllegalArgumentException(
- "PresenterPane: invalid title",
- static_cast<XWeak*>(this),
- 3);
- }
-
- if ( ! (rArguments[4] >>= mxBorderPainter))
- {
- throw lang::IllegalArgumentException(
- "PresenterPane: invalid border painter",
- static_cast<XWeak*>(this),
- 4);
- }
-
- bool bIsWindowVisibleOnCreation (true);
- if (rArguments.getLength()>5 && ! (rArguments[5] >>= bIsWindowVisibleOnCreation))
- {
- throw lang::IllegalArgumentException(
- "PresenterPane: invalid window visibility flag",
- static_cast<XWeak*>(this),
- 5);
- }
-
- CreateWindows(mxParentWindow, bIsWindowVisibleOnCreation);
-
- if (mxBorderWindow.is())
- {
- mxBorderWindow->addWindowListener(this);
- mxBorderWindow->addPaintListener(this);
- }
-
- CreateCanvases(mxParentWindow, xParentCanvas);
-
- // Raise new windows.
- ToTop();
+ throw lang::IllegalArgumentException(
+ "PresenterPane: invalid pane id",
+ static_cast<XWeak*>(this),
+ 0);
}
- catch (Exception&)
+
+ if ( ! (rArguments[1] >>= mxParentWindow))
{
- mxContentWindow = nullptr;
- mxComponentContext = nullptr;
- throw;
+ throw lang::IllegalArgumentException(
+ "PresenterPane: invalid parent window",
+ static_cast<XWeak*>(this),
+ 1);
}
+
+ Reference<rendering::XSpriteCanvas> xParentCanvas;
+ if ( ! (rArguments[2] >>= xParentCanvas))
+ {
+ throw lang::IllegalArgumentException(
+ "PresenterPane: invalid parent canvas",
+ static_cast<XWeak*>(this),
+ 2);
+ }
+
+ if ( ! (rArguments[3] >>= msTitle))
+ {
+ throw lang::IllegalArgumentException(
+ "PresenterPane: invalid title",
+ static_cast<XWeak*>(this),
+ 3);
+ }
+
+ if ( ! (rArguments[4] >>= mxBorderPainter))
+ {
+ throw lang::IllegalArgumentException(
+ "PresenterPane: invalid border painter",
+ static_cast<XWeak*>(this),
+ 4);
+ }
+
+ bool bIsWindowVisibleOnCreation (true);
+ if (rArguments.getLength()>5 && ! (rArguments[5] >>= bIsWindowVisibleOnCreation))
+ {
+ throw lang::IllegalArgumentException(
+ "PresenterPane: invalid window visibility flag",
+ static_cast<XWeak*>(this),
+ 5);
+ }
+
+ CreateWindows(mxParentWindow, bIsWindowVisibleOnCreation);
+
+ if (mxBorderWindow.is())
+ {
+ mxBorderWindow->addWindowListener(this);
+ mxBorderWindow->addPaintListener(this);
+ }
+
+ CreateCanvases(mxParentWindow, xParentCanvas);
+
+ // Raise new windows.
+ ToTop();
}
- else
+ catch (Exception&)
{
- throw RuntimeException(
- "PresenterSpritePane: invalid number of arguments",
- static_cast<XWeak*>(this));
+ mxContentWindow = nullptr;
+ mxComponentContext = nullptr;
+ throw;
}
}
diff --git a/sdext/source/presenter/PresenterProtocolHandler.cxx b/sdext/source/presenter/PresenterProtocolHandler.cxx
index f1aceb54f8d1..b7ca0c08a4b2 100644
--- a/sdext/source/presenter/PresenterProtocolHandler.cxx
+++ b/sdext/source/presenter/PresenterProtocolHandler.cxx
@@ -430,54 +430,48 @@ void SAL_CALL PresenterProtocolHandler::Dispatch::dispatch(
static_cast<uno::XWeak*>(this));
}
- if (rURL.Protocol == "vnd.org.libreoffice.presenterscreen:"
- && rURL.Path == msURLPath)
- {
- if (mpCommand.get() != nullptr)
- mpCommand->Execute();
- }
- else
+ if (rURL.Protocol != "vnd.org.libreoffice.presenterscreen:"
+ || rURL.Path != msURLPath)
{
// We can not throw an IllegalArgumentException
throw RuntimeException();
}
+
+ if (mpCommand.get() != nullptr)
+ mpCommand->Execute();
}
void SAL_CALL PresenterProtocolHandler::Dispatch::addStatusListener(
const css::uno::Reference<css::frame::XStatusListener>& rxListener,
const css::util::URL& rURL)
{
- if (rURL.Path == msURLPath)
- {
- maStatusListenerContainer.push_back(rxListener);
-
- frame::FeatureStateEvent aEvent;
- aEvent.FeatureURL = rURL;
- aEvent.IsEnabled = mpCommand->IsEnabled();
- aEvent.Requery = false;
- aEvent.State = mpCommand->GetState();
- rxListener->statusChanged(aEvent);
- }
- else
+ if (rURL.Path != msURLPath)
throw RuntimeException();
+
+ maStatusListenerContainer.push_back(rxListener);
+
+ frame::FeatureStateEvent aEvent;
+ aEvent.FeatureURL = rURL;
+ aEvent.IsEnabled = mpCommand->IsEnabled();
+ aEvent.Requery = false;
+ aEvent.State = mpCommand->GetState();
+ rxListener->statusChanged(aEvent);
}
void SAL_CALL PresenterProtocolHandler::Dispatch::removeStatusListener (
const css::uno::Reference<css::frame::XStatusListener>& rxListener,
const css::util::URL& rURL)
{
- if (rURL.Path == msURLPath)
- {
- StatusListenerContainer::iterator iListener (
- ::std::find(
- maStatusListenerContainer.begin(),
- maStatusListenerContainer.end(),
- rxListener));
- if (iListener != maStatusListenerContainer.end())
- maStatusListenerContainer.erase(iListener);
- }
- else
+ if (rURL.Path != msURLPath)
throw RuntimeException();
+
+ StatusListenerContainer::iterator iListener (
+ ::std::find(
+ maStatusListenerContainer.begin(),
+ maStatusListenerContainer.end(),
+ rxListener));
+ if (iListener != maStatusListenerContainer.end())
+ maStatusListenerContainer.erase(iListener);
}
//----- document::XEventListener ----------------------------------------------
diff --git a/sfx2/source/control/thumbnailviewacc.cxx b/sfx2/source/control/thumbnailviewacc.cxx
index cab703490918..d6f977f4bd74 100644
--- a/sfx2/source/control/thumbnailviewacc.cxx
+++ b/sfx2/source/control/thumbnailviewacc.cxx
@@ -138,14 +138,12 @@ uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewAcc::getAcces
{
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
- uno::Reference< accessibility::XAccessible > xRet;
ThumbnailViewItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(i));
- if( pItem )
- xRet = pItem->GetAccessible( mbIsTransientChildrenDisabled );
- else
+ if( !pItem )
throw lang::IndexOutOfBoundsException();
+ uno::Reference< accessibility::XAccessible > xRet = pItem->GetAccessible( mbIsTransientChildrenDisabled );
return xRet;
}
@@ -414,12 +412,10 @@ void SAL_CALL ThumbnailViewAcc::selectAccessibleChild( sal_Int32 nChildIndex )
const SolarMutexGuard aSolarGuard;
ThumbnailViewItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
- if(pItem != nullptr)
- {
- mpParent->SelectItem( pItem->mnId );
- }
- else
+ if(pItem == nullptr)
throw lang::IndexOutOfBoundsException();
+
+ mpParent->SelectItem( pItem->mnId );
}
sal_Bool SAL_CALL ThumbnailViewAcc::isAccessibleChildSelected( sal_Int32 nChildIndex )
@@ -427,14 +423,11 @@ sal_Bool SAL_CALL ThumbnailViewAcc::isAccessibleChildSelected( sal_Int32 nChildI
ThrowIfDisposed();
const SolarMutexGuard aSolarGuard;
ThumbnailViewItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
- bool bRet = false;
- if (pItem != nullptr)
- bRet = mpParent->IsItemSelected( pItem->mnId );
- else
+ if (pItem == nullptr)
throw lang::IndexOutOfBoundsException();
- return bRet;
+ return mpParent->IsItemSelected( pItem->mnId );
}
void SAL_CALL ThumbnailViewAcc::clearAccessibleSelection()
diff --git a/sfx2/source/doc/Metadatable.cxx b/sfx2/source/doc/Metadatable.cxx
index b7913dc4e349..2879e12e1131 100644
--- a/sfx2/source/doc/Metadatable.cxx
+++ b/sfx2/source/doc/Metadatable.cxx
@@ -1281,15 +1281,13 @@ void Metadatable::SetMetadataReference( const css::beans::StringPair & i_rRefere
IsInContent() ? s_content : s_styles );
}
XmlIdRegistry & rReg( dynamic_cast<XmlIdRegistry&>( GetRegistry() ) );
- if (rReg.TryRegisterMetadatable(*this, streamName, i_rReference.Second))
- {
- m_pReg = &rReg;
- }
- else
+ if (!rReg.TryRegisterMetadatable(*this, streamName, i_rReference.Second))
{
throw lang::IllegalArgumentException(
"Metadatable::SetMetadataReference: argument is invalid", /*this*/nullptr, 0);
}
+
+ m_pReg = &rReg;
}
}
diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx
index ecbdededf266..f3e6c5124024 100644
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -1843,16 +1843,15 @@ SfxDocumentMetaData::storeToStorage(
xExp->setSourceDocument(css::uno::Reference<css::lang::XComponent>(this));
css::uno::Reference<css::document::XFilter> xFilter(xExp,
css::uno::UNO_QUERY_THROW);
- if (xFilter->filter(css::uno::Sequence< css::beans::PropertyValue >())) {
- css::uno::Reference<css::embed::XTransactedObject> xTransaction(
- xStorage, css::uno::UNO_QUERY);
- if (xTransaction.is()) {
- xTransaction->commit();
- }
- } else {
+ if (!xFilter->filter(css::uno::Sequence< css::beans::PropertyValue >())) {
throw css::io::IOException(
"SfxDocumentMetaData::storeToStorage: cannot filter", *this);
}
+ css::uno::Reference<css::embed::XTransactedObject> xTransaction(
+ xStorage, css::uno::UNO_QUERY);
+ if (xTransaction.is()) {
+ xTransaction->commit();
+ }
}
void SAL_CALL
@@ -1955,17 +1954,16 @@ void SAL_CALL SfxDocumentMetaData::initialize( const css::uno::Sequence< css::un
for (sal_Int32 i = 0; i < aArguments.getLength(); ++i) {
const css::uno::Any any = aArguments[i];
- if (any >>= xDoc) {
- if (!xDoc.is()) {
- throw css::lang::IllegalArgumentException(
- "SfxDocumentMetaData::initialize: argument is null",
- *this, static_cast<sal_Int16>(i));
- }
- } else {
+ if (!(any >>= xDoc)) {
throw css::lang::IllegalArgumentException(
"SfxDocumentMetaData::initialize: argument must be XDocument",
*this, static_cast<sal_Int16>(i));
}
+ if (!xDoc.is()) {
+ throw css::lang::IllegalArgumentException(
+ "SfxDocumentMetaData::initialize: argument is null",
+ *this, static_cast<sal_Int16>(i));
+ }
}
if (!xDoc.is()) {
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 75a6c4f9353b..548ccd30d161 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -613,15 +613,7 @@ bool ModelData_Impl::ExecuteFilterDialog_Impl( const OUString& aFilterName )
GetMediaDescr() >> aPropsForDialog;
xFilterProperties->setPropertyValues( aPropsForDialog );
- if( xFilterDialog->execute() )
- {
- uno::Sequence< beans::PropertyValue > aPropsFromDialog =
- xFilterProperties->getPropertyValues();
- const sal_Int32 nPropsLen {aPropsFromDialog.getLength()};
- for ( sal_Int32 nInd = 0; nInd < nPropsLen; ++nInd )
- GetMediaDescr()[aPropsFromDialog[nInd].Name] = aPropsFromDialog[nInd].Value;
- }
- else
+ if( !xFilterDialog->execute() )
{
throw task::ErrorCodeIOException(
("ModelData_Impl::ExecuteFilterDialog_Impl:"
@@ -629,6 +621,12 @@ bool ModelData_Impl::ExecuteFilterDialog_Impl( const OUString& aFilterName )
uno::Reference< uno::XInterface >(),
sal_uInt32(ERRCODE_IO_ABORT));
}
+
+ uno::Sequence< beans::PropertyValue > aPropsFromDialog =
+ xFilterProperties->getPropertyValues();
+ const sal_Int32 nPropsLen {aPropsFromDialog.getLength()};
+ for ( sal_Int32 nInd = 0; nInd < nPropsLen; ++nInd )
+ GetMediaDescr()[aPropsFromDialog[nInd].Name] = aPropsFromDialog[nInd].Value;
}
}
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 0dfd5b80959f..6dc7fc317dc2 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -622,15 +622,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
SfxStoringHelper aHelper;
- if ( QueryHiddenInformation( bIsPDFExport ? HiddenWarningFact::WhenCreatingPDF : HiddenWarningFact::WhenSaving, nullptr ) == RET_YES )
- {
- aHelper.GUIStoreModel( GetModel(),
- OUString::createFromAscii( pSlot->GetUnoName() ),
- aDispatchArgs,
- bPreselectPassword,
- GetDocumentSignatureState() );
- }
- else
+ if ( QueryHiddenInformation( bIsPDFExport ? HiddenWarningFact::WhenCreatingPDF : HiddenWarningFact::WhenSaving, nullptr ) != RET_YES )
{
// the user has decided not to store the document
throw task::ErrorCodeIOException(
@@ -638,6 +630,13 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_IO_ABORT));
}
+ aHelper.GUIStoreModel( GetModel(),
+ OUString::createFromAscii( pSlot->GetUnoName() ),
+ aDispatchArgs,
+ bPreselectPassword,
+ GetDocumentSignatureState() );
+
+
// merge aDispatchArgs to the request
SfxAllItemSet aResultParams( GetPool() );
TransformParameters( nId,
diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx
index f4824a6b8fe8..3e02827bbe6e 100644
--- a/sfx2/source/doc/printhelper.cxx
+++ b/sfx2/source/doc/printhelper.cxx
@@ -698,7 +698,6 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >&
sal_Int32 nCopies = 0;
if ( !( rProp.Value >>= nCopies ) )
throw css::lang::IllegalArgumentException();
-
aCheckedArgs[nProps].Name = rProp.Name;
aCheckedArgs[nProps++].Value <<= nCopies;
}
@@ -708,26 +707,20 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >&
else if ( rProp.Name == "Collate" || rProp.Name == "Sort" )
{
bool bTemp;
- if ( rProp.Value >>= bTemp )
- {
- aCheckedArgs[nProps].Name = "Collate";
- aCheckedArgs[nProps++].Value <<= bTemp;
- }
- else
+ if ( !(rProp.Value >>= bTemp) )
throw css::lang::IllegalArgumentException();
+ aCheckedArgs[nProps].Name = "Collate";
+ aCheckedArgs[nProps++].Value <<= bTemp;
}
// Pages-Property
else if ( rProp.Name == "Pages" )
{
OUString sTemp;
- if( rProp.Value >>= sTemp )
- {
- aCheckedArgs[nProps].Name = rProp.Name;
- aCheckedArgs[nProps++].Value <<= sTemp;
- }
- else
+ if( !(rProp.Value >>= sTemp) )
throw css::lang::IllegalArgumentException();
+ aCheckedArgs[nProps].Name = rProp.Name;
+ aCheckedArgs[nProps++].Value <<= sTemp;
}
// MonitorVisible
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index d3907953cbb0..ce5f43c9bf9d 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -1878,95 +1878,87 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla
{
if ( aFlavor.MimeType == "application/x-openoffice-objectdescriptor-xml;windows_formatname=\"Star Object Descriptor (XML)\"" )
{
- if ( aFlavor.DataType == cppu::UnoType<Sequence< sal_Int8 >>::get() )
- {
- TransferableObjectDescriptor aDesc;
+ if ( aFlavor.DataType != cppu::UnoType<Sequence< sal_Int8 >>::get() )
+ throw datatransfer::UnsupportedFlavorException();
- aDesc.maClassName = m_pData->m_pObjectShell->GetClassName();
- aDesc.maTypeName = aFlavor.HumanPresentableName;
+ TransferableObjectDescriptor aDesc;
- // TODO/LATER: ViewAspect needs to be sal_Int64
- aDesc.mnViewAspect = sal::static_int_cast< sal_uInt16 >( embed::Aspects::MSOLE_CONTENT );
+ aDesc.maClassName = m_pData->m_pObjectShell->GetClassName();
+ aDesc.maTypeName = aFlavor.HumanPresentableName;
- Size aSize = m_pData->m_pObjectShell->GetVisArea().GetSize();
+ // TODO/LATER: ViewAspect needs to be sal_Int64
+ aDesc.mnViewAspect = sal::static_int_cast< sal_uInt16 >( embed::Aspects::MSOLE_CONTENT );
- MapUnit aMapUnit = m_pData->m_pObjectShell->GetMapUnit();
- aDesc.maSize = OutputDevice::LogicToLogic( aSize, aMapUnit, MapUnit::Map100thMM );
- aDesc.maDragStartPos = Point();
- aDesc.maDisplayName.clear();
+ Size aSize = m_pData->m_pObjectShell->GetVisArea().GetSize();
- SvMemoryStream aMemStm( 1024, 1024 );
- WriteTransferableObjectDescriptor( aMemStm, aDesc );
- aAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Tell() );
- }
- else
- throw datatransfer::UnsupportedFlavorException();
+ MapUnit aMapUnit = m_pData->m_pObjectShell->GetMapUnit();
+ aDesc.maSize = OutputDevice::LogicToLogic( aSize, aMapUnit, MapUnit::Map100thMM );
+ aDesc.maDragStartPos = Point();
+ aDesc.maDisplayName.clear();
+
+ SvMemoryStream aMemStm( 1024, 1024 );
+ WriteTransferableObjectDescriptor( aMemStm, aDesc );
+ aAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Tell() );
}
else if ( aFlavor.MimeType == "application/x-openoffice-embed-source;windows_formatname=\"Star EMBS\"" )
{
- if ( aFlavor.DataType == cppu::UnoType<Sequence< sal_Int8 >>::get() )
+ if ( aFlavor.DataType != cppu::UnoType<Sequence< sal_Int8 >>::get() )
+ throw datatransfer::UnsupportedFlavorException();
+
+ try
+ {
+ utl::TempFile aTmp;
+ aTmp.EnableKillingFile();
+ storeToURL( aTmp.GetURL(), Sequence < beans::PropertyValue >() );
+ SvStream* pStream = aTmp.GetStream( StreamMode::READ );
+ const sal_uInt32 nLen = pStream->Seek( STREAM_SEEK_TO_END );
+ Sequence< sal_Int8 > aSeq( nLen );
+ pStream->Seek( STREAM_SEEK_TO_BEGIN );
+ pStream->ReadBytes(aSeq.getArray(), nLen);
+ delete pStream;
+ if( aSeq.getLength() )
+ aAny <<= aSeq;
+ }
+ catch ( Exception& )
{
- try
- {
- utl::TempFile aTmp;
- aTmp.EnableKillingFile();
- storeToURL( aTmp.GetURL(), Sequence < beans::PropertyValue >() );
- SvStream* pStream = aTmp.GetStream( StreamMode::READ );
- const sal_uInt32 nLen = pStream->Seek( STREAM_SEEK_TO_END );
- Sequence< sal_Int8 > aSeq( nLen );
- pStream->Seek( STREAM_SEEK_TO_BEGIN );
- pStream->ReadBytes(aSeq.getArray(), nLen);
- delete pStream;
- if( aSeq.getLength() )
- aAny <<= aSeq;
- }
- catch ( Exception& )
- {
- }
}
- else
- throw datatransfer::UnsupportedFlavorException();
}
else if ( aFlavor.MimeType == "application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\"" )
{
- if ( aFlavor.DataType == cppu::UnoType<Sequence< sal_Int8 >>::get() )
- {
+ if ( aFlavor.DataType != cppu::UnoType<Sequence< sal_Int8 >>::get() )
+ throw datatransfer::UnsupportedFlavorException();
- std::shared_ptr<GDIMetaFile> xMetaFile =
- m_pData->m_pObjectShell->GetPreviewMetaFile( true );
- if (xMetaFile)
- {
- SvMemoryStream aMemStm( 65535, 65535 );
- aMemStm.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
+ std::shared_ptr<GDIMetaFile> xMetaFile =
+ m_pData->m_pObjectShell->GetPreviewMetaFile( true );
- xMetaFile->Write( aMemStm );
- aAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ),
- aMemStm.Seek( STREAM_SEEK_TO_END ) );
- }
+ if (xMetaFile)
+ {
+ SvMemoryStream aMemStm( 65535, 65535 );
+ aMemStm.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
+
+ xMetaFile->Write( aMemStm );
+ aAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ),
+ aMemStm.Seek( STREAM_SEEK_TO_END ) );
}
- else
- throw datatransfer::UnsupportedFlavorException();
}
else if ( aFlavor.MimeType == "application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\"" )
{
- if ( aFlavor.DataType == cppu::UnoType<Sequence< sal_Int8 >>::get() )
- {
- std::shared_ptr<GDIMetaFile> xMetaFile =
- m_pData->m_pObjectShell->CreatePreviewMetaFile_Impl( true );
+ if ( aFlavor.DataType != cppu::UnoType<Sequence< sal_Int8 >>::get() )
+ throw datatransfer::UnsupportedFlavorException();
- if (xMetaFile)
- {
- SvMemoryStream aMemStm( 65535, 65535 );
- aMemStm.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
+ std::shared_ptr<GDIMetaFile> xMetaFile =
+ m_pData->m_pObjectShell->CreatePreviewMetaFile_Impl( true );
- xMetaFile->Write( aMemStm );
- aAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ),
- aMemStm.Seek( STREAM_SEEK_TO_END ) );
- }
+ if (xMetaFile)
+ {
+ SvMemoryStream aMemStm( 65535, 65535 );
+ aMemStm.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
+
+ xMetaFile->Write( aMemStm );
+ aAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ),
+ aMemStm.Seek( STREAM_SEEK_TO_END ) );
}
- else
- throw datatransfer::UnsupportedFlavorException();
}
else if ( aFlavor.MimeType == "application/x-openoffice-emf;windows_formatname=\"Image EMF\"" )
{
@@ -2045,51 +2037,47 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla
}
else if ( aFlavor.MimeType == "application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"" )
{
- if ( aFlavor.DataType == cppu::UnoType<Sequence< sal_Int8 >>::get() )
+ if ( aFlavor.DataType != cppu::UnoType<Sequence< sal_Int8 >>::get() )
+ throw datatransfer::UnsupportedFlavorException();
+
+ std::shared_ptr<GDIMetaFile> xMetaFile =
+ m_pData->m_pObjectShell->GetPreviewMetaFile( true );
+
+ if (xMetaFile)
{
- std::shared_ptr<GDIMetaFile> xMetaFile =
- m_pData->m_pObjectShell->GetPreviewMetaFile( true );
+ std::shared_ptr<SvMemoryStream> xStream(
+ GraphicHelper::getFormatStrFromGDI_Impl(
+ xMetaFile.get(), ConvertDataFormat::BMP ) );
- if (xMetaFile)
+ if (xStream)
{
- std::shared_ptr<SvMemoryStream> xStream(
- GraphicHelper::getFormatStrFromGDI_Impl(
- xMetaFile.get(), ConvertDataFormat::BMP ) );
-
- if (xStream)
- {
- xStream->SetVersion( SOFFICE_FILEFORMAT_CURRENT );
- aAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( xStream->GetData() ),
- xStream->Seek( STREAM_SEEK_TO_END ) );
- }
+ xStream->SetVersion( SOFFICE_FILEFORMAT_CURRENT );
+ aAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( xStream->GetData() ),
+ xStream->Seek( STREAM_SEEK_TO_END ) );
}
}
- else
- throw datatransfer::UnsupportedFlavorException();
}
else if ( aFlavor.MimeType == "image/png" )
{
- if ( aFlavor.DataType == cppu::UnoType<Sequence< sal_Int8 >>::get() )
+ if ( aFlavor.DataType != cppu::UnoType<Sequence< sal_Int8 >>::get() )
+ throw datatransfer::UnsupportedFlavorException();
+
+ std::shared_ptr<GDIMetaFile> xMetaFile =
+ m_pData->m_pObjectShell->GetPreviewMetaFile( true );
+
+ if (xMetaFile)
{
- std::shared_ptr<GDIMetaFile> xMetaFile =
- m_pData->m_pObjectShell->GetPreviewMetaFile( true );
+ std::shared_ptr<SvMemoryStream> xStream(
+ GraphicHelper::getFormatStrFromGDI_Impl(
+ xMetaFile.get(), ConvertDataFormat::PNG ) );
- if (xMetaFile)
+ if (xStream)
{
- std::shared_ptr<SvMemoryStream> xStream(
- GraphicHelper::getFormatStrFromGDI_Impl(
- xMetaFile.get(), ConvertDataFormat::PNG ) );
-
- if (xStream)
- {
- xStream->SetVersion( SOFFICE_FILEFORMAT_CURRENT );
- aAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( xStream->GetData() ),
- xStream->Seek( STREAM_SEEK_TO_END ) );
- }
+ xStream->SetVersion( SOFFICE_FILEFORMAT_CURRENT );
+ aAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( xStream->GetData() ),
+ xStream->Seek( STREAM_SEEK_TO_END ) );
}
}
- else
- throw datatransfer::UnsupportedFlavorException();
}
else
throw datatransfer::UnsupportedFlavorException();
diff --git a/sfx2/source/sidebar/UnoDecks.cxx b/sfx2/source/sidebar/UnoDecks.cxx
index 66dcc0719092..9812bc5c6dfa 100644
--- a/sfx2/source/sidebar/UnoDecks.cxx
+++ b/sfx2/source/sidebar/UnoDecks.cxx
@@ -38,17 +38,11 @@ uno::Any SAL_CALL SfxUnoDecks::getByName( const OUString& aName )
{
SolarMutexGuard aGuard;
- uno::Any aRet;
-
- if (hasByName(aName))
- {
- uno::Reference<ui::XDeck> xDeck = new SfxUnoDeck(xFrame, aName);
- aRet <<= xDeck;
- }
- else
+ if (!hasByName(aName))
throw container::NoSuchElementException();
- return aRet;
+ uno::Reference<ui::XDeck> xDeck = new SfxUnoDeck(xFrame, aName);
+ return uno::Any(xDeck);
}
diff --git a/sfx2/source/sidebar/UnoPanels.cxx b/sfx2/source/sidebar/UnoPanels.cxx
index 257c75cea4bc..a74763572cdb 100644
--- a/sfx2/source/sidebar/UnoPanels.cxx
+++ b/sfx2/source/sidebar/UnoPanels.cxx
@@ -47,17 +47,11 @@ uno::Any SAL_CALL SfxUnoPanels::getByName( const OUString& aName )
{
SolarMutexGuard aGuard;
- uno::Any aRet;
-
- if (hasByName(aName))
- {
- uno::Reference<ui::XPanel> xPanel = new SfxUnoPanel(xFrame, aName, mDeckId);
- aRet <<= xPanel;
- }
- else
+ if (!hasByName(aName))
throw container::NoSuchElementException();
- return aRet;
+ uno::Reference<ui::XPanel> xPanel = new SfxUnoPanel(xFrame, aName, mDeckId);
+ return uno::Any(xPanel);
}
diff --git a/shell/source/unix/sysshell/recently_used_file.cxx b/shell/source/unix/sysshell/recently_used_file.cxx
index ee0e598fbd32..9068e96b0b55 100644
--- a/shell/source/unix/sysshell/recently_used_file.cxx
+++ b/shell/source/unix/sysshell/recently_used_file.cxx
@@ -50,37 +50,35 @@ recently_used_file::recently_used_file() :
osl::Security sec;
OUString homedir_url;
- if (sec.getHomeDir(homedir_url))
- {
- OUString homedir;
- osl::FileBase::getSystemPathFromFileURL(homedir_url, homedir);
-
- OUString rufn = homedir;
- ensure_final_slash(rufn);
- rufn += ".recently-used";
-
- OString tmp =
- OUStringToOString(rufn, osl_getThreadTextEncoding());
-
- int fd = open(tmp.getStr(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
- if (fd != -1) {
- file_ = fdopen(fd, "w+");
- if (file_ == nullptr) {
- close(fd);
- }
- }
+ if (!sec.getHomeDir(homedir_url))
+ throw "Cannot determine user home directory";
+
+ OUString homedir;
+ osl::FileBase::getSystemPathFromFileURL(homedir_url, homedir);
+
+ OUString rufn = homedir;
+ ensure_final_slash(rufn);
+ rufn += ".recently-used";
- if (nullptr == file_)
- throw "I/O error opening ~/.recently-used";
+ OString tmp =
+ OUStringToOString(rufn, osl_getThreadTextEncoding());
- if (lockf(fileno(file_), F_LOCK, 0) != 0)
- {
- fclose(file_);
- throw "Cannot lock ~/.recently-used";
+ int fd = open(tmp.getStr(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+ if (fd != -1) {
+ file_ = fdopen(fd, "w+");
+ if (file_ == nullptr) {
+ close(fd);
}
}
- else
- throw "Cannot determine user home directory";
+
+ if (nullptr == file_)
+ throw "I/O error opening ~/.recently-used";
+
+ if (lockf(fileno(file_), F_LOCK, 0) != 0)
+ {
+ fclose(file_);
+ throw "Cannot lock ~/.recently-used";
+ }
}
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index ef5276b6512d..114662deaf15 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -584,19 +584,17 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any*
if (pPrinter)
{
OUString sPrinterName;
- if (*pValues >>= sPrinterName )
+ if ( !(*pValues >>= sPrinterName) )
+ throw IllegalArgumentException();
+
+ if ( !sPrinterName.isEmpty() )
{
- if ( !sPrinterName.isEmpty() )
- {
- VclPtrInstance<SfxPrinter> pNewPrinter( std::unique_ptr<SfxItemSet>(pPrinter->GetOptions().Clone()), sPrinterName );
- if (pNewPrinter->IsKnown())
- pDocSh->SetPrinter ( pNewPrinter );
- else
- pNewPrinter.disposeAndClear();
- }
+ VclPtrInstance<SfxPrinter> pNewPrinter( std::unique_ptr<SfxItemSet>(pPrinter->GetOptions().Clone()), sPrinterName );
+ if (pNewPrinter->IsKnown())
+ pDocSh->SetPrinter ( pNewPrinter );
+ else
+ pNewPrinter.disposeAndClear();
}
- else
- throw IllegalArgumentException();
}
}
}
@@ -604,61 +602,57 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any*
case HANDLE_PRINTER_SETUP:
{
Sequence < sal_Int8 > aSequence;
- if ( *pValues >>= aSequence )
- {
- sal_uInt32 nSize = aSequence.getLength();
- SvMemoryStream aStream ( aSequence.getArray(), nSize, StreamMode::READ );
- aStream.Seek ( STREAM_SEEK_TO_BEGIN );
- static sal_uInt16 const nRange[] =
- {
- SID_PRINTSIZE, SID_PRINTSIZE,
- SID_PRINTZOOM, SID_PRINTZOOM,
- SID_PRINTTITLE, SID_PRINTTITLE,
- SID_PRINTTEXT, SID_PRINTTEXT,
- SID_PRINTFRAME, SID_PRINTFRAME,
- SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES,
- SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS,
- SID_AUTO_CLOSE_BRACKETS, SID_AUTO_CLOSE_BRACKETS,
- 0
- };
- auto pItemSet = o3tl::make_unique<SfxItemSet>( SmDocShell::GetPool(), nRange );
- SmModule *pp = SM_MOD();
- pp->GetConfig()->ConfigToItemSet(*pItemSet);
- VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, std::move(pItemSet) );
-
- pDocSh->SetPrinter( pPrinter );
- }
- else
+ if ( !(*pValues >>= aSequence) )
throw IllegalArgumentException();
+
+ sal_uInt32 nSize = aSequence.getLength();
+ SvMemoryStream aStream ( aSequence.getArray(), nSize, StreamMode::READ );
+ aStream.Seek ( STREAM_SEEK_TO_BEGIN );
+ static sal_uInt16 const nRange[] =
+ {
+ SID_PRINTSIZE, SID_PRINTSIZE,
+ SID_PRINTZOOM, SID_PRINTZOOM,
+ SID_PRINTTITLE, SID_PRINTTITLE,
+ SID_PRINTTEXT, SID_PRINTTEXT,
+ SID_PRINTFRAME, SID_PRINTFRAME,
+ SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES,
+ SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS,
+ SID_AUTO_CLOSE_BRACKETS, SID_AUTO_CLOSE_BRACKETS,
+ 0
+ };
+ auto pItemSet = o3tl::make_unique<SfxItemSet>( SmDocShell::GetPool(), nRange );
+ SmModule *pp = SM_MOD();
+ pp->GetConfig()->ConfigToItemSet(*pItemSet);
+ VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, std::move(pItemSet) );
+
+ pDocSh->SetPrinter( pPrinter );
}
break;
case HANDLE_SYMBOLS:
{
// this is set
Sequence < SymbolDescriptor > aSequence;
- if ( *pValues >>= aSequence )
+ if ( !(*pValues >>= aSequence) )
+ throw IllegalArgumentException();
+
+ sal_uInt32 nSize = aSequence.getLength();
+ SmModule *pp = SM_MOD();
+ SmSymbolManager &rManager = pp->GetSymbolManager();
+ SymbolDescriptor *pDescriptor = aSequence.getArray();
+ for (sal_uInt32 i = 0; i < nSize ; i++, pDescriptor++)
{
- sal_uInt32 nSize = aSequence.getLength();
- SmModule *pp = SM_MOD();
- SmSymbolManager &rManager = pp->GetSymbolManager();
- SymbolDescriptor *pDescriptor = aSequence.getArray();
- for (sal_uInt32 i = 0; i < nSize ; i++, pDescriptor++)
- {
- vcl::Font aFont;
- aFont.SetFamilyName ( pDescriptor->sFontName );
- aFont.SetCharSet ( static_cast < rtl_TextEncoding > (pDescriptor->nCharSet) );
- aFont.SetFamily ( static_cast < FontFamily > (pDescriptor->nFamily ) );
- aFont.SetPitch ( static_cast < FontPitch > (pDescriptor->nPitch ) );
- aFont.SetWeight ( static_cast < FontWeight > (pDescriptor->nWeight ) );
- aFont.SetItalic ( static_cast < FontItalic > (pDescriptor->nItalic ) );
- SmSym aSymbol ( pDescriptor->sName, aFont, static_cast < sal_Unicode > (pDescriptor->nCharacter),
- pDescriptor->sSymbolSet );
- aSymbol.SetExportName ( pDescriptor->sExportName );
- rManager.AddOrReplaceSymbol ( aSymbol );
- }
+ vcl::Font aFont;
+ aFont.SetFamilyName ( pDescriptor->sFontName );
+ aFont.SetCharSet ( static_cast < rtl_TextEncoding > (pDescriptor->nCharSet) );
+ aFont.SetFamily ( static_cast < FontFamily > (pDescriptor->nFamily ) );
+ aFont.SetPitch ( static_cast < FontPitch > (pDescriptor->nPitch ) );
+ aFont.SetWeight ( static_cast < FontWeight > (pDescriptor->nWeight ) );
+ aFont.SetItalic ( static_cast < FontItalic > (pDescriptor->nItalic ) );
+ SmSym aSymbol ( pDescriptor->sName, aFont, static_cast < sal_Unicode > (pDescriptor->nCharacter),
+ pDescriptor->sSymbolSet );
+ aSymbol.SetExportName ( pDescriptor->sExportName );
+ rManager.AddOrReplaceSymbol ( aSymbol );
}
- else
- throw IllegalArgumentException();
}
break;
// #i33095# Security Options
diff --git a/stoc/source/corereflection/crcomp.cxx b/stoc/source/corereflection/crcomp.cxx
index 0a0572676a73..01e043144075 100644
--- a/stoc/source/corereflection/crcomp.cxx
+++ b/stoc/source/corereflection/crcomp.cxx
@@ -210,16 +210,13 @@ void IdlCompFieldImpl::set( const Any & rObj, const Any & rValue )
if (pTD)
{
TYPELIB_DANGER_RELEASE( pObjTD );
- if (coerce_assign( const_cast<char *>(static_cast<char const *>(rObj.getValue()) + _nOffset), getTypeDescr(), rValue, getReflection() ))
- {
- return;
- }
- else
+ if (!coerce_assign( const_cast<char *>(static_cast<char const *>(rObj.getValue()) + _nOffset), getTypeDescr(), rValue, getReflection() ))
{
throw IllegalArgumentException(
"cannot assign value to destination",
static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 1 );
}
+ return;
}
TYPELIB_DANGER_RELEASE( pObjTD );
}
@@ -246,16 +243,13 @@ void IdlCompFieldImpl::set( Any & rObj, const Any & rValue )
if (pTD)
{
TYPELIB_DANGER_RELEASE( pObjTD );
- if (coerce_assign( const_cast<char *>(static_cast<char const *>(rObj.getValue()) + _nOffset), getTypeDescr(), rValue, getReflection() ))
- {
- return;
- }
- else
+ if (!coerce_assign( const_cast<char *>(static_cast<char const *>(rObj.getValue()) + _nOffset), getTypeDescr(), rValue, getReflection() ))
{
throw IllegalArgumentException(
"cannot assign to destination",
static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 1 );
}
+ return;
}
TYPELIB_DANGER_RELEASE( pObjTD );
}
diff --git a/stoc/source/corereflection/crefl.cxx b/stoc/source/corereflection/crefl.cxx
index 00c9429b3586..8982b768a684 100644
--- a/stoc/source/corereflection/crefl.cxx
+++ b/stoc/source/corereflection/crefl.cxx
@@ -264,12 +264,10 @@ Any IdlReflectionServiceImpl::getByHierarchicalName( const OUString & rName )
// else is enum member(?)
// update
- if (aRet.hasValue())
- _aElements.setValue( rName, aRet );
- else
- {
+ if (!aRet.hasValue())
throw container::NoSuchElementException( rName );
- }
+
+ _aElements.setValue( rName, aRet );
}
return aRet;
}
diff --git a/stoc/source/corereflection/criface.cxx b/stoc/source/corereflection/criface.cxx
index 680e55083dd4..841cb235eb90 100644
--- a/stoc/source/corereflection/criface.cxx
+++ b/stoc/source/corereflection/criface.cxx
@@ -296,16 +296,15 @@ void IdlAttributeFieldImpl::checkException(
&e, exception->pData, exception->pType,
getReflection()->getUno2Cpp().get());
uno_any_destruct(exception, nullptr);
- if (e.isExtractableTo(
+ if (!e.isExtractableTo(
cppu::UnoType<RuntimeException>::get()))
{
- cppu::throwException(e);
- } else {
throw WrappedTargetRuntimeException(
"non-RuntimeException occurred when accessing an"
" interface type attribute",
context, e);
}
+ cppu::throwException(e);
}
}
diff --git a/stoc/source/defaultregistry/defaultregistry.cxx b/stoc/source/defaultregistry/defaultregistry.cxx
index fb54149dc27d..5f24b18e34f6 100644
--- a/stoc/source/defaultregistry/defaultregistry.cxx
+++ b/stoc/source/defaultregistry/defaultregistry.cxx
@@ -263,10 +263,10 @@ sal_Bool SAL_CALL NestedKeyImpl::isReadOnly( )
Guard< Mutex > aGuard( m_xRegistry->m_mutex );
computeChanges();
- if ( m_localKey.is() && m_localKey->isValid() )
- return m_localKey->isReadOnly();
- else
+ if ( !m_localKey.is() || !m_localKey->isValid() )
throw InvalidRegistryException();
+
+ return m_localKey->isReadOnly();
}
@@ -724,22 +724,20 @@ void SAL_CALL NestedKeyImpl::closeKey( )
void SAL_CALL NestedKeyImpl::deleteKey( const OUString& rKeyName )
{
Guard< Mutex > aGuard( m_xRegistry->m_mutex );
- if ( m_localKey.is() && m_localKey->isValid() &&
- !m_localKey->isReadOnly() )
+ if ( !m_localKey.is() || !m_localKey->isValid() ||
+ m_localKey->isReadOnly() )
{
- OUString resolvedName = computeName(rKeyName);
+ throw InvalidRegistryException();
+ }
- if ( resolvedName.isEmpty() )
- {
- throw InvalidRegistryException();
- }
+ OUString resolvedName = computeName(rKeyName);
- m_xRegistry->m_localReg->getRootKey()->deleteKey(resolvedName);
- }
- else
+ if ( resolvedName.isEmpty() )
{
throw InvalidRegistryException();
}
+
+ m_xRegistry->m_localReg->getRootKey()->deleteKey(resolvedName);
}
@@ -976,15 +974,13 @@ void SAL_CALL NestedKeyImpl::deleteLink( const OUString& rLinkName )
resolvedName = m_name + "/" + rLinkName;
}
- if ( m_localKey.is() && m_localKey->isValid() &&
- !m_localKey->isReadOnly() )
- {
- m_xRegistry->m_localReg->getRootKey()->deleteLink(resolvedName);
- }
- else
+ if ( !m_localKey.is() || !m_localKey->isValid() ||
+ m_localKey->isReadOnly() )
{
throw InvalidRegistryException();
}
+
+ m_xRegistry->m_localReg->getRootKey()->deleteLink(resolvedName);
}
@@ -1224,25 +1220,23 @@ void SAL_CALL NestedRegistryImpl::destroy( )
Reference< XRegistryKey > SAL_CALL NestedRegistryImpl::getRootKey( )
{
Guard< Mutex > aGuard( m_mutex );
- if ( m_localReg.is() && m_localReg->isValid() )
+ if ( !m_localReg.is() || !m_localReg->isValid() )
{
- Reference<XRegistryKey> localKey, defaultKey;
+ throw InvalidRegistryException();
+ }
- localKey = m_localReg->getRootKey();
+ Reference<XRegistryKey> localKey, defaultKey;
- if ( localKey.is() )
- {
- if ( m_defaultReg.is() && m_defaultReg->isValid() )
- {
- defaultKey = m_defaultReg->getRootKey();
- }
+ localKey = m_localReg->getRootKey();
- return static_cast<XRegistryKey*>(new NestedKeyImpl(this, localKey, defaultKey));
- }
- }
- else
+ if ( localKey.is() )
{
- throw InvalidRegistryException();
+ if ( m_defaultReg.is() && m_defaultReg->isValid() )
+ {
+ defaultKey = m_defaultReg->getRootKey();
+ }
+
+ return static_cast<XRegistryKey*>(new NestedKeyImpl(this, localKey, defaultKey));
}
return Reference<XRegistryKey>();
diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx
index 063e868a1604..3bb086d5ad7d 100644
--- a/stoc/source/inspect/introspection.cxx
+++ b/stoc/source/inspect/introspection.cxx
@@ -372,10 +372,9 @@ void IntrospectionAccessStatic_Impl::setPropertyValue( const Any& obj, const OUS
//void IntrospectionAccessStatic_Impl::setPropertyValue( Any& obj, const OUString& aPropertyName, const Any& aValue ) const
{
sal_Int32 i = getPropertyIndex( aPropertyName );
- if( i != -1 )
- setPropertyValueByIndex( obj, i, aValue );
- else
+ if( i == -1 )
throw UnknownPropertyException(aPropertyName);
+ setPropertyValueByIndex( obj, i, aValue );
}
void IntrospectionAccessStatic_Impl::setPropertyValueByIndex(const Any& obj, sal_Int32 nSequenceIndex, const Any& aValue) const
diff --git a/stoc/source/javaloader/javaloader.cxx b/stoc/source/javaloader/javaloader.cxx
index 01000b0ab827..2139815d357c 100644
--- a/stoc/source/javaloader/javaloader.cxx
+++ b/stoc/source/javaloader/javaloader.cxx
@@ -310,10 +310,9 @@ sal_Bool SAL_CALL JavaComponentLoader::writeRegistryInfo(
const OUString & rLibName)
{
const css::uno::Reference<XImplementationLoader> & loader = getJavaLoader();
- if (loader.is())
- return loader->writeRegistryInfo(xKey, blabla, rLibName);
- else
+ if (!loader.is())
throw CannotRegisterImplementationException("Could not create Java implementation loader");
+ return loader->writeRegistryInfo(xKey, blabla, rLibName);
}
@@ -322,10 +321,9 @@ css::uno::Reference<XInterface> SAL_CALL JavaComponentLoader::activate(
const css::uno::Reference<XRegistryKey> & xKey)
{
const css::uno::Reference<XImplementationLoader> & loader = getJavaLoader();
- if (loader.is())
- return loader->activate(rImplName, blabla, rLibName, xKey);
- else
+ if (!loader.is())
throw CannotActivateFactoryException("Could not create Java implementation loader");
+ return loader->activate(rImplName, blabla, rLibName, xKey);
}
static Mutex & getInitMutex()
diff --git a/stoc/source/security/access_controller.cxx b/stoc/source/security/access_controller.cxx
index 65771de2bd99..06fdc0e4cfbf 100644
--- a/stoc/source/security/access_controller.cxx
+++ b/stoc/source/security/access_controller.cxx
@@ -439,19 +439,17 @@ Reference< security::XPolicy > const & AccessController::getPolicy()
Reference< security::XPolicy > xPolicy;
m_xComponentContext->getValueByName(
"/singletons/com.sun.star.security.thePolicy" ) >>= xPolicy;
- if (xPolicy.is())
- {
- MutexGuard guard( m_mutex );
- if (! m_xPolicy.is())
- {
- m_xPolicy = xPolicy;
- }
- }
- else
+ if (!xPolicy.is())
{
throw SecurityException(
"cannot get policy singleton!", static_cast<OWeakObject *>(this) );
}
+
+ MutexGuard guard( m_mutex );
+ if (! m_xPolicy.is())
+ {
+ m_xPolicy = xPolicy;
+ }
}
return m_xPolicy;
}
diff --git a/stoc/source/typeconv/convert.cxx b/stoc/source/typeconv/convert.cxx
index 8a0ea977272d..011340f4e88e 100644
--- a/stoc/source/typeconv/convert.cxx
+++ b/stoc/source/typeconv/convert.cxx
@@ -507,17 +507,14 @@ Any SAL_CALL TypeConverter_Impl::convertTo( const Any& rVal, const Type& aDestTy
// same types or destination type is derived source type?
TypeDescription aSourceTD( aSourceType );
TypeDescription aDestTD( aDestType );
- if (typelib_typedescription_isAssignableFrom( aDestTD.get(), aSourceTD.get() ))
- {
- aRet.setValue( rVal.getValue(), aDestTD.get() ); // evtl. .uP.cAsT.
- }
- else
+ if (!typelib_typedescription_isAssignableFrom( aDestTD.get(), aSourceTD.get() ))
{
throw CannotConvertException(
"value is not of same or derived type!",
Reference< XInterface >(), aDestinationClass,
FailReason::SOURCE_IS_NO_DERIVED_TYPE, 0 );
}
+ aRet.setValue( rVal.getValue(), aDestTD.get() ); // evtl. .uP.cAsT.
break;
}
// --- to INTERFACE -------------------------------------------------------------------------
@@ -636,18 +633,17 @@ Any SAL_CALL TypeConverter_Impl::convertTo( const Any& rVal, const Type& aDestTy
}
}
- if (nPos >= 0)
- {
- aRet.setValue(
- &reinterpret_cast<typelib_EnumTypeDescription *>(aEnumTD.get())->pEnumValues[nPos],
- aEnumTD.get() );
- }
- else
+ if (nPos < 0)
{
throw CannotConvertException(
"value cannot be converted to demanded ENUM!",
Reference< XInterface >(), aDestinationClass, FailReason::IS_NOT_ENUM, 0 );
}
+
+ aRet.setValue(
+ &reinterpret_cast<typelib_EnumTypeDescription *>(aEnumTD.get())->pEnumValues[nPos],
+ aEnumTD.get() );
+
break;
}
@@ -815,17 +811,16 @@ Any TypeConverter_Impl::convertToSimpleType( const Any& rVal, TypeClass aDestina
if (nEnumValue == reinterpret_cast<typelib_EnumTypeDescription *>(aEnumTD.get())->pEnumValues[nPos])
break;
}
- if (nPos >= 0)
- {
- aRet <<= OUString::unacquired(
- &reinterpret_cast<typelib_EnumTypeDescription *>(aEnumTD.get())->ppEnumNames[nPos]);
- }
- else
+ if (nPos < 0)
{
throw CannotConvertException(
"value is not ENUM!",
Reference< XInterface >(), aDestinationClass, FailReason::IS_NOT_ENUM, 0 );
}
+
+ aRet <<= OUString::unacquired(
+ &reinterpret_cast<typelib_EnumTypeDescription *>(aEnumTD.get())->ppEnumNames[nPos]);
+
break;
}