Well, it turns out that we need a different return value for the xhtml

routines, one that allows us to "defer" certain material, e.g., a float
that ought to appear in a div but can't simply be put into the middle
of a paragraph.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30079 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2009-06-12 17:23:17 +00:00
parent 12f57a57bd
commit 67e70c6c02
49 changed files with 124 additions and 67 deletions

View File

@ -2349,12 +2349,14 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
}
void Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
odocstream & os,
OutputParams const & runparams,
Font const & outerfont,
pos_type initial) const
{
docstring retval;
// FIXME We really need to manage the tag nesting here.
// Probably in the same sort of way as in output_xhtml.
bool emph_flag = false;
@ -2395,7 +2397,7 @@ void Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
// FIXME Other such tags?
if (Inset const * inset = getInset(i)) {
inset->xhtml(os, runparams);
retval += inset->xhtml(os, runparams);
} else {
char_type c = d->text_[i];
@ -2429,10 +2431,7 @@ void Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
if (bold_flag)
os << "</strong>";
// if (style.free_spacing)
// os << '\n';
// if (style.pass_thru && !d->onlyText(buf, outerfont, initial))
// os << "<![CDATA[";
return retval;
}

View File

@ -157,8 +157,9 @@ public:
OutputParams const & runparams,
Font const & outerfont,
pos_type initial = 0) const;
///
void simpleLyXHTMLOnePar(Buffer const & buf,
/// \return any material that has had to be deferred until after the
/// paragraph has closed.
docstring simpleLyXHTMLOnePar(Buffer const & buf,
odocstream &,
OutputParams const & runparams,
Font const & outerfont,

View File

@ -329,9 +329,10 @@ int Inset::docbook(odocstream &, OutputParams const &) const
}
void Inset::xhtml(odocstream & od, OutputParams const &) const
docstring Inset::xhtml(odocstream & od, OutputParams const &) const
{
od << "[[Inset: " << from_ascii(insetName(lyxCode())) << "]]";
return docstring();
}
bool Inset::directWrite() const

View File

@ -296,7 +296,7 @@ public:
/// docbook output
virtual int docbook(odocstream & os, OutputParams const &) const;
/// LyX HTML output
virtual void xhtml(odocstream & os, OutputParams const &) const;
virtual docstring xhtml(odocstream & os, OutputParams const &) const;
/// the string that is passed to the TOC
virtual void tocString(odocstream &) const {}

View File

@ -266,10 +266,11 @@ void InsetBibitem::updateLabels(ParIterator const &)
}
void InsetBibitem::xhtml(odocstream & os, OutputParams const &) const
docstring InsetBibitem::xhtml(odocstream & os, OutputParams const &) const
{
os << "<a name='" << html::htmlize(getParam("key")) << "'></a>";
os << "<span class='biblabel'>" << bibLabel() << "</span> ";
return docstring();
}

View File

@ -61,7 +61,7 @@ private:
///
int plaintext(odocstream &, OutputParams const &) const;
///
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
///
virtual void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const;
/// Update the counter of this inset

View File

@ -911,7 +911,7 @@ namespace {
}
void InsetBibtex::xhtml(odocstream & os, OutputParams const &) const
docstring InsetBibtex::xhtml(odocstream & os, OutputParams const &) const
{
// We are going to collect all the citation keys used in the document,
// getting them from the TOC.
@ -929,7 +929,7 @@ void InsetBibtex::xhtml(odocstream & os, OutputParams const &) const
citekeys.push_back(*dit);
}
if (citekeys.empty())
return;
return docstring();
sort(citekeys.begin(), citekeys.end());
unique(citekeys.begin(), citekeys.end());
// We now have a sorted, unique list of the keys used in this document.
@ -974,6 +974,7 @@ void InsetBibtex::xhtml(odocstream & os, OutputParams const &) const
}
os << "</div>\n";
return docstring();
}

View File

@ -52,7 +52,7 @@ public:
///
void validate(LaTeXFeatures &) const;
///
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
///
static ParamInfo const & findInfo(std::string const &);
///

View File

