summaryrefslogtreecommitdiff
path: root/xmloff/source
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2024-11-21 13:57:14 +0500
committerMike Kaganski <mike.kaganski@collabora.com>2024-11-21 12:47:15 +0100
commit512ef23224987e3107e66241db3b42934e15a561 (patch)
tree70d976da96bb969e19036ef3721c72df48fff4d3 /xmloff/source
parenta1a21ca3d4a8c36620fcb2e2af0b6ddd300f6739 (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
Diffstat (limited to 'xmloff/source')
-rw-r--r--xmloff/source/text/XMLFootnoteImportContext.cxx14
-rw-r--r--xmloff/source/text/XMLFootnoteImportContext.hxx1
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;