summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2012-09-21 21:32:11 +0100
committerMichael Meeks <michael.meeks@suse.com>2012-09-21 21:33:59 +0100
commitff300e59e74ee88aa6a4981b57a51af416c9e991 (patch)
treefd927304bd49c3bea36f63d1da892628c5ba3c60
parent6ba1a664a94cfbfbc7c280b15cee35122710ff86 (diff)
fdo#49819 - allow slightly inconsistent docx files to be repaired
-rw-r--r--sfx2/source/doc/objstor.cxx8
-rw-r--r--writerfilter/inc/dmapper/DomainMapper.hxx3
-rw-r--r--writerfilter/inc/ooxml/OOXMLDocument.hxx1
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx6
-rw-r--r--writerfilter/source/filter/ImportFilter.cxx7
-rw-r--r--writerfilter/source/filter/RtfFilter.cxx3
-rw-r--r--writerfilter/source/ooxml/OOXMLStreamImpl.cxx9
-rw-r--r--writerfilter/source/ooxml/OOXMLStreamImpl.hxx2
-rw-r--r--writerfilter/unocomponent/debugservices/ooxml/OOXMLAnalyzeService.cxx2
-rw-r--r--writerfilter/unocomponent/debugservices/ooxml/OOXMLTestService.cxx2
10 files changed, 27 insertions, 16 deletions
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index cf8d0c264f51..9e7407a7ea65 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -33,6 +33,7 @@
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/document/FilterOptionsRequest.hpp>
#include <com/sun/star/document/XInteractionFilterOptions.hpp>
+#include <com/sun/star/packages/zip/ZipIOException.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp>
#include <com/sun/star/task/XInteractionAskLater.hpp>
#include <com/sun/star/task/FutureDocumentVersionProductUpdateRequest.hpp>
@@ -2219,7 +2220,12 @@ sal_Bool SfxObjectShell::ImportFrom( SfxMedium& rMedium, bool bInsert )
}
return xLoader->filter( aArgs );
- }catch(...)
+ }
+ catch (const packages::zip::ZipIOException&)
+ {
+ SetError( ERRCODE_IO_BROKENPACKAGE, "Badness in the underlying package format." );
+ }
+ catch(...)
{}
}
diff --git a/writerfilter/inc/dmapper/DomainMapper.hxx b/writerfilter/inc/dmapper/DomainMapper.hxx
index 4dbbe87e5b5e..1d9b2f0d9500 100644
--- a/writerfilter/inc/dmapper/DomainMapper.hxx
+++ b/writerfilter/inc/dmapper/DomainMapper.hxx
@@ -80,7 +80,8 @@ public:
DomainMapper(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xInputStream,
::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModel,
- SourceDocumentType eDocumentType );
+ bool bRepairStorage,
+ SourceDocumentType eDocumentType);
virtual ~DomainMapper();
// Stream
diff --git a/writerfilter/inc/ooxml/OOXMLDocument.hxx b/writerfilter/inc/ooxml/OOXMLDocument.hxx
index f3365dbc4cf5..c97e2b2b08c0 100644
--- a/writerfilter/inc/ooxml/OOXMLDocument.hxx
+++ b/writerfilter/inc/ooxml/OOXMLDocument.hxx
@@ -248,6 +248,7 @@ public:
static OOXMLStream::Pointer_t
createStream(uno::Reference<uno::XComponentContext> rContext,
uno::Reference<io::XInputStream> rStream,
+ bool bRepairStorage,
OOXMLStream::StreamType_t nStreamType = OOXMLStream::DOCUMENT);
static OOXMLStream::Pointer_t
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 38a99611a7f0..cd4a17c09d9a 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -88,7 +88,8 @@ struct _PageSz
DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xContext,
uno::Reference< io::XInputStream > xInputStream,
uno::Reference< lang::XComponent > xModel,
- SourceDocumentType eDocumentType) :
+ bool bRepairStorage,
+ SourceDocumentType eDocumentType ) :
LoggedProperties(dmapper_logger, "DomainMapper"),
LoggedTable(dmapper_logger, "DomainMapper"),
LoggedStream(dmapper_logger, "DomainMapper"),
@@ -101,12 +102,11 @@ LoggedStream(dmapper_logger, "DomainMapper"),
uno::makeAny( false ) );
//import document properties
-
try
{
uno::Reference< lang::XMultiServiceFactory > xFactory(xContext->getServiceManager(), uno::UNO_QUERY_THROW);
uno::Reference< embed::XStorage > xDocumentStorage =
- (comphelper::OStorageHelper::GetStorageOfFormatFromInputStream(OFOPXML_STORAGE_FORMAT_STRING, xInputStream));
+ (comphelper::OStorageHelper::GetStorageOfFormatFromInputStream(OFOPXML_STORAGE_FORMAT_STRING, xInputStream, xFactory, bRepairStorage ));
uno::Reference< uno::XInterface > xTemp = xContext->getServiceManager()->createInstanceWithContext(
"com.sun.star.document.OOXMLDocumentPropertiesImporter",
diff --git a/writerfilter/source/filter/ImportFilter.cxx b/writerfilter/source/filter/ImportFilter.cxx
index 2eef1c12c43f..207342ada465 100644
--- a/writerfilter/source/filter/ImportFilter.cxx
+++ b/writerfilter/source/filter/ImportFilter.cxx
@@ -63,6 +63,7 @@ sal_Bool WriterFilter::filter( const uno::Sequence< beans::PropertyValue >& aDes
else if (m_xDstDoc.is())
{
MediaDescriptor aMediaDesc( aDescriptor );
+ bool bRepairStorage = aMediaDesc.getUnpackedValueOrDefault( "RepairPackage", false );
OUString sFilterName = aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_FILTERNAME(), OUString() );
uno::Reference< io::XInputStream > xInputStream;
@@ -77,9 +78,7 @@ sal_Bool WriterFilter::filter( const uno::Sequence< beans::PropertyValue >& aDes
}
if ( !xInputStream.is() )
- {
return sal_False;
- }
#ifdef DEBUG_IMPORT
OUString sURL = aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_URL(), OUString() );
@@ -101,11 +100,11 @@ sal_Bool WriterFilter::filter( const uno::Sequence< beans::PropertyValue >& aDes
m_sFilterName == "writer_OOXML" || m_sFilterName == "writer_OOXML_Text_Template" ) ?
writerfilter::dmapper::DOCUMENT_OOXML : writerfilter::dmapper::DOCUMENT_DOC;
- writerfilter::Stream::Pointer_t pStream(new writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc, eType));
+ writerfilter::Stream::Pointer_t pStream(new writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc, bRepairStorage, eType));
//create the tokenizer and domain mapper
if( eType == writerfilter::dmapper::DOCUMENT_OOXML )
{
- writerfilter::ooxml::OOXMLStream::Pointer_t pDocStream = writerfilter::ooxml::OOXMLDocumentFactory::createStream(m_xContext, xInputStream);
+ writerfilter::ooxml::OOXMLStream::Pointer_t pDocStream = writerfilter::ooxml::OOXMLDocumentFactory::createStream(m_xContext, xInputStream, bRepairStorage);
writerfilter::ooxml::OOXMLDocument::Pointer_t pDocument(writerfilter::ooxml::OOXMLDocumentFactory::createDocument(pDocStream));
uno::Reference<frame::XModel> xModel(m_xDstDoc, uno::UNO_QUERY_THROW);
diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx
index b071449f1b1b..080f8adcbdf1 100644
--- a/writerfilter/source/filter/RtfFilter.cxx
+++ b/writerfilter/source/filter/RtfFilter.cxx
@@ -66,6 +66,7 @@ sal_Bool RtfFilter::filter( const uno::Sequence< beans::PropertyValue >& aDescri
try
{
MediaDescriptor aMediaDesc( aDescriptor );
+ bool bRepairStorage = aMediaDesc.getUnpackedValueOrDefault( "RepairPackage", false );
#ifdef DEBUG_IMPORT
OUString sURL = aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_URL(), OUString() );
::std::string sURLc = OUStringToOString(sURL, RTL_TEXTENCODING_ASCII_US).getStr();
@@ -87,7 +88,7 @@ sal_Bool RtfFilter::filter( const uno::Sequence< beans::PropertyValue >& aDescri
uno::Reference<task::XStatusIndicator>());
writerfilter::Stream::Pointer_t pStream(
- new writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc, writerfilter::dmapper::DOCUMENT_RTF));
+ new writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc, bRepairStorage, writerfilter::dmapper::DOCUMENT_RTF));
writerfilter::rtftok::RTFDocument::Pointer_t const pDocument(
writerfilter::rtftok::RTFDocumentFactory::createDocument(m_xContext, xInputStream, m_xDstDoc, xFrame, xStatusIndicator));
pDocument->resolve(*pStream);
diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
index 98747403278f..3ece742ab7fa 100644
--- a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
@@ -35,12 +35,14 @@ using namespace ::std;
OOXMLStreamImpl::OOXMLStreamImpl
(uno::Reference<uno::XComponentContext> xContext,
- uno::Reference<io::XInputStream> xStorageStream, StreamType_t nType)
+ uno::Reference<io::XInputStream> xStorageStream,
+ StreamType_t nType, bool bRepairStorage)
: mxContext(xContext), mxStorageStream(xStorageStream), mnStreamType(nType)
{
+ uno::Reference< lang::XMultiServiceFactory > xFactory(xContext->getServiceManager(), uno::UNO_QUERY_THROW);
mxStorage.set
(comphelper::OStorageHelper::GetStorageOfFormatFromInputStream
- (OFOPXML_STORAGE_FORMAT_STRING, mxStorageStream));
+ (OFOPXML_STORAGE_FORMAT_STRING, mxStorageStream, xFactory, bRepairStorage));
mxRelationshipAccess.set(mxStorage, uno::UNO_QUERY_THROW);
init();
@@ -297,10 +299,11 @@ OOXMLStream::Pointer_t
OOXMLDocumentFactory::createStream
(uno::Reference<uno::XComponentContext> xContext,
uno::Reference<io::XInputStream> rStream,
+ bool bRepairStorage,
OOXMLStream::StreamType_t nStreamType)
{
OOXMLStreamImpl * pStream = new OOXMLStreamImpl(xContext, rStream,
- nStreamType);
+ nStreamType, bRepairStorage);
return OOXMLStream::Pointer_t(pStream);
}
diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.hxx b/writerfilter/source/ooxml/OOXMLStreamImpl.hxx
index e5d3f33a596d..80065f691bfc 100644
--- a/writerfilter/source/ooxml/OOXMLStreamImpl.hxx
+++ b/writerfilter/source/ooxml/OOXMLStreamImpl.hxx
@@ -61,7 +61,7 @@ public:
OOXMLStreamImpl
(uno::Reference<uno::XComponentContext> xContext,
uno::Reference<io::XInputStream> xStorageStream,
- StreamType_t nType);
+ StreamType_t nType, bool bRepairStorage);
OOXMLStreamImpl(OOXMLStreamImpl & rStream, const OUString & rId);
virtual ~OOXMLStreamImpl();
diff --git a/writerfilter/unocomponent/debugservices/ooxml/OOXMLAnalyzeService.cxx b/writerfilter/unocomponent/debugservices/ooxml/OOXMLAnalyzeService.cxx
index 7abb841a3707..b8fd2428b565 100644
--- a/writerfilter/unocomponent/debugservices/ooxml/OOXMLAnalyzeService.cxx
+++ b/writerfilter/unocomponent/debugservices/ooxml/OOXMLAnalyzeService.cxx
@@ -173,7 +173,7 @@ sal_Int32 SAL_CALL AnalyzeService::run
{
ooxml::OOXMLStream::Pointer_t pDocStream =
ooxml::OOXMLDocumentFactory::createStream
- (xContext, xInputStream);
+ (xContext, xInputStream, false);
if (pDocStream.get() != NULL)
{
diff --git a/writerfilter/unocomponent/debugservices/ooxml/OOXMLTestService.cxx b/writerfilter/unocomponent/debugservices/ooxml/OOXMLTestService.cxx
index b6423f0cc4b7..4d1335b749bd 100644
--- a/writerfilter/unocomponent/debugservices/ooxml/OOXMLTestService.cxx
+++ b/writerfilter/unocomponent/debugservices/ooxml/OOXMLTestService.cxx
@@ -88,7 +88,7 @@ sal_Int32 SAL_CALL ScannerTestService::run( const uno::Sequence< OUString >& aAr
uno::Reference<io::XInputStream> xInputStream =
xFileAccess->openFileRead(absFileUrl);
ooxml::OOXMLStream::Pointer_t pDocStream =
- ooxml::OOXMLDocumentFactory::createStream(xContext, xInputStream);
+ ooxml::OOXMLDocumentFactory::createStream(xContext, xInputStream, false);
ooxml::OOXMLDocument::Pointer_t pDocument
(ooxml::OOXMLDocumentFactory::createDocument(pDocStream));