Move depthHook(), outerHook(), isFirstInSequence(), outerFont() to Text methods.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30957 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2009-08-09 18:35:39 +00:00
parent 5fd5cf41c0
commit 8c053ea10c
13 changed files with 139 additions and 137 deletions

View File

@ -1316,7 +1316,7 @@ void Buffer::writeDocBookSource(odocstream & os, string const & fname,
sgml::openTag(os, top);
os << '\n';
docbookParagraphs(paragraphs(), *this, os, runparams);
docbookParagraphs(text(), *this, os, runparams);
sgml::closeTag(os, top_element);
}
@ -1374,7 +1374,7 @@ void Buffer::writeLyXHTMLSource(odocstream & os,
}
params().documentClass().counters().reset();
xhtmlParagraphs(paragraphs(), *this, os, runparams);
xhtmlParagraphs(text(), *this, os, runparams);
if (!only_body)
os << "</body>\n</html>\n";
}
@ -2580,7 +2580,7 @@ void Buffer::getSourceCode(odocstream & os, pit_type par_begin,
texrow.newline();
// output paragraphs
if (isDocBook())
docbookParagraphs(paragraphs(), *this, os, runparams);
docbookParagraphs(text(), *this, os, runparams);
else
// latex or literate
latexParagraphs(*this, text(), os, texrow, runparams);
@ -3297,7 +3297,7 @@ static void setLabel(Buffer const & buf, ParIterator & it)
case LABEL_COUNTER:
if (layout.toclevel <= bp.secnumdepth
&& (layout.latextype != LATEX_ENVIRONMENT
|| isFirstInSequence(it.pit(), it.plist()))) {
|| it.text()->isFirstInSequence(it.pit()))) {
counters.step(layout.counter);
par.params().labelString(
par.expandLabel(layout, bp));

View File

@ -2002,7 +2002,7 @@ Encoding const * Cursor::getEncoding() const
CursorSlice const & sl = innerTextSlice();
Text const & text = *sl.text();
Font font = text.getPar(sl.pit()).getFont(
bv().buffer().params(), sl.pos(), outerFont(sl.pit(), text.paragraphs()));
bv().buffer().params(), sl.pos(), text.outerFont(sl.pit()));
return font.language()->encoding();
}
@ -2059,7 +2059,7 @@ Font Cursor::getFont() const
// get font at the position
Font font = par.getFont(buffer()->params(), pos,
outerFont(sl.pit(), text.paragraphs()));
text.outerFont(sl.pit()));
return font;
}

View File

@ -171,91 +171,62 @@ void mergeParagraph(BufferParams const & bparams,
}
pit_type depthHook(pit_type pit, ParagraphList const & pars, depth_type depth)
pit_type Text::depthHook(pit_type pit, depth_type depth) const
{
pit_type newpit = pit;
if (newpit != 0)
--newpit;
while (newpit != 0 && pars[newpit].getDepth() > depth)
while (newpit != 0 && pars_[newpit].getDepth() > depth)
--newpit;
if (pars[newpit].getDepth() > depth)
if (pars_[newpit].getDepth() > depth)
return pit;
return newpit;
}
pit_type outerHook(pit_type par_offset, ParagraphList const & pars)
pit_type Text::outerHook(pit_type par_offset) const
{
Paragraph const & par = pars[par_offset];
Paragraph const & par = pars_[par_offset];
if (par.getDepth() == 0)
return pars.size();
return depthHook(par_offset, pars, depth_type(par.getDepth() - 1));
return pars_.size();
return depthHook(par_offset, depth_type(par.getDepth() - 1));
}
bool isFirstInSequence(pit_type par_offset, ParagraphList const & pars)
bool Text::isFirstInSequence(pit_type par_offset) const
{
Paragraph const & par = pars[par_offset];
Paragraph const & par = pars_[par_offset];
pit_type dhook_offset = depthHook(par_offset, pars, par.getDepth());
pit_type dhook_offset = depthHook(par_offset, par.getDepth());
if (dhook_offset == par_offset)
return true;
Paragraph const & dhook = pars[dhook_offset];
Paragraph const & dhook = pars_[dhook_offset];
return dhook.layout() != par.layout()
|| dhook.getDepth() != par.getDepth();
}
int getEndLabel(pit_type p, ParagraphList const & pars)
Font const Text::outerFont(pit_type par_offset) const
{
pit_type pit = p;
depth_type par_depth = pars[p].getDepth();
while (pit != pit_type(pars.size())) {
Layout const & layout = pars[pit].layout();
int const endlabeltype = layout.endlabeltype;
if (endlabeltype != END_LABEL_NO_LABEL) {
if (p + 1 == pit_type(pars.size()))
return endlabeltype;
depth_type const next_depth =
pars[p + 1].getDepth();
if (par_depth > next_depth ||
(par_depth == next_depth && layout != pars[p + 1].layout()))
return endlabeltype;
break;
}
if (par_depth == 0)
break;
pit = outerHook(pit, pars);
if (pit != pit_type(pars.size()))
par_depth = pars[pit].getDepth();
}
return END_LABEL_NO_LABEL;
}
Font const outerFont(pit_type par_offset, ParagraphList const & pars)
{
depth_type par_depth = pars[par_offset].getDepth();
depth_type par_depth = pars_[par_offset].getDepth();
FontInfo tmpfont = inherit_font;
// Resolve against environment font information
while (par_offset != pit_type(pars.size())
while (par_offset != pit_type(pars_.size())
&& par_depth
&& !tmpfont.resolved()) {
par_offset = outerHook(par_offset, pars);
if (par_offset != pit_type(pars.size())) {
tmpfont.realize(pars[par_offset].layout().font);
par_depth = pars[par_offset].getDepth();
par_offset = outerHook(par_offset);
if (par_offset != pit_type(pars_.size())) {
tmpfont.realize(pars_[par_offset].layout().font);
par_depth = pars_[par_offset].getDepth();
}
}
@ -561,10 +532,11 @@ double Text::spacing(Paragraph const & par) const
* keep_layout == false
* - keep current depth and layout when keep_layout == true
*/
static void breakParagraph(BufferParams const & bparams,
ParagraphList & pars, pit_type par_offset, pos_type pos,
static void breakParagraph(Text & text, pit_type par_offset, pos_type pos,
bool keep_layout)
{
BufferParams const & bparams = text.inset().buffer().params();
ParagraphList & pars = text.paragraphs();
// create a new paragraph, and insert into the list
ParagraphList::iterator tmp =
pars.insert(boost::next(pars.begin(), par_offset + 1),
@ -584,7 +556,7 @@ static void breakParagraph(BufferParams const & bparams,
tmp->setLabelWidthString(par.params().labelWidthString());
tmp->params().depth(par.params().depth());
} else if (par.params().depth() > 0) {
Paragraph const & hook = pars[outerHook(par_offset, pars)];
Paragraph const & hook = pars[text.outerHook(par_offset)];
tmp->setLayout(hook.layout());
// not sure the line below is useful
tmp->setLabelWidthString(par.params().labelWidthString());
@ -689,8 +661,7 @@ void Text::breakParagraph(Cursor & cur, bool inverse_logic)
// we need to set this before we insert the paragraph.
bool const isempty = cpar.allowEmpty() && cpar.empty();
lyx::breakParagraph(cur.buffer()->params(), paragraphs(), cpit,
cur.pos(), keep_layout);
lyx::breakParagraph(*this, cpit, cur.pos(), keep_layout);
// After this, neither paragraph contains any rows!
@ -743,8 +714,8 @@ void Text::insertStringAsLines(DocIterator const & dit, docstring const & str,
Paragraph & par = pars_[pit];
if (*cit == '\n') {
if (autoBreakRows_ && (!par.empty() || par.allowEmpty())) {
lyx::breakParagraph(bparams, pars_, pit, pos,
par.layout().isEnvironment());
lyx::breakParagraph(*this, pit, pos,
par.layout().isEnvironment());
++pit;
pos = 0;
space_inserted = true;

View File

@ -312,6 +312,15 @@ public:
bool insertCompletion(Cursor & cur, docstring const & s, bool /*finished*/);
///
docstring completionPrefix(Cursor const & cur) const;
/// for the environments
pit_type depthHook(pit_type par, depth_type depth) const;
///
pit_type outerHook(pit_type par) const;
/// Is it the first par with same depth and layout?
bool isFirstInSequence(pit_type par) const;
/// Get the font of the "environment" of paragraph \p par_offset in \p pars.
/// All font changes of the paragraph are relative to this font.
Font const outerFont(pit_type par_offset) const;
private:
/// The InsetText owner shall have access to everything.
@ -375,26 +384,6 @@ void breakParagraphConservative(BufferParams const & bparams,
void mergeParagraph(BufferParams const & bparams,
ParagraphList & paragraphs, pit_type par);
/// for the environments
pit_type depthHook(pit_type par,
ParagraphList const & plist, depth_type depth);
pit_type outerHook(pit_type par, ParagraphList const & plist);
/// Is it the first par with same depth and layout?
bool isFirstInSequence(pit_type par, ParagraphList const & plist);
/** Check if the current paragraph is the last paragraph in a
proof environment */
int getEndLabel(pit_type par, ParagraphList const & plist);
/**
* Get the font of the "environment" of paragraph \p par_offset in \p pars.
* All font changes of the paragraph are relative to this font.
*/
Font const outerFont(pit_type par_offset, ParagraphList const & pars);
/// accept the changes within the complete ParagraphList
void acceptChanges(ParagraphList & pars, BufferParams const & bparams);

View File

@ -94,7 +94,7 @@ FontInfo Text::layoutFont(pit_type const pit) const
FontInfo font = layout.font;
// Realize with the fonts of lesser depth.
//font.realize(outerFont(pit, paragraphs()));
//font.realize(outerFont(pit));
font.realize(owner_->buffer().params().getFont().fontInfo());
return font;
@ -144,7 +144,7 @@ void Text::setCharFont(pit_type pit,
while (!layoutfont.resolved() &&
tp != pit_type(paragraphs().size()) &&
pars_[tp].getDepth()) {
tp = outerHook(tp, paragraphs());
tp = outerHook(tp);
if (tp != pit_type(paragraphs().size()))
layoutfont.realize(pars_[tp].layout().font);
}
@ -436,8 +436,8 @@ void Text::setLabelWidthStringToSequence(pit_type const par_offset,
{
pit_type offset = par_offset;
// Find first of same layout in sequence
while (!isFirstInSequence(offset, pars_)) {
offset = depthHook(offset, pars_, pars_[offset].getDepth());
while (!isFirstInSequence(offset)) {
offset = depthHook(offset, pars_[offset].getDepth());
}
// now apply label width string to every par

View File

@ -292,7 +292,7 @@ Font TextMetrics::displayFont(pit_type pit, pos_type pos) const
// NOTE: the cast to pit_type should be removed when pit_type
// changes to a unsigned integer.
if (pit < pit_type(pars.size()))
font.fontInfo().realize(outerFont(pit, pars).fontInfo());
font.fontInfo().realize(text_->outerFont(pit).fontInfo());
// Realize with the fonts of lesser depth.
font.fontInfo().realize(params.getFont().fontInfo());
@ -1074,7 +1074,7 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first,
if ((layout.labeltype == LABEL_TOP_ENVIRONMENT
|| layout.labeltype == LABEL_BIBLIO
|| layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
&& isFirstInSequence(pit, pars)
&& text_->isFirstInSequence(pit)
&& !par.labelString().empty())
{
labeladdon = int(
@ -1088,7 +1088,7 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first,
// a section, or between the items of a itemize or enumerate
// environment.
pit_type prev = depthHook(pit, pars, par.getDepth());
pit_type prev = text_->depthHook(pit, par.getDepth());
Paragraph const & prevpar = pars[prev];
if (prev != pit
&& prevpar.layout() == layout
@ -1101,7 +1101,7 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first,
layoutasc = layout.topsep * dh;
}
prev = outerHook(pit, pars);
prev = text_->outerHook(pit);
if (prev != pit_type(pars.size())) {
maxasc += int(pars[prev].layout().parsep * dh);
} else if (pit != 0) {
@ -1126,7 +1126,7 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first,
if (pars[cpit].getDepth() > pars[nextpit].getDepth()) {
usual = pars[cpit].layout().bottomsep * dh;
cpit = depthHook(cpit, pars, pars[nextpit].getDepth());
cpit = text_->depthHook(cpit, pars[nextpit].getDepth());
if (pars[cpit].layout() != pars[nextpit].layout()
|| pars[nextpit].getLabelWidthString() != pars[cpit].getLabelWidthString())
{
@ -1844,7 +1844,7 @@ int TextMetrics::leftMargin(int max_width,
if (par.getDepth() != 0) {
// find the next level paragraph
pit_type newpar = outerHook(pit, pars);
pit_type newpar = text_->outerHook(pit);
if (newpar != pit_type(pars.size())) {
if (pars[newpar].layout().isEnvironment()) {
l_margin = leftMargin(max_width, newpar);
@ -1913,7 +1913,7 @@ int TextMetrics::leftMargin(int max_width,
// theorems (JMarc)
|| (layout.labeltype == LABEL_STATIC
&& layout.latextype == LATEX_ENVIRONMENT
&& !isFirstInSequence(pit, pars))) {
&& !text_->isFirstInSequence(pit))) {
l_margin += labelfont_metrics.signedWidth(layout.leftmargin);
} else if (layout.labeltype != LABEL_TOP_ENVIRONMENT
&& layout.labeltype != LABEL_BIBLIO
@ -1962,7 +1962,7 @@ int TextMetrics::leftMargin(int max_width,
|| layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
|| (layout.labeltype == LABEL_STATIC
&& layout.latextype == LATEX_ENVIRONMENT
&& !isFirstInSequence(pit, pars)))
&& !text_->isFirstInSequence(pit)))
&& align == LYX_ALIGN_BLOCK
&& !par.params().noindent()
// in some insets, paragraphs are never indented

View File

@ -455,7 +455,7 @@ int InsetText::docbook(odocstream & os, OutputParams const & runparams) const
sgml::openTag(os, getLayout().latexname(),
beg->getID(buffer(), runparams) + getLayout().latexparam());
docbookParagraphs(paragraphs(), buffer(), os, runparams);
docbookParagraphs(text_, buffer(), os, runparams);
if (!undefined())
sgml::closeTag(os, getLayout().latexname());
@ -468,7 +468,7 @@ docstring InsetText::xhtml(odocstream & os, OutputParams const & runparams) cons
{
InsetLayout const & il = getLayout();
if (undefined()) {
xhtmlParagraphs(paragraphs(), buffer(), os, runparams);
xhtmlParagraphs(text_, buffer(), os, runparams);
return docstring();
}
@ -485,7 +485,7 @@ docstring InsetText::xhtml(odocstream & os, OutputParams const & runparams) cons
if (!il.htmlinnertag().empty())
innertag_opened = html::openTag(os, il.htmlinnertag(), il.htmlinnerattr());
xhtmlParagraphs(paragraphs(), buffer(), os, runparams);
xhtmlParagraphs(text_, buffer(), os, runparams);
if (innertag_opened)
html::closeTag(os, il.htmlinnertag());

View File

@ -97,21 +97,22 @@ ParagraphList::const_iterator searchEnvironment(
ParagraphList::const_iterator makeParagraph(Buffer const & buf,
odocstream & os,
OutputParams const & runparams,
ParagraphList const & paragraphs,
Text const & text,
ParagraphList::const_iterator const & pbegin,
ParagraphList::const_iterator const & pend)
{
ParagraphList const & paragraphs = text.paragraphs();
for (ParagraphList::const_iterator par = pbegin; par != pend; ++par) {
if (par != pbegin)
os << '\n';
if (buf.params().documentClass().isDefaultLayout(par->layout())
&& par->emptyTag()) {
par->simpleDocBookOnePar(buf, os, runparams,
outerFont(distance(paragraphs.begin(), par), paragraphs));
text.outerFont(distance(paragraphs.begin(), par)));
} else {
sgml::openTag(buf, os, runparams, *par);
par->simpleDocBookOnePar(buf, os, runparams,
outerFont(distance(paragraphs.begin(), par), paragraphs));
text.outerFont(distance(paragraphs.begin(), par)));
sgml::closeTag(os, *par);
}
}
@ -122,9 +123,11 @@ ParagraphList::const_iterator makeParagraph(Buffer const & buf,
ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
odocstream & os,
OutputParams const & runparams,
ParagraphList const & paragraphs,
Text const & text,
ParagraphList::const_iterator const & pbegin,
ParagraphList::const_iterator const & pend) {
ParagraphList::const_iterator const & pend)
{
ParagraphList const & paragraphs = text.paragraphs();
ParagraphList::const_iterator par = pbegin;
Layout const & defaultstyle = buf.params().documentClass().defaultLayout();
@ -176,19 +179,20 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
case LATEX_ITEM_ENVIRONMENT: {
if (par->params().depth() == pbegin->params().depth()) {
sgml::openTag(os, wrapper);
par->simpleDocBookOnePar(buf, os, runparams, outerFont(distance(paragraphs.begin(), par), paragraphs), sep);
par->simpleDocBookOnePar(buf, os, runparams,
text.outerFont(distance(paragraphs.begin(), par)), sep);
sgml::closeTag(os, wrapper);
++par;
}
else {
send = searchEnvironment(par, pend);
par = makeEnvironment(buf, os, runparams, paragraphs, par,send);
par = makeEnvironment(buf, os, runparams, text, par,send);
}
break;
}
case LATEX_PARAGRAPH:
send = searchParagraph(par, pend);
par = makeParagraph(buf, os, runparams, paragraphs, par,send);
par = makeParagraph(buf, os, runparams, text, par,send);
break;
case LATEX_LIST_ENVIRONMENT:
case LATEX_BIB_ENVIRONMENT:
@ -240,10 +244,11 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
ParagraphList::const_iterator makeCommand(Buffer const & buf,
odocstream & os,
OutputParams const & runparams,
ParagraphList const & paragraphs,
Text const & text,
ParagraphList::const_iterator const & pbegin,
ParagraphList::const_iterator const & pend)
{
ParagraphList const & paragraphs = text.paragraphs();
ParagraphList::const_iterator par = pbegin;
Layout const & bstyle = par->layout();
@ -261,7 +266,8 @@ ParagraphList::const_iterator makeCommand(Buffer const & buf,
// Opend inner tag and close inner tags
sgml::openTag(os, bstyle.innertag());
par->simpleDocBookOnePar(buf, os, runparams, outerFont(distance(paragraphs.begin(), par), paragraphs));
par->simpleDocBookOnePar(buf, os, runparams,
text.outerFont(distance(paragraphs.begin(), par)));
sgml::closeTag(os, bstyle.innertag());
os << '\n';
@ -273,18 +279,18 @@ ParagraphList::const_iterator makeCommand(Buffer const & buf,
switch (style.latextype) {
case LATEX_COMMAND: {
send = searchCommand(par, pend);
par = makeCommand(buf, os, runparams, paragraphs, par,send);
par = makeCommand(buf, os, runparams, text, par,send);
break;
}
case LATEX_ENVIRONMENT:
case LATEX_ITEM_ENVIRONMENT: {
send = searchEnvironment(par, pend);
par = makeEnvironment(buf, os, runparams, paragraphs, par,send);
par = makeEnvironment(buf, os, runparams, text, par,send);
break;
}
case LATEX_PARAGRAPH:
send = searchParagraph(par, pend);
par = makeParagraph(buf, os, runparams, paragraphs, par,send);
par = makeParagraph(buf, os, runparams, text, par,send);
break;
default:
break;
@ -299,11 +305,12 @@ ParagraphList::const_iterator makeCommand(Buffer const & buf,
} // end anonym namespace
void docbookParagraphs(ParagraphList const & paragraphs,
void docbookParagraphs(Text const & text,
Buffer const & buf,
odocstream & os,
OutputParams const & runparams)
{
ParagraphList const & paragraphs = text.paragraphs();
ParagraphList::const_iterator par = paragraphs.begin();
ParagraphList::const_iterator pend = paragraphs.end();
@ -326,18 +333,18 @@ void docbookParagraphs(ParagraphList const & paragraphs,
switch (style.latextype) {
case LATEX_COMMAND: {
send = searchCommand(par, pend);
par = makeCommand(buf, os, runparams, paragraphs, par,send);
par = makeCommand(buf, os, runparams, text, par,send);
break;
}
case LATEX_ENVIRONMENT:
case LATEX_ITEM_ENVIRONMENT: {
send = searchEnvironment(par, pend);
par = makeEnvironment(buf, os, runparams, paragraphs, par,send);
par = makeEnvironment(buf, os, runparams, text, par,send);
break;
}
case LATEX_PARAGRAPH:
send = searchParagraph(par, pend);
par = makeParagraph(buf, os, runparams, paragraphs, par,send);
par = makeParagraph(buf, os, runparams, text, par,send);
break;
default:
break;

View File

@ -19,10 +19,10 @@ namespace lyx {
class Buffer;
class OutputParams;
class ParagraphList;
class Text;
///
void docbookParagraphs(ParagraphList const & subset,
void docbookParagraphs(Text const & text,
Buffer const & buf,
odocstream & os,
OutputParams const & runparams);

View File

@ -313,7 +313,7 @@ ParagraphList::const_iterator TeXOnePar(Buffer const & buf,
if (runparams.verbatim) {
int const dist = distance(paragraphs.begin(), pit);
Font const outerfont = outerFont(dist, paragraphs);
Font const outerfont = text.outerFont(dist);
// No newline if only one paragraph in this lyxtext
if (dist > 0) {
@ -556,8 +556,7 @@ ParagraphList::const_iterator TeXOnePar(Buffer const & buf,
break;
}
Font const outerfont = outerFont(distance(paragraphs.begin(), pit),
paragraphs);
Font const outerfont = text.outerFont(distance(paragraphs.begin(), pit));
// FIXME UNICODE
os << from_utf8(everypar);

View File

@ -192,10 +192,11 @@ ParagraphList::const_iterator searchEnvironment(
ParagraphList::const_iterator makeParagraphs(Buffer const & buf,
odocstream & os,
OutputParams const & runparams,
ParagraphList const & paragraphs,
Text const & text,
ParagraphList::const_iterator const & pbegin,
ParagraphList::const_iterator const & pend)
{
ParagraphList::const_iterator const begin = text.paragraphs().begin();
ParagraphList::const_iterator par = pbegin;
for (; par != pend; ++par) {
Layout const & lay = par->layout();
@ -207,7 +208,7 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf,
os << '\n';
bool const opened = openTag(os, lay);
docstring const deferred = par->simpleLyXHTMLOnePar(buf, os, runparams,
outerFont(distance(paragraphs.begin(), par), paragraphs));
text.outerFont(distance(begin, par)));
if (opened) {
closeTag(os, lay);
os << '\n';
@ -222,7 +223,7 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf,
ParagraphList::const_iterator makeBibliography(Buffer const & buf,
odocstream & os,
OutputParams const & runparams,
ParagraphList const & paragraphs,
Text const & text,
ParagraphList::const_iterator const & pbegin,
ParagraphList::const_iterator const & pend)
{
@ -230,7 +231,7 @@ ParagraphList::const_iterator makeBibliography(Buffer const & buf,
<< pbegin->layout().labelstring(false)
<< "</h2>\n"
<< "<div class='bibliography'>\n";
makeParagraphs(buf, os, runparams, paragraphs, pbegin, pend);
makeParagraphs(buf, os, runparams, text, pbegin, pend);
os << "</div>";
return pend;
}
@ -239,10 +240,11 @@ ParagraphList::const_iterator makeBibliography(Buffer const & buf,
ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
odocstream & os,
OutputParams const & runparams,
ParagraphList const & paragraphs,
Text const & text,
ParagraphList::const_iterator const & pbegin,
ParagraphList::const_iterator const & pend)
{
ParagraphList::const_iterator const begin = text.paragraphs().begin();
ParagraphList::const_iterator par = pbegin;
Layout const & bstyle = par->layout();
depth_type const origdepth = pbegin->params().depth();
@ -301,7 +303,7 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
else
os << "<span class='item'>";
par->simpleLyXHTMLOnePar(buf, os, runparams,
outerFont(distance(paragraphs.begin(), par), paragraphs), sep);
text.outerFont(distance(begin, par)), sep);
if (!labelfirst)
os << "</span>";
++par;
@ -326,19 +328,19 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
// case we need to recurse.
else {
send = searchEnvironment(par, pend);
par = makeEnvironment(buf, os, runparams, paragraphs, par, send);
par = makeEnvironment(buf, os, runparams, text, par, send);
}
break;
}
case LATEX_PARAGRAPH:
send = searchParagraph(par, pend);
par = makeParagraphs(buf, os, runparams, paragraphs, par, send);
par = makeParagraphs(buf, os, runparams, text, par, send);
break;
// Shouldn't happen
case LATEX_BIB_ENVIRONMENT:
send = par;
++send;
par = makeParagraphs(buf, os, runparams, paragraphs, par, send);
par = makeParagraphs(buf, os, runparams, text, par, send);
break;
// Shouldn't happen
case LATEX_COMMAND:
@ -359,7 +361,7 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
void makeCommand(Buffer const & buf,
odocstream & os,
OutputParams const & runparams,
ParagraphList const & paragraphs,
Text const & text,
ParagraphList::const_iterator const & pbegin)
{
Layout const & style = pbegin->layout();
@ -379,8 +381,9 @@ void makeCommand(Buffer const & buf,
os << ' ';
}
ParagraphList::const_iterator const begin = text.paragraphs().begin();
pbegin->simpleLyXHTMLOnePar(buf, os, runparams,
outerFont(distance(paragraphs.begin(), pbegin), paragraphs));
text.outerFont(distance(begin, pbegin)));
if (main_tag_opened)
closeTag(os, style);
os << '\n';
@ -389,11 +392,12 @@ void makeCommand(Buffer const & buf,
} // end anonymous namespace
void xhtmlParagraphs(ParagraphList const & paragraphs,
void xhtmlParagraphs(Text const & text,
Buffer const & buf,
odocstream & os,
OutputParams const & runparams)
{
ParagraphList const & paragraphs = text.paragraphs();
ParagraphList::const_iterator par = paragraphs.begin();
ParagraphList::const_iterator pend = paragraphs.end();
@ -406,7 +410,7 @@ void xhtmlParagraphs(ParagraphList const & paragraphs,
case LATEX_COMMAND: {
// The files with which we are working never have more than
// one paragraph in a command structure.
makeCommand(buf, os, runparams, paragraphs, par);
makeCommand(buf, os, runparams, text, par);
++par;
break;
}
@ -414,17 +418,17 @@ void xhtmlParagraphs(ParagraphList const & paragraphs,
case LATEX_LIST_ENVIRONMENT:
case LATEX_ITEM_ENVIRONMENT: {
send = searchEnvironment(par, pend);
par = makeEnvironment(buf, os, runparams, paragraphs, par, send);
par = makeEnvironment(buf, os, runparams, text, par, send);
break;
}
case LATEX_BIB_ENVIRONMENT: {
send = searchEnvironment(par, pend);
par = makeBibliography(buf, os, runparams, paragraphs, par, send);
par = makeBibliography(buf, os, runparams, text, par, send);
break;
}
case LATEX_PARAGRAPH:
send = searchParagraph(par, pend);
par = makeParagraphs(buf, os, runparams, paragraphs, par, send);
par = makeParagraphs(buf, os, runparams, text, par, send);
break;
}
// FIXME??

View File

@ -18,10 +18,10 @@ namespace lyx {
class Buffer;
class OutputParams;
class ParagraphList;
class Text;
///
void xhtmlParagraphs(ParagraphList const & subset,
void xhtmlParagraphs(Text const & text,
Buffer const & buf,
odocstream & os,
OutputParams const & runparams);

View File

@ -503,7 +503,7 @@ void RowPainter::paintFirst()
}
bool const is_rtl = text_.isRTL(par_);
bool const is_seq = isFirstInSequence(pit_, text_.paragraphs());
bool const is_seq = text_.isFirstInSequence(pit_);
//lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << endl;
// should we print a label?
@ -593,10 +593,42 @@ void RowPainter::paintFirst()
}
/** Check if the current paragraph is the last paragraph in a
proof environment */
static int getEndLabel(pit_type p, Text const & text)
{
ParagraphList const & pars = text.paragraphs();
pit_type pit = p;
depth_type par_depth = pars[p].getDepth();
while (pit != pit_type(pars.size())) {
Layout const & layout = pars[pit].layout();
int const endlabeltype = layout.endlabeltype;
if (endlabeltype != END_LABEL_NO_LABEL) {
if (p + 1 == pit_type(pars.size()))
return endlabeltype;
depth_type const next_depth =
pars[p + 1].getDepth();
if (par_depth > next_depth ||
(par_depth == next_depth && layout != pars[p + 1].layout()))
return endlabeltype;
break;
}
if (par_depth == 0)
break;
pit = text.outerHook(pit);
if (pit != pit_type(pars.size()))
par_depth = pars[pit].getDepth();
}
return END_LABEL_NO_LABEL;
}
void RowPainter::paintLast()
{
bool const is_rtl = text_.isRTL(par_);
int const endlabel = getEndLabel(pit_, text_.paragraphs());
int const endlabel = getEndLabel(pit_, text_);
// paint imaginary end-of-paragraph character