]> git.lyx.org Git - features.git/commitdiff
Try to dispatch to document BufferView in case dispatch to current BufferView fails...
authorAbdelrazak Younes <younes@lyx.org>
Sun, 20 Sep 2009 21:41:21 +0000 (21:41 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 20 Sep 2009 21:41:21 +0000 (21:41 +0000)
URL: http://www.lyx.org/trac/changeset/31412

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31419 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/LyXFunc.cpp

index e929f789f2e31ac43d21ebdc8650b18cdc94d8b8..fbecee4c9229536a82183b2c3ed2e954873b39f4 100644 (file)
@@ -1095,6 +1095,8 @@ bool BufferView::dispatch(FuncRequest const & cmd)
        switch (cmd.action) {
 
        case LFUN_BUFFER_PARAMS_APPLY: {
+               if (buffer_.isInternal())
+                       return false;
                DocumentClass const * const oldClass = buffer_.params().documentClassPtr();
                cur.recordUndoFullDocument();
                istringstream ss(to_utf8(cmd.argument()));
@@ -1116,6 +1118,8 @@ bool BufferView::dispatch(FuncRequest const & cmd)
        }
                
        case LFUN_LAYOUT_MODULES_CLEAR: {
+               if (buffer_.isInternal())
+                       return false;
                DocumentClass const * const oldClass =
                        buffer_.params().documentClassPtr();
                cur.recordUndoFullDocument();
@@ -1127,6 +1131,8 @@ bool BufferView::dispatch(FuncRequest const & cmd)
        }
 
        case LFUN_LAYOUT_MODULE_ADD: {
+               if (buffer_.isInternal())
+                       return false;
                BufferParams const & params = buffer_.params();
                if (!params.moduleCanBeAdded(argument)) {
                        LYXERR0("Module `" << argument << 
@@ -1144,6 +1150,8 @@ bool BufferView::dispatch(FuncRequest const & cmd)
        }
 
        case LFUN_TEXTCLASS_APPLY: {
+               if (buffer_.isInternal())
+                       return false;
                if (!LayoutFileList::get().load(argument, buffer_.temppath()) &&
                        !LayoutFileList::get().load(argument, buffer_.filePath()))
                        break;
@@ -1167,11 +1175,15 @@ bool BufferView::dispatch(FuncRequest const & cmd)
        }
 
        case LFUN_TEXTCLASS_LOAD:
+               if (buffer_.isInternal())
+                       return false;
                LayoutFileList::get().load(argument, buffer_.temppath()) ||
                LayoutFileList::get().load(argument, buffer_.filePath());
                break;
 
        case LFUN_LAYOUT_RELOAD: {
+               if (buffer_.isInternal())
+                       return false;
                DocumentClass const * const oldClass = buffer_.params().documentClassPtr();
                LayoutFileIndex bc = buffer_.params().baseClassID();
                LayoutFileList::get().reset(bc);
index b53f2d2c2dc4212945c33ba4b45f9445c8a66d13..13f0ab3ba05ae906c3d0cb77f26c6abaaf174de2 100644 (file)
@@ -1091,6 +1091,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        if (lyx_view_ == 0)
                                break;
 
+                       BufferView * bv = lyx_view_->documentBufferView();
+                       BufferView * doc_bv = lyx_view_->documentBufferView();
+
                        // Start an undo group. This may be needed for
                        // some stuff like inset-apply on labels.
                        if (theBufferList().isLoaded(buffer))
@@ -1098,38 +1101,44 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                
                        // Let the current LyXView dispatch its own actions.
                        if (lyx_view_->dispatch(cmd)) {
-                               if (lyx_view_->currentBufferView()) {
-                                       updateFlags = lyx_view_->currentBufferView()->cursor().result().update();
+                               if (bv) {
+                                       updateFlags = bv->cursor().result().update();
                                        if (theBufferList().isLoaded(buffer))
                                                buffer->undo().endUndoGroup();
                                }
                                break;
                        }
 
-                       LASSERT(lyx_view_->currentBufferView(), /**/);
+                       LASSERT(bv, /**/);
 
                        // Let the current BufferView dispatch its own actions.
-                       if (lyx_view_->currentBufferView()->dispatch(cmd)) {
+                       if (bv->dispatch(cmd)) {
+                               // The BufferView took care of its own updates if needed.
+                               updateFlags = Update::None;
+                               if (theBufferList().isLoaded(buffer))
+                                       buffer->undo().endUndoGroup();
+                               break;
+                       }
+                       // Try with the document BufferView dispatch if any.
+                       if (doc_bv && doc_bv->dispatch(cmd)) {
                                // The BufferView took care of its own updates if needed.
+                               buffer = &(doc_bv->buffer());
                                updateFlags = Update::None;
                                if (theBufferList().isLoaded(buffer))
                                        buffer->undo().endUndoGroup();
                                break;
                        }
 
-                       // OK, so try the Buffer itself
+                       // OK, so try the current Buffer itself...
                        DispatchResult dr;
-                       BufferView * bv = lyx_view_->currentBufferView();
                        bv->buffer().dispatch(cmd, dr);
                        if (dr.dispatched()) {
                                updateFlags = dr.update();
                                break;
                        }
-                       // OK, so try with the document Buffer.
-                       BufferView * doc_bv = lyx_view_->documentBufferView();
+                       // and with the document Buffer.
                        if (doc_bv) {
-                               buffer = &(doc_bv->buffer());
-                               buffer->dispatch(cmd, dr);
+                               doc_bv->buffer().dispatch(cmd, dr);
                                if (dr.dispatched()) {
                                        updateFlags = dr.update();
                                        break;