diff --git a/lib/RELEASE-NOTES b/lib/RELEASE-NOTES index 9d52b53c48..7fee69a461 100644 --- a/lib/RELEASE-NOTES +++ b/lib/RELEASE-NOTES @@ -51,6 +51,10 @@ * info-insert buffer vcs-*: renamed to info-insert vcs * +* file-insert: optional second parameter "ignorelang" to make the insertion + ignore the inserted file's main language (and rather adapt it to the insertion + context's language). + !!!The following LyX functions have been removed in 2.4: diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 900207c238..ba8c768ca4 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -2875,7 +2875,7 @@ void BufferView::updatePosCache() } -void BufferView::insertLyXFile(FileName const & fname) +void BufferView::insertLyXFile(FileName const & fname, bool const ignorelang) { LASSERT(d->cursor_.inTexted(), return); @@ -2893,8 +2893,12 @@ void BufferView::insertLyXFile(FileName const & fname) ErrorList & el = buffer_.errorList("Parse"); // Copy the inserted document error list into the current buffer one. el = buf.errorList("Parse"); + ParagraphList & pars = buf.paragraphs(); + if (ignorelang) + // set main language of imported file to context language + buf.changeLanguage(buf.language(), d->cursor_.getFont().language()); buffer_.undo().recordUndo(d->cursor_); - cap::pasteParagraphList(d->cursor_, buf.paragraphs(), + cap::pasteParagraphList(d->cursor_, pars, buf.params().documentClassPtr(), el); res = _("Document %1$s inserted."); } else { diff --git a/src/BufferView.h b/src/BufferView.h index 5bad57ca0e..520ecdb0d5 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -340,7 +340,7 @@ public: // Insert plain text file (if filename is empty, prompt for one) void insertPlaintextFile(support::FileName const & f, bool asParagraph); /// - void insertLyXFile(support::FileName const & f); + void insertLyXFile(support::FileName const & f, bool const ignorelang = false); /// save temporary bookmark for jump back navigation void bookmarkEditPosition(); /// Find and return the inset associated with given dialog name. diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 92734a202a..969ef64be0 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -1571,8 +1571,10 @@ void LyXAction::init() /*! * \var lyx::FuncCode lyx::LFUN_FILE_INSERT * \li Action: Inserts another LyX file. - * \li Syntax: file-insert [] + * \li Syntax: file-insert [] [ignorelang] * \li Params: : Filename to be inserted. + * ignorelang: If given, the (main) language of the inserted file + * is ignored (the context language is used). * \endvar */ { LFUN_FILE_INSERT, "file-insert", Noop, Edit }, diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index dfab5d7230..98dba1dfa5 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -2605,7 +2605,7 @@ void GuiView::newDocument(string const & filename, string templatefile, } -void GuiView::insertLyXFile(docstring const & fname) +void GuiView::insertLyXFile(docstring const & fname, bool ignorelang) { BufferView * bv = documentBufferView(); if (!bv) @@ -2644,7 +2644,7 @@ void GuiView::insertLyXFile(docstring const & fname) } } - bv->insertLyXFile(filename); + bv->insertLyXFile(filename, ignorelang); bv->buffer().errors("Parse"); } @@ -4049,9 +4049,13 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr) menu->exec(QCursor::pos()); break; - case LFUN_FILE_INSERT: - insertLyXFile(cmd.argument()); + case LFUN_FILE_INSERT: { + if (cmd.getArg(1) == "ignorelang") + insertLyXFile(from_utf8(cmd.getArg(0)), true); + else + insertLyXFile(cmd.argument()); break; + } case LFUN_FILE_INSERT_PLAINTEXT: case LFUN_FILE_INSERT_PLAINTEXT_PARA: { diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index 493b070b25..fa36f7ff8b 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -373,7 +373,7 @@ private: /// void toggleFullScreen(); /// - void insertLyXFile(docstring const & fname); + void insertLyXFile(docstring const & fname, bool ignorelang = false); /// /// Open Export As ... dialog. \p iformat is the format the /// filter is initially set to.