From dfe1bc44b44903faf77ef454c98c4c3e56c1d5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Thu, 4 Nov 1999 01:40:20 +0000 Subject: [PATCH] the runlatex merge git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@291 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 218 +++++ Makefile.am | 1 + src/BackStack.h | 41 +- src/BufferView.C | 136 ++- src/BufferView.h | 26 +- src/Chktex.C | 27 +- src/DepTable.C | 179 ++-- src/DepTable.h | 33 +- src/LaTeX.C | 455 ++++----- src/LaTeX.h | 101 +- src/LaTeXFeatures.C | 22 +- src/Literate.C | 62 +- src/Literate.h | 25 +- src/LyXSendto.C | 10 +- src/LyXView.C | 18 +- src/LyXView.h | 62 +- src/PaperLayout.C | 43 +- src/ParagraphExtra.C | 7 +- src/TableLayout.C | 1 + src/broken_headers.h | 4 +- src/buffer.C | 488 +++++----- src/buffer.h | 8 +- src/bufferlist.h | 4 +- src/bufferparams.C | 18 +- src/bufferparams.h | 23 +- src/debug.h | 13 +- src/insets/figinset.C | 4 +- src/insets/inset.C | 10 +- src/insets/insetbib.C | 57 +- src/insets/insetbib.h | 22 +- src/insets/insetcommand.C | 30 +- src/insets/insetcommand.h | 38 +- src/insets/inseterror.C | 38 +- src/insets/inseterror.h | 32 +- src/insets/insetinclude.C | 51 +- src/insets/insetinclude.h | 20 +- src/insets/insetindex.C | 30 +- src/insets/insetindex.h | 28 +- src/insets/insetinfo.C | 38 +- src/insets/insetinfo.h | 38 +- src/insets/insetlabel.C | 22 +- src/insets/insetlabel.h | 20 +- src/insets/insetlatex.C | 45 +- src/insets/insetlatex.h | 28 +- src/insets/insetlatexaccent.C | 53 +- src/insets/insetlatexaccent.h | 31 +- src/insets/insetloa.C | 13 +- src/insets/insetloa.h | 16 +- src/insets/insetlof.h | 15 +- src/insets/insetlot.h | 14 +- src/insets/insetparent.C | 12 +- src/insets/insetparent.h | 17 +- src/insets/insetquotes.C | 8 +- src/insets/insetquotes.h | 3 +- src/insets/insetref.C | 160 +--- src/insets/insetref.h | 23 +- src/insets/insetspecialchar.C | 28 +- src/insets/insetspecialchar.h | 28 +- src/insets/insettoc.C | 6 +- src/insets/insettoc.h | 18 +- src/insets/inseturl.C | 33 +- src/insets/inseturl.h | 30 +- src/insets/lyxinset.h | 47 +- src/kbmap.C | 4 +- src/lastfiles.C | 88 +- src/lastfiles.h | 131 ++- src/layout.C | 843 +++++++---------- src/layout.h | 426 +++++---- src/lyx_cb.C | 121 ++- src/lyx_gui_misc.C | 8 - src/lyx_main.C | 32 +- src/lyxcursor.h | 17 +- src/lyxfont.C | 20 +- src/lyxfr1.C | 75 +- src/lyxfr1.h | 11 +- src/lyxfunc.C | 54 +- src/lyxparagraph.h | 405 +++++--- src/lyxrc.C | 6 +- src/lyxrc.h | 4 +- src/lyxrow.h | 24 +- src/lyxtext.h | 275 ++++-- src/lyxvc.C | 50 +- src/mathed/formula.C | 42 +- src/mathed/math_cursor.C | 12 +- src/mathed/math_draw.C | 4 +- src/mathed/math_hash.C | 12 +- src/mathed/math_inset.C | 14 +- src/mathed/math_iter.C | 26 +- src/menus.C | 320 +++---- src/paragraph.C | 1667 ++++++++++++++++++++++++--------- src/support/Makefile.am | 1 + src/support/filetools.C | 6 +- src/support/lyxstring.C | 5 +- src/support/syscall.C | 2 +- src/table.C | 398 +------- src/texrow.h | 10 +- src/text.C | 973 +++++++++++-------- src/text2.C | 928 ++++++++++-------- src/trans.C | 4 +- src/trans.h | 2 +- src/vspace.C | 22 +- src/vspace.h | 3 +- 102 files changed, 5403 insertions(+), 4773 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9b18bad7ff..3fb7552597 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,10 @@ 1999-11-02 Lars Gullik Bjønnes + * src/layout.C (less_textclass_desc): functor for use in sorting + of textclasses. + (LyXTextClass::Read): sort the textclasses after reading. + * src/support/filetools.C (SpaceLess): new version of the SpaceLess functions. What problems does this one give? Please report. @@ -68,6 +72,12 @@ * added patch for OS/2 from SMiyata. +1999-10-29 Lars Gullik Bjønnes + + * src/text2.C (CutSelection): make space_wrapped a bool + (CutSelection): dont declare int i until we have to. + (alphaCounter): return a char const *. + 1999-10-28 Jean-Marc Lasgouttes * src/support/syscall.C (Systemcalls::kill): @@ -79,6 +89,11 @@ 1999-10-28 Lars Gullik Bjønnes + * src/layout.[Ch] + several files: access to class variables + limited and made accessor functions instead a lot of code changed + becuase of this. Also instead of returning pointers often a const + reference is returned instead. + * src/form1.C (create_form_Figure): added a couple fo "no-c-format" * src/Makefile.am (dist-hook): added used to remove the CVS from @@ -93,6 +108,32 @@ 1999-10-27 Lars Gullik Bjønnes + * src/layout.[Ch] src/BufferView.C src/LaTeXFeatures.C + src/LyXView.C src/buffer.C src/bufferparams.C + src/lyx_cb.C src/lyxfunc.C src/paragraph.C src/text.C + src/text2.C src/insets/insetinclude.C: + lyxlayout renamed to textclasslist. + + * src/layout.C: some lyxerr changes. + + * src/layout.[Ch] (LyXLayout::Read): changed second paramter to + LyXTextClass. rewrote LT_COPYSTYLE, rewrote LT_OBSOLETEDBY + (LyXLayoutList): removed all traces of this class. + (LyXTextClass::Read): rewrote LT_STYLE + (LyXTextClass::hasLayout): new function + (LyXTextClass::GetLayout): rewritten to return an iterator + has + both const and nonconst version. + (LyXTextClass::delete_layout): new function. + (LyXTextClassList::Style): bug fix. do the right thing if layout + is to big. + (LyXTextClassList::NumberOfLayout): new acces to layoutlist. + (LyXTextClassList::NameOfLayout): ditto + (LyXTextClassList::Load): ditto + + * src/buffer.C (makeLaTeXFile): new access to layoutlist + + * src/LaTeXFeatures.C (getTClassPreamble): new access to layoutlist + * src/LyXAction.C (LookupFunc): added a workaround for sun compiler, on the other hand...we don't know if the current code compiles on sun at all... @@ -122,8 +163,130 @@ * src/lyx_cb.C (MenuFax): subst fix (PrintApplyCB): subst fix +1999-10-26 Juergen Vigna + + * src/table.C (TexEndOfCell) + (DocBookEndOfCell): removed some #if 0 + + (Read): Cleaned up this code so now we read only format vestion >= 5 + 1999-10-26 Lars Gullik Bjønnes + * src/support/filetools.C (PutEnvPath): subst fix for EMX, how + come nobody has complained about this one? + + * src/insets/insetinclude.C (Latex): subst fix + + * src/insets/insetbib.C (getKeys): subst fix + + * src/lyx_main.C (init): subst fix + + * src/layout.C (Read): subst fix + + * src/buffer.C (RoffAsciiTable): subst fix + + * src/lyx_cb.C (MenuFax): subst fix. + + * src/layout.[hC] + some other files: rewrote to use + std::container to store textclasses and layouts in. + Simplified, removed a lot of code. Make all classes + assignable. Further simplifications and review of type + use still to be one. + + * src/menus.C (ShowFileMenu/ShowFileMenu2): Use the iterators from + lastfiles to create the lastfiles partr of the menu. + + * src/lastfiles.[Ch]: rewritten to use deque to store the + lastfiles in. Uses fstream for reading and writing. Simplifies + code. + + * src/support/syscall.C: remove explicit cast. + + * src/BufferView.C (CursorToggleCB): removed code snippets that + were commented out. + use explicat C++ style casts instead of C style casts. also use + u_vdata instea of passing pointers in longs. + + * src/PaperLayout.C: removed code snippets that were commented out. + + * src/lyx_gui_misc.C: removed code snippets that were commented out. + + * src/lyx_main.C: removed code snippets that wer commented out. + + * src/paragraph.C: removed code snippets that were commented out. + + * src/lyxvc.C (logClose): use static_cast + (logUpdate): ditto + (viewLog): remove explicit cast to void* + (showLog): removed old commented code + + * src/menus.C: use static_cast instead of C style casts. use + u_vdata instead of u_ldata. remove explicit cast to (long) for + pointers. Removed old code that was commented out. + + * src/insets/inset.C: removed old commented func + + * src/insets/insetref.C (InsetRef): removed old code that had been + commented out for a long time. + (Edit): ditto + (escape): removed C style cast + + * src/insets/insetlatexaccent.C (Draw): removed old commented code + + * src/insets/insetlatex.C (Draw): removed old commented code + (Read): rewritten to use string + + * src/insets/insetlabel.C (escape): removed C style cast + + * src/insets/insetindex.h: removed vdata and ldata from FD_index_form + + * src/insets/insetindex.C: use static_cast and u_vdata, removed + old commented code. + + * src/insets/insetinclude.h: removed a couple of stupid bools + + * src/insets/insetinclude.C (include_cb): use static_cast and u_data. + (Clone): remove C style cast + (getKeys): changed list to lst because of std::list + + * src/insets/inseterror.C (Draw): removed som old commented code. + + * src/insets/insetcommand.C (Draw): removed some old commented code. + + * src/insets/insetbib.C (bibitem_cb): removed code that has been + commented out forever. + (bibitem_cb): use static_cast instead of C style cast + use of vdata changed to u_vdata. + + * src/insets/inseturl.C (C_InsetUrl_CloseUrlCB): forward the data + parameter. + (CloseUrlCB): use static_cast instead of C style cast. + (CloseUrlCB): added a fl_free form...it seemed to be missing. + + * src/insets/insetinfo.C (Edit): pass object in u_vdata instead + (C_InsetInfo_CloseInfoCB): forward the ob parameter + (CloseInfoCB): static_cast from ob->u_vdata instead. + (Edit): removed bogus arg from fl_set_object_shortcut, set to 1 + instead. + + * src/insets/inseterror.C (Edit): pass object in u_vdata instead + (C_InsetError_CloseErrorCB): forward the ob parameter + (CloseErrorCB): static_cast from ob->u_vdata instead. + + * src/vspace.h: include LString.h since we use string in this class. + + * src/vspace.C (lyx_advance): changed name from advance because of + nameclash with stl. And since we cannot use namespaces yet...I + used a lyx_ prefix instead. Expect this to change when we begin + using namespaces. + + * src/BufferView.[Ch] (BufferView::~BufferView): removed + + * src/BackStack.h: rewrote to use std::stack. made BackStackItem + and removed now defunct constructor and deconstructor. + + * src/BufferView.h: have backstack as a object not as a pointer. + removed initialization from constructor. added include for BackStack + * development/lyx.spec.in (%build): add CFLAGS also. * src/screen.C (drawFrame): removed another warning. @@ -208,6 +371,13 @@ 1999-10-24 Lars Gullik Bjønnes +1999-10-24 Lars Gullik Bjønnes + + * src/LaTeX.C (run): made run_bibtex also depend on files with + extension ".bst" + (runBibTeX): added scans for "\\bibstyle", now also ".bst" files + are put into the dependency file. + * src/spellchecker.C (create_ispell_pipe): removed old #warning, the code has shown itself to work (create_ispell_pipe): removed another warning, added a comment @@ -316,6 +486,21 @@ 1999-10-22 Lars Gullik Bjønnes + * src/LaTeX.C (run): added a check in 0 sumchange so that if it + was a bib file that had been changed we ensure that bibtex is run. + (runBibTeX): enhanced to extract the names of the bib files and + getting their absolute path and enter them into the dep file. + (findtexfile): static func that is used to look for tex-files, + checks for absolute patchs and tries also with kpsewhich. + Alternative ways of finding the correct files are wanted. Will + probably be moved. + (do_popen): function that runs a command using popen and returns + the whole output of that command in a string. Should be moved to + somewhere else. + + * src/DepTable.[Ch] (extchanged): new function that returns true if a + file with extension ext has changed. + * src/insets/figinset.C: added ifdef guards around the fl_free code that jug commented out. Now it is commented out when compiling with XForms == 0.89. @@ -359,6 +544,27 @@ 1999-10-20 Lars Gullik Bjønnes + * src/support/lyxstring.C (getline): reads now _all_ chars. uses + get instead of >> + + * src/Literate.h: some funcs moved from public to private to make + interface clearer. Unneeded args removed. + + * src/Literate.C (scanLiterateLogFile): rewritten to use iostream + instead of lyxlex. + (scanBuildLogFile): ditto + + * src/LaTeX.C (scanLogFile): merged LaTeX Error handling into + normal TeX Error. Still room for improvement. + + * src/LaTeX.[Ch]: removed scanError. Wrong place and not needed. + + * src/buffer.C (insertErrors): changes to make the error + desctription show properly. + + * src/LaTeX.C (deplog): removed the test for file in lyx doc dir. + could never happen + * src/support/lyxstring.C (helper): changed to use sizeof(object->rep->ref). (operator>>): changed to use a pointer instead. @@ -469,8 +675,20 @@ * src/lyxrc.C (Read): RC_PRINTEXSTRAOPTIONS now uses LyXLex::next() and not eatline() to get its argument. +1999-10-17 Lars Gullik Bjønnes + + * src/DepTable.[Ch]: rewritten to store the dependencies in a map + instead, use fstreams for io of the depfile, removed unneeded + functions and variables. + + * src/LaTeX.[Ch] (class TeXErrors): rewrote to store the errors in a + vector instead, removed all functions and variables that is not in + use. + 1999-10-16 Lars Gullik Bjønnes + * src/buffer.C (insertErrors): use new interface to TeXError + * Makefile.am (rpmdist): added a rpmdist target * lib/reLyX/Makefile.am: added RelyxFigure.pm and Verbatim.pm as diff --git a/Makefile.am b/Makefile.am index f1a91f2310..5da61745cf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,3 +22,4 @@ rpmdist: dist ln -s images/lyx.xpm . ; \ rpm -ta ${PACKAGE}-${VERSION}.tar.gz ; \ rm lyx.xpm + diff --git a/src/BackStack.h b/src/BackStack.h index 5ca40451a3..b56bb64147 100644 --- a/src/BackStack.h +++ b/src/BackStack.h @@ -11,6 +11,7 @@ #ifndef BACK_STACK_H #define BACK_STACK_H +#include #include "LString.h" // Created by Alejandro Aguilar Sierra, 970806 @@ -18,13 +19,15 @@ /** Utility to get back from a reference or from a child document. */ class BackStack { -public: +private: /// struct BackStackItem { + BackStackItem(string const & f, int xx, int yy) + : fname(f), x(xx), y(yy) {} /// - void set(string f, int xx, int yy) { - fname = f; x = xx; y = yy; - } + //void set(string f, int xx, int yy) { + // fname = f; x = xx; y = yy; + //} /// Filename string fname; /// Cursor x-position @@ -32,35 +35,27 @@ public: /// Cursor y-position int y; }; - /// - BackStack(int n) : item(new BackStackItem[n]) , i(0), imax(n) {} - /// - ~BackStack() { - delete[] item; - } +public: /// void push(string f, int x, int y) { - if (i < imax) - item[i++].set(f, x, y); + BackStackItem bit(f, x, y); + stakk.push(bit); } /// - string & pop(int *x, int *y) { - if (i > 0) i--; - *x = item[i].x; - *y = item[i].y; - return item[i].fname; + string pop(int * x, int * y) { + BackStackItem bit = stakk.top(); + *x = bit.x; + *y = bit.y; + stakk.pop(); + return bit.fname; } /// bool empty() const { - return i == 0; + return stakk.empty(); } private: /// - BackStackItem *item; - /// - int i; - /// - int imax; + stack stakk; }; #endif diff --git a/src/BufferView.C b/src/BufferView.C index a9abd9ff9c..e8f2fd63e2 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -40,6 +40,7 @@ #include "lyxtext.h" #include "lyx_cb.h" #include "gettext.h" +#include "layout.h" extern BufferList bufferlist; void sigchldhandler(pid_t pid, int *status); @@ -56,7 +57,7 @@ extern InsetUpdateStruct *InsetUpdateList; extern void UpdateInsetUpdateList(); // This is _very_ temporary -FL_OBJECT *figinset_canvas; +FL_OBJECT * figinset_canvas; BufferView::BufferView(LyXView *o, int xpos, int ypos, int width, int height) @@ -78,16 +79,9 @@ BufferView::BufferView(LyXView *o, int xpos, int ypos, fl_set_focus_object(_owner->getForm(), work_area); work_area_focus = true; lyx_focus = false; - backstack = new BackStack(16); } -BufferView::~BufferView() -{ - delete backstack; -} - - void BufferView::setBuffer(Buffer *b) { lyxerr.debug() << "Setting buffer in BufferView" << endl; @@ -129,7 +123,6 @@ void BufferView::setBuffer(Buffer *b) } else { lyxerr.debug() << " No Buffer!" << endl; _owner->getMenus()->hideMenus(); - //workAreaExpose(); updateScrollbar(); fl_redraw_object(work_area); } @@ -241,9 +234,9 @@ void BufferView::updateScrollbar() fl_set_slider_increment(scrollbar,work_area->h-lineh,lineh); #endif if (maxfloat>0){ - if ((hfloat/maxfloat) * (float) height2 < 3) + if ((hfloat/maxfloat) * float(height2) < 3) fl_set_slider_size(scrollbar, - 3/(float)height2); + 3/float(height2)); else fl_set_slider_size(scrollbar, hfloat/maxfloat); @@ -267,9 +260,9 @@ int BufferView::resizeCurrentBuffer() { lyxerr.debug() << "resizeCurrentBuffer" << endl; - LyXParagraph *par = 0; - LyXParagraph *selstartpar = 0; - LyXParagraph *selendpar = 0; + LyXParagraph * par = 0; + LyXParagraph * selstartpar = 0; + LyXParagraph * selendpar = 0; int pos = 0; int selstartpos = 0; int selendpos = 0; @@ -364,33 +357,34 @@ void BufferView::gotoError() _buffer->text->cursor; } + // Just a bunch of C wrappers around static members of BufferView -extern "C" void C_BufferView_UpCB(FL_OBJECT *ob, long buf) { - BufferView::UpCB(ob,buf); +extern "C" void C_BufferView_UpCB(FL_OBJECT * ob, long buf) { + BufferView::UpCB(ob, buf); } -extern "C" void C_BufferView_DownCB(FL_OBJECT *ob, long buf) { - BufferView::DownCB(ob,buf); +extern "C" void C_BufferView_DownCB(FL_OBJECT * ob, long buf) { + BufferView::DownCB(ob, buf); } -extern "C" void C_BufferView_ScrollCB(FL_OBJECT *ob, long buf) { - BufferView::ScrollCB(ob,buf); +extern "C" void C_BufferView_ScrollCB(FL_OBJECT * ob, long buf) { + BufferView::ScrollCB(ob, buf); } -extern "C" void C_BufferView_CursorToggleCB(FL_OBJECT *ob, long buf) { - BufferView::CursorToggleCB(ob,buf); +extern "C" void C_BufferView_CursorToggleCB(FL_OBJECT * ob, long buf) { + BufferView::CursorToggleCB(ob, buf); } -extern "C" int C_BufferView_work_area_handler(FL_OBJECT *ob, int event, +extern "C" int C_BufferView_work_area_handler(FL_OBJECT * ob, int event, FL_Coord, FL_Coord, - int key, void *xev) { + int key, void * xev) { return BufferView::work_area_handler(ob, event, 0, 0, key, xev); } void BufferView::create_view(int xpos, int ypos, int width, int height) { - FL_OBJECT *obj; + FL_OBJECT * obj; const int bw = abs(fl_get_border_width()); // a hack for the figinsets (Matthias) @@ -441,7 +435,8 @@ void BufferView::create_view(int xpos, int ypos, int width, int height) fl_set_object_color(obj,FL_MCOL,FL_BLUE); fl_set_object_resize(obj, FL_RESIZE_ALL); fl_set_object_gravity(obj,NorthEastGravity, NorthEastGravity); - fl_set_object_callback(obj,C_BufferView_UpCB,(long)this); + fl_set_object_callback(obj, C_BufferView_UpCB, 0); + obj->u_vdata = this; fl_set_pixmapbutton_data(obj, up_xpm); #if FL_REVISION >85 @@ -459,7 +454,8 @@ void BufferView::create_view(int xpos, int ypos, int width, int height) fl_set_object_boxtype(obj, FL_UP_BOX); fl_set_object_resize(obj, FL_RESIZE_ALL); fl_set_object_gravity(obj, NorthEastGravity, SouthEastGravity); - fl_set_object_callback(obj,C_BufferView_ScrollCB,(long)this); + fl_set_object_callback(obj, C_BufferView_ScrollCB, 0); + obj->u_vdata = this; // down - scrollbar button #if FL_REVISION > 85 @@ -475,7 +471,8 @@ void BufferView::create_view(int xpos, int ypos, int width, int height) fl_set_object_color(obj,FL_MCOL,FL_BLUE); fl_set_object_resize(obj, FL_RESIZE_ALL); fl_set_object_gravity(obj, SouthEastGravity, SouthEastGravity); - fl_set_object_callback(obj,C_BufferView_DownCB,(long)this); + fl_set_object_callback(obj, C_BufferView_DownCB, 0); + obj->u_vdata = this; fl_set_pixmapbutton_data(obj, down_xpm); fl_set_border_width(-bw); @@ -497,13 +494,13 @@ void BufferView::create_view(int xpos, int ypos, int width, int height) // Callback for scrollbar up button -void BufferView::UpCB(FL_OBJECT *ob, long buf) +void BufferView::UpCB(FL_OBJECT * ob, long) { - BufferView *view = (BufferView*) buf; + BufferView * view = static_cast(ob->u_vdata); if (view->_buffer == 0) return; - const XEvent*ev2; + XEvent const * ev2; static long time = 0; ev2 = fl_last_event(); if (ev2->type == ButtonPress || ev2->type == ButtonRelease) @@ -540,20 +537,20 @@ void waitForX() } static XEvent ev; XChangeProperty(fl_display, w, a, a, 8, - PropModeAppend, (unsigned char *)"", 0); + PropModeAppend, reinterpret_cast(""), 0); XWindowEvent(fl_display, w, PropertyChangeMask, &ev); } // Callback for scrollbar slider -void BufferView::ScrollCB(FL_OBJECT *ob, long buf) +void BufferView::ScrollCB(FL_OBJECT * ob, long) { - BufferView *view = (BufferView*) buf; + BufferView *view = static_cast(ob->u_vdata); extern bool cursor_follows_scrollbar; if (view->_buffer == 0) return; - view->current_scrollbar_value = (long)fl_get_slider_value(ob); + view->current_scrollbar_value = long(fl_get_slider_value(ob)); if (view->current_scrollbar_value < 0) view->current_scrollbar_value = 0; @@ -584,13 +581,13 @@ void BufferView::ScrollCB(FL_OBJECT *ob, long buf) // Callback for scrollbar down button -void BufferView::DownCB(FL_OBJECT *ob, long buf) +void BufferView::DownCB(FL_OBJECT * ob, long) { - BufferView *view = (BufferView*) buf; + BufferView * view = static_cast(ob->u_vdata); if (view->_buffer == 0) return; - const XEvent*ev2; + XEvent const *ev2; static long time = 0; ev2 = fl_last_event(); if (ev2->type == ButtonPress || ev2->type == ButtonRelease) @@ -619,11 +616,11 @@ int BufferView::ScrollUp(long time) return 0; float add_value = (_buffer->text->DefaultHeight() - + (float)(time) * (float)(time) * 0.125); + + float(time) * float(time) * 0.125); if (add_value > work_area->h) - add_value = (float) (work_area->h - - _buffer->text->DefaultHeight()); + add_value = float(work_area->h - + _buffer->text->DefaultHeight()); value -= add_value; @@ -632,7 +629,7 @@ int BufferView::ScrollUp(long time) fl_set_slider_value(scrollbar, value); - ScrollCB(scrollbar,(long)this); + ScrollCB(scrollbar, 0); return 0; } @@ -651,11 +648,11 @@ int BufferView::ScrollDown(long time) return 0; float add_value = (_buffer->text->DefaultHeight() - + (float)(time) * (float)(time) * 0.125); + + float(time) * float(time) * 0.125); if (add_value > work_area->h) - add_value = (float) (work_area->h - - _buffer->text->DefaultHeight()); + add_value = float(work_area->h - + _buffer->text->DefaultHeight()); value += add_value; @@ -664,7 +661,7 @@ int BufferView::ScrollDown(long time) fl_set_slider_value(scrollbar, value); - ScrollCB(scrollbar,(long)this); + ScrollCB(scrollbar, 0); return 0; } @@ -684,7 +681,7 @@ void BufferView::ScrollUpOnePage(long /*time*/) fl_set_slider_value(scrollbar, y); - ScrollCB(scrollbar,(long)this); + ScrollCB(scrollbar, 0); } @@ -706,7 +703,7 @@ void BufferView::ScrollDownOnePage(long /*time*/) fl_set_slider_value(scrollbar, y); - ScrollCB(scrollbar,(long)this); + ScrollCB(scrollbar, 0); } @@ -718,8 +715,8 @@ int BufferView::work_area_handler(FL_OBJECT * ob, int event, static int y_old = -1; static long scrollbar_value_old = -1; - XEvent* ev = (XEvent*) xev; - BufferView *view = (BufferView*) ob->u_vdata; + XEvent * ev = static_cast(xev); + BufferView * view = static_cast(ob->u_vdata); // If we don't have a view yet; return if (!view || quitting) return 0; @@ -858,7 +855,7 @@ int BufferView::WorkAreaMotionNotify(FL_OBJECT *ob, Window, } -extern int bibitemMaxWidth(const class LyXFont &); +extern int bibitemMaxWidth(LyXFont const &); // Single-click on work area int BufferView::WorkAreaButtonPress(FL_OBJECT *ob, Window, @@ -1163,8 +1160,8 @@ int BufferView::WorkAreaButtonRelease(FL_OBJECT *ob, Window , // Maybe we want to edit a bibitem ale970302 if (_buffer->text->cursor.par->bibkey && x < 20 + - bibitemMaxWidth(lyxstyle.TextClass(_buffer-> - params.textclass)->defaultfont)) { + bibitemMaxWidth(textclasslist.TextClass(_buffer-> + params.textclass).defaultfont())) { _buffer->text->cursor.par->bibkey->Edit(0, 0); } @@ -1177,7 +1174,7 @@ int BufferView::WorkAreaButtonRelease(FL_OBJECT *ob, Window , * If hit, the coordinates are changed relative to the inset. * Otherwise coordinates are not changed, and false is returned. */ -Inset * BufferView::checkInsetHit(int &x, int &y) +Inset * BufferView::checkInsetHit(int & x, int & y) { if (!getScreen()) return 0; @@ -1272,19 +1269,17 @@ int BufferView::workAreaExpose() // Callback for cursor timer -void BufferView::CursorToggleCB(FL_OBJECT *ob, long) +void BufferView::CursorToggleCB(FL_OBJECT * ob, long) { - BufferView *view = (BufferView*) ob->u_vdata; + BufferView *view = static_cast(ob->u_vdata); /* quite a nice place for asyncron Inset updating, isn't it? */ // actually no! This is run even if no buffer exist... so (Lgb) if (view && !view->_buffer) { goto set_timer_and_return; } -#ifdef WITH_WARNINGS -#warning NOTE! -#endif + // NOTE: // On my quest to solve the gs rendre hangups I am now // disabling the SIGHUP completely, and will do a wait // now and then instead. If the guess that xforms somehow @@ -1312,7 +1307,6 @@ void BufferView::CursorToggleCB(FL_OBJECT *ob, long) // rendering process. // these comments posted to lyx@via -//#if 0 { int status = 1; int pid = waitpid((pid_t)0, &status, WNOHANG); @@ -1321,7 +1315,6 @@ void BufferView::CursorToggleCB(FL_OBJECT *ob, long) else if (pid > 0) sigchldhandler(pid, &status); } -//#endif if (InsetUpdateList) UpdateInsetUpdateList(); @@ -1387,7 +1380,7 @@ int BufferView::WorkAreaSelectionNotify(FL_OBJECT *, Window win, Atom tmpatom; unsigned long ul1; unsigned long ul2; - unsigned char* uc = 0; + unsigned char * uc = 0; int tmpint; screen->HideCursor(); BeforeChange(); @@ -1436,12 +1429,13 @@ int BufferView::WorkAreaSelectionNotify(FL_OBJECT *, Window win, XFlush(fl_display); if (uc){ - if (!ascii_type) + if (!ascii_type) { _buffer->text-> - InsertStringA((char*)uc); - else + InsertStringA(reinterpret_cast(uc)); + } else { _buffer->text-> - InsertStringB((char*)uc); + InsertStringB(reinterpret_cast(uc)); + } free(uc); uc = 0; } @@ -1457,7 +1451,7 @@ void BufferView::cursorPrevious() if (!currentBuffer()->text->cursor.row->previous) return; long y = getScreen()->first; - Row* cursorrow = currentBuffer()->text->cursor.row; + Row * cursorrow = currentBuffer()->text->cursor.row; currentBuffer()->text-> SetCursorFromCoordinates(currentBuffer()->text-> cursor.x_fix, @@ -1506,7 +1500,7 @@ bool BufferView::available() const void BufferView::savePosition() { - backstack->push(currentBuffer()->getFileName(), + backstack.push(currentBuffer()->getFileName(), currentBuffer()->text->cursor.x, currentBuffer()->text->cursor.y); } @@ -1514,13 +1508,13 @@ void BufferView::savePosition() void BufferView::restorePosition() { - if (backstack->empty()) return; + if (backstack.empty()) return; int x, y; - string fname = backstack->pop(&x, &y); + string fname = backstack.pop(&x, &y); BeforeChange(); - Buffer *b = (bufferlist.exists(fname)) ? bufferlist.getBuffer(fname): + Buffer * b = (bufferlist.exists(fname)) ? bufferlist.getBuffer(fname): bufferlist.loadLyXFile(fname); // don't ask, just load it setBuffer(b); currentBuffer()->text->SetCursorFromCoordinates(x, y); diff --git a/src/BufferView.h b/src/BufferView.h index 25157ba325..07bc95f88a 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -1,27 +1,27 @@ // -*- C++ -*- /* This file is part of -* ====================================================== -* -* LyX, The Document Processor -* -* Copyright (C) 1995 Matthias Ettrich -* Copyright (C) 1995-1998 The LyX Team. -* -*======================================================*/ + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright (C) 1995 Matthias Ettrich + * Copyright (C) 1995-1998 The LyX Team. + * + * ======================================================*/ -#ifndef _BUFFER_VIEW_H -#define _BUFFER_VIEW_H +#ifndef BUFFER_VIEW_H +#define BUFFER_VIEW_H #ifdef __GNUG__ #pragma interface #endif #include FORMS_H_LOCATION +#include "BackStack.h" class LyXView; class Buffer; class LyXScreen; -class BackStack; class Inset; /// @@ -29,8 +29,6 @@ class BufferView { public: /// BufferView(LyXView *owner, int ,int ,int, int); - /// - ~BufferView(); /// Buffer *currentBuffer() { return _buffer; } /// @@ -152,7 +150,7 @@ private: /// FL_OBJECT *timer_cursor; /// - BackStack *backstack; + BackStack backstack; /// int last_click_x, last_click_y; }; diff --git a/src/Chktex.C b/src/Chktex.C index dc94696ace..f4f9cf22da 100644 --- a/src/Chktex.C +++ b/src/Chktex.C @@ -61,32 +61,21 @@ int Chktex::scanLogFile(TeXErrors &terr) string token; int retval = 0; - LyXLex lex(0, 0); - string tmp = ChangeExtension(file, ".log", true); - if (!lex.setFile(tmp)) { - // Unable to open file. Return at once - return -1; - } - - while (lex.IsOK()) { - if (lex.EatLine()) - token = lex.GetString(); - else // blank line in the file being read - continue; - + ifstream ifs(tmp.c_str()); + while (getline(ifs, token)) { string srcfile, line, pos, warno, warning; - token=split(token, srcfile, ':'); - token=split(token, line, ':'); - token=split(token, pos, ':'); - token=split(token, warno, ':'); - token=split(token, warning, ':'); + token = split(token, srcfile, ':'); + token = split(token, line, ':'); + token = split(token, pos, ':'); + token = split(token, warno, ':'); + token = split(token, warning, ':'); int lineno = atoi(line.c_str()); warno = _("ChkTeX warning id #") + warno; terr.insertError(lineno, warno, warning); - retval++; + ++retval; } return retval; } diff --git a/src/DepTable.C b/src/DepTable.C index e3a5acc262..dd15f5d042 100644 --- a/src/DepTable.C +++ b/src/DepTable.C @@ -13,46 +13,14 @@ #include +#ifdef __GNUG__ +#pragma implementation +#endif + #include "DepTable.h" #include "support/lyxlib.h" #include "support/filetools.h" - -DepTable::DepTable() -{ - new_sum = 0; - old_sum = 0; - next = 0; -} - - -DepTable::DepTable(string const & f, - bool upd, - unsigned long one, - unsigned long two) -{ - // not quite sure if this is the correct place for MakeAbsPath - file = MakeAbsPath(f); - new_sum = 0; old_sum = 0; - if (one != 0) - new_sum = one; - if (two != 0) - old_sum = two; - if (upd) { - old_sum = new_sum; - new_sum = lyxsum(file.c_str()); - } - if (lyxerr.debugging()) { - char tmp1[256]; - char tmp2[256]; - sprintf(tmp1, "%lu", new_sum); - sprintf(tmp2, "%lu", old_sum); - lyxerr.debug() << "New file inserted in deplog: " - << file << " " - << tmp1 << " " << tmp2 << endl; - } - next = 0; -} - +#include void DepTable::insert(string const & fi, bool upd, @@ -61,42 +29,40 @@ void DepTable::insert(string const & fi, { // not quite sure if this is the correct place for MakeAbsPath string f = MakeAbsPath(fi); - if (f == file) return; // exist already in the log - if (next) - next->insert(f, upd, one, two); - else - next = new DepTable(f, upd, one, two); + if (deplist.find(f) == deplist.end()) { + if (upd) { + one = two; + two = lyxsum(f.c_str()); + } + deplist[f] = make_pair(one, two); + } } void DepTable::update() { - if (!file.empty()) { - old_sum = new_sum; - new_sum = lyxsum(file.c_str()); + for(DepList::iterator itr = deplist.begin(); + itr != deplist.end(); + ++itr) { + unsigned long one = (*itr).second.second; + unsigned long two = lyxsum((*itr).first.c_str()); + (*itr).second = make_pair(one, two); if (lyxerr.debugging()) { - char tmp1[256]; - char tmp2[256]; - sprintf(tmp1, "%lu", new_sum); - sprintf(tmp2, "%lu", old_sum); - lyxerr.debug() << "update: " << file << " " - << tmp1 << " " << tmp2 << endl; + lyxerr << "update: " << (*itr).first << " " + << one << " " << two << endl; } } - if (next) next->update(); } bool DepTable::sumchange() { - bool ret = false; - - if (!file.empty()) { - if (old_sum != new_sum) ret = true; + for (DepList::const_iterator cit = deplist.begin(); + cit != deplist.end(); + ++cit) { + if ((*cit).second.first != (*cit).second.second) return true; } - if (!ret && next) ret = next->sumchange(); - - return ret; + return false; } @@ -104,65 +70,62 @@ bool DepTable::haschanged(string const & f) { // not quite sure if this is the correct place for MakeAbsPath string fil = MakeAbsPath(f); - bool ret = false; - - if (!fil.empty() && !file.empty() && fil == file) { - if (new_sum != old_sum && new_sum != 0) - ret = true; + DepList::const_iterator cit = deplist.find(fil); + if (cit != deplist.end()) { + if ((*cit).second.first != (*cit).second.second + && (*cit).second.second != 0) + return true; } - if (!ret && next) ret = next->haschanged(fil); - return ret; + return false; } -void DepTable::write(string const&f) +bool DepTable::extchanged(string const & ext) { - FilePtr fp(f, FilePtr::write); - if (fp() && next) next->write(fp()); + for (DepList::const_iterator cit = deplist.begin(); + cit != deplist.end(); + ++cit) { + if (suffixIs((*cit).first, ext.c_str())) { + if ((*cit).second.first != (*cit).second.second) + return true; + } + } + + return false; } +void DepTable::write(string const & f) +{ + ofstream ofs(f.c_str()); + for (DepList::const_iterator cit = deplist.begin(); + cit != deplist.end(); + ++cit) { + if (lyxerr.debugging()) { + lyxerr << "Write dep: " + << (*cit).first << " " + << (*cit).second.first << " " + << (*cit).second.second << endl; + } + ofs << (*cit).first << " " + << (*cit).second.first << " " + << (*cit).second.second << endl; + } +} + void DepTable::read(string const &f) { - FilePtr fp(f, FilePtr::read); - if (fp()) { // file opened - char nome[256]; - unsigned long one = 0; - unsigned long two = 0; - // scan the file line by line - // return true if the two numbers on the line is different - int ret = 0; - while (!feof(fp())) { - ret = fscanf(fp(), "%s %lu %lu", - nome, &one, &two); - if (ret !=3) continue; - if (lyxerr.debugging()) { - char tmp1[255]; - char tmp2[255]; - sprintf(tmp1, "%lu", one); - sprintf(tmp2, "%lu", two); - lyxerr.debug() << "read dep: " - << nome << " " << tmp1 - << " " << tmp2 << endl; - } - insert(string(nome), false, one, two); + ifstream ifs(f.c_str()); + string nome; + unsigned long one = 0; + unsigned long two = 0; + while(ifs >> nome >> one >> two) { + if (lyxerr.debugging()) { + lyxerr << "read dep: " + << nome << " " + << one << " " + << two << endl; } + deplist[nome] = make_pair(one, two); } } - - -void DepTable::write(FILE * f) -{ - if (lyxerr.debugging()) { - char tmp1[255]; - char tmp2[255]; - sprintf(tmp1, "%lu", new_sum); - sprintf(tmp2, "%lu", old_sum); - lyxerr << "Write dep: " << file << " " - << tmp1 << " " << tmp2 << endl; - } - fprintf(f, "%s %lu %lu\n", file.c_str(), - new_sum, old_sum); - if (next) - next->write(f); -} diff --git a/src/DepTable.h b/src/DepTable.h index f23e66adb2..0f9b4827fe 100644 --- a/src/DepTable.h +++ b/src/DepTable.h @@ -15,18 +15,19 @@ #define DEP_TABLE_H #include "LString.h" -#include +#include + +#ifdef __GNUG__ +#pragma interface +#endif /// class DepTable { public: - /// - DepTable(); - /// /** This one is a little bit harder since we need the absolute filename. Should we insert files with .sty .cls etc as extension? */ - void insert(string const &f, + void insert(string const & f, bool upd = false, unsigned long one = 0, unsigned long two = 0); @@ -39,25 +40,15 @@ public: void read(string const &f); /// returns true if any of the files has changed bool sumchange(); - /// - bool haschanged(string const &fil); + /// return true if fil has changed. + bool haschanged(string const & fil); + /// return true if a file with extension ext has changed. + bool extchanged(string const & ext); private: /// - DepTable(string const &f, - bool upd, - unsigned long one, - unsigned long two); + typedef map > DepList; /// - string file; - /// The files new checksum - unsigned long new_sum; - /// The files old checksum - unsigned long old_sum; - /// - DepTable *next; - - /// - void write(FILE *f); + DepList deplist; }; #endif diff --git a/src/LaTeX.C b/src/LaTeX.C index b1758d2749..f05672c1c3 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -13,16 +13,12 @@ #include -#include -#include - #ifdef __GNUG__ #pragma implementation #endif #include "support/filetools.h" #include "LaTeX.h" -#include "lyxlex.h" #include "support/FileInfo.h" #include "debug.h" #include "support/lyxlib.h" @@ -33,6 +29,19 @@ #include "minibuffer.h" #include "gettext.h" +// TODO: in no particular order +// - get rid of the extern BufferList and the call to +// BufferList::updateIncludedTeXfiles, this should either +// be done before calling LaTeX::funcs or in a completely +// different way. +// - the bibtex command options should be supported. +// - the makeindex style files should be taken care of with +// the dependency mechanism. +// - makeindex commandline options should be supported +// - somewhere support viewing of bibtex and makeindex log files. +// - we should perhaps also scan the bibtex log file +// - we should perhaps also scan the bibtex log file + extern BufferList bufferlist; struct texfile_struct { @@ -57,174 +66,18 @@ const texfile_struct all_files[] = { { LaTeX::TEX, ".tex"} }; -// This should perhaps be placed in LyXLex -static -string readLine(FILE *file) -{ - if (feof(file)) - return string(); - - int i = 0; - char s[512]; - - do { - s[i] = fgetc(file); - i++; - } while (!feof(file) && s[i-1] != '\n' && i<510); - s[i] = '\0'; - string tmp; - if (i == 1 && feof(file)) - ; - else - tmp = s; - - return tmp; -} - - /* * CLASS TEXERRORS */ -// I did not leave this inlined because DEC cxx does not like -// variables declarations in inlined code (JMarc) -TeXErrors::~TeXErrors() +void TeXErrors::insertError(int line, string const & error_desc, + string const & error_text) { - Error *tmp; - while (errors) { - tmp = errors->next_error; - delete errors; - errors = tmp; - } + Error newerr(line, error_desc, error_text); + errors.push_back(newerr); } - -void TeXErrors::scanError(LyXLex &lex) -{ - string token = lex.GetString(); - // Sometimes the error string goes over more than one - // line, and we need to get them all. - string errstr; - string tmp = frontStrip(readLine(lex.getFile())); - if (tmp == "\n" || tmp.empty()) { - tmp = frontStrip(readLine(lex.getFile())); - if (contains(tmp, "See the LaTeX manual")) { - do { - tmp = readLine(lex.getFile()); - } while (!tmp.empty() && !contains(tmp, "...")); - } - tmp = frontStrip(readLine(lex.getFile())); - } - - while ((tmp != "\n" || !contains(errstr, "l.")) - && !prefixIs(tmp, "! ") - && !contains(tmp, "(job aborted") - && !tmp.empty()) { - errstr += tmp; - tmp = frontStrip(readLine(lex.getFile())); - } - lyxerr.debug() << "tmp: " << errstr << endl; - int line = 0; - // unfortunately the error line is not always given - // by "l.###" in the beginning of the error string - // therefore we must search for "l.###" in the error - // msg. - if (contains(errstr, "l.")) { - // We make a const copy to make [] fast. (Asger) - string const es(errstr); - for (string::size_type i = 2; i < es.length(); ++i) { - if (es[i-2] == 'l' && es[i-1] == '.' && - (es[i] >= '0' && es[i]<= '9')) { - line = atoi(es.c_str() + i); - break; - } - } - } - insertError(line, token, errstr); - - if (prefixIs(tmp, "! ")) { - scanError(lex); - } -} - - -bool TeXErrors::getFirstError(int *line, string *text) -{ - next_error = errors; - if (next_error) { - *line = next_error->error_in_line; - *text = next_error->error_desc + "\n" + next_error->error_text; - next_error = next_error->next_error; - return true; - } - return false; -} - - -bool TeXErrors::getNextError(int *line, string *text) -{ - if (next_error) { - *line = next_error->error_in_line; - *text = next_error->error_desc + "\n" + next_error->error_text; - next_error = next_error->next_error; - return true; - } - return false; -} - - -void TeXErrors::insertError(int line, string const &error_desc, - string const &error_text) -{ - Error *newerr = new Error(line, error_desc, error_text); - if (errors) { - Error *tmperr = errors; - while (tmperr->next_error) tmperr = tmperr->next_error; - tmperr->next_error = newerr; - } else { - errors = newerr; - } -} - - -void TeXErrors::printErrors() -{ - lyxerr << "Printing errors." << endl; - if (errors) { - Error *tmperr = errors; - do { - lyxerr << "Error in line " - << tmperr->error_in_line - << ": " << tmperr->error_desc - << '\n' << tmperr->error_text << endl; - tmperr = tmperr->next_error; - } while (tmperr); - } -} - - -void TeXErrors::printWarnings() -{ -} - - -void TeXErrors::printStatus() -{ - lyxerr << "Error struct:" - << "\n status: " << status - << "\n no err: " << number_of_errors << endl; - if (status == LaTeX::NO_ERRORS) lyxerr << "NO_ERRORS" << endl; - if (status & LaTeX::NO_LOGFILE) lyxerr << "NO_LOGFILE" << endl; - if (status & LaTeX::NO_OUTPUT) lyxerr << "NO_OUTPUT" << endl; - if (status & LaTeX::UNDEF_REF) lyxerr << "UNDEF_REF" << endl; - if (status & LaTeX::RERUN) lyxerr << "RERUN" << endl; - if (status & LaTeX::TEX_ERROR) lyxerr << "TEX_ERROR" << endl; - if (status & LaTeX::TEX_WARNING) lyxerr << "TEX_WARNING" << endl; - if (status & LaTeX::NO_FILE) lyxerr << "NO_FILE" << endl; -} - - /* * CLASS LaTeX */ @@ -239,7 +92,7 @@ LaTeX::LaTeX(string const & latex, string const & f, string const & p) } -int LaTeX::run(TeXErrors &terr, MiniBuffer *minib) +int LaTeX::run(TeXErrors & terr, MiniBuffer * minib) // We know that this function will only be run if the lyx buffer // has been changed. We also know that a newly written .tex file // is always different from the previous one because of the date @@ -274,6 +127,7 @@ int LaTeX::run(TeXErrors &terr, MiniBuffer *minib) // remake the dependency file. // FileInfo fi(depfile); + bool run_bibtex = false; if (fi.exist()) { // Read the dep file: head.read(depfile); @@ -283,6 +137,8 @@ int LaTeX::run(TeXErrors &terr, MiniBuffer *minib) lyxerr[Debug::LATEX] << "Dependency file exists" << endl; if (head.sumchange()) { ++count; + if (head.extchanged(".bib") + || head.extchanged(".bst")) run_bibtex = true; lyxerr[Debug::LATEX] << "Dependency file has changed\n" << "Run #" << count << endl; @@ -322,20 +178,24 @@ int LaTeX::run(TeXErrors &terr, MiniBuffer *minib) // run makeindex if (head.haschanged(ChangeExtension(file, ".idx", true))) { // no checks for now + lyxerr[Debug::LATEX] << "Running MakeIndex." << endl; minib->Set(_("Running MakeIndex.")); minib->Store(); rerun=runMakeIndex(ChangeExtension(file,".idx",true)); } // run bibtex - if (scanres & LaTeX::UNDEF_CIT || scanres & LaTeX::RERUN) { + if (scanres & LaTeX::UNDEF_CIT + || scanres & LaTeX::RERUN + || run_bibtex) { // Here we must scan the .aux file and look for // "\bibdata" and/or "\bibstyle". If one of those // tags is found -> run bibtex and set rerun = true; // no checks for now + lyxerr[Debug::LATEX] << "Running BibTeX." << endl; minib->Set(_("Running BibTeX.")); minib->Store(); - rerun = runBibTeX(ChangeExtension(file, ".aux", true)); + rerun = runBibTeX(ChangeExtension(file, ".aux", true), head); } // 1 @@ -379,6 +239,7 @@ int LaTeX::run(TeXErrors &terr, MiniBuffer *minib) // run makeindex if the .idx has changed or was generated. if (head.haschanged(ChangeExtension(file, ".idx", true))) { // no checks for now + lyxerr[Debug::LATEX] << "Running MakeIndex." << endl; minib->Set(_("Running MakeIndex.")); minib->Store(); rerun = runMakeIndex(ChangeExtension(file, ".idx", true)); @@ -447,59 +308,124 @@ bool LaTeX::runMakeIndex(string const &file) } -bool LaTeX::runBibTeX(string const &file) +typedef pair cmdret; +static cmdret do_popen(string const & cmd) { - LyXLex lex(0, 0); - string token; - if (!lex.setFile(file)) { - // unable to open .aux file - // return at once - return false; + // One question is if we should use popen or + // create our own popen based on fork,exec,pipe + // of course the best would be to have a + // pstream (process stream), with the + // variants ipstream, opstream and + FILE * inf = popen(cmd.c_str(), "r"); + string ret; + int c = fgetc(inf); + while (c != EOF) { + ret += static_cast(c); + c = fgetc(inf); } + int pret = pclose(inf); + return make_pair(pret, ret); +} - while (lex.IsOK()) { - if (lex.EatLine()) - token=lex.GetString(); - else // blank line in the file being read - continue; +static string findtexfile(string const & fil, string const & format) +{ + // If fil is a file with absolute path we just return it + if (AbsolutePath(fil)) return fil; + + // Check in the current dir. + if (FileInfo(OnlyFilename(fil)).exist()) + return OnlyFilename(fil); + + // No we try to find it using kpsewhich. + string kpsecmd = "kpsewhich --format=" + format + " " + fil; + cmdret c = do_popen(kpsecmd); + + lyxerr << "kpse status = " << c.first << "\n" + << "kpse result = `" << strip(c.second, '\n') << "'" << endl; + return c.first == 0 ? strip(c.second, '\n') : string(); +} + + +bool LaTeX::runBibTeX(string const & file, DepTable & dep) +{ + ifstream ifs(file.c_str()); + string token; + bool using_bibtex = false; + while (getline(ifs, token)) { if (contains(token, "\\bibdata{")) { - // run bibtex and - string tmp="bibtex "; - tmp += ChangeExtension(file, string(), true); - Systemcalls one; - one.startscript(Systemcalls::System, tmp); - return true; + using_bibtex = true; + string::size_type a = token.find("\\bibdata{") + 9; + string::size_type b = token.find_first_of("}", a); + string data = token.substr(a, b - a); + // data is now all the bib files separated by ',' + // get them one by one and pass them to the helper + do { + b = data.find_first_of(',', 0); + string l; + if (b == string::npos) + l = data; + else { + l = data.substr(0, b - 0); + data.erase(0, b + 1); + } + string full_l = + findtexfile( + ChangeExtension(l,"bib",false), + "bib"); + lyxerr << "data = `" + << full_l << "'" << endl; + if (!full_l.empty()) { + // add full_l to the dep file. + dep.insert(full_l, true); + } + } while (b != string::npos); + } else if (contains(token, "\\bibstyle{")) { + using_bibtex = true; + string::size_type a = token.find("\\bibstyle{") + 10; + string::size_type b = token.find_first_of("}", a); + string style = token.substr(a, b - a); + // token is now the style file + // pass it to the helper + string full_l = + findtexfile( + ChangeExtension(style, "bst", false), + "bst"); + lyxerr << "style = `" + << full_l << "'" << endl; + if (!full_l.empty()) { + // add full_l to the dep file. + dep.insert(full_l, true); + } } - + } + if (using_bibtex) { + // run bibtex and + string tmp= "bibtex "; + tmp += ChangeExtension(file, string(), true); + Systemcalls one; + one.startscript(Systemcalls::System, tmp); + return true; } // bibtex was not run. return false; } -int LaTeX::scanLogFile(TeXErrors &terr) +int LaTeX::scanLogFile(TeXErrors & terr) { int retval = NO_ERRORS; string tmp = ChangeExtension(file, ".log", true); - - LyXLex lex(0, 0); - if (!lex.setFile(tmp)) { - // unable to open file - // return at once - retval |= NO_LOGFILE; - return retval; - } + lyxerr[Debug::LATEX] << "Log file: " << tmp << endl; + ifstream ifs(tmp.c_str()); string token; - while (lex.IsOK()) { - if (lex.EatLine()) - token = lex.GetString(); - else // blank line in the file being read + while (getline(ifs, token)) { + lyxerr[Debug::LATEX] << "Log line: " << token << endl; + + if (token.empty()) continue; - lyxerr[Debug::LATEX] << token << endl; - if (prefixIs(token, "LaTeX Warning:")) { // Here shall we handle different // types of warnings @@ -528,55 +454,41 @@ int LaTeX::scanLogFile(TeXErrors &terr) // at least longtable.sty might use this. retval |= RERUN; } - } else if (prefixIs(token, "! LaTeX Error:")) { - // Here shall we handle different - // types of errors - retval |= LATEX_ERROR; - lyxerr[Debug::LATEX] << "LaTeX Error." << endl; - // this is not correct yet - terr.scanError(lex); - num_errors++; } else if (prefixIs(token, "! ")) { // Ok, we have something that looks like a TeX Error // but what do we really have. // Just get the error description: - string desc(token); - desc.erase(0, 2); - - if (contains(desc, "Undefined control sequence")) { - retval |= TEX_ERROR; - lyxerr[Debug::LATEX] << "TeX Error." << endl; - terr.scanError(lex); - num_errors++; - } else { - // get the next line - lex.next(); - string tmp = lex.GetString(); - if (prefixIs(tmp, "l.")) { + string desc(token, 2); + if (contains(token, "LaTeX Error:")) + retval |= LATEX_ERROR; + // get the next line + string tmp; + getline(ifs, tmp); + if (prefixIs(tmp, "l.")) { // we have a latex error - retval |= TEX_ERROR; - lyxerr[Debug::LATEX] - <<"TeX Error." << endl; + retval |= TEX_ERROR; // get the line number: - int line = 0; - sscanf(tmp.c_str(), "l.%d", &line); + int line = 0; + sscanf(tmp.c_str(), "l.%d", &line); // get the rest of the message: - string errstr; - lex.EatLine(); - tmp = lex.GetString(); - while ((tmp != "\n" || !contains(errstr, "l.")) - && !prefixIs(tmp, "! ") - && !contains(tmp, "(job aborted") - && !tmp.empty()) { - errstr += tmp; - errstr += "\n"; - lex.EatLine(); - tmp = lex.GetString(); - } - terr.insertError(line, desc, errstr); - num_errors++; + string errstr(tmp, tmp.find(' ')); + errstr += '\n'; + getline(ifs, tmp); + while (!contains(errstr, "l.") + && !tmp.empty() + && !prefixIs(tmp, "! ") + && !contains(tmp, "(job aborted")) { + errstr += tmp; + errstr += "\n"; + getline(ifs, tmp); } + lyxerr[Debug::LATEX] + << "line: " << line << '\n' + << "Desc: " << desc << '\n' + << "Text: " << errstr << endl; + terr.insertError(line, desc, errstr); + num_errors++; } } else { // information messages, TeX warnings and other @@ -596,7 +508,8 @@ int LaTeX::scanLogFile(TeXErrors &terr) retval |= TOO_MANY_ERRORS; } } - } + } + lyxerr[Debug::LATEX] << "Log line: " << token << endl; return retval; } @@ -608,33 +521,28 @@ void LaTeX::deplog(DepTable & head) // dependency file. string logfile = ChangeExtension(file, ".log", true); - FilePtr in(logfile, FilePtr::read); - bool not_eof = true; - if (in()) while (not_eof) { // We were able to open the file + + ifstream ifs(logfile.c_str()); + while (ifs) { // Now we read chars until we find a '(' - int c; - do { - c = fgetc(in()); - } while (c != EOF && c != '('); - if (c == EOF) { - // Nothing more we can do - not_eof = false; - continue; - } - + char c = 0; + while(ifs.get(c)) { + if (c == '(') break; + }; + if (!ifs) break; + // We now have c == '(', we now read the the sequence of - // chars until reaching EOL, or ' ' and put that into a string. - + // chars until reaching EOL, ' ' or ')' and put that + // into a string. string foundfile; - c = fgetc(in()); - while (c != '\n' && c != ' ' && c != ')') { - foundfile += char(c); - c = fgetc(in()); + while (ifs.get(c)) { + if (c == '\n' || c == ' ' || c == ')') + break; + foundfile += c; } - if (foundfile.empty()) continue; - lyxerr[Debug::LATEX] << "Found file: " << foundfile << endl; + // Ok now we found a file. // Now we should make sure that // this is a file that we can @@ -677,23 +585,6 @@ void LaTeX::deplog(DepTable & head) } continue; } - - // (3) the foundfile can be - // found in the same dir - // as the .lyx file and - // should be inserted. - Path p(path); - if (FileInfo(foundfile).exist()) { - lyxerr << "LyX Strange: this should actually never" - " happen anymore, this it should be" - " handled by the Absolute check." - << endl; - lyxerr[Debug::LATEX] << "Same Directory file: " - << foundfile << endl; - head.insert(foundfile); - continue; - } - lyxerr[Debug::LATEX] << "Not a file or we are unable to find it." << endl; @@ -701,12 +592,12 @@ void LaTeX::deplog(DepTable & head) } -void LaTeX::deptex(DepTable &head) +void LaTeX::deptex(DepTable & head) { int except = AUX|LOG|DVI|BBL|IND|GLO; string tmp; FileInfo fi; - for (int i = 0; i < file_count; i++) { + for (int i = 0; i < file_count; ++i) { if (!(all_files[i].file & except)) { tmp = ChangeExtension(file, all_files[i].extension, diff --git a/src/LaTeX.h b/src/LaTeX.h index 99e3a56e26..e81348eca5 100644 --- a/src/LaTeX.h +++ b/src/LaTeX.h @@ -21,65 +21,23 @@ #include "LString.h" #include "DepTable.h" +#include +#include -class LyXLex; class MiniBuffer; /// class TeXErrors { -public: - /// - TeXErrors() { - errors = 0; - next_error = 0; - status = 0; - number_of_errors = 0; - } - /// - ~TeXErrors(); - /// - void scanError(LyXLex &); - /// - bool getFirstError(int *line, string *text); - /// - bool getNextError(int *line, string *text); - /// - void insertError(int line, string const &error_desc, - string const &error_text); - /// - void printErrors(); - /// - void printWarnings(); - /// - void printStatus(); - /// - int getStatus() { return status; } private: - /// - friend class LaTeX; - /// - int status; - /// - int number_of_errors; /// struct Error { /// - Error () { - next_error = 0; - error_in_line = 0; - } + Error () : error_in_line(0) {} /// - Error(int line, string const &desc, string const &text) { - next_error = 0; - error_in_line = line; - error_desc = desc; - error_text = text; - } - /// - ~Error() { - } - /// - Error *next_error; + Error(int line, string const & desc, string const & text) + : error_in_line(line), + error_desc(desc), + error_text(text) {} /// what line in the TeX file the error occured in int error_in_line; /// The kind of error @@ -87,10 +45,19 @@ private: /// The line/cmd that caused the error. string error_text; }; +public: /// - Error *errors; + typedef vector Errors; /// - Error *next_error; + Errors::const_iterator begin() const { return errors.begin(); } + /// + Errors::const_iterator end() const { return errors.end(); } + /// + void insertError(int line, string const & error_desc, + string const & error_text); +private: + /// + Errors errors; }; @@ -98,10 +65,10 @@ private: class LaTeX { public: /** All the different files produced by TeX. - - This is the files mentioned on page 208-9 in Lamports book + - .ltx and .tex files. - */ + + This is the files mentioned on page 208-9 in Lamports book + + .ltx and .tex files. + */ enum TEX_FILES { /// NO_FILES = 0, @@ -175,9 +142,9 @@ public: /** - cmd = the latex command, file = name of the (temporary) latex file, - path = name of the files original path. - */ + cmd = the latex command, file = name of the (temporary) latex file, + path = name of the files original path. + */ LaTeX(string const & cmd, string const & file, string const & path); /// runs LaTeX several times @@ -189,19 +156,13 @@ public: /// use this for running LaTeX once int operator() (); protected: - /** The dependency file. - - We store the file dependencies in this file. - the depency file is on the format: - - */ + /// The dependency file. string depfile; - /// - LaTeX() {} - - /// - LaTeX(LaTeX const &) {} + /// unavail + LaTeX(LaTeX const &); + /// unavail + LaTeX & operator=(LaTeX const &); /// void deplog(DepTable & head); @@ -216,7 +177,7 @@ protected: bool runMakeIndex(string const &); /// - bool runBibTeX(string const &); + bool runBibTeX(string const &, DepTable &); /// string cmd; diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index 21cf9e4d11..6c2c72669b 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -77,7 +77,7 @@ LaTeXFeatures::LaTeXFeatures(int n) string LaTeXFeatures::getPackages(BufferParams const ¶ms) { string packages; - LyXTextClass *tclass = lyxstyle.TextClass(params.textclass); + LyXTextClass const & tclass = textclasslist.TextClass(params.textclass); // color.sty if (color) { @@ -90,7 +90,7 @@ string LaTeXFeatures::getPackages(BufferParams const ¶ms) // makeidx.sty if (makeidx) { - if (! tclass->provides_makeidx + if (! tclass.provides(LyXTextClass::makeidx) && params.language != "french") // french provides // \index ! packages += "\\usepackage{makeidx}\n"; @@ -167,7 +167,7 @@ string LaTeXFeatures::getPackages(BufferParams const ¶ms) packages += "\\usepackage{floatflt}\n"; // url.sty - if (url && ! tclass->provides_url) + if (url && ! tclass.provides(LyXTextClass::url)) packages += "\\IfFileExists{url.sty}{\\usepackage{url}}\n" " {\\newcommand{\\url}{\\texttt}}\n"; @@ -226,24 +226,22 @@ string LaTeXFeatures::getMacros(BufferParams const & /* params */) } -string LaTeXFeatures::getTClassPreamble(BufferParams const ¶ms) +string LaTeXFeatures::getTClassPreamble(BufferParams const & params) { // the text class specific preamble - LyXTextClass *tclass = lyxstyle.TextClass(params.textclass); - string tcpreamble = tclass->preamble; + LyXTextClass const & tclass = textclasslist.TextClass(params.textclass); + string tcpreamble = tclass.preamble(); - int l; - for (l = 0 ; l < tclass->number_of_defined_layouts ; l++) { - if (layout[l] - && !tclass->style[l].preamble.empty()) - tcpreamble += tclass->style[l].preamble; + for (LyXTextClass::LayoutList::const_iterator cit = tclass.begin(); + cit != tclass.end(); ++cit) { + tcpreamble += (*cit).preamble(); } return tcpreamble; } -void LaTeXFeatures::showStruct(BufferParams ¶ms) { +void LaTeXFeatures::showStruct(BufferParams & params) { lyxerr << "LyX needs the following commands when LaTeXing:" // packs << "\n***** Packages:" << getPackages(params) diff --git a/src/Literate.C b/src/Literate.C index a91a40b267..0be43b8162 100644 --- a/src/Literate.C +++ b/src/Literate.C @@ -10,9 +10,6 @@ #include -#include -#include - #ifdef __GNUG__ #pragma implementation #endif @@ -20,7 +17,6 @@ #include "support/filetools.h" #include "LaTeX.h" #include "Literate.h" -#include "lyxlex.h" #include "support/FileInfo.h" #include "debug.h" #include "support/lyxlib.h" @@ -37,15 +33,14 @@ Literate::Literate(string const & latex, string const & f, string const & p, string const & l, string const & literate, string const & literate_f, string const & build, string const & build_f) - : LaTeX (latex, f, p), + : LaTeX(latex, f, p), litfile(l), literate_cmd(literate), literate_filter(literate_f), build_cmd(build), build_filter(build_f) -{ -} +{} -int Literate::weave(TeXErrors &terr, MiniBuffer *minib) +int Literate::weave(TeXErrors & terr, MiniBuffer * minib) { int scanres = Literate::NO_ERRORS; string tmp1, tmp2; @@ -66,21 +61,18 @@ int Literate::weave(TeXErrors &terr, MiniBuffer *minib) ret1 = one.startscript(Systemcalls::System, tmp1); ret2 = two.startscript(Systemcalls::System, tmp2); lyxerr.debug() << "LITERATE {" << tmp1 << "} {" << tmp2 << "}" << endl; - scanres = scanLiterateLogFile(terr); + scanres = scanLiterateLogFile(); if (scanres & Literate::ERRORS) return scanres; // return on literate error - return run(terr, minib); } -int Literate::build(TeXErrors &terr, MiniBuffer *minib) +int Literate::build(TeXErrors & terr, MiniBuffer * minib) // We know that this function will only be run if the lyx buffer // has been changed. { int scanres = Literate::NO_ERRORS; num_errors = 0; // just to make sure. - // DepTable head; // empty head // unused - // bool rerun = false; // rerun requested // unused string tmp1, tmp2; int ret1, ret2; Systemcalls one, two; @@ -98,35 +90,22 @@ int Literate::build(TeXErrors &terr, MiniBuffer *minib) tmp2 = build_filter + " < " + litfile + ".out" + " > " + litfile + ".log"; ret1 = one.startscript(Systemcalls::System, tmp1); ret2 = two.startscript(Systemcalls::System, tmp2); - scanres = scanBuildLogFile(terr); + scanres = scanBuildLogFile(); lyxerr[Debug::LATEX] << "Done." << endl; return scanres; } -int Literate::scanLiterateLogFile(TeXErrors &terr) +int Literate::scanLiterateLogFile() { string token; int retval = NO_ERRORS; - LyXLex lex(0, 0); - string tmp = litfile + ".log"; - if (!lex.setFile(tmp)) { - // unable to open file - // return at once - retval |= NO_LOGFILE; - return retval; - } - - while (lex.IsOK()) { - if (lex.EatLine()) - token = lex.GetString(); - else // blank line in the file being read - continue; - + ifstream ifs(tmp.c_str()); + while (getline(ifs, token)) { lyxerr[Debug::LATEX] << token << endl; if (prefixIs(token, "Build Warning:")) { @@ -140,7 +119,6 @@ int Literate::scanLiterateLogFile(TeXErrors &terr) retval |= LATEX_ERROR; lyxerr[Debug::LATEX] << "Build Error." << endl; // this is not correct yet - terr.scanError(lex); num_errors++; } } @@ -148,28 +126,15 @@ int Literate::scanLiterateLogFile(TeXErrors &terr) } -int Literate::scanBuildLogFile(TeXErrors &terr) +int Literate::scanBuildLogFile() { string token; int retval = NO_ERRORS; - - LyXLex lex(0, 0); string tmp = litfile + ".log"; - if (!lex.setFile(tmp)) { - // unable to open file - // return at once - retval |= NO_LOGFILE; - return retval; - } - - while (lex.IsOK()) { - if (lex.EatLine()) - token = lex.GetString(); - else // blank line in the file being read - continue; - + ifstream ifs(tmp.c_str()); + while (getline(ifs, token)) { lyxerr[Debug::LATEX] << token << endl; if (prefixIs(token, "Build Warning:")) { @@ -183,11 +148,8 @@ int Literate::scanBuildLogFile(TeXErrors &terr) retval |= LATEX_ERROR; lyxerr[Debug::LATEX] << "Build Error." << endl; // this is not correct yet - terr.scanError(lex); num_errors++; } } return retval; } - - diff --git a/src/Literate.h b/src/Literate.h index 17827c36ac..020a0b024b 100644 --- a/src/Literate.h +++ b/src/Literate.h @@ -5,24 +5,20 @@ * LyX, The Document Processor * Copyright (C) 1995 Matthias Ettrich * - * This file is Copyright (C) 1996-1998 - * Lars Gullik Bjønnes - * *====================================================== */ -#ifndef _LITERATE_H -#define _LITERATE_H +#ifndef LITERATE_H +#define LITERATE_H #ifdef __GNUG__ #pragma interface #endif -#include "LString.h" -#include "DepTable.h" - +class MiniBuffer; + /// -class Literate: public LaTeX { +class Literate : public LaTeX { public: Literate(string const & cmd, string const & file, string const & path, string const & litfile, @@ -32,16 +28,17 @@ public: /// runs literate and latex int weave(TeXErrors &, MiniBuffer *); - /// - int scanLiterateLogFile(TeXErrors &); - /// runs literate and build int build(TeXErrors &, MiniBuffer *); - /// - int scanBuildLogFile(TeXErrors &); private: + /// + int scanLiterateLogFile(); + + /// + int scanBuildLogFile(); + /// string litfile; diff --git a/src/LyXSendto.C b/src/LyXSendto.C index 34285484e6..539755b3a1 100644 --- a/src/LyXSendto.C +++ b/src/LyXSendto.C @@ -13,10 +13,10 @@ #include "gettext.h" #include "lyx_cb.h" -extern FD_form_sendto *fd_form_sendto; -extern BufferView *current_view; -extern int MakeDVIOutput(Buffer *buffer); -extern bool MenuRunDvips(Buffer *buffer, bool wait); +extern FD_form_sendto * fd_form_sendto; +extern BufferView * current_view; +extern int MakeDVIOutput(Buffer * buffer); +extern bool MenuRunDvips(Buffer * buffer, bool wait); // Whereas this feature is under the menu item File->Export->Custom, // I kept the old name sendto in the code because I am lazy (JMarc) @@ -82,7 +82,7 @@ void SendtoApplyCB(FL_OBJECT *, long) ftypeext, true)); if (!contains(command, "$$FName")) command = "( " + command + " ) <$$FName"; - command = subst(command, "$$FName",fname); + command = subst(command, "$$FName", fname); command += " &"; // execute in background // push directorypath, if necessary string path = OnlyPath(buffer->getFileName()); diff --git a/src/LyXView.C b/src/LyXView.C index b9b600c831..5e2b9ba3e1 100644 --- a/src/LyXView.C +++ b/src/LyXView.C @@ -291,20 +291,20 @@ void LyXView::updateLayoutChoice() // If textclass is different, we need to update the list if (toolbar->combox->empty() || - (last_textclass != currentBuffer()->params.textclass)) { + (last_textclass != int(currentBuffer()->params.textclass))) { toolbar->combox->clear(); for (int i = 0; - lyxstyle.NameOfLayout(currentBuffer()-> + textclasslist.NameOfLayout(currentBuffer()-> params.textclass, i) !="@@end@@"; i++) { - LyXLayout *layout = lyxstyle. + LyXLayout const & layout = textclasslist. Style(currentBuffer()->params.textclass, i); - if (layout->obsoleted_by.empty()) - toolbar->combox->addline(layout->name.c_str()); + if (layout.obsoleted_by().empty()) + toolbar->combox->addline(layout.name().c_str()); else - toolbar->combox->addline(("@N"+layout->name).c_str()); + toolbar->combox->addline(("@N"+layout.name()).c_str()); } - last_textclass = currentBuffer()->params.textclass; + last_textclass = int(currentBuffer()->params.textclass); current_layout = 0; } // we need to do this. @@ -325,9 +325,9 @@ void LyXView::UpdateDocumentClassChoice() int i; if (fd_form_document) { fl_clear_choice(fd_form_document->choice_class); - for (i = 0; lyxstyle.DescOfClass (i)!="@@end@@"; i++) { + for (i = 0; textclasslist.DescOfClass (i)!="@@end@@"; i++) { fl_addto_choice(fd_form_document->choice_class, - lyxstyle.DescOfClass(i).c_str()); + textclasslist.DescOfClass(i).c_str()); } } } diff --git a/src/LyXView.h b/src/LyXView.h index 94f46f676d..0f6d459792 100644 --- a/src/LyXView.h +++ b/src/LyXView.h @@ -1,16 +1,16 @@ // -*- C++ -*- /* This file is part of -* ====================================================== -* -* LyX, The Document Processor -* -* Copyright (C) 1995 Matthias Ettrich -* Copyright (C) 1995-1998 The LyX Team. -* -*======================================================*/ + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 1995 Matthias Ettrich + * Copyright 1995-1998 The LyX Team. + * + * ====================================================== */ -#ifndef _LyXView_H_ -#define _LyXView_H_ +#ifndef LyXView_H +#define LyXView_H #ifdef __GNUG__ #pragma interface @@ -21,6 +21,8 @@ #include "buffer.h" #include "menus.h" #include "BufferView.h" +#include "layout.h" + class LyXFunc; class Toolbar; class MiniBuffer; @@ -59,7 +61,7 @@ public: void setPosition(int, int); /// Show the main form. - void show(int, int, char const* t= "LyX"); + void show(int, int, char const * t= "LyX"); /// init (should probably be removed later) (Lgb) void init(); @@ -68,28 +70,28 @@ public: void redraw(); /// returns the buffer currently shown in the main form. - Buffer *currentBuffer(){ return bufferview->currentBuffer();} + Buffer * currentBuffer(){ return bufferview->currentBuffer();} /// - BufferView *currentView() { return bufferview; } + BufferView * currentView() { return bufferview; } /// returns a pointer to the form. - FL_FORM *getForm() { return _form; } + FL_FORM * getForm() { return _form; } /// return a pointer to the toolbar - Toolbar *getToolbar() { return toolbar; } + Toolbar * getToolbar() { return toolbar; } /// return a pointer to the lyxfunc - LyXFunc *getLyXFunc() { return lyxfunc; } + LyXFunc * getLyXFunc() { return lyxfunc; } /// return a pointer to the minibuffer - MiniBuffer *getMiniBuffer() { return minibuffer; } + MiniBuffer * getMiniBuffer() { return minibuffer; } /// - Menus *getMenus() { return menus; } + Menus * getMenus() { return menus; } /// - Intl *getIntl() { return intl; } + Intl * getIntl() { return intl; } /// void updateLayoutChoice(); @@ -101,27 +103,27 @@ public: void resetAutosaveTimer(); private: /// - LyXFunc *lyxfunc; + LyXFunc * lyxfunc; /// - Toolbar *toolbar; + Toolbar * toolbar; /// - MiniBuffer *minibuffer; + MiniBuffer * minibuffer; /// - Menus *menus; + Menus * menus; /// - Intl *intl; + Intl * intl; /** This is supposed to be a pointer or a list of pointers to the BufferViews currently being shown in the LyXView. So far this is not used, but that should change pretty soon. (Lgb) */ - BufferView *bufferview; + BufferView * bufferview; /// void invalidateLayoutChoice(); /// void UpdateDocumentClassChoice(); public: /// - static int KeyPressMask_raw_callback(FL_FORM *, void *xev); + static int KeyPressMask_raw_callback(FL_FORM *, void * xev); /** This callback is run when a close event is sent from the window manager. */ static int atCloseMainFormCB(FL_FORM *, void *); @@ -131,17 +133,15 @@ public: static void UpdateTimerCB(FL_OBJECT *, long); private: /// makes the main form. - FD_form_main *create_form_form_main(int width, int height); + FD_form_main * create_form_form_main(int width, int height); /// A pointer to the form. - FD_form_main *_form_main; + FD_form_main * _form_main; /// A pointer to the form. - FL_FORM *_form; + FL_FORM * _form; /** The last textclass layout list in the layout choice selector This should probably be moved to the toolbar, but for now it's here. (Asger) */ int last_textclass; }; - - #endif diff --git a/src/PaperLayout.C b/src/PaperLayout.C index a023143bdb..193db2a8d2 100644 --- a/src/PaperLayout.C +++ b/src/PaperLayout.C @@ -16,9 +16,9 @@ #include "BufferView.h" #include "gettext.h" -extern FD_form_paper *fd_form_paper; -extern MiniBuffer *minibuffer; -extern BufferView *current_view; +extern FD_form_paper * fd_form_paper; +extern MiniBuffer * minibuffer; +extern BufferView * current_view; inline void DeactivatePaperButtons () @@ -89,11 +89,7 @@ static void checkMarginValues() fl_hide_object(fd_form_paper->text_warning); ActivatePaperButtons(); -#if 0 - val = fl_get_choice(fd_form_paper->choice_papersize2)-1; - if (val == VM_PAPER_DEFAULT) - return; -#endif + allEmpty = (!strlen(fl_get_input(fd_form_paper->input_top_margin)) && !strlen(fl_get_input(fd_form_paper->input_bottom_margin)) && !strlen(fl_get_input(fd_form_paper->input_left_margin)) && @@ -188,9 +184,9 @@ void PaperApplyCB(FL_OBJECT *, long) if (! current_view->available()) return; - BufferParams *params = ¤t_view->currentBuffer()->params; + BufferParams * params = ¤t_view->currentBuffer()->params; - const FD_form_paper* fd = fd_form_paper; + FD_form_paper const * fd = fd_form_paper; params->papersize2 = fl_get_choice(fd->choice_papersize2)-1; params->paperpackage = fl_get_choice(fd->choice_paperpackage)-1; @@ -222,21 +218,18 @@ void PaperCancelCB(FL_OBJECT *, long) } -void PaperOKCB(FL_OBJECT *ob, long data) +void PaperOKCB(FL_OBJECT * ob, long data) { PaperCancelCB(ob,data); PaperApplyCB(ob,data); } -void PaperMarginsCB(FL_OBJECT *ob, long) +void PaperMarginsCB(FL_OBJECT * ob, long) { - const FD_form_paper - *fd = fd_form_paper; - string - str; - char - val; + FD_form_paper const * fd = fd_form_paper; + string str; + char val; checkMarginValues(); if (ob == fd->choice_papersize2) { @@ -258,11 +251,15 @@ void PaperMarginsCB(FL_OBJECT *ob, long) fl_set_choice(fd->choice_papersize2, VM_PAPER_DEFAULT + 1); fl_set_button(fd->push_use_geometry, 0); } - } else if ((ob==fd->input_custom_width) || (ob==fd->input_custom_height) || - (ob==fd->input_left_margin) || (ob==fd->input_right_margin) || - (ob==fd->input_top_margin) || (ob==fd->input_bottom_margin) || - (ob==fd->input_head_height) || (ob==fd->input_head_sep) || - (ob==fd->input_foot_skip)) { + } else if ((ob==fd->input_custom_width) + || (ob==fd->input_custom_height) + || (ob==fd->input_left_margin) + || (ob==fd->input_right_margin) + || (ob==fd->input_top_margin) + || (ob==fd->input_bottom_margin) + || (ob==fd->input_head_height) + || (ob==fd->input_head_sep) + || (ob==fd->input_foot_skip)) { str = fl_get_input(ob); if (!str.empty() && !isValidLength(str)) { fl_set_object_label(fd_form_paper->text_warning, diff --git a/src/ParagraphExtra.C b/src/ParagraphExtra.C index 41773763e1..934fd3d270 100644 --- a/src/ParagraphExtra.C +++ b/src/ParagraphExtra.C @@ -171,9 +171,8 @@ void ParagraphExtraApplyCB(FL_OBJECT *, long) *widthp = fl_get_input(fd->input_pextra_widthp); LyXText *text = current_view->currentBuffer()->text; - int - type = PEXTRA_NONE, - alignment = 0; + int type = PEXTRA_NONE; + int alignment = 0; bool hfill = false, start_minipage = false; @@ -196,10 +195,8 @@ void ParagraphExtraApplyCB(FL_OBJECT *, long) } text->SetParagraphExtraOpt(type,width,widthp,alignment,hfill, start_minipage); -// current_view->redoCurrentBuffer(); current_view->currentBuffer()->update(1); minibuffer->Set(_("ParagraphExtra layout set")); -// current_view->currentBuffer()->markDirty(); } return; } diff --git a/src/TableLayout.C b/src/TableLayout.C index 9bb11361ff..7f7c259fdd 100644 --- a/src/TableLayout.C +++ b/src/TableLayout.C @@ -15,6 +15,7 @@ #include "lyxscreen.h" #include "gettext.h" #include "lyxtext.h" +#include "layout.h" extern void BeforeChange(); diff --git a/src/broken_headers.h b/src/broken_headers.h index d2e51ee41e..dd97486bba 100644 --- a/src/broken_headers.h +++ b/src/broken_headers.h @@ -9,8 +9,8 @@ *====================================================== A few prototypes missing from Sun and SCO 3.2v4 header files */ -#ifndef _BROKEN_HEADERS_H -#define _BROKEN_HEADERS_H +#ifndef BROKEN_HEADERS_H +#define BROKEN_HEADERS_H #ifdef __cplusplus extern "C" { diff --git a/src/buffer.C b/src/buffer.C index d7cd5a4c06..88e9270fa0 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -138,8 +138,8 @@ Buffer::~Buffer() DestroyBufferTmpDir(tmppath); } - LyXParagraph *par = paragraph; - LyXParagraph *tmppar; + LyXParagraph * par = paragraph; + LyXParagraph * tmppar; while (par) { tmppar = par->next; delete par; @@ -240,7 +240,7 @@ bool Buffer::insertLyXFile(string const & filen) bool res = true; - if (c=='#') { + if (c == '#') { lyxerr.debug() << "Will insert file with header" << endl; res = readFile(lex, text->cursor.par); } else { @@ -261,7 +261,7 @@ bool Buffer::insertLyXFile(string const & filen) bool Buffer::readLyXformat2(LyXLex &lex, LyXParagraph *par) { string tmptok; - Inset *inset = 0; + Inset * inset = 0; int pos = 0; int tmpret, tmpret2; char depth = 0; // signed or unsigned? @@ -330,19 +330,23 @@ bool Buffer::readLyXformat2(LyXLex &lex, LyXParagraph *par) par = new LyXParagraph(par); pos = 0; lex.EatLine(); - par->layout = - lyxstyle.NumberOfLayout(params.textclass, - lex.GetString()); - if (par->layout == -1) // layout not found + string layoutname = lex.GetString(); + pair pp + = textclasslist.NumberOfLayout(params.textclass, + layoutname); + if (pp.first) { + par->layout = pp.second; + } else { // layout not found // use default layout "Standard" (0) par->layout = 0; + } // Test whether the layout is obsolete. - LyXLayout* layout = lyxstyle.Style(params.textclass, - par->layout); - if (!layout->obsoleted_by.empty()) + LyXLayout const & layout = textclasslist.Style(params.textclass, + par->layout); + if (!layout.obsoleted_by().empty()) par->layout = - lyxstyle.NumberOfLayout(params.textclass, - layout->obsoleted_by); + textclasslist.NumberOfLayout(params.textclass, + layout.obsoleted_by()).second; par->footnoteflag = footnoteflag; par->footnotekind = footnotekind; par->depth = depth; @@ -381,12 +385,15 @@ bool Buffer::readLyXformat2(LyXLex &lex, LyXParagraph *par) params.readPreamble(lex); } else if (token == "\\textclass") { lex.EatLine(); - params.textclass = lyxstyle.NumberOfClass(lex.GetString()); - if (params.textclass == -1) { + pair pp = + textclasslist.NumberOfClass(lex.GetString()); + if (pp.first) { + params.textclass = pp.second; + } else { lex.printError("Unknown textclass `$$Token'"); params.textclass = 0; } - if (!lyxstyle.Load(params.textclass)) { + if (!textclasslist.Load(params.textclass)) { // if the textclass wasn't loaded properly // we need to either substitute another // or stop loading the file. @@ -394,7 +401,7 @@ bool Buffer::readLyXformat2(LyXLex &lex, LyXParagraph *par) // stop loading... ideas?? ARRae980418 WriteAlert(_("Textclass Loading Error!"), string(_("Can't load textclass ")) + - lyxstyle.NameOfClass(params.textclass), + textclasslist.NameOfClass(params.textclass), _("-- substituting default")); params.textclass = 0; } @@ -548,7 +555,11 @@ bool Buffer::readLyXformat2(LyXLex &lex, LyXParagraph *par) params.columns = lex.GetInteger(); } else if (token == "\\papersides") { lex.nextToken(); - params.sides = lex.GetInteger(); + switch(lex.GetInteger()) { + default: + case 1: params.sides = LyXTextClass::OneSide; break; + case 2: params.sides = LyXTextClass::TwoSides; break; + } } else if (token == "\\paperpagestyle") { lex.nextToken(); params.pagestyle = strip(lex.GetString()); @@ -683,7 +694,7 @@ bool Buffer::readLyXformat2(LyXLex &lex, LyXParagraph *par) tmpret2 = 1; for (; tmpret>0; tmpret--) tmpret2 = tmpret2 * 2; - par->align = tmpret2; + par->align = LyXAlignment(tmpret2); } } else if (token == "\\added_space_top"){ lex.nextToken(); @@ -858,8 +869,7 @@ bool Buffer::readLyXformat2(LyXLex &lex, LyXParagraph *par) } else if (tmptok == "Label") { // Kept for compability. Remove in 0.13. if (lex.EatLine()) { - string tmp; - tmp += "\\label{"; + string tmp = "\\label{"; tmp += lex.GetString(); tmp += '}'; inset = new InsetLabel(tmp); @@ -1070,7 +1080,7 @@ bool Buffer::readLyXformat2(LyXLex &lex, LyXParagraph *par) } -bool Buffer::readFile(LyXLex &lex, LyXParagraph *par) +bool Buffer::readFile(LyXLex & lex, LyXParagraph * par) { string token; @@ -1207,10 +1217,8 @@ void Buffer::writeFileAscii(string const & filename, int linelen) FilePtr file(filename, FilePtr::write); LyXFont font1, font2; - Inset - *inset; - LyXParagraph - *par = paragraph; + Inset * inset; + LyXParagraph * par = paragraph; char c, footnoteflag = 0, @@ -1219,9 +1227,14 @@ void Buffer::writeFileAscii(string const & filename, int linelen) string fname1, tmp; - + +#ifdef NEW_TEXT + LyXParagraph::size_type i; +#else + int i; +#endif int - i,j,h, + j,h, ltype=0, ltype_depth=0, noparbreak=0, @@ -1278,7 +1291,7 @@ void Buffer::writeFileAscii(string const & filename, int linelen) } /* First write the layout */ - tmp = lyxstyle.NameOfLayout(params.textclass,par->layout); + tmp = textclasslist.NameOfLayout(params.textclass,par->layout); if (tmp == "Itemize") { ltype = 1; ltype_depth = depth+1; @@ -1337,7 +1350,11 @@ void Buffer::writeFileAscii(string const & filename, int linelen) cells = par->table->columns; clen = new int [cells]; memset(clen,0,sizeof(int)*cells); +#ifdef NEW_TEXT + for (i = 0, j = 0, h = 1; i < par->size(); ++i, ++h) { +#else for (i = 0, j = 0, h=1; i < par->last; i++, h++) { +#endif c = par->GetChar(i); if (c == LYX_META_INSET) { if ((inset = par->GetInset(i))) { @@ -1365,7 +1382,11 @@ void Buffer::writeFileAscii(string const & filename, int linelen) font1 = LyXFont(LyXFont::ALL_INHERIT); actcell=0; +#ifdef NEW_TEXT + for (i = 0, actpos = 1; i < par->size(); ++i, ++actpos) { +#else for (i = 0,actpos=1; i < par->last; i++, actpos++) { +#endif if (!i && !footnoteflag && !noparbreak){ fprintf(file, "\n\n"); for(j=0; j linelen - 10 + && c == ' ' && i + 2 < par->size()) { +#else if (currlinelen > (linelen-10) \ && c==' ' && (i+2 < par->last)) { +#endif fprintf(file, "\n"); - for(j=0; j depth) { - for(j=ltype_depth; j>depth; j--) + for(j = ltype_depth; + j > depth; --j) fprintf(file, " "); currlinelen += (ltype_depth-depth)*2; } @@ -1550,7 +1577,7 @@ void Buffer::makeLaTeXFile(string const & filename, tex_code_break_column = lyxrc->ascii_linelen; - LyXTextClass *tclass = lyxstyle.TextClass(params.textclass); + LyXTextClass const & tclass = textclasslist.TextClass(params.textclass); FilePtr file(filename, FilePtr::write); if (!file()) { @@ -1560,7 +1587,7 @@ void Buffer::makeLaTeXFile(string const & filename, // validate the buffer. lyxerr[Debug::LATEX] << " Validating buffer..." << endl; - LaTeXFeatures features(tclass->number_of_defined_layouts); + LaTeXFeatures features(tclass.numLayouts()); validate(features); lyxerr[Debug::LATEX] << " Buffer validation done." << endl; @@ -1616,7 +1643,7 @@ void Buffer::makeLaTeXFile(string const & filename, string options; // the document class options. - if (tokenPos(tclass->opt_fontsize, '|',params.fontsize) >= 0) { + if (tokenPos(tclass.opt_fontsize(), '|',params.fontsize) >= 0) { // only write if existing in list (and not default) options += params.fontsize; options += "pt,"; @@ -1648,7 +1675,7 @@ void Buffer::makeLaTeXFile(string const & filename, } // if needed - if (params.sides != tclass->sides) { + if (params.sides != tclass.sides()) { if (params.sides == 2) options += "twoside,"; else @@ -1656,7 +1683,7 @@ void Buffer::makeLaTeXFile(string const & filename, } // if needed - if (params.columns != tclass->columns) { + if (params.columns != tclass.columns()) { if (params.columns == 2) options += "twocolumn,"; else @@ -1684,7 +1711,7 @@ void Buffer::makeLaTeXFile(string const & filename, } LFile += '{'; - LFile += lyxstyle.LatexnameOfClass(params.textclass); + LFile += textclasslist.LatexnameOfClass(params.textclass); LFile += "}\n"; texrow.newline(); // end of \documentclass defs @@ -1810,11 +1837,11 @@ void Buffer::makeLaTeXFile(string const & filename, texrow.newline(); } if (params.use_amsmath - && !prefixIs(lyxstyle.LatexnameOfClass(params.textclass), "ams")) { + && !prefixIs(textclasslist.LatexnameOfClass(params.textclass), "ams")) { LFile += "\\usepackage{amsmath}\n"; } - if (tokenPos(tclass->opt_pagestyle, '|',params.pagestyle) >= 0) { + if (tokenPos(tclass.opt_pagestyle(), '|',params.pagestyle) >= 0) { if (params.pagestyle == "fancy") { LFile += "\\usepackage{fancyhdr}\n"; texrow.newline(); @@ -1830,13 +1857,13 @@ void Buffer::makeLaTeXFile(string const & filename, texrow.newline(); } - if (params.secnumdepth != tclass->secnumdepth) { + if (params.secnumdepth != tclass.secnumdepth()) { LFile += "\\setcounter{secnumdepth}{"; LFile += tostr(params.secnumdepth); LFile += "}\n"; texrow.newline(); } - if (params.tocdepth != tclass->tocdepth) { + if (params.tocdepth != tclass.tocdepth()) { LFile += "\\setcounter{tocdepth}{"; LFile += tostr(params.tocdepth); LFile += "}\n"; @@ -1954,7 +1981,7 @@ void Buffer::makeLaTeXFile(string const & filename, int ftcount = 0; int loop_count = 0; - LyXParagraph *par = paragraph; + LyXParagraph * par = paragraph; // if only_body while (par) { @@ -1962,10 +1989,10 @@ void Buffer::makeLaTeXFile(string const & filename, if (par->IsDummy()) lyxerr[Debug::LATEX] << "Error in MakeLateXFile." << endl; - LyXLayout * layout = lyxstyle.Style(params.textclass, + LyXLayout const & layout = textclasslist.Style(params.textclass, par->layout); - if (layout->intitle) { + if (layout.intitle) { if (already_title) { lyxerr <<"Error in MakeLatexFile: You" " should not mix title layouts" @@ -1982,7 +2009,7 @@ void Buffer::makeLaTeXFile(string const & filename, // ordinary \footnote{} generation // flag this with ftcount ftcount = -1; - if (layout->isEnvironment() + if (layout.isEnvironment() || par->pextra_type != PEXTRA_NONE) { par = par->TeXEnvironment(LFile, texrow, ftnote, ft_texrow, ftcount); @@ -2054,62 +2081,62 @@ void Buffer::makeLaTeXFile(string const & filename, bool Buffer::isLatex() { - return lyxstyle.TextClass(params.textclass)->output_type == LATEX; + return textclasslist.TextClass(params.textclass).outputType() == LATEX; } bool Buffer::isLinuxDoc() { - return lyxstyle.TextClass(params.textclass)->output_type == LINUXDOC; + return textclasslist.TextClass(params.textclass).outputType() == LINUXDOC; } bool Buffer::isLiterate() { - return lyxstyle.TextClass(params.textclass)->output_type == LITERATE; + return textclasslist.TextClass(params.textclass).outputType() == LITERATE; } bool Buffer::isDocBook() { - return lyxstyle.TextClass(params.textclass)->output_type == DOCBOOK; + return textclasslist.TextClass(params.textclass).outputType() == DOCBOOK; } bool Buffer::isSGML() { - return lyxstyle.TextClass(params.textclass)->output_type == LINUXDOC || - lyxstyle.TextClass(params.textclass)->output_type == DOCBOOK; + return textclasslist.TextClass(params.textclass).outputType() == LINUXDOC || + textclasslist.TextClass(params.textclass).outputType() == DOCBOOK; } -void Buffer::sgmlOpenTag(FILE * file,int depth,string & latexname) +void Buffer::sgmlOpenTag(FILE * file, int depth, string const & latexname) const { static char *space[] = {" "," "," "," "," "," "," ", " "," "," "," "}; - fprintf(file,"%s<%s>\n",space[depth],latexname.c_str()); + fprintf(file, "%s<%s>\n", space[depth], latexname.c_str()); } -void Buffer::sgmlCloseTag(FILE * file,int depth,string & latexname) +void Buffer::sgmlCloseTag(FILE * file, int depth, string const & latexname) const { static char *space[] = {" "," "," "," "," "," "," ", " "," "," "," "}; - fprintf(file,"%s\n",space[depth],latexname.c_str()); + fprintf(file, "%s\n", space[depth], latexname.c_str()); } void Buffer::makeLinuxDocFile(string const & filename, int column) { - LyXParagraph *par = paragraph; + LyXParagraph * par = paragraph; - string top_element=lyxstyle.LatexnameOfClass(params.textclass); + string top_element=textclasslist.LatexnameOfClass(params.textclass); string environment_stack[10]; string item_name; - int depth=0; /* paragraph depth */ + int depth = 0; /* paragraph depth */ FilePtr file(filename, FilePtr::write); tex_code_break_column = column; @@ -2145,7 +2172,7 @@ void Buffer::makeLinuxDocFile(string const & filename, int column) while (par) { int desc_on=0; /* description mode*/ - LyXLayout *style=lyxstyle.Style(GetCurrentTextClass(), par->layout); + LyXLayout const & style=textclasslist.Style(GetCurrentTextClass(), par->layout); par->AutoDeleteInsets(); /* treat as a special case for compatibility with old code */ @@ -2169,7 +2196,7 @@ void Buffer::makeLinuxDocFile(string const & filename, int column) } /* write opening SGML tags */ - switch(style->latextype) { + switch(style.latextype) { case LATEX_PARAGRAPH: if(depth == par->depth && !environment_stack[depth].empty()) { @@ -2180,7 +2207,7 @@ void Buffer::makeLinuxDocFile(string const & filename, int column) else fprintf(file,"

"); } - sgmlOpenTag(file,depth,style->latexname); + sgmlOpenTag(file,depth,style.latexname()); break; case LATEX_COMMAND: @@ -2193,13 +2220,13 @@ void Buffer::makeLinuxDocFile(string const & filename, int column) } environment_stack[depth].clear(); - sgmlOpenTag(file,depth, style->latexname); + sgmlOpenTag(file,depth, style.latexname()); break; case LATEX_ENVIRONMENT: case LATEX_ITEM_ENVIRONMENT: if(depth == par->depth - && environment_stack[depth]!=style->latexname + && environment_stack[depth] != style.latexname() && !environment_stack[depth].empty()) { sgmlCloseTag(file,depth,environment_stack[depth]); @@ -2209,17 +2236,17 @@ void Buffer::makeLinuxDocFile(string const & filename, int column) depth = par->depth; environment_stack[depth].clear(); } - if (environment_stack[depth] != style->latexname) { + if (environment_stack[depth] != style.latexname()) { if(depth==0) { string temp="p"; sgmlOpenTag(file,depth,temp); } - environment_stack[depth]= style->latexname; + environment_stack[depth] = style.latexname(); sgmlOpenTag(file,depth,environment_stack[depth]); } - if(style->latextype == LATEX_ENVIRONMENT) break; + if(style.latextype == LATEX_ENVIRONMENT) break; - desc_on =(style->labeltype == LABEL_MANUAL); + desc_on =(style.labeltype == LABEL_MANUAL); if(desc_on) item_name="tag"; @@ -2229,7 +2256,7 @@ void Buffer::makeLinuxDocFile(string const & filename, int column) sgmlOpenTag(file,depth+1,item_name); break; default: - sgmlOpenTag(file,depth,style->latexname); + sgmlOpenTag(file, depth, style.latexname()); break; } @@ -2243,13 +2270,13 @@ void Buffer::makeLinuxDocFile(string const & filename, int column) fprintf(file,"\n"); /* write closing SGML tags */ - switch(style->latextype) { + switch(style.latextype) { case LATEX_COMMAND: case LATEX_ENVIRONMENT: case LATEX_ITEM_ENVIRONMENT: break; default: - sgmlCloseTag(file,depth,style->latexname); + sgmlCloseTag(file, depth, style.latexname()); break; } @@ -2293,10 +2320,10 @@ void Buffer::DocBookHandleCaption(FILE *file, string &inner_tag, LyXParagraph *tpar = par; string tmp_par, extra_par; while (tpar && (tpar->footnoteflag != LyXParagraph::NO_FOOTNOTE) && - (tpar->layout != lyxstyle.NumberOfLayout(params.textclass,"Caption"))) + (tpar->layout != textclasslist.NumberOfLayout(params.textclass,"Caption").second)) tpar = tpar->next; if (tpar && - tpar->layout==lyxstyle.NumberOfLayout(params.textclass,"Caption")) { + tpar->layout==textclasslist.NumberOfLayout(params.textclass,"Caption").second) { sgmlOpenTag(file,depth+1,inner_tag); SimpleDocBookOnePar(tmp_par,extra_par,tpar,desc_on,depth+2); tmp_par = strip(tmp_par); @@ -2384,8 +2411,8 @@ void Buffer::DocBookHandleFootnote(FILE *file,LyXParagraph* &par, int const dept } } // ignore all caption here, we processed them above!!! - if (par->layout != lyxstyle.NumberOfLayout(params.textclass, - "Caption")) { + if (par->layout != textclasslist.NumberOfLayout(params.textclass, + "Caption").second) { SimpleDocBookOnePar(tmp_par,extra_par,par, desc_on,depth+2); } @@ -2462,9 +2489,14 @@ void Buffer::SimpleLinuxDocOnePar(FILE *file, LyXParagraph *par, int desc_on, in { LyXFont font1,font2; char c; - Inset *inset; + Inset * inset; +#ifdef NEW_TEXT + LyXParagraph::size_type main_body; + int j; +#else int main_body, j; - LyXLayout * style = lyxstyle.Style(params.textclass, par->GetLayout()); +#endif + LyXLayout const & style = textclasslist.Style(params.textclass, par->GetLayout()); char family_type = 0; // family font flag bool is_bold = false; // series font flag @@ -2475,25 +2507,30 @@ void Buffer::SimpleLinuxDocOnePar(FILE *file, LyXParagraph *par, int desc_on, in char stack[5][3]; // style stack unsigned int char_line_count = 5; // Heuristic choice ;-) - if (style->labeltype != LABEL_MANUAL) + if (style.labeltype != LABEL_MANUAL) main_body = 0; else main_body = par->BeginningOfMainBody(); /* gets paragraph main font */ if (main_body > 0) - font1 = style->labelfont; + font1 = style.labelfont; else - font1 = style->font; + font1 = style.font; /* parsing main loop */ +#ifdef NEW_TEXT + for (LyXParagraph::size_type i = 0; + i < par->size(); ++i) { +#else for (int i = 0; i < par->last; i++) { +#endif /* handle quote tag */ if (i == main_body && !par->IsDummy()) { if (main_body > 0) - font1 = style->font; + font1 = style.font; } font2 = par->getFont(i); @@ -2605,7 +2642,7 @@ void Buffer::SimpleLinuxDocOnePar(FILE *file, LyXParagraph *par, int desc_on, in else { string sgml_string; if (par->linuxDocConvertChar(c, sgml_string) - && !style->free_spacing) { // in freespacing + && !style.free_spacing) { // in freespacing // mode, spaces are // non-breaking characters // char is ' ' @@ -2628,13 +2665,18 @@ void Buffer::SimpleLinuxDocOnePar(FILE *file, LyXParagraph *par, int desc_on, in font1 = font2; } - /* needed if there is an optional argument but no contents */ - if (main_body > 0 && main_body == par->last) { - font1 = style->font; + /* needed if there is an optional argument but no contents */ +#ifdef NEW_TEXT + if (main_body > 0 && main_body == par->size()) { + font1 = style.font; } - +#else + if (main_body > 0 && main_body == par->last) { + font1 = style.font; + } +#endif /* pop all defined Styles */ - for (j=stack_num; j>=0; j--) { + for (j = stack_num; j >= 0; j--) { linux_doc_line_break(file, char_line_count, 3+strlen(stack[j])); @@ -2656,10 +2698,10 @@ void Buffer::SimpleLinuxDocOnePar(FILE *file, LyXParagraph *par, int desc_on, in /* print an error message */ -void Buffer::LinuxDocError(LyXParagraph *par, int pos, - char const *message) +void Buffer::LinuxDocError(LyXParagraph * par, int pos, + char const * message) { - InsetError *new_inset; + InsetError * new_inset; /* insert an error marker in text */ new_inset = new InsetError(message); @@ -2677,9 +2719,9 @@ enum { MAX_NEST_LEVEL = 25}; void Buffer::makeDocBookFile(string const & filename, int column) { - LyXParagraph *par = paragraph; + LyXParagraph * par = paragraph; - string top_element=lyxstyle.LatexnameOfClass(params.textclass); + string top_element=textclasslist.LatexnameOfClass(params.textclass); string environment_stack[MAX_NEST_LEVEL]; string environment_inner[MAX_NEST_LEVEL]; string command_stack[MAX_NEST_LEVEL]; @@ -2702,7 +2744,9 @@ void Buffer::makeDocBookFile(string const & filename, int column) //ResetTexRow(); texrow.reset(); - fprintf(file, "\n\n"); @@ -2725,7 +2769,7 @@ void Buffer::makeDocBookFile(string const & filename, int column) while (par) { int desc_on=0; /* description mode*/ - LyXLayout * style = lyxstyle.Style(GetCurrentTextClass(), + LyXLayout const & style = textclasslist.Style(GetCurrentTextClass(), par->layout); par->AutoDeleteInsets(); @@ -2746,7 +2790,7 @@ void Buffer::makeDocBookFile(string const & filename, int column) } if(depth == par->depth - && environment_stack[depth]!=style->latexname + && environment_stack[depth] != style.latexname() && !environment_stack[depth].empty()) { if(environment_inner[depth] != "!-- --") { item_name="listitem"; @@ -2765,11 +2809,11 @@ void Buffer::makeDocBookFile(string const & filename, int column) } // Write opening SGML tags. - switch(style->latextype) { + switch(style.latextype) { case LATEX_PARAGRAPH: - if(style->latexname != "dummy") + if(style.latexname() != "dummy") sgmlOpenTag(file, depth+command_depth, - style->latexname); + style.latexname()); break; case LATEX_COMMAND: @@ -2778,10 +2822,10 @@ void Buffer::makeDocBookFile(string const & filename, int column) _("Error : Wrong depth for " "LatexType Command.\n")); - command_name=style->latexname; + command_name = style.latexname(); - tmps=style->latexparam; - c_params= split(tmps, c_depth,'|'); + tmps = style.latexparam(); + c_params = split(tmps, c_depth,'|'); cmd_depth=atoi(c_depth.c_str()); @@ -2835,8 +2879,8 @@ void Buffer::makeDocBookFile(string const & filename, int column) environment_stack[depth].clear(); } - if (environment_stack[depth] != style->latexname) { - environment_stack[depth]= style->latexname; + if (environment_stack[depth] != style.latexname()) { + environment_stack[depth]= style.latexname(); environment_inner[depth]= "!-- --"; sgmlOpenTag(file, depth + command_depth, environment_stack[depth]); @@ -2853,14 +2897,14 @@ void Buffer::makeDocBookFile(string const & filename, int column) } } - if(style->latextype == LATEX_ENVIRONMENT) { - if(!style->latexparam.empty()) + if(style.latextype == LATEX_ENVIRONMENT) { + if(!style.latexparam().empty()) sgmlOpenTag(file, depth+command_depth, - style->latexparam); + style.latexparam()); break; } - desc_on =(style->labeltype == LABEL_MANUAL); + desc_on =(style.labeltype == LABEL_MANUAL); if(desc_on) environment_inner[depth]="varlistentry"; @@ -2882,7 +2926,8 @@ void Buffer::makeDocBookFile(string const & filename, int column) } break; default: - sgmlOpenTag(file,depth+command_depth,style->latexname); + sgmlOpenTag(file, depth + command_depth, + style.latexname()); break; } @@ -2900,15 +2945,15 @@ void Buffer::makeDocBookFile(string const & filename, int column) string end_tag; /* write closing SGML tags */ - switch(style->latextype) { + switch(style.latextype) { case LATEX_COMMAND: - end_tag="title"; - sgmlCloseTag(file,depth+command_depth,end_tag); + end_tag = "title"; + sgmlCloseTag(file, depth + command_depth, end_tag); break; case LATEX_ENVIRONMENT: - if(!style->latexparam.empty()) - sgmlCloseTag(file,depth+command_depth, - style->latexparam); + if(!style.latexparam().empty()) + sgmlCloseTag(file, depth + command_depth, + style.latexparam()); break; case LATEX_ITEM_ENVIRONMENT: if(desc_on==1) break; @@ -2916,13 +2961,13 @@ void Buffer::makeDocBookFile(string const & filename, int column) sgmlCloseTag(file,depth+1+command_depth,end_tag); break; case LATEX_PARAGRAPH: - if( style->latexname != "dummy") - sgmlCloseTag(file,depth+command_depth, - style->latexname); + if(style.latexname() != "dummy") + sgmlCloseTag(file, depth + command_depth, + style.latexname()); break; default: sgmlCloseTag(file,depth+command_depth, - style->latexname); + style.latexname()); break; } } @@ -2969,32 +3014,41 @@ void Buffer::SimpleDocBookOnePar(string & file, string & extra, LyXFont font1,font2; char c; Inset *inset; +#ifdef NEW_TEXT + LyXParagraph::size_type main_body; + int j; +#else int main_body, j; +#endif string emph="emphasis"; bool emph_flag=false; int char_line_count=0; - LyXLayout * style = lyxstyle.Style(params.textclass, par->GetLayout()); + LyXLayout const & style = textclasslist.Style(params.textclass, par->GetLayout()); - if (style->labeltype != LABEL_MANUAL) + if (style.labeltype != LABEL_MANUAL) main_body = 0; else main_body = par->BeginningOfMainBody(); /* gets paragraph main font */ if (main_body > 0) - font1 = style->labelfont; + font1 = style.labelfont; else - font1 = style->font; + font1 = style.font; char_line_count = depth; - if(!style->free_spacing) + if(!style.free_spacing) for (j=0;j< depth;j++) file += ' '; /* parsing main loop */ +#ifdef NEW_TEXT + for (LyXParagraph::size_type i = 0; + i < par->size(); ++i) { +#else for (int i = 0; i < par->last; i++) { - +#endif font2 = par->getFont(i); /* handle tag */ @@ -3043,7 +3097,7 @@ void Buffer::SimpleDocBookOnePar(string & file, string & extra, else { string sgml_string; if (par->linuxDocConvertChar(c, sgml_string) - && !style->free_spacing) { // in freespacing + && !style.free_spacing) { // in freespacing // mode, spaces are // non-breaking characters // char is ' ' @@ -3064,11 +3118,16 @@ void Buffer::SimpleDocBookOnePar(string & file, string & extra, font1 = font2; } - /* needed if there is an optional argument but no contents */ - if (main_body > 0 && main_body == par->last) { - font1 = style->font; + /* needed if there is an optional argument but no contents */ +#ifdef NEW_TEXT + if (main_body > 0 && main_body == par->size()) { + font1 = style.font; } - +#else + if (main_body > 0 && main_body == par->last) { + font1 = style.font; + } +#endif if (emph_flag) { file += ""; } @@ -3138,12 +3197,6 @@ int Buffer::runLaTeX() // Remove all error insets bool a = removeAutoInsets(); - // generate the LaTeX file if necessary - //if (!isDviClean() || a) { - // makeLaTeXFile(name, org_path, false); - // markDviDirty(); - //} - // Always generate the LaTeX file makeLaTeXFile(name, org_path, false); markDviDirty(); @@ -3214,12 +3267,12 @@ int Buffer::runLiterate() markDviDirty(); } - TeXErrors terr; Literate literate(lyxrc->latex_command, name, filepath, lit_name, lyxrc->literate_command, lyxrc->literate_error_filter, lyxrc->build_command, lyxrc->build_error_filter); - int res = literate.weave(terr,users->getOwner()->getMiniBuffer()); + TeXErrors terr; + int res = literate.weave(terr, users->getOwner()->getMiniBuffer()); // check return value from literate.weave(). if ((res & Literate::NO_LOGFILE)) { @@ -3282,12 +3335,12 @@ int Buffer::buildProgram() markNwDirty(); } - TeXErrors terr; Literate literate(lyxrc->latex_command, name, filepath, lit_name, lyxrc->literate_command, lyxrc->literate_error_filter, lyxrc->build_command, lyxrc->build_error_filter); - int res = literate.build(terr,users->getOwner()->getMiniBuffer()); + TeXErrors terr; + int res = literate.build(terr, users->getOwner()->getMiniBuffer()); // check return value from literate.build(). if ((res & Literate::NO_LOGFILE)) { @@ -3377,32 +3430,22 @@ int Buffer::runChktex() extern void AllFloats(char, char); -void Buffer::insertErrors(TeXErrors &terr) +void Buffer::insertErrors(TeXErrors & terr) { // Save the cursor position LyXCursor cursor = text->cursor; - // Now traverse all the errors and insert them - bool firsterror = true; - bool more = true; - // This is drastic, but it's the only fix, I could find. (Asger) AllFloats(1,0); AllFloats(1,1); - while (more) { - string errortext; - int errorrow = 0; - - if (firsterror) { - more = terr.getFirstError(&errorrow, &errortext); - firsterror = false; - } else { - more = terr.getNextError(&errorrow, &errortext); - } - - if (!more) - break; + for (TeXErrors::Errors::const_iterator cit = terr.begin(); + cit != terr.end(); + ++cit) { + string desctext((*cit).error_desc); + string errortext((*cit).error_text); + string msgtxt = desctext + '\n' + errortext; + int errorrow = (*cit).error_in_line; // Insert error string for row number int tmpid = -1; @@ -3422,7 +3465,7 @@ void Buffer::insertErrors(TeXErrors &terr) if (texrowpar == 0) continue; - InsetError *new_inset = new InsetError(errortext); + InsetError *new_inset = new InsetError(msgtxt); text->SetCursorIntern(texrowpar, tmppos); text->InsertInset(new_inset); @@ -3452,33 +3495,38 @@ void Buffer::setCursorFromRow (int row) } -void Buffer::RoffAsciiTable(FILE *file, LyXParagraph *par) +void Buffer::RoffAsciiTable(FILE * file, LyXParagraph * par) { LyXFont font1 = LyXFont(LyXFont::ALL_INHERIT), font2; - Inset - *inset; + Inset * inset; +#ifdef NEW_TEXT + LyXParagraph::size_type i; +#else + int i; +#endif int - i,j, + j, cell = 0; char c; - string - fname1, - fname2; FILE - *fp,*fp2; + * fp, * fp2; - fname1 = TmpFileName(string(),"RAT1"); - fname2 = TmpFileName(string(),"RAT2"); + string fname1 = TmpFileName(string(),"RAT1"); + string fname2 = TmpFileName(string(),"RAT2"); if (!(fp=fopen(fname1.c_str(),"w"))) { WriteAlert(_("LYX_ERROR:"), _("Cannot open temporary file:"), fname1); return; } par->table->RoffEndOfCell(fp, -1); - for (i = 0; i < par->last; i++) { +#ifdef NEW_TEXT + for (i = 0; i < par->size(); ++i) { +#else + for (i = 0; i < par->last; ++i) { +#endif c = par->GetChar(i); if (par->table->IsContRow(cell)) { if (c == LYX_META_NEWLINE) @@ -3573,6 +3621,7 @@ void Buffer::RoffAsciiTable(FILE *file, LyXParagraph *par) remove(fname2.c_str()); } + /// changed Heinrich Bauer, 23/03/98 bool Buffer::isDviClean() { @@ -3582,6 +3631,7 @@ bool Buffer::isDviClean() return dvi_clean_orgd; } + /// changed Heinrich Bauer, 23/03/98 void Buffer::markDviClean() { @@ -3591,6 +3641,7 @@ void Buffer::markDviClean() dvi_clean_orgd = true; } + /// changed Heinrich Bauer, 23/03/98 void Buffer::markDviDirty() { @@ -3600,6 +3651,7 @@ void Buffer::markDviDirty() dvi_clean_orgd = false; } + void Buffer::update(signed char f) { if (!users) return; @@ -3629,15 +3681,16 @@ void Buffer::update(signed char f) } -void Buffer::validate(LaTeXFeatures &features) +void Buffer::validate(LaTeXFeatures & features) { - LyXParagraph *par = paragraph; - LyXTextClass *tclass = lyxstyle.TextClass(params.textclass); + LyXParagraph * par = paragraph; + LyXTextClass const & tclass = + textclasslist.TextClass(params.textclass); // AMS Style is at document level features.amsstyle = (params.use_amsmath || - tclass->provides_amsmath); + tclass.provides(LyXTextClass::amsmath)); while (par) { // We don't use "lyxerr.debug" because of speed. (Asger) @@ -3658,7 +3711,9 @@ void Buffer::validate(LaTeXFeatures &features) if (params.user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) { int font = params.user_defined_bullets[i].getFont(); if (font == 0) { - int c = params.user_defined_bullets[i].getCharacter(); + int c = params + .user_defined_bullets[i] + .getCharacter(); if (c == 16 || c == 17 || c == 25 @@ -3684,12 +3739,10 @@ void Buffer::validate(LaTeXFeatures &features) void Buffer::setPaperStuff() { - char c1, c2; - params.papersize = PAPER_DEFAULT; - c1 = params.paperpackage; + char c1 = params.paperpackage; if (c1 == PACKAGE_NONE) { - c2 = params.papersize2; + char c2 = params.papersize2; if (c2 == VM_PAPER_USLETTER) params.papersize = PAPER_USLETTER; else if (c2 == VM_PAPER_USLEGAL) @@ -3713,9 +3766,7 @@ void Buffer::setPaperStuff() void Buffer::setOldPaperStuff() { - char c; - - c = params.papersize = params.papersize2; + char c = params.papersize = params.papersize2; params.papersize2 = VM_PAPER_DEFAULT; params.paperpackage = PACKAGE_NONE; if (c == OLD_PAPER_A4PAPER) @@ -3740,7 +3791,7 @@ void Buffer::setOldPaperStuff() } -void Buffer::insertInset(Inset *inset, string const &lout, +void Buffer::insertInset(Inset * inset, string const & lout, bool no_table) { // check for table/list in tables @@ -3767,7 +3818,8 @@ void Buffer::insertInset(Inset *inset, string const &lout, update(-1); } - int lay = lyxstyle.NumberOfLayout(params.textclass, lout); + int lay = textclasslist.NumberOfLayout(params.textclass, + lout).second; if (lay == -1) // layout not found // use default layout "Standard" (0) lay = 0; @@ -3788,17 +3840,12 @@ void Buffer::insertInset(Inset *inset, string const &lout, text->InsertInset(inset); update(-1); -// Commenting these two lines fixes the problem with new display inset -// inside a paragraph, not sure why. (ale 971117) -// if (inset->Display()) -// text->CursorRight(); - text->UnFreezeUndo(); } // Open and lock an updatable inset -void Buffer::open_new_inset(UpdatableInset* new_inset) +void Buffer::open_new_inset(UpdatableInset * new_inset) { BeforeChange(); text->FinishUndo(); @@ -3812,28 +3859,33 @@ void Buffer::open_new_inset(UpdatableInset* new_inset) /* This function should be in Buffer because it's a buffer's property (ale) */ string Buffer::getIncludeonlyList(char delim) { - string list; - LyXParagraph *par = paragraph; + string lst; + LyXParagraph * par = paragraph; +#ifdef NEW_TEXT + LyXParagraph::size_type pos; +#else int pos; - Inset* inset; +#endif + Inset * inset; while (par){ pos = -1; while ((inset = par->ReturnNextInsetPointer(pos))){ if (inset->LyxCode()==Inset::INCLUDE_CODE) { - InsetInclude *insetinc = (InsetInclude*)inset; + InsetInclude * insetinc = + static_cast(inset); if (insetinc->isInclude() && insetinc->isNoLoad()) { - if (!list.empty()) - list += delim; - list += ChangeExtension(insetinc->getContents(), string(), true); + if (!lst.empty()) + lst += delim; + lst += ChangeExtension(insetinc->getContents(), string(), true); } } pos++; } par = par->next; } - lyxerr.debug() << "Includeonly(" << list << ')' << endl; - return list; + lyxerr.debug() << "Includeonly(" << lst << ')' << endl; + return lst; } @@ -3849,23 +3901,27 @@ string Buffer::getReferenceList(char delim) } LyXParagraph *par = paragraph; +#ifdef NEW_TEXT + LyXParagraph::size_type pos; +#else int pos; - Inset* inset; - string list; +#endif + Inset * inset; + string lst; while (par){ pos = -1; while ((inset = par->ReturnNextInsetPointer(pos))){ for (int i = 0; i < inset->GetNumberOfLabels(); i++) { - if (!list.empty()) - list += delim; - list += inset->getLabel(i); + if (!lst.empty()) + lst += delim; + lst += inset->getLabel(i); } pos++; } par = par->next; } - lyxerr.debug() << "References(" << list << ")" << endl; - return list; + lyxerr.debug() << "References(" << lst << ")" << endl; + return lst; } @@ -3881,7 +3937,7 @@ string Buffer::getBibkeyList(char delim) } string bibkeys; - LyXParagraph *par = paragraph; + LyXParagraph * par = paragraph; while (par) { if (par->bibkey) { if (!bibkeys.empty()) @@ -3895,8 +3951,12 @@ string Buffer::getBibkeyList(char delim) if (bibkeys.empty()) { par = paragraph; while (par) { - Inset *inset; + Inset * inset; +#ifdef NEW_TEXT + LyXParagraph::size_type pos = -1; +#else int pos = -1; +#endif // Search for Bibtex or Include inset while ((inset = par->ReturnNextInsetPointer(pos))) { @@ -3928,13 +3988,16 @@ string Buffer::getBibkeyList(char delim) // think how this will work in a multiwindo/buffer environment, all the // cursors in all the views showing this buffer will move. (Lgb) // OK, then no cursor action should be allowed in buffer. (ale) -bool Buffer::gotoLabel(const string &label) +bool Buffer::gotoLabel(string const & label) { - LyXParagraph *par = paragraph; + LyXParagraph * par = paragraph; +#ifdef NEW_TEXT + LyXParagraph::size_type pos; +#else int pos; - Inset* inset; - string list; +#endif + Inset * inset; while (par) { pos = -1; while ((inset = par->ReturnNextInsetPointer(pos))){ @@ -3957,7 +4020,7 @@ bool Buffer::gotoLabel(const string &label) bool Buffer::isDepClean(string const & name) const { - DEPCLEAN* item = dep_clean; + DEPCLEAN * item = dep_clean; while (item && item->master != name) item = item->next; if (!item) return true; @@ -3985,5 +4048,4 @@ void Buffer::markDepClean(string const & name) item->next = 0;; } } - //return false; // why use that in a void method?? } diff --git a/src/buffer.h b/src/buffer.h index e1866b7e73..91f0d79153 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -19,8 +19,8 @@ // every time the LyX-file was left unchanged between the two actions mentioned // above. -#ifndef _BUFFER_H_ -#define _BUFFER_H_ +#ifndef BUFFER_H +#define BUFFER_H #ifdef __GNUG__ #pragma interface @@ -370,9 +370,9 @@ private: /// void DocBookHandleFootnote(FILE *file,LyXParagraph* &par, int const depth); /// - void sgmlOpenTag(FILE * file,int depth,string & latexname); + void sgmlOpenTag(FILE * file,int depth,string const & latexname) const; /// - void sgmlCloseTag(FILE * file,int depth,string & latexname); + void sgmlCloseTag(FILE * file,int depth,string const & latexname) const; /// void LinuxDocError(LyXParagraph *par, int pos, char const *message); /// diff --git a/src/bufferlist.h b/src/bufferlist.h index aadda105f1..093871714c 100644 --- a/src/bufferlist.h +++ b/src/bufferlist.h @@ -60,8 +60,8 @@ private: class BufferStorage_Iter { public: /// - BufferStorage_Iter(const BufferStorage & bs) - { cs=&bs; index=0;} + BufferStorage_Iter(BufferStorage const & bs) + { cs =& bs; index = 0;} /// next Buffer* operator() (); /// diff --git a/src/bufferparams.C b/src/bufferparams.C index 5ac2f74584..ff656f2024 100644 --- a/src/bufferparams.C +++ b/src/bufferparams.C @@ -44,7 +44,7 @@ BufferParams::BufferParams() fonts = "default"; inputenc = "latin1"; graphicsDriver = "default"; - sides = 1; + sides = LyXTextClass::OneSide; columns = 1; pagestyle = "default"; for(int iter = 0; iter < 4; iter++) { @@ -112,7 +112,7 @@ void BufferParams::writeFile(FILE *file) // the textclass fprintf(file, "\\textclass %s\n", - lyxstyle.NameOfClass(textclass).c_str()); + textclasslist.NameOfClass(textclass).c_str()); // then the the preamble if (!preamble.empty()) { @@ -222,14 +222,14 @@ void BufferParams::writeFile(FILE *file) void BufferParams::useClassDefaults() { - LyXTextClass *tclass = lyxstyle.TextClass(textclass); + LyXTextClass const & tclass = textclasslist.TextClass(textclass); - sides = tclass->sides; - columns = tclass->columns; - pagestyle = tclass->pagestyle; - options = tclass->options; - secnumdepth = tclass->secnumdepth; - tocdepth = tclass->tocdepth; + sides = tclass.sides(); + columns = tclass.columns(); + pagestyle = tclass.pagestyle(); + options = tclass.options(); + secnumdepth = tclass.secnumdepth(); + tocdepth = tclass.tocdepth(); } diff --git a/src/bufferparams.h b/src/bufferparams.h index f7176b1eac..1940b5f0f4 100644 --- a/src/bufferparams.h +++ b/src/bufferparams.h @@ -4,13 +4,13 @@ * * LyX, The Document Processor * - * Copyright (C) 1995 1996 Matthias Ettrich - * and the LyX Team. + * Copyright 1995 Matthias Ettrich + * Copyright 1995-1999 The LyX Team. * - *======================================================*/ + * ====================================================== */ -#ifndef _BUFFERPARAMS_H -#define _BUFFERPARAMS_H +#ifndef BUFFERPARAMS_H +#define BUFFERPARAMS_H #ifdef __GNUG__ #pragma interface @@ -22,6 +22,7 @@ #include "Spacing.h" #include "Bullet.h" #include "insets/insetquotes.h" +#include "layout.h" /** This class contains all the parameters for this a buffer uses. Some @@ -34,8 +35,6 @@ public: //@{ /// BufferParams(); - // /// - //BufferParams(const BufferParams&); //@} /// Dummy destructor to shut up gcc @@ -65,7 +64,7 @@ public: /// string fontsize; /// - signed char textclass; + LyXTextClassList::ClassList::size_type textclass; /* this are for the PaperLayout */ /// @@ -105,9 +104,9 @@ public: /// Spacing spacing; /// - signed char secnumdepth; + int secnumdepth; /// - signed char tocdepth; + int tocdepth; /// string language; /// @@ -119,9 +118,9 @@ public: /// string float_placement; /// - char columns; // add approp. signedness + unsigned int columns; /// - char sides; // add approp. signedness + LyXTextClass::PageSides sides; /// string pagestyle; /// diff --git a/src/debug.h b/src/debug.h index 0dd2501c60..ce584db816 100644 --- a/src/debug.h +++ b/src/debug.h @@ -48,12 +48,14 @@ struct Debug { PARSER | LYXRC | KBMAP | LATEX | MATHED | FONT | TCLASS | LYXVC | LYXSERVER | ROFF); - + /// + friend inline void operator|=(Debug::type & d1, Debug::type d2); + /** A function to convert symbolic string names on debug levels to their numerical value. */ static Debug::type value(string const & val) { - int l = Debug::NONE; + type l = Debug::NONE; string v(val); while (!v.empty()) { string::size_type st = v.find(','); @@ -78,9 +80,14 @@ struct Debug { if (st == string::npos) break; v.erase(0, st + 1); } - return Debug::type(l); + return l; } }; +/// +inline void operator|=(Debug::type & d1, Debug::type d2) +{ + d1 = static_cast(d1 | d2); +} #include "support/DebugStream.h" diff --git a/src/insets/figinset.C b/src/insets/figinset.C index 4fb1b106e0..48ba4d3b72 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -611,7 +611,7 @@ static void runqueue() XInternAtom(tempdisp, "GHOSTVIEW", false), XInternAtom(tempdisp, "STRING", false), 8, PropModeAppend, - (unsigned char *) tbuf, + reinterpret_cast(tbuf), strlen(tbuf)); switch (p->data->flags & 3) { @@ -641,7 +641,7 @@ static void runqueue() XInternAtom(tempdisp, "GHOSTVIEW_COLORS", false), XInternAtom(tempdisp, "STRING", false), 8, PropModeReplace, - (unsigned char *) tbuf, + reinterpret_cast(tbuf), strlen(tbuf)); XUngrabServer(tempdisp); XFlush(tempdisp); diff --git a/src/insets/inset.C b/src/insets/inset.C index 8216147c35..cad6369463 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -37,13 +37,12 @@ unsigned char Inset::Editable() const return 0; } + void Inset::Validate(LaTeXFeatures &) const { - // nothing by default } - bool Inset::AutoDelete() const { return false; @@ -61,14 +60,8 @@ LyXFont Inset::ConvertFont(LyXFont font) } -// Inset::Code Inset::LyxCode() const -// { -// return Inset::NO_CODE; -// } - /* some stuff for inset locking */ - void UpdatableInset::InsetButtonPress(int x, int y, int button) { lyxerr.debug() << "Inset Button Press x=" << x @@ -111,5 +104,4 @@ unsigned char UpdatableInset::Editable() const void UpdatableInset::ToggleInsetCursor() { - // nothing } diff --git a/src/insets/insetbib.C b/src/insets/insetbib.C index c95b013648..ec5f1c064e 100644 --- a/src/insets/insetbib.C +++ b/src/insets/insetbib.C @@ -19,11 +19,11 @@ #include "lyxtext.h" #include "support/filetools.h" -extern BufferView *current_view; +extern BufferView * current_view; -FD_citation_form *citation_form=0; -FD_bibitem_form *bibitem_form=0; -static Combox *bibcombox = 0; +FD_citation_form * citation_form = 0; +FD_bibitem_form * bibitem_form = 0; +static Combox * bibcombox = 0; extern void UpdateInset(Inset* inset, bool mark_dirty = true); void BibitemUpdate(Combox *); @@ -34,19 +34,10 @@ FD_bibitem_form * create_form_bibitem_form(void); extern "C" void bibitem_cb(FL_OBJECT *, long data) { switch (data) { -// case 0: fl_hide_form(citation_form->citation_form); -// break; -// case 1: case 1: // OK, citation { -// InsetCommand *inset = (InsetCommand*)citation_form->vdata; -// inset->setContents(bibcombox->getline()); -// inset->setOptions(fl_get_input(citation_form->label)); -// fl_hide_form(citation_form->citation_form); -// UpdateInset(inset); -// break; if(!current_view->currentBuffer()->isReadonly()) { - InsetCommand *inset = (InsetCommand*)citation_form->vdata; + InsetCommand *inset = static_cast(citation_form->citation_form->u_vdata); inset->setContents(bibcombox->getline()); inset->setOptions(fl_get_input(citation_form->label)); fl_hide_form(citation_form->citation_form); @@ -57,23 +48,12 @@ extern "C" void bibitem_cb(FL_OBJECT *, long data) } // fall through to Cancel on RO-mode } -// case 2: fl_hide_form(bibitem_form->bibitem_form); case 0: fl_hide_form(citation_form->citation_form); break; -// case 3: - case 3: // OK, bibitem { -// InsetCommand *inset = (InsetCommand *)bibitem_form->vdata; -// inset->setContents(fl_get_input(bibitem_form->key)); -// inset->setOptions(fl_get_input(bibitem_form->label)); -// fl_hide_form(bibitem_form->bibitem_form); -// // Does look like a hack? It is! (but will change at 0.13) -// current_view->currentBuffer()->text->RedoParagraph(); -// current_view->currentBuffer()->update(1); -// break; if(!current_view->currentBuffer()->isReadonly()) { - InsetCommand *inset = (InsetCommand *)bibitem_form->vdata; + InsetCommand *inset = static_cast(bibitem_form->bibitem_form->u_vdata); inset->setContents(fl_get_input(bibitem_form->key)); inset->setOptions(fl_get_input(bibitem_form->label)); fl_hide_form(bibitem_form->bibitem_form); @@ -159,7 +139,7 @@ InsetCitation::~InsetCitation() { if(citation_form && citation_form->citation_form && citation_form->citation_form->visible - && citation_form->vdata == this) + && citation_form->citation_form->u_vdata == this) fl_hide_form(citation_form->citation_form); } @@ -174,7 +154,7 @@ void InsetCitation::Edit(int, int) fl_set_form_atclose(citation_form->citation_form, CancelCloseBoxCB, 0); } - citation_form->vdata = this; + citation_form->citation_form->u_vdata = this; BibitemUpdate(bibcombox); if (!bibcombox->select_text(getContents().c_str())) @@ -276,7 +256,7 @@ void InsetBibKey::Edit(int, int) fl_set_form_atclose(bibitem_form->bibitem_form, CancelCloseBoxCB, 0); } - bibitem_form->vdata = this; + bibitem_form->bibitem_form->u_vdata = this; // InsetBibtex uses the same form, with different labels fl_set_object_label(bibitem_form->key, idex(_("Key:|#K"))); fl_set_button_shortcut(bibitem_form->key,scex(_("Key:|#K")),1); @@ -411,7 +391,7 @@ string InsetBibtex::getKeys() linebuf = subst(linebuf, '{', '('); linebuf = split(linebuf, - tmp, '('); + tmp,'('); tmp = lowercase(tmp); if (!prefixIs(tmp, "@string") && !prefixIs(tmp, "@preamble") ) { linebuf = split(linebuf, tmp,','); @@ -440,7 +420,7 @@ void InsetBibtex::Edit(int, int) CancelCloseBoxCB, 0); } - bibitem_form->vdata = this; + bibitem_form->bibitem_form->u_vdata = this; fl_set_object_label(bibitem_form->key, _("Database:")); fl_set_object_label(bibitem_form->label, _("Style: ")); fl_set_input(bibitem_form->key, getContents().c_str()); @@ -448,13 +428,14 @@ void InsetBibtex::Edit(int, int) if (bibitem_form->bibitem_form->visible) { fl_raise_form(bibitem_form->bibitem_form); } else { - fl_show_form(bibitem_form->bibitem_form,FL_PLACE_MOUSE, FL_FULLBORDER, + fl_show_form(bibitem_form->bibitem_form, + FL_PLACE_MOUSE, FL_FULLBORDER, _("BibTeX")); } } -bool InsetBibtex::addDatabase(string const &db) +bool InsetBibtex::addDatabase(string const & db) { if (!contains(contents, db.c_str())) { if (!contents.empty()) @@ -466,7 +447,7 @@ bool InsetBibtex::addDatabase(string const &db) } -bool InsetBibtex::delDatabase(string const &db) +bool InsetBibtex::delDatabase(string const & db) { if (contains(contents, db.c_str())) { string bd = db; @@ -486,7 +467,7 @@ bool InsetBibtex::delDatabase(string const &db) // This function should be in LyXView when multiframe works ale970302 -void BibitemUpdate(Combox* combox) +void BibitemUpdate(Combox * combox) { combox->clear(); @@ -504,7 +485,7 @@ void BibitemUpdate(Combox* combox) // ale070405 This function maybe shouldn't be here. We'll fix this at 0.13. -int bibitemMaxWidth(const class LyXFont &font) +int bibitemMaxWidth(LyXFont const & font) { int w = 0; // Does look like a hack? It is! (but will change at 0.13) @@ -526,8 +507,8 @@ string bibitemWidthest() { int w = 0; // Does look like a hack? It is! (but will change at 0.13) - LyXParagraph *par = current_view->currentBuffer()->paragraph; - InsetBibKey *bkey=0; + LyXParagraph * par = current_view->currentBuffer()->paragraph; + InsetBibKey * bkey=0; LyXFont font; while (par) { diff --git a/src/insets/insetbib.h b/src/insets/insetbib.h index b0dfb75d2f..3c07f55a29 100644 --- a/src/insets/insetbib.h +++ b/src/insets/insetbib.h @@ -5,12 +5,12 @@ * LyX, The Document Processor * * Copyright (C) 1995 Matthias Ettrich - * Copyright (C) 1995-1998 The LyX Team. + * Copyright (C) 1995-1999 The LyX Team. * - *======================================================*/ + * ======================================================*/ -#ifndef _INSET_BIB_H -#define _INSET_BIB_H +#ifndef INSET_BIB_H +#define INSET_BIB_H #ifdef __GNUG__ #pragma interface @@ -28,11 +28,11 @@ public: /// InsetCitation(): InsetCommand("cite") { } /// - InsetCitation(string const & key, string const & note=string()); + InsetCitation(string const & key, string const & note = string()); /// ~InsetCitation(); /// - Inset* Clone() { return new InsetCitation(contents, options); } + Inset * Clone() { return new InsetCitation(contents, options); } /// string getScreenLabel()const; /// @@ -54,13 +54,13 @@ public: /// InsetBibKey(): InsetCommand("bibitem") { counter = 1; } /// - InsetBibKey(string const & key, string const & label=string()); + InsetBibKey(string const & key, string const & label = string()); /// - InsetBibKey(InsetBibKey const*); + InsetBibKey(InsetBibKey const *); /// ~InsetBibKey(); /// - Inset* Clone() { return new InsetBibKey(this); } + Inset * Clone() { return new InsetBibKey(this); } /// Currently \bibitem is used as a LyX2.x command, so we need this method. void Write(FILE *); /// @@ -98,7 +98,7 @@ public: /// ~InsetBibtex(); /// - Inset* Clone() { return new InsetBibtex(contents, options, 0); } + Inset * Clone() { return new InsetBibtex(contents, options, 0); } /// Inset::Code LyxCode() const { @@ -111,7 +111,7 @@ public: /// int Latex(FILE *, signed char); /// - int Latex(string &file, signed char fragile); + int Latex(string & file, signed char fragile); /// string getKeys(); /// diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index b2f939134e..1457cad889 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -35,7 +35,7 @@ InsetCommand::~InsetCommand() } -int InsetCommand::Ascent(LyXFont const&font) const +int InsetCommand::Ascent(LyXFont const & font) const { LyXFont f = font; f.decSize(); @@ -43,7 +43,7 @@ int InsetCommand::Ascent(LyXFont const&font) const } -int InsetCommand::Descent(LyXFont const&font) const +int InsetCommand::Descent(LyXFont const & font) const { LyXFont f = font; f.decSize(); @@ -51,7 +51,7 @@ int InsetCommand::Descent(LyXFont const&font) const } -int InsetCommand::Width(LyXFont const&font) const +int InsetCommand::Width(LyXFont const & font) const { LyXFont f = font; f.decSize(); @@ -60,15 +60,12 @@ int InsetCommand::Width(LyXFont const&font) const } -void InsetCommand::Draw(LyXFont font, LyXScreen &scr, - int baseline, float &x) +void InsetCommand::Draw(LyXFont font, LyXScreen & scr, + int baseline, float & x) { // Draw it as a box with the LaTeX text x += 3; - //scr.drawFilledRectangle(int(x), baseline - Ascent(font) + 1, - // Width(font) - 2, Ascent(font) + Descent(font)-2, - // FL_GRAY80); scr.fillRectangle(gc_lighted, int(x), baseline - Ascent(font) + 1, Width(font) - 6, @@ -80,9 +77,6 @@ void InsetCommand::Draw(LyXFont font, LyXScreen &scr, h = (Ascent(font)+Descent(font)-2); scr.drawFrame(FL_UP_FRAME, int(x), y, w, h, FL_BLACK, -1); } else { - //scr.drawRectangle(int(x), baseline - Ascent(font)+1, - // Width(font)-2, Ascent(font)+Descent(font)-2, - // FL_BLACK); scr.drawRectangle(gc_note_frame, int(x), baseline - Ascent(font)+1, Width(font)-6, @@ -100,13 +94,13 @@ void InsetCommand::Draw(LyXFont font, LyXScreen &scr, // In lyxf3 this will be just LaTeX -void InsetCommand::Write(FILE *file) +void InsetCommand::Write(FILE * file) { fprintf(file, "LatexCommand %s\n", getCommand().c_str()); } -void InsetCommand::scanCommand(string const &cmd) +void InsetCommand::scanCommand(string const & cmd) { string tcommand, toptions, tcontents; @@ -170,7 +164,7 @@ void InsetCommand::scanCommand(string const &cmd) // This function will not be necessary when lyx3 -void InsetCommand::Read(LyXLex &lex) +void InsetCommand::Read(LyXLex & lex) { if (lex.EatLine()) { string t = lex.GetString(); @@ -180,14 +174,14 @@ void InsetCommand::Read(LyXLex &lex) } -int InsetCommand::Latex(FILE *file, signed char /*fragile*/) +int InsetCommand::Latex(FILE * file, signed char /*fragile*/) { fprintf(file, "%s", getCommand().c_str()); return 0; } -int InsetCommand::Latex(string &file, signed char /*fragile*/) +int InsetCommand::Latex(string & file, signed char /*fragile*/) { file += getCommand(); return 0; @@ -206,9 +200,9 @@ int InsetCommand::DocBook(string &/*file*/) } -Inset* InsetCommand::Clone() +Inset * InsetCommand::Clone() { - InsetCommand *result = new InsetCommand(command, contents, options); + InsetCommand * result = new InsetCommand(command, contents, options); return result; } diff --git a/src/insets/insetcommand.h b/src/insets/insetcommand.h index 1657ce931c..b1a53e82bf 100644 --- a/src/insets/insetcommand.h +++ b/src/insets/insetcommand.h @@ -5,12 +5,12 @@ * LyX, The Document Processor * * Copyright (C) 1995 Matthias Ettrich - * Copyright (C) 1996-1998 The LyX Team. + * Copyright (C) 1996-1999 The LyX Team. * - *======================================================*/ + * ======================================================*/ -#ifndef _INSET_LATEXCOMMAND_H -#define _INSET_LATEXCOMMAND_H +#ifndef INSET_LATEXCOMMAND_H +#define INSET_LATEXCOMMAND_H #ifdef __GNUG__ #pragma interface @@ -35,29 +35,29 @@ public: /// ~InsetCommand(); /// - int Ascent(LyXFont const &font) const; + int Ascent(LyXFont const & font) const; /// - int Descent(LyXFont const &font) const; + int Descent(LyXFont const & font) const; /// - int Width(LyXFont const &font) const; + int Width(LyXFont const & font) const; /// - void Draw(LyXFont, LyXScreen &scr, int baseline, float &x); + void Draw(LyXFont, LyXScreen & scr, int baseline, float & x); /// - void Write(FILE *file); + void Write(FILE * file); /// Parse the command. - void scanCommand(string const &cmd); + void scanCommand(string const & cmd); /// Will not be used when lyxf3 - void Read(LyXLex &lex); + void Read(LyXLex & lex); /// - virtual int Latex(FILE *file, signed char fragile); + virtual int Latex(FILE * file, signed char fragile); /// - virtual int Latex(string &file, signed char fragile); + virtual int Latex(string & file, signed char fragile); /// - virtual int Linuxdoc(string &file); + virtual int Linuxdoc(string & file); /// - virtual int DocBook(string &file); + virtual int DocBook(string & file); /// - Inset* Clone(); + Inset * Clone(); /// Inset::Code LyxCode() const { @@ -78,15 +78,15 @@ public: /// Build the complete LaTeX command string getCommand() const; /// - string const &getCmdName() const { + string const & getCmdName() const { return command; } /// - string const &getOptions() const { + string const & getOptions() const { return options; } /// - string const &getContents() const { + string const & getContents() const { return contents; } /// diff --git a/src/insets/inseterror.C b/src/insets/inseterror.C index 42f3a1e63d..1d4bd36a1d 100644 --- a/src/insets/inseterror.C +++ b/src/insets/inseterror.C @@ -27,8 +27,8 @@ InsetError::InsetError() form = 0; } -InsetError::InsetError(string const & string) - : contents(string) +InsetError::InsetError(string const & str) + : contents(str) { form = 0; } @@ -44,7 +44,7 @@ InsetError::~InsetError() } -int InsetError::Ascent(LyXFont const &font) const +int InsetError::Ascent(LyXFont const & font) const { LyXFont efont; efont.setSize(font.size()).decSize(); @@ -52,7 +52,7 @@ int InsetError::Ascent(LyXFont const &font) const } -int InsetError::Descent(LyXFont const &font) const +int InsetError::Descent(LyXFont const & font) const { LyXFont efont; efont.setSize(font.size()).decSize(); @@ -60,7 +60,7 @@ int InsetError::Descent(LyXFont const &font) const } -int InsetError::Width(LyXFont const &font) const +int InsetError::Width(LyXFont const & font) const { LyXFont efont; efont.setSize(font.size()).decSize(); @@ -68,8 +68,8 @@ int InsetError::Width(LyXFont const &font) const } -void InsetError::Draw(LyXFont font, LyXScreen &scr, - int baseline, float &x) +void InsetError::Draw(LyXFont font, LyXScreen & scr, + int baseline, float & x) { LyXFont efont; efont.setSize(font.size()).decSize(); @@ -77,15 +77,9 @@ void InsetError::Draw(LyXFont font, LyXScreen &scr, // Draw as "Error" in a framed box x += 1; - //scr.drawFilledRectangle(int(x), baseline - Ascent(font)+1, - // Width(font)-2,Ascent(font)+ Descent(font)-2, - // FL_GRAY80); scr.fillRectangle(gc_lighted, int(x), baseline - Ascent(font)+1, Width(font)-2,Ascent(font)+ Descent(font)-2); - //scr.drawRectangle(int(x), baseline-Ascent(font)+1, - // Width(font)-2, Ascent(font)+Descent(font)-2, - // FL_RED); scr.drawRectangle(gc_foot, int(x), baseline-Ascent(font)+1, Width(font)-2, Ascent(font)+Descent(font)-2); @@ -140,9 +134,9 @@ unsigned char InsetError::Editable() const } -void InsetError::CloseErrorCB(FL_OBJECT *, long data) +void InsetError::CloseErrorCB(FL_OBJECT * ob, long) { - InsetError *inset = (InsetError*) data; + InsetError * inset = static_cast(ob->u_vdata); if (inset->form) { fl_hide_form(inset->form); fl_free_form(inset->form); @@ -150,10 +144,11 @@ void InsetError::CloseErrorCB(FL_OBJECT *, long data) } } + // A C wrapper -extern "C" void C_InsetError_CloseErrorCB(FL_OBJECT *, long data) +extern "C" void C_InsetError_CloseErrorCB(FL_OBJECT * ob, long data) { - InsetError::CloseErrorCB(0,data); + InsetError::CloseErrorCB(ob , data); } @@ -162,13 +157,14 @@ void InsetError::Edit(int, int) static int ow = 400, oh = 240; if (!form) { - FL_OBJECT *obj; - form = fl_bgn_form(FL_UP_BOX,ow,oh); + FL_OBJECT * obj; + form = fl_bgn_form(FL_UP_BOX, ow, oh); strobj = fl_add_box(FL_FRAME_BOX,10,10,380,180,""); fl_set_object_color(strobj,FL_MCOL,FL_MCOL); fl_set_object_gravity(strobj, FL_NorthWest, FL_SouthEast); obj = fl_add_button(FL_RETURN_BUTTON,140,200,120,30,_("Close")); - fl_set_object_callback(obj, C_InsetError_CloseErrorCB, (long)this); + fl_set_object_callback(obj, C_InsetError_CloseErrorCB, 0); + obj->u_vdata = this; fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); fl_set_object_resize(obj, FL_RESIZE_NONE); fl_end_form(); @@ -187,6 +183,6 @@ void InsetError::Edit(int, int) Inset* InsetError::Clone() { - InsetError *result = new InsetError(contents); + InsetError * result = new InsetError(contents); return result; } diff --git a/src/insets/inseterror.h b/src/insets/inseterror.h index cdc03f41dc..1bde3a4d03 100644 --- a/src/insets/inseterror.h +++ b/src/insets/inseterror.h @@ -8,8 +8,8 @@ * *======================================================*/ -#ifndef _INSET_ERROR_H -#define _INSET_ERROR_H +#ifndef INSET_ERROR_H +#define INSET_ERROR_H #ifdef __GNUG__ #pragma interface @@ -34,35 +34,35 @@ public: /// ~InsetError(); /// - int Ascent(LyXFont const &font) const; + int Ascent(LyXFont const & font) const; /// - int Descent(LyXFont const &font) const; + int Descent(LyXFont const & font) const; /// - int Width(LyXFont const &font) const; + int Width(LyXFont const & font) const; /// - void Draw(LyXFont font, LyXScreen &scr, int baseline, float &x); + void Draw(LyXFont font, LyXScreen & scr, int baseline, float & x); /// - void Write(FILE *file); + void Write(FILE * file); /// - void Read(LyXLex &lex); + void Read(LyXLex & lex); /// - int Latex(FILE *file, signed char fragile); + int Latex(FILE * file, signed char fragile); /// - int Latex(string &file, signed char fragile); + int Latex(string & file, signed char fragile); /// - int Linuxdoc(string &file); + int Linuxdoc(string & file); /// - int DocBook(string &file); + int DocBook(string & file); /// bool AutoDelete() const; /// what appears in the minibuffer when opening - char const* EditMessage() {return _("Opened error");} + char const * EditMessage() {return _("Opened error");} /// void Edit(int, int); /// unsigned char Editable() const; /// - Inset* Clone(); + Inset * Clone(); /// Inset::Code LyxCode() const { return Inset::NO_CODE; } /// We don't want "begin" and "end inset" in lyx-file @@ -73,8 +73,8 @@ private: /// string contents; /// - FL_FORM *form; + FL_FORM * form; /// - FL_OBJECT *strobj; + FL_OBJECT * strobj; }; #endif diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 283eb0a1f1..f881d9b103 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -20,18 +20,19 @@ #include "gettext.h" #include "include_form.h" #include "support/FileInfo.h" +#include "layout.h" -extern BufferView *current_view; +extern BufferView * current_view; -extern LyXRC *lyxrc; +extern LyXRC * lyxrc; extern BufferList bufferlist; -extern void UpdateInset(Inset* inset, bool mark_dirty = true); +extern void UpdateInset(Inset * inset, bool mark_dirty = true); -FD_include *create_form_include(void) +FD_include * create_form_include(void) { - FL_OBJECT *obj; - FD_include *fdui = (FD_include *) fl_calloc(1, sizeof(FD_include)); + FL_OBJECT * obj; + FD_include * fdui = (FD_include *) fl_calloc(1, sizeof(FD_include)); fdui->include = fl_bgn_form(FL_NO_BOX, 340, 210); obj = fl_add_box(FL_UP_BOX,0,0,340,210,""); @@ -86,12 +87,12 @@ FD_include *create_form_include(void) /*---------------------------------------*/ -FD_include *form = 0; +FD_include * form = 0; extern "C" void include_cb(FL_OBJECT *, long arg) { - InsetInclude *inset = (InsetInclude*)form->vdata; + InsetInclude * inset = static_cast(form->include->u_vdata); switch (arg) { case 0: { @@ -183,7 +184,7 @@ extern "C" void include_cb(FL_OBJECT *, long arg) } -InsetInclude::InsetInclude(string const & fname, Buffer *bf) +InsetInclude::InsetInclude(string const & fname, Buffer * bf) : InsetCommand("include") { master = bf; @@ -195,7 +196,7 @@ InsetInclude::InsetInclude(string const & fname, Buffer *bf) InsetInclude::~InsetInclude() { - if (form && form->vdata == this) { + if (form && form->include->u_vdata == this) { // this inset is in the popup so hide the popup // and remove the reference to this inset. ARRae if (form->include) { @@ -221,7 +222,7 @@ Inset * InsetInclude::Clone() ii->setVerb(); ii->setVisibleSpace(isVerbVisibleSpace()); } - return (Inset*)ii; + return ii; } void InsetInclude::Edit(int, int) @@ -233,7 +234,7 @@ void InsetInclude::Edit(int, int) form = create_form_include(); fl_set_form_atclose(form->include, IgnoreCloseBoxCB, 0); } - form->vdata = this; + form->include->u_vdata = this; fl_set_input(form->input, contents.c_str()); fl_set_button(form->flag1, int(isNoLoad())); @@ -257,13 +258,13 @@ void InsetInclude::Edit(int, int) } -void InsetInclude::Write(FILE *file) +void InsetInclude::Write(FILE * file) { fprintf(file, "Include %s\n", getCommand().c_str()); } -void InsetInclude::Read(LyXLex &lex) +void InsetInclude::Read(LyXLex & lex) { InsetCommand::Read(lex); @@ -313,7 +314,7 @@ bool InsetInclude::loadIfNeeded() const } -int InsetInclude::Latex(FILE *file, signed char /*fragile*/) +int InsetInclude::Latex(FILE * file, signed char /*fragile*/) { string include_file; signed char dummy = 0; @@ -323,7 +324,7 @@ int InsetInclude::Latex(FILE *file, signed char /*fragile*/) } -int InsetInclude::Latex(string &file, signed char /*fragile*/) +int InsetInclude::Latex(string & file, signed char /*fragile*/) { string writefile, incfile; @@ -341,9 +342,9 @@ int InsetInclude::Latex(string &file, signed char /*fragile*/) lyxerr << "ERROR: Cannot handle include file `" << MakeDisplayPath(getFileName()) << "' which has textclass `" - << lyxstyle.NameOfClass(tmp->params.textclass) + << textclasslist.NameOfClass(tmp->params.textclass) << "' instead of `" - << lyxstyle.NameOfClass(master->params.textclass) + << textclasslist.NameOfClass(master->params.textclass) << "'." << endl; return 0; } @@ -400,7 +401,7 @@ int InsetInclude::Latex(string &file, signed char /*fragile*/) } -void InsetInclude::Validate(LaTeXFeatures& features) const +void InsetInclude::Validate(LaTeXFeatures & features) const { if (isVerb()) features.verbatim = true; @@ -410,7 +411,7 @@ void InsetInclude::Validate(LaTeXFeatures& features) const // to be loaded: if (loadIfNeeded()) { // a file got loaded - Buffer *tmp = bufferlist.getBuffer(getFileName()); + Buffer * tmp = bufferlist.getBuffer(getFileName()); tmp->validate(features); } } @@ -423,7 +424,7 @@ string InsetInclude::getLabel(int) const if (loadIfNeeded()) { - Buffer *tmp = bufferlist.getBuffer(getFileName()); + Buffer * tmp = bufferlist.getBuffer(getFileName()); tmp->setParentName(""); label = tmp->getReferenceList('\n'); tmp->setParentName(getMasterFilename()); @@ -438,7 +439,7 @@ int InsetInclude::GetNumberOfLabels() const { int nl; if (loadIfNeeded()) { - Buffer *tmp = bufferlist.getBuffer(getFileName()); + Buffer * tmp = bufferlist.getBuffer(getFileName()); tmp->setParentName(""); label = tmp->getReferenceList('\n'); tmp->setParentName(getMasterFilename()); @@ -451,14 +452,14 @@ int InsetInclude::GetNumberOfLabels() const { string InsetInclude::getKeys() const { - string list; + string lst; if (loadIfNeeded()) { Buffer *tmp = bufferlist.getBuffer(getFileName()); tmp->setParentName(""); - list = tmp->getBibkeyList(','); + lst = tmp->getBibkeyList(','); tmp->setParentName(getMasterFilename()); } - return list; + return lst; } diff --git a/src/insets/insetinclude.h b/src/insets/insetinclude.h index 4919819f62..a37d9a2b79 100644 --- a/src/insets/insetinclude.h +++ b/src/insets/insetinclude.h @@ -6,7 +6,7 @@ * * Copyright (C) 1997 LyX Team (this file was created this year) * - *======================================================*/ + * ======================================================*/ #ifndef INSET_INCLUDE_H #define INSET_INCLUDE_H @@ -33,11 +33,11 @@ public: flag = InsetInclude::INCLUDE; } /// - InsetInclude(string const &, Buffer*); + InsetInclude(string const &, Buffer *); /// ~InsetInclude(); /// - Inset* Clone(); + Inset * Clone(); /// Inset::Code LyxCode() const { return Inset::INCLUDE_CODE; } /// This is 1 if the childs have labels, 0 otherwise @@ -58,9 +58,9 @@ public: /// void Read(LyXLex &); /// - int Latex(FILE *file, signed char fragile); + int Latex(FILE * file, signed char fragile); /// - int Latex(string &file, signed char fragile); + int Latex(string & file, signed char fragile); /// void Validate(LaTeXFeatures &) const; @@ -84,18 +84,18 @@ public: return filename; } /// In "input" mode uses \input instead of \include. - bool isInput() const { return (bool)(flag == InsetInclude::INPUT); } + bool isInput() const { return flag == InsetInclude::INPUT; } /// If this is true, the child file shouldn't be loaded by lyx - bool isNoLoad() const { return (bool)(noload); } + bool isNoLoad() const { return noload; } /** A verbatim file shouldn't be loaded by LyX * No need to generate LaTeX code of a verbatim file */ bool isVerb() const; /// - bool isVerbVisibleSpace() const { return (bool)(flag==InsetInclude::VERBAST);} + bool isVerbVisibleSpace() const { return flag==InsetInclude::VERBAST;} /// - bool isInclude() const { return (bool)(flag == InsetInclude::INCLUDE);} + bool isInclude() const { return flag == InsetInclude::INCLUDE;} /// void setInput(); /// @@ -126,7 +126,7 @@ private: /// int flag; /// - Buffer *master; + Buffer * master; /// string filename; }; diff --git a/src/insets/insetindex.C b/src/insets/insetindex.C index 035c3dd511..a46d471e2d 100644 --- a/src/insets/insetindex.C +++ b/src/insets/insetindex.C @@ -1,6 +1,6 @@ #include -#include +#include #ifdef __GNUG__ #pragma implementation @@ -15,24 +15,16 @@ #include "LString.h" #include "lyx_gui_misc.h" // WarnReadonly() -extern BufferView *current_view; -extern void UpdateInset(Inset* inset, bool mark_dirty = true); +extern BufferView * current_view; +extern void UpdateInset(Inset * inset, bool mark_dirty = true); -FD_index_form *index_form = 0; +FD_index_form * index_form = 0; extern "C" void index_cb(FL_OBJECT *, long data) { - InsetIndex *inset = (InsetIndex*)index_form->vdata; + InsetIndex * inset = static_cast(index_form->index_form->u_vdata); switch (data) { -// - case 0: fl_hide_form(index_form->index_form); break; -// - case 1: -// - { -// - inset->setContents(fl_get_input(index_form->key)); -// - fl_hide_form(index_form->index_form); -// - UpdateInset(inset); -// - break; -// - } case 1: // OK if(!current_view->currentBuffer()->isReadonly()) { string tmp = fl_get_input(index_form->key); @@ -50,9 +42,9 @@ extern "C" void index_cb(FL_OBJECT *, long data) static -FD_index_form *create_form_index_form() +FD_index_form * create_form_index_form() { - FL_OBJECT *obj; + FL_OBJECT * obj; FD_index_form *fdui = (FD_index_form *) fl_calloc(1, sizeof(FD_index_form)); fdui->index_form = fl_bgn_form(FL_NO_BOX, 258, 196); @@ -89,7 +81,7 @@ InsetIndex::~InsetIndex() { if(index_form && index_form->index_form && index_form->index_form->visible - && index_form->vdata == this) + && index_form->index_form->u_vdata == this) fl_hide_form(index_form->index_form); } @@ -102,7 +94,7 @@ void InsetIndex::Edit(int, int) if (!index_form) index_form = create_form_index_form(); - index_form->vdata = this; + index_form->index_form->u_vdata = this; fl_set_input(index_form->key, getContents().c_str()); if (index_form->index_form->visible) { fl_raise_form(index_form->index_form); @@ -131,7 +123,7 @@ InsetPrintIndex::InsetPrintIndex() } -InsetPrintIndex::InsetPrintIndex(Buffer *o) +InsetPrintIndex::InsetPrintIndex(Buffer * o) : InsetCommand("printindex"), owner(o) { } @@ -148,7 +140,7 @@ string InsetPrintIndex::getScreenLabel() const } -void InsetPrintIndex::Validate(LaTeXFeatures &features) const +void InsetPrintIndex::Validate(LaTeXFeatures & features) const { features.makeidx = true; } diff --git a/src/insets/insetindex.h b/src/insets/insetindex.h index 76db96764f..6470404e28 100644 --- a/src/insets/insetindex.h +++ b/src/insets/insetindex.h @@ -4,13 +4,13 @@ * * LyX, The Document Processor * - * Copyright (C) 1995 Matthias Ettrich - * 1996-1998 LyX Team + * Copyright 1995 Matthias Ettrich + * Copyright 1996-1999 the LyX Team. * - *======================================================*/ + * ======================================================*/ -#ifndef _INSET_INDEX_H -#define _INSET_INDEX_H +#ifndef INSET_INDEX_H +#define INSET_INDEX_H #ifdef __GNUG__ #pragma interface @@ -35,7 +35,7 @@ public: /// ~InsetIndex(); /// - Inset *Clone() { return new InsetIndex(contents);} + Inset * Clone() { return new InsetIndex(contents);} /// void Edit(int, int); /// @@ -53,13 +53,13 @@ public: /// InsetPrintIndex(); /// - InsetPrintIndex(Buffer*); + InsetPrintIndex(Buffer *); /// ~InsetPrintIndex(); /// Updates needed features for this inset. - void Validate(LaTeXFeatures &features) const; + void Validate(LaTeXFeatures & features) const; /// - void Edit(int, int){;} + void Edit(int, int) {} /// unsigned char Editable() const{ return 1; @@ -72,18 +72,16 @@ public: string getScreenLabel() const; private: /// - Buffer *owner; + Buffer * owner; }; // this was shifted here rather than a separate // file because its little and only need by // insetindex.C and lyx_gui_misc.C ARRae 981020 struct FD_index_form { - FL_FORM *index_form; - FL_OBJECT *key; - void *vdata; - long ldata; + FL_FORM * index_form; + FL_OBJECT * key; }; -extern FD_index_form *index_form; +extern FD_index_form * index_form; #endif diff --git a/src/insets/insetinfo.C b/src/insets/insetinfo.C index 52e8935c17..139d32167d 100644 --- a/src/insets/insetinfo.C +++ b/src/insets/insetinfo.C @@ -52,26 +52,26 @@ InsetInfo::~InsetInfo() } -int InsetInfo::Ascent(LyXFont const &font) const +int InsetInfo::Ascent(LyXFont const & font) const { - return font.maxAscent()+1; + return font.maxAscent() + 1; } -int InsetInfo::Descent(LyXFont const &font) const +int InsetInfo::Descent(LyXFont const & font) const { - return font.maxDescent()+1; + return font.maxDescent() + 1; } -int InsetInfo::Width(LyXFont const &font) const +int InsetInfo::Width(LyXFont const & font) const { return 6 + font.textWidth(_("Note"), strlen(_("Note"))); } -void InsetInfo::Draw(LyXFont font, LyXScreen &scr, - int baseline, float &x) +void InsetInfo::Draw(LyXFont font, LyXScreen & scr, + int baseline, float & x) { /* Info-insets are never LaTeX, so just correct the font */ font.setLatex(LyXFont::OFF); @@ -90,13 +90,13 @@ void InsetInfo::Draw(LyXFont font, LyXScreen &scr, } -void InsetInfo::Write(FILE *file) +void InsetInfo::Write(FILE * file) { fprintf(file, "Info %s", contents.c_str()); } -void InsetInfo::Read(LyXLex &lex) +void InsetInfo::Read(LyXLex & lex) { string tmp = lex.GetString(); // should be "Info" if (tmp != "Info") @@ -153,12 +153,11 @@ unsigned char InsetInfo::Editable() const } -void InsetInfo::CloseInfoCB(FL_OBJECT *, long data) +void InsetInfo::CloseInfoCB(FL_OBJECT * ob, long) { - InsetInfo *inset = (InsetInfo*) data; -// inset->contents = fl_get_input(inset->strobj); + InsetInfo * inset = static_cast(ob->u_vdata); string tmp = fl_get_input(inset->strobj); - Buffer *buffer = current_view->currentBuffer(); + Buffer * buffer = current_view->currentBuffer(); if(tmp != inset->contents && !(buffer->isReadonly()) ) { buffer->markDirty(); inset->contents = tmp; @@ -170,12 +169,14 @@ void InsetInfo::CloseInfoCB(FL_OBJECT *, long data) } } + // This is just a wrapper. -extern "C" void C_InsetInfo_CloseInfoCB(FL_OBJECT *, long data) +extern "C" void C_InsetInfo_CloseInfoCB(FL_OBJECT * ob, long data) { - InsetInfo::CloseInfoCB(0, data); + InsetInfo::CloseInfoCB(ob, data); } + void InsetInfo::Edit(int, int) { static int ow = -1, oh; @@ -193,8 +194,9 @@ void InsetInfo::Edit(int, int) obj = fl_add_button(FL_NORMAL_BUTTON,130,140,120,30,idex(_("Close|#C^["))); fl_set_object_resize(obj, FL_RESIZE_NONE); fl_set_object_gravity(obj, SouthEastGravity, SouthEastGravity); - fl_set_object_callback(obj, C_InsetInfo_CloseInfoCB, (long)this); - fl_set_object_shortcut(obj, scex(_("Close|#C^[")), (long)this); + fl_set_object_callback(obj, C_InsetInfo_CloseInfoCB, 0); + obj->u_vdata = this; + fl_set_object_shortcut(obj, scex(_("Close|#C^[")), 1); fl_end_form(); fl_set_form_atclose(form, CancelCloseBoxCB, 0); } @@ -215,7 +217,7 @@ void InsetInfo::Edit(int, int) Inset* InsetInfo::Clone() { - InsetInfo *result = new InsetInfo(contents); + InsetInfo * result = new InsetInfo(contents); return result; } diff --git a/src/insets/insetinfo.h b/src/insets/insetinfo.h index edd3e9fa1e..5023a069fd 100644 --- a/src/insets/insetinfo.h +++ b/src/insets/insetinfo.h @@ -4,12 +4,13 @@ * * LyX, The Document Processor * - * Copyright (C) 1995 Matthias Ettrich + * Copyright 1995 Matthias Ettrich + * Copyright 1995-1999 the LyX Team. * - *======================================================*/ + * ======================================================*/ -#ifndef _INSET_INFO_H -#define _INSET_INFO_H +#ifndef INSET_INFO_H +#define INSET_INFO_H #ifdef __GNUG__ #pragma interface @@ -36,27 +37,27 @@ public: /// ~InsetInfo(); /// - int Ascent(LyXFont const &font) const; + int Ascent(LyXFont const & font) const; /// - int Descent(LyXFont const &font) const; + int Descent(LyXFont const & font) const; /// - int Width(LyXFont const &font) const; + int Width(LyXFont const & font) const; /// - void Draw(LyXFont font, LyXScreen &scr, int baseline, float &x); + void Draw(LyXFont font, LyXScreen & scr, int baseline, float & x); /// - void Write(FILE *file); + void Write(FILE * file); /// - void Read(LyXLex &lex); + void Read(LyXLex & lex); /// - int Latex(FILE *file, signed char fragile); + int Latex(FILE * file, signed char fragile); /// - int Latex(string &file, signed char fragile); + int Latex(string & file, signed char fragile); /// - int Linuxdoc(string &file); + int Linuxdoc(string & file); /// - int DocBook(string &file); + int DocBook(string & file); /// what appears in the minibuffer when opening - char const* EditMessage() {return "Opened note";} + char const * EditMessage() {return "Opened note";} /// void Edit(int, int); /// @@ -64,16 +65,15 @@ public: /// Inset::Code LyxCode() const; /// - Inset* Clone(); + Inset * Clone(); /// static void CloseInfoCB(FL_OBJECT *, long data); private: /// string contents; /// - FL_FORM *form; + FL_FORM * form; /// - FL_OBJECT *strobj; + FL_OBJECT * strobj; }; - #endif diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index 2ebb685295..6ef9e342a8 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -30,9 +30,9 @@ InsetLabel::~InsetLabel() } -Inset* InsetLabel::Clone() +Inset * InsetLabel::Clone() { - InsetLabel *result = new InsetLabel(getCommand()); + InsetLabel * result = new InsetLabel(getCommand()); return result; } @@ -48,28 +48,28 @@ string InsetLabel::getLabel(int) const return contents; } -int InsetLabel::Latex(FILE *file, signed char /*fragile*/) +int InsetLabel::Latex(FILE * file, signed char /*fragile*/) { fprintf(file, "%s", escape(getCommand()).c_str()); return 0; } -int InsetLabel::Latex(string &file, signed char /*fragile*/) +int InsetLabel::Latex(string & file, signed char /*fragile*/) { file += escape(getCommand()); return 0; } -int InsetLabel::Linuxdoc(string &file) +int InsetLabel::Linuxdoc(string & file) { file += "