@ -27,6 +27,7 @@
#include "TextClass.h"
#include "support/debug.h"
#include "support/docstream.h"
#include "support/gettext.h"
#include "support/lstrings.h"
#include "support/Translator.h"
@ -484,7 +485,7 @@ int InsetBox::docbook(odocstream & os, OutputParams const & runparams) const
}
void InsetBox::xhtml(odocstream & os, OutputParams const & runparams) const
docstring InsetBox::xhtml(odocstream &, OutputParams const & runparams) const
{
string style;
if (!params_.width.empty())
@ -492,12 +493,16 @@ void InsetBox::xhtml(odocstream & os, OutputParams const & runparams) const
if (!params_.height.empty())
style += ("height: " + params_.height.asHTMLString() + ";");
os << from_ascii("<span class='" + params_.type + "'");
docstring retval = from_ascii("<div class='" + params_.type + "'");
if (!style.empty())
os << from_ascii(" style='" + style + "'");
os << ">\n";
InsetText::xhtml(os, runparams);
os << "</span>\n";
retval += from_ascii(" style='" + style + "'");
retval += ">\n";
odocstringstream os;
docstring defer = InsetText::xhtml(os, runparams);
retval += os.str();
retval += "</div>\n";
retval += defer + "\n";
return retval;
}

View File

@ -119,7 +119,7 @@ private:
///
int docbook(odocstream &, OutputParams const &) const;
///
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
///
void validate(LaTeXFeatures &) const;
///

View File

@ -235,10 +235,11 @@ int InsetBranch::docbook(odocstream & os,
}
void InsetBranch::xhtml(odocstream & os, OutputParams const & rp) const
docstring InsetBranch::xhtml(odocstream & os, OutputParams const & rp) const
{
if (isBranchSelected())
InsetText::xhtml(os, rp);
return InsetText::xhtml(os, rp);
return docstring();
}

View File

@ -74,7 +74,7 @@ private:
///
int docbook(odocstream &, OutputParams const &) const;
///
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
///
void tocString(odocstream &) const;
///

View File

@ -504,12 +504,12 @@ int InsetCitation::docbook(odocstream & os, OutputParams const &) const
}
void InsetCitation::xhtml(odocstream & os, OutputParams const &) const
docstring InsetCitation::xhtml(odocstream & os, OutputParams const &) const
{
BiblioInfo const & bi = buffer().masterBibInfo();
docstring const & keyList = getParam("key");
if (keyList.empty())
return;
return docstring();
// FIXME We shuld do a better job outputing different things for the
// different citation styles. For now, we use square brackets for every
@ -541,6 +541,7 @@ void InsetCitation::xhtml(odocstream & os, OutputParams const &) const
if (!after.empty())
os << ", " << after;
os << "]\n";
return docstring();
}

View File

@ -50,7 +50,7 @@ public:
///
int docbook(odocstream &, OutputParams const &) const;
///
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
/// the string that is passed to the TOC
void tocString(odocstream &) const;
///

View File

@ -872,13 +872,11 @@ int InsetCollapsable::docbook(odocstream & os, OutputParams const & runparams) c
}
void InsetCollapsable::xhtml(odocstream & os, OutputParams const & runparams) const
docstring InsetCollapsable::xhtml(odocstream & os, OutputParams const & runparams) const
{
InsetLayout const & il = getLayout();
if (undefined()) {
InsetText::xhtml(os, runparams);
return;
}
if (undefined())
return InsetText::xhtml(os, runparams);
bool const opened = html::openTag(os, il.htmltag(), il.htmlattr());
if (!il.counter().empty()) {
@ -891,11 +889,12 @@ void InsetCollapsable::xhtml(odocstream & os, OutputParams const & runparams) co
bool innertag_opened = false;
if (!il.htmlinnertag().empty())
innertag_opened = html::openTag(os, il.htmlinnertag(), il.htmlinnerattr());
InsetText::xhtml(os, runparams);
docstring deferred = InsetText::xhtml(os, runparams);
if (innertag_opened)
html::closeTag(os, il.htmlinnertag());
if (opened)
html::closeTag(os, il.htmltag());
return deferred;
}

View File

@ -146,7 +146,7 @@ public:
/// It will rarely be right to call this from subclasses, due
/// to the fact that it steps counters, etc. Instead, call
/// InsetText::xhtml().
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
///
void validate(LaTeXFeatures &) const;
///

View File

@ -202,4 +202,9 @@ string InsetERT::params2string(CollapseStatus status)
}
docstring InsetERT::xhtml(odocstream &, OutputParams const &) const
{
return docstring();
}
} // namespace lyx

