add missing using's

start with 'preview' (not activated)


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4245 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2002-05-28 11:13:01 +00:00
parent 66fb6d57da
commit 1e0262d6ef
8 changed files with 133 additions and 1 deletions

View File

@ -5,6 +5,7 @@ noinst_LTLIBRARIES = libmathed.la
INCLUDES = -I$(srcdir)/../ $(SIGC_CFLAGS) $(BOOST_INCLUDES)
libmathed_la_SOURCES = \
preview.C \
textpainter.C \
textpainter.h \
formulabase.C \

View File

@ -42,6 +42,7 @@
#include "math_support.h"
#include "math_mathmlstream.h"
#include "textpainter.h"
#include "preview.h"
using std::ostream;
using std::ifstream;
@ -365,6 +366,16 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & font,
}
par_->draw(pain, x, y);
// preview stuff
#if 0
ostringstream os;
WriteStream wi(os, false, false);
par_->write(wi);
if (grfx::ImagePtr image = preview(os.str()))
pain.image(x, y, w, h, *image);
#endif
xx += par_->width();
xo_ = x;
yo_ = y;

View File

@ -60,6 +60,8 @@ using std::max;
using std::swap;
using std::vector;
using std::ostringstream;
using std::isalpha;
namespace {

View File

@ -8,6 +8,7 @@
using std::ostream;
using std::strlen;
MathMLStream::MathMLStream(ostream & os)

View File

@ -88,6 +88,7 @@ using std::endl;
using std::stack;
using std::fill;
using std::vector;
using std::atoi;
//#define FILEDEBUG
@ -488,7 +489,7 @@ void Parser::tokenize(string const & buffer)
char c;
while (is.get(c)) {
lyxerr << "reading c: " << c << "\n";
//lyxerr << "reading c: " << c << "\n";
switch (catcode(c)) {
case catNewline: {

View File

@ -13,6 +13,7 @@
using std::max;
using std::min;
using std::abs;
extern MathScriptInset const * asScript(MathArray::const_iterator it);

106
src/mathed/preview.C Normal file
View File

@ -0,0 +1,106 @@
#include <config.h>
#include "formula.h"
#include "debug.h"
#include "frontends/Painter.h"
#include "support/systemcall.h"
#include "graphics/GraphicsTypes.h"
#include "graphics/GraphicsImage.h"
#include "graphics/GraphicsImageXPM.h"
#include <fstream>
#include <map>
using namespace std;
namespace {
typedef map<string, grfx::ImagePtr> previews_map;
// cache for computed previews
previews_map thePreviews;
// cache for scedule previews
vector<string> theSchedule;
}
void imageLoaded()
{
}
grfx::ImagePtr preview(string const & str)
{
// do we already have access to a rendered version?
previews_map::const_iterator it = thePreviews.find(str);
if (it != thePreviews.end())
return it->second;
// constructing new item
grfx::ImagePtr & im = thePreviews[str];
lyxerr << "writing: " << str << endl;
std::ofstream of("/tmp/previewlyx.tex");
of << "\\documentclass{article}"
<< "\\usepackage{amssymb}"
<< "\\thispagestyle{empty}"
<< "\\begin{document}"
<< str
<< "\\end{document}\n";
of.close();
Systemcall sc1;
sc1.startscript(Systemcall::Wait,
"(cd /tmp ; latex previewlyx.tex ; dvips previewlyx.dvi)");
Systemcall sc2;
sc2.startscript(Systemcall::Wait,
"(cd /tmp ; convert previewlyx.ps previewlyx.xpm)");
//grfx::SignalLoadTypePtr on_finish;
//on_finish.reset(new SignalLoadType);
//on_finish->connect(SigC::slot(this, &imageLoaded));
// load image
XpmImage * xpm_image = new XpmImage;
int const success =
XpmReadFileToXpmImage("/tmp/previewlyx.ps", xpm_image, 0);
switch (success) {
case XpmOpenFailed:
lyxerr[Debug::GRAPHICS]
<< "No XPM image file found." << std::endl;
break;
case XpmFileInvalid:
lyxerr[Debug::GRAPHICS]
<< "File format is invalid" << std::endl;
break;
case XpmNoMemory:
lyxerr[Debug::GRAPHICS]
<< "Insufficient memory to read in XPM file"
<< std::endl;
break;
}
if (success != XpmSuccess) {
XpmFreeXpmImage(xpm_image);
delete xpm_image;
lyxerr[Debug::GRAPHICS]
<< "Error reading XPM file '"
<< XpmGetErrorString(success) << "'"
<< std::endl;
} else {
//grfx::GImageXPM * xim = static_cast<grfx::GImageXPM *>(im.get());
//xim->image_.reset(*xpm_image);
}
return im;
}

9
src/mathed/preview.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef PREVIEW_H
#define PREVIEW_H
#include "LString.h"
#include "graphics/GraphicsTypes.h"
grfx::ImagePtr preview(string const & str);
#endif