#include "insets/InsetInclude.h"
#include "insets/InsetText.h"
+#include "mathed/InsetMathHull.h"
#include "mathed/MacroTable.h"
#include "mathed/MathMacroTemplate.h"
#include "mathed/MathSupport.h"
/// Update macro table starting with position of it \param it in some
/// text inset.
- void updateMacros(DocIterator & it, DocIterator & scope);
+ void updateMacros(DocIterator & it, DocIterator & scope,
+ bool record_docits = false);
///
void setLabel(ParIterator & it, UpdateType utype) const;
///
}
// Remove any previewed LaTeX snippets associated with this buffer.
- thePreviews().removeLoader(*this);
+ if (!isClone())
+ thePreviews().removeLoader(*this);
delete d;
}
updateBuffer(UpdateMaster, OutputUpdate);
checkBibInfoCache();
d->bibinfo_.makeCitationLabels(*this);
- updateMacros();
+ updateMacros(true);
updateMacroInstances();
if (!only_body) {
}
-void Buffer::Impl::updateMacros(DocIterator & it, DocIterator & scope)
+void Buffer::Impl::updateMacros(DocIterator & it, DocIterator & scope,
+ bool record_docits)
{
pit_type const lastpit = it.lastpit();
continue;
}
+ if (record_docits && iit->inset->asInsetMath()) {
+ InsetMath * im = static_cast<InsetMath *>(iit->inset);
+ if (im->asHullInset()) {
+ InsetMathHull * hull = static_cast<InsetMathHull *>(im);
+ hull->recordLocation(it);
+ }
+ }
+
if (iit->inset->lyxCode() != MATHMACRO_CODE)
continue;
}
-void Buffer::updateMacros() const
+void Buffer::updateMacros(bool record_docit) const
{
if (d->macro_lock)
return;
DocIterator it = par_iterator_begin();
DocIterator outerScope = it;
outerScope.pit() = outerScope.lastpit() + 2;
- d->updateMacros(it, outerScope);
+ d->updateMacros(it, outerScope, record_docit);
}
// Macro handling
//
/// Collect macro definitions in paragraphs
- void updateMacros() const;
+ void updateMacros(bool record_docit = false) const;
/// Iterate through the whole buffer and try to resolve macros
void updateMacroInstances() const;
}
+support::FileName const & PreviewImage::filename() const
+{
+ return pimpl_->iloader_.filename();
+}
+
+
Dimension PreviewImage::dim() const
{
Dimension dim;
* triggers that.
*/
Image const * image() const;
+ ///
+ support::FileName const & filename() const;
private:
/// Use the Pimpl idiom to hide the internals.
///
void remove(string const & latex_snippet);
///
- void startLoading();
+ void startLoading(bool wait = false);
/// Emit this signal when an image is ready for display.
boost::signal<void(PreviewImage const &)> imageReady;
}
-void PreviewLoader::startLoading() const
+void PreviewLoader::startLoading(bool wait) const
{
- pimpl_->startLoading();
+ pimpl_->startLoading(wait);
}
}
-void PreviewLoader::Impl::startLoading()
+void PreviewLoader::Impl::startLoading(bool wait)
{
if (pending_.empty() || !pconverter_)
return;
double font_scaling_factor = 0.01 * lyxrc.dpi * lyxrc.zoom
* lyxrc.preview_scale_factor;
+ // For XHTML image export, we need to control the background
+ // color here.
+ ColorCode bg = buffer_.isClone()
+ ? Color_white : PreviewLoader::backgroundColor();
// The conversion command.
ostringstream cs;
cs << pconverter_->command << ' ' << pconverter_->to << ' '
<< quoteName(latexfile.toFilesystemEncoding()) << ' '
<< int(font_scaling_factor) << ' '
<< theApp()->hexName(PreviewLoader::foregroundColor()) << ' '
- << theApp()->hexName(PreviewLoader::backgroundColor());
+ << theApp()->hexName(bg);
if (buffer_.params().useXetex)
cs << " xelatex";
string const command = libScriptSearch(cs.str());
+ if (wait) {
+ ForkedCall call;
+ int ret = call.startScript(ForkedProcess::Wait, command);
+ static int fake = (2^20) + 1;
+ int pid = fake++;
+ inprogress.pid = pid;
+ inprogress.command = command;
+ in_progress_[pid] = inprogress;
+ finishedGenerating(pid, ret);
+ return;
+ }
+
// Initiate the conversion from LaTeX to bitmap images files.
ForkedCall::SignalTypePtr
convert_ptr(new ForkedCall::SignalType);
/** We have accumulated several latex snippets with status "InQueue".
* Initiate their transformation into bitmap images.
*/
- void startLoading() const;
+ void startLoading(bool wait = false) const;
/** Connect and you'll be informed when the bitmap image file
* has been created and is ready for loading through
}
-void RenderPreview::startLoading(Buffer const & buffer) const
+void RenderPreview::startLoading(Buffer const & buffer, bool wait) const
{
if (status() == LyXRC::PREVIEW_OFF || snippet_.empty())
return;
graphics::PreviewLoader const & loader = getPreviewLoader(buffer);
- loader.startLoading();
+ loader.startLoading(wait);
}
graphics::PreviewLoader & ploader);
/// Begin the loading process.
- void startLoading(Buffer const & buffer) const;
+ void startLoading(Buffer const & buffer, bool wait = false) const;
/** Remove a snippet from the cache of previews.
* Useful if previewing the contents of a file that has changed.
#include "ColorSet.h"
#include "CutAndPaste.h"
#include "Encoding.h"
+#include "Exporter.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "LaTeXFeatures.h"
}
-void InsetMathHull::reloadPreview(DocIterator const & pos) const
+void InsetMathHull::reloadPreview(DocIterator const & pos, bool wait) const
{
preparePreview(pos);
- preview_->startLoading(*pos.buffer());
+ preview_->startLoading(*pos.buffer(), wait);
}
}
-docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
{
BufferParams::MathOutput mathtype = buffer().params().html_math_output;
// FIXME Eventually we would like to do this inset by inset.
break;
}
case BufferParams::HTML: {
- string tag = (getType() == hullSimple) ? "span" : "div";
+ string const tag = (getType() == hullSimple) ? "span" : "div";
xs << html::StartTag(tag, "class='formula'", true);
HtmlStream ms(xs.os());
InsetMathGrid::htmlize(ms);
break;
}
case BufferParams::Images: {
- LYXERR0("Image output for math presently unsupported.");
+ reloadPreview(docit_, true);
+ graphics::PreviewImage const * pimage = preview_->getPreviewImage(buffer());
+ string const tag = (getType() == hullSimple) ? "span" : "div";
+ if (!pimage) {
+ LYXERR0("Unable to generate image. LaTeX follows.");
+ LYXERR0(latexString(*this));
+ xs << html::StartTag(tag) << "MATH" << html::EndTag(tag);
+ xs.cr();
+ break;
+ }
+ // need to do a conversion to png, possibly.
+ FileName const & mathimg = pimage->filename();
+ xs << html::StartTag(tag);
+ xs << html::CompTag("img", "src=\"" + mathimg.onlyFileName() + "\"");
+ xs << html::EndTag(tag);
+ xs.cr();
+ op.exportdata->addExternalFile("xhtml", mathimg);
break;
}
case BufferParams::LaTeX: {
}
+void InsetMathHull::recordLocation(DocIterator const & di)
+{
+ docit_ = di;
+}
+
} // namespace lyx
#include "InsetMathGrid.h"
+#include "DocIterator.h"
#include "OutputEnums.h"
#include <boost/scoped_ptr.hpp>
/// Prepare the preview if preview is enabled.
void preparePreview(DocIterator const & pos) const;
/// Recreates the preview if preview is enabled.
- void reloadPreview(DocIterator const & pos) const;
+ void reloadPreview(DocIterator const & pos, bool wait = false) const;
///
void initUnicodeMath() const;
/// Force inset into LTR environment if surroundings are RTL
virtual bool forceLTR() const { return true; }
+ ///
+ void recordLocation(DocIterator const & di);
///
virtual docstring contextMenu(BufferView const &, int, int) const;
boost::scoped_ptr<RenderPreview> preview_;
///
mutable bool use_preview_;
+ ///
+ DocIterator docit_;
//
// Incorporate me
//