]> git.lyx.org Git - features.git/commitdiff
Get rid of Buffer::insertStringAsLines().
authorAbdelrazak Younes <younes@lyx.org>
Sun, 9 Aug 2009 16:37:30 +0000 (16:37 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 9 Aug 2009 16:37:30 +0000 (16:37 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30948 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/Buffer.h
src/Text2.cpp

index 48c528fde4af3c46c5c0ad3de97317b1a6e69141..168f5797979c27028ae43905b494965f51f5e910 100644 (file)
@@ -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;
index 6cb04bb7c0b72693b0bfe5a299554fb471ccaae6..a6fcbd5430716778b62d1f19f256a66c248f7efe 100644 (file)
@@ -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?
index c55b9e2a42afc02b80afd5bbfd5182bf21c6e200..be95232d1271a6da80bfab4c370d7e886e0c0e08 100644 (file)
@@ -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 == ' ');
+               }
+       }
 }