}
-void RenderPreview::startLoading(Buffer const & buffer, bool wait) const
+void RenderPreview::startLoading(Buffer const & buffer, bool forexport) const
{
- if (status() == LyXRC::PREVIEW_OFF || snippet_.empty())
+ if (!forexport && (status() == LyXRC::PREVIEW_OFF || snippet_.empty()))
return;
graphics::PreviewLoader const & loader = getPreviewLoader(buffer);
- loader.startLoading(wait);
+ loader.startLoading(forexport);
}
void RenderPreview::addPreview(docstring const & latex_snippet,
- Buffer const & buffer)
+ Buffer const & buffer,
+ bool ignore_lyxrc)
{
- if (status() == LyXRC::PREVIEW_OFF)
+ if (status() == LyXRC::PREVIEW_OFF && !ignore_lyxrc)
return;
graphics::PreviewLoader & loader = getPreviewLoader(buffer);
- addPreview(latex_snippet, loader);
+ addPreview(latex_snippet, loader, ignore_lyxrc);
}
void RenderPreview::addPreview(docstring const & latex_snippet,
- graphics::PreviewLoader & ploader)
+ graphics::PreviewLoader & ploader,
+ bool ignore_lyxrc)
{
- if (status() == LyXRC::PREVIEW_OFF)
+ if (status() == LyXRC::PREVIEW_OFF && !ignore_lyxrc)
return;
// FIXME UNICODE
/** Find the PreviewLoader and add a LaTeX snippet to it.
* Do not start the loading process.
+ * \param ignore_lyxrc: generate the preview no matter what LyXRC says
*/
- void addPreview(docstring const & latex_snippet, Buffer const &);
+ void addPreview(docstring const & latex_snippet, Buffer const &,
+ bool ignore_lyxrc = false);
/** Add a LaTeX snippet to the PreviewLoader.
* Do not start the loading process.
+ * \param ignore_lyxrc: generate the preview no matter what LyXRC says
*/
void addPreview(docstring const & latex_snippet,
- graphics::PreviewLoader & ploader);
+ graphics::PreviewLoader & ploader,
+ bool ignore_lyxrc = false);
/// Begin the loading process.
- void startLoading(Buffer const & buffer, bool wait = false) const;
+ /// \param forexport : whether this is intended for export. if so,
+ /// then we ignore LyXRC and wait for the image to be generated.
+ void startLoading(Buffer const & buffer, bool forexport = false) const;
/** Remove a snippet from the cache of previews.
* Useful if previewing the contents of a file that has changed.
}
-void InsetMathHull::preparePreview(DocIterator const & pos) const
+void InsetMathHull::preparePreview(DocIterator const & pos,
+ bool forexport) const
{
+ // there is no need to do all the macro stuff if we're not
+ // actually going to generate the preview.
+ if (RenderPreview::status() != LyXRC::PREVIEW_ON && !forexport)
+ return;
+
Buffer const * buffer = pos.buffer();
// collect macros at this position
docstring const snippet = macro_preamble.str() + latexString(*this);
LYXERR(Debug::MACROS, "Preview snippet: " << snippet);
- preview_->addPreview(snippet, *buffer);
+ preview_->addPreview(snippet, *buffer, forexport);
}
-void InsetMathHull::reloadPreview(DocIterator const & pos, bool wait) const
+void InsetMathHull::reloadPreview(DocIterator const & pos) const
{
preparePreview(pos);
- preview_->startLoading(*pos.buffer(), wait);
+ preview_->startLoading(*pos.buffer());
+}
+
+
+void InsetMathHull::loadPreview(DocIterator const & pos) const
+{
+ bool const forexport = true;
+ preparePreview(pos, forexport);
+ preview_->startLoading(*pos.buffer(), forexport);
}
break;
}
case BufferParams::Images: {
- reloadPreview(docit_, true);
+ loadPreview(docit_);
graphics::PreviewImage const * pimage = preview_->getPreviewImage(buffer());
if (pimage) {
// FIXME Do we always have png?
///
void addPreview(DocIterator const & inset_pos,
graphics::PreviewLoader &) const;
- /// 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, bool wait = false) const;
+ void reloadPreview(DocIterator const & pos) const;
///
void initUnicodeMath() const;
private:
virtual Inset * clone() const;
+ /// Prepare the preview if preview is enabled.
+ /// \param forexport: whether this is intended for export
+ /// If so, we ignore LyXRC and wait for the image to be generated.
+ void preparePreview(DocIterator const & pos,
+ bool forexport = false) const;
+ /// like reloadPreview, but forces load
+ /// used by image export
+ void loadPreview(DocIterator const & pos) const;
///
void setType(HullType type);
///