commit 3f07ae9083ab7299f9bc63a8f7749ce94e9aea6e
Author: Thibaut Cuvelier <[email protected]>
Date: Fri Nov 27 05:19:27 2020 +0100
DocBook: for empty figures, output a message.
This ensures that this part of the DocBook file is valid.
---
development/autotests/invertedTests | 2 +-
src/insets/InsetFloat.cpp | 28 +++++++++++++++++++++++++---
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/development/autotests/invertedTests
b/development/autotests/invertedTests
index e40d0d8..edf4c59 100644
--- a/development/autotests/invertedTests
+++ b/development/autotests/invertedTests
@@ -498,7 +498,7 @@ export/examples/(es|fr)/Modules/Linguistics_docbook5
export/examples/ko/cjk-ko-doc_docbook5
# - Metadata in abstract paragraph.
export/templates/Articles/Springers_Global_Journal_Template_%28V._3%29_docbook5
-# - Sweave impossible to implement. Document irremediably wrong (no .bib file,
still referenced in the text).
+# - Sweave impossible to implement. Broken references (no .bib file, still
referenced in the text).
export/templates/Articles/R_Journal_docbook5
# - Forbidden inlines, equation in formatting, broken references, float in
paragraphs, videos.
export/templates/Articles/REVTeX_%28V._4.1%29_docbook5
diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index 2dfd53c..e432fa0 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -731,6 +731,11 @@ void docbookNoSubfigures(XMLStream & xs, OutputParams
const & runparams, const I
if (ftype.docbookFloatType() == "table")
rpNoTitle.docbook_in_table = true;
+ // Generate the contents of the float (to check for emptiness).
+ odocstringstream os2;
+ XMLStream xs2(os2);
+ thisFloat->InsetText::docbook(xs, rpNoTitle);
+
// Organisation: <float> <title if any/> <contents without title/>
</float>.
docstring attr = docstring();
if (label)
@@ -749,7 +754,24 @@ void docbookNoSubfigures(XMLStream & xs, OutputParams
const & runparams, const I
xs << xml::EndTag(titleTag);
xs << xml::CR();
}
- thisFloat->InsetText::docbook(xs, rpNoTitle);
+
+ if (!os2.str().empty()) {
+ xs << XMLStream::ESCAPE_NONE << os2.str();
+ } else {
+ xs << xml::StartTag("mediaobject");
+ xs << xml::CR();
+ xs << xml::StartTag("textobject");
+ xs << xml::CR();
+ xs << xml::StartTag("phrase");
+ xs << "This figure is empty.";
+ xs << xml::EndTag("phrase");
+ xs << xml::CR();
+ xs << xml::EndTag("textobject");
+ xs << xml::CR();
+ xs << xml::EndTag("mediaobject");
+ xs << xml::CR();
+ }
+
xs << xml::EndTag(ftype.docbookTag(caption != nullptr));
xs << xml::CR();
}
@@ -777,8 +799,8 @@ void InsetFloat::docbook(XMLStream & xs, OutputParams const
& runparams) const
}
// Gather a few things from global environment that are shared between
all following cases.
- FloatList const &floats = buffer().params().documentClass().floats();
- Floating const &ftype = floats.getType(params_.type);
+ FloatList const & floats = buffer().params().documentClass().floats();
+ Floating const & ftype = floats.getType(params_.type);
// Switch on subfigures.
if (!subfigures.empty())
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs