commit 7437a6ce3c8c79cc734411e3b55391b9528fbbbb
Author: Thibaut Cuvelier <[email protected]>
Date: Fri Nov 27 23:44:48 2020 +0100
DocBook: fix regression in floats.
Also implement a valid filler for tables.
---
.../docbook/table_float_regression_Intro.xml | 9 +--
src/insets/InsetFloat.cpp | 68 ++++++++++++++-----
2 files changed, 52 insertions(+), 25 deletions(-)
diff --git a/autotests/export/docbook/table_float_regression_Intro.xml
b/autotests/export/docbook/table_float_regression_Intro.xml
index 28ddb2e..873a65b 100644
--- a/autotests/export/docbook/table_float_regression_Intro.xml
+++ b/autotests/export/docbook/table_float_regression_Intro.xml
@@ -6,6 +6,8 @@
<section>
<title>La philosophie de LyX</title>
<para>Le tableau <xref linkend="tab.Unit-s" /> décrit les unités
utilisées dans LyX.</para>
+<table xml:id="tab.Unit-s">
+<caption>Unités</caption>
<tbody>
<tr>
<td align='center' valign='top'>unité</td>
@@ -95,13 +97,6 @@
<td align='center' valign='top'>unité mathématique (1 mu =
1/18 em)</td>
</tr>
</tbody>
-<table xml:id="tab.Unit-s">
-<caption>Unités</caption>
-<mediaobject>
-<textobject>
-<phrase>This figure is empty.</phrase>
-</textobject>
-</mediaobject>
</table>
</section>
</article>
\ No newline at end of file
diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index e432fa0..6500d58 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -714,11 +714,47 @@ void docbookSubfigures(XMLStream & xs, OutputParams const
& runparams, const Ins
}
+void docbookGenerateFillerMedia(XMLStream & xs)
+{
+ 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();
+}
+
+
+void docbookGenerateFillerTable(XMLStream & xs, BufferParams::TableOutput
format)
+{
+ switch (format) {
+ case BufferParams::HTMLTable:
+ xs << xml::StartTag("tr");
+ xs << xml::CR();
+ xs << xml::StartTag("td");
+ xs << "This table is empty.";
+ xs << xml::EndTag("td");
+ xs << xml::CR();
+ xs << xml::EndTag("tr");
+ xs << xml::CR();
+ break;
+ case BufferParams::CALSTable:
+ // CALS tables allow for <mediaobject>, use that instead.
+ docbookGenerateFillerMedia(xs);
+ break;
+ }
+}
+
+
void docbookNoSubfigures(XMLStream & xs, OutputParams const & runparams, const
InsetCaption * caption,
const InsetLabel * label, Floating const & ftype,
const InsetFloat * thisFloat)
{
- string const &titleTag = ftype.docbookCaption();
-
// Ensure there is no label output, it is supposed to be handled as
xml:id.
OutputParams rpNoLabel = runparams;
if (label)
@@ -734,7 +770,7 @@ void docbookNoSubfigures(XMLStream & xs, OutputParams const
& runparams, const I
// Generate the contents of the float (to check for emptiness).
odocstringstream os2;
XMLStream xs2(os2);
- thisFloat->InsetText::docbook(xs, rpNoTitle);
+ thisFloat->InsetText::docbook(xs2, rpNoTitle);
// Organisation: <float> <title if any/> <contents without title/>
</float>.
docstring attr = docstring();
@@ -746,32 +782,28 @@ void docbookNoSubfigures(XMLStream & xs, OutputParams
const & runparams, const I
attr += from_utf8(ftype.docbookAttr());
}
+ // - Open the float tag.
xs << xml::StartTag(ftype.docbookTag(caption != nullptr), attr);
xs << xml::CR();
+
+ // - Generate the caption.
if (caption) {
+ string const &titleTag = ftype.docbookCaption();
xs << xml::StartTag(titleTag);
caption->getCaptionAsDocBook(xs, rpNoLabel);
xs << xml::EndTag(titleTag);
xs << xml::CR();
}
- if (!os2.str().empty()) {
+ // - Output the actual content of the float.
+ 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();
- }
+ else if (ftype.docbookFloatType() == "table")
+ docbookGenerateFillerTable(xs,
thisFloat->buffer().params().docbook_table_output);
+ else
+ docbookGenerateFillerMedia(xs);
+ // - Close the float.
xs << xml::EndTag(ftype.docbookTag(caption != nullptr));
xs << xml::CR();
}
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs