From 4916bd41d3e4ebc50b636cc036b374e4d2b8de8d Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sun, 9 Aug 2009 16:37:30 +0000 Subject: [PATCH] Get rid of Buffer::insertStringAsLines(). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30948 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 51 -------------------------------------------------- src/Buffer.h | 4 ---- src/Text2.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 57 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 48c528fde4..168f579797 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -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; diff --git a/src/Buffer.h b/src/Buffer.h index 6cb04bb7c0..a6fcbd5430 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -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? diff --git a/src/Text2.cpp b/src/Text2.cpp index c55b9e2a42..be95232d12 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -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 == ' '); + } + } } -- 2.39.2