mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-13 03:40:34 +00:00
Porting fix for bug 4135 from trunk
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@19534 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f7756c3020
commit
6084e59610
@ -121,18 +121,34 @@ bool menuWrite(Buffer * buffer)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Write a buffer to a new file name and rename the buffer
|
||||||
|
according to the new file name.
|
||||||
|
|
||||||
|
This function is e.g. used by menu callbacks and
|
||||||
|
LFUN_BUFFER_WRITE_AS.
|
||||||
|
|
||||||
|
If 'newname' is empty (the default), the user is asked via a
|
||||||
|
dialog for the buffer's new name and location.
|
||||||
|
|
||||||
|
If 'newname' is non-empty and has an absolute path, that is used.
|
||||||
|
Otherwise the base directory of the buffer is used as the base
|
||||||
|
for any relative path in 'newname'.
|
||||||
|
*/
|
||||||
|
|
||||||
bool writeAs(Buffer * buffer, string const & newname)
|
bool writeAs(Buffer * buffer, string const & newname)
|
||||||
{
|
{
|
||||||
string fname = buffer->fileName();
|
string fname = buffer->fileName();
|
||||||
string const oldname = fname;
|
string const oldname = fname;
|
||||||
|
|
||||||
if (newname.empty()) {
|
if (newname.empty()) { /// No argument? Ask user through dialog
|
||||||
|
|
||||||
// FIXME UNICODE
|
// FIXME UNICODE
|
||||||
FileDialog fileDlg(_("Choose a filename to save document as"),
|
FileDialog fileDlg(_("Choose a filename to save document as"),
|
||||||
LFUN_BUFFER_WRITE_AS,
|
LFUN_BUFFER_WRITE_AS,
|
||||||
make_pair(_("Documents|#o#O"), from_utf8(lyxrc.document_path)),
|
make_pair(_("Documents|#o#O"),
|
||||||
make_pair(_("Templates|#T#t"), from_utf8(lyxrc.template_path)));
|
from_utf8(lyxrc.document_path)),
|
||||||
|
make_pair(_("Templates|#T#t"),
|
||||||
|
from_utf8(lyxrc.template_path)));
|
||||||
|
|
||||||
if (!isLyXFilename(fname))
|
if (!isLyXFilename(fname))
|
||||||
fname += ".lyx";
|
fname += ".lyx";
|
||||||
@ -156,14 +172,16 @@ bool writeAs(Buffer * buffer, string const & newname)
|
|||||||
fname = makeAbsPath(fname).absFilename();
|
fname = makeAbsPath(fname).absFilename();
|
||||||
if (!isLyXFilename(fname))
|
if (!isLyXFilename(fname))
|
||||||
fname += ".lyx";
|
fname += ".lyx";
|
||||||
} else
|
|
||||||
fname = newname;
|
|
||||||
|
|
||||||
FileName const filename(fname);
|
} else
|
||||||
if (fs::exists(filename.toFilesystemEncoding())) {
|
fname = makeAbsPath(newname, onlyPath(oldname)).absFilename();
|
||||||
|
|
||||||
|
if (fs::exists(FileName(fname).toFilesystemEncoding())) {
|
||||||
docstring const file = makeDisplayPath(fname, 30);
|
docstring const file = makeDisplayPath(fname, 30);
|
||||||
docstring text = bformat(_("The document %1$s already exists.\n\n"
|
docstring text = bformat(_("The document %1$s already "
|
||||||
"Do you want to overwrite that document?"), file);
|
"exists.\n\nDo you want to "
|
||||||
|
"overwrite that document?"),
|
||||||
|
file);
|
||||||
int const ret = Alert::prompt(_("Overwrite document?"),
|
int const ret = Alert::prompt(_("Overwrite document?"),
|
||||||
text, 0, 1, _("&Overwrite"), _("&Cancel"));
|
text, 0, 1, _("&Overwrite"), _("&Cancel"));
|
||||||
|
|
||||||
|
@ -64,6 +64,10 @@ What's new
|
|||||||
|
|
||||||
- Fix bug related to citation dialog (Bug 4121)
|
- Fix bug related to citation dialog (Bug 4121)
|
||||||
|
|
||||||
|
- Fix crash when using the LFUN 'buffer-write-as' with an argument
|
||||||
|
that is not an absolute path (Bug 4135).
|
||||||
|
|
||||||
|
|
||||||
* DOCUMENTATION
|
* DOCUMENTATION
|
||||||
|
|
||||||
- Embedded Objects manual: section about longtable alignment added
|
- Embedded Objects manual: section about longtable alignment added
|
||||||
|
Loading…
Reference in New Issue
Block a user