]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathHull.cpp
Small improvement for bug #7509 as suggested by JMarc
[lyx.git] / src / mathed / InsetMathHull.cpp
index 279da91f9b67bff63cde2779f380daad2a996163..686e4274077c61251d66d4ec7e6ffb242cfa0789 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"
 
@@ -244,7 +245,8 @@ void InsetMathHull::updateBuffer(ParIterator const & it, UpdateType utype)
        if (haveNumbers()) {
                BufferParams const & bp = buffer_->params();
                string const & lang = it->getParLanguage(bp)->code();
-               Counters & cnts = bp.documentClass().counters();
+               Counters & cnts =
+                       buffer_->masterBuffer()->params().documentClass().counters();
 
                // right now, we only need to do this at export time
                if (utype == OutputUpdate) {
@@ -2156,15 +2158,25 @@ 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));
+                                       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;
                }
        }
@@ -2187,7 +2199,6 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
                // probably should allow for some kind of customization here
                string const tag = (getType() == hullSimple) ? "span" : "div";
                xs << html::StartTag(tag, "class='math'")
-                  << XHTMLStream::ESCAPE_AND
                   << latex 
                   << html::EndTag(tag)
                   << html::CR();