]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetGraphics.cpp
Properly fix handling of title layouts within insets (#11787)
[lyx.git] / src / insets / InsetGraphics.cpp
index 27df512a29e2f1d507dc23e850ff0a89f6509e04..68bf2c13f323bb2307788f3474ca16afaf4b89be 100644 (file)
@@ -68,7 +68,7 @@ TODO
 #include "Mover.h"
 #include "OutputParams.h"
 #include "output_xhtml.h"
-#include "sgml.h"
+#include "xml.h"
 #include "texstream.h"
 #include "TocBackend.h"
 
@@ -107,7 +107,7 @@ namespace Alert = frontend::Alert;
 namespace {
 
 /// Find the most suitable image format for images in \p format
-/// Note that \p format may be unknown (i. e. an empty string)
+/// Note that \p format may be unknown (i.e. an empty string)
 string findTargetFormat(string const & format, OutputParams const & runparams)
 {
        // Are we latexing to DVI or PDF?
@@ -177,7 +177,7 @@ void readInsetGraphics(Lexer & lex, Buffer const & buf, bool allowOrigin,
 
 
 InsetGraphics::InsetGraphics(Buffer * buf)
-       : Inset(buf), graphic_label(sgml::uniqueID(from_ascii("graph"))),
+       : Inset(buf), graphic_label(xml::uniqueID(from_ascii("graph"))),
          graphic_(new RenderGraphic(this))
 {
 }
@@ -185,7 +185,7 @@ InsetGraphics::InsetGraphics(Buffer * buf)
 
 InsetGraphics::InsetGraphics(InsetGraphics const & ig)
        : Inset(ig),
-         graphic_label(sgml::uniqueID(from_ascii("graph"))),
+         graphic_label(xml::uniqueID(from_ascii("graph"))),
          graphic_(new RenderGraphic(*ig.graphic_, this))
 {
        setParams(ig.params());
@@ -502,10 +502,6 @@ docstring InsetGraphics::createDocBookAttributes() const
        // Calculate the options part of the command, we must do it to a string
        // stream since we copied the code from createLatexParams() ;-)
 
-       // FIXME: av: need to translate spec -> Docbook XSL spec
-       // (http://www.sagehill.net/docbookxsl/ImageSizing.html)
-       // Right now it only works with my version of db2latex :-)
-
        odocstringstream options;
        double const scl = convert<double>(params().scale);
        if (!params().scale.empty() && !float_equal(scl, 0.0, 0.05)) {
@@ -627,7 +623,10 @@ string const stripExtensionIfPossible(string const & file, string const & to, bo
 {
        // No conversion is needed. LaTeX can handle the graphic file as is.
        // This is true even if the orig_file is compressed.
-       string const to_format = theFormats().getFormat(to)->extension();
+       Format const * f = theFormats().getFormat(to);
+       if (!f)
+               return latex_path(file, EXCLUDE_EXTENSION);
+       string const to_format = f->extension();
        string const file_format = getExtension(file);
        // for latex .ps == .eps
        if (to_format == file_format ||
@@ -858,11 +857,6 @@ void InsetGraphics::latex(otexstream & os,
        if (runparams.moving_arg)
                before += "\\protect";
 
-       if (runparams.inDeletedInset) {
-               before += "\\lyxobjectsout{";
-               after += "}";
-       }
-
        // We never use the starred form, we use the "clip" option instead.
        before += "\\includegraphics";
 
@@ -947,14 +941,14 @@ static int writeImageObject(char const * format, odocstream & os,
 {
        if (runparams.flavor != OutputParams::XML)
                os << "<![ %output.print." << format
-                        << "; [" << endl;
+                  << "; [" << endl;
 
        os <<"<imageobject><imagedata fileref=\"&"
-                << graphic_label
-                << ";."
-                << format
-                << "\" "
-                << attributes;
+          << graphic_label
+          << ";."
+          << format
+          << "\" "
+          << attributes;
 
        if (runparams.flavor == OutputParams::XML)
                os <<  " role=\"" << format << "\"/>" ;
@@ -1083,7 +1077,7 @@ string InsetGraphics::prepareHTMLFile(OutputParams const & runparams) const
 }
 
 
-docstring InsetGraphics::xhtml(XHTMLStream & xs, OutputParams const & op) const
+docstring InsetGraphics::xhtml(XMLStream & xs, OutputParams const & op) const
 {
        string const output_file = op.dryrun ? string() : prepareHTMLFile(op);
 
@@ -1092,7 +1086,7 @@ docstring InsetGraphics::xhtml(XHTMLStream & xs, OutputParams const & op) const
                        << params().filename << "' for output. File missing?");
                string const attr = "src='" + params().filename.absFileName()
                                    + "' alt='image: " + output_file + "'";
-               xs << html::CompTag("img", attr);
+               xs << xml::CompTag("img", attr);
                return docstring();
        }
 
@@ -1120,7 +1114,7 @@ docstring InsetGraphics::xhtml(XHTMLStream & xs, OutputParams const & op) const
 
        string const attr = imgstyle + "src='" + output_file + "' alt='image: "
                            + output_file + "'";
-       xs << html::CompTag("img", attr);
+       xs << xml::CompTag("img", attr);
        return docstring();
 }
 
@@ -1141,8 +1135,10 @@ void InsetGraphics::validate(LaTeXFeatures & features) const
                if (contains(rel_file, "."))
                        features.require("lyxdot");
        }
-       if (features.inDeletedInset())
+       if (features.inDeletedInset()) {
+               features.require("tikz");
                features.require("ct-tikz-object-sout");
+       }
 }