mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Add ignorelang option to file-insert
This is useful for inserted files with no real text content
This commit is contained in:
parent
2871b484a1
commit
2ed3b22a06
@ -51,6 +51,10 @@
|
|||||||
|
|
||||||
* info-insert buffer vcs-*: renamed to info-insert vcs *
|
* 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:
|
!!!The following LyX functions have been removed in 2.4:
|
||||||
|
|
||||||
|
@ -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);
|
LASSERT(d->cursor_.inTexted(), return);
|
||||||
|
|
||||||
@ -2893,8 +2893,12 @@ void BufferView::insertLyXFile(FileName const & fname)
|
|||||||
ErrorList & el = buffer_.errorList("Parse");
|
ErrorList & el = buffer_.errorList("Parse");
|
||||||
// Copy the inserted document error list into the current buffer one.
|
// Copy the inserted document error list into the current buffer one.
|
||||||
el = buf.errorList("Parse");
|
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_);
|
buffer_.undo().recordUndo(d->cursor_);
|
||||||
cap::pasteParagraphList(d->cursor_, buf.paragraphs(),
|
cap::pasteParagraphList(d->cursor_, pars,
|
||||||
buf.params().documentClassPtr(), el);
|
buf.params().documentClassPtr(), el);
|
||||||
res = _("Document %1$s inserted.");
|
res = _("Document %1$s inserted.");
|
||||||
} else {
|
} else {
|
||||||
|
@ -340,7 +340,7 @@ public:
|
|||||||
// Insert plain text file (if filename is empty, prompt for one)
|
// Insert plain text file (if filename is empty, prompt for one)
|
||||||
void insertPlaintextFile(support::FileName const & f, bool asParagraph);
|
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
|
/// save temporary bookmark for jump back navigation
|
||||||
void bookmarkEditPosition();
|
void bookmarkEditPosition();
|
||||||
/// Find and return the inset associated with given dialog name.
|
/// Find and return the inset associated with given dialog name.
|
||||||
|
@ -1571,8 +1571,10 @@ void LyXAction::init()
|
|||||||
/*!
|
/*!
|
||||||
* \var lyx::FuncCode lyx::LFUN_FILE_INSERT
|
* \var lyx::FuncCode lyx::LFUN_FILE_INSERT
|
||||||
* \li Action: Inserts another LyX file.
|
* \li Action: Inserts another LyX file.
|
||||||
* \li Syntax: file-insert [<FILE>]
|
* \li Syntax: file-insert [<FILE>] [ignorelang]
|
||||||
* \li Params: <FILE>: Filename to be inserted.
|
* \li Params: <FILE>: Filename to be inserted.
|
||||||
|
* ignorelang: If given, the (main) language of the inserted file
|
||||||
|
* is ignored (the context language is used).
|
||||||
* \endvar
|
* \endvar
|
||||||
*/
|
*/
|
||||||
{ LFUN_FILE_INSERT, "file-insert", Noop, Edit },
|
{ LFUN_FILE_INSERT, "file-insert", Noop, Edit },
|
||||||
|
@ -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();
|
BufferView * bv = documentBufferView();
|
||||||
if (!bv)
|
if (!bv)
|
||||||
@ -2644,7 +2644,7 @@ void GuiView::insertLyXFile(docstring const & fname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bv->insertLyXFile(filename);
|
bv->insertLyXFile(filename, ignorelang);
|
||||||
bv->buffer().errors("Parse");
|
bv->buffer().errors("Parse");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4049,9 +4049,13 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
|||||||
menu->exec(QCursor::pos());
|
menu->exec(QCursor::pos());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_FILE_INSERT:
|
case LFUN_FILE_INSERT: {
|
||||||
insertLyXFile(cmd.argument());
|
if (cmd.getArg(1) == "ignorelang")
|
||||||
|
insertLyXFile(from_utf8(cmd.getArg(0)), true);
|
||||||
|
else
|
||||||
|
insertLyXFile(cmd.argument());
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case LFUN_FILE_INSERT_PLAINTEXT:
|
case LFUN_FILE_INSERT_PLAINTEXT:
|
||||||
case LFUN_FILE_INSERT_PLAINTEXT_PARA: {
|
case LFUN_FILE_INSERT_PLAINTEXT_PARA: {
|
||||||
|
@ -373,7 +373,7 @@ private:
|
|||||||
///
|
///
|
||||||
void toggleFullScreen();
|
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
|
/// Open Export As ... dialog. \p iformat is the format the
|
||||||
/// filter is initially set to.
|
/// filter is initially set to.
|
||||||
|
Loading…
Reference in New Issue
Block a user