X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyx_cb.C;h=a31535504570b11336175ca9f51cdcb5366cd4f2;hb=0c978e6a3fb133c97d95e87715add6bae26f7837;hp=003643240b140efcb5727fa13465126159d9bb41;hpb=4c295014fe141d56fcfd110473ab53c4e86e62d4;p=lyx.git diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 003643240b..a315355045 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -17,11 +17,10 @@ #include FORMS_H_LOCATION #include "lyx.h" #include "layout_forms.h" -#include "bullet_forms.h" -#include "form1.h" +//#include "form1.h" #include "lyx_main.h" #include "lyx_cb.h" -#include "insets/insetref.h" +//#include "insets/insetref.h" #include "insets/insetlabel.h" #include "insets/figinset.h" #include "lyxfunc.h" @@ -31,18 +30,19 @@ #include "filedlg.h" #include "lyx_gui_misc.h" #include "LyXView.h" -#include "BufferView.h" +//#include "BufferView.h" #include "lastfiles.h" #include "bufferview_funcs.h" #include "support/FileInfo.h" #include "support/syscall.h" #include "support/filetools.h" #include "support/path.h" -#include "lyxserver.h" +//#include "support/lyxlib.h" +//#include "lyxserver.h" #include "lyxrc.h" #include "lyxtext.h" -#include "CutAndPaste.h" -#include "exporter.h" +//#include "CutAndPaste.h" +//#include "exporter.h" using std::ifstream; using std::copy; @@ -61,23 +61,21 @@ extern Combox * combo_language2; extern BufferList bufferlist; extern void show_symbols_form(); extern FD_form_title * fd_form_title; -extern FD_form_paragraph * fd_form_paragraph; extern FD_form_character * fd_form_character; -extern FD_form_document * fd_form_document; -extern FD_form_quotes * fd_form_quotes; extern FD_form_preamble * fd_form_preamble; -extern FD_form_table * fd_form_table; extern FD_form_figure * fd_form_figure; -extern FD_form_bullet * fd_form_bullet; extern BufferView * current_view; // called too many times in this file... extern void DeleteSimpleCutBuffer(); /* for the cleanup when exiting */ +#if 0 extern bool send_fax(string const & fname, string const & sendcmd); +#endif + extern void MenuSendto(); -extern LyXServer * lyxserver; +//extern LyXServer * lyxserver; // this should be static, but I need it in buffer.C bool quitting; // flag, that we are quitting the program @@ -133,7 +131,7 @@ bool toggleall = true; otherwise 0 */ // Now they work only for updatable insets. [Alejandro 080596] //int LockInset(UpdatableInset * inset); -void ToggleLockedInsetCursor(long x, long y, int asc, int desc); +void ToggleLockedInsetCursor(int x, int y, int asc, int desc); //void FitLockedInsetCursor(long x, long y, int asc, int desc); //int UnlockInset(UpdatableInset * inset); //void LockedInsetStoreUndo(Undo::undo_kind kind); @@ -160,18 +158,16 @@ void MenuReload(Buffer * buf); void MenuLayoutSave(); -void ShowMessage(Buffer * buf, +void ShowMessage(Buffer const * buf, string const & msg1, string const & msg2, string const & msg3, int delay) { - if (lyxrc.use_gui) { + if (lyxrc.use_gui) buf->getUser()->owner()->getMiniBuffer()->Set(msg1, msg2, msg3, delay); - } else { - // can somebody think of something more clever? cerr? - cout << msg1 << msg2 << msg3 << endl; - } + else + lyxerr << msg1 << msg2 << msg3 << endl; } @@ -186,7 +182,7 @@ void ShowMessage(Buffer * buf, // should be moved to lyxfunc.C bool MenuWrite(Buffer * buffer) { - XFlush(fl_display); + XFlush(fl_get_display()); if (!buffer->save()) { string fname = buffer->fileName(); string s = MakeAbsPath(fname); @@ -222,29 +218,23 @@ bool MenuWriteAs(Buffer * buffer) if (!IsLyXFilename(fname)) fname += ".lyx"; - if (buffer->isUnnamed()) { - fname = fileDlg.Select(_("Enter Filename to Save Document as"), - "", - "*.lyx", - ""); - } else { - fname = fileDlg.Select(_("Enter Filename to Save Document as"), - OnlyPath(fname), - "*.lyx", - OnlyFilename(fname)); - } + fname = fileDlg.Select(_("Enter Filename to Save Document as"), + OnlyPath(fname), + "*.lyx", + OnlyFilename(fname)); + AllowInput(current_view); - if (fname.empty()) { + if (fname.empty()) return false; - } + // Make sure the absolute filename ends with appropriate suffix string s = MakeAbsPath(fname); if (!IsLyXFilename(s)) s += ".lyx"; // Same name as we have already? - if (s == oldname) { + if (!buffer->isUnnamed() && s == oldname) { if (!AskQuestion(_("Same name as document already has:"), MakeDisplayPath(s, 50), _("Save anyway?"))) @@ -252,7 +242,7 @@ bool MenuWriteAs(Buffer * buffer) // Falls through to name change and save } // No, but do we have another file with this name open? - else if (bufferlist.exists(s)) { + else if (!buffer->isUnnamed() && bufferlist.exists(s)) { if (AskQuestion(_("Another document with same name open!"), MakeDisplayPath(s, 50), _("Replace with current document?"))) @@ -260,7 +250,7 @@ bool MenuWriteAs(Buffer * buffer) bufferlist.close(bufferlist.getBuffer(s)); // Ok, change the name of the buffer, but don't save! - buffer->fileName(s); + buffer->setFileName(s); buffer->markDirty(); ShowMessage(buffer, _("Document renamed to '"), @@ -277,7 +267,7 @@ bool MenuWriteAs(Buffer * buffer) } // Ok, change the name of the buffer - buffer->fileName(s); + buffer->setFileName(s); buffer->markDirty(); bool unnamed = buffer->isUnnamed(); buffer->setUnnamed(false); @@ -286,7 +276,7 @@ bool MenuWriteAs(Buffer * buffer) // of the document. // Hope this is fixed this way! (Jug) if (!MenuWrite(buffer)) { - buffer->fileName(oldname); + buffer->setFileName(oldname); buffer->setUnnamed(unnamed); ShowMessage(buffer, _("Document could not be saved!"), _("Holding the old name."), MakeDisplayPath(oldname)); @@ -297,66 +287,6 @@ bool MenuWriteAs(Buffer * buffer) return true; } -#ifndef NEW_EXPORT -int MenuRunLaTeX(Buffer * buffer) -{ - int ret = 0; - - if (buffer->isLinuxDoc()) - ret = RunLinuxDoc(buffer->getUser(), 1, buffer->fileName()); - else if (buffer->isLiterate()) - ret = buffer->runLiterate(); - else if (buffer->isDocBook()) - ret = RunDocBook(1, buffer->fileName()); - else - ret = buffer->runLaTeX(); - - if (ret > 0) { - string s; - string t; - if (ret == 1) { - s = _("One error detected"); - t = _("You should try to fix it."); - } else { - s += tostr(ret); - s += _(" errors detected."); - t = _("You should try to fix them."); - } - WriteAlert(_("There were errors during the LaTeX run."), s, t); - } - return ret; -} -#endif - -int MenuBuildProg(Buffer * buffer) -{ - int ret = 0; - - if (buffer->isLiterate()) - ret = buffer->buildProgram(); - else { - string s = _("Wrong type of document"); - string t = _("The Build operation is not allowed in this document"); - WriteAlert(_("There were errors during the Build process."), s, t); - return 1; - } - - if (ret > 0) { - string s; - string t; - if (ret == 1) { - s = _("One error detected"); - t = _("You should try to fix it."); - } else { - s += tostr(ret); - s += _(" errors detected."); - t = _("You should try to fix them."); - } - WriteAlert(_("There were errors during the Build process."), s, t); - } - return ret; -} - int MenuRunChktex(Buffer * buffer) { @@ -388,245 +318,17 @@ int MenuRunChktex(Buffer * buffer) return ret; } -#ifndef NEW_EXPORT -int MakeLaTeXOutput(Buffer * buffer) -{ - // Who cares? - //if (!bv->text) - // return 1; - int ret = 0; - string path = OnlyPath(buffer->fileName()); - if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) { - path = buffer->tmppath; - } - - Path p(path); - ret = MenuRunLaTeX(buffer); - - return ret; -} - - -/* wait == false means don't wait for termination */ -/* wait == true means wait for termination */ -// The bool should be placed last on the argument line. (Lgb) -// Returns false if we fail. -bool RunScript(Buffer * buffer, bool wait, - string const & command, - string const & orgname = string(), - bool need_shell = true) -{ - string path; - string cmd; - string name = orgname; - int result = 0; - - if (MakeLaTeXOutput(buffer) > 0) - return false; - /* get DVI-Filename */ - if (name.empty()) - name = ChangeExtension(buffer->getLatexName(), ".dvi"); - - path = OnlyPath(name); - if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) { - path = buffer->tmppath; - } - Path p(path); - // At this point we check whether the command contains the - // filename parameter $$FName and if that's the case we - // substitute the real file name otherwise the filename is - // simply appended. rokrau 1/12/00 - cmd = command; - string::size_type i; - if ( (i=command.find("$$FName")) != string::npos) - { - cmd.replace(i,7,QuoteName(name)); - } - else - cmd = command + ' ' + QuoteName(name); - - Systemcalls one; - - if (need_shell) { -#ifndef __EMX__ - if (!wait) - cmd += " &"; -#else - // OS/2 cmd.exe has another use for '&' - if (!wait) { - // This is not NLS safe, but it's OK, I think. - string sh = OnlyFilename(GetEnvPath("EMXSHELL")); - if (sh.empty()) { - // COMSPEC is set, unless user unsets - sh = OnlyFilename(GetEnvPath("COMSPEC")); - if (sh.empty()) - sh = "cmd.exe"; - } - sh = lowercase(sh); - if (contains(sh, "cmd.exe") - || contains(sh, "4os2.exe")) - cmd = "start /min/n " + cmd; - else - cmd += " &"; - } -#endif - // It seems that, if wait is false, we never get back - // the return code of the command. This means that all - // the code I added in PrintApplyCB is currently - // useless... - // CHECK What should we do here? - ShowMessage(buffer, _("Executing command:"), cmd); - result = one.startscript(Systemcalls::System, cmd); - } else { - ShowMessage(buffer, _("Executing command:"), cmd); - result = one.startscript(wait ? Systemcalls::Wait - : Systemcalls::DontWait, cmd); - } - return result == 0; -} - - -// Returns false if we fail -bool CreatePostscript(Buffer * buffer, bool wait = false) -{ - // Who cares? - //if (!bv->text) - // return false; - - ProhibitInput(current_view); - - // Generate dvi file - if (MakeLaTeXOutput(buffer) > 0) { - AllowInput(current_view); - return false; - } - // Generate postscript file - string psname = OnlyFilename(ChangeExtension (buffer->fileName(), - ".ps_tmp")); - - string paper; - - // Wrong type - char real_papersize = buffer->params.papersize; - if (real_papersize == BufferParams::PAPER_DEFAULT) - real_papersize = lyxrc.default_papersize; - - switch (real_papersize) { - case BufferParams::PAPER_USLETTER: - paper = "letter"; - break; - case BufferParams::PAPER_A3PAPER: - paper = "a3"; - break; - case BufferParams::PAPER_A4PAPER: - paper = "a4"; - break; - case BufferParams::PAPER_A5PAPER: - paper = "a5"; - break; - case BufferParams::PAPER_B5PAPER: - paper = "b5"; - break; - case BufferParams::PAPER_EXECUTIVEPAPER: - paper = "foolscap"; - break; - case BufferParams::PAPER_LEGALPAPER: - paper = "legal"; - break; - default: /* If nothing else fits, keep an empty value... */ - break; - } - - // Make postscript file. - string command = lyxrc.dvi_to_ps_command + ' ' + lyxrc.print_to_file + ' '; - command += QuoteName(psname); - if (buffer->params.use_geometry - && buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM - && !lyxrc.print_paper_dimension_flag.empty() - && !buffer->params.paperwidth.empty() - && !buffer->params.paperheight.empty()) { - // using a custom papersize - command += ' '; - command += lyxrc.print_paper_dimension_flag + ' '; - command += buffer->params.paperwidth + ','; - command += buffer->params.paperheight; - } else if (!paper.empty() - && (real_papersize != BufferParams::PAPER_USLETTER || - buffer->params.orientation == BufferParams::ORIENTATION_PORTRAIT)) { - // dvips won't accept -t letter -t landscape. In all other - // cases, include the paper size explicitly. - command += ' '; - command += lyxrc.print_paper_flag + ' ' + paper; - } - if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE) { - command += ' '; - command += lyxrc.print_landscape_flag; - } - // push directorypath, if necessary - string path = OnlyPath(buffer->fileName()); - if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){ - path = buffer->tmppath; - } - Path p(path); - bool ret = RunScript(buffer, wait, command); - AllowInput(current_view); - return ret; -} - - -// Returns false if we fail -//bool MenuPreviewPS(Buffer * buffer) -bool PreviewPostscript(Buffer * buffer) -{ - // Who cares? - //if (!bv->text) - // return false; - - // Generate postscript file - if (!CreatePostscript(buffer, true)) { - return false; - } - - // Start postscript viewer - ProhibitInput(current_view); - string ps = OnlyFilename(ChangeExtension (buffer->fileName(), - ".ps_tmp")); - // push directorypath, if necessary - string path = OnlyPath(buffer->fileName()); - if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){ - path = buffer->tmppath; - } - Path p(path); - bool ret = RunScript(buffer, false, lyxrc.view_ps_command, ps); - AllowInput(current_view); - return ret; -} -#endif - +#if 0 void MenuFax(Buffer * buffer) { - // Who cares? - //if (!bv->text) - // return; - -#ifdef NEW_EXPORT // Generate postscript file if (!Exporter::Export(buffer, "ps", true)) return; // Send fax - string ps = OnlyFilename(ChangeExtension (buffer->fileName(), - ".ps")); -#else - // Generate postscript file - if (!CreatePostscript(buffer, true)) { - return; - } + string const ps = OnlyFilename(ChangeExtension(buffer->fileName(), + ".ps")); - // Send fax - string ps = OnlyFilename(ChangeExtension (buffer->fileName(), - ".ps_tmp")); -#endif string path = OnlyPath (buffer->fileName()); if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) { path = buffer->tmppath; @@ -639,330 +341,6 @@ void MenuFax(Buffer * buffer) } else send_fax(ps, lyxrc.fax_command); } - - -#ifndef NEW_EXPORT -// Returns false if we fail -bool PreviewDVI(Buffer * buffer) -{ - // Who cares? - //if (!bv->text) - // return false; - - string paper = lyxrc.view_dvi_paper_option; - if (!paper.empty()) { - // wrong type - char real_papersize = buffer->params.papersize; - if (real_papersize == BufferParams::PAPER_DEFAULT) - real_papersize = lyxrc.default_papersize; - - switch (real_papersize) { - case BufferParams::PAPER_USLETTER: - paper += " us"; - break; - case BufferParams::PAPER_A3PAPER: - paper += " a3"; - break; - case BufferParams::PAPER_A4PAPER: - paper += " a4"; - break; - case BufferParams::PAPER_A5PAPER: - paper += " a5"; - break; - case BufferParams::PAPER_B5PAPER: - paper += " b5"; - break; - case BufferParams::PAPER_EXECUTIVEPAPER: - paper += " foolscap"; - break; - case BufferParams::PAPER_LEGALPAPER: - paper += " legal"; - break; - default: /* If nothing else fits, keep the empty value */ - break; - } - if (real_papersize==' ') { - // if (paper.empty()) { - if (buffer->params.orientation - == BufferParams::ORIENTATION_LANDSCAPE) - // we HAVE to give a size when the page is in - // landscape, so use USletter. - paper = " -paper usr"; - } else { - // paper = " -paper " + paper; - if (buffer->params.orientation - == BufferParams::ORIENTATION_LANDSCAPE) - paper+= 'r'; - } - } - // push directorypath, if necessary - string path = OnlyPath(buffer->fileName()); - if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) { - path = buffer->tmppath; - } - Path p(path); - // Run dvi-viewer - string command = lyxrc.view_dvi_command + " " + paper; - bool ret = RunScript(buffer, false, command); - return ret; -} - - -bool AskOverwrite(Buffer * buffer, string const & s) -{ - if (lyxrc.use_gui) { - // be friendly if there is a gui - FileInfo fi(s); - if (fi.readable() && - !AskQuestion(_("File already exists:"), - MakeDisplayPath(s, 50), - _("Do you want to overwrite the file?"))) { - ShowMessage(buffer, _("Canceled")); - return false; - } - } - return true; -} - - -void MenuMakeLaTeX(Buffer * buffer) -{ - // Why care about this? - //if (!bv->text) - // return; - - // Get LaTeX-Filename - string s = buffer->getLatexName(false); - - if (!AskOverwrite(buffer, s)) - return; - - if (buffer->isDocBook()) - ShowMessage(buffer, _("DocBook does not have a latex backend")); - else { - if (buffer->isLinuxDoc()) - RunLinuxDoc(buffer->getUser(), 0, buffer->fileName()); - else - buffer->makeLaTeXFile(s, string(), true); - ShowMessage(buffer, _("Nice LaTeX file saved as"), - MakeDisplayPath(s)); - } -} - - -void MenuMakeLinuxDoc(Buffer * buffer) -{ - // Who cares? - //if (!bv->text) return; - - if (!buffer->isLinuxDoc()) { - WriteAlert(_("Error!"), _("Document class must be linuxdoc.")); - return; - } - - // Get LinuxDoc-Filename - string s = ChangeExtension(buffer->fileName(), ".sgml"); - - if (!AskOverwrite(buffer, s)) - return; - - ShowMessage(buffer, _("Building LinuxDoc SGML file `"), - MakeDisplayPath(s),"'..."); - - buffer->makeLinuxDocFile(s, true); - buffer->redraw(); - ShowMessage(buffer, _("LinuxDoc SGML file save as"), - MakeDisplayPath(s)); -} - - -void MenuMakeDocBook(Buffer * buffer) -{ - // Who cares? - //if (!bv->text) return; - - if (!buffer->isDocBook()) { - WriteAlert(_("Error!"), - _("Document class must be docbook.")); - return; - } - - // Get DocBook-Filename - string s = ChangeExtension(buffer->fileName(), ".sgml"); - - if (!AskOverwrite(buffer, s)) - return; - - ShowMessage(buffer, _("Building DocBook SGML file `"), - MakeDisplayPath(s), "'..."); - - buffer->makeDocBookFile(s, true); - buffer->redraw(); - ShowMessage(buffer, _("DocBook SGML file save as"), - MakeDisplayPath(s)); -} - - -void MenuMakeAscii(Buffer * buffer) -{ - // Who cares? - //if (!bv->text) return; - - /* get LaTeX-Filename */ - string s = ChangeExtension (buffer->fileName(), ".txt"); - - - if (!AskOverwrite(buffer, s)) - return; - - buffer->writeFileAscii(s, lyxrc.ascii_linelen); - - ShowMessage(buffer, _("Ascii file saved as"), MakeDisplayPath(s)); -} - - -void MenuMakeHTML(Buffer * buffer) -{ - // First, create LaTeX file - MenuMakeLaTeX(buffer); - - // And now, run the converter - string file = buffer->fileName(); - Path path(OnlyPath(file)); - // the tex file name has to be correct for - // latex, but the html file name can be - // anything. - string result = ChangeExtension(file, ".html"); - string infile = buffer->getLatexName(false); - string tmp = lyxrc.html_command; - tmp = subst(tmp, "$$FName", infile); - tmp = subst(tmp, "$$OutName", result); - Systemcalls one; - int res = one.startscript(Systemcalls::System, tmp); - if (res == 0) { - ShowMessage(buffer, _("Document exported as HTML to file `") - + MakeDisplayPath(result) +'\''); - } else { - ShowMessage(buffer, _("Unable to convert to HTML the file `") - + MakeDisplayPath(infile) - + '\''); - } - -} - - -void MenuMakeHTML_LinuxDoc(Buffer * buffer) -{ - // First, create LinuxDoc file - MenuMakeLinuxDoc(buffer); - - // And now, run the converter - string file = buffer->fileName(); - - string result = ChangeExtension(file, ".html"); - string infile = ChangeExtension(file, ".sgml"); - string tmp = lyxrc.linuxdoc_to_html_command; - tmp = subst(tmp, "$$FName", infile); - tmp = subst(tmp, "$$OutName", result); - Systemcalls one; - int res = one.startscript(Systemcalls::System, tmp); - if (res == 0) { - ShowMessage(buffer,_("Document exported as HTML to file `") - + MakeDisplayPath(result) +'\''); - } else { - ShowMessage(buffer,_("Unable to convert to HTML the file `") - + MakeDisplayPath(infile) - + '\''); - } - -} - -void MenuMakeHTML_DocBook(Buffer * buffer) -{ - // First, create LaTeX file - MenuMakeDocBook(buffer); - - // And now, run the converter - string file = buffer->fileName(); - string result = ChangeExtension(file, ".html"); - string infile = ChangeExtension(file, ".sgml"); - string tmp = lyxrc.docbook_to_html_command; - tmp = subst(tmp, "$$FName", infile); - tmp = subst(tmp, "$$OutName", result); - Systemcalls one; - int res = one.startscript(Systemcalls::System, tmp); - if (res == 0) { - ShowMessage(buffer,_("Document exported as HTML to file `") - + MakeDisplayPath(result) +'\''); - } else { - ShowMessage(buffer,_("Unable to convert to HTML the file `") - + MakeDisplayPath(infile) - + '\''); - } - -} - - -void MenuExport(Buffer * buffer, string const & extyp) -{ - // latex - if (extyp == "latex") { - // make sure that this buffer is not linuxdoc - MenuMakeLaTeX(buffer); - } - // linuxdoc - else if (extyp == "linuxdoc") { - // make sure that this buffer is not latex - MenuMakeLinuxDoc(buffer); - } - // docbook - else if (extyp == "docbook") { - // make sure that this buffer is not latex or linuxdoc - MenuMakeDocBook(buffer); - } - // dvi - else if (extyp == "dvi") { - // Run LaTeX as "Update dvi..." Bernhard. - // We want the dvi in the current directory. This - // is achieved by temporarily disabling use of - // temp directory. As a side-effect, we get - // *.log and *.aux files also. (Asger) - bool flag = lyxrc.use_tempdir; - lyxrc.use_tempdir = false; - MenuRunLaTeX(buffer); - lyxrc.use_tempdir = flag; - } - // postscript - else if (extyp == "postscript") { - // Start Print-dialog. Not as good as dvi... Bernhard. - //should start lyxview->getDialogs()->showPrint(); - // to get same as before - // MenuPrint(buffer); - // Since the MenuPrint is a pop-up, we can't use - // the same trick as above. (Asger) - // MISSING: Move of ps-file :-( - // And MenuPrint should not be used for this at all... - } - // ascii - else if (extyp == "ascii") { - MenuMakeAscii(buffer); - } - else if (extyp == "custom") { - MenuSendto(); - } - // HTML - else if (extyp == "html") { - if (buffer->isLinuxDoc()) - MenuMakeHTML_LinuxDoc(buffer); - else if (buffer->isDocBook()) - MenuMakeHTML_DocBook(buffer); - else - MenuMakeHTML(buffer); - } - else { - ShowMessage(buffer, _("Unknown export type: ") + extyp); - } -} #endif @@ -1015,8 +393,6 @@ void AutoSave(BufferView * bv) // tmp_ret will be located (usually) in /tmp // will that be a problem? - string tmp_ret = tmpnam(0); - pid_t pid = fork(); // If you want to debug the autosave // you should set pid to -1, and comment out the // fork. @@ -1025,15 +401,17 @@ void AutoSave(BufferView * bv) // to fork. But we will do the save // anyway. bool failed = false; + + string tmp_ret = lyx::tempName(); if (!tmp_ret.empty()) { bv->buffer()->writeFile(tmp_ret, 1); // assume successful write of tmp_ret - if (rename(tmp_ret.c_str(), fname.c_str()) == -1) { + if (lyx::rename(tmp_ret, fname)) { failed = true; // most likely couldn't move between filesystems // unless write of tmp_ret failed // so remove tmp file (if it exists) - remove(tmp_ret.c_str()); + lyx::unlink(tmp_ret); } } else { failed = true; @@ -1140,7 +518,7 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph) copy(ii, end, back_inserter(tmpstr)); #endif // insert the string - current_view->hideCursor(); + bv->hideCursor(); // clear the selection bv->beforeChange(); @@ -1172,710 +550,36 @@ void MenuInsertLabel(string const & arg) } -// candidate for move to LyXView -// This is only used in toolbar.C +// This is _only_ used in Toolbar_pimpl.C, move it there and get rid of +// current_view. (Lgb) void LayoutsCB(int sel, void *, Combox *) { string tmp = tostr(sel); current_view->owner()->getLyXFunc()->Dispatch(LFUN_LAYOUTNO, - tmp.c_str()); + tmp); } -#ifndef NEW_EXPORT -/* - * SGML Linuxdoc support: - * (flag == 0) make TeX output - * (flag == 1) make dvi output - */ -int RunLinuxDoc(BufferView * bv, int flag, string const & filename) -{ - string s2; - string add_flags; - - int errorcode = 0; - - /* generate a path-less extension name */ - string name = OnlyFilename(ChangeExtension (filename, ".sgml")); - string path = OnlyPath (filename); - if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) { - path = bv->buffer()->tmppath; - } - Path p(path); - - if (!bv->available()) - return 0; - bv->buffer()->makeLinuxDocFile(name, false); - // CHECK remove this once we have a proper geometry class +void MenuLayoutCharacter() +{ + static int ow = -1, oh; - BufferParams::PAPER_SIZE ps = - static_cast(bv->buffer()->params.papersize); - switch (ps) { - case BufferParams::PAPER_A4PAPER: - add_flags = "-p a4"; - break; - case BufferParams::PAPER_USLETTER: - add_flags = "-p letter"; - break; - default: /* nothing to be done yet ;-) */ break; - } - - ProhibitInput(bv); - - Systemcalls one; - switch (flag) { - case 0: /* TeX output asked */ - bv->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to TeX file...")); - s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o tex " + ' ' + name; - if (one.startscript(Systemcalls::System, s2)) - errorcode = 1; - break; - case 1: /* dvi output asked */ - bv->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to dvi file...")); - s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o dvi " + ' ' + name; - if (one.startscript(Systemcalls::System, s2)) { - errorcode = 1; - } - break; - default: /* unknown output */ - break; + if (fd_form_character->form_character->visible) { + fl_raise_form(fd_form_character->form_character); + } else { + fl_show_form(fd_form_character->form_character, + FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT, + _("Character Style")); + if (ow < 0) { + ow = fd_form_character->form_character->w; + oh = fd_form_character->form_character->h; + } + fl_set_form_minsize(fd_form_character->form_character, ow, oh); } - - AllowInput(bv); - - bv->buffer()->redraw(); - return errorcode; } -/* - * SGML DocBook support: - * (flag == 1) make dvi output - */ -int RunDocBook(int flag, string const & filename) -{ - /* generate a path-less extension name */ - string name = OnlyFilename(ChangeExtension (filename, ".sgml")); - string path = OnlyPath (filename); - if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) { - path = current_view->buffer()->tmppath; - } - Path p(path); - - if (!current_view->available()) - return 0; - - current_view->buffer()->makeDocBookFile(name, false); - - // Shall this code go or should it stay? (Lgb) - // This code is a placeholder for future implementation. (Jose') -// string add_flags; -// LYX_PAPER_SIZE ps = (LYX_PAPER_SIZE) current_view->buffer()->params.papersize; -// switch (ps) { -// case BufferParams::PAPER_A4PAPER: add_flags = "-p a4"; break; -// case BufferParams::PAPER_USLETTER: add_flags = "-p letter"; break; -// default: /* nothing to be done yet ;-) */ break; -// } - ProhibitInput(current_view); - - int errorcode = 0; - Systemcalls one; - switch (flag) { - case 1: /* dvi output asked */ - { - current_view->owner()->getMiniBuffer()->Set(_("Converting DocBook SGML to dvi file...")); - string s2 = lyxrc.docbook_to_dvi_command + ' ' + name; - if (one.startscript(Systemcalls::System, s2)) { - errorcode = 1; - } - } - break; - default: /* unknown output */ - break; - } - - AllowInput(current_view); - - current_view->buffer()->redraw(); - return errorcode; -} -#endif - -void MenuLayoutCharacter() -{ - static int ow = -1, oh; - - if (fd_form_character->form_character->visible) { - fl_raise_form(fd_form_character->form_character); - } else { - fl_show_form(fd_form_character->form_character, - FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER, - _("Character Style")); - if (ow < 0) { - ow = fd_form_character->form_character->w; - oh = fd_form_character->form_character->h; - } - fl_set_form_minsize(fd_form_character->form_character, ow, oh); - } -} - - -static inline -void DeactivateParagraphButtons () -{ - fl_deactivate_object (fd_form_paragraph->button_ok); - fl_deactivate_object (fd_form_paragraph->button_apply); - fl_set_object_lcol (fd_form_paragraph->button_ok, FL_INACTIVE); - fl_set_object_lcol (fd_form_paragraph->button_apply, FL_INACTIVE); -} - - -static inline -void ActivateParagraphButtons () -{ - fl_activate_object (fd_form_paragraph->button_ok); - fl_activate_object (fd_form_paragraph->button_apply); - fl_set_object_lcol (fd_form_paragraph->button_ok, FL_BLACK); - fl_set_object_lcol (fd_form_paragraph->button_apply, FL_BLACK); -} - - -static inline -void DisableParagraphLayout () -{ - DeactivateParagraphButtons(); - fl_deactivate_object (fd_form_paragraph->input_labelwidth); - fl_deactivate_object (fd_form_paragraph->check_lines_top); - fl_deactivate_object (fd_form_paragraph->check_lines_bottom); - fl_deactivate_object (fd_form_paragraph->check_pagebreaks_top); - fl_deactivate_object (fd_form_paragraph->check_pagebreaks_bottom); - fl_deactivate_object (fd_form_paragraph->check_noindent); - fl_deactivate_object (fd_form_paragraph->group_radio_alignment); - fl_deactivate_object (fd_form_paragraph->radio_align_right); - fl_deactivate_object (fd_form_paragraph->radio_align_left); - fl_deactivate_object (fd_form_paragraph->radio_align_block); - fl_deactivate_object (fd_form_paragraph->radio_align_center); - fl_deactivate_object (fd_form_paragraph->input_space_above); - fl_deactivate_object (fd_form_paragraph->input_space_below); - fl_deactivate_object (fd_form_paragraph->choice_space_above); - fl_deactivate_object (fd_form_paragraph->choice_space_below); - fl_deactivate_object (fd_form_paragraph->check_space_above); - fl_deactivate_object (fd_form_paragraph->check_space_below); -} - - -static inline -void EnableParagraphLayout () -{ - ActivateParagraphButtons(); - fl_activate_object (fd_form_paragraph->input_labelwidth); - fl_activate_object (fd_form_paragraph->check_lines_top); - fl_activate_object (fd_form_paragraph->check_lines_bottom); - fl_activate_object (fd_form_paragraph->check_pagebreaks_top); - fl_activate_object (fd_form_paragraph->check_pagebreaks_bottom); - fl_activate_object (fd_form_paragraph->check_noindent); - fl_activate_object (fd_form_paragraph->group_radio_alignment); - fl_activate_object (fd_form_paragraph->radio_align_right); - fl_activate_object (fd_form_paragraph->radio_align_left); - fl_activate_object (fd_form_paragraph->radio_align_block); - fl_activate_object (fd_form_paragraph->radio_align_center); - fl_activate_object (fd_form_paragraph->input_space_above); - fl_activate_object (fd_form_paragraph->input_space_below); - fl_activate_object (fd_form_paragraph->choice_space_above); - fl_activate_object (fd_form_paragraph->choice_space_below); - fl_activate_object (fd_form_paragraph->check_space_above); - fl_activate_object (fd_form_paragraph->check_space_below); -} - - -bool UpdateLayoutParagraph() -{ - if (!current_view->available()) { - if (fd_form_paragraph->form_paragraph->visible) - fl_hide_form(fd_form_paragraph->form_paragraph); - return false; - } - - Buffer * buf = current_view->buffer(); - LyXText * text = 0; - if (current_view->the_locking_inset) - text = current_view->the_locking_inset->getLyXText(current_view); - if (!text) - text = current_view->text; - - fl_set_input(fd_form_paragraph->input_labelwidth, - text->cursor.par()->GetLabelWidthString().c_str()); - fl_set_button(fd_form_paragraph->radio_align_right, 0); - fl_set_button(fd_form_paragraph->radio_align_left, 0); - fl_set_button(fd_form_paragraph->radio_align_center, 0); - fl_set_button(fd_form_paragraph->radio_align_block, 0); - - int align = text->cursor.par()->GetAlign(); - if (align == LYX_ALIGN_LAYOUT) - align = textclasslist.Style(buf->params.textclass, - text->cursor.par()->GetLayout()).align; - - switch (align) { - case LYX_ALIGN_RIGHT: - fl_set_button(fd_form_paragraph->radio_align_right, 1); - break; - case LYX_ALIGN_LEFT: - fl_set_button(fd_form_paragraph->radio_align_left, 1); - break; - case LYX_ALIGN_CENTER: - fl_set_button(fd_form_paragraph->radio_align_center, 1); - break; - default: - fl_set_button(fd_form_paragraph->radio_align_block, 1); - break; - } - -#ifndef NEW_INSETS - fl_set_button(fd_form_paragraph->check_lines_top, - text->cursor.par()->FirstPhysicalPar()->line_top); - - fl_set_button(fd_form_paragraph->check_lines_bottom, - text->cursor.par()->FirstPhysicalPar()->line_bottom); - - fl_set_button(fd_form_paragraph->check_pagebreaks_top, - text->cursor.par()->FirstPhysicalPar()->pagebreak_top); - - fl_set_button(fd_form_paragraph->check_pagebreaks_bottom, - text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom); - fl_set_button(fd_form_paragraph->check_noindent, - text->cursor.par()->FirstPhysicalPar()->noindent); -#else - fl_set_button(fd_form_paragraph->check_lines_top, - text->cursor.par()->line_top); - fl_set_button(fd_form_paragraph->check_lines_bottom, - text->cursor.par()->line_bottom); - fl_set_button(fd_form_paragraph->check_pagebreaks_top, - text->cursor.par()->pagebreak_top); - fl_set_button(fd_form_paragraph->check_pagebreaks_bottom, - text->cursor.par()->pagebreak_bottom); - fl_set_button(fd_form_paragraph->check_noindent, - text->cursor.par()->noindent); -#endif - fl_set_input (fd_form_paragraph->input_space_above, ""); - -#ifndef NEW_INSETS - switch (text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) { -#else - switch (text->cursor.par()->added_space_top.kind()) { -#endif - - case VSpace::NONE: - fl_set_choice (fd_form_paragraph->choice_space_above, 1); - break; - case VSpace::DEFSKIP: - fl_set_choice (fd_form_paragraph->choice_space_above, 2); - break; - case VSpace::SMALLSKIP: - fl_set_choice (fd_form_paragraph->choice_space_above, 3); - break; - case VSpace::MEDSKIP: - fl_set_choice (fd_form_paragraph->choice_space_above, 4); - break; - case VSpace::BIGSKIP: - fl_set_choice (fd_form_paragraph->choice_space_above, 5); - break; - case VSpace::VFILL: - fl_set_choice (fd_form_paragraph->choice_space_above, 6); - break; - case VSpace::LENGTH: - fl_set_choice (fd_form_paragraph->choice_space_above, 7); -#ifndef NEW_INSETS - fl_set_input (fd_form_paragraph->input_space_above, - text->cursor.par()->FirstPhysicalPar()->added_space_top.length().asString().c_str()); -#else - fl_set_input (fd_form_paragraph->input_space_above, - text->cursor.par()->added_space_top.length().asString().c_str()); -#endif - break; - } -#ifndef NEW_INSETS - fl_set_button (fd_form_paragraph->check_space_above, - text->cursor.par()->FirstPhysicalPar()->added_space_top.keep()); - fl_set_input (fd_form_paragraph->input_space_below, ""); - switch (text->cursor.par()->FirstPhysicalPar()->added_space_bottom.kind()) { -#else - fl_set_button (fd_form_paragraph->check_space_above, - text->cursor.par()->added_space_top.keep()); - fl_set_input (fd_form_paragraph->input_space_below, ""); - switch (text->cursor.par()->added_space_bottom.kind()) { -#endif - case VSpace::NONE: - fl_set_choice (fd_form_paragraph->choice_space_below, - 1); - break; - case VSpace::DEFSKIP: - fl_set_choice (fd_form_paragraph->choice_space_below, - 2); - break; - case VSpace::SMALLSKIP: - fl_set_choice (fd_form_paragraph->choice_space_below, - 3); - break; - case VSpace::MEDSKIP: - fl_set_choice (fd_form_paragraph->choice_space_below, - 4); - break; - case VSpace::BIGSKIP: - fl_set_choice (fd_form_paragraph->choice_space_below, - 5); - break; - case VSpace::VFILL: - fl_set_choice (fd_form_paragraph->choice_space_below, - 6); - break; - case VSpace::LENGTH: - fl_set_choice (fd_form_paragraph->choice_space_below, - 7); -#ifndef NEW_INSETS - fl_set_input (fd_form_paragraph->input_space_below, - text->cursor.par()->FirstPhysicalPar()->added_space_bottom.length().asString().c_str()); - break; - } - fl_set_button (fd_form_paragraph->check_space_below, - text->cursor.par()->FirstPhysicalPar()->added_space_bottom.keep()); - - fl_set_button(fd_form_paragraph->check_noindent, - text->cursor.par()->FirstPhysicalPar()->noindent); -#else - fl_set_input (fd_form_paragraph->input_space_below, - text->cursor.par()->added_space_bottom.length().asString().c_str()); - break; - } - fl_set_button (fd_form_paragraph->check_space_below, - text->cursor.par()->added_space_bottom.keep()); - - fl_set_button(fd_form_paragraph->check_noindent, - text->cursor.par()->noindent); -#endif - if (current_view->buffer()->isReadonly()) { - DisableParagraphLayout(); - } else { - EnableParagraphLayout(); - } - return true; -} - - -void MenuLayoutParagraph() -{ - if (UpdateLayoutParagraph()) { - if (fd_form_paragraph->form_paragraph->visible) { - fl_raise_form(fd_form_paragraph->form_paragraph); - } else { - fl_show_form(fd_form_paragraph->form_paragraph, - FL_PLACE_MOUSE, FL_FULLBORDER, - _("Paragraph Environment")); - } - } -} - -#ifdef USE_OLD_DOCUMENT_LAYOUT -static inline -void DeactivateDocumentButtons () -{ - fl_deactivate_object (fd_form_document->button_ok); - fl_deactivate_object (fd_form_document->button_apply); - fl_set_object_lcol (fd_form_document->button_ok, FL_INACTIVE); - fl_set_object_lcol (fd_form_document->button_apply, FL_INACTIVE); -} - - -static inline -void ActivateDocumentButtons () -{ - fl_activate_object (fd_form_document->button_ok); - fl_activate_object (fd_form_document->button_apply); - fl_set_object_lcol (fd_form_document->button_ok, FL_BLACK); - fl_set_object_lcol (fd_form_document->button_apply, FL_BLACK); -} - - -static inline -void DisableDocumentLayout () -{ - DeactivateDocumentButtons (); - fl_deactivate_object (fd_form_document->group_radio_separation); - fl_deactivate_object (fd_form_document->radio_indent); - fl_deactivate_object (fd_form_document->radio_skip); - fl_deactivate_object (fd_form_document->choice_class); - fl_deactivate_object (fd_form_document->choice_pagestyle); - fl_deactivate_object (fd_form_document->choice_fonts); - fl_deactivate_object (fd_form_document->choice_fontsize); - fl_deactivate_object (fd_form_document->input_float_placement); - fl_deactivate_object (fd_form_document->choice_postscript_driver); - fl_deactivate_object (fd_form_document->choice_inputenc); - fl_deactivate_object (fd_form_document->group_radio_sides); - fl_deactivate_object (fd_form_document->radio_sides_one); - fl_deactivate_object (fd_form_document->radio_sides_two); - fl_deactivate_object (fd_form_document->group_radio_columns); - fl_deactivate_object (fd_form_document->radio_columns_one); - fl_deactivate_object (fd_form_document->radio_columns_two); - fl_deactivate_object (fd_form_document->input_extra); - fl_deactivate_object (fd_form_document->choice_language); - combo_language->deactivate(); - fl_deactivate_object (fd_form_document->input_default_skip); - fl_deactivate_object (fd_form_document->choice_default_skip); - fl_deactivate_object (fd_form_document->slider_secnumdepth); - fl_deactivate_object (fd_form_document->slider_tocdepth); - fl_deactivate_object (fd_form_document->choice_spacing); - fl_deactivate_object (fd_form_document->input_spacing); - fl_deactivate_object (fd_form_document->check_use_amsmath); -} - - -static inline -void EnableDocumentLayout () -{ - ActivateDocumentButtons (); - fl_activate_object (fd_form_document->group_radio_separation); - fl_activate_object (fd_form_document->radio_indent); - fl_activate_object (fd_form_document->radio_skip); - fl_activate_object (fd_form_document->choice_class); - fl_activate_object (fd_form_document->choice_pagestyle); - fl_activate_object (fd_form_document->choice_fonts); - fl_activate_object (fd_form_document->choice_fontsize); - fl_activate_object (fd_form_document->input_float_placement); - fl_activate_object (fd_form_document->choice_postscript_driver); - fl_activate_object (fd_form_document->choice_inputenc); - fl_activate_object (fd_form_document->group_radio_sides); - fl_activate_object (fd_form_document->radio_sides_one); - fl_activate_object (fd_form_document->radio_sides_two); - fl_activate_object (fd_form_document->group_radio_columns); - fl_activate_object (fd_form_document->radio_columns_one); - fl_activate_object (fd_form_document->radio_columns_two); - fl_activate_object (fd_form_document->input_extra); - fl_activate_object (fd_form_document->choice_language); - combo_language->activate(); - fl_activate_object (fd_form_document->input_default_skip); - fl_activate_object (fd_form_document->choice_default_skip); - fl_activate_object (fd_form_document->slider_secnumdepth); - fl_activate_object (fd_form_document->slider_tocdepth); - fl_activate_object (fd_form_document->choice_spacing); - fl_activate_object (fd_form_document->input_spacing); - fl_activate_object (fd_form_document->check_use_amsmath); -} - - -bool UpdateLayoutDocument(BufferParams * params) -{ - if (!current_view->available()) { - if (fd_form_document->form_document->visible) - fl_hide_form(fd_form_document->form_document); - return false; - } - - if (params == 0) - params = ¤t_view->buffer()->params; - LyXTextClass const & tclass = textclasslist.TextClass(params->textclass); - - fl_set_choice_text(fd_form_document->choice_class, - textclasslist.DescOfClass(params->textclass).c_str()); - combo_language->select_text(params->language.c_str()); - - fl_set_choice_text(fd_form_document->choice_fonts, - params->fonts.c_str()); - fl_set_choice_text(fd_form_document->choice_inputenc, - params->inputenc.c_str()); - fl_set_choice_text(fd_form_document->choice_postscript_driver, - params->graphicsDriver.c_str()); - - // ale970405+lasgoutt970513 - fl_clear_choice(fd_form_document->choice_fontsize); - fl_addto_choice(fd_form_document->choice_fontsize, "default"); - fl_addto_choice(fd_form_document->choice_fontsize, - tclass.opt_fontsize().c_str()); - fl_set_choice(fd_form_document->choice_fontsize, - tokenPos(tclass.opt_fontsize(), '|', params->fontsize) + 2); - - // ale970405+lasgoutt970513 - fl_clear_choice(fd_form_document->choice_pagestyle); - fl_addto_choice(fd_form_document->choice_pagestyle, "default"); - fl_addto_choice(fd_form_document->choice_pagestyle, - tclass.opt_pagestyle().c_str()); - - fl_set_choice(fd_form_document->choice_pagestyle, - tokenPos(tclass.opt_pagestyle(), '|', params->pagestyle) + 2); - - fl_set_button(fd_form_document->radio_indent, 0); - fl_set_button(fd_form_document->radio_skip, 0); - - - fl_set_button(fd_form_document->check_use_amsmath, params->use_amsmath); - - if (params->paragraph_separation == BufferParams::PARSEP_INDENT) - fl_set_button(fd_form_document->radio_indent, 1); - else - fl_set_button(fd_form_document->radio_skip, 1); - - switch (params->getDefSkip().kind()) { - case VSpace::SMALLSKIP: - fl_set_choice (fd_form_document->choice_default_skip, 1); - break; - case VSpace::MEDSKIP: - fl_set_choice (fd_form_document->choice_default_skip, 2); - break; - case VSpace::BIGSKIP: - fl_set_choice (fd_form_document->choice_default_skip, 3); - break; - case VSpace::LENGTH: - fl_set_choice (fd_form_document->choice_default_skip, 4); - fl_set_input (fd_form_document->input_default_skip, - params->getDefSkip().asLyXCommand().c_str()); - break; - default: - fl_set_choice (fd_form_document->choice_default_skip, 2); - break; - } - - fl_set_button(fd_form_document->radio_sides_one, 0); - fl_set_button(fd_form_document->radio_sides_two, 0); - - switch (params->sides) { - case LyXTextClass::OneSide: - fl_set_button(fd_form_document->radio_sides_one, 1); - break; - case LyXTextClass::TwoSides: - fl_set_button(fd_form_document->radio_sides_two, 1); - break; - } - - fl_set_button(fd_form_document->radio_columns_one, 0); - fl_set_button(fd_form_document->radio_columns_two, 0); - - if (params->columns == 2) - fl_set_button(fd_form_document->radio_columns_two, 1); - else - fl_set_button(fd_form_document->radio_columns_one, 1); - - fl_set_input(fd_form_document->input_spacing, ""); - switch (params->spacing.getSpace()) { - case Spacing::Default: // nothing bad should happen with this - case Spacing::Single: - { - // \singlespacing - fl_set_choice(fd_form_document->choice_spacing, 1); - break; - } - case Spacing::Onehalf: - { - // \onehalfspacing - fl_set_choice(fd_form_document->choice_spacing, 2); - break; - } - case Spacing::Double: - { - // \ doublespacing - fl_set_choice(fd_form_document->choice_spacing, 3); - break; - } - case Spacing::Other: - { - fl_set_choice(fd_form_document->choice_spacing, 4); - std::ostringstream sval; - sval << params->spacing.getValue(); // setw? - fl_set_input(fd_form_document->input_spacing, - sval.str().c_str()); - break; - } - } - - - fl_set_counter_value(fd_form_document->slider_secnumdepth, - params->secnumdepth); - fl_set_counter_value(fd_form_document->slider_tocdepth, - params->tocdepth); - if (!params->float_placement.empty()) { // buffer local (Lgb) - fl_set_input(fd_form_document->input_float_placement, - params->float_placement.c_str()); - } else { - fl_set_input(fd_form_document->input_float_placement, ""); - } - if (!params->options.empty()) - fl_set_input(fd_form_document->input_extra, - params->options.c_str()); - else - fl_set_input(fd_form_document->input_extra, ""); - - if (current_view->buffer()->isSGML()) { - // bullets not used in SGML derived documents - fl_deactivate_object(fd_form_document->button_bullets); - fl_set_object_lcol(fd_form_document->button_bullets, - FL_INACTIVE); - } else { - fl_activate_object(fd_form_document->button_bullets); - fl_set_object_lcol(fd_form_document->button_bullets, - FL_BLACK); - } - - if (current_view->buffer()->isReadonly()) { - DisableDocumentLayout(); - } else { - EnableDocumentLayout(); - } - - return true; -} - - -void MenuLayoutDocument() -{ - if (UpdateLayoutDocument()) { - if (fd_form_document->form_document->visible) { - fl_raise_form(fd_form_document->form_document); - } else { - fl_show_form(fd_form_document->form_document, - FL_PLACE_MOUSE, FL_FULLBORDER, - _("Document Layout")); - } - } -} - - -bool UpdateLayoutQuotes() -{ - bool update = true; - if (!current_view->available() - || current_view->buffer()->isReadonly()) - update = false; - - if (update) { - fl_set_choice(fd_form_quotes->choice_quotes_language, - current_view->buffer()->params.quotes_language + 1); - fl_set_button(fd_form_quotes->radio_single, 0); - fl_set_button(fd_form_quotes->radio_double, 0); - - if (current_view->buffer()->params.quotes_times == InsetQuotes::SingleQ) - fl_set_button(fd_form_quotes->radio_single, 1); - else - fl_set_button(fd_form_quotes->radio_double, 1); - } else if (fd_form_quotes->form_quotes->visible) { - fl_hide_form(fd_form_quotes->form_quotes); - } - return update; -} - - -void MenuLayoutQuotes() -{ - if (UpdateLayoutQuotes()) { - if (fd_form_quotes->form_quotes->visible) { - fl_raise_form(fd_form_quotes->form_quotes); - } else { - fl_show_form(fd_form_quotes->form_quotes, - FL_PLACE_MOUSE, FL_FULLBORDER, - _("Quotes")); - } - } -} -#endif - - -bool UpdateLayoutPreamble() +bool UpdateLayoutPreamble() { bool update = true; if (!current_view->available()) @@ -1916,7 +620,7 @@ void MenuLayoutPreamble() } else { fl_show_form(fd_form_preamble->form_preamble, FL_PLACE_MOUSE | FL_FREE_SIZE, - FL_FULLBORDER, + FL_TRANSIENT, _("LaTeX Preamble")); if (ow < 0) { ow = fd_form_preamble->form_preamble->w; @@ -1948,7 +652,7 @@ LyXFont const UserFreeFont(BufferParams const & params) LyXFont font(LyXFont::ALL_IGNORE); int pos = fl_get_choice(fd_form_character->choice_family); - switch(pos) { + switch (pos) { case 1: font.setFamily(LyXFont::IGNORE_FAMILY); break; case 2: font.setFamily(LyXFont::ROMAN_FAMILY); break; case 3: font.setFamily(LyXFont::SANS_FAMILY); break; @@ -1957,7 +661,7 @@ LyXFont const UserFreeFont(BufferParams const & params) } pos = fl_get_choice(fd_form_character->choice_series); - switch(pos) { + switch (pos) { case 1: font.setSeries(LyXFont::IGNORE_SERIES); break; case 2: font.setSeries(LyXFont::MEDIUM_SERIES); break; case 3: font.setSeries(LyXFont::BOLD_SERIES); break; @@ -1965,7 +669,7 @@ LyXFont const UserFreeFont(BufferParams const & params) } pos = fl_get_choice(fd_form_character->choice_shape); - switch(pos) { + switch (pos) { case 1: font.setShape(LyXFont::IGNORE_SHAPE); break; case 2: font.setShape(LyXFont::UP_SHAPE); break; case 3: font.setShape(LyXFont::ITALIC_SHAPE); break; @@ -1975,7 +679,7 @@ LyXFont const UserFreeFont(BufferParams const & params) } pos = fl_get_choice(fd_form_character->choice_size); - switch(pos) { + switch (pos) { case 1: font.setSize(LyXFont::IGNORE_SIZE); break; case 2: font.setSize(LyXFont::SIZE_TINY); break; case 3: font.setSize(LyXFont::SIZE_SCRIPT); break; @@ -1993,7 +697,7 @@ LyXFont const UserFreeFont(BufferParams const & params) } pos = fl_get_choice(fd_form_character->choice_bar); - switch(pos) { + switch (pos) { case 1: font.setEmph(LyXFont::IGNORE); font.setUnderbar(LyXFont::IGNORE); font.setNoun(LyXFont::IGNORE); @@ -2011,7 +715,7 @@ LyXFont const UserFreeFont(BufferParams const & params) } pos = fl_get_choice(fd_form_character->choice_color); - switch(pos) { + switch (pos) { case 1: font.setColor(LColor::ignore); break; case 2: font.setColor(LColor::none); break; case 3: font.setColor(LColor::black); break; @@ -2025,13 +729,13 @@ LyXFont const UserFreeFont(BufferParams const & params) case 11: font.setColor(LColor::inherit); break; } - int choice = combo_language2->get(); + int const choice = combo_language2->get(); if (choice == 1) font.setLanguage(ignore_language); else if (choice == 2) - font.setLanguage(params.language_info); + font.setLanguage(params.language); else - font.setLanguage(&languages[combo_language2->getline()]); + font.setLanguage(languages.getLanguage(combo_language2->getline())); return font; } @@ -2041,7 +745,9 @@ LyXFont const UserFreeFont(BufferParams const & params) extern "C" void TimerCB(FL_OBJECT *, long) { // only if the form still exists - if (lyxrc.show_banner && fd_form_title->form_title != 0) { + if (lyxrc.show_banner + && fd_form_title + && fd_form_title->form_title) { if (fd_form_title->form_title->visible) { fl_hide_form(fd_form_title->form_title); } @@ -2051,152 +757,6 @@ extern "C" void TimerCB(FL_OBJECT *, long) } -/* callbacks for form form_paragraph */ - -extern "C" void ParagraphVSpaceCB(FL_OBJECT * obj, long ) -{ - // "Synchronize" the choices and input fields, making it - // impossible to commit senseless data. - - FD_form_paragraph const * fp = fd_form_paragraph; - - if (obj == fp->choice_space_above) { - if (fl_get_choice (fp->choice_space_above) != 7) { - fl_set_input (fp->input_space_above, ""); - ActivateParagraphButtons(); - } - } else if (obj == fp->choice_space_below) { - if (fl_get_choice (fp->choice_space_below) != 7) { - fl_set_input (fp->input_space_below, ""); - ActivateParagraphButtons(); - } - } else if (obj == fp->input_space_above) { - string input = fl_get_input (fp->input_space_above); - - if (input.empty()) { - fl_set_choice (fp->choice_space_above, 1); - ActivateParagraphButtons(); - } - else if (isValidGlueLength (input)) { - fl_set_choice (fp->choice_space_above, 7); - ActivateParagraphButtons(); - } - else { - fl_set_choice (fp->choice_space_above, 7); - DeactivateParagraphButtons(); - } - } else if (obj == fp->input_space_below) { - string input = fl_get_input (fp->input_space_below); - - if (input.empty()) { - fl_set_choice (fp->choice_space_below, 1); - ActivateParagraphButtons(); - } - else if (isValidGlueLength (input)) { - fl_set_choice (fp->choice_space_below, 7); - ActivateParagraphButtons(); - } - else { - fl_set_choice (fp->choice_space_below, 7); - DeactivateParagraphButtons(); - } - } -} - - -extern "C" void ParagraphApplyCB(FL_OBJECT *, long) -{ - if (!current_view->available()) - return; - - VSpace space_top, space_bottom; - LyXAlignment align; - string labelwidthstring; - bool noindent; - - // If a vspace kind is "Length" but there's no text in - // the input field, reset the kind to "None". - if (fl_get_choice (fd_form_paragraph->choice_space_above) == 7 - && !*(fl_get_input (fd_form_paragraph->input_space_above))) { - fl_set_choice (fd_form_paragraph->choice_space_above, 1); - } - if (fl_get_choice (fd_form_paragraph->choice_space_below) == 7 - && !*(fl_get_input (fd_form_paragraph->input_space_below))) { - fl_set_choice (fd_form_paragraph->choice_space_below, 1); - } - - bool line_top = fl_get_button(fd_form_paragraph->check_lines_top); - bool line_bottom = fl_get_button(fd_form_paragraph->check_lines_bottom); - bool pagebreak_top = fl_get_button(fd_form_paragraph->check_pagebreaks_top); - bool pagebreak_bottom = fl_get_button(fd_form_paragraph->check_pagebreaks_bottom); - switch (fl_get_choice (fd_form_paragraph->choice_space_above)) { - case 1: space_top = VSpace(VSpace::NONE); break; - case 2: space_top = VSpace(VSpace::DEFSKIP); break; - case 3: space_top = VSpace(VSpace::SMALLSKIP); break; - case 4: space_top = VSpace(VSpace::MEDSKIP); break; - case 5: space_top = VSpace(VSpace::BIGSKIP); break; - case 6: space_top = VSpace(VSpace::VFILL); break; - case 7: space_top = VSpace(LyXGlueLength (fl_get_input (fd_form_paragraph->input_space_above))); break; - } - if (fl_get_button (fd_form_paragraph->check_space_above)) - space_top.setKeep (true); - switch (fl_get_choice (fd_form_paragraph->choice_space_below)) { - case 1: space_bottom = VSpace(VSpace::NONE); break; - case 2: space_bottom = VSpace(VSpace::DEFSKIP); break; - case 3: space_bottom = VSpace(VSpace::SMALLSKIP); break; - case 4: space_bottom = VSpace(VSpace::MEDSKIP); break; - case 5: space_bottom = VSpace(VSpace::BIGSKIP); break; - case 6: space_bottom = VSpace(VSpace::VFILL); break; - case 7: space_bottom = VSpace(LyXGlueLength (fl_get_input (fd_form_paragraph->input_space_below))); break; - } - if (fl_get_button (fd_form_paragraph->check_space_below)) - space_bottom.setKeep (true); - - if (fl_get_button(fd_form_paragraph->radio_align_left)) - align = LYX_ALIGN_LEFT; - else if (fl_get_button(fd_form_paragraph->radio_align_right)) - align = LYX_ALIGN_RIGHT; - else if (fl_get_button(fd_form_paragraph->radio_align_center)) - align = LYX_ALIGN_CENTER; - else - align = LYX_ALIGN_BLOCK; - - labelwidthstring = fl_get_input(fd_form_paragraph->input_labelwidth); - noindent = fl_get_button(fd_form_paragraph->check_noindent); - - LyXText * text = 0; - if (current_view->the_locking_inset) - text = current_view->the_locking_inset->getLyXText(current_view); - if (!text) - text = current_view->text; - text->SetParagraph(current_view, - line_top, - line_bottom, - pagebreak_top, - pagebreak_bottom, - space_top, - space_bottom, - align, - labelwidthstring, - noindent); - current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - current_view->owner()->getMiniBuffer()->Set(_("Paragraph layout set")); -} - - -extern "C" void ParagraphCancelCB(FL_OBJECT *, long) -{ - fl_hide_form(fd_form_paragraph->form_paragraph); -} - - -extern "C" void ParagraphOKCB(FL_OBJECT *ob, long data) -{ - ParagraphApplyCB(ob, data); - ParagraphCancelCB(ob, data); -} - - /* callbacks for form form_character */ extern "C" void CharacterApplyCB(FL_OBJECT *, long) @@ -2223,374 +783,6 @@ extern "C" void CharacterOKCB(FL_OBJECT *ob, long data) } -#ifdef USE_OLD_DOCUMENT_LAYOUT -/* callbacks for form form_document */ -void UpdateDocumentButtons(BufferParams const & params) -{ - fl_set_choice(fd_form_document->choice_pagestyle, 1); - - switch (params.sides) { - case LyXTextClass::OneSide: - fl_set_button(fd_form_document->radio_sides_one, 1); - break; - case LyXTextClass::TwoSides: - fl_set_button(fd_form_document->radio_sides_two, 1); - break; - } - - if (params.columns == 2) - fl_set_button(fd_form_document->radio_columns_two, 1); - else - fl_set_button(fd_form_document->radio_columns_one, 1); - - fl_set_input(fd_form_document->input_extra, params.options.c_str()); - fl_set_counter_value(fd_form_document->slider_secnumdepth, - params.secnumdepth); - fl_set_counter_value(fd_form_document->slider_tocdepth, - params.tocdepth); - -} - -extern "C" void ChoiceClassCB(FL_OBJECT * ob, long) -{ - ProhibitInput(current_view); - if (textclasslist.Load(fl_get_choice(ob)-1)) { - if (AskQuestion(_("Should I set some parameters to"), - fl_get_choice_text(ob), - _("the defaults of this document class?"))) { - BufferParams params = BufferParams(); - params.textclass = fl_get_choice(ob)-1; - params.useClassDefaults(); - UpdateLayoutDocument(¶ms); - UpdateDocumentButtons(params); - } - } else { - // unable to load new style - WriteAlert(_("Conversion Errors!"), - _("Unable to switch to new document class."), - _("Reverting to original document class.")); - fl_set_choice(fd_form_document->choice_class, - current_view->buffer()->params.textclass + 1); - } - AllowInput(current_view); -} - - -extern "C" void DocumentDefskipCB(FL_OBJECT * obj, long) -{ - // "Synchronize" the choice and the input field, so that it - // is impossible to commit senseless data. - FD_form_document const * fd = fd_form_document; - - if (obj == fd->choice_default_skip) { - if (fl_get_choice (fd->choice_default_skip) != 4) { - fl_set_input (fd->input_default_skip, ""); - ActivateDocumentButtons(); - } - } else if (obj == fd->input_default_skip) { - - char const * input = fl_get_input (fd->input_default_skip); - - if (!*input) { - fl_set_choice (fd->choice_default_skip, 2); - ActivateDocumentButtons(); - } else if (isValidGlueLength (input)) { - fl_set_choice (fd->choice_default_skip, 4); - ActivateDocumentButtons(); - } else { - fl_set_choice (fd->choice_default_skip, 4); - DeactivateDocumentButtons(); - } - } -} - - -extern "C" void DocumentSpacingCB(FL_OBJECT * obj, long) -{ - // "Synchronize" the choice and the input field, so that it - // is impossible to commit senseless data. - FD_form_document const * fd = fd_form_document; - - if (obj == fd->choice_spacing - && fl_get_choice (fd->choice_spacing) != 4) { - fl_set_input(fd->input_spacing, ""); - } else if (obj == fd->input_spacing) { - - const char* input = fl_get_input (fd->input_spacing); - - if (!*input) { - fl_set_choice (fd->choice_spacing, 1); - } else { - fl_set_choice (fd->choice_spacing, 4); - } - } -} - - -extern "C" void DocumentApplyCB(FL_OBJECT *, long) -{ - bool redo = false; - BufferParams * params = &(current_view->buffer()->params); - - Language const * old_language = params->language_info; - params->language = combo_language->getline(); - Languages::iterator lit = languages.find(params->language); - - Language const * new_language; - if (lit != languages.end()) - new_language = &(*lit).second; - else - new_language = default_language; - - if (current_view->available()) { - if (old_language != new_language - && old_language->RightToLeft() == new_language->RightToLeft() - && !current_view->buffer()->isMultiLingual()) - current_view->buffer()->ChangeLanguage(old_language, - new_language); - if (old_language != new_language) { - //current_view->buffer()->redraw(); - redo = true; - } - } - params->language_info = new_language; - - // If default skip is a "Length" but there's no text in the - // input field, reset the kind to "Medskip", which is the default. - if (fl_get_choice (fd_form_document->choice_default_skip) == 4 - && !*(fl_get_input (fd_form_document->input_default_skip))) { - fl_set_choice (fd_form_document->choice_default_skip, 2); - } - - /* this shouldn't be done automatically IMO. For example I write german - * documents with an american keyboard very often. Matthias */ - - /* ChangeKeymap(buffer->parameters.language, TRUE, false, - fl_get_choice(fd_form_document->choice_language)); */ - params->fonts = - fl_get_choice_text(fd_form_document->choice_fonts); - params->inputenc = - fl_get_choice_text(fd_form_document->choice_inputenc); - params->fontsize = - fl_get_choice_text(fd_form_document->choice_fontsize); - params->pagestyle = - fl_get_choice_text(fd_form_document->choice_pagestyle); - params->graphicsDriver = - fl_get_choice_text(fd_form_document->choice_postscript_driver); - params->use_amsmath = - fl_get_button(fd_form_document->check_use_amsmath); - - if (!current_view->available()) - return; - - current_view->text->SetCursor(current_view, - current_view->text->cursor.par(), - current_view->text->cursor.pos()); - current_view->setState(); - - LyXTextClassList::ClassList::size_type new_class = - fl_get_choice(fd_form_document->choice_class) - 1; - - if (params->textclass != new_class) { - // try to load new_class - if (textclasslist.Load(new_class)) { - // successfully loaded - redo = true; - current_view->owner()->getMiniBuffer()-> - Set(_("Converting document to new document class...")); - CutAndPaste cap; - int ret = cap.SwitchLayoutsBetweenClasses( - current_view->buffer()->params.textclass, - new_class, - current_view->buffer()->paragraph); - - if (ret) { - string s; - if (ret == 1) - s = _("One paragraph couldn't be converted"); - else { - s += tostr(ret); - s += _(" paragraphs couldn't be converted"); - } - WriteAlert(_("Conversion Errors!"), s, - _("into chosen document class")); - } - - params->textclass = new_class; - } else { - // problem changing class -- warn user and retain old style - WriteAlert(_("Conversion Errors!"), - _("Unable to switch to new document class."), - _("Reverting to original document class.")); - fl_set_choice(fd_form_document->choice_class, params->textclass + 1); - } - } - - char tmpsep = params->paragraph_separation; - if (fl_get_button(fd_form_document->radio_indent)) - params->paragraph_separation = BufferParams::PARSEP_INDENT; - else - params->paragraph_separation = BufferParams::PARSEP_SKIP; - if (tmpsep != params->paragraph_separation) - redo = true; - - VSpace tmpdefskip = params->getDefSkip(); - switch (fl_get_choice (fd_form_document->choice_default_skip)) { - case 1: params->setDefSkip(VSpace(VSpace::SMALLSKIP)); break; - case 2: params->setDefSkip(VSpace(VSpace::MEDSKIP)); break; - case 3: params->setDefSkip(VSpace(VSpace::BIGSKIP)); break; - case 4: params->setDefSkip( - VSpace (LyXGlueLength (fl_get_input - (fd_form_document->input_default_skip)))); - break; - // DocumentDefskipCB assures that this never happens - default: params->setDefSkip(VSpace(VSpace::MEDSKIP)); break; - } - if (!(tmpdefskip == params->getDefSkip())) - redo = true; - - if (fl_get_button(fd_form_document->radio_columns_two)) - params->columns = 2; - else - params->columns = 1; - if (fl_get_button(fd_form_document->radio_sides_two)) - params->sides = LyXTextClass::TwoSides; - else - params->sides = LyXTextClass::OneSide; - - Spacing tmpSpacing = params->spacing; - switch(fl_get_choice(fd_form_document->choice_spacing)) { - case 1: - lyxerr.debug() << "Spacing: SINGLE" << endl; - params->spacing.set(Spacing::Single); - break; - case 2: - lyxerr.debug() << "Spacing: ONEHALF" << endl; - params->spacing.set(Spacing::Onehalf); - break; - case 3: - lyxerr.debug() << "Spacing: DOUBLE" << endl; - params->spacing.set(Spacing::Double); - break; - case 4: - lyxerr.debug() << "Spacing: OTHER" << endl; - params->spacing.set(Spacing::Other, - fl_get_input(fd_form_document->input_spacing)); - break; - } - if (tmpSpacing != params->spacing) - redo = true; - - signed char tmpchar = - static_cast(fl_get_counter_value(fd_form_document->slider_secnumdepth)); - if (params->secnumdepth != tmpchar) - redo = true; - params->secnumdepth = tmpchar; - - params->tocdepth = - static_cast(fl_get_counter_value(fd_form_document->slider_tocdepth)); - - params->float_placement = - fl_get_input(fd_form_document->input_float_placement); - - // More checking should be done to ensure the string doesn't have - // spaces or illegal placement characters in it. (thornley) - - if (redo) - current_view->redoCurrentBuffer(); - - current_view->owner()->getMiniBuffer()->Set(_("Document layout set")); - current_view->buffer()->markDirty(); - - params->options = - fl_get_input(fd_form_document->input_extra); -} - - -extern "C" void DocumentCancelCB(FL_OBJECT *, long) -{ - fl_hide_form(fd_form_document->form_document); -} - - -extern "C" void DocumentOKCB(FL_OBJECT * ob, long data) -{ - DocumentCancelCB(ob, data); - DocumentApplyCB(ob, data); -} - - -extern "C" void DocumentBulletsCB(FL_OBJECT *, long) -{ - bulletForm(); - // bullet callbacks etc. in bullet_panel.C -- ARRae -} - -/* callbacks for form form_quotes */ - -extern "C" void QuotesApplyCB(FL_OBJECT *, long) -{ - if (!current_view->available()) - return; - - current_view->owner()->getMiniBuffer()->Set(_("Quotes type set")); - InsetQuotes::quote_language lga = InsetQuotes::EnglishQ; - switch(fl_get_choice(fd_form_quotes->choice_quotes_language) - 1) { - case 0: - lga = InsetQuotes::EnglishQ; - break; - case 1: - lga = InsetQuotes::SwedishQ; - break; - case 2: - lga = InsetQuotes::GermanQ; - break; - case 3: - lga = InsetQuotes::PolishQ; - break; - case 4: - lga = InsetQuotes::FrenchQ; - break; - case 5: - lga = InsetQuotes::DanishQ; - break; - } - current_view->buffer()->params.quotes_language = lga; - if (fl_get_button(fd_form_quotes->radio_single)) - current_view->buffer()-> - params.quotes_times = InsetQuotes::SingleQ; - else - current_view->buffer()-> - params.quotes_times = InsetQuotes::DoubleQ; -} - - -extern "C" void QuotesCancelCB(FL_OBJECT *, long) -{ - fl_hide_form(fd_form_quotes->form_quotes); -} - - -extern "C" void QuotesOKCB(FL_OBJECT * ob, long data) -{ - QuotesApplyCB(ob, data); - QuotesCancelCB(ob, data); -} -#else -// this is needed for now! -extern "C" void ChoiceClassCB(FL_OBJECT *, long) {} -extern "C" void DocumentDefskipCB(FL_OBJECT *, long) {} -extern "C" void DocumentSpacingCB(FL_OBJECT *, long) {} -extern "C" void DocumentApplyCB(FL_OBJECT *, long) {} -extern "C" void DocumentCancelCB(FL_OBJECT *, long) {} -extern "C" void DocumentOKCB(FL_OBJECT *, long) {} -extern "C" void DocumentBulletsCB(FL_OBJECT *, long) {} -extern "C" void QuotesApplyCB(FL_OBJECT *, long) {} -extern "C" void QuotesCancelCB(FL_OBJECT *, long) {} -extern "C" void QuotesOKCB(FL_OBJECT *, long) {} -#endif - - /* callbacks for form form_preamble */ extern "C" void PreambleCancelCB(FL_OBJECT *, long) @@ -2618,138 +810,18 @@ extern "C" void PreambleOKCB(FL_OBJECT * ob, long data) } -/* callbacks for form form_table */ - -extern "C" -void TableApplyCB(FL_OBJECT *, long) -{ - if (!current_view->available()) - return; - -#ifndef NEW_TABULAR - // check for tables in tables - if (current_view->text->cursor.par()->table){ - WriteAlert(_("Impossible Operation!"), - _("Cannot insert table in table."), - _("Sorry.")); - return; - } -#endif - current_view->owner()->getMiniBuffer()->Set(_("Inserting table...")); - - int ysize = int(fl_get_slider_value(fd_form_table->slider_columns) + 0.5); - int xsize = int(fl_get_slider_value(fd_form_table->slider_rows) + 0.5); - - - current_view->hideCursor(); - current_view->beforeChange(); - current_view->update(BufferView::SELECT|BufferView::FITCUR); - - current_view->text->SetCursorParUndo(current_view->buffer()); - current_view->text->FreezeUndo(); - - current_view->text->BreakParagraph(current_view); - current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - - if (current_view->text->cursor.par()->Last()) { - current_view->text->CursorLeft(current_view); - - current_view->text->BreakParagraph(current_view); - current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - } - - current_view->text->current_font.setLatex(LyXFont::OFF); - //if (!fl_get_button(fd_form_table->check_latex)){ - // insert the new wysiwy table - current_view->text->SetLayout(current_view, 0); // standard layout -#ifndef NEW_INSETS - if (current_view->text->cursor.par()->footnoteflag == - LyXParagraph::NO_FOOTNOTE) { -#endif - current_view->text - ->SetParagraph(current_view, 0, 0, - 0, 0, - VSpace (0.3 * current_view->buffer()-> - params.spacing.getValue(), - LyXLength::CM), - VSpace (0.3 * current_view->buffer()-> - params.spacing.getValue(), - LyXLength::CM), - LYX_ALIGN_CENTER, - string(), - 0); -#ifndef NEW_INSETS - } else { - current_view->text - ->SetParagraph(current_view, 0, 0, - 0, 0, - VSpace(VSpace::NONE), - VSpace(VSpace::NONE), - LYX_ALIGN_CENTER, - string(), - 0); - } -#endif -#ifndef NEW_TABULAR - current_view->text->cursor.par()->table = - new LyXTable(xsize, ysize); -#endif - Language const * lang = - current_view->text->cursor.par()->getParLanguage(current_view->buffer()->params); - LyXFont font(LyXFont::ALL_INHERIT, lang); - for (int i = 0; i < xsize * ysize - 1; ++i) { - current_view->text->cursor.par() - ->InsertChar(0, LyXParagraph::META_NEWLINE, font); - } - current_view->text->RedoParagraph(current_view); - - current_view->text->UnFreezeUndo(); - - current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - current_view->owner()->getMiniBuffer()->Set(_("Table inserted")); - current_view->setState(); -} - - -extern "C" -void TableCancelCB(FL_OBJECT *, long) -{ - fl_hide_form(fd_form_table->form_table); -} - - -extern "C" -void TableOKCB(FL_OBJECT * ob, long data) -{ - TableApplyCB(ob, data); - TableCancelCB(ob, data); -} - - void Figure() { if (fd_form_figure->form_figure->visible) { fl_raise_form(fd_form_figure->form_figure); } else { fl_show_form(fd_form_figure->form_figure, - FL_PLACE_MOUSE, FL_FULLBORDER, + FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT, _("Insert Figure")); } } -void Table() -{ - if (fd_form_table->form_table->visible) { - fl_raise_form(fd_form_table->form_table); - } else { - fl_show_form(fd_form_table->form_table, - FL_PLACE_MOUSE, FL_FULLBORDER, - _("Insert Table")); - } -} - - /* callbacks for form form_figure */ extern "C" void FigureApplyCB(FL_OBJECT *, long) @@ -2758,16 +830,12 @@ void FigureApplyCB(FL_OBJECT *, long) return; Buffer * buffer = current_view->buffer(); - if(buffer->isReadonly()) // paranoia + if (buffer->isReadonly()) // paranoia return; current_view->owner()->getMiniBuffer()->Set(_("Inserting figure...")); - if (fl_get_button(fd_form_figure->radio_inline) -#ifndef NEW_TABULAR - || current_view->text->cursor.par()->table -#endif - ) { - InsetFig * new_inset = new InsetFig(100, 20, buffer); + if (fl_get_button(fd_form_figure->radio_inline)) { + InsetFig * new_inset = new InsetFig(100, 20, *buffer); current_view->insertInset(new_inset); current_view->owner()->getMiniBuffer()->Set(_("Figure inserted")); new_inset->Edit(current_view, 0, 0, 0); @@ -2821,7 +889,7 @@ void FigureApplyCB(FL_OBJECT *, long) current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - Inset * new_inset = new InsetFig(100, 100, buffer); + Inset * new_inset = new InsetFig(100, 100, *buffer); current_view->insertInset(new_inset); new_inset->Edit(current_view, 0, 0, 0); current_view->update(BufferView::SELECT|BufferView::FITCUR);