]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
* src/LaTeXFeatures.cpp: simplify greektext definition. Patch by G. Milde (bug #6458)
[lyx.git] / src / Buffer.cpp
index 8c1abfbd8cb70ff9fb646e10e8024ee3ed7e7e2b..6bd4ab12b0a1d85ffcadb4b887276e1046a4b502 100644 (file)
@@ -126,7 +126,7 @@ namespace {
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-int const LYX_FORMAT = 378; // ps: rev insetinfo
+int const LYX_FORMAT = 385; // uwestoehr: support to change the shaded box color
 
 typedef map<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
@@ -668,6 +668,15 @@ int Buffer::readHeader(Lexer & lex)
        params().pdfoptions().clear();
        params().indiceslist().clear();
        params().backgroundcolor = lyx::rgbFromHexName("#ffffff");
+       params().isbackgroundcolor = false;
+       params().fontcolor = lyx::rgbFromHexName("#000000");
+       params().isfontcolor = false;
+       params().notefontcolor = lyx::rgbFromHexName("#cccccc");
+       lyx::dispatch(FuncRequest(LFUN_SET_COLOR,
+               from_ascii("greyedouttext #cccccc")));
+       params().boxbgcolor = lyx::rgbFromHexName("#ff0000");
+       lyx::dispatch(FuncRequest(LFUN_SET_COLOR,
+               from_ascii("shaded #ff0000")));
 
        for (int i = 0; i < 4; ++i) {
                params().user_defined_bullet(i) = ITEMIZE_DEFAULTS[i];
@@ -975,6 +984,17 @@ Buffer::ReadStatus Buffer::readFile(Lexer & lex, FileName const & filename,
 // Should probably be moved to somewhere else: BufferView? GuiView?
 bool Buffer::save() const
 {
+       // ask if the disk file has been externally modified (use checksum method)
+       if (fileName().exists() && isExternallyModified(checksum_method)) {
+               docstring const file = makeDisplayPath(absFileName(), 20);
+               docstring text = bformat(_("Document %1$s has been externally modified. Are you sure "
+                                                            "you want to overwrite this file?"), file);
+               int const ret = Alert::prompt(_("Overwrite modified file?"),
+                       text, 1, 1, _("&Overwrite"), _("&Cancel"));
+               if (ret == 1)
+                       return false;
+       }
+
        // We don't need autosaves in the immediate future. (Asger)
        resetAutosaveTimers();
 
@@ -990,7 +1010,7 @@ bool Buffer::save() const
                        backupName = FileName(addName(lyxrc.backupdir_path,
                                                      mangledName));
                }
-               if (fileName().copyTo(backupName)) {
+               if (fileName().moveTo(backupName)) {
                        madeBackup = true;
                } else {
                        Alert::error(_("Backup failure"),
@@ -1001,17 +1021,6 @@ bool Buffer::save() const
                }
        }
 
-       // ask if the disk file has been externally modified (use checksum method)
-       if (fileName().exists() && isExternallyModified(checksum_method)) {
-               docstring const file = makeDisplayPath(absFileName(), 20);
-               docstring text = bformat(_("Document %1$s has been externally modified. Are you sure "
-                                                            "you want to overwrite this file?"), file);
-               int const ret = Alert::prompt(_("Overwrite modified file?"),
-                       text, 1, 1, _("&Overwrite"), _("&Cancel"));
-               if (ret == 1)
-                       return false;
-       }
-
        if (writeFile(d->filename)) {
                markClean();
                return true;
@@ -1050,7 +1059,8 @@ bool Buffer::writeFile(FileName const & fname) const
                return false;
        }
 
-       removeAutosaveFile();
+       // see bug 6587
+       // removeAutosaveFile();
 
        saveCheckSum(d->filename);
        message(str + _(" done."));
@@ -1558,19 +1568,24 @@ void Buffer::writeLyXHTMLSource(odocstream & os,
        updateMacroInstances();
 
        if (!only_body) {
-               os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
-               os << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN\" \"http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd\">\n";
-               // FIXME Language should be set properly.
-               os << "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
-               os << "<head>\n";
-               // FIXME Presumably need to set this right
-               os << "<meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\" />\n";
-               os << "<title>" << features.htmlTitle() << "</title>\n";
+               os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+                  << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN\" \"http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd\">\n"
+                  // FIXME Language should be set properly.
+                  << "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
+                  << "<head>\n"
+                  << "<meta name=\"GENERATOR\" content=\"" << PACKAGE_STRING << "\" />\n"
+                  // FIXME Presumably need to set this right
+                  << "<meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\" />\n";
+
+               docstring const & doctitle = features.htmlTitle();
+               os << "<title>"
+                  << (doctitle.empty() ? from_ascii("LyX Document") : doctitle)
+                  << "</title>\n";
 
                os << "\n<!-- Text Class Preamble -->\n"
-                       << features.getTClassHTMLPreamble()
-                       << "\n<!-- Premable Snippets -->\n"
-                       << from_utf8(features.getPreambleSnippets());
+                  << features.getTClassHTMLPreamble()
+                  << "\n<!-- Premable Snippets -->\n"
+                  << from_utf8(features.getPreambleSnippets());
 
                os << "\n<!-- Layout-provided Styles -->\n";
                docstring const styleinfo = features.getTClassHTMLStyles();
@@ -2971,11 +2986,11 @@ void Buffer::getSourceCode(odocstream & os, pit_type par_begin,
 ErrorList & Buffer::errorList(string const & type) const
 {
        static ErrorList emptyErrorList;
-       map<string, ErrorList>::iterator I = d->errorLists.find(type);
-       if (I == d->errorLists.end())
+       map<string, ErrorList>::iterator it = d->errorLists.find(type);
+       if (it == d->errorLists.end())
                return emptyErrorList;
 
-       return I->second;
+       return it->second;
 }
 
 
@@ -3268,6 +3283,21 @@ bool Buffer::doExport(string const & format, bool put_in_tempdir,
        // HTML backend
        else if (backend_format == "xhtml") {
                runparams.flavor = OutputParams::HTML;
+               switch (params().html_math_output) {
+               case BufferParams::MathML: 
+                       runparams.math_flavor = OutputParams::MathAsMathML; 
+                       break;
+               case BufferParams::HTML: 
+                       runparams.math_flavor = OutputParams::MathAsHTML; 
+                       break;
+               case BufferParams::Images:
+                       runparams.math_flavor = OutputParams::MathAsImages; 
+                       break;
+               case BufferParams::LaTeX:
+                       runparams.math_flavor = OutputParams::MathAsLaTeX; 
+                       break;                                                                                  
+               }
+               
                makeLyXHTMLFile(FileName(filename), runparams);
        }       else if (backend_format == "lyx")
                writeFile(FileName(filename));
@@ -3477,7 +3507,7 @@ bool Buffer::readFileHelper(FileName const & s)
                        else
                                str = _("Document was NOT successfully recovered.");
                        str += "\n\n" + bformat(_("Remove emergency file now?\n(%1$s)"),
-                                               from_utf8(e.absFilename()));
+                                               makeDisplayPath(e.absFilename()));
 
                        if (!Alert::prompt(_("Delete emergency file?"), str, 1, 1,
                                        _("&Remove"), _("&Keep it"))) {
@@ -3868,8 +3898,7 @@ void Buffer::updateBuffer(ParIterator & parit, UpdateType utype) const
                InsetList::const_iterator end = parit->insetList().end();
                for (; iit != end; ++iit) {
                        parit.pos() = iit->pos;
-                       if (!parit->isDeleted(iit->pos))
-                               iit->inset->updateBuffer(parit, utype);
+                       iit->inset->updateBuffer(parit, utype);
                }
        }
 }
@@ -3914,6 +3943,8 @@ int Buffer::spellCheck(DocIterator & from, DocIterator & to,
 bool Buffer::reload()
 {
        setBusy(true);
+       // c.f. bug 6587
+       removeAutosaveFile();
        // e.g., read-only status could have changed due to version control
        d->filename.refresh();
        docstring const disp_fn = makeDisplayPath(d->filename.absFilename());
@@ -3928,6 +3959,9 @@ bool Buffer::reload()
                message(bformat(_("Could not reload document %1$s."), disp_fn));
        }       
        setBusy(false);
+       thePreviews().removeLoader(*this);
+       if (graphics::Previews::status() != LyXRC::PREVIEW_OFF)
+               thePreviews().generateBufferPreviews(*this);
        errors("Parse");
        return success;
 }