]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
cleanups: split Paragraph::Private::simpleTeXSpecialChars() in two. Remove two or...
[lyx.git] / src / Buffer.cpp
index d48a33955dc7bb406cdd31d8a2c345ead9ac1097..d1cbd25870e031df52986d5674eca48c14374e1e 100644 (file)
@@ -30,6 +30,7 @@
 #include "FuncRequest.h"
 #include "gettext.h"
 #include "InsetIterator.h"
+#include "InsetList.h"
 #include "Language.h"
 #include "LaTeX.h"
 #include "LaTeXFeatures.h"
@@ -154,7 +155,7 @@ namespace fs = boost::filesystem;
 
 namespace {
 
-int const LYX_FORMAT = 294; //pavel pdfoptions
+int const LYX_FORMAT = 295; //Uwe: htmlurl, href
 
 } // namespace anon
 
@@ -165,9 +166,7 @@ class Buffer::Impl
 {
 public:
        Impl(Buffer & parent, FileName const & file, bool readonly);
-
-       limited_stack<Undo> undostack;
-       limited_stack<Undo> redostack;
+       
        BufferParams params;
        LyXVC lyxvc;
        string temppath;
@@ -219,6 +218,9 @@ public:
 
        ///
        frontend::WorkAreaManager * wa_;
+
+       ///
+       Undo undo_;
 };
 
 
@@ -226,7 +228,7 @@ Buffer::Impl::Impl(Buffer & parent, FileName const & file, bool readonly_)
        : lyx_clean(true), bak_clean(true), unnamed(false), read_only(readonly_),
          filename(file), file_fully_loaded(false), inset(params),
          toc_backend(&parent), embedded_files(&parent), timestamp_(0),
-         checksum_(0), wa_(0)
+         checksum_(0), wa_(0), undo_(parent)
 {
        inset.setAutoBreakRows(true);
        lyxvc.buffer(&parent);
@@ -304,30 +306,6 @@ Inset & Buffer::inset() const
 }
 
 
-limited_stack<Undo> & Buffer::undostack()
-{
-       return pimpl_->undostack;
-}
-
-
-limited_stack<Undo> const & Buffer::undostack() const
-{
-       return pimpl_->undostack;
-}
-
-
-limited_stack<Undo> & Buffer::redostack()
-{
-       return pimpl_->redostack;
-}
-
-
-limited_stack<Undo> const & Buffer::redostack() const
-{
-       return pimpl_->redostack;
-}
-
-
 BufferParams & Buffer::params()
 {
        return pimpl_->params;
@@ -405,6 +383,12 @@ EmbeddedFiles const & Buffer::embeddedFiles() const
        return pimpl_->embedded_files;
 }
 
+Undo & Buffer::undo()
+{
+       return pimpl_->undo_;
+}
+
+
 
 string const Buffer::getLatexName(bool const no_path) const
 {
@@ -432,9 +416,8 @@ pair<Buffer::LogType, string> const Buffer::getLogName() const
 
        // If no Latex log or Build log is newer, show Build log
 
-       if (fs::exists(bname.toFilesystemEncoding()) &&
-           (!fs::exists(fname.toFilesystemEncoding()) ||
-            fs::last_write_time(fname.toFilesystemEncoding()) < fs::last_write_time(bname.toFilesystemEncoding()))) {
+       if (bname.exists() &&
+           (!fname.exists() || fname.lastModified() < bname.lastModified())) {
                LYXERR(Debug::FILES) << "Log name calculated as: " << bname << endl;
                return make_pair(Buffer::buildlog, bname.absFilename());
        }
@@ -704,7 +687,7 @@ bool Buffer::readFile(FileName const & filename)
                //
                FileName lyxfile(addName(temppath(), "content.lyx"));
                // if both manifest.txt and file.lyx exist, this is am embedded file
-               if (fs::exists(lyxfile.toFilesystemEncoding())) {
+               if (lyxfile.exists()) {
                        params().embedded = true;
                        fname = lyxfile;
                }
@@ -750,7 +733,7 @@ Buffer::ReadStatus Buffer::readFile(Lexer & lex, FileName const & filename,
        }
 
        lex.next();
-       string const token(lex.getString());
+       string const token = lex.getString();
 
        if (!lex) {
                Alert::error(_("Document could not be read"),
@@ -1661,10 +1644,10 @@ bool Buffer::isBakClean() const
 
 bool Buffer::isExternallyModified(CheckMethod method) const
 {
-       BOOST_ASSERT(fs::exists(pimpl_->filename.toFilesystemEncoding()));
+       BOOST_ASSERT(pimpl_->filename.exists());
        // if method == timestamp, check timestamp before checksum
        return (method == checksum_method 
-               || pimpl_->timestamp_ != fs::last_write_time(pimpl_->filename.toFilesystemEncoding()))
+               || pimpl_->timestamp_ != pimpl_->filename.lastModified())
                && pimpl_->checksum_ != sum(pimpl_->filename);
 }
 
@@ -1818,7 +1801,7 @@ void Buffer::buildMacros()
        for (size_t i = 0, n = pars.size(); i != n; ++i) {
                //lyxerr << "searching main par " << i
                //      << " for macro definitions" << std::endl;
-               InsetList const & insets = pars[i].insetlist;
+               InsetList const & insets = pars[i].insetList();
                InsetList::const_iterator it = insets.begin();
                InsetList::const_iterator end = insets.end();
                for ( ; it != end; ++it) {
@@ -2152,7 +2135,7 @@ bool Buffer::writeAs(string const & newname)
        } else 
                fname = makeAbsPath(newname, onlyPath(oldname)).absFilename();
 
-       if (fs::exists(FileName(fname).toFilesystemEncoding())) {
+       if (FileName(fname).exists()) {
                docstring const file = makeDisplayPath(fname, 30);
                docstring text = bformat(_("The document %1$s already "
                                           "exists.\n\nDo you want to "