* src/output_plaintext.C: check line length before outputting

a word in front of an inset; make sensible use of plaintext()
	return value (IMHO totally broken before)
	* insets/insetfoot.[Ch]: add plaintext()
	* insets/insethfill.[Ch]: adjust plaintext(); make the 
	number of characters determinitic; minor header cleanup
	* insets/insetbase.h: add comment on return value
	of plaintext() - before its meaning was unclear 


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17200 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Michael Schmitt 2007-02-15 16:07:36 +00:00
parent 018cb4905e
commit 1baa28f2bc
6 changed files with 34 additions and 12 deletions

View File

@ -201,6 +201,8 @@ public:
virtual void infoize2(odocstream &) const {}
/// plain text output in ucs4 encoding
/// return the number of characters, in case of multiple lines of
/// output, add runparams.linelen to the number of chars in the last line
virtual int plaintext(Buffer const &, odocstream &,
OutputParams const &) const;
/// docbook output

View File

@ -80,6 +80,17 @@ int InsetFoot::latex(Buffer const & buf, odocstream & os,
}
int InsetFoot::plaintext(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
os << '[' << _("footnote") << ":\n";
InsetText::plaintext(buf, os, runparams);
os << "\n]";
return 1 + runparams.linelen; // one char on a separate line
}
int InsetFoot::docbook(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{

View File

@ -31,8 +31,11 @@ public:
int latex(Buffer const &, odocstream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, odocstream &,
OutputParams const &) const;
///
int docbook(Buffer const &, odocstream &,
OutputParams const & runparams) const;
OutputParams const &) const;
///
virtual docstring const editMessage() const;
protected:

View File

@ -50,10 +50,10 @@ docstring const InsetHFill::getScreenLabel(Buffer const &) const
int InsetHFill::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
OutputParams const &) const
{
os << '\t';
return 0;
os << " ";
return 5;
}

View File

@ -30,10 +30,10 @@ public:
InsetBase::Code lyxCode() const { return InsetBase::HFILL_CODE; }
///
int plaintext(Buffer const &, odocstream &,
OutputParams const & runparams) const;
OutputParams const &) const;
///
int docbook(Buffer const &, odocstream &,
OutputParams const & runparams) const;
OutputParams const &) const;
///
void write(Buffer const & buf, std::ostream & os) const;
/// We don't need \begin_inset and \end_inset

View File

@ -198,18 +198,24 @@ void writePlaintextParagraph(Buffer const & buf,
char_type c = par.getUChar(buf.params(), i);
switch (c) {
case Paragraph::META_INSET: {
InsetBase const * inset = par.getInset(i);
if (runparams.linelen > 0 &&
currlinelen + word.length() > runparams.linelen) {
os << '\n';
pair<int, docstring> p = addDepth(depth, ltype_depth);
os << p.second;
currlinelen = p.first;
}
os << word;
currlinelen += word.length();
word.erase();
OutputParams rp = runparams;
rp.depth = par.params().depth();
if (inset->plaintext(buf, os, rp)) {
// to be sure it breaks paragraph
currlinelen += runparams.linelen;
}
int len = par.getInset(i)->plaintext(buf, os, rp);
if (len >= runparams.linelen)
currlinelen = len - runparams.linelen;
else
currlinelen += len;
break;
}