]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.C
fix aspell encoding (confirmed on linux, cygwin and native windows,
[lyx.git] / src / CutAndPaste.C
index e2c3afedb56403d3bf8ea62f783ecc67f4d6fc78..d82aab8faa82d0c5597035705fc66eefc5568ac4 100644 (file)
@@ -6,6 +6,7 @@
  * \author Jürgen Vigna
  * \author Lars Gullik Bjønnes
  * \author Alfredo Braunstein
+ * \author Michael Gerz
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -209,8 +210,8 @@ pasteSelectionHelper(LCursor & cur, ParagraphList const & parlist,
        ParIterator fend = par_iterator_end(in);
 
        for (; fpit != fend; ++fpit) {
-               InsetList::iterator lit = fpit->insetlist.begin();
-               InsetList::iterator eit = fpit->insetlist.end();
+               InsetList::const_iterator lit = fpit->insetlist.begin();
+               InsetList::const_iterator eit = fpit->insetlist.end();
 
                for (; lit != eit; ++lit) {
                        switch (lit->inset->lyxCode()) {
@@ -292,21 +293,18 @@ PitPosPair eraseSelectionHelper(BufferParams const & params,
                return PitPosPair(endpit, endpos);
        }
 
-       // A paragraph break has to be physically removed by merging, but
-       // only if either (1) change tracking is off, or (2) the para break
-       // is "blue"
        for (pit_type pit = startpit; pit != endpit + 1;) {
-               // FIXME: Change tracking (MG)
-               bool const merge = !params.trackChanges ||
-                                  pars[pit].isInserted(pars[pit].size());
-               pos_type const left  = ( pit == startpit ? startpos : 0 );
-               pos_type const right = ( pit == endpit ? endpos :
-                               pars[pit].size() + 1 );
-               // Logical erase only:
-               pars[pit].eraseChars(left, right, false);
-               // Separate handling of para break:
+               pos_type const left  = (pit == startpit ? startpos : 0);
+               pos_type const right = (pit == endpit ? endpos : pars[pit].size() + 1);
+
+               bool const merge = pars[pit].isMergedOnEndOfParDeletion(params.trackChanges);
+
+               // Logically erase only, including the end-of-paragraph character
+               pars[pit].eraseChars(left, right, params.trackChanges);
+
+               // Separate handling of paragraph break:
                if (merge && pit != endpit &&
-                  (pit + 1 != endpit || pars[pit].hasSameLayout(pars[pit + 1]))) {
+                   (pit + 1 != endpit || pars[pit].hasSameLayout(pars[pit + 1]))) {
                        pos_type const thissize = pars[pit].size();
                        if (doclear)
                                pars[pit + 1].stripLeadingSpaces();
@@ -643,6 +641,7 @@ void pasteSelection(LCursor & cur, ErrorList & errorList, size_t sel_index)
        if (!checkPastePossible(sel_index))
                return;
 
+       recordUndo(cur);
        pasteParagraphList(cur, theCuts[sel_index].first,
                           theCuts[sel_index].second, errorList);
        cur.setSelection();
@@ -650,7 +649,7 @@ void pasteSelection(LCursor & cur, ErrorList & errorList, size_t sel_index)
 
 
 // simple replacing. The font of the first selected character is used
-void replaceSelectionWithString(LCursor & cur, string const & str, bool backwards)
+void replaceSelectionWithString(LCursor & cur, docstring const & str, bool backwards)
 {
        recordUndo(cur);
        DocIterator selbeg = cur.selectionBegin();
@@ -662,10 +661,10 @@ void replaceSelectionWithString(LCursor & cur, string const & str, bool backward
        // Insert the new string
        pos_type pos = cur.selEnd().pos();
        Paragraph & par = cur.selEnd().paragraph();
-       string::const_iterator cit = str.begin();
-       string::const_iterator end = str.end();
+       docstring::const_iterator cit = str.begin();
+       docstring::const_iterator end = str.end();
        for (; cit != end; ++cit, ++pos)
-               par.insertChar(pos, (*cit), font, cur.buffer().params().trackChanges);
+               par.insertChar(pos, *cit, font, cur.buffer().params().trackChanges);
 
        // Cut the selection
        cutSelection(cur, true, false);