]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetGraphics.cpp
Do not scan BibTeX files multiple times in a collectBibKeys() procedure.
[lyx.git] / src / insets / InsetGraphics.cpp
index 335c92d6269c16285e8b24b8f7ea60f59b77af7a..94182a73269fa5585adf4cce8de06e6d5d149b59 100644 (file)
@@ -165,7 +165,7 @@ void readInsetGraphics(Lexer & lex, Buffer const & buf, bool allowOrigin,
        }
 }
 
-} // namespace anon
+} // namespace
 
 
 InsetGraphics::InsetGraphics(Buffer * buf)
@@ -226,7 +226,7 @@ void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & cmd)
                // if the inset is part of a graphics group, all the
                // other members should be updated too.
                if (!params_.groupId.empty())
-                       graphics::unifyGraphicsGroups(buffer(), 
+                       graphics::unifyGraphicsGroups(buffer(),
                                                      to_utf8(cmd.argument()));
                break;
        }
@@ -304,17 +304,19 @@ void InsetGraphics::read(Lexer & lex)
 }
 
 
-string InsetGraphics::createLatexOptions() const
+string InsetGraphics::createLatexOptions(bool const ps) const
 {
        // Calculate the options part of the command, we must do it to a string
        // stream since we might have a trailing comma that we would like to remove
        // before writing it to the output stream.
        ostringstream options;
-       if (!params().bbox.empty())
-               options << "bb=" << params().bbox.xl.asLatexString() << ' '
+       if (!params().bbox.empty()) {
+               string const key = ps ? "bb=" : "viewport=";
+               options << key << params().bbox.xl.asLatexString() << ' '
                        << params().bbox.yb.asLatexString() << ' '
                        << params().bbox.xr.asLatexString() << ' '
                        << params().bbox.yt.asLatexString() << ',';
+       }
        if (params().draft)
            options << "draft,";
        if (params().clip)
@@ -559,7 +561,7 @@ string const stripExtensionIfPossible(string const & file, string const & to, bo
        return latex_path(file, EXCLUDE_EXTENSION);
 }
 
-} // namespace anon
+} // namespace
 
 
 string InsetGraphics::prepareFile(OutputParams const & runparams) const
@@ -667,12 +669,12 @@ string InsetGraphics::prepareFile(OutputParams const & runparams) const
                        // The LaTeX compiler will not be able to determine
                        // the file format from the extension, so we must
                        // change it.
-                       FileName const new_file = 
+                       FileName const new_file =
                                FileName(changeExtension(temp_file.absFileName(), ext));
                        if (temp_file.moveTo(new_file)) {
                                temp_file = new_file;
                                output_file = changeExtension(output_file, ext);
-                               source_file = 
+                               source_file =
                                        FileName(changeExtension(source_file.absFileName(), ext));
                        } else {
                                LYXERR(Debug::GRAPHICS, "Could not rename file `"
@@ -765,7 +767,9 @@ void InsetGraphics::latex(otexstream & os,
        before += "\\includegraphics";
 
        // Write the options if there are any.
-       string const opts = createLatexOptions();
+       bool const ps = runparams.flavor == OutputParams::LATEX
+               || runparams.flavor == OutputParams::DVILUATEX;
+       string const opts = createLatexOptions(ps);
        LYXERR(Debug::GRAPHICS, "\tOpts = " << opts);
 
        if (!opts.empty() && !message.empty())
@@ -935,10 +939,10 @@ string InsetGraphics::prepareHTMLFile(OutputParams const & runparams) const
 
        // FIXME (Abdel 12/08/06): Is there a need to show these errors?
        ErrorList el;
-       bool const success = 
+       bool const success =
                theConverters().convert(&buffer(), temp_file, to_file, params().filename,
                        from, to, el, Converters::try_default | Converters::try_cache);
-       if (!success)   
+       if (!success)
                return string();
        runparams.exportdata->addExternalFile("xhtml", to_file, output_to_file);
        return output_to_file;
@@ -950,15 +954,15 @@ docstring InsetGraphics::xhtml(XHTMLStream & xs, OutputParams const & op) const
        string const output_file = op.dryrun ? string() : prepareHTMLFile(op);
 
        if (output_file.empty() && !op.dryrun) {
-               LYXERR0("InsetGraphics::xhtml: Unable to prepare file `" 
+               LYXERR0("InsetGraphics::xhtml: Unable to prepare file `"
                        << params().filename << "' for output. File missing?");
-               string const attr = "src='" + params().filename.absFileName() 
+               string const attr = "src='" + params().filename.absFileName()
                                    + "' alt='image: " + output_file + "'";
                xs << html::CompTag("img", attr);
                return docstring();
        }
 
-       // FIXME XHTML 
+       // FIXME XHTML
        // We aren't doing anything with the crop and rotate parameters, and it would
        // really be better to do width and height conversion, rather than to output
        // these parameters here.
@@ -980,7 +984,7 @@ docstring InsetGraphics::xhtml(XHTMLStream & xs, OutputParams const & op) const
        if (!imgstyle.empty())
                imgstyle = "style='" + imgstyle + "' ";
 
-       string const attr = imgstyle + "src='" + output_file + "' alt='image: " 
+       string const attr = imgstyle + "src='" + output_file + "' alt='image: "
                            + output_file + "'";
        xs << html::CompTag("img", attr);
        return docstring();