]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
* Paragraph: reserve memory by chunks of 100 chars. This improve the loading of big...
[lyx.git] / src / BufferView.cpp
index 320477bdf4b654aed838c9686fdd886e183325f9..2b6820949c4ec46b6b44fc7e460fb1858ec11e3f 100644 (file)
@@ -25,6 +25,7 @@
 #include "CutAndPaste.h"
 #include "debug.h"
 #include "DispatchResult.h"
+#include "EmbeddedFiles.h"
 #include "ErrorList.h"
 #include "factory.h"
 #include "FloatList.h"
@@ -106,8 +107,6 @@ using support::bformat;
 using support::FileFilterList;
 using support::FileName;
 using support::fileSearch;
-using support::isDirWriteable;
-using support::isFileReadable;
 using support::makeDisplayPath;
 using support::makeAbsPath;
 using support::package;
@@ -422,7 +421,7 @@ BufferView::~BufferView()
        // That is to say, if a cursor is in a nested inset, it will be
        // restore to the left of the top level inset.
        LyX::ref().session().lastFilePos().save(
-               support::FileName(buffer_.fileName()),
+               support::FileName(buffer_.absFileName()),
                boost::tie(d->cursor_.bottom().pit(), d->cursor_.bottom().pos()) );
 
        delete d;
@@ -723,7 +722,7 @@ void BufferView::saveBookmark(unsigned int idx)
        // pit and pos will be updated with bottom level pit/pos
        // when lyx exits.
        LyX::ref().session().bookmarks().save(
-               FileName(buffer_.fileName()),
+               FileName(buffer_.absFileName()),
                d->cursor_.bottom().pit(),
                d->cursor_.bottom().pos(),
                d->cursor_.paragraph().id(),
@@ -852,10 +851,10 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
        switch (cmd.action) {
 
        case LFUN_UNDO:
-               flag.enabled(!buffer_.undo().hasUndoStack());
+               flag.enabled(buffer_.undo().hasUndoStack());
                break;
        case LFUN_REDO:
-               flag.enabled(!buffer_.undo().hasRedoStack());
+               flag.enabled(buffer_.undo().hasRedoStack());
                break;
        case LFUN_FILE_INSERT:
        case LFUN_FILE_INSERT_PLAINTEXT_PARA:
@@ -919,6 +918,11 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
                flag.setOnOff(buffer_.params().compressed);
                break;
        }
+       
+       case LFUN_BUFFER_TOGGLE_EMBEDDING: {
+               flag.setOnOff(buffer_.params().embedded);
+               break;
+       }
 
        case LFUN_SCREEN_UP:
        case LFUN_SCREEN_DOWN:
@@ -1088,7 +1092,7 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd)
                                LYXERR(Debug::INFO)
                                        << "Paragraph " << par->id()
                                        << " found in buffer `"
-                                       << b->fileName() << "'." << endl;
+                                       << b->absFileName() << "'." << endl;
 
                                if (b == &buffer_) {
                                        // Set the cursor
@@ -1096,7 +1100,7 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd)
                                } else {
                                        // Switch to other buffer view and resend cmd
                                        theLyXFunc().dispatch(FuncRequest(
-                                               LFUN_BUFFER_SWITCH, b->fileName()));
+                                               LFUN_BUFFER_SWITCH, b->absFileName()));
                                        theLyXFunc().dispatch(cmd);
                                        updateFlags = Update::None;
                                }
@@ -1300,6 +1304,11 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd)
                // turn compression on/off
                buffer_.params().compressed = !buffer_.params().compressed;
                break;
+       
+       case LFUN_BUFFER_TOGGLE_EMBEDDING:
+               // turn embedding on/off
+               buffer_.embeddedFiles().enable(!buffer_.params().embedded);
+               break;
 
        case LFUN_NEXT_INSET_TOGGLE: {
                // this is the real function we want to invoke
@@ -1928,7 +1937,7 @@ void BufferView::menuInsertLyXFile(string const & filenm)
                string initpath = lyxrc.document_path;
                string const trypath = buffer_.filePath();
                // If directory is writeable, use this as default.
-               if (isDirWriteable(FileName(trypath)))
+               if (FileName(trypath).isDirWritable())
                        initpath = trypath;
 
                // FIXME UNICODE
@@ -1968,7 +1977,7 @@ void BufferView::menuInsertLyXFile(string const & filenm)
 
        docstring res;
        Buffer buf("", false);
-       if (lyx::loadLyXFile(&buf, FileName(filename))) {
+       if (buf.loadLyXFile(FileName(filename))) {
                ErrorList & el = buffer_.errorList("Parse");
                // Copy the inserted document error list into the current buffer one.
                el = buf.errorList("Parse");
@@ -1976,8 +1985,9 @@ void BufferView::menuInsertLyXFile(string const & filenm)
                cap::pasteParagraphList(d->cursor_, buf.paragraphs(),
                                             buf.params().getTextClassPtr(), el);
                res = _("Document %1$s inserted.");
-       } else
+       } else {
                res = _("Could not insert document %1$s");
+       }
 
        // emit message signal.
        message(bformat(res, disp_fn));