summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--filter/source/svg/svgfilter.cxx56
-rw-r--r--sdext/source/pdfimport/filterdet.cxx107
2 files changed, 86 insertions, 77 deletions
diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index b3a56dffb630..0f20f8f9a832 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -360,32 +360,36 @@ OUString SAL_CALL SVGFilter::detect(Sequence<PropertyValue>& rDescriptor) throw
if (!xInput.is())
return OUString();
- if (isStreamGZip(xInput))
- {
- boost::scoped_ptr<SvStream> aStream(utl::UcbStreamHelper::CreateStream(xInput, true ));
- if(!aStream.get())
- return OUString();
-
- SvStream* pMemoryStream = new SvMemoryStream;
- uno::Reference<io::XSeekable> xSeek(xInput, uno::UNO_QUERY);
- if (!xSeek.is())
- return OUString();
- xSeek->seek(0);
-
- ZCodec aCodec;
- aCodec.BeginCompression(ZCODEC_DEFAULT_COMPRESSION, false, true);
- aCodec.Decompress(*aStream.get(), *pMemoryStream);
- aCodec.EndCompression();
- pMemoryStream->Seek(STREAM_SEEK_TO_BEGIN);
- uno::Reference<io::XInputStream> xDecompressedInput(new utl::OSeekableInputStreamWrapper(pMemoryStream, true));
-
- if (xDecompressedInput.is() && isStreamSvg(xDecompressedInput))
- return OUString(constFilterName);
- }
- else
- {
- if (isStreamSvg(xInput))
- return OUString(constFilterName);
+ try {
+ if (isStreamGZip(xInput))
+ {
+ boost::scoped_ptr<SvStream> aStream(utl::UcbStreamHelper::CreateStream(xInput, true ));
+ if(!aStream.get())
+ return OUString();
+
+ SvStream* pMemoryStream = new SvMemoryStream;
+ uno::Reference<io::XSeekable> xSeek(xInput, uno::UNO_QUERY);
+ if (!xSeek.is())
+ return OUString();
+ xSeek->seek(0);
+
+ ZCodec aCodec;
+ aCodec.BeginCompression(ZCODEC_DEFAULT_COMPRESSION, false, true);
+ aCodec.Decompress(*aStream.get(), *pMemoryStream);
+ aCodec.EndCompression();
+ pMemoryStream->Seek(STREAM_SEEK_TO_BEGIN);
+ uno::Reference<io::XInputStream> xDecompressedInput(new utl::OSeekableInputStreamWrapper(pMemoryStream, true));
+
+ if (xDecompressedInput.is() && isStreamSvg(xDecompressedInput))
+ return OUString(constFilterName);
+ }
+ else
+ {
+ if (isStreamSvg(xInput))
+ return OUString(constFilterName);
+ }
+ } catch (css::io::IOException & e) {
+ SAL_WARN("filter", "caught IOException " + e.Message);
}
return OUString();
}
diff --git a/sdext/source/pdfimport/filterdet.cxx b/sdext/source/pdfimport/filterdet.cxx
index e966529f7eb2..af89ee742ae1 100644
--- a/sdext/source/pdfimport/filterdet.cxx
+++ b/sdext/source/pdfimport/filterdet.cxx
@@ -229,73 +229,78 @@ OUString SAL_CALL PDFDetector::detect( uno::Sequence< beans::PropertyValue >& rF
}
if( xInput.is() )
{
- uno::Reference< io::XSeekable > xSeek( xInput, uno::UNO_QUERY );
- if( xSeek.is() )
- xSeek->seek( 0 );
- // read the first 1024 byte (see PDF reference implementation note 12)
- const sal_Int32 nHeaderSize = 1024;
- uno::Sequence< sal_Int8 > aBuf( nHeaderSize );
- sal_uInt64 nBytes = 0;
- nBytes = xInput->readBytes( aBuf, nHeaderSize );
- if( nBytes > 5 )
- {
- const sal_Int8* pBytes = aBuf.getConstArray();
- for( unsigned int i = 0; i < nBytes-5; i++ )
+ oslFileHandle aFile = NULL;
+ try {
+ uno::Reference< io::XSeekable > xSeek( xInput, uno::UNO_QUERY );
+ if( xSeek.is() )
+ xSeek->seek( 0 );
+ // read the first 1024 byte (see PDF reference implementation note 12)
+ const sal_Int32 nHeaderSize = 1024;
+ uno::Sequence< sal_Int8 > aBuf( nHeaderSize );
+ sal_uInt64 nBytes = 0;
+ nBytes = xInput->readBytes( aBuf, nHeaderSize );
+ if( nBytes > 5 )
{
- if( pBytes[i] == '%' &&
- pBytes[i+1] == 'P' &&
- pBytes[i+2] == 'D' &&
- pBytes[i+3] == 'F' &&
- pBytes[i+4] == '-' )
+ const sal_Int8* pBytes = aBuf.getConstArray();
+ for( unsigned int i = 0; i < nBytes-5; i++ )
{
- bSuccess = true;
- break;
+ if( pBytes[i] == '%' &&
+ pBytes[i+1] == 'P' &&
+ pBytes[i+2] == 'D' &&
+ pBytes[i+3] == 'F' &&
+ pBytes[i+4] == '-' )
+ {
+ bSuccess = true;
+ break;
+ }
}
}
- }
- // check for hybrid PDF
- oslFileHandle aFile = NULL;
- if( bSuccess &&
- ( aURL.isEmpty() || !comphelper::isFileUrl(aURL) )
- )
- {
- sal_uInt64 nWritten = 0;
- if( osl_createTempFile( NULL, &aFile, &aURL.pData ) != osl_File_E_None )
- {
- bSuccess = false;
- }
- else
+ // check for hybrid PDF
+ if( bSuccess &&
+ ( aURL.isEmpty() || !comphelper::isFileUrl(aURL) )
+ )
{
+ sal_uInt64 nWritten = 0;
+ if( osl_createTempFile( NULL, &aFile, &aURL.pData ) != osl_File_E_None )
+ {
+ bSuccess = false;
+ }
+ else
+ {
#if OSL_DEBUG_LEVEL > 1
- OSL_TRACE( "created temp file %s\n",
- OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 ).getStr() );
+ OSL_TRACE( "created temp file %s\n",
+ OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 ).getStr() );
#endif
- osl_writeFile( aFile, aBuf.getConstArray(), nBytes, &nWritten );
+ osl_writeFile( aFile, aBuf.getConstArray(), nBytes, &nWritten );
- OSL_ENSURE( nWritten == nBytes, "writing of header bytes failed" );
+ OSL_ENSURE( nWritten == nBytes, "writing of header bytes failed" );
- if( nWritten == nBytes )
- {
- const sal_uInt32 nBufSize = 4096;
- aBuf = uno::Sequence<sal_Int8>(nBufSize);
- // copy the bytes
- do
+ if( nWritten == nBytes )
{
- nBytes = xInput->readBytes( aBuf, nBufSize );
- if( nBytes > 0 )
+ const sal_uInt32 nBufSize = 4096;
+ aBuf = uno::Sequence<sal_Int8>(nBufSize);
+ // copy the bytes
+ do
{
- osl_writeFile( aFile, aBuf.getConstArray(), nBytes, &nWritten );
- if( nWritten != nBytes )
+ nBytes = xInput->readBytes( aBuf, nBufSize );
+ if( nBytes > 0 )
{
- bSuccess = false;
- break;
+ osl_writeFile( aFile, aBuf.getConstArray(), nBytes, &nWritten );
+ if( nWritten != nBytes )
+ {
+ bSuccess = false;
+ break;
+ }
}
- }
- } while( nBytes == nBufSize );
+ } while( nBytes == nBufSize );
+ }
}
+ osl_closeFile( aFile );
}
- osl_closeFile( aFile );
+ } catch (css::io::IOException & e) {
+ SAL_WARN("sdext.pdfimport", "caught IOException " + e.Message);
+ return OUString();
}
OUString aEmbedMimetype;
xEmbedStream = getAdditionalStream( aURL, aEmbedMimetype, aPwd, m_xContext, rFilterData, false );