]> git.lyx.org Git - features.git/blobdiff - src/insets/InsetFloat.cpp
InsetIndex: Some comments and indentation fixes
[features.git] / src / insets / InsetFloat.cpp
index 97d80618df82384ae7db293f223b93edcac79182..cb05e49aa6b57c91ccd669df653ded358ea2b58c 100644 (file)
@@ -759,8 +759,7 @@ void docbookGenerateFillerTable(XMLStream & xs, BufferParams::TableOutput format
 
 
 void docbookNoSubfigures(XMLStream & xs, OutputParams const & runparams, const InsetCaption * caption,
-                         const InsetLabel * label, Floating const & ftype, const InsetFloat * thisFloat)
-{
+                         const InsetLabel * label, Floating const & ftype, const InsetFloat * thisFloat) {
        // Ensure there is no label output, it is supposed to be handled as xml:id.
        OutputParams rpNoLabel = runparams;
        if (label)
@@ -775,17 +774,26 @@ void docbookNoSubfigures(XMLStream & xs, OutputParams const & runparams, const I
 
        // Generate the contents of the float (to check for emptiness).
        odocstringstream osFloatContent;
-       XMLStream xsFloatContent(osFloatContent);
-       thisFloat->InsetText::docbook(xsFloatContent, rpNoTitle);
-       bool hasFloat = !osFloatContent.str().empty();
+       bool hasFloat = false;
+
+       if (thisFloat) {
+               XMLStream xsFloatContent(osFloatContent);
+               thisFloat->InsetText::docbook(xsFloatContent, rpNoTitle);
+               hasFloat = !osFloatContent.str().empty();
+       }
 
        // Do the same for the caption.
        odocstringstream osCaptionContent;
-       XMLStream xsCaptionContent(osCaptionContent);
-       caption->getCaptionAsDocBook(xsCaptionContent, rpNoLabel);
-       bool hasCaption = !osCaptionContent.str().empty();
+       bool hasCaption = false;
 
-       // Organisation: <float> <title if any/> <contents without title/> </float>.
+       if (caption != nullptr) {
+               XMLStream xsCaptionContent(osCaptionContent);
+               caption->getCaptionAsDocBook(xsCaptionContent, rpNoLabel);
+               hasCaption = !osCaptionContent.str().empty();
+       }
+
+       // Organisation: <float with xml:id if any> <title if any/> <contents without title nor xml:id/> </float>.
+       // Titles and xml:id are generated with specific insets and must be dealt with using OutputParams.
 
        // - Generate the attributes for the float tag.
        docstring attr = docstring();
@@ -827,11 +835,6 @@ void docbookNoSubfigures(XMLStream & xs, OutputParams const & runparams, const I
 
 void InsetFloat::docbook(XMLStream & xs, OutputParams const & runparams) const
 {
-//     if (runparams.docbook_in_par) {
-//             xs << xml::EndTag("para");
-//             xs << xml::CR();
-//     }
-
        const InsetCaption* caption = getCaptionInset();
        const InsetLabel* label = getLabelInset();
 
@@ -855,11 +858,6 @@ void InsetFloat::docbook(XMLStream & xs, OutputParams const & runparams) const
                docbookSubfigures(xs, runparams, caption, label, subfigures);
        else
                docbookNoSubfigures(xs, runparams, caption, label, ftype, this);
-
-//     if (runparams.docbook_in_par) {
-//             xs << xml::CR();
-//             xs << xml::StartTag("para");
-//     }
 }