]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
Dekels tabular/textinset patches
[lyx.git] / src / lyxfunc.C
index 9a78e888604732f03d25e223304cf6a4d5372a8c..c0af8bd4cf160d98b097295e4daa1054c8af63cc 100644 (file)
@@ -91,9 +91,8 @@ using std::pair;
 using std::endl;
 using std::find_if;
 
-extern void InsertAsciiFile(BufferView *, string const &, bool);
-extern void math_insert_symbol(string const &);
-extern bool math_insert_greek(char);
+extern void math_insert_symbol(BufferView *, string const &);
+extern bool math_insert_greek(BufferView *, char);
 extern BufferList bufferlist;
 extern LyXServer * lyxserver;
 extern int greek_kb_flag;
@@ -101,14 +100,6 @@ extern bool selection_possible;
 
 extern kb_keymap * toplevel_keymap;
 
-extern bool MenuWrite(Buffer *);
-extern bool MenuWriteAs(Buffer *);
-extern int  MenuRunLaTeX(Buffer *);
-extern int  MenuBuildProg(Buffer *);
-extern int  MenuRunChktex(Buffer *);
-extern void MenuPrint(Buffer *);
-extern void MenuSendto();
-extern void QuitLyX();
 #if 0
 extern void MenuFax(Buffer *);
 #endif
@@ -118,19 +109,7 @@ extern LyXAction lyxaction;
 // (alkis)
 extern tex_accent_struct get_accent(kb_action action);
 
-extern void AutoSave(BufferView *);
-extern void MenuInsertLabel(string const &);
-extern void MenuLayoutCharacter();
-extern void MenuLayoutParagraph();
-extern void MenuLayoutPreamble();
-extern void MenuLayoutSave();
-
-extern Buffer * NewLyxFile(string const &);
-extern void LoadLyXFile(string const &);
-extern void Reconfigure(BufferView *);
-
 extern LyXTextClass::size_type current_layout;
-extern int getISOCodeFromLaTeX(char *);
 
 extern void ShowLatexLog();
 
@@ -177,11 +156,12 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
        
        if (lyxerr.debugging(Debug::KEY)) {
                char * tmp = XKeysymToString(keysym);
-               string stm = (tmp ? tmp : "");
+               string const stm = (tmp ? tmp : "");
                lyxerr << "KeySym is "
                       << stm
                       << "["
-                      << keysym << "]"
+                      << keysym << "] State is ["
+                      << state << "]"
                       << endl;
        }
        // Do nothing if we have nothing (JMarc)
@@ -225,17 +205,25 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
        int action = cancel_meta_seq.addkey(keysym, state
                                            &(ShiftMask|ControlMask
                                              |Mod1Mask)); 
-
+       if (lyxerr.debugging(Debug::KEY)) {
+               lyxerr << "action first set to [" << action << "]" << endl;
+       }
+       
        // When not cancel or meta-fake, do the normal lookup. 
        // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
        // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
        if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
-
+               if (lyxerr.debugging(Debug::KEY)) {
+                       lyxerr << "meta_fake_bit is [" << meta_fake_bit << "]" << endl;
+               }
                // remove Caps Lock and Mod2 as a modifiers
                action = keyseq.addkey(keysym,
                                       (state | meta_fake_bit)
                                       &(ShiftMask|ControlMask
-                                        |Mod1Mask));      
+                                        |Mod1Mask));
+               if (lyxerr.debugging(Debug::KEY)) {
+                       lyxerr << "action now set to [" << action << "]" << endl;
+               }
        }
        // Dont remove this unless you know what you are doing.
        meta_fake_bit = 0;
@@ -270,7 +258,7 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
                        return 0;
                }
        
-               char isochar = keyseq.getiso();
+               char const isochar = keyseq.getiso();
                if (!(state & ControlMask) &&
                    !(state & Mod1Mask) &&
                    (isochar && keysym < 0xF000)) {
@@ -282,7 +270,38 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
                        // so we`ll skip the dispatch.
                        return 0;
                }
