]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
Try to deal with one of the big problems here, namely, that we
[lyx.git] / src / Buffer.cpp
index 361f3d9e68c3547500a1aa81960e53ec51a1d6a6..11c9231bb651b4be4cc1a87c67feae6cbd6f7920 100644 (file)
@@ -42,6 +42,7 @@
 #include "Lexer.h"
 #include "LyXAction.h"
 #include "LyX.h"
+#include "LyXFunc.h"
 #include "LyXRC.h"
 #include "LyXVC.h"
 #include "output_docbook.h"
@@ -1391,7 +1392,7 @@ void Buffer::makeLyXHTMLFile(FileName const & fname,
                              OutputParams const & runparams,
                              bool const body_only) const
 {
-       LYXERR(Debug::LATEX, "makeLYXHTMLFile...");
+       LYXERR(Debug::LATEX, "makeLyXHTMLFile...");
 
        ofdocstream ofs;
        if (!openFileWrite(ofs, fname))
@@ -1709,6 +1710,10 @@ bool Buffer::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                        // if no Buffer is present, then of course we won't be called!
                        break;
 
+               case LFUN_BUFFER_LANGUAGE:
+                       enable = !isReadonly();
+                       break;
+
                default:
                        return false;
        }
@@ -1737,6 +1742,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
        string const argument = to_utf8(func.argument());
        // We'll set this back to false if need be.
        bool dispatched = true;
+       undo().beginUndoGroup();
 
        switch (func.action) {
        case LFUN_BUFFER_TOGGLE_READ_ONLY:
@@ -2045,11 +2051,22 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
                break;
        }
 
+       case LFUN_BUFFER_LANGUAGE: {
+               Language const * oldL = params().language;
+               Language const * newL = languages.getLanguage(argument);
+               if (!newL || oldL == newL)
+                       break;
+               if (oldL->rightToLeft() == newL->rightToLeft() && !isMultiLingual())
+                       changeLanguage(oldL, newL);
+               break;
+       }
+
        default:
                dispatched = false;
                break;
        }
        dr.dispatched(dispatched);
+       undo().endUndoGroup();
 }
 
 
@@ -3107,10 +3124,11 @@ bool Buffer::doExport(string const & format, bool put_in_tempdir,
        // Plain text backend
        if (backend_format == "text")
                writePlaintextFile(*this, FileName(filename), runparams);
-       // no backend
-       else if (backend_format == "xhtml")
+       // HTML backend
+       else if (backend_format == "xhtml") {
+               runparams.flavor = OutputParams::HTML;
                makeLyXHTMLFile(FileName(filename), runparams);
-       else if (backend_format == "lyx")
+       }       else if (backend_format == "lyx")
                writeFile(FileName(filename));
        // Docbook backend
        else if (isDocBook()) {
@@ -3285,7 +3303,8 @@ bool Buffer::readFileHelper(FileName const & s)
                                str = _("Document was successfully recovered.");
                        else
                                str = _("Document was NOT successfully recovered.");
-                       str += "\n\n" + _("Remove emergency file now?");
+                       str += "\n\n" + bformat(_("Remove emergency file now?\n(%1$s)"),
+                                               from_utf8(e.absFilename()));
 
                        if (!Alert::prompt(_("Delete emergency file?"), str, 1, 1,
                                        _("&Remove"), _("&Keep it"))) {