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),
dryrun(false), pass_thru(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
// OutputParams runparams(0);

View File

@ -264,6 +264,9 @@ public:
/// Are we generating this material for inclusion in a 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
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;

View File

@ -183,7 +183,8 @@ public:
/// Extract only the explicitly visible text (without any formatting),
/// 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 &,

View File

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

View File

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