mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
Get rid of Buffer::insertStringAsLines().
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30948 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
730a67e0d1
commit
4916bd41d3
@ -698,57 +698,6 @@ bool Buffer::readDocument(Lexer & lex)
|
||||
}
|
||||
|
||||
|
||||
// needed to insert the selection
|
||||
void Buffer::insertStringAsLines(ParagraphList & pars,
|
||||
pit_type & pit, pos_type & pos,
|
||||
Font const & fn, docstring const & str, bool autobreakrows)
|
||||
{
|
||||
Font font = fn;
|
||||
|
||||
// insert the string, don't insert doublespace
|
||||
bool space_inserted = true;
|
||||
for (docstring::const_iterator cit = str.begin();
|
||||
cit != str.end(); ++cit) {
|
||||
Paragraph & par = pars[pit];
|
||||
if (*cit == '\n') {
|
||||
if (autobreakrows && (!par.empty() || par.allowEmpty())) {
|
||||
breakParagraph(params(), pars, pit, pos,
|
||||
par.layout().isEnvironment());
|
||||
++pit;
|
||||
pos = 0;
|
||||
space_inserted = true;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
// do not insert consecutive spaces if !free_spacing
|
||||
} else if ((*cit == ' ' || *cit == '\t') &&
|
||||
space_inserted && !par.isFreeSpacing()) {
|
||||
continue;
|
||||
} else if (*cit == '\t') {
|
||||
if (!par.isFreeSpacing()) {
|
||||
// tabs are like spaces here
|
||||
par.insertChar(pos, ' ', font, params().trackChanges);
|
||||
++pos;
|
||||
space_inserted = true;
|
||||
} else {
|
||||
par.insertChar(pos, *cit, font, params().trackChanges);
|
||||
++pos;
|
||||
space_inserted = true;
|
||||
}
|
||||
} else if (!isPrintable(*cit)) {
|
||||
// Ignore unprintables
|
||||
continue;
|
||||
} else {
|
||||
// just insert the character
|
||||
par.insertChar(pos, *cit, font, params().trackChanges);
|
||||
++pos;
|
||||
space_inserted = (*cit == ' ');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Buffer::readString(string const & s)
|
||||
{
|
||||
params().compressed = false;
|
||||
|
@ -155,10 +155,6 @@ public:
|
||||
*/
|
||||
bool readDocument(Lexer &);
|
||||
|
||||
///
|
||||
void insertStringAsLines(ParagraphList & plist,
|
||||
pit_type &, pos_type &,
|
||||
Font const &, docstring const &, bool);
|
||||
///
|
||||
DocIterator getParFromID(int id) const;
|
||||
/// do we have a paragraph with this id?
|
||||
|
@ -505,8 +505,51 @@ void Text::insertInset(Cursor & cur, Inset * inset)
|
||||
// needed to insert the selection
|
||||
void Text::insertStringAsLines(Cursor & cur, docstring const & str)
|
||||
{
|
||||
cur.buffer()->insertStringAsLines(pars_, cur.pit(), cur.pos(),
|
||||
cur.current_font, str, autoBreakRows_);
|
||||
BufferParams const & bparams = owner_->buffer().params();
|
||||
pit_type pit = cur.pit();
|
||||
pos_type pos = cur.pos();
|
||||
Font font = cur.current_font;
|
||||
|
||||
// insert the string, don't insert doublespace
|
||||
bool space_inserted = true;
|
||||
for (docstring::const_iterator cit = str.begin();
|
||||
cit != str.end(); ++cit) {
|
||||
Paragraph & par = pars_[pit];
|
||||
if (*cit == '\n') {
|
||||
if (autoBreakRows_ && (!par.empty() || par.allowEmpty())) {
|
||||
lyx::breakParagraph(bparams, pars_, pit, pos,
|
||||
par.layout().isEnvironment());
|
||||
++pit;
|
||||
pos = 0;
|
||||
space_inserted = true;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
// do not insert consecutive spaces if !free_spacing
|
||||
} else if ((*cit == ' ' || *cit == '\t') &&
|
||||
space_inserted && !par.isFreeSpacing()) {
|
||||
continue;
|
||||
} else if (*cit == '\t') {
|
||||
if (!par.isFreeSpacing()) {
|
||||
// tabs are like spaces here
|
||||
par.insertChar(pos, ' ', font, bparams.trackChanges);
|
||||
++pos;
|
||||
space_inserted = true;
|
||||
} else {
|
||||
par.insertChar(pos, *cit, font, bparams.trackChanges);
|
||||
++pos;
|
||||
space_inserted = true;
|
||||
}
|
||||
} else if (!isPrintable(*cit)) {
|
||||
// Ignore unprintables
|
||||
continue;
|
||||
} else {
|
||||
// just insert the character
|
||||
par.insertChar(pos, *cit, font, bparams.trackChanges);
|
||||
++pos;
|
||||
space_inserted = (*cit == ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user