View File

@ -57,7 +57,7 @@ private:
///
int docbook(odocstream &, OutputParams const &) const;
///
void xhtml(odocstream &, OutputParams const &) const { return; }
docstring xhtml(odocstream &, OutputParams const &) const;
///
void validate(LaTeXFeatures &) const {}
///

View File

@ -181,7 +181,7 @@ int InsetHyperlink::docbook(odocstream & os, OutputParams const &) const
}
void InsetHyperlink::xhtml(odocstream & os, OutputParams const &) const
docstring InsetHyperlink::xhtml(odocstream & os, OutputParams const &) const
{
os << "<a href=\""
// FIXME Do we need to do more escaping than this?
@ -189,6 +189,7 @@ void InsetHyperlink::xhtml(odocstream & os, OutputParams const &) const
<< "\">"
<< getParam("name")
<< "</a>";
return docstring();
}

View File

@ -41,7 +41,7 @@ public:
///
int docbook(odocstream &, OutputParams const &) const;
///
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
/// the string that is passed to the TOC
void tocString(odocstream &) const;
///

View File

@ -171,6 +171,12 @@ int InsetIndex::docbook(odocstream & os, OutputParams const & runparams) const
}
docstring InsetIndex::xhtml(odocstream &, OutputParams const &) const
{
return docstring();
}
bool InsetIndex::showInsetDialog(BufferView * bv) const
{
bv->showDialog("index", params2string(params_),
@ -541,5 +547,9 @@ bool InsetPrintIndex::hasSettings() const
return buffer().masterBuffer()->params().use_indices;
}
docstring InsetPrintIndex::xhtml(odocstream &, OutputParams const &) const
{
return docstring();
}
} // namespace lyx

View File

@ -58,7 +58,7 @@ private:
int docbook(odocstream &, OutputParams const &) const;
/// At the moment, this does nothing. See development/HTML.notes
/// for some remarks on what could be done.
void xhtml(odocstream &, OutputParams const &) const { return; }
docstring xhtml(odocstream &, OutputParams const &) const;
///
int latex(odocstream &, OutputParams const &) const;
///
@ -105,7 +105,7 @@ public:
///
int latex(odocstream &, OutputParams const &) const;
/// Does nothing yet.
void xhtml(odocstream &, OutputParams const &) const { return; }
docstring xhtml(odocstream &, OutputParams const &) const;
///
void doDispatch(Cursor & cur, FuncRequest & cmd);
///

View File

@ -219,9 +219,10 @@ int InsetLabel::docbook(odocstream & os, OutputParams const & runparams) const
}
void InsetLabel::xhtml(odocstream & os, OutputParams const & /*runparams*/) const
docstring InsetLabel::xhtml(odocstream & os, OutputParams const &) const
{
os << "<a name=\"" << html::htmlize(getParam("name")) << "\"></a>";
return docstring();
}
} // namespace lyx

View File

@ -44,7 +44,7 @@ public:
///
int docbook(odocstream &, OutputParams const &) const;
///
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
///
static ParamInfo const & findInfo(std::string const &);
///

View File

@ -85,9 +85,10 @@ int InsetLine::docbook(odocstream & os, OutputParams const &) const
}
void InsetLine::xhtml(odocstream & os, OutputParams const &) const
docstring InsetLine::xhtml(odocstream & os, OutputParams const &) const
{
os << "<hr />\n";
return docstring();
}

View File

@ -35,7 +35,7 @@ public:
///
int docbook(odocstream &, OutputParams const &) const;
///
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
///
void read(Lexer & lex);
///

View File