+       } else if (action == LFUN_SELFINSERT) {
+               // We must set the argument to the char looked up by
+               // XKeysymToString
+               XKeyEvent xke;
+               xke.type = KeyPress;
+               xke.serial = 0;
+               xke.send_event = False;
+               xke.display = fl_get_display();
+               xke.window = 0;
+               xke.root = 0;
+               xke.subwindow = 0;
+               xke.time = 0;
+               xke.x = 0;
+               xke.y = 0;
+               xke.x_root = 0;
+               xke.y_root = 0;
+               xke.state = state;
+               xke.keycode = XKeysymToKeycode(fl_get_display(), keysym);
+               xke.same_screen = True;
+               char ret[10];
+               KeySym tmpkeysym;
+               int res = XLookupString(&xke, ret, 10, &tmpkeysym, 0);
+               //Assert(keysym == tmpkeysym);
+               lyxerr[Debug::KEY] << "TmpKeysym ["
+                                  << tmpkeysym << "]" << endl;
+               
+               if (res > 0)
+                       argument = string(ret, res);
+               lyxerr[Debug::KEY] << "SelfInsert arg["
+                                  << argument << "]" << endl;
        }
+       
 
         bool tmp_sc = show_sc;
        show_sc = false;
@@ -351,9 +370,6 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
                        !Exporter::IsExportable(buf, argument);
                break;
 #endif
-       case LFUN_IMPORT:
-               disable = !Importer::IsImportable(argument);
-               break;
        case LFUN_UNDO:
                disable = buf->undostack.empty();
                break;
@@ -370,6 +386,17 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
                disable = !Exporter::IsExportable(buf, "program");
                break;
 
