namespace {
typedef pair<pit_type, int> PitPosPair;
+typedef pair<DocumentClassConstPtr, AuthorList > DocInfoPair;
-typedef limited_stack<pair<ParagraphList, DocumentClassConstPtr> > CutStack;
+typedef limited_stack<pair<ParagraphList, DocInfoPair > > CutStack;
CutStack theCuts(10);
// persistent selection, cleared until the next selection
void putClipboard(ParagraphList const & paragraphs,
- DocumentClassConstPtr docclass, docstring const & plaintext,
+ DocInfoPair docinfo, docstring const & plaintext,
BufferParams const & bp)
{
- Buffer * buffer = copyToTempBuffer(paragraphs, docclass);
+ Buffer * buffer = copyToTempBuffer(paragraphs, docinfo.first);
if (!buffer) // already asserted in copyToTempBuffer()
return;
// 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);
- }
+ // 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
{
par.setInsetOwner(nullptr);
}
- cutstack.push(make_pair(copy_pars, dc));
+ cutstack.push(make_pair(copy_pars, make_pair(dc, buf.params().authors())));
}
} // namespace
}
+void switchBetweenClasses(DocumentClassConstPtr oldone,
+ DocumentClassConstPtr newone, InsetText & in) {
+ ErrorList el = {};
+ switchBetweenClasses(oldone, newone, in, el);
+}
+
+
void switchBetweenClasses(DocumentClassConstPtr oldone,
DocumentClassConstPtr newone, InsetText & in, ErrorList & errorlist)
{
docstring const & n = newone->insetLayout(layoutName).name();
bool const is_undefined = n.empty() ||
n == DocumentClass::plainInsetLayout().name();
- if (!is_undefined)
+ docstring const & oldn = oldone->insetLayout(layoutName).name();
+ bool const was_undefined = oldn.empty() ||
+ oldn == DocumentClass::plainInsetLayout().name();
+ if (!is_undefined || was_undefined)
continue;
// The flex inset is undefined in newtc
Font font(inherit_font, bp.language);
par.insertInset(0, inset, font, Change(Change::UNCHANGED));
pars.push_back(par);
- theCuts.push(make_pair(pars, bp.documentClassPtr()));
+ theCuts.push(make_pair(pars, make_pair(bp.documentClassPtr(), bp.authors())));
// stuff the selection onto the X clipboard, from an explicit copy request
putClipboard(theCuts[0].first, theCuts[0].second, plaintext, bp);
par.insert(0, grabSelection(cur), Font(sane_font, par.getParLanguage(bp)),
Change(Change::UNCHANGED));
pars.push_back(par);
- cutstack.push(make_pair(pars, bp.documentClassPtr()));
+ cutstack.push(make_pair(pars, make_pair(bp.documentClassPtr(), bp.authors())));
}
}
while (pars.size() > 1)
mergeParagraph(bp, pars, 0);
}
- theCuts.push(make_pair(pars, bp.documentClassPtr()));
+ theCuts.push(make_pair(pars, make_pair(bp.documentClassPtr(), bp.authors())));
} else {
copySelectionToStack(cur, theCuts);
}
}
-docstring selection(size_t sel_index, DocumentClassConstPtr docclass, bool for_math)
+docstring selection(size_t sel_index, DocInfoPair docinfo, bool for_math)
{
if (sel_index >= theCuts.size())
return docstring();
unique_ptr<Buffer> buffer(copyToTempBuffer(theCuts[sel_index].first,
- docclass));
+ docinfo.first));
if (!buffer)
return docstring();
void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
- DocumentClassConstPtr docclass, ErrorList & errorList,
+ DocumentClassConstPtr docclass, AuthorList const & authors,
+ ErrorList & errorList,
cap::BranchAction branchAction)
{
+ // Copy authors to the params. We need those pointers.
+ for (Author const & a : authors)
+ cur.buffer()->params().authors().record(a);
+
if (cur.inTexted()) {
Text * text = cur.text();
LBUFERR(text);
cur.recordUndo();
pasteParagraphList(cur, theCuts[sel_index].first,
- theCuts[sel_index].second, errorList, BRANCH_ASK);
+ theCuts[sel_index].second.first, theCuts[sel_index].second.second,
+ errorList, BRANCH_ASK);
return true;
}
cur.recordUndo();
pasteParagraphList(cur, tempCut[0].first,
- tempCut[0].second, errorList, BRANCH_IGNORE);
+ tempCut[0].second.first, tempCut[0].second.second,
+ errorList, BRANCH_IGNORE);
return true;
}
string lyx = theClipboard().getAsLyX();
if (!lyx.empty()) {
Buffer buffer(string(), false);
+ buffer.setInternal(true);
buffer.setUnnamed(true);
if (buffer.readString(lyx)) {
cur.recordUndo();
pasteParagraphList(cur, buffer.paragraphs(),
- buffer.params().documentClassPtr(), errorList);
+ buffer.params().documentClassPtr(),
+ buffer.params().authors(),
+ errorList);
return true;
}
}
available = !text.empty();
if (available) {
Buffer buffer(string(), false);
+ buffer.setInternal(true);
buffer.setUnnamed(true);
available = buffer.importString(names[i], text, errorList);
if (available)
buffer.changeLanguage(buffer.language(), cur.getFont().language());
cur.recordUndo();
pasteParagraphList(cur, buffer.paragraphs(),
- buffer.params().documentClassPtr(), errorList);
+ buffer.params().documentClassPtr(),
+ buffer.params().authors(),
+ errorList);
return true;
}
}
return;
cur.recordUndo();
pasteParagraphList(cur, selectionBuffer[0].first,
- selectionBuffer[0].second, errorList);
+ selectionBuffer[0].second.first,
+ selectionBuffer[0].second.second,
+ errorList);
}