* src/insets/insetbox.[Ch]:

* src/insets/insetnote.[Ch]: fix plaintext()


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17207 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Michael Schmitt 2007-02-15 22:59:06 +00:00
parent 5caa8e2c6d
commit 2ca15c641a
4 changed files with 47 additions and 48 deletions

View File

@ -253,7 +253,7 @@ bool InsetBox::getStatus(LCursor & cur, FuncRequest const & cmd,
int InsetBox::latex(Buffer const & buf, odocstream & os, int InsetBox::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const OutputParams const & runparams) const
{ {
BoxType btype = boxtranslator().find(params_.type); BoxType btype = boxtranslator().find(params_.type);
@ -389,39 +389,40 @@ int InsetBox::latex(Buffer const & buf, odocstream & os,
} }
int InsetBox::docbook(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
return InsetText::docbook(buf, os, runparams);
}
int InsetBox::plaintext(Buffer const & buf, odocstream & os, int InsetBox::plaintext(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const OutputParams const & runparams) const
{ {
BoxType const btype = boxtranslator().find(params_.type); BoxType const btype = boxtranslator().find(params_.type);
switch (btype) { switch (btype) {
case Frameless: break; case Frameless: break;
case Boxed: os << "["; break; case Boxed: os << "[\n"; break;
case ovalbox: os << "("; break; case ovalbox: os << "(\n"; break;
case Ovalbox: os << "(("; break; case Ovalbox: os << "((\n"; break;
case Shadowbox: os << "["; break; case Shadowbox: os << "[/\n"; break;
case Doublebox: os << "[["; break; case Doublebox: os << "[[\n"; break;
} }
int i = InsetText::plaintext(buf, os, runparams); InsetText::plaintext(buf, os, runparams);
int len = 0;
switch (btype) { switch (btype) {
case Frameless: break; case Frameless: break;
case Boxed: os << "]"; break; case Boxed: os << "\n]"; len = 1; break;
case ovalbox: os << ")"; break; case ovalbox: os << "\n)"; len = 1; break;
case Ovalbox: os << "))"; break; case Ovalbox: os << "\n))"; len = 2; break;
case Shadowbox: os << "]/"; break; case Shadowbox: os << "\n/]"; len = 2; break;
case Doublebox: os << "]]"; break; case Doublebox: os << "\n]]"; len = 2; break;
} }
return i; return len + runparams.linelen; // len chars on a separate line
}
int InsetBox::docbook(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
return InsetText::docbook(buf, os, runparams);
} }

View File

@ -86,10 +86,9 @@ public:
/// ///
int latex(Buffer const &, odocstream &, OutputParams const &) const; int latex(Buffer const &, odocstream &, OutputParams const &) const;
/// ///
int docbook(Buffer const &, odocstream &, OutputParams const &) const; int plaintext(Buffer const &, odocstream &, OutputParams const &) const;
/// ///
int plaintext(Buffer const &, odocstream &, int docbook(Buffer const &, odocstream &, OutputParams const &) const;
OutputParams const & runparams) const;
/// ///
void validate(LaTeXFeatures &) const; void validate(LaTeXFeatures &) const;
/// ///

View File

@ -295,8 +295,28 @@ int InsetNote::latex(Buffer const & buf, odocstream & os,
} }
int InsetNote::plaintext(Buffer const & buf, odocstream & os,
OutputParams const & runparams_in) const
{
if (params_.type == InsetNoteParams::Note)
return 0;
OutputParams runparams(runparams_in);
if (params_.type == InsetNoteParams::Comment) {
runparams.inComment = true;
// Ignore files that are exported inside a comment
runparams.exportdata.reset(new ExportData);
}
os << '[' << _("note") << ":\n";
InsetText::plaintext(buf, os, runparams);
os << "\n]";
return 1 + runparams.linelen; // one char on a separate line
}
int InsetNote::docbook(Buffer const & buf, odocstream & os, int InsetNote::docbook(Buffer const & buf, odocstream & os,
OutputParams const & runparams_in) const OutputParams const & runparams_in) const
{ {
if (params_.type == InsetNoteParams::Note) if (params_.type == InsetNoteParams::Note)
return 0; return 0;
@ -320,27 +340,6 @@ int InsetNote::docbook(Buffer const & buf, odocstream & os,
} }
int InsetNote::plaintext(Buffer const & buf, odocstream & os,
OutputParams const & runparams_in) const
{
if (params_.type == InsetNoteParams::Note)
return 0;
OutputParams runparams(runparams_in);
if (params_.type == InsetNoteParams::Comment) {
runparams.inComment = true;
// Ignore files that are exported inside a comment
runparams.exportdata.reset(new ExportData);
}
os << "[";
int const nlines = InsetText::plaintext(buf, os, runparams);
os << "]";
// Return how many newlines we issued.
return nlines;
}
void InsetNote::validate(LaTeXFeatures & features) const void InsetNote::validate(LaTeXFeatures & features) const
{ {
if (params_.type == InsetNoteParams::Comment) if (params_.type == InsetNoteParams::Comment)

View File

@ -62,10 +62,10 @@ public:
/// ///
int latex(Buffer const &, odocstream &, OutputParams const &) const; int latex(Buffer const &, odocstream &, OutputParams const &) const;
/// ///
int docbook(Buffer const &, odocstream &, OutputParams const &) const;
///
int plaintext(Buffer const &, odocstream &, OutputParams const &) const; int plaintext(Buffer const &, odocstream &, OutputParams const &) const;
/// ///
int docbook(Buffer const &, odocstream &, OutputParams const &) const;
///
void validate(LaTeXFeatures &) const; void validate(LaTeXFeatures &) const;
/// ///
InsetNoteParams const & params() const { return params_; } InsetNoteParams const & params() const { return params_; }