From 6084e5961015f09d70809bb48c80f40982d7f782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ridderstr=C3=B6m?= Date: Tue, 14 Aug 2007 00:31:04 +0000 Subject: [PATCH] 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 --- src/callback.cpp | 38 ++++++++++++++++++++++++++++---------- status.15x | 4 ++++ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/callback.cpp b/src/callback.cpp index 7053831020..0a65761838 100644 --- a/src/callback.cpp +++ b/src/callback.cpp @@ -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) { string fname = buffer->fileName(); string const oldname = fname; - if (newname.empty()) { + if (newname.empty()) { /// No argument? Ask user through dialog // FIXME UNICODE FileDialog fileDlg(_("Choose a filename to save document as"), - LFUN_BUFFER_WRITE_AS, - make_pair(_("Documents|#o#O"), from_utf8(lyxrc.document_path)), - make_pair(_("Templates|#T#t"), from_utf8(lyxrc.template_path))); + LFUN_BUFFER_WRITE_AS, + make_pair(_("Documents|#o#O"), + from_utf8(lyxrc.document_path)), + make_pair(_("Templates|#T#t"), + from_utf8(lyxrc.template_path))); if (!isLyXFilename(fname)) fname += ".lyx"; @@ -156,14 +172,16 @@ bool writeAs(Buffer * buffer, string const & newname) fname = makeAbsPath(fname).absFilename(); if (!isLyXFilename(fname)) fname += ".lyx"; - } else - fname = newname; - FileName const filename(fname); - if (fs::exists(filename.toFilesystemEncoding())) { + } else + fname = makeAbsPath(newname, onlyPath(oldname)).absFilename(); + + if (fs::exists(FileName(fname).toFilesystemEncoding())) { docstring const file = makeDisplayPath(fname, 30); - docstring text = bformat(_("The document %1$s already exists.\n\n" - "Do you want to overwrite that document?"), file); + docstring text = bformat(_("The document %1$s already " + "exists.\n\nDo you want to " + "overwrite that document?"), + file); int const ret = Alert::prompt(_("Overwrite document?"), text, 0, 1, _("&Overwrite"), _("&Cancel")); diff --git a/status.15x b/status.15x index b77ce7be31..a565c92548 100644 --- a/status.15x +++ b/status.15x @@ -64,6 +64,10 @@ What's new - 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 - Embedded Objects manual: section about longtable alignment added