X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetgraphics.C;h=1dc04a8530c0eea9948d5443e3762bdede8630ab;hb=4a5b7a5952ad2381fcdf4830511293e184c7c5a1;hp=e670ddda5e56ac29bb9c16e2a67a14d2ee847d7c;hpb=7ea7dabed1b72cc25dcbdc482ac006f2b61dacfd;p=lyx.git diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index e670ddda5e..1dc04a8530 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -143,9 +143,25 @@ string const RemoveExtension(string const & filename) } +namespace { + +string const unique_id() +{ + static unsigned int seed = 1000; + + ostringstream ost; + ost << "graph" << ++seed; + + // Needed if we use lyxstring. + return ost.str().c_str(); +} + +} // namespace anon + + // Initialize only those variables that do not have a constructor. InsetGraphics::InsetGraphics() - : cacheHandle(0), imageLoaded(false) + : cacheHandle(0), imageLoaded(false), graphic_label(unique_id()) {} @@ -153,6 +169,7 @@ InsetGraphics::InsetGraphics(InsetGraphics const & ig, bool same_id) : Inset(), SigC::Object() , cacheHandle(ig.cacheHandle) , imageLoaded(ig.imageLoaded) + , graphic_label(unique_id()) { setParams(ig.getParams()); if (same_id) @@ -640,20 +657,12 @@ int InsetGraphics::linuxdoc(Buffer const *, ostream &) const // For explanation on inserting graphics into DocBook checkout: // http://linuxdoc.org/LDP/LDP-Author-Guide/inserting-pictures.html // See also the docbook guide at http://www.docbook.org/ -int InsetGraphics::docbook(Buffer const * buf, ostream & os) const +int InsetGraphics::docbook(Buffer const *, ostream & os) const { - // Change the path to be relative to the main file. - string const buffer_dir = buf->filePath(); - string filename = RemoveExtension( - MakeRelPath(params.filename, buffer_dir)); - - if (suffixIs(filename, ".eps")) - filename.erase(filename.length() - 4); - // In DocBook v5.0, the graphic tag will be eliminated from DocBook, will // need to switch to MediaObject. However, for now this is sufficient and // easier to use. - os << ""; + os << ""; return 0; } @@ -664,6 +673,8 @@ void InsetGraphics::validate(LaTeXFeatures & features) const if (params.filename.empty()) return ; + features.includeFile(graphic_label, RemoveExtension(params.filename)); + features.require("graphicx"); if (params.subcaption)