From 7437a6ce3c8c79cc734411e3b55391b9528fbbbb Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Fri, 27 Nov 2020 23:44:48 +0100 Subject: [PATCH] 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 28ddb2ecb0..873a65b11d 100644 --- a/autotests/export/docbook/table_float_regression_Intro.xml +++ b/autotests/export/docbook/table_float_regression_Intro.xml @@ -6,6 +6,8 @@
La philosophie de LyX Le tableau  décrit les unités utilisées dans LyX. + + @@ -95,13 +97,6 @@ -
Unités
unitéunité mathématique (1 mu = 1/18 em)
- - - -This figure is empty. - -
Unités
\ No newline at end of file diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index e432fa05de..6500d5883b 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 , 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: <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(); }