summaryrefslogtreecommitdiff
path: root/reportdesign
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-22 14:52:24 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-23 09:01:46 +0200
commit2684aefcf5d2804351bda01a2d2fe7bbbd351451 (patch)
tree5c19a705883a068a4945d7e49376296e341cb191 /reportdesign
parent1fde962b71860d77fb10e9b16c9d5b6c124d9b61 (diff)
new loplugin unnecessarycatchthrow
Change-Id: Iabab71ee076227bc38447ec109afaea1e53a86a6 Reviewed-on: https://gerrit.libreoffice.org/42643 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'reportdesign')
-rw-r--r--reportdesign/source/core/api/ReportDefinition.cxx62
-rw-r--r--reportdesign/source/core/api/ReportEngineJFree.cxx172
2 files changed, 111 insertions, 123 deletions
diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx
index ca6d941dcf50..a2a746474283 100644
--- a/reportdesign/source/core/api/ReportDefinition.cxx
+++ b/reportdesign/source/core/api/ReportDefinition.cxx
@@ -1484,46 +1484,40 @@ bool OReportDefinition::WriteThroughComponent(
{
OSL_ENSURE( nullptr != pStreamName, "Need stream name!" );
OSL_ENSURE( nullptr != pServiceName, "Need service name!" );
- try
+
+ // open stream
+ OUString sStreamName = OUString::createFromAscii( pStreamName );
+ uno::Reference<io::XStream> xStream = _xStorageToSaveTo->openStreamElement( sStreamName,embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
+ if ( !xStream.is() )
+ return false;
+ uno::Reference<io::XOutputStream> xOutputStream = xStream->getOutputStream();
+ OSL_ENSURE(xOutputStream.is(), "Can't create output stream in package!");
+ if ( ! xOutputStream.is() )
+ return false;
+
+ uno::Reference<beans::XPropertySet> xStreamProp(xOutputStream,uno::UNO_QUERY);
+ OSL_ENSURE(xStreamProp.is(),"No valid property set for the output stream!");
+
+ uno::Reference<io::XSeekable> xSeek(xStreamProp,uno::UNO_QUERY);
+ if ( xSeek.is() )
{
- // open stream
- OUString sStreamName = OUString::createFromAscii( pStreamName );
- uno::Reference<io::XStream> xStream = _xStorageToSaveTo->openStreamElement( sStreamName,embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
- if ( !xStream.is() )
- return false;
- uno::Reference<io::XOutputStream> xOutputStream = xStream->getOutputStream();
- OSL_ENSURE(xOutputStream.is(), "Can't create output stream in package!");
- if ( ! xOutputStream.is() )
- return false;
-
- uno::Reference<beans::XPropertySet> xStreamProp(xOutputStream,uno::UNO_QUERY);
- OSL_ENSURE(xStreamProp.is(),"No valid property set for the output stream!");
-
- uno::Reference<io::XSeekable> xSeek(xStreamProp,uno::UNO_QUERY);
- if ( xSeek.is() )
- {
- xSeek->seek(0);
- }
+ xSeek->seek(0);
+ }
- xStreamProp->setPropertyValue( "MediaType", uno::Any(OUString("text/xml")) );
+ xStreamProp->setPropertyValue( "MediaType", uno::Any(OUString("text/xml")) );
- // encrypt all streams
- xStreamProp->setPropertyValue( "UseCommonStoragePasswordEncryption",
+ // encrypt all streams
+ xStreamProp->setPropertyValue( "UseCommonStoragePasswordEncryption",
uno::makeAny( true ) );
- // set buffer and create outputstream
+ // set buffer and create outputstream
- // write the stuff
- bool bRet = WriteThroughComponent(
- xOutputStream, xComponent,
- pServiceName, rArguments, rMediaDesc );
- // finally, commit stream.
- return bRet;
- }
- catch (const uno::Exception&)
- {
- throw;
- }
+ // write the stuff
+ bool bRet = WriteThroughComponent(
+ xOutputStream, xComponent,
+ pServiceName, rArguments, rMediaDesc );
+ // finally, commit stream.
+ return bRet;
}
bool OReportDefinition::WriteThroughComponent(
diff --git a/reportdesign/source/core/api/ReportEngineJFree.cxx b/reportdesign/source/core/api/ReportEngineJFree.cxx
index 2a8b1cd0fb56..8b68da19e646 100644
--- a/reportdesign/source/core/api/ReportEngineJFree.cxx
+++ b/reportdesign/source/core/api/ReportEngineJFree.cxx
@@ -154,109 +154,103 @@ void SAL_CALL OReportEngineJFree::setStatusIndicator( const uno::Reference< task
OUString OReportEngineJFree::getNewOutputName()
{
- OUString sOutputName;
- {
- ::osl::MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(ReportEngineBase::rBHelper.bDisposed);
- if ( !m_xReport.is() || !m_xActiveConnection.is() )
- throw lang::IllegalArgumentException();
+ ::osl::MutexGuard aGuard(m_aMutex);
+ ::connectivity::checkDisposed(ReportEngineBase::rBHelper.bDisposed);
+ if ( !m_xReport.is() || !m_xActiveConnection.is() )
+ throw lang::IllegalArgumentException();
- static const char s_sMediaType[] = "MediaType";
- try
- {
- MimeConfigurationHelper aConfighelper(m_xContext);
- const OUString sMimeType = m_xReport->getMimeType();
- std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetDefaultFilter( aConfighelper.GetDocServiceNameFromMediaType(sMimeType) );
- OUString sExt(".rpt");
- if ( pFilter )
- sExt = ::comphelper::string::stripStart(pFilter->GetDefaultExtension(), '*');
-
- uno::Reference< embed::XStorage > xTemp = OStorageHelper::GetTemporaryStorage(/*sFileTemp,embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE,*/ m_xContext);
- utl::DisposableComponent aTemp(xTemp);
- uno::Sequence< beans::PropertyValue > aEmpty;
- uno::Reference< beans::XPropertySet> xStorageProp(xTemp,uno::UNO_QUERY);
- if ( xStorageProp.is() )
- {
- xStorageProp->setPropertyValue( s_sMediaType, uno::makeAny(sMimeType));
- }
- m_xReport->storeToStorage(xTemp,aEmpty); // store to temp file because it may contain information which isn't in the database yet.
-
- uno::Sequence< beans::NamedValue > aConvertedProperties(8);
- sal_Int32 nPos = 0;
- aConvertedProperties[nPos].Name = "InputStorage";
- aConvertedProperties[nPos++].Value <<= xTemp;
- aConvertedProperties[nPos].Name = "OutputStorage";
-
- OUString sFileURL;
- OUString sName = m_xReport->getCaption();
- if ( sName.isEmpty() )
- sName = m_xReport->getName();
- {
- ::utl::TempFile aTestFile(sName, false, &sExt);
- if ( !aTestFile.IsValid() )
- {
- sName = RptResId(RID_STR_REPORT);
- ::utl::TempFile aFile(sName, false, &sExt);
- sFileURL = aFile.GetURL();
- }
- else
- sFileURL = aTestFile.GetURL();
- }
+ static const char s_sMediaType[] = "MediaType";
- uno::Reference< embed::XStorage > xOut = OStorageHelper::GetStorageFromURL(sFileURL,embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE, m_xContext);
- utl::DisposableComponent aOut(xOut);
- xStorageProp.set(xOut,uno::UNO_QUERY);
- if ( xStorageProp.is() )
- {
- xStorageProp->setPropertyValue( s_sMediaType, uno::makeAny(sMimeType));
- }
+ MimeConfigurationHelper aConfighelper(m_xContext);
+ const OUString sMimeType = m_xReport->getMimeType();
+ std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetDefaultFilter( aConfighelper.GetDocServiceNameFromMediaType(sMimeType) );
+ OUString sExt(".rpt");
+ if ( pFilter )
+ sExt = ::comphelper::string::stripStart(pFilter->GetDefaultExtension(), '*');
- aConvertedProperties[nPos++].Value <<= xOut;
+ uno::Reference< embed::XStorage > xTemp = OStorageHelper::GetTemporaryStorage(/*sFileTemp,embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE,*/ m_xContext);
+ utl::DisposableComponent aTemp(xTemp);
+ uno::Sequence< beans::PropertyValue > aEmpty;
+ uno::Reference< beans::XPropertySet> xStorageProp(xTemp,uno::UNO_QUERY);
+ if ( xStorageProp.is() )
+ {
+ xStorageProp->setPropertyValue( s_sMediaType, uno::makeAny(sMimeType));
+ }
+ m_xReport->storeToStorage(xTemp,aEmpty); // store to temp file because it may contain information which isn't in the database yet.
+
+ uno::Sequence< beans::NamedValue > aConvertedProperties(8);
+ sal_Int32 nPos = 0;
+ aConvertedProperties[nPos].Name = "InputStorage";
+ aConvertedProperties[nPos++].Value <<= xTemp;
+ aConvertedProperties[nPos].Name = "OutputStorage";
+
+ OUString sFileURL;
+ OUString sName = m_xReport->getCaption();
+ if ( sName.isEmpty() )
+ sName = m_xReport->getName();
+ {
+ ::utl::TempFile aTestFile(sName, false, &sExt);
+ if ( !aTestFile.IsValid() )
+ {
+ sName = RptResId(RID_STR_REPORT);
+ ::utl::TempFile aFile(sName, false, &sExt);
+ sFileURL = aFile.GetURL();
+ }
+ else
+ sFileURL = aTestFile.GetURL();
+ }
- aConvertedProperties[nPos].Name = PROPERTY_REPORTDEFINITION;
- aConvertedProperties[nPos++].Value <<= m_xReport;
+ uno::Reference< embed::XStorage > xOut = OStorageHelper::GetStorageFromURL(sFileURL,embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE, m_xContext);
+ utl::DisposableComponent aOut(xOut);
+ xStorageProp.set(xOut,uno::UNO_QUERY);
+ if ( xStorageProp.is() )
+ {
+ xStorageProp->setPropertyValue( s_sMediaType, uno::makeAny(sMimeType));
+ }
- aConvertedProperties[nPos].Name = PROPERTY_ACTIVECONNECTION;
- aConvertedProperties[nPos++].Value <<= m_xActiveConnection;
+ aConvertedProperties[nPos++].Value <<= xOut;
- aConvertedProperties[nPos].Name = PROPERTY_MAXROWS;
- aConvertedProperties[nPos++].Value <<= m_nMaxRows;
+ aConvertedProperties[nPos].Name = PROPERTY_REPORTDEFINITION;
+ aConvertedProperties[nPos++].Value <<= m_xReport;
- // some meta data
- SvtUserOptions aUserOpts;
- OUStringBuffer sAuthor(aUserOpts.GetFirstName());
- sAuthor.append(" ");
- sAuthor.append(aUserOpts.GetLastName());
- aConvertedProperties[nPos].Name = "Author";
- aConvertedProperties[nPos++].Value <<= sAuthor.makeStringAndClear();
+ aConvertedProperties[nPos].Name = PROPERTY_ACTIVECONNECTION;
+ aConvertedProperties[nPos++].Value <<= m_xActiveConnection;
- aConvertedProperties[nPos].Name = "Title";
- aConvertedProperties[nPos++].Value <<= m_xReport->getCaption();
+ aConvertedProperties[nPos].Name = PROPERTY_MAXROWS;
+ aConvertedProperties[nPos++].Value <<= m_nMaxRows;
- // create job factory and initialize
- const OUString sReportEngineServiceName = ::dbtools::getDefaultReportEngineServiceName(m_xContext);
- uno::Reference<task::XJob> xJob(m_xContext->getServiceManager()->createInstanceWithContext(sReportEngineServiceName,m_xContext),uno::UNO_QUERY_THROW);
- if ( !m_xReport->getCommand().isEmpty() )
- {
- xJob->execute(aConvertedProperties);
- if ( xStorageProp.is() )
- {
- sOutputName = sFileURL;
- }
- }
+ // some meta data
+ SvtUserOptions aUserOpts;
+ OUStringBuffer sAuthor(aUserOpts.GetFirstName());
+ sAuthor.append(" ");
+ sAuthor.append(aUserOpts.GetLastName());
+ aConvertedProperties[nPos].Name = "Author";
+ aConvertedProperties[nPos++].Value <<= sAuthor.makeStringAndClear();
- uno::Reference<embed::XTransactedObject> xTransact(xOut,uno::UNO_QUERY);
- if ( !sOutputName.isEmpty() && xTransact.is() )
- xTransact->commit();
+ aConvertedProperties[nPos].Name = "Title";
+ aConvertedProperties[nPos++].Value <<= m_xReport->getCaption();
- if ( sOutputName.isEmpty() )
- throw lang::IllegalArgumentException();
- }
- catch(const uno::Exception&)
+ OUString sOutputName;
+
+ // create job factory and initialize
+ const OUString sReportEngineServiceName = ::dbtools::getDefaultReportEngineServiceName(m_xContext);
+ uno::Reference<task::XJob> xJob(m_xContext->getServiceManager()->createInstanceWithContext(sReportEngineServiceName,m_xContext),uno::UNO_QUERY_THROW);
+ if ( !m_xReport->getCommand().isEmpty() )
+ {
+ xJob->execute(aConvertedProperties);
+ if ( xStorageProp.is() )
{
- throw;
+ sOutputName = sFileURL;
}
}
+
+ uno::Reference<embed::XTransactedObject> xTransact(xOut,uno::UNO_QUERY);
+ if ( !sOutputName.isEmpty() && xTransact.is() )
+ xTransact->commit();
+
+ if ( sOutputName.isEmpty() )
+ throw lang::IllegalArgumentException();
+
return sOutputName;
}