]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
Move bind file format tag to LyXAction.cpp, and rename it.
[lyx.git] / src / Buffer.cpp
index 1509b5ba28cd272795bba61d0eba1cc200e6f181..4cf17a497dccfe233772b033839ccf6eea5b3c41 100644 (file)
@@ -820,6 +820,14 @@ bool Buffer::readDocument(Lexer & lex)
        // read main text
        bool const res = text().read(lex, errorList, d->inset);
 
+       // inform parent buffer about local macros
+       if (parent()) {
+               Buffer const * pbuf = parent();
+               UserMacroSet::const_iterator cit = usermacros.begin();
+               UserMacroSet::const_iterator end = usermacros.end();
+               for (; cit != end; ++cit)
+                       pbuf->usermacros.insert(*cit);
+       }
        usermacros.clear();
        updateMacros();
        updateMacroInstances();
@@ -1053,7 +1061,7 @@ bool Buffer::save() const
                } else {
                        Alert::error(_("Backup failure"),
                                     bformat(_("Cannot create backup file %1$s.\n"
-                                              "Please check whether the directory exists and is writeable."),
+                                              "Please check whether the directory exists and is writable."),
                                             from_utf8(backupName.absFileName())));
                        //LYXERR(Debug::DEBUG, "Fs error: " << fe.what());
                }
@@ -2679,7 +2687,9 @@ MacroData const * Buffer::Impl::getBufferMacro(docstring const & name,
                        break;
 
                // scope ends behind pos?
-               if (pos < it->second.first) {
+               if (pos < it->second.first
+                       && (cloned_buffer_ ||
+                           theBufferList().isLoaded(it->second.second))) {
                        // look for macro in external file
                        macro_lock = true;
                        MacroData const * data
@@ -3071,12 +3081,13 @@ void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to,
 }
 
 
-void Buffer::getSourceCode(odocstream & os, pit_type par_begin,
-       pit_type par_end, bool full_source)
+void Buffer::getSourceCode(odocstream & os, string const format,
+                          pit_type par_begin, pit_type par_end,
+                          bool full_source) const
 {
        OutputParams runparams(&params().encoding());
        runparams.nice = true;
-       runparams.flavor = getDefaultOutputFlavor();
+       runparams.flavor = getOutputFlavor(format);
        runparams.linelen = lyxrc.plaintext_linelen;
        // No side effect of file copying and image conversion
        runparams.dryrun = true;
@@ -3388,9 +3399,10 @@ string Buffer::getDefaultOutputFormat() const
 }
 
 
-OutputParams::FLAVOR Buffer::getDefaultOutputFlavor()
+OutputParams::FLAVOR Buffer::getOutputFlavor(string const format) const
 {
-       string const dformat = getDefaultOutputFormat();
+       string const dformat = (format.empty() || format == "default") ?
+               getDefaultOutputFormat() : format;
        DefaultFlavorCache::const_iterator it =
                default_flavors_.find(dformat);
 
@@ -3467,6 +3479,7 @@ bool Buffer::doExport(string const & format, bool put_in_tempdir,
        vector<string> backs = backends();
        if (find(backs.begin(), backs.end(), format) == backs.end()) {
                // Get shortest path to format
+               theConverters().buildGraph();
                Graph::EdgePath path;
                for (vector<string>::const_iterator it = backs.begin();
                     it != backs.end(); ++it) {
@@ -3749,7 +3762,7 @@ Buffer::ReadStatus Buffer::loadEmergency()
                if (success) {
                        if (isReadonly()) {
                                Alert::warning(_("File is read-only"),
-                                       bformat(_("An emergency file is succesfully loaded, "
+                                       bformat(_("An emergency file is successfully loaded, "
                                        "but the original file %1$s is marked read-only. "
                                        "Please make sure to save the document as a different "
                                        "file."), from_utf8(d->filename.absFileName())));
@@ -3811,7 +3824,7 @@ Buffer::ReadStatus Buffer::loadAutosave()
                if (ret_llf == ReadSuccess) {
                        if (isReadonly()) {
                                Alert::warning(_("File is read-only"),
-                                       bformat(_("A backup file is succesfully loaded,  "
+                                       bformat(_("A backup file is successfully loaded, "
                                        "but the original file %1$s is marked read-only. "
                                        "Please make sure to save the document as a "
                                        "different file."), 
@@ -4238,6 +4251,7 @@ Buffer::ReadStatus Buffer::reload()
                updateTitles();
                markClean();
                message(bformat(_("Document %1$s reloaded."), disp_fn));
+               d->undo_.clear();
        } else {
                message(bformat(_("Could not reload document %1$s."), disp_fn));
        }