summaryrefslogtreecommitdiff
path: root/embeddedobj
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-27 09:11:35 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-27 11:02:56 +0200
commitcc1ed7fbce20f90650f96acc2846b6f232c8ab0f (patch)
treefcd441cdf9568861363894f63107967adf571f81 /embeddedobj
parentb50f595b34585f2927adfd44b4eaaafb8f600972 (diff)
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>
Diffstat (limited to 'embeddedobj')
-rw-r--r--embeddedobj/source/general/dummyobject.cxx33
-rw-r--r--embeddedobj/source/msole/oleembed.cxx104
-rw-r--r--embeddedobj/source/msole/olepersist.cxx200
3 files changed, 160 insertions, 177 deletions
diff --git a/embeddedobj/source/general/dummyobject.cxx b/embeddedobj/source/general/dummyobject.cxx
index fa44b4db4286..935ad015fb0b 100644
--- a/embeddedobj/source/general/dummyobject.cxx
+++ b/embeddedobj/source/general/dummyobject.cxx
@@ -293,34 +293,29 @@ void SAL_CALL ODummyEmbeddedObject::setPersistentEntry(
if ( m_bWaitSaveCompleted )
{
- if ( nEntryConnectionMode == embed::EntryInitModes::NO_INIT )
- saveCompleted( m_xParentStorage != xStorage || m_aEntryName != sEntName );
- else
+ if ( nEntryConnectionMode != embed::EntryInitModes::NO_INIT )
throw embed::WrongStateException(
"The object waits for saveCompleted() call!",
static_cast< ::cppu::OWeakObject* >(this) );
- }
- if ( nEntryConnectionMode == embed::EntryInitModes::DEFAULT_INIT
- || nEntryConnectionMode == embed::EntryInitModes::NO_INIT )
- {
- if ( xStorage->hasByName( sEntName ) )
-
- {
- m_xParentStorage = xStorage;
- m_aEntryName = sEntName;
- m_nObjectState = embed::EmbedStates::LOADED;
- }
- else
- throw lang::IllegalArgumentException( "Wrong entry is provided!",
- static_cast< ::cppu::OWeakObject* >(this),
- 2 );
+ saveCompleted( m_xParentStorage != xStorage || m_aEntryName != sEntName );
}
- else
+
+ if ( nEntryConnectionMode != embed::EntryInitModes::DEFAULT_INIT
+ && nEntryConnectionMode != embed::EntryInitModes::NO_INIT )
throw lang::IllegalArgumentException( "Wrong connection mode is provided!",
static_cast< ::cppu::OWeakObject* >(this),
3 );
+
+ if ( !xStorage->hasByName( sEntName ) )
+ throw lang::IllegalArgumentException( "Wrong entry is provided!",
+ static_cast< ::cppu::OWeakObject* >(this),
+ 2 );
+
+ m_xParentStorage = xStorage;
+ m_aEntryName = sEntName;
+ m_nObjectState = embed::EmbedStates::LOADED;
}
diff --git a/embeddedobj/source/msole/oleembed.cxx b/embeddedobj/source/msole/oleembed.cxx
index b00cea109890..e8139480b39d 100644
--- a/embeddedobj/source/msole/oleembed.cxx
+++ b/embeddedobj/source/msole/oleembed.cxx
@@ -903,75 +903,73 @@ void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID )
else
#endif
{
- if ( nVerbID == -9 )
+ if ( nVerbID != -9 )
{
- // 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 ( !m_bTriedConversion )
+ throw embed::UnreachableStateException();
+ }
+
+ // 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 ( !m_bTriedConversion )
+ {
+ m_bTriedConversion = true;
+ if ( TryToConvertToOOo( m_xObjectStream ) )
{
- m_bTriedConversion = true;
- if ( TryToConvertToOOo( m_xObjectStream ) )
- {
- changeState( embed::EmbedStates::ACTIVE );
- return;
- }
+ changeState( embed::EmbedStates::ACTIVE );
+ return;
}
+ }
- if ( !m_xOwnView.is() && m_xObjectStream.is() && m_aFilterName != "Text" )
- {
- try {
- uno::Reference< io::XSeekable > xSeekable( m_xObjectStream, uno::UNO_QUERY );
- if ( xSeekable.is() )
- xSeekable->seek( 0 );
+ if ( !m_xOwnView.is() && m_xObjectStream.is() && m_aFilterName != "Text" )
+ {
+ try {
+ uno::Reference< io::XSeekable > xSeekable( m_xObjectStream, uno::UNO_QUERY );
+ if ( xSeekable.is() )
+ xSeekable->seek( 0 );
- m_xOwnView = new OwnView_Impl( m_xFactory, m_xObjectStream->getInputStream() );
- }
- catch( uno::RuntimeException& )
- {
- throw;
- }
- catch (uno::Exception const& e)
- {
- SAL_WARN("embeddedobj.ole", "OleEmbeddedObject::doVerb: "
- "-9 fallback path: exception caught: " << e.Message);
- }
+ m_xOwnView = new OwnView_Impl( m_xFactory, m_xObjectStream->getInputStream() );
}
-
- // it may be the OLE Storage, try to extract stream
- if ( !m_xOwnView.is() && m_xObjectStream.is() && m_aFilterName == "Text" )
+ catch( uno::RuntimeException& )
{
- uno::Reference< io::XStream > xStream = lcl_ExtractObjectStream( m_xFactory, m_xObjectStream );
-
- if ( TryToConvertToOOo( xStream ) )
- {
- changeState( embed::EmbedStates::ACTIVE );
- return;
- }
+ throw;
}
-
- if (!m_xOwnView.is() || !m_xOwnView->Open())
+ catch (uno::Exception const& e)
{
- //Make a RO copy and see if the OS can find something to at
- //least display the content for us
- if (m_aTempDumpURL.isEmpty())
- m_aTempDumpURL = lcl_ExtractObject(m_xFactory, m_xObjectStream);
+ SAL_WARN("embeddedobj.ole", "OleEmbeddedObject::doVerb: "
+ "-9 fallback path: exception caught: " << e.Message);
+ }
+ }
- if (!m_aTempDumpURL.isEmpty())
- {
- uno::Reference< css::system::XSystemShellExecute > xSystemShellExecute(
- css::system::SystemShellExecute::create(comphelper::getComponentContext(m_xFactory)) );
- xSystemShellExecute->execute(m_aTempDumpURL, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY);
- }
- else
- throw embed::UnreachableStateException();
+ // it may be the OLE Storage, try to extract stream
+ if ( !m_xOwnView.is() && m_xObjectStream.is() && m_aFilterName == "Text" )
+ {
+ uno::Reference< io::XStream > xStream = lcl_ExtractObjectStream( m_xFactory, m_xObjectStream );
+
+ if ( TryToConvertToOOo( xStream ) )
+ {
+ changeState( embed::EmbedStates::ACTIVE );
+ return;
}
}
- else
+
+ if (!m_xOwnView.is() || !m_xOwnView->Open())
{
+ //Make a RO copy and see if the OS can find something to at
+ //least display the content for us
+ if (m_aTempDumpURL.isEmpty())
+ m_aTempDumpURL = lcl_ExtractObject(m_xFactory, m_xObjectStream);
+
+ if (m_aTempDumpURL.isEmpty())
+ throw embed::UnreachableStateException();
+
+ uno::Reference< css::system::XSystemShellExecute > xSystemShellExecute(
+ css::system::SystemShellExecute::create(comphelper::getComponentContext(m_xFactory)) );
+ xSystemShellExecute->execute(m_aTempDumpURL, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY);
- throw embed::UnreachableStateException();
}
+
}
}
diff --git a/embeddedobj/source/msole/olepersist.cxx b/embeddedobj/source/msole/olepersist.cxx
index cff38074655a..b8a42b373bc2 100644
--- a/embeddedobj/source/msole/olepersist.cxx
+++ b/embeddedobj/source/msole/olepersist.cxx
@@ -120,15 +120,12 @@ OUString GetNewFilledTempFile_Impl( const uno::Reference< io::XInputStream >& xI
ucb::SimpleFileAccess::create( comphelper::getComponentContext(xFactory) ) );
uno::Reference< io::XOutputStream > xTempOutStream = xTempAccess->openFileWrite( aResult );
- if ( xTempOutStream.is() )
- {
- // copy stream contents to the file
- ::comphelper::OStorageHelper::CopyInputToOutput( xInStream, xTempOutStream );
- xTempOutStream->closeOutput();
- xTempOutStream.clear();
- }
- else
+ if ( !xTempOutStream.is() )
throw io::IOException(); // TODO:
+ // copy stream contents to the file
+ ::comphelper::OStorageHelper::CopyInputToOutput( xInStream, xTempOutStream );
+ xTempOutStream->closeOutput();
+ xTempOutStream.clear();
}
catch( const packages::WrongPasswordException& )
{
@@ -267,14 +264,10 @@ uno::Reference< io::XStream > OleEmbeddedObject::GetNewFilledTempStream_Impl( co
uno::UNO_QUERY_THROW );
uno::Reference< io::XOutputStream > xTempOutStream = xTempFile->getOutputStream();
- if ( xTempOutStream.is() )
- {
- ::comphelper::OStorageHelper::CopyInputToOutput( xInStream, xTempOutStream );
- xTempOutStream->flush();
- }
- else
+ if ( !xTempOutStream.is() )
throw io::IOException(); // TODO:
-
+ ::comphelper::OStorageHelper::CopyInputToOutput( xInStream, xTempOutStream );
+ xTempOutStream->flush();
return xTempFile;
}
@@ -388,110 +381,108 @@ void OleEmbeddedObject::InsertVisualCache_Impl( const uno::Reference< io::XStrea
uno::Reference< io::XSeekable > xTempSeek( xTempFile, uno::UNO_QUERY_THROW );
uno::Reference< io::XOutputStream > xTempOutStream = xTempFile->getOutputStream();
- if ( xTempOutStream.is() )
- {
- // the OlePres stream must have additional header
- // TODO/LATER: might need to be extended in future (actually makes sense only for SO7 format)
- uno::Reference< io::XInputStream > xInCacheStream = xCachedVisualRepresentation->getInputStream();
- if ( !xInCacheStream.is() )
- throw uno::RuntimeException();
+ if ( !xTempOutStream.is() )
+ throw io::IOException(); // TODO:
- // write 0xFFFFFFFF at the beginning
- uno::Sequence< sal_Int8 > aData( 4 );
- * reinterpret_cast<sal_uInt32*>(aData.getArray()) = 0xFFFFFFFF;
+ // the OlePres stream must have additional header
+ // TODO/LATER: might need to be extended in future (actually makes sense only for SO7 format)
+ uno::Reference< io::XInputStream > xInCacheStream = xCachedVisualRepresentation->getInputStream();
+ if ( !xInCacheStream.is() )
+ throw uno::RuntimeException();
- xTempOutStream->writeBytes( aData );
+ // write 0xFFFFFFFF at the beginning
+ uno::Sequence< sal_Int8 > aData( 4 );
+ * reinterpret_cast<sal_uInt32*>(aData.getArray()) = 0xFFFFFFFF;
- // write clipboard format
- uno::Sequence< sal_Int8 > aSigData( 2 );
- xInCacheStream->readBytes( aSigData, 2 );
- if ( aSigData.getLength() < 2 )
- throw io::IOException();
+ xTempOutStream->writeBytes( aData );
- if ( aSigData[0] == 'B' && aSigData[1] == 'M' )
- {
- // it's a bitmap
- aData[0] = 0x02; aData[1] = 0; aData[2] = 0; aData[3] = 0;
- }
- else
- {
- // treat it as a metafile
- aData[0] = 0x03; aData[1] = 0; aData[2] = 0; aData[3] = 0;
- }
- xTempOutStream->writeBytes( aData );
+ // write clipboard format
+ uno::Sequence< sal_Int8 > aSigData( 2 );
+ xInCacheStream->readBytes( aSigData, 2 );
+ if ( aSigData.getLength() < 2 )
+ throw io::IOException();
- // write job related information
- aData[0] = 0x04; aData[1] = 0; aData[2] = 0; aData[3] = 0;
- xTempOutStream->writeBytes( aData );
+ if ( aSigData[0] == 'B' && aSigData[1] == 'M' )
+ {
+ // it's a bitmap
+ aData[0] = 0x02; aData[1] = 0; aData[2] = 0; aData[3] = 0;
+ }
+ else
+ {
+ // treat it as a metafile
+ aData[0] = 0x03; aData[1] = 0; aData[2] = 0; aData[3] = 0;
+ }
+ xTempOutStream->writeBytes( aData );
- // write aspect
- aData[0] = 0x01; aData[1] = 0; aData[2] = 0; aData[3] = 0;
- xTempOutStream->writeBytes( aData );
+ // write job related information
+ aData[0] = 0x04; aData[1] = 0; aData[2] = 0; aData[3] = 0;
+ xTempOutStream->writeBytes( aData );
- // write l-index
- * reinterpret_cast<sal_uInt32*>(aData.getArray()) = 0xFFFFFFFF;
- xTempOutStream->writeBytes( aData );
+ // write aspect
+ aData[0] = 0x01; aData[1] = 0; aData[2] = 0; aData[3] = 0;
+ xTempOutStream->writeBytes( aData );
- // write adv. flags
- aData[0] = 0x02; aData[1] = 0; aData[2] = 0; aData[3] = 0;
- xTempOutStream->writeBytes( aData );
+ // write l-index
+ * reinterpret_cast<sal_uInt32*>(aData.getArray()) = 0xFFFFFFFF;
+ xTempOutStream->writeBytes( aData );
- // write compression
- * reinterpret_cast<sal_uInt32*>(aData.getArray()) = 0x0;
- xTempOutStream->writeBytes( aData );
+ // write adv. flags
+ aData[0] = 0x02; aData[1] = 0; aData[2] = 0; aData[3] = 0;
+ xTempOutStream->writeBytes( aData );
- // get the size
- awt::Size aSize = getVisualAreaSize( embed::Aspects::MSOLE_CONTENT );
- sal_Int32 nIndex = 0;
+ // write compression
+ * reinterpret_cast<sal_uInt32*>(aData.getArray()) = 0x0;
+ xTempOutStream->writeBytes( aData );
- // write width
- for ( nIndex = 0; nIndex < 4; nIndex++ )
- {
- aData[nIndex] = (sal_Int8)( aSize.Width % 0x100 );
- aSize.Width /= 0x100;
- }
- xTempOutStream->writeBytes( aData );
-
- // write height
- for ( nIndex = 0; nIndex < 4; nIndex++ )
- {
- aData[nIndex] = (sal_Int8)( aSize.Height % 0x100 );
- aSize.Height /= 0x100;
- }
- xTempOutStream->writeBytes( aData );
+ // get the size
+ awt::Size aSize = getVisualAreaSize( embed::Aspects::MSOLE_CONTENT );
+ sal_Int32 nIndex = 0;
- // write garbage, it will be overwritten by the size
- xTempOutStream->writeBytes( aData );
+ // write width
+ for ( nIndex = 0; nIndex < 4; nIndex++ )
+ {
+ aData[nIndex] = (sal_Int8)( aSize.Width % 0x100 );
+ aSize.Width /= 0x100;
+ }
+ xTempOutStream->writeBytes( aData );
- // write first bytes that was used to detect the type
- xTempOutStream->writeBytes( aSigData );
+ // write height
+ for ( nIndex = 0; nIndex < 4; nIndex++ )
+ {
+ aData[nIndex] = (sal_Int8)( aSize.Height % 0x100 );
+ aSize.Height /= 0x100;
+ }
+ xTempOutStream->writeBytes( aData );
- // write the rest of the stream
- ::comphelper::OStorageHelper::CopyInputToOutput( xInCacheStream, xTempOutStream );
+ // write garbage, it will be overwritten by the size
+ xTempOutStream->writeBytes( aData );
- // write the size of the stream
- sal_Int64 nLength = xTempSeek->getLength() - 40;
- if ( nLength < 0 || nLength >= 0xFFFFFFFF )
- {
- SAL_WARN( "embeddedobj.ole", "Length is not acceptable!" );
- return;
- }
- for ( sal_Int32 nInd = 0; nInd < 4; nInd++ )
- {
- aData[nInd] = (sal_Int8)( ( (sal_uInt64) nLength ) % 0x100 );
- nLength /= 0x100;
- }
- xTempSeek->seek( 36 );
- xTempOutStream->writeBytes( aData );
+ // write first bytes that was used to detect the type
+ xTempOutStream->writeBytes( aSigData );
- xTempOutStream->flush();
+ // write the rest of the stream
+ ::comphelper::OStorageHelper::CopyInputToOutput( xInCacheStream, xTempOutStream );
- xTempSeek->seek( 0 );
- if ( xCachedSeek.is() )
- xCachedSeek->seek( 0 );
+ // write the size of the stream
+ sal_Int64 nLength = xTempSeek->getLength() - 40;
+ if ( nLength < 0 || nLength >= 0xFFFFFFFF )
+ {
+ SAL_WARN( "embeddedobj.ole", "Length is not acceptable!" );
+ return;
}
- else
- throw io::IOException(); // TODO:
+ for ( sal_Int32 nInd = 0; nInd < 4; nInd++ )
+ {
+ aData[nInd] = (sal_Int8)( ( (sal_uInt64) nLength ) % 0x100 );
+ nLength /= 0x100;
+ }
+ xTempSeek->seek( 36 );
+ xTempOutStream->writeBytes( aData );
+
+ xTempOutStream->flush();
+
+ xTempSeek->seek( 0 );
+ if ( xCachedSeek.is() )
+ xCachedSeek->seek( 0 );
// insert the result file as replacement image
OUString aCacheName = "\002OlePres000";
@@ -1164,7 +1155,7 @@ void OleEmbeddedObject::StoreToLocation_Impl(
}
}
#endif
- else
+ else if (true) // loplugin:flatten
{
throw io::IOException(); // TODO
}
@@ -1304,12 +1295,11 @@ void SAL_CALL OleEmbeddedObject::setPersistentEntry(
if ( m_bWaitSaveCompleted )
{
- if ( nEntryConnectionMode == embed::EntryInitModes::NO_INIT )
- saveCompleted( m_xParentStorage != xStorage || m_aEntryName != sEntName );
- else
+ if ( nEntryConnectionMode != embed::EntryInitModes::NO_INIT )
throw embed::WrongStateException(
"The object waits for saveCompleted() call!",
static_cast< ::cppu::OWeakObject* >(this) );
+ saveCompleted( m_xParentStorage != xStorage || m_aEntryName != sEntName );
}
uno::Reference< container::XNameAccess > xNameAccess( xStorage, uno::UNO_QUERY_THROW );