]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
remove more forms.h cruft
[lyx.git] / src / lyxfunc.C
index 33ae956f304a88cdc90b9c9dc6c62221e794bbb3..9a5f2b241016db7f253534c311e9962728624d4f 100644 (file)
@@ -32,7 +32,6 @@
 #include "BufferView.h"
 #include "ColorHandler.h"
 #include "lyxserver.h"
-#include "figure_form.h"
 #include "intl.h"
 #include "lyx_main.h"
 #include "lyx_cb.h"
@@ -433,16 +432,16 @@ func_status::value_type LyXFunc::getStatus(int ac,
                // Disable insertion of floats in a tabular.
                disable = false;
                if (owner->view()->theLockingInset()) {
-                       disable = (owner->view()->theLockingInset()->LyxCode() == Inset::TABULAR_CODE) ||
-                               owner->view()->theLockingInset()->GetFirstLockingInsetOfType(Inset::TABULAR_CODE);
+                       disable = (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) ||
+                               owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
                }
                break;
 
        case LFUN_LAYOUT_TABULAR:
                disable = true;
                if (owner->view()->theLockingInset()) {
-                       disable = (owner->view()->theLockingInset()->LyxCode() != Inset::TABULAR_CODE) &&
-                               !owner->view()->theLockingInset()->GetFirstLockingInsetOfType(Inset::TABULAR_CODE);
+                       disable = (owner->view()->theLockingInset()->lyxCode() != Inset::TABULAR_CODE) &&
+                               !owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
                }
                break;
 
@@ -450,14 +449,14 @@ func_status::value_type LyXFunc::getStatus(int ac,
                disable = true;
                if (owner->view()->theLockingInset()) {
                        func_status::value_type ret = func_status::Disabled;
-                       if (owner->view()->theLockingInset()->LyxCode() == Inset::TABULAR_CODE) {
+                       if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) {
                                ret = static_cast<InsetTabular *>
                                        (owner->view()->theLockingInset())->
                                        getStatus(argument);
-                       } else if (owner->view()->theLockingInset()->GetFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
+                       } else if (owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
                                ret = static_cast<InsetTabular *>
                                        (owner->view()->theLockingInset()->
-                                        GetFirstLockingInsetOfType(Inset::TABULAR_CODE))->
+                                        getFirstLockingInsetOfType(Inset::TABULAR_CODE))->
                                        getStatus(argument);
                        }
                        flag |= ret;
@@ -493,8 +492,8 @@ func_status::value_type LyXFunc::getStatus(int ac,
                        isSavedPosition(strToUnsignedInt(argument));
        case LFUN_MATH_VALIGN: {
                Inset * tli = owner->view()->theLockingInset();
-               if (tli && (tli->LyxCode() == Inset::MATH_CODE 
-                           || tli->LyxCode() == Inset::MATHMACRO_CODE)) {
+               if (tli && (tli->lyxCode() == Inset::MATH_CODE 
+                           || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
                        char align = mathcursor->valign();
                        if (align == '\0') {
                                disable = true;
@@ -518,8 +517,8 @@ func_status::value_type LyXFunc::getStatus(int ac,
        }
        case LFUN_MATH_HALIGN: {
                Inset * tli = owner->view()->theLockingInset();
-               if (tli && (tli->LyxCode() == Inset::MATH_CODE 
-                           || tli->LyxCode() == Inset::MATHMACRO_CODE)) {
+               if (tli && (tli->lyxCode() == Inset::MATH_CODE 
+                           || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
                        char align = mathcursor->halign();
                        if (align == '\0') {
                                disable = true;
@@ -543,7 +542,7 @@ func_status::value_type LyXFunc::getStatus(int ac,
        }
        case LFUN_MATH_MUTATE: {
                Inset * tli = owner->view()->theLockingInset();
-               if (tli && (tli->LyxCode() == Inset::MATH_CODE)) {
+               if (tli && (tli->lyxCode() == Inset::MATH_CODE)) {
                        MathInsetTypes type = mathcursor->par()->GetType();
                        func_status::value_type box = func_status::ToggleOff;
                        if (argument == "inline") {
@@ -656,7 +655,14 @@ string const LyXFunc::Dispatch(int ac,
                if (!do_not_use_this_arg.empty())
                        argument = do_not_use_this_arg; // except here
        }
-    
+
+#ifdef NEW_DISPATCHER
+       // We try do call the most specific dispatcher first:
+       //  1. the lockinginset's dispatch
+       //  2. the bufferview's dispatch
+       //  3. the lyxview's dispatch
+#endif
+       
        selection_possible = false;
        
        if (owner->view()->available())
@@ -681,7 +687,7 @@ string const LyXFunc::Dispatch(int ac,
                                int sly;
                                UpdatableInset * inset = 
                                        owner->view()->theLockingInset();
-                               inset->GetCursorPos(owner->view(), slx, sly);
+                               inset->getCursorPos(owner->view(), slx, sly);
                                owner->view()->unlockInset(inset);
                                owner->view()->menuUndo();
                                if (TEXT()->cursor.par()->
@@ -694,14 +700,14 @@ string const LyXFunc::Dispatch(int ac,
                                        inset = 0;
                                }
                                if (inset)
-                                       inset->Edit(owner->view(),slx,sly,0);
+                                       inset->edit(owner->view(),slx,sly,0);
                                return string();
                        } else if (action == LFUN_REDO) {
                                int slx;
                                int sly;
                                UpdatableInset * inset = owner->view()->
                                        theLockingInset();
-                               inset->GetCursorPos(owner->view(), slx, sly);
+                               inset->getCursorPos(owner->view(), slx, sly);
                                owner->view()->unlockInset(inset);
                                owner->view()->menuRedo();
                                inset = static_cast<UpdatableInset*>(
@@ -709,10 +715,10 @@ string const LyXFunc::Dispatch(int ac,
                                        getInset(TEXT()->
                                                 cursor.pos()));
                                if (inset)
-                                       inset->Edit(owner->view(),slx,sly,0); 
+                                       inset->edit(owner->view(),slx,sly,0); 
                                return string();
                        } else if (((result=owner->view()->theLockingInset()->
-                                  LocalDispatch(owner->view(), action,
+                                  localDispatch(owner->view(), action,
                                                 argument)) ==
                                   UpdatableInset::DISPATCHED) ||
                                   (result == UpdatableInset::DISPATCHED_NOUPDATE))
@@ -768,7 +774,7 @@ string const LyXFunc::Dispatch(int ac,
                UpdatableInset * tli =
                        owner->view()->theLockingInset();
                if (tli) {
-                       UpdatableInset * lock = tli->GetLockingInset();
+                       UpdatableInset * lock = tli->getLockingInset();
                        
                        if (tli == lock) {
                                owner->view()->unlockInset(tli);
@@ -776,7 +782,7 @@ string const LyXFunc::Dispatch(int ac,
                                moveCursorUpdate(true, false);
                                owner->showState();
                        } else {
-                               tli->UnlockInsetInInset(owner->view(),
+                               tli->unlockInsetInInset(owner->view(),
                                                        lock,
                                                        true);
                        }
@@ -1064,25 +1070,25 @@ string const LyXFunc::Dispatch(int ac,
                        setErrorMessage(N_("Missing argument"));
                        break;
                }
-               ProhibitInput(owner->view());
+               owner->prohibitInput();
                string const fname = i18nLibFileSearch("doc", arg, "lyx");
                if (fname.empty()) {
                        lyxerr << "LyX: unable to find documentation file `"
                               << arg << "'. Bad installation?" << endl;
-                       AllowInput(owner->view());
+                       owner->allowInput();
                        break;
                }
                ostringstream str;
                str << _("Opening help file") << ' '
                    << MakeDisplayPath(fname) << "...";
                owner->message(str.str().c_str());
-               owner->view()->buffer(bufferlist.loadLyXFile(fname,false));
-               AllowInput(owner->view());
+               owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
+               owner->allowInput();
                break;
         }
 
        case LFUN_HELP_VERSION: {
-               ProhibitInput(owner->view());
+               owner->prohibitInput();
                string msg(_("LyX Version "));
                msg += LYX_VERSION;
                msg += " of ";
@@ -1092,7 +1098,7 @@ string const LyXFunc::Dispatch(int ac,
                                 + MakeDisplayPath(system_lyxdir)).c_str(),
                                (_("User directory: ") 
                                 + MakeDisplayPath(user_lyxdir)).c_str());
-               AllowInput(owner->view());
+               owner->allowInput();
                break;
        }
        
@@ -1195,15 +1201,15 @@ string const LyXFunc::Dispatch(int ac,
 
        case LFUN_LAYOUT_TABULAR:
            if (owner->view()->theLockingInset()) {
-               if (owner->view()->theLockingInset()->LyxCode()==Inset::TABULAR_CODE) {
+               if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
                    InsetTabular * inset = static_cast<InsetTabular *>
                        (owner->view()->theLockingInset());
-                   inset->OpenLayoutDialog(owner->view());
+                   inset->openLayoutDialog(owner->view());
                } else if (owner->view()->theLockingInset()->
-                          GetFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
+                          getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
                    InsetTabular * inset = static_cast<InsetTabular *>(
-                       owner->view()->theLockingInset()->GetFirstLockingInsetOfType(Inset::TABULAR_CODE));
-                   inset->OpenLayoutDialog(owner->view());
+                       owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
+                   inset->openLayoutDialog(owner->view());
                }
            }
            break;
@@ -1250,19 +1256,26 @@ string const LyXFunc::Dispatch(int ac,
 
        case LFUN_GOTOFILEROW:
        {
+#if 0
                char file_name[100];
                int row;
                ::sscanf(argument.c_str(), " %s %d", file_name, &row);
-
+#else
+               string file_name;
+               int row;
+               istringstream istr(argument.c_str());
+               istr >> file_name >> row;
+#endif
                // Must replace extension of the file to be .lyx and get full path
-               string s = ChangeExtension(string(file_name), ".lyx");
+               string const s(ChangeExtension(file_name, ".lyx"));
 
                // Either change buffer or load the file
-               if (bufferlist.exists(s))
+               if (bufferlist.exists(s)) {
                        owner->view()->buffer(bufferlist.getBuffer(s));
-               else
+               } else {
                        owner->view()->buffer(bufferlist.loadLyXFile(s));
-
+               }
+               
                // Set the cursor  
                owner->view()->setCursorFromRow(row);
 
@@ -1278,8 +1291,11 @@ string const LyXFunc::Dispatch(int ac,
                int id;
                istr >> id;
                Paragraph * par = TEXT()->getParFromID(id);
-               if (par == 0)
+               if (par == 0) {
+                       lyxerr[Debug::INFO] << "No matching paragraph found! ["
+                                           << id << "]" << std::endl;
                        break;
+               }
 
                // Set the cursor
                TEXT()->setCursor(owner->view(), par, 0);