mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
Allow images to be export even when LyXRC says no previews.
I'll try to figure out how to get rid of the magic booleans. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35022 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
833ef6352f
commit
e48fb0b661
@ -175,31 +175,33 @@ void RenderPreview::draw(PainterInfo & pi, int x, int y) const
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
@ -59,17 +59,23 @@ public:
|
||||
|
||||
/** 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.
|
||||
|
@ -516,8 +516,14 @@ void InsetMathHull::addPreview(DocIterator const & inset_pos,
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
@ -536,14 +542,22 @@ void InsetMathHull::preparePreview(DocIterator const & pos) const
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -1871,7 +1885,7 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
|
||||
break;
|
||||
}
|
||||
case BufferParams::Images: {
|
||||
reloadPreview(docit_, true);
|
||||
loadPreview(docit_);
|
||||
graphics::PreviewImage const * pimage = preview_->getPreviewImage(buffer());
|
||||
if (pimage) {
|
||||
// FIXME Do we always have png?
|
||||
|
@ -139,10 +139,8 @@ public:
|
||||
///
|
||||
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;
|
||||
|
||||
@ -172,6 +170,14 @@ protected:
|
||||
|
||||
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);
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user