+       case LFUN_INSERTFOOTNOTE:
+       case LFUN_FOOTMELT:
+       case LFUN_MARGINMELT:
+               // 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);
+               }
+               break;
+
        case LFUN_LAYOUT_TABULAR:
                disable = true;
                if (owner->view()->theLockingInset()) {
@@ -431,13 +458,8 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
 
        if (buf) {
                func_status box = LyXFunc::ToggleOff;
-               LyXFont font;
-               if (owner->view()->theLockingInset() &&
-                   owner->view()->theLockingInset()->getLyXText(owner->view()))
-                   font = owner->view()->theLockingInset()->
-                       getLyXText(owner->view())->real_current_font;
-               else
-                   font = owner->view()->text->real_current_font;
+               LyXFont const & font =
+                       owner->view()->getLyXText()->real_current_font;
                switch (action) {
                case LFUN_EMPH:
                        if (font.emph() == LyXFont::ON)
@@ -485,7 +507,6 @@ string const LyXFunc::Dispatch(int ac,
        
        string argument;
        kb_action action;
-       LyXText * text = 0;
         
         // we have not done anything wrong yet.
         errorstat = false;
@@ -509,6 +530,9 @@ string const LyXFunc::Dispatch(int ac,
        if (owner->view()->available())
                owner->view()->hideCursor();
 
+       // We have to do this heare because of te goto below. (Lgb)
+       LyXText * text = owner->view()->getLyXText();
+
        // We cannot use this function here
        if (getStatus(ac) & Disabled)
                goto exit_with_message;
@@ -539,7 +563,8 @@ string const LyXFunc::Dispatch(int ac,
                                }
                        }
 
-                       string shortcuts = toplevel_keymap->findbinding(pseudoaction);
+                       string const shortcuts =
+                               toplevel_keymap->findbinding(pseudoaction);
 
                        if (!shortcuts.empty()) {
                                comname += ": " + shortcuts;
@@ -612,7 +637,7 @@ string const LyXFunc::Dispatch(int ac,
                                   (result == UpdatableInset::DISPATCHED_NOUPDATE))
                                return string();
                        else {
-                               setMessage(N_("Text mode"));
+                               //setMessage(N_("Text mode"));
                                switch (action) {
                                case LFUN_UNKNOWN_ACTION:
                                case LFUN_BREAKPARAGRAPH:
@@ -645,14 +670,8 @@ string const LyXFunc::Dispatch(int ac,
                                }
                        }
                }
-               if (owner->view()->theLockingInset())
-                       text = owner->view()->theLockingInset()->
-                               getLyXText(owner->view());
        }
 
-       if (!text)
-           text = owner->view()->text;
-
        switch (action) {
                // --- Misc -------------------------------------------
        case LFUN_WORDFINDFORWARD  : 
@@ -776,7 +795,7 @@ string const LyXFunc::Dispatch(int ac,
                        owner->getMiniBuffer()->Set(_("Saving document"),
                                                    MakeDisplayPath(owner->buffer()->fileName()),
                                                    "...");
-                       MenuWrite(owner->buffer());
+                       MenuWrite(owner->view(), owner->buffer());
                        //owner->getMiniBuffer()-> {
                        //      Set(_("Document saved as"),
                        //          MakeDisplayPath(owner->buffer()->fileName()));
@@ -784,12 +803,12 @@ string const LyXFunc::Dispatch(int ac,
                        //owner->getMiniBuffer()->Set(_("Save failed!"));
                        //}
                } else {
-                       MenuWriteAs(owner->buffer());
+                       MenuWriteAs(owner->view(), owner->buffer());
                }
                break;
                
        case LFUN_MENUWRITEAS:
-               MenuWriteAs(owner->buffer());
+               MenuWriteAs(owner->view(), owner->buffer());
                break;
                
        case LFUN_MENURELOAD:
@@ -998,15 +1017,15 @@ string const LyXFunc::Dispatch(int ac,
                break;
                
        case LFUN_DEPTH:
-               changeDepth(owner->view(), 0);
+               changeDepth(owner->view(), text, 0);
                break;
                
        case LFUN_DEPTH_MIN:
-               changeDepth(owner->view(), -1);
+               changeDepth(owner->view(), text, -1);
                break;
                
        case LFUN_DEPTH_PLUS:
-               changeDepth(owner->view(), 1);
+               changeDepth(owner->view(), text, 1);
                break;
                
        case LFUN_FREE:
@@ -1290,7 +1309,7 @@ string const LyXFunc::Dispatch(int ac,
                break;
                
        case LFUN_LAYOUT_SAVE_DEFAULT:
-               MenuLayoutSave();
+               MenuLayoutSave(owner->view());
                break;
                
        case LFUN_DROP_LAYOUTS_CHOICE:
@@ -1378,7 +1397,7 @@ string const LyXFunc::Dispatch(int ac,
                break;
                
        case LFUN_INSERT_LABEL:
-               MenuInsertLabel(argument);
+               MenuInsertLabel(owner->view(), argument);
                break;
                
        case LFUN_REF_INSERT:
@@ -1449,7 +1468,15 @@ string const LyXFunc::Dispatch(int ac,
                    && tmptext->cursor.par()->GetInset(tmptext->cursor.pos())->Editable() == Inset::HIGHLY_EDITABLE){
                        Inset * tmpinset = tmptext->cursor.par()->GetInset(tmptext->cursor.pos());
                        setMessage(tmpinset->EditMessage());
-                       tmpinset->Edit(owner->view(), 0, 0, 0);
+                       int y = 0;
+                       if (is_rtl) {
+                               LyXFont font = 
+                                       tmptext->GetFont(owner->view()->buffer(),
+                                                        tmptext->cursor.par(),
+                                                        tmptext->cursor.pos());        
+                               y = tmpinset->descent(owner->view(),font);
+                       }
+                       tmpinset->Edit(owner->view(), 0, y, 0);
                        break;
                }
                if (!is_rtl)
@@ -1471,7 +1498,7 @@ string const LyXFunc::Dispatch(int ac,
                LyXCursor cur = txt->cursor;
                if (!is_rtl)
                        txt->CursorLeft(owner->view(), false);
-               if ((cur != txt->cursor) && // only if really moved!
+               if ((is_rtl || cur != txt->cursor) && // only if really moved!
                    txt->cursor.pos() < txt->cursor.par()->Last() &&
                    (txt->cursor.par()->GetChar(txt->cursor.pos()) ==
                     LyXParagraph::META_INSET) &&
@@ -1484,11 +1511,12 @@ string const LyXFunc::Dispatch(int ac,
                        LyXFont font = txt->GetFont(owner->view()->buffer(),
                                                    txt->cursor.par(),
                                                    txt->cursor.pos());
+                       int y = is_rtl ? 0 
+                               : tmpinset->descent(owner->view(),font);
                        tmpinset->Edit(owner->view(),
                                       tmpinset->x() +
                                       tmpinset->width(owner->view(),font),
-                                      tmpinset->descent(owner->view(),font),
-                                      0);
+                                      y, 0);
                        break;
                }
                if  (is_rtl)
@@ -1825,7 +1853,7 @@ string const LyXFunc::Dispatch(int ac,
                                owner->view()->text->cursor;
                        owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
                        // It is possible to make it a lot faster still
-                       // just comment out the lone below...
+                       // just comment out the line below...
                        owner->view()->showCursor();
                } else {
                        owner->view()->cut();
@@ -1935,13 +1963,17 @@ string const LyXFunc::Dispatch(int ac,
        case LFUN_BACKSPACE:
        {
                if (!owner->view()->text->selection) {
+#if 0
                        if (owner->getIntl()->getTrans()->backspace()) {
+#else
+                       if (owner->getIntl()->getTrans().backspace()) {
+#endif
                                owner->view()->text->Backspace(owner->view());
                                owner->view()->text->sel_cursor = 
                                        owner->view()->text->cursor;
                                owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
                                // It is possible to make it a lot faster still
-                               // just comment out the lone below...
+                               // just comment out the line below...
                                owner->view()->showCursor();
                        }
                } else {
@@ -2242,9 +2274,9 @@ string const LyXFunc::Dispatch(int ac,
                        ::sscanf(argument.c_str(),"%d%d", &r, &c);
                InsetTabular * new_inset =
                        new InsetTabular(*owner->buffer(), r, c);
-               if (owner->view()->insertInset(new_inset))
-                       new_inset->Edit(owner->view(), 0, 0, 0);
-               else
+               bool rtl =
+                       owner->view()->getLyXText()->real_current_font.isRightToLeft();
+               if (!owner->view()->open_new_inset(new_inset, rtl))
                        delete new_inset;
        }
        break;
@@ -2398,10 +2430,16 @@ string const LyXFunc::Dispatch(int ac,
                
                if (keyseq.length == -1 && keyseq.getiso() != 0) 
                        c = keyseq.getiso();
-               
+
+#if 0
                owner->getIntl()->getTrans()->
                        deadkey(c, get_accent(action).accent, 
                                owner->view()->text);
+#else
+               owner->getIntl()->getTrans()
+                       .deadkey(c, get_accent(action).accent, 
+                               owner->view()->text);
+#endif
                
                // Need to reset, in case the minibuffer calls these
                // actions
@@ -2491,7 +2529,7 @@ string const LyXFunc::Dispatch(int ac,
               
        case LFUN_INSERT_MATH:
        {
-               math_insert_symbol(argument);
+               math_insert_symbol(owner->view(), argument);
        }
        break;
        
@@ -2509,8 +2547,8 @@ string const LyXFunc::Dispatch(int ac,
                        if (s.empty())
                                setErrorMessage(N_("Missing argument"));
                        else {
-                               string s1 = token(s, ' ', 1);
-                               int na = s1.empty() ? 0 : lyx::atoi(s1);
+                               string const s1 = token(s, ' ', 1);
+                               int const na = s1.empty() ? 0 : lyx::atoi(s1);
                                owner->view()->
                                        open_new_inset(new InsetFormulaMacro(token(s, ' ', 0), na));
                        }
@@ -2542,17 +2580,22 @@ string const LyXFunc::Dispatch(int ac,
        
        case LFUN_CITATION_CREATE:
        {
-               // Should do this "at source"
                InsetCommandParams p( "cite" );
                
-               if (contains(argument, "|")) {
-                       p.setContents( token(argument, '|', 0) );
-                       p.setOptions(  token(argument, '|', 1) );
-               } else {
-                       p.setContents( argument );
-               }
-
-               owner->getDialogs()->createCitation( p.getAsString() );
+               if (!argument.empty()) {
+                       // This should be set at source, ie when typing
+                       // "citation-insert foo" in the minibuffer.
+                       // Question: would pybibliographer also need to be
+                       // changed. Suspect so. Leave as-is therefore.
+                       if (contains(argument, "|")) {
+                               p.setContents( token(argument, '|', 0) );
+                               p.setOptions(  token(argument, '|', 1) );
+                       } else {
+                               p.setContents( argument );
+                       }
+                       Dispatch(LFUN_CITATION_INSERT, p.getAsString());
+               } else
+                       owner->getDialogs()->createCitation( p.getAsString() );
        }
        break;
                    
@@ -2574,7 +2617,7 @@ string const LyXFunc::Dispatch(int ac,
                // ale970405+lasgoutt970425
                // The argument can be up to two tokens separated 
                // by a space. The first one is the bibstyle.
-               string db       = token(argument, ' ', 0);
+               string const db       = token(argument, ' ', 0);
                string bibstyle = token(argument, ' ', 1);
                if (bibstyle.empty())
                        bibstyle = "plain";
@@ -2647,13 +2690,13 @@ string const LyXFunc::Dispatch(int ac,
        case LFUN_INDEX_INSERT:
        {
                InsetCommandParams p;
-               p.setFromString( argument );
-               InsetIndex * inset = new InsetIndex( p );
+               p.setFromString(argument);
+               InsetIndex * inset = new InsetIndex(p);
 
                if (!owner->view()->insertInset(inset))
                        delete inset;
                else
-                       owner->view()->updateInset( inset, true );
+                       owner->view()->updateInset(inset, true);
        }
        break;
                    
@@ -2663,24 +2706,24 @@ string const LyXFunc::Dispatch(int ac,
                LyXParagraph::size_type curpos = 
                        owner->view()->text->cursor.pos() - 1;
                // Can't do that at the beginning of a paragraph
-               if (curpos < 0 ) break;
+               if (curpos < 0) break;
 
-               string curstring( owner->view()->text
-                                 ->cursor.par()->GetWord(curpos) );
+               string const curstring(owner->view()->text
+                                 ->cursor.par()->GetWord(curpos));
 
-               InsetCommandParams p( "index", curstring );
-               InsetIndex * inset = new InsetIndex( p );
+               InsetCommandParams p("index", curstring);
+               InsetIndex * inset = new InsetIndex(p);
 
                if (!owner->view()->insertInset(inset))
                        delete inset;
                else
-                       owner->view()->updateInset( inset, true );
+                       owner->view()->updateInset(inset, true);
        }
        break;
                    
        case LFUN_INDEX_PRINT:
        {
-               InsetCommandParams p( "printindex" );
+               InsetCommandParams p("printindex");
                Inset * inset = new InsetPrintIndex(p);
                if (!owner->view()->insertInset(inset, "Standard", true))
                        delete inset;
@@ -2710,7 +2753,7 @@ string const LyXFunc::Dispatch(int ac,
 
        case LFUN_CHILDOPEN:
        {
-               string filename =
+               string const filename =
                        MakeAbsPath(argument, 
                                    OnlyPath(owner->buffer()->fileName()));
                setMessage(N_("Opening child document ") +
@@ -2730,21 +2773,21 @@ string const LyXFunc::Dispatch(int ac,
        case LFUN_INSERTFOOTNOTE: 
        {
                LyXParagraph::footnote_kind kind;
-               if (argument == "footnote")
-                       { kind = LyXParagraph::FOOTNOTE; }
-               else if (argument == "margin")
-                       { kind = LyXParagraph::MARGIN; }
-               else if (argument == "figure")
-                       { kind = LyXParagraph::FIG; }
-               else if (argument == "table")
-                       { kind = LyXParagraph::TAB; }
-               else if (argument == "wide-fig")
-                       { kind = LyXParagraph::WIDE_FIG; }
-               else if (argument == "wide-tab")
-                       { kind = LyXParagraph::WIDE_TAB; }
-               else if (argument == "algorithm")
-                       { kind = LyXParagraph::ALGORITHM; }
-               else {
+               if (argument == "footnote") {
+                       kind = LyXParagraph::FOOTNOTE;
+               } else if (argument == "margin") {
+                       kind = LyXParagraph::MARGIN;
+               } else if (argument == "figure") {
+                       kind = LyXParagraph::FIG;
+               } else if (argument == "table") {
+                       kind = LyXParagraph::TAB;
+               } else if (argument == "wide-fig") {
+                       kind = LyXParagraph::WIDE_FIG;
+               } else if (argument == "wide-tab") {
+                       kind = LyXParagraph::WIDE_TAB;
+               } else if (argument == "algorithm") {
+                       kind = LyXParagraph::ALGORITHM;
+               else {
                        setErrorMessage(N_("Unknown kind of footnote"));
                        break;
                }
@@ -2776,7 +2819,7 @@ string const LyXFunc::Dispatch(int ac,
 
        case LFUN_SELFINSERT:
        {
-               LyXFont old_font(owner->view()->text->real_current_font);
+               LyXFont const old_font(owner->view()->text->real_current_font);
                for (string::size_type i = 0; i < argument.length(); ++i) {
                        owner->view()->text->InsertChar(owner->view(), argument[i]);
                        // This needs to be in the loop, or else we
@@ -2818,7 +2861,8 @@ string const LyXFunc::Dispatch(int ac,
                else 
                        arg = lyxrc.date_insert_format;
                char datetmp[32];
-               int datetmp_len = ::strftime(datetmp, 32, arg.c_str(), now_tm);
+               int const datetmp_len =
+                       ::strftime(datetmp, 32, arg.c_str(), now_tm);
                for (int i = 0; i < datetmp_len; i++) {
                        owner->view()->text->InsertChar(owner->view(), datetmp[i]);
                        owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
@@ -2859,8 +2903,8 @@ string const LyXFunc::Dispatch(int ac,
 
        case LFUN_SET_COLOR:
        {
-               string lyx_name, x11_name;
-               x11_name = split(argument, lyx_name, ' ');
+               string lyx_name;
+               string const x11_name = split(argument, lyx_name, ' ');
                if (lyx_name.empty() || x11_name.empty()) {
                        LyXBell();
                        setErrorMessage(N_("Syntax: set-color <lyx_name>"
@@ -2869,11 +2913,12 @@ string const LyXFunc::Dispatch(int ac,
                        }
 
                if (!lcolor.setColor(lyx_name, x11_name)) {
-                       static string err1 (N_("Set-color \""));
-                       static string err2 (N_("\" failed - color is undefined "
-                                               "or may not be redefined"));
+                       static string const err1 (N_("Set-color \""));
+                       static string const err2 (
+                               N_("\" failed - color is undefined "
+                                  "or may not be redefined"));
                        LyXBell();
-                       setErrorMessage(err1 + lyx_name + err2);
+                       setErrorMessage(_(err1) + lyx_name + _(err2));
                        break;
                }
                lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
@@ -2911,14 +2956,23 @@ string const LyXFunc::Dispatch(int ac,
                        }
                        
                        owner->view()->beforeChange();
-                       LyXFont old_font(owner->view()->text->real_current_font);
+                       LyXFont const old_font(owner->view()->text->real_current_font);
                        for (string::size_type i = 0;
                             i < argument.length(); ++i) {
                                if (greek_kb_flag) {
-                                       if (!math_insert_greek(argument[i]))
+                                       if (!math_insert_greek(owner->view(),
+                                                              argument[i]))
+#if 0
                                                owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
+#else
+                                               owner->getIntl()->getTrans().TranslateAndInsert(argument[i], owner->view()->text);
+#endif
                                } else
+#if 0
                                        owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
+#else
+                                       owner->getIntl()->getTrans().TranslateAndInsert(argument[i], owner->view()->text);
+#endif
                        }
 
                        owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
@@ -2948,11 +3002,12 @@ string const LyXFunc::Dispatch(int ac,
        } // end of switch
   exit_with_message:
 
-       string res = getMessage();
+       string const res = getMessage();
 
        if (res.empty()) {
                if (!commandshortcut.empty()) {
-                       string newbuf = owner->getMiniBuffer()->GetText();
+                       string const newbuf =
+                               owner->getMiniBuffer()->GetText();
                        if (newbuf != commandshortcut) {
                                owner->getMiniBuffer()->Set(newbuf
                                                            + " " +
@@ -2983,7 +3038,7 @@ void LyXFunc::MenuNew(bool fromTemplate)
        LyXFileDlg fileDlg;
 
        if (owner->view()->available()) {
-               string trypath = owner->buffer()->filepath;
+               string const trypath = owner->buffer()->filepath;
                // If directory is writeable, use this as default.
                if (IsDirWriteable(trypath) == 1)
                        initpath = trypath;
@@ -2991,7 +3046,7 @@ void LyXFunc::MenuNew(bool fromTemplate)
 
        static int newfile_number = 0;
        string s;
-
+       
        if (lyxrc.new_ask_filename) {
                ProhibitInput(owner->view());
                fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
@@ -3068,9 +3123,9 @@ void LyXFunc::MenuNew(bool fromTemplate)
        string templname;
        if (fromTemplate) {
                ProhibitInput(owner->view());
-               string fname = fileDlg.Select(_("Choose template"),
-                                      lyxrc.template_path,
-                                      "*.lyx");
+               string const fname = fileDlg.Select(_("Choose template"),
+                                                   lyxrc.template_path,
+                                                   "*.lyx");
                AllowInput(owner->view());
                if (fname.empty()) return;
                 templname = fname;
@@ -3088,7 +3143,7 @@ void LyXFunc::MenuOpen()
        LyXFileDlg fileDlg;
   
        if (owner->view()->available()) {
-               string trypath = owner->buffer()->filepath;
+               string const trypath = owner->buffer()->filepath;
                // If directory is writeable, use this as default.
                if (IsDirWriteable(trypath) == 1)
                        initpath = trypath;
@@ -3130,6 +3185,7 @@ void LyXFunc::MenuOpen()
        }
 }
 
+
 // checks for running without gui are missing.
 void LyXFunc::doImport(string const & argument)
 {
@@ -3143,7 +3199,7 @@ void LyXFunc::doImport(string const & argument)
                LyXFileDlg fileDlg;
                
                if (owner->view()->available()) {
-                       string trypath = owner->buffer()->filepath;
+                       string const trypath = owner->buffer()->filepath;
                        // If directory is writeable, use this as default.
                        if (IsDirWriteable(trypath) == 1)
                                initpath = trypath;
@@ -3154,10 +3210,9 @@ void LyXFunc::doImport(string const & argument)
                fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
                fileDlg.SetButton(1, _("Examples"), 
                                        AddPath(system_lyxdir, "examples"));
-               string text = _("Select ") + formats.PrettyName(format)
+               string const text = _("Select ") + formats.PrettyName(format)
                        + _(" file to import");
-               string format2 = (format == "textparagraph") ? "text" : format;
-               string extension = "*." + formats.Extension(format2);
+               string const extension = "*." + formats.Extension(format);
                filename = fileDlg.Select(text, initpath, extension);
                AllowInput(owner->view());
  
@@ -3173,7 +3228,7 @@ void LyXFunc::doImport(string const & argument)
        // get absolute path of file
        filename = MakeAbsPath(filename);
 
-       string lyxfile = ChangeExtension(filename, ".lyx");
+       string const lyxfile = ChangeExtension(filename, ".lyx");
 
        // Check if the document already is open
        if (bufferlist.exists(lyxfile)) {
@@ -3197,7 +3252,7 @@ void LyXFunc::doImport(string const & argument)
        }
 
        // Check if a LyX document by the same root exists in filesystem
-       FileInfo f(lyxfile, true);
+       FileInfo const f(lyxfile, true);
        if (f.exist() && !AskQuestion(_("A document by the name"), 
                                      MakeDisplayPath(lyxfile),
                                      _("already exists. Overwrite?"))) {
@@ -3220,7 +3275,7 @@ void LyXFunc::MenuInsertLyXFile(string const & filen)
                LyXFileDlg fileDlg;
 
                if (owner->view()->available()) {
-                       string trypath = owner->buffer()->filepath;
+                       string const trypath = owner->buffer()->filepath;
                        // If directory is writeable, use this as default.
                        if (IsDirWriteable(trypath) == 1)
                                initpath = trypath;
@@ -3251,7 +3306,7 @@ void LyXFunc::MenuInsertLyXFile(string const & filen)
        // Inserts document
        owner->getMiniBuffer()->Set(_("Inserting document"),
                                    MakeDisplayPath(filename), "...");
-       bool res = owner->view()->insertLyXFile(filename);
+       bool const res = owner->view()->insertLyXFile(filename);
        if (res) {
                owner->getMiniBuffer()->Set(_("Document"),
                                            MakeDisplayPath(filename),
@@ -3265,7 +3320,7 @@ void LyXFunc::MenuInsertLyXFile(string const & filen)
 
 void LyXFunc::reloadBuffer()
 {
-       string fn = owner->buffer()->fileName();
+       string const fn = owner->buffer()->fileName();
        if (bufferlist.close(owner->buffer()))
                owner->view()->buffer(bufferlist.loadLyXFile(fn));
 }
@@ -3279,8 +3334,7 @@ void LyXFunc::CloseBuffer()
                        // set variables that don't exist
                        // since there's no current buffer
                        owner->getDialogs()->hideBufferDependent();
-               }
-               else {
+               } else {
                        owner->view()->buffer(bufferlist.first());
                }
        }