mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 22:17:41 +00:00
Move setLabelWidthStringToSequence() to Text private member.
Move isFullyDeleted() to static function in CutAndPaste.cpp. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30956 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2b9e44cb01
commit
5fd5cf41c0
@ -429,6 +429,21 @@ void putClipboard(ParagraphList const & paragraphs,
|
||||
}
|
||||
|
||||
|
||||
/// return true if the whole ParagraphList is deleted
|
||||
static bool isFullyDeleted(ParagraphList const & pars)
|
||||
{
|
||||
pit_type const pars_size = static_cast<pit_type>(pars.size());
|
||||
|
||||
// check all paragraphs
|
||||
for (pit_type pit = 0; pit < pars_size; ++pit) {
|
||||
if (!pars[pit].empty()) // prevent assertion failure
|
||||
if (!pars[pit].isDeleted(0, pars[pit].size()))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void copySelectionHelper(Buffer const & buf, Text const & text,
|
||||
pit_type startpit, pit_type endpit,
|
||||
int start, int end, DocumentClass const * const dc, CutStack & cutstack)
|
||||
|
40
src/Text.cpp
40
src/Text.cpp
@ -214,32 +214,6 @@ bool isFirstInSequence(pit_type par_offset, ParagraphList const & pars)
|
||||
}
|
||||
|
||||
|
||||
void setLabelWidthStringToSequence(pit_type const par_offset,
|
||||
ParagraphList & pars, docstring const & s)
|
||||
{
|
||||
pit_type offset = par_offset;
|
||||
// Find first of same layout in sequence
|
||||
while (!isFirstInSequence(offset, pars)) {
|
||||
offset = depthHook(offset, pars, pars[offset].getDepth());
|
||||
}
|
||||
|
||||
// now apply label width string to every par
|
||||
// in sequence
|
||||
pit_type const end = pars.size();
|
||||
depth_type const depth = pars[offset].getDepth();
|
||||
Layout const & layout = pars[offset].layout();
|
||||
for (pit_type pit = 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;
|
||||
@ -289,20 +263,6 @@ Font const outerFont(pit_type par_offset, ParagraphList const & pars)
|
||||
}
|
||||
|
||||
|
||||
bool isFullyDeleted(ParagraphList const & pars)
|
||||
{
|
||||
pit_type const pars_size = static_cast<pit_type>(pars.size());
|
||||
|
||||
// check all paragraphs
|
||||
for (pit_type pit = 0; pit < pars_size; ++pit) {
|
||||
if (!pars[pit].empty()) // prevent assertion failure
|
||||
if (!pars[pit].isDeleted(0, pars[pit].size()))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void acceptChanges(ParagraphList & pars, BufferParams const & bparams)
|
||||
{
|
||||
pit_type pars_size = static_cast<pit_type>(pars.size());
|
||||
|
11
src/Text.h
11
src/Text.h
@ -347,6 +347,9 @@ private:
|
||||
Font & font, Change & change, ErrorList & errorList);
|
||||
///
|
||||
void readParagraph(Paragraph & par, Lexer & lex, ErrorList & errorList);
|
||||
/// Set Label Width string to all paragraphs of the same layout
|
||||
/// and depth in a sequence.
|
||||
void setLabelWidthStringToSequence(pit_type const par_offset, docstring const & s);
|
||||
|
||||
/// Owner Inset.
|
||||
InsetText * owner_;
|
||||
@ -382,11 +385,6 @@ 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 const 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);
|
||||
@ -400,9 +398,6 @@ Font const outerFont(pit_type par_offset, ParagraphList const & pars);
|
||||
/// accept the changes within the complete ParagraphList
|
||||
void acceptChanges(ParagraphList & pars, BufferParams const & bparams);
|
||||
|
||||
/// return true if the whole ParagraphList is deleted
|
||||
bool isFullyDeleted(ParagraphList const & pars);
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
#endif // TEXT_H
|
||||
|
@ -431,6 +431,32 @@ docstring Text::getStringToIndex(Cursor const & cur)
|
||||
}
|
||||
|
||||
|
||||
void Text::setLabelWidthStringToSequence(pit_type const par_offset,
|
||||
docstring const & s)
|
||||
{
|
||||
pit_type offset = par_offset;
|
||||
// Find first of same layout in sequence
|
||||
while (!isFirstInSequence(offset, pars_)) {
|
||||
offset = depthHook(offset, pars_, pars_[offset].getDepth());
|
||||
}
|
||||
|
||||
// now apply label width string to every par
|
||||
// in sequence
|
||||
pit_type const end = pars_.size();
|
||||
depth_type const depth = pars_[offset].getDepth();
|
||||
Layout const & layout = pars_[offset].layout();
|
||||
for (pit_type pit = 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
|
||||
{
|
||||
LASSERT(cur.text(), /**/);
|
||||
@ -452,8 +478,7 @@ void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
|
||||
// Do this only once for a selected range of paragraphs
|
||||
// of the same layout and depth.
|
||||
if (par.getDepth() != priordepth || par.layout() != priorlayout)
|
||||
setLabelWidthStringToSequence(pit, pars_,
|
||||
params.labelWidthString());
|
||||
setLabelWidthStringToSequence(pit, params.labelWidthString());
|
||||
par.params().apply(params, par.layout());
|
||||
priordepth = par.getDepth();
|
||||
priorlayout = par.layout();
|
||||
@ -481,8 +506,8 @@ void Text::setParagraphs(Cursor & cur, ParagraphParameters const & p)
|
||||
// Do this only once for a selected range of paragraphs
|
||||
// of the same layout and depth.
|
||||
if (par.getDepth() != priordepth || par.layout() != priorlayout)
|
||||
setLabelWidthStringToSequence(pit, pars_,
|
||||
par.params().labelWidthString());
|
||||
setLabelWidthStringToSequence(pit,
|
||||
par.params().labelWidthString());
|
||||
par.params().apply(p, par.layout());
|
||||
priordepth = par.getDepth();
|
||||
priorlayout = par.layout();
|
||||
|
Loading…
Reference in New Issue
Block a user