#include "insets/insetgraphics.h"
#include "insets/insetgraphicsParams.h"
+
#include "graphics/GraphicsCache.h"
#include "graphics/GraphicsCacheItem.h"
-#include "frontends/Dialogs.h"
-#include "frontends/Alert.h"
#include "LyXView.h"
#include "buffer.h"
#include "BufferView.h"
#include "converter.h"
-#include "frontends/support/LyXImage.h"
#include "Painter.h"
#include "lyx_gui_misc.h"
-#include "support/FileInfo.h"
-#include "support/filetools.h"
-#include "support/lyxalgo.h" // lyx::count
-#include "support/lyxlib.h"
-#include "frontends/controllers/helper_funcs.h"
#include "lyxtext.h"
#include "lyxrc.h"
-#include "font.h" // For the lyxfont class.
-#include "fstream" // for ifstream in isEPS
-#include <algorithm> // For the std::max
-#include "support/lyxmanip.h"
+#include "font.h"
#include "debug.h"
#include "gettext.h"
-//#include "LOStream.h"
+
+#include "frontends/Dialogs.h"
+#include "frontends/Alert.h"
+#include "frontends/controllers/helper_funcs.h"
+#include "frontends/support/LyXImage.h"
+
+#include "support/FileInfo.h"
+#include "support/filetools.h"
+#include "support/lyxlib.h"
+#include "support/lyxmanip.h"
#include "support/lyxalgo.h"
+#include <fstream>
+#include <algorithm>
+
extern string system_tempdir;
using std::ifstream;
using std::ostream;
using std::endl;
+using std::max;
+using std::vector;
+
///////////////////////////////////////////////////////////////////////////
int const VersionNumber = 1;
}
+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())
{}
: Inset(), SigC::Object()
, cacheHandle(ig.cacheHandle)
, imageLoaded(ig.imageLoaded)
+ , graphic_label(unique_id())
{
setParams(ig.getParams());
if (same_id)
if (!msg.empty()) {
msgFont.setSize(LyXFont::SIZE_TINY);
int const msg_width = lyxfont::width(msg, msgFont);
- font_width = std::max(font_width, msg_width);
+ font_width = max(font_width, msg_width);
}
- return std::max(50, font_width + 15);
+ return max(50, font_width + 15);
}
}
string const token = lex.getString();
lyxerr[Debug::INFO] << "Token: '" << token << '\''
- << std::endl;
+ << endl;
if (token.empty()) {
continue;
<< "This document was created with a newer Graphics widget"
", You should use a newer version of LyX to read this"
" file."
- << std::endl;
+ << endl;
// TODO: Possibly open up a dialog?
}
else {
if (! params.Read(buf, lex, token))
lyxerr << "Unknown token, " << token << ", skipping."
- << std::endl;
+ << endl;
}
}
}
// FormatVersion < 1.0 (LyX < 1.2)
void InsetGraphics::readFigInset(Buffer const * buf, LyXLex & lex)
{
- std::vector<string> const oldUnits =
+ vector<string> const oldUnits =
getVectorFromString("pt,cm,in,p%,c%");
bool finished = false;
// set the display default
// 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 << "<graphic fileref=\"" << filename << "\"></graphic>";
+ os << "<graphic fileref=\"&" << graphic_label << ";\">";
return 0;
}
if (params.filename.empty())
return ;
+ features.includeFile(graphic_label, RemoveExtension(params.filename));
+
features.require("graphicx");
if (params.subcaption)