]> git.lyx.org Git - lyx.git/commitdiff
DocBook: for empty figures, output a message.
authorThibaut Cuvelier <tcuvelier@lyx.org>
Fri, 27 Nov 2020 04:19:27 +0000 (05:19 +0100)
committerThibaut Cuvelier <tcuvelier@lyx.org>
Fri, 27 Nov 2020 04:19:27 +0000 (05:19 +0100)
This ensures that this part of the DocBook file is valid.

development/autotests/invertedTests
src/insets/InsetFloat.cpp

index e40d0d85e64dc3eb3ffe0eca6404e444b347aa27..edf4c597bf2b30954de492eae01d7888a6cda3fa 100644 (file)
@@ -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
index 2dfd53c9a9da79978149d70a19bc7794423b0788..e432fa05de10920e69dc72b4b8298327fc8bab5f 100644 (file)
@@ -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())