* paragraph_funcs.{cpp,h}:

- new member setLabelWidthStringToSequence

* Text2.cpp (setParagraphs):
	- use that.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29839 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2009-05-25 07:52:55 +00:00
parent eb9151060d
commit e38ca152a4
3 changed files with 41 additions and 0 deletions

View File

@ -449,6 +449,10 @@ void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
Paragraph & par = pars_[pit];
ParagraphParameters params = par.params();
params.read(argument, merge);
// changes to label width string apply to all
// paragraph with same layout in a sequence
setLabelWidthStringToSequence(pit, pars_,
params.labelWidthString());
par.params().apply(params, par.layout());
}
}
@ -467,6 +471,10 @@ void Text::setParagraphs(Cursor & cur, ParagraphParameters const & p)
for (pit_type pit = cur.selBegin().pit(), end = cur.selEnd().pit();
pit <= end; ++pit) {
Paragraph & par = pars_[pit];
// changes to label width string apply to all
// paragraph with same layout in a sequence
setLabelWidthStringToSequence(pit, pars_,
par.params().labelWidthString());
par.params().apply(p, par.layout());
}
}

View File

@ -256,6 +256,33 @@ bool isFirstInSequence(pit_type par_offset, ParagraphList const & pars)
}
void setLabelWidthStringToSequence(pit_type par_offset,
ParagraphList & pars, docstring const & s)
{
Paragraph & par = pars[par_offset];
// Find first of same layout in sequence
while (!isFirstInSequence(par_offset, pars)) {
par_offset = depthHook(par_offset, pars, par.getDepth());
par = pars[par_offset];
}
// now apply label width string to every par
// in sequence
pit_type const end = pars.size();
depth_type const depth = par.getDepth();
Layout const & layout = par.layout();
for (pit_type pit = par_offset; pit != end; ++pit) {
while (pars[pit].getDepth() > depth)
++pit;
if (pars[pit].getDepth() < depth)
return;
if (pars[pit].layout() != layout)
return;
pars[pit].setLabelWidthString(s);
}
}
int getEndLabel(pit_type p, ParagraphList const & pars)
{
pit_type pit = p;

View File

@ -12,6 +12,7 @@
#ifndef PARAGRAPH_FUNCS_H
#define PARAGRAPH_FUNCS_H
#include "support/docstring.h"
#include "support/types.h"
@ -60,6 +61,11 @@ 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);
/** Set Label Width string to all paragraphs of the same layout
and depth in a sequence */
void setLabelWidthStringToSequence(pit_type par_offset,
ParagraphList & pars, docstring const & s);
/** Check if the current paragraph is the last paragraph in a
proof environment */
int getEndLabel(pit_type par, ParagraphList const & plist);