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

View File

@ -2002,7 +2002,7 @@ Encoding const * Cursor::getEncoding() const
CursorSlice const & sl = innerTextSlice(); CursorSlice const & sl = innerTextSlice();
Text const & text = *sl.text(); Text const & text = *sl.text();
Font font = text.getPar(sl.pit()).getFont( 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(); return font.language()->encoding();
} }
@ -2059,7 +2059,7 @@ Font Cursor::getFont() const
// get font at the position // get font at the position
Font font = par.getFont(buffer()->params(), pos, Font font = par.getFont(buffer()->params(), pos,
outerFont(sl.pit(), text.paragraphs())); text.outerFont(sl.pit()));
return font; 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; pit_type newpit = pit;
if (newpit != 0) if (newpit != 0)
--newpit; --newpit;
while (newpit != 0 && pars[newpit].getDepth() > depth) while (newpit != 0 && pars_[newpit].getDepth() > depth)
--newpit; --newpit;
if (pars[newpit].getDepth() > depth) if (pars_[newpit].getDepth() > depth)
return pit; return pit;
return newpit; 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) if (par.getDepth() == 0)
return pars.size(); return pars_.size();
return depthHook(par_offset, pars, depth_type(par.getDepth() - 1)); 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) if (dhook_offset == par_offset)
return true; return true;
Paragraph const & dhook = pars[dhook_offset]; Paragraph const & dhook = pars_[dhook_offset];
return dhook.layout() != par.layout() return dhook.layout() != par.layout()
|| dhook.getDepth() != par.getDepth(); || 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_[par_offset].getDepth();
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();
FontInfo tmpfont = inherit_font; FontInfo tmpfont = inherit_font;
// Resolve against environment font information // Resolve against environment font information
while (par_offset != pit_type(pars.size()) while (par_offset != pit_type(pars_.size())
&& par_depth && par_depth
&& !tmpfont.resolved()) { && !tmpfont.resolved()) {
par_offset = outerHook(par_offset, pars); par_offset = outerHook(par_offset);
if (par_offset != pit_type(pars.size())) { if (par_offset != pit_type(pars_.size())) {
tmpfont.realize(pars[par_offset].layout().font); tmpfont.realize(pars_[par_offset].layout().font);
par_depth = pars[par_offset].getDepth(); par_depth = pars_[par_offset].getDepth();
} }
} }
@ -561,10 +532,11 @@ double Text::spacing(Paragraph const & par) const
* keep_layout == false * keep_layout == false
* - keep current depth and layout when keep_layout == true * - keep current depth and layout when keep_layout == true
*/ */
static void breakParagraph(BufferParams const & bparams, static void breakParagraph(Text & text, pit_type par_offset, pos_type pos,
ParagraphList & pars, pit_type par_offset, pos_type pos,
bool keep_layout) bool keep_layout)
{ {
BufferParams const & bparams = text.inset().buffer().params();
ParagraphList & pars = text.paragraphs();
// create a new paragraph, and insert into the list // create a new paragraph, and insert into the list
ParagraphList::iterator tmp = ParagraphList::iterator tmp =
pars.insert(boost::next(pars.begin(), par_offset + 1), 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->setLabelWidthString(par.params().labelWidthString());
tmp->params().depth(par.params().depth()); tmp->params().depth(par.params().depth());
} else if (par.params().depth() > 0) { } 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()); tmp->setLayout(hook.layout());
// not sure the line below is useful // not sure the line below is useful
tmp->setLabelWidthString(par.params().labelWidthString()); 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. // we need to set this before we insert the paragraph.
bool const isempty = cpar.allowEmpty() && cpar.empty(); bool const isempty = cpar.allowEmpty() && cpar.empty();
lyx::breakParagraph(cur.buffer()->params(), paragraphs(), cpit, lyx::breakParagraph(*this, cpit, cur.pos(), keep_layout);
cur.pos(), keep_layout);
// After this, neither paragraph contains any rows! // After this, neither paragraph contains any rows!
@ -743,8 +714,8 @@ void Text::insertStringAsLines(DocIterator const & dit, docstring const & str,
Paragraph & par = pars_[pit]; Paragraph & par = pars_[pit];
if (*cit == '\n') { if (*cit == '\n') {
if (autoBreakRows_ && (!par.empty() || par.allowEmpty())) { if (autoBreakRows_ && (!par.empty() || par.allowEmpty())) {
lyx::breakParagraph(bparams, pars_, pit, pos, lyx::breakParagraph(*this, pit, pos,
par.layout().isEnvironment()); par.layout().isEnvironment());
++pit; ++pit;
pos = 0; pos = 0;
space_inserted = true; space_inserted = true;

View File

@ -312,6 +312,15 @@ public:
bool insertCompletion(Cursor & cur, docstring const & s, bool /*finished*/); bool insertCompletion(Cursor & cur, docstring const & s, bool /*finished*/);
/// ///
docstring completionPrefix(Cursor const & cur) const; 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: private:
/// The InsetText owner shall have access to everything. /// The InsetText owner shall have access to everything.
@ -375,26 +384,6 @@ void breakParagraphConservative(BufferParams const & bparams,
void mergeParagraph(BufferParams const & bparams, void mergeParagraph(BufferParams const & bparams,
ParagraphList & paragraphs, pit_type par); 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 /// accept the changes within the complete ParagraphList
void acceptChanges(ParagraphList & pars, BufferParams const & bparams); 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; FontInfo font = layout.font;
// Realize with the fonts of lesser depth. // Realize with the fonts of lesser depth.
//font.realize(outerFont(pit, paragraphs())); //font.realize(outerFont(pit));
font.realize(owner_->buffer().params().getFont().fontInfo()); font.realize(owner_->buffer().params().getFont().fontInfo());
return font; return font;
@ -144,7 +144,7 @@ void Text::setCharFont(pit_type pit,
while (!layoutfont.resolved() && while (!layoutfont.resolved() &&
tp != pit_type(paragraphs().size()) && tp != pit_type(paragraphs().size()) &&
pars_[tp].getDepth()) { pars_[tp].getDepth()) {
tp = outerHook(tp, paragraphs()); tp = outerHook(tp);
if (tp != pit_type(paragraphs().size())) if (tp != pit_type(paragraphs().size()))
layoutfont.realize(pars_[tp].layout().font); layoutfont.realize(pars_[tp].layout().font);
} }
@ -436,8 +436,8 @@ void Text::setLabelWidthStringToSequence(pit_type const par_offset,
{ {
pit_type offset = par_offset; pit_type offset = par_offset;
// Find first of same layout in sequence // Find first of same layout in sequence
while (!isFirstInSequence(offset, pars_)) { while (!isFirstInSequence(offset)) {
offset = depthHook(offset, pars_, pars_[offset].getDepth()); offset = depthHook(offset, pars_[offset].getDepth());
} }
// now apply label width string to every par // 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 // NOTE: the cast to pit_type should be removed when pit_type
// changes to a unsigned integer. // changes to a unsigned integer.
if (pit < pit_type(pars.size())) 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. // Realize with the fonts of lesser depth.
font.fontInfo().realize(params.getFont().fontInfo()); 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 if ((layout.labeltype == LABEL_TOP_ENVIRONMENT
|| layout.labeltype == LABEL_BIBLIO || layout.labeltype == LABEL_BIBLIO
|| layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) || layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
&& isFirstInSequence(pit, pars) && text_->isFirstInSequence(pit)
&& !par.labelString().empty()) && !par.labelString().empty())
{ {
labeladdon = int( 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 // a section, or between the items of a itemize or enumerate
// environment. // environment.
pit_type prev = depthHook(pit, pars, par.getDepth()); pit_type prev = text_->depthHook(pit, par.getDepth());
Paragraph const & prevpar = pars[prev]; Paragraph const & prevpar = pars[prev];
if (prev != pit if (prev != pit
&& prevpar.layout() == layout && prevpar.layout() == layout
@ -1101,7 +1101,7 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first,
layoutasc = layout.topsep * dh; layoutasc = layout.topsep * dh;
} }
prev = outerHook(pit, pars); prev = text_->outerHook(pit);
if (prev != pit_type(pars.size())) { if (prev != pit_type(pars.size())) {
maxasc += int(pars[prev].layout().parsep * dh); maxasc += int(pars[prev].layout().parsep * dh);
} else if (pit != 0) { } 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()) { if (pars[cpit].getDepth() > pars[nextpit].getDepth()) {
usual = pars[cpit].layout().bottomsep * dh; 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() if (pars[cpit].layout() != pars[nextpit].layout()
|| pars[nextpit].getLabelWidthString() != pars[cpit].getLabelWidthString()) || pars[nextpit].getLabelWidthString() != pars[cpit].getLabelWidthString())
{ {
@ -1844,7 +1844,7 @@ int TextMetrics::leftMargin(int max_width,
if (par.getDepth() != 0) { if (par.getDepth() != 0) {
// find the next level paragraph // find the next level paragraph
pit_type newpar = outerHook(pit, pars); pit_type newpar = text_->outerHook(pit);
if (newpar != pit_type(pars.size())) { if (newpar != pit_type(pars.size())) {
if (pars[newpar].layout().isEnvironment()) { if (pars[newpar].layout().isEnvironment()) {
l_margin = leftMargin(max_width, newpar); l_margin = leftMargin(max_width, newpar);
@ -1913,7 +1913,7 @@ int TextMetrics::leftMargin(int max_width,
// theorems (JMarc) // theorems (JMarc)
|| (layout.labeltype == LABEL_STATIC || (layout.labeltype == LABEL_STATIC
&& layout.latextype == LATEX_ENVIRONMENT && layout.latextype == LATEX_ENVIRONMENT
&& !isFirstInSequence(pit, pars))) { && !text_->isFirstInSequence(pit))) {
l_margin += labelfont_metrics.signedWidth(layout.leftmargin); l_margin += labelfont_metrics.signedWidth(layout.leftmargin);
} else if (layout.labeltype != LABEL_TOP_ENVIRONMENT } else if (layout.labeltype != LABEL_TOP_ENVIRONMENT
&& layout.labeltype != LABEL_BIBLIO && layout.labeltype != LABEL_BIBLIO
@ -1962,7 +1962,7 @@ int TextMetrics::leftMargin(int max_width,
|| layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT || layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
|| (layout.labeltype == LABEL_STATIC || (layout.labeltype == LABEL_STATIC
&& layout.latextype == LATEX_ENVIRONMENT && layout.latextype == LATEX_ENVIRONMENT
&& !isFirstInSequence(pit, pars))) && !text_->isFirstInSequence(pit)))
&& align == LYX_ALIGN_BLOCK && align == LYX_ALIGN_BLOCK
&& !par.params().noindent() && !par.params().noindent()
// in some insets, paragraphs are never indented // 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(), sgml::openTag(os, getLayout().latexname(),
beg->getID(buffer(), runparams) + getLayout().latexparam()); beg->getID(buffer(), runparams) + getLayout().latexparam());
docbookParagraphs(paragraphs(), buffer(), os, runparams); docbookParagraphs(text_, buffer(), os, runparams);
if (!undefined()) if (!undefined())
sgml::closeTag(os, getLayout().latexname()); sgml::closeTag(os, getLayout().latexname());
@ -468,7 +468,7 @@ docstring InsetText::xhtml(odocstream & os, OutputParams const & runparams) cons
{ {
InsetLayout const & il = getLayout(); InsetLayout const & il = getLayout();
if (undefined()) { if (undefined()) {
xhtmlParagraphs(paragraphs(), buffer(), os, runparams); xhtmlParagraphs(text_, buffer(), os, runparams);
return docstring(); return docstring();
} }
@ -485,7 +485,7 @@ docstring InsetText::xhtml(odocstream & os, OutputParams const & runparams) cons
if (!il.htmlinnertag().empty()) if (!il.htmlinnertag().empty())
innertag_opened = html::openTag(os, il.htmlinnertag(), il.htmlinnerattr()); innertag_opened = html::openTag(os, il.htmlinnertag(), il.htmlinnerattr());
xhtmlParagraphs(paragraphs(), buffer(), os, runparams); xhtmlParagraphs(text_, buffer(), os, runparams);
if (innertag_opened) if (innertag_opened)
html::closeTag(os, il.htmlinnertag()); html::closeTag(os, il.htmlinnertag());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -503,7 +503,7 @@ void RowPainter::paintFirst()
} }
bool const is_rtl = text_.isRTL(par_); 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; //lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << endl;
// should we print a label? // 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() void RowPainter::paintLast()
{ {
bool const is_rtl = text_.isRTL(par_); 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 // paint imaginary end-of-paragraph character