summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2015-12-28 19:27:56 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-08-31 14:18:52 +0000
commit9876ffe934a21df1df4a457aa88aa8441243dba9 (patch)
treec68b72f3b83232ed6fcc8902316cda13a4001c5e
parente8b19c216be98aa0dd7f837152fc5bc93cd0f367 (diff)
tdf#96749: deal with missing custom headers/footers in docx
Some custom headers and footers are referenced in docx but aren't present. See https://bugs.documentfoundation.org/show_bug.cgi?id=96749#c1 eg: warn:writerfilter:20417:1:writerfilter/source/filter/WriterFilter.cxx:214: WriterFilter::filter(): failed with exception Element does not exist and cannot be created: "header1.xml" See comment in bug: "The attached DOCX was generated by 1C:Enterprise -- extremely popular monopoly business CRM in Russia, with huge userbase (millions of installations)." This is apparently not a fatal condition in MS Word, so all we need to do is to return when we hit such a problem (resolveEmbeddingsStream is a recursive function). Change-Id: I0e085a5f07dc6cc044bbd713e8f81d67dbe5d8b2 Reviewed-on: https://gerrit.libreoffice.org/20993 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/qa/core/data/ooxml/pass/tdf96749.docxbin0 -> 6563 bytes
-rw-r--r--writerfilter/source/ooxml/OOXMLDocumentImpl.cxx17
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.cxx32
3 files changed, 38 insertions, 11 deletions
diff --git a/sw/qa/core/data/ooxml/pass/tdf96749.docx b/sw/qa/core/data/ooxml/pass/tdf96749.docx
new file mode 100644
index 000000000000..c7b79eec094d
--- /dev/null
+++ b/sw/qa/core/data/ooxml/pass/tdf96749.docx
Binary files differ
diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
index 6503fbdc3d83..ae8d8feb7301 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
@@ -186,7 +186,7 @@ void OOXMLDocumentImpl::importSubStreamRelations(const OOXMLStream::Pointer_t& p
OOXMLStream::Pointer_t cStream;
try
{
- cStream = OOXMLDocumentFactory::createStream(pStream, nType);
+ cStream = OOXMLDocumentFactory::createStream(pStream, nType);
}
catch (uno::Exception const& e)
{
@@ -763,9 +763,18 @@ void OOXMLDocumentImpl::resolveEmbeddingsStream(const OOXMLStream::Pointer_t& pS
}
if(bHeaderFooterFound)
{
- OOXMLStream::Pointer_t Stream = OOXMLDocumentFactory::createStream(pStream, streamType);
- if(Stream)
- resolveEmbeddingsStream(Stream);
+ try
+ {
+ OOXMLStream::Pointer_t Stream = OOXMLDocumentFactory::createStream(pStream, streamType);
+ if (Stream)
+ resolveEmbeddingsStream(Stream);
+ }
+ catch (uno::Exception const& e)
+ {
+ SAL_INFO("writerfilter", "resolveEmbeddingsStream: can't find header/footer whilst "
+ "resolving stream " << streamType << " : " << e.Message);
+ return;
+ }
}
beans::PropertyValue embeddingsTemp;
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index a69cbc63b0a7..c6730eb9a2af 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -21,11 +21,13 @@
#include <set>
#include <comphelper/servicehelper.hxx>
#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <com/sun/star/xml/sax/FastShapeContextHandler.hpp>
#include <ooxml/QNameToString.hxx>
#include <ooxml/resourceids.hxx>
#include <oox/token/namespaces.hxx>
#include <comphelper/embeddedobjectcontainer.hxx>
+#include <cppuhelper/exc_hlp.hxx>
#include <tools/globname.hxx>
#include <comphelper/classids.hxx>
#include <sfx2/sfxbasemodel.hxx>
@@ -930,18 +932,34 @@ void OOXMLFastContextHandlerProperties::lcl_endFastElement
(Token_t Element)
throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
{
- endAction(Element);
-
- if (mbResolve)
+ try
{
- if (isForwardEvents())
+ endAction(Element);
+
+ if (mbResolve)
{
- mpStream->props(mpPropertySet);
+ if (isForwardEvents())
+ {
+ mpStream->props(mpPropertySet);
+ }
+ }
+ else
+ {
+ sendPropertiesToParent();
}
}
- else
+ catch (const uno::RuntimeException&)
+ {
+ throw;
+ }
+ catch (const xml::sax::SAXException&)
+ {
+ throw;
+ }
+ catch (const uno::Exception& e)
{
- sendPropertiesToParent();
+ auto a = cppu::getCaughtException();
+ throw lang::WrappedTargetRuntimeException(e.Message, e.Context, a);
}
}