@ -173,9 +173,10 @@ int InsetNewline::docbook(odocstream & os, OutputParams const &) const
}
void InsetNewline::xhtml(odocstream & os, OutputParams const &) const
docstring InsetNewline::xhtml(odocstream & os, OutputParams const &) const
{
os << "<br />\n";
return docstring();
}

View File

@ -65,7 +65,7 @@ private:
///
int docbook(odocstream &, OutputParams const &) const;
///
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
///
void read(Lexer & lex);
///

View File

@ -247,9 +247,10 @@ int InsetNewpage::docbook(odocstream & os, OutputParams const &) const
}
void InsetNewpage::xhtml(odocstream & os, OutputParams const &) const
docstring InsetNewpage::xhtml(odocstream & os, OutputParams const &) const
{
os << "<br />\n";
return docstring();
}

View File

@ -69,7 +69,7 @@ private:
///
int docbook(odocstream &, OutputParams const &) const;
///
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
///
void read(Lexer & lex);
///

View File

@ -98,6 +98,12 @@ int InsetNomencl::docbook(odocstream & os, OutputParams const &) const
}
docstring InsetNomencl::xhtml(odocstream &, OutputParams const &) const
{
return docstring();
}
int InsetNomencl::docbookGlossary(odocstream & os) const
{
os << "<glossentry id=\"" << nomenclature_entry_id << "\">\n"
@ -192,6 +198,11 @@ bool InsetPrintNomencl::getStatus(Cursor & cur, FuncRequest const & cmd,
}
docstring InsetPrintNomencl::xhtml(odocstream &, OutputParams const &) const
{
return docstring();
}
int InsetPrintNomencl::docbook(odocstream & os, OutputParams const &) const
{

View File

@ -40,7 +40,7 @@ public:
///
int docbook(odocstream &, OutputParams const &) const;
/// Does nothing at the moment.
void xhtml(odocstream &, OutputParams const &) const { return; }
docstring xhtml(odocstream &, OutputParams const &) const;
///
int docbookGlossary(odocstream &) const;
///
@ -66,7 +66,7 @@ public:
///
int docbook(odocstream &, OutputParams const &) const;
/// Does nothing at the moment.
void xhtml(odocstream &, OutputParams const &) const { return; }
docstring xhtml(odocstream &, OutputParams const &) const;
///
InsetCode lyxCode() const;
///

View File

@ -326,12 +326,12 @@ int InsetNote::docbook(odocstream & os, OutputParams const & runparams_in) const
}
void InsetNote::xhtml(odocstream & os, OutputParams const & rp) const
docstring InsetNote::xhtml(odocstream & os, OutputParams const & rp) const
{
if (params_.type == InsetNoteParams::Note)
return;
return docstring();
InsetCollapsable::xhtml(os, rp);
return InsetCollapsable::xhtml(os, rp);
}

View File

@ -91,7 +91,7 @@ private:
///
int docbook(odocstream &, OutputParams const &) const;
///
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
///
void validate(LaTeXFeatures &) const;
///

View File

@ -57,6 +57,11 @@ int InsetOptArg::docbook(odocstream &, OutputParams const &) const
}
docstring InsetOptArg::xhtml(odocstream &, OutputParams const &) const
{
return docstring();
}
int InsetOptArg::latexOptional(odocstream & os,
OutputParams const & runparams) const
{

View File

@ -48,7 +48,7 @@ private:
/// Standard DocBook output -- short-circuited
int docbook(odocstream &, OutputParams const &) const;
/// Standard XHTML output -- short-circuited
void xhtml(odocstream &, OutputParams const &) const { return; }
docstring xhtml(odocstream &, OutputParams const &) const;
/// Write out to the .lyx file
void write(std::ostream & os) const;
/// should paragraph indendation be ommitted in any case?

View File

@ -365,6 +365,11 @@ int InsetPhantom::docbook(odocstream & os, OutputParams const & runparams) const
}
docstring InsetPhantom::xhtml(odocstream &, OutputParams const &) const
{
return docstring();
}
docstring InsetPhantom::contextMenu(BufferView const &, int, int) const
{
return from_ascii("context-phantom");

View File

@ -84,7 +84,7 @@ private:
///
int docbook(odocstream &, OutputParams const &) const;
/// Makes no sense fof XHTML.
void xhtml(odocstream &, OutputParams const &) const { return; }
docstring xhtml(odocstream &, OutputParams const &) const;
///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
///

View File

@ -312,9 +312,10 @@ int InsetQuotes::docbook(odocstream & os, OutputParams const &) const
}
void InsetQuotes::xhtml(odocstream & os, OutputParams const & op) const
docstring InsetQuotes::xhtml(odocstream & os, OutputParams const & op) const
{
docbook(os, op);
return docstring();
}

View File

@ -84,7 +84,7 @@ public:
///
int docbook(odocstream &, OutputParams const &) const;
///
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
/// the string that is passed to the TOC
void tocString(odocstream &) const;

View File

@ -680,7 +680,7 @@ int InsetSpace::docbook(odocstream & os, OutputParams const &) const
}
void InsetSpace::xhtml(odocstream & os, OutputParams const &) const
docstring InsetSpace::xhtml(odocstream & os, OutputParams const &) const
{
switch (params_.kind) {
case InsetSpaceParams::NORMAL:
@ -722,6 +722,7 @@ void InsetSpace::xhtml(odocstream & os, OutputParams const &) const
// FIXME Probably we could do some sort of blank span?
os << '\n';
}
return docstring();
}

View File

@ -129,7 +129,7 @@ public:
///
int docbook(odocstream &, OutputParams const &) const;
///
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
///
void validate(LaTeXFeatures & features) const;
/// the string that is passed to the TOC

View File

@ -291,7 +291,7 @@ int InsetSpecialChar::docbook(odocstream & os, OutputParams const &) const
}
void InsetSpecialChar::xhtml(odocstream & os, OutputParams const &) const
docstring InsetSpecialChar::xhtml(odocstream & os, OutputParams const &) const
{
switch (kind_) {
case HYPHENATION:
@ -313,6 +313,7 @@ void InsetSpecialChar::xhtml(odocstream & os, OutputParams const &) const
os << '-';
break;
}
return docstring();
}

View File

@ -65,7 +65,7 @@ public:
///
int docbook(odocstream &, OutputParams const &) const;
///
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
/// the string that is passed to the TOC
void tocString(odocstream &) const;
///

View File

@ -368,9 +368,10 @@ int InsetText::docbook(odocstream & os, OutputParams const & runparams) const
}
void InsetText::xhtml(odocstream & os, OutputParams const & runparams) const
docstring InsetText::xhtml(odocstream & os, OutputParams const & runparams) const
{
xhtmlParagraphs(paragraphs(), buffer(), os, runparams);
return docstring();
}

View File

@ -81,7 +81,7 @@ public:
///
int docbook(odocstream &, OutputParams const &) const;
///
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
///
void validate(LaTeXFeatures & features) const;

View File

@ -233,7 +233,7 @@ int InsetVSpace::docbook(odocstream & os, OutputParams const &) const
}
void InsetVSpace::xhtml(odocstream & os, OutputParams const &) const
docstring InsetVSpace::xhtml(odocstream & os, OutputParams const &) const
{
string len = space_.asHTMLLength();
if (len.empty())
@ -241,6 +241,7 @@ void InsetVSpace::xhtml(odocstream & os, OutputParams const &) const
os << "<br />\n";
else
os << "<div style='height:" << from_ascii(len) << "'></div>\n";
return docstring();
}

View File

@ -51,7 +51,7 @@ private:
///
int docbook(odocstream &, OutputParams const &) const;
///
void xhtml(odocstream &, OutputParams const &) const;
docstring xhtml(odocstream &, OutputParams const &) const;
///
void read(Lexer & lex);
///

View File

@ -206,12 +206,14 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf,
if (par != pbegin)
os << '\n';
bool const opened = openTag(os, lay);
par->simpleLyXHTMLOnePar(buf, os, runparams,
docstring const deferred = par->simpleLyXHTMLOnePar(buf, os, runparams,
outerFont(distance(paragraphs.begin(), par), paragraphs));
if (opened) {
closeTag(os, lay);
os << '\n';
}
if (!deferred.empty())
os << deferred << '\n';
}
return pend;
}