Add a for_search member to OutputParams, and use it to limit what

work we do when calling plaintext() for the purpose of generating
material for the advanced search function.

Here again, not only were we parsing BibTeX files, since Julien's
(sensible) introduction of plaintext output for that inset, but we
were in fact writing (to disk) complete plaintext output for
included files every time we did such a search.
This commit is contained in:
Richard Heck 2013-03-12 12:45:15 -04:00
parent 96289519c5
commit 3f748c79c3
6 changed files with 21 additions and 11 deletions

View File

@ -30,7 +30,8 @@ OutputParams::OutputParams(Encoding const * enc)
par_begin(0), par_end(0), lastid(-1), lastpos(-1), isLastPar(false), par_begin(0), par_end(0), lastid(-1), lastpos(-1), isLastPar(false),
dryrun(false), pass_thru(false), dryrun(false), pass_thru(false),
html_disable_captions(false), html_in_par(false), html_disable_captions(false), html_in_par(false),
html_make_pars(true), for_toc(false), for_tooltip(false), includeall(false) html_make_pars(true), for_toc(false), for_tooltip(false),
for_search(false), includeall(false)
{ {
// Note: in PreviewLoader::Impl::dumpPreamble // Note: in PreviewLoader::Impl::dumpPreamble
// OutputParams runparams(0); // OutputParams runparams(0);

View File

@ -264,6 +264,9 @@ public:
/// Are we generating this material for inclusion in a tooltip? /// Are we generating this material for inclusion in a tooltip?
bool for_tooltip; bool for_tooltip;
/// Are we generating this material for use by advanced search?
bool for_search;
/// Include all children notwithstanding the use of \includeonly /// Include all children notwithstanding the use of \includeonly
bool includeall; bool includeall;

View File

@ -3132,7 +3132,8 @@ void Paragraph::forToc(docstring & os, size_t maxlen) const
} }
docstring Paragraph::stringify(pos_type beg, pos_type end, int options, OutputParams & runparams) const docstring Paragraph::stringify(pos_type beg, pos_type end, int options,
OutputParams const & runparams) const
{ {
odocstringstream os; odocstringstream os;

View File

@ -183,18 +183,19 @@ public:
/// Extract only the explicitly visible text (without any formatting), /// Extract only the explicitly visible text (without any formatting),
/// descending into insets /// descending into insets
docstring stringify(pos_type beg, pos_type end, int options, OutputParams & runparams) const; docstring stringify(pos_type beg, pos_type end, int options,
OutputParams const & runparams) const;
/// ///
void write(std::ostream &, BufferParams const &, void write(std::ostream &, BufferParams const &,
depth_type & depth) const; depth_type & depth) const;
/// ///
void validate(LaTeXFeatures &) const; void validate(LaTeXFeatures &) const;
/// \param force means: output even if layout.inpreamble is true. /// \param force means: output even if layout.inpreamble is true.
void latex(BufferParams const &, Font const & outerfont, otexstream &, void latex(BufferParams const &, Font const & outerfont, otexstream &,
OutputParams const &, int start_pos = 0, int end_pos = -1, OutputParams const &, int start_pos = 0, int end_pos = -1,
bool force = false) const; bool force = false) const;
/// Can we drop the standard paragraph wrapper? /// Can we drop the standard paragraph wrapper?
bool emptyTag() const; bool emptyTag() const;

View File

@ -933,9 +933,12 @@ int InsetBibtex::plaintext(odocstringstream & os,
{ {
docstring const reflabel = buffer().B_("References"); docstring const reflabel = buffer().B_("References");
if (op.for_tooltip || op.for_toc) { // We could output more information here, e.g., what databases are included
os << reflabel; // and information about options. But I don't necessarily see any reason to
return reflabel.size(); // do this right now.
if (op.for_tooltip || op.for_toc || op.for_search) {
os << '[' << reflabel << ']' << '\n';
return PLAINTEXT_NEWLINE;
} }
BiblioInfo bibinfo = buffer().masterBibInfo(); BiblioInfo bibinfo = buffer().masterBibInfo();

View File

@ -813,8 +813,9 @@ docstring InsetInclude::xhtml(XHTMLStream & xs, OutputParams const & rp) const
int InsetInclude::plaintext(odocstringstream & os, int InsetInclude::plaintext(odocstringstream & os,
OutputParams const & op, size_t) const OutputParams const & op, size_t) const
{ {
// just write the filename if we're making a tooltip or toc entry // just write the filename if we're making a tooltip or toc entry,
if (op.for_tooltip || op.for_toc) { // or are generating this for advanced search
if (op.for_tooltip || op.for_toc || op.for_search) {
os << '[' << screenLabel() << '\n' os << '[' << screenLabel() << '\n'
<< getParam("filename") << "\n]"; << getParam("filename") << "\n]";
return PLAINTEXT_NEWLINE + 1; // one char on a separate line return PLAINTEXT_NEWLINE + 1; // one char on a separate line