]> git.lyx.org Git - features.git/commitdiff
Fix preview of generated math images under XHTML.
authorRichard Heck <rgheck@comcast.net>
Sat, 2 Apr 2011 13:04:11 +0000 (13:04 +0000)
committerRichard Heck <rgheck@comcast.net>
Sat, 2 Apr 2011 13:04:11 +0000 (13:04 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38205 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathHull.cpp

index 279da91f9b67bff63cde2779f380daad2a996163..9576f7a3eefb1c0d7c876236b196431ad69915f7 100644 (file)
@@ -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;
                }
        }