]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.cpp
More requires --> required, for C++2a.
[lyx.git] / src / CutAndPaste.cpp
index c71697ffda99b8892b57de705c5c0038541da0fc..8e0a72d6dda5068d155af22cb8081521f1b8a120 100644 (file)
@@ -141,7 +141,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
        InsetText * target_inset = cur.inset().asInsetText();
        if (!target_inset) {
                InsetTabular * it = cur.inset().asInsetTabular();
-               target_inset = it ? it->cell(cur.idx())->asInsetText() : 0;
+               target_inset = it ? it->cell(cur.idx())->asInsetText() : nullptr;
        }
        LASSERT(target_inset, return PasteReturnValue(pit, pos, need_update));
 
@@ -287,8 +287,9 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
                                        tmpbuf->eraseChar(i--, false);
                }
 
-               tmpbuf->setChange(Change(buffer.params().track_changes ?
-                                        Change::INSERTED : Change::UNCHANGED));
+               if (lyxrc.ct_markup_copied)
+                       tmpbuf->setChange(Change(buffer.params().track_changes ?
+                                                Change::INSERTED : Change::UNCHANGED));
        }
 
        bool const empty = pars[pit].empty();
@@ -304,8 +305,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
        InsetIterator const i_end = inset_iterator_end(in);
        for (InsetIterator it = inset_iterator_begin(in); it != i_end; ++it) {
                // Even though this will also be done later, it has to be done here
-               // since some inset might going to try to access
-               // the buffer() member.
+               // since some inset might try to access the buffer() member.
                it->setBuffer(const_cast<Buffer &>(buffer));
                switch (it->lyxCode()) {
 
@@ -580,7 +580,7 @@ Buffer * copyToTempBuffer(ParagraphList const & paragraphs, DocumentClassConstPt
        // Use a clone for the complicated stuff so that we do not need to clean
        // up in order to avoid a crash.
        Buffer * buffer = staticbuffer->cloneBufferOnly();
-       LASSERT(buffer, return 0);
+       LASSERT(buffer, return nullptr);
 
        // This needs doing every time.
        // Since setDocumentClass() causes deletion of the old document class
@@ -607,7 +607,8 @@ Buffer * copyToTempBuffer(ParagraphList const & paragraphs, DocumentClassConstPt
 
 
 void putClipboard(ParagraphList const & paragraphs,
-       DocumentClassConstPtr docclass, docstring const & plaintext)
+                 DocumentClassConstPtr docclass, docstring const & plaintext,
+                 BufferParams const bp)
 {
        Buffer * buffer = copyToTempBuffer(paragraphs, docclass);
        if (!buffer) // already asserted in copyToTempBuffer()
@@ -618,6 +619,12 @@ void putClipboard(ParagraphList const & paragraphs,
        // applications, the number that can parse it should go up in the future.
        buffer->params().html_math_output = BufferParams::MathML;
 
+       if (lyxrc.ct_markup_copied) {
+               // Copy authors to the params. We need those pointers.
+               for (Author const & a : bp.authors())
+                       buffer->params().authors().record(a);
+       }
+
        // Make sure MarkAsExporting is deleted before buffer is
        {
                // The Buffer is being used to export. This is necessary so that the
@@ -712,10 +719,12 @@ void copySelectionHelper(Buffer const & buf, Text const & text,
 
        // do not copy text (also nested in insets) which is marked as
        // deleted, unless the whole selection was deleted
-       if (!isFullyDeleted(copy_pars))
-               acceptChanges(copy_pars, buf.params());
-       else
-               rejectChanges(copy_pars, buf.params());
+       if (!lyxrc.ct_markup_copied) {
+               if (!isFullyDeleted(copy_pars))
+                       acceptChanges(copy_pars, buf.params());
+               else
+                       rejectChanges(copy_pars, buf.params());
+       }
 
 
        // do some final cleanup now, to make sure that the paragraphs
@@ -723,7 +732,7 @@ void copySelectionHelper(Buffer const & buf, Text const & text,
        it = copy_pars.begin();
        for (; it != it_end; ++it) {
                it->resetBuffer();
-               it->setInsetOwner(0);
+               it->setInsetOwner(nullptr);
        }
 
        cutstack.push(make_pair(copy_pars, dc));
@@ -951,7 +960,7 @@ void cutSelectionHelper(Cursor & cur, CutStack & cuts, bool realcut, bool putcli
                        // Even if there is no selection.
                        if (putclip)
                                putClipboard(cuts[0].first, cuts[0].second,
-                                            cur.selectionAsString(true));
+                                            cur.selectionAsString(true, true), bp);
                }
 
                if (begpit != endpit)
@@ -1012,7 +1021,7 @@ void cutSelectionToTemp(Cursor & cur, bool realcut)
 
 void copySelection(Cursor const & cur)
 {
-       copySelection(cur, cur.selectionAsString(true));
+       copySelection(cur, cur.selectionAsString(true, true));
 }
 
 
@@ -1028,7 +1037,7 @@ void copyInset(Cursor const & cur, Inset * inset, docstring const & plaintext)
        theCuts.push(make_pair(pars, bp.documentClassPtr()));
 
        // stuff the selection onto the X clipboard, from an explicit copy request
-       putClipboard(theCuts[0].first, theCuts[0].second, plaintext);
+       putClipboard(theCuts[0].first, theCuts[0].second, plaintext, bp);
 }
 
 
@@ -1111,7 +1120,8 @@ void copySelection(Cursor const & cur, docstring const & plaintext)
        }
 
        // stuff the selection onto the X clipboard, from an explicit copy request
-       putClipboard(theCuts[0].first, theCuts[0].second, plaintext);
+       putClipboard(theCuts[0].first, theCuts[0].second, plaintext,
+                       cur.buffer()->params());
 }
 
 
@@ -1123,7 +1133,7 @@ void saveSelection(Cursor const & cur)
        if (cur.selection()
            && cur.selBegin() == cur.bv().cursor().selBegin()
            && cur.selEnd() == cur.bv().cursor().selEnd()) {
-               LYXERR(Debug::SELECTION, "saveSelection: '" << cur.selectionAsString(true) << "'");
+               LYXERR(Debug::SELECTION, "saveSelection: '" << cur.selectionAsString(true, true) << "'");
                copySelectionToStack(cur, selectionBuffer);
        }
 }
@@ -1163,8 +1173,8 @@ docstring selection(size_t sel_index, DocumentClassConstPtr docclass)
 
 
 void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
-                                               DocumentClassConstPtr docclass, ErrorList & errorList,
-                                               cap::BranchAction branchAction)
+                       DocumentClassConstPtr docclass, ErrorList & errorList,
+                       cap::BranchAction branchAction)
 {
        if (cur.inTexted()) {
                Text * text = cur.text();