#include <config.h>
+#include <map>
+
+#include <unistd.h> // unlink
+
+#include FORMS_H_LOCATION
+
#ifdef __GNUG__
#pragma implementation
#endif
#include "support/filetools.h"
#include "debug.h"
#include "support/LAssert.h"
-#include <unistd.h> // unlink
-
-#include <map>
-
-#include FORMS_H_LOCATION
using std::endl;
using std::map;
pixmap_(0), renderer(0), refCount(0)
{}
+
GraphicsCacheItem_pimpl::~GraphicsCacheItem_pimpl()
{
if (imageStatus_ == GraphicsCacheItem::Loaded) {
delete renderer;
}
+
bool
GraphicsCacheItem_pimpl::setFilename(string const & filename)
{
return false;
}
+
/*** Callback method ***/
typedef map<string, GraphicsCacheItem_pimpl*> CallbackMap;
static CallbackMap callbackMap;
+
void
callback(string cmd, int retval)
{
- lyxerr << "callback, cmd="<<cmd<<", retval="<<retval<<endl;
+ lyxerr << "callback, cmd=" << cmd << ", retval=" << retval << endl;
GraphicsCacheItem_pimpl * item = callbackMap[cmd];
callbackMap.erase(cmd);
item->imageConverted(retval);
}
+
void
GraphicsCacheItem_pimpl::imageConverted(int retval)
{
- lyxerr << "imageConverted, retval="<<retval<<endl;
+ lyxerr << "imageConverted, retval=" << retval << endl;
if (retval) {
imageStatus_ = GraphicsCacheItem::ErrorConverting;
// Take only the filename part of the file, without path or extension.
string temp = OnlyFilename(filename);
- temp = ChangeExtension(filename , string());
+ temp = ChangeExtension(filename, string());
// Add some stuff to have it a unique temp file.
xpmfile = TmpFileName(string(), temp);
// There is a problem with running it asyncronously, it doesn't return
// to call the callback, so until the Systemcalls mechanism is fixed
// I use the syncronous method.
- lyxerr << "Launching convert to xpm, command="<<command<<endl;
+ lyxerr << "Launching convert to xpm, command=" << command << endl;
// syscall.startscript(Systemcalls::DontWait, command, &callback);
syscall.startscript(Systemcalls::Wait, command, &callback);
return true;
}
+
// This function gets called from the callback after the image has been
// converted successfully.
void
GraphicsCacheItem_pimpl::loadXPMImage()
{
- if (! renderer->setFilename(xpmfile)) {
+ if (!renderer->setFilename(xpmfile)) {
return;
}