- // 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();
-
- minibuffer->Set(_("Document layout set"));
- current_view->currentBuffer()->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
-}
-
-
-void GotoNote()
-{
- if (!current_view->getScreen())
- return;
-
- current_view->getScreen()->HideCursor();
- BeforeChange();
- current_view->currentBuffer()->update(-2);
- LyXCursor tmp;
-
- if (!current_view->currentBuffer()->text->GotoNextNote()) {
- if (current_view->currentBuffer()->text->cursor.pos
- || current_view->currentBuffer()->text->cursor.par !=
- current_view->currentBuffer()->text->FirstParagraph())
- {
- tmp = current_view->currentBuffer()->text->cursor;
- current_view->currentBuffer()->text->cursor.par =
- current_view->currentBuffer()->text->FirstParagraph();
- current_view->currentBuffer()->text->cursor.pos = 0;
- if (!current_view->currentBuffer()->text->GotoNextNote()) {
- current_view->currentBuffer()->text->cursor = tmp;
- minibuffer->Set(_("No more notes"));
- LyXBell();
- }
- } else {
- minibuffer->Set(_("No more notes"));
- LyXBell();
- }
- }
- current_view->currentBuffer()->update(0);
- current_view->currentBuffer()->text->sel_cursor =
- current_view->currentBuffer()->text->cursor;
-}
-
-
-void InsertCorrectQuote()
-{
- Buffer *cbuffer = current_view->currentBuffer();
- char c;
-
- if (cbuffer->text->cursor.pos )
- c = cbuffer->text->cursor.par->GetChar(cbuffer->text->cursor.pos - 1);
- else
- c = ' ';
-
- cbuffer->insertInset(new InsetQuotes(c, cbuffer->params));
-}
-
-
-/* callbacks for form form_quotes */
-
-extern "C" void QuotesApplyCB(FL_OBJECT *, long)
-{
- if (!current_view->available())
- return;
-
- minibuffer->Set(_("Quotes type set"));
- //current_view->currentBuffer()->params.quotes_language =
- // fl_get_choice(fd_form_quotes->choice_quotes_language) - 1;
- 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->currentBuffer()->params.quotes_language = lga;
- if (fl_get_button(fd_form_quotes->radio_single))
- current_view->currentBuffer()->
- params.quotes_times = InsetQuotes::SingleQ;
- else
- current_view->currentBuffer()->
- 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);
-}
-
-
-
-/* callbacks for form form_preamble */
-
-extern "C" void PreambleCancelCB(FL_OBJECT *, long)
-{
- fl_hide_form(fd_form_preamble->form_preamble);
-}
-
-
-extern "C" void PreambleApplyCB(FL_OBJECT *, long)
-{
- if (!current_view->available())
- return;
-
- current_view->currentBuffer()->params.preamble =
- fl_get_input(fd_form_preamble->input_preamble);
- current_view->currentBuffer()->markDirty();
- minibuffer->Set(_("LaTeX preamble set"));
-}
-
-
-extern "C" void PreambleOKCB(FL_OBJECT *ob, long data)
-{
- PreambleApplyCB(ob, data);
- PreambleCancelCB(ob, data);
-}
-
-
-/* callbacks for form form_table */
-
-extern "C" void TableApplyCB(FL_OBJECT *, long)
-{
- int xsize,ysize;
- if (!current_view->getScreen())
- return;
-
- // check for tables in tables
- if (current_view->currentBuffer()->text->cursor.par->table){
- WriteAlert(_("Impossible Operation!"),
- _("Cannot insert table in table."),
- _("Sorry."));
- return;
- }
-
- minibuffer->Set(_("Inserting table..."));
-
- ysize = (int)(fl_get_slider_value(fd_form_table->slider_columns) + 0.5);
- xsize = (int)(fl_get_slider_value(fd_form_table->slider_rows) + 0.5);
-
-
- current_view->getScreen()->HideCursor();
- BeforeChange();
- current_view->currentBuffer()->update(-2);
-
- current_view->currentBuffer()->text->SetCursorParUndo();
- current_view->currentBuffer()->text->FreezeUndo();
-
- current_view->currentBuffer()->text->BreakParagraph();
- current_view->currentBuffer()->update(-1);
-
- if (current_view->currentBuffer()->text->cursor.par->Last()) {
- current_view->currentBuffer()->text->CursorLeft();
-
- current_view->currentBuffer()->text->BreakParagraph();
- current_view->currentBuffer()->update(-1);
- }
-
- current_view->currentBuffer()->text->current_font.setLatex(LyXFont::OFF);
- //if (!fl_get_button(fd_form_table->check_latex)){
- // insert the new wysiwy table
- current_view->currentBuffer()->text->SetLayout(0); // standard layout
- if (current_view->currentBuffer()->text->cursor.par->footnoteflag ==
- LyXParagraph::NO_FOOTNOTE) {
- current_view->currentBuffer()->
- text->SetParagraph(0, 0,
- 0, 0,
- VSpace (0.3 * current_view->currentBuffer()->
- params.spacing.getValue(),
- LyXLength::CM),
- VSpace (0.3 * current_view->currentBuffer()->
- params.spacing.getValue(),
- LyXLength::CM),
- LYX_ALIGN_CENTER,
- string(),
- 0);
- }
- else
- current_view->currentBuffer()->text->SetParagraph(0, 0,
- 0, 0,
- VSpace(VSpace::NONE),
- VSpace(VSpace::NONE),
- LYX_ALIGN_CENTER,
- string(),
- 0);
-
- current_view->currentBuffer()->text->cursor.par->table = new LyXTable(xsize, ysize);
- int i;
- for (i=0; i<xsize * ysize - 1; i++)
- current_view->currentBuffer()->text->cursor.par->InsertChar(0,LYX_META_NEWLINE);
- current_view->currentBuffer()->text->RedoParagraph();
-
- current_view->currentBuffer()->text->UnFreezeUndo();
-
- current_view->currentBuffer()->update(1);
- minibuffer->Set(_("Table inserted"));
-}
-
-
-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);
-}
-
-
-/* callbacks for form form_print */
-
-extern "C" void PrintCancelCB(FL_OBJECT *, long)
-{
- fl_hide_form(fd_form_print->form_print);
-}
-
-static bool stringOnlyContains (string const & LStr, const char * cset)
-{
- const char * cstr = LStr.c_str() ;
-
- return strspn(cstr,cset) == strlen(cstr) ;
-}
-
-extern "C" void PrintApplyCB(FL_OBJECT *, long)
-{
- if (!current_view->available())
- return;
- Buffer *buffer = current_view->currentBuffer();
- string path = OnlyPath(buffer->getFileName());
-
- string pageflag;
- if (fl_get_button(fd_form_print->radio_even_pages))
- pageflag = lyxrc->print_evenpage_flag + ' ';
- else if (fl_get_button(fd_form_print->radio_odd_pages))
- pageflag = lyxrc->print_oddpage_flag + ' ';
-
-// Changes by Stephan Witt (stephan.witt@beusen.de), 19-Jan-99
-// User may give a page (range) list
-// User may print multiple (unsorted) copies
- string pages = subst(fl_get_input(fd_form_print->input_pages), ';',',');
- pages = subst(pages, '+',',');
- pages = frontStrip(strip(pages)) ;
- while (!pages.empty()) { // a page range was given
- string piece ;
- pages = split (pages, piece, ',') ;
- piece = strip(piece) ;
- piece = frontStrip(piece) ;
- if ( !stringOnlyContains (piece, "0123456789-") ) {
- WriteAlert(_("ERROR! Unable to print!"),
- _("Check 'range of pages'!"));
- return;
- }
- if (piece.find('-') == string::npos) { // not found
- pageflag += lyxrc->print_pagerange_flag + piece + '-' + piece + ' ' ;
- } else if (suffixIs(piece, "-") ) { // missing last page
- pageflag += lyxrc->print_pagerange_flag + piece + "1000 ";
- } else if (prefixIs(piece, "-") ) { // missing first page
- pageflag += lyxrc->print_pagerange_flag + '1' + piece + ' ' ;
- } else {
- pageflag += lyxrc->print_pagerange_flag + piece + ' ' ;
- }
- }
-
- string copies = frontStrip(strip(fl_get_input(fd_form_print->input_copies)));
- if (!copies.empty()) { // a number of copies was given
- if ( !stringOnlyContains (copies, "0123456789") ) {
- WriteAlert(_("ERROR! Unable to print!"),
- _("Check 'number of copies'!"));
- return;
- }
- if (fl_get_button(fd_form_print->do_unsorted))
- pageflag += lyxrc->print_copies_flag;
- else
- pageflag += lyxrc->print_collcopies_flag;
- pageflag += " " + copies + ' ' ;
- }
-
- string reverseflag;
- if (fl_get_button(fd_form_print->radio_order_reverse))
- reverseflag = lyxrc->print_reverse_flag + ' ';
-
- string orientationflag;
- if (buffer->params.orientation == ORIENTATION_LANDSCAPE)
- orientationflag = lyxrc->print_landscape_flag + ' ';
-
- string ps_file = SpaceLess(fl_get_input(fd_form_print->input_file));
- string printer = strip(fl_get_input(fd_form_print->input_printer));
-
- string printerflag;
- if (lyxrc->print_adapt_output // printer name should be passed to dvips
- && ! printer.empty()) // a printer name has been given
- printerflag = lyxrc->print_to_printer + printer + ' ';
-
- string extraflags;
- if (!lyxrc->print_extra_options.empty())
- extraflags = lyxrc->print_extra_options + ' ';
-
- string command = lyxrc->print_command + ' '
- + printerflag + pageflag + reverseflag
- + orientationflag + extraflags;
-
- char real_papersize = buffer->params.papersize;
- if (real_papersize == PAPER_DEFAULT)
- real_papersize = lyxrc->default_papersize;
- string
- paper;
-
- switch (real_papersize) {
- case PAPER_USLETTER:
- paper = "letter";
- break;
- case PAPER_A3PAPER:
- paper = "a3";
- break;
- case PAPER_A4PAPER:
- paper = "a4";
- break;
- case PAPER_A5PAPER:
- paper = "a5";
- break;
- case PAPER_B5PAPER:
- paper = "b5";
- break;
- case PAPER_EXECUTIVEPAPER:
- paper = "foolscap";
- break;
- case PAPER_LEGALPAPER:
- paper = "legal";
- break;
- default: /* If nothing else fits, keep an empty value... */
- break;
- }
-
- if (buffer->params.use_geometry
- && buffer->params.papersize2 == 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 (!lyxrc->print_paper_flag.empty()
- && !paper.empty()
- && (real_papersize != PAPER_USLETTER ||
- buffer->params.orientation == ORIENTATION_PORTRAIT)) {
- command += " " + lyxrc->print_paper_flag + " " + paper + " ";
- }
- if (fl_get_button(fd_form_print->radio_file))
- command += lyxrc->print_to_file + '\"'
- + MakeAbsPath(ps_file, path)
- + '\"';
- else if (!lyxrc->print_spool_command.empty())
- command += lyxrc->print_to_file
- + '\"' + ps_file + '\"';
-
- // push directorypath, if necessary
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
- path = buffer->tmppath;
- }
- Path p(path);
-
- bool result;
- if (!lyxrc->print_spool_command.empty() &&
- !fl_get_button(fd_form_print->radio_file)) {
- string command2 = lyxrc->print_spool_command + ' ';
- if (!printer.empty())
- command2 += lyxrc->print_spool_printerprefix
- + printer;
- // First run dvips and, if succesful, then spool command
- if ((result = RunScript(buffer, true, command))) {
- result = RunScript(buffer, false, command2, ps_file);
- }
- } else
- result = RunScript(buffer, false, command);
-
- if (!result)
- WriteAlert(_("Error:"),
- _("Unable to print"),
- _("Check that your parameters are correct"));
-}
-
-
-extern "C" void PrintOKCB(FL_OBJECT *ob, long data)
-{
- PrintCancelCB(ob, data);
- PrintApplyCB(ob,data);
-}
-
-
-/* callbacks for form form_figure */
-
-extern "C" void FigureApplyCB(FL_OBJECT *, long)
-{
- if (!current_view->available())
- return;
-
- Buffer * buffer = current_view->currentBuffer();
- if(buffer->isReadonly()) // paranoia
- return;
-
- minibuffer->Set(_("Inserting figure..."));
- if (fl_get_button(fd_form_figure->radio_inline)
- || buffer->text->cursor.par->table) {
- InsetFig * new_inset = new InsetFig(100, 20, buffer);
- buffer->insertInset(new_inset);
- minibuffer->Set(_("Figure inserted"));
- new_inset->Edit(0, 0);
- return;
- }
-
- current_view->getScreen()->HideCursor();
- buffer->update(-2);
- BeforeChange();
-
- buffer->text->SetCursorParUndo();
- buffer->text->FreezeUndo();
-
- buffer->text->BreakParagraph();
- buffer->update(-1);
-
- if (buffer->text->cursor.par->Last()) {
- buffer->text->CursorLeft();
-
- buffer->text->BreakParagraph();
- buffer->update(-1);
- }
-
- // The standard layout should always be numer 0;
- buffer->text->SetLayout(0);
-
- if (buffer->text->cursor.par->footnoteflag ==
- LyXParagraph::NO_FOOTNOTE) {
- buffer->text->SetParagraph(0, 0,
- 0, 0,
- VSpace (0.3 * buffer->params.spacing.getValue(),
- LyXLength::CM),
- VSpace (0.3 *
- buffer->params.spacing.getValue(),
- LyXLength::CM),
- LYX_ALIGN_CENTER, string(), 0);
- } else
- buffer->text->SetParagraph(0, 0,
- 0, 0,
- VSpace(VSpace::NONE),
- VSpace(VSpace::NONE),
- LYX_ALIGN_CENTER,
- string(),
- 0);
-
- buffer->update(-1);
-
- Inset *new_inset = 0;
-
- new_inset = new InsetFig(100, 100, buffer);
- buffer->insertInset(new_inset);
- new_inset->Edit(0, 0);
- buffer->update(0);
- minibuffer->Set(_("Figure inserted"));
- buffer->text->UnFreezeUndo();
-}