diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-11-21 13:57:14 +0500 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2024-11-22 11:15:50 +0100 |
commit | da0e4cdc4f6bf8e0e88a4dd0e00afdf68e59a883 (patch) | |
tree | def4699a1f90be0051db8d4c4d0280240b3f7946 /xmloff | |
parent | 1e35da78bcc7002b401313c8b39503403379715a (diff) |
tdf#163974: ignore nested footnotes on ODF import
That is a valid, but unsupported, markup, that is explicitly mentioned
in ODF 1.4 part 3 "Schema" sect. 6.3.4 "<text:note-body>":
Note: The schema allows for the inclusion of <text:note> elements as
a descendant of a child of the <text:note-body> element. While this
may be reasonable for note types, it is not reasonable for footnotes
and endnotes. Conforming consumers need not support notes inside notes.
(The "reasonable for note types" is obviously an editorial error from the time when ODF 1.1 text "reasonable for some future note types"
was reviewed for ODF 1.2.)
As the ODF also specifies, that a conforming consumer "need not
interpret the semantics of all elements, attributes and attribute values"
(ibid., sect. 2.4 "Consumer"), it is OK to silently drop this data, just
as done for other similar cases.
Change-Id: I0a417981087ebf225565628f14409661058d100d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176906
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
(cherry picked from commit 512ef23224987e3107e66241db3b42934e15a561)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176919
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/text/XMLFootnoteImportContext.cxx | 14 | ||||
-rw-r--r-- | xmloff/source/text/XMLFootnoteImportContext.hxx | 1 |
2 files changed, 14 insertions, 1 deletions
diff --git a/xmloff/source/text/XMLFootnoteImportContext.cxx b/xmloff/source/text/XMLFootnoteImportContext.cxx index a73147ec09f1..fc9605bd8651 100644 --- a/xmloff/source/text/XMLFootnoteImportContext.cxx +++ b/xmloff/source/text/XMLFootnoteImportContext.cxx @@ -19,6 +19,7 @@ #include "XMLFootnoteImportContext.hxx" +#include <comphelper/diagnose_ex.hxx> #include <rtl/ustring.hxx> #include <sal/log.hxx> #include <xmloff/xmlimp.hxx> @@ -102,7 +103,16 @@ void XMLFootnoteImportContext::startFastElement( // save old cursor and install new one xOldCursor = rHelper.GetCursor(); Reference<XText> xText(xTextContent, UNO_QUERY); - rHelper.SetCursor(xText->createTextCursor()); + try + { + // May fail e.g. for a nested footnote, which is formally a valid ODF, but is not supported + rHelper.SetCursor(xText->createTextCursor()); + } + catch (css::uno::RuntimeException&) + { + TOOLS_WARN_EXCEPTION("xmloff.text", "skipping the footnote: caught"); + mbIsValid = false; + } // remember old list item and block (#89891#) and reset them // for the footnote @@ -132,6 +142,8 @@ void XMLFootnoteImportContext::endFastElement(sal_Int32 ) css::uno::Reference< css::xml::sax::XFastContextHandler > XMLFootnoteImportContext::createFastChildContext( sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { + if (!mbIsValid) + return {}; SvXMLImportContextRef xContext; switch(nElement) diff --git a/xmloff/source/text/XMLFootnoteImportContext.hxx b/xmloff/source/text/XMLFootnoteImportContext.hxx index d05b7b631c22..8321639bbd1a 100644 --- a/xmloff/source/text/XMLFootnoteImportContext.hxx +++ b/xmloff/source/text/XMLFootnoteImportContext.hxx @@ -42,6 +42,7 @@ class XMLFootnoteImportContext : public SvXMLImportContext /// old list item and block (#89891#) bool mbListContextPushed; + bool mbIsValid = true; /// text import helper; holds current XTextCursor (and XText) XMLTextImportHelper& rHelper; |