commit 2cd7a94f8b31f1b59d002c4861585c32059c4269
Author: Thibaut Cuvelier <tcuvel...@lyx.org>
Date:   Thu Sep 3 00:48:55 2020 +0200

    DocBook: introduce Floating::docbookFloatType.
    
    This ensures that all comparisons for DocBook are made on the same 
normalised version of the float type. This cased a strange bug where <table> 
was output within <informaltable> for Linguistics Tableaux.
---
 autotests/export/docbook/Linguistics.xml |    2 --
 src/Floating.cpp                         |   27 +++++++++++++++++++++++----
 src/Floating.h                           |    2 ++
 src/insets/InsetFloat.cpp                |    2 +-
 4 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/autotests/export/docbook/Linguistics.xml 
b/autotests/export/docbook/Linguistics.xml
index 688ee2d..e7d7875 100644
--- a/autotests/export/docbook/Linguistics.xml
+++ b/autotests/export/docbook/Linguistics.xml
@@ -140,7 +140,6 @@ EndPreamble</programlisting>
 <para>Wenn Sie allerdings Ihre Tableaux durch das Dokument hindurch 
nummerieren und ein eigenes Tableaux-Verzeichnis einrichten möchten, reichen 
die Bordmittel von LyX nicht aus. Auch hier hilft das Linguistikmodul. Wenn es 
ausgewählt ist, finden Sie unter <emphasis 
role='sans'>Einfügen&#x21D2;Gleitobjekte</emphasis> zusätzlich ein 
Tableau-Gleitobjekt (siehe Tableau&#xA0;<xref linkend="tab.Beispiel-Tableau" /> 
für ein Beispiel).</para>
 <table xml:id="tab.Beispiel-Tableau">
 <caption>Beispiel-Tableau</caption>
-<informaltable>
 <tbody>
 <tr>
 <td align='right' valign='top'>/atikap/</td>
@@ -205,7 +204,6 @@ EndPreamble</programlisting>
 <td align='center' valign='top'></td>
 </tr>
 </tbody>
-</informaltable>
 </table>
 
 <para>Bitte beachten Sie, dass die Legende in der Standardeinstellung immer 
unter dem Tableau ausgegeben wird, egal, wohin Sie sie im LyX-Arbeitsfenster 
setzen. Um die Legende über das Tableau zu setzen, müssen Sie den folgenden 
Code in <emphasis role='sans'>Dokument&#x21D2;Einstellungen&#x21D2;Präambel 
</emphasis>eingeben:</para>
diff --git a/src/Floating.cpp b/src/Floating.cpp
index 7ee042c..6ae52b4 100644
--- a/src/Floating.cpp
+++ b/src/Floating.cpp
@@ -44,6 +44,25 @@ Floating::Floating(string const & type, string const & 
placement,
 {}
 
 
+std::string Floating::docbookFloatType() const
+{
+       // TODO: configure this in the layouts?
+       if (floattype_ == "figure") {
+               return "figure";
+       } else if (floattype_ == "table" || floattype_ == "tableau") {
+               return "table";
+       } else if (floattype_ == "algorithm") {
+               // TODO: no good translation for now! Figures are the closest 
match, as they can contain text.
+               // Solvable as soon as 
https://github.com/docbook/docbook/issues/157 has a definitive answer.
+               return "algorithm";
+       } else {
+               // If nothing matches, return something that will not be valid.
+               LYXERR0("Unrecognised float type: " + floattype_);
+               return "unknown";
+       }
+}
+
+
 string const & Floating::htmlAttrib() const
 {
        if (html_attrib_.empty())
@@ -91,17 +110,17 @@ string const & Floating::docbookAttr() const
 string Floating::docbookTag(bool hasTitle) const
 {
        // TODO: configure this in the layouts?
-       if (floattype_ == "figure") {
+       if (docbookFloatType() == "figure") {
                return hasTitle ? "figure" : "informalfigure";
-       } else if (floattype_ == "table" || floattype_ == "tableau") {
+       } else if (docbookFloatType() == "table") {
                return hasTitle ? "table" : "informaltable";
-       } else if (floattype_ == "algorithm") {
+       } else if (docbookFloatType() == "algorithm") {
                // TODO: no good translation for now! Figures are the closest 
match, as they can contain text.
                // Solvable as soon as 
https://github.com/docbook/docbook/issues/157 has a definitive answer.
                return "figure";
        } else {
                // If nothing matches, return something that will not be valid.
-               LYXERR0("Unrecognised float type: " + floattype_);
+               LYXERR0("Unrecognised float type: " + floattype());
                return "float";
        }
 }
diff --git a/src/Floating.h b/src/Floating.h
index 46816af..0a2eb50 100644
--- a/src/Floating.h
+++ b/src/Floating.h
@@ -44,6 +44,8 @@ public:
        ///
        std::string const & floattype() const { return floattype_; }
        ///
+       std::string docbookFloatType() const;
+       ///
        std::string const & placement() const { return placement_; }
        ///
        std::string const & ext() const {return ext_; }
diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index 86bcf9d..981ba40 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -639,7 +639,7 @@ void docbookNoSubfigures(XMLStream & xs, OutputParams const 
& runparams, const I
        // captions, they cannot appear at the end of the float, albeit LyX is 
happy with that).
        OutputParams rpNoTitle = runparams;
        rpNoTitle.docbook_in_float = true;
-       if (ftype.floattype() == "table")
+       if (ftype.docbookFloatType() == "table")
                rpNoTitle.docbook_in_table = true;
 
        // Organisation: <float> <title if any/> <contents without title/> 
</float>.
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to