From 30339c03adec64df116276adc0b9da201b0ee4dd Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Sat, 2 Apr 2011 13:04:11 +0000 Subject: [PATCH] Fix preview of generated math images under XHTML. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38205 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/InsetMathHull.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 279da91f9b..9576f7a3ee 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -53,6 +53,7 @@ #include "support/convert.h" #include "support/lassert.h" #include "support/debug.h" +#include "support/filetools.h" #include "support/gettext.h" #include "support/lstrings.h" @@ -2156,15 +2157,26 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const if (pimage || op.dryrun) { string const filename = pimage ? pimage->filename().onlyFileName() : "previewimage.png"; + if (pimage) { + // if we are not in the master buffer, then we need to see that the + // generated image is copied there; otherwise, preview fails. + Buffer const * mbuf = buffer().masterBuffer(); + if (mbuf != &buffer()) { + string mbtmp = mbuf->temppath(); + FileName const mbufimg(support::addName(mbtmp, filename)); + LYXERR0(mbufimg); + pimage->filename().copyTo(mbufimg); + } + // add the file to the list of files to be exported + op.exportdata->addExternalFile("xhtml", pimage->filename()); + } + string const tag = (getType() == hullSimple) ? "span" : "div"; xs << html::CR() << html::StartTag(tag) << html::CompTag("img", "src=\"" + filename + "\"") << html::EndTag(tag) << html::CR(); - if (pimage) - // add the file to the list of files to be exported - op.exportdata->addExternalFile("xhtml", pimage->filename()); success = true; } } -- 2.39.2