]> git.lyx.org Git - lyx.git/commitdiff
the runlatex merge
authorLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 4 Nov 1999 01:40:20 +0000 (01:40 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 4 Nov 1999 01:40:20 +0000 (01:40 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@291 a592a061-630c-0410-9148-cb99ea01b6c8

102 files changed:
ChangeLog
Makefile.am
src/BackStack.h
src/BufferView.C
src/BufferView.h
src/Chktex.C
src/DepTable.C
src/DepTable.h
src/LaTeX.C
src/LaTeX.h
src/LaTeXFeatures.C
src/Literate.C
src/Literate.h
src/LyXSendto.C
src/LyXView.C
src/LyXView.h
src/PaperLayout.C
src/ParagraphExtra.C
src/TableLayout.C
src/broken_headers.h
src/buffer.C
src/buffer.h
src/bufferlist.h
src/bufferparams.C
src/bufferparams.h
src/debug.h
src/insets/figinset.C
src/insets/inset.C
src/insets/insetbib.C
src/insets/insetbib.h
src/insets/insetcommand.C
src/insets/insetcommand.h
src/insets/inseterror.C
src/insets/inseterror.h
src/insets/insetinclude.C
src/insets/insetinclude.h
src/insets/insetindex.C
src/insets/insetindex.h
src/insets/insetinfo.C
src/insets/insetinfo.h
src/insets/insetlabel.C
src/insets/insetlabel.h
src/insets/insetlatex.C
src/insets/insetlatex.h
src/insets/insetlatexaccent.C
src/insets/insetlatexaccent.h
src/insets/insetloa.C
src/insets/insetloa.h
src/insets/insetlof.h
src/insets/insetlot.h
src/insets/insetparent.C
src/insets/insetparent.h
src/insets/insetquotes.C
src/insets/insetquotes.h
src/insets/insetref.C
src/insets/insetref.h
src/insets/insetspecialchar.C
src/insets/insetspecialchar.h
src/insets/insettoc.C
src/insets/insettoc.h
src/insets/inseturl.C
src/insets/inseturl.h
src/insets/lyxinset.h
src/kbmap.C
src/lastfiles.C
src/lastfiles.h
src/layout.C
src/layout.h
src/lyx_cb.C
src/lyx_gui_misc.C
src/lyx_main.C
src/lyxcursor.h
src/lyxfont.C
src/lyxfr1.C
src/lyxfr1.h
src/lyxfunc.C
src/lyxparagraph.h
src/lyxrc.C
src/lyxrc.h
src/lyxrow.h
src/lyxtext.h
src/lyxvc.C
src/mathed/formula.C
src/mathed/math_cursor.C
src/mathed/math_draw.C
src/mathed/math_hash.C
src/mathed/math_inset.C
src/mathed/math_iter.C
src/menus.C
src/paragraph.C
src/support/Makefile.am
src/support/filetools.C
src/support/lyxstring.C
src/support/syscall.C
src/table.C
src/texrow.h
src/text.C
src/text2.C
src/trans.C
src/trans.h
src/vspace.C
src/vspace.h

index 9b18bad7ffd020ee545746fa38b80b29034b0e55..3fb7552597b938b5368ea7a7d3c90d0392890a6a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 
 1999-11-02  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
+       * 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.
 
        * added patch for OS/2 from SMiyata.
 
+1999-10-29  Lars Gullik Bjønnes  <larsbj@lyx.org>
+
+       * 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  <Jean-Marc.Lasgouttes@inria.fr>
 
        * src/support/syscall.C (Systemcalls::kill): 
 
 1999-10-28  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
+       * 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
 
 1999-10-27  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
+       * 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...
        * src/lyx_cb.C (MenuFax): subst fix
        (PrintApplyCB): subst fix
 
+1999-10-26  Juergen Vigna  <jug@sad.it>
+
+       * 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  <larsbj@lyx.org>
 
+       * 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.
 
 1999-10-24  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
+1999-10-24  Lars Gullik Bjønnes  <larsbj@lyx.org>
+
+       * 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
 
 1999-10-22  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
+       * 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.
 
 1999-10-20  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
+       * 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.
        * src/lyxrc.C (Read): RC_PRINTEXSTRAOPTIONS now uses
        LyXLex::next() and not eatline() to get its argument.
 
+1999-10-17  Lars Gullik Bjønnes  <larsbj@lyx.org>
+
+       * 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  <larsbj@lyx.org>
 
+       * 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
index f1a91f23108e9fa05a9a1f3134e36fcabbad3efa..5da61745cfa6903712df1fdb4e0dd37cceb8cab9 100644 (file)
@@ -22,3 +22,4 @@ rpmdist: dist
        ln -s images/lyx.xpm . ; \
        rpm -ta ${PACKAGE}-${VERSION}.tar.gz ; \
        rm lyx.xpm
+
index 5ca40451a3cb009f7bcaa6a8091ccb85a648d6ac..b56bb641476158fcdbefeb10b119af15def9da88 100644 (file)
@@ -11,6 +11,7 @@
 #ifndef BACK_STACK_H
 #define BACK_STACK_H
 
+#include <stack>
 #include "LString.h"
 
 // Created by Alejandro Aguilar Sierra, 970806
 /**  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<BackStackItem> stakk;
 };
 
 #endif
index a9abd9ff9cc6112a7fc83383395c17a3d6888347..e8f2fd63e2db4440670f5a013ee599ccbe31dc2d 100644 (file)
@@ -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<BufferView*>(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<unsigned char*>(""), 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<BufferView*>(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<BufferView*>(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<XEvent*>(xev);
+       BufferView * view = static_cast<BufferView*>(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<BufferView*>(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<char*>(uc));
+                       } else {
                                _buffer->text->
-                                       InsertStringB((char*)uc);
+                                       InsertStringB(reinterpret_cast<char*>(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);
index 25157ba3253a4d4cee63094c9e57b834be719fbc..07bc95f88a3d72b922443318d0108614bfa20b7c 100644 (file)
@@ -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;
 };
index dc94696ace1b5a8317eee8d9a2b7a3c89ef74575..f4f9cf22da5b0052fce3e303fbd216030be4aad4 100644 (file)
@@ -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;
 }
index e3a5acc2621217fcbad6bb0f92b206b590333a15..dd15f5d042899b9346379dde09e745cbbade70fb 100644 (file)
 
 #include <config.h>
 
+#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 <fstream>
 
 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::read(string const &f)
+void DepTable::write(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);
+       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::write(FILE * f)
+void DepTable::read(string const &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;
+       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);
        }
-       fprintf(f, "%s %lu %lu\n", file.c_str(),
-               new_sum, old_sum);
-       if (next)
-               next->write(f);
 }
index f23e66adb22440a7efd925c2e25ab3ccec29956c..0f9b4827fe24eb5a5c40f9e92a1a87250d29542a 100644 (file)
 #define DEP_TABLE_H
 
 #include "LString.h"
-#include <cstdio>
+#include <map>
+
+#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);
-       ///
-       string file;
-       /// The files new checksum
-       unsigned long new_sum;
-       /// The files old checksum
-       unsigned long old_sum;
-       ///
-       DepTable *next;
-               
+       typedef map<string, pair<unsigned long, unsigned long> > DepList;
        ///
-       void write(FILE *f);
+       DepList deplist;
 };
 
 #endif
index b1758d2749634a7e49bd69b3d7dbd7da588a73d2..f05672c1c39ce11885869202fda4dc5979a28e63 100644 (file)
 
 #include <config.h>
 
-#include <cstdio>
-#include <cstdlib>
-
 #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"
 #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()
-{
-       Error *tmp;
-       while (errors) {
-               tmp = errors->next_error;
-               delete errors;
-               errors = tmp;
-       }
-}
-
-
-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::insertError(int line, string const & error_desc,
+                           string const & error_text)
 {
+        Error newerr(line, error_desc, error_text);
+       errors.push_back(newerr);
 }
 
-
-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 <file>.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<int, string> 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<char>(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,
index 99e3a56e26a8c7eb7c105c0552007519c508bfe6..e81348eca58902d4f5c841cde009af88fbda2b8f 100644 (file)
 
 #include "LString.h"
 #include "DepTable.h"
+#include <vector>
+#include <fstream>
 
-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:
+       ///
+       typedef vector<Error> Errors;
        ///
-       Error *errors;
+       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:
        ///
-       Error *next_error;
+       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:
-         <file> <new checksum> <old checksum>
-       */
+       /// 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;
index 21cf9e4d111ae3df5b711f8f123593f27f415582..6c2c72669b37b346e36a7ce394636b000fe2d7db 100644 (file)
@@ -77,7 +77,7 @@ LaTeXFeatures::LaTeXFeatures(int n)
 string LaTeXFeatures::getPackages(BufferParams const &params)
 {
        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 &params)
                
        // 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 &params)
                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 &params)
+string LaTeXFeatures::getTClassPreamble(BufferParams const & params)
 {
        // the text class specific preamble 
-       LyXTextClass *tclass = lyxstyle.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;
+       LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
+       string tcpreamble = tclass.preamble();
+
+       for (LyXTextClass::LayoutList::const_iterator cit = tclass.begin();
+            cit != tclass.end(); ++cit) {
+               tcpreamble += (*cit).preamble();
        }
 
        return tcpreamble;
 }      
 
 
-void LaTeXFeatures::showStruct(BufferParams &params) {
+void LaTeXFeatures::showStruct(BufferParams & params) {
        lyxerr << "LyX needs the following commands when LaTeXing:"
        // packs
               << "\n***** Packages:" << getPackages(params)
index a91a40b26732eb94267d934a08551a8c29ff4774..0be43b816292b28e9b20259b92e5cb6794bfedda 100644 (file)
@@ -10,9 +10,6 @@
 
 #include <config.h>
 
-#include <cstdio>
-#include <cstdlib>
-
 #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;
 }
-
-
index 17827c36acbc4e0512572f0044c2452043e23f3a..020a0b024b7f440e9638e02188fab49ae679814b 100644 (file)
@@ -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;
         
index 34285484e6f21e319e564d5f9cc6ded8a53dec61..539755b3a1382101764c7c84167c9bc8c54bab51 100644 (file)
 #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());
index b9b600c831ceb35686e4e360feb83ee205cdd072..5e2b9ba3e123e8888473fb7be821a16c0ae45cbe 100644 (file)
@@ -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());
                }
        }
 }
index 94f46f676d372af5da7e0d98f07d54d398177fe4..0f6d4597925f5df608b69d58847c72ed4f2c1924 100644 (file)
@@ -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.
-*
-*======================================================*/
-
-#ifndef _LyXView_H_
-#define _LyXView_H_
+ * ======================================================
+ 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-1998 The LyX Team.
+ *
+ * ====================================================== */
+
+#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
index a023143bdb7768879d5b9dc125b97c4c3f89d7e3..193db2a8d2736eb2a059e0969a18b6973920e3c0 100644 (file)
@@ -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 = &current_view->currentBuffer()->params;
+       BufferParams * params = &current_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,
index 41773763e1bfc9c6aa2ea0e35bfc3ada0dfd5899..934fd3d270d5164aaaf8a1e04e0e20f580fafe9b 100644 (file)
@@ -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;
 }
index 9bb11361ff50a9b022d00c220144e4584c683102..7f7c259fddaacffabaabae014bbb34da78058ab2 100644 (file)
@@ -15,6 +15,7 @@
 #include "lyxscreen.h"
 #include "gettext.h"
 #include "lyxtext.h"
+#include "layout.h"
 
 extern void BeforeChange();
 
index d2e51ee41e5e557c57c3d44ddd6232728eea30ec..dd97486bba744f13b23d1690f1e5805c689948a2 100644 (file)
@@ -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" {
index d7cd5a4c0699d7da544b107b708477667ef0bd0e..88e9270fa08513a2c69250bef3ac73fdfeb495b0 100644 (file)
@@ -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<bool, LyXTextClass::LayoutList::size_type> 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<bool, LyXTextClassList::ClassList::size_type> 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<depth; j++)
@@ -1494,14 +1515,20 @@ void Buffer::writeFileAscii(string const & filename, int linelen)
                                fprintf(file, "\\");
                                break;
                        default:
+#ifdef NEW_TEXT
+                               if (currlinelen > 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; j++)
+                                       for(j = 0; j < depth; ++j)
                                                fprintf(file, "  ");
-                                       currlinelen = depth*2;
+                                       currlinelen = depth * 2;
                                        if (ltype_depth > 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</%s>\n",space[depth],latexname.c_str());
+       fprintf(file, "%s</%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 <toc> 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,"</p>");
                        }
-                       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 */ 
+       /* 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;
+               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, "<!doctype %s public \"-//OASIS//DTD DocBook V3.1//EN\"",top_element.c_str());
+       fprintf(file,
+               "<!doctype %s public \"-//OASIS//DTD DocBook V3.1//EN\"",
+               top_element.c_str());
 
        if (params.preamble.empty())
                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 <emphasis> 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 */ 
+       /* 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;
+               font1 = style.font;
        }
-
+#endif
        if (emph_flag) {
                file += "</emphasis>";
        }
@@ -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<InsetInclude*>(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??
 }
index e1866b7e7359ce7f51d2cb5d83b437a38670f3a7..91f0d791532dd2dba203840514985341e4a2b05f 100644 (file)
@@ -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);
         ///
index aadda105f1726308e0d4824b2bd0b2e86976d962..093871714caa16a2ad2a0da7d32b452e9184c29f 100644 (file)
@@ -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() ();
        ///
index 5ac2f745842a361a32a44761b125f8cfe98d9a16..ff656f202489483ef6f24ea741a182722c444d44 100644 (file)
@@ -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();
 }
 
 
index f7176b1eac73f54957485550dda4becbf47d56e2..1940b5f0f4d277f73a44195e75904bc4fc9bf93a 100644 (file)
@@ -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;
        ///
index 0dd2501c6051cd95fb384a4473cd0905ac9e26e9..ce584db816e4c0ceb833b49b0c7ea5402371b9ec 100644 (file)
@@ -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<Debug::type>(d1 | d2);
+}
 
 
 #include "support/DebugStream.h"
index 4fb1b106e0bdc3fea23fe85f1daae753b405f17a..48ba4d3b727785df51cfa8540d568f22d4ebf8fb 100644 (file)
@@ -611,7 +611,7 @@ static void runqueue()
                                        XInternAtom(tempdisp, "GHOSTVIEW", false),
                                        XInternAtom(tempdisp, "STRING", false),
                                        8, PropModeAppend, 
-                                       (unsigned char *) tbuf,
+                                       reinterpret_cast<unsigned char*>(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<unsigned char*>(tbuf),
                                        strlen(tbuf));
                        XUngrabServer(tempdisp);
                        XFlush(tempdisp);
index 8216147c35c0e6492cf74b230a923a48fec57769..cad6369463ee645e9cdd3388e77297ded29448ba 100644 (file)
@@ -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
 }
index c95b013648121653b8d79034211f8d184d860d30..ec5f1c064eb3ed3a3330bb1c372168757f2fbb74 100644 (file)
 #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<InsetCommand*>(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<InsetCommand*>(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) {
index b0dfb75d2fd213d1348f3c77e9985d06c02b083e..3c07f55a2927c602535d08441be4b11bb5c0d838 100644 (file)
@@ -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();
        ///
index b2f939134e695b1f6f9d4dad777c4628d8912ce7..1457cad889d2655cf5bf71a6a3bd092d5a28708e 100644 (file)
@@ -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;
 }
 
index 1657ce931cb6a463f7d5fd0b59d9b4da691b4a01..b1a53e82bf6088273c36d8b996aaf44ad4734aaf 100644 (file)
@@ -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;
        }
        ///
index 42f3a1e63d7c8be6661a119ee4fe1524479c5b45..1d4bd36a1d0d3420390fede4ed4d2e76092828d1 100644 (file)
@@ -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<InsetError*>(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;
 }
index cdc03f41dcae981bc9b287bbff68ce92587f80c2..1bde3a4d03a724335597b09baa2f3c8176f76f15 100644 (file)
@@ -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
index 283eb0a1f14a3fe939c53aa1f4932ca7ac5598f7..f881d9b1030dfe39598f8c2fe231743fcb1ff2f1 100644 (file)
 #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<InsetInclude*>(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;
 }
index 4919819f62dfc8b3752fb8de42a1d3db32ca00ea..a37d9a2b795da8320eb9c0d4e302431f36261c35 100644 (file)
@@ -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;
 };
index 035c3dd51169421205147b166d25d3000b203377..a46d471e2d7cea918e3fd7b2fdec249f7d2cc508 100644 (file)
@@ -1,6 +1,6 @@
 #include <config.h>
 
-#include <stdlib.h>
+#include <cstdlib>
 
 #ifdef __GNUG__
 #pragma implementation
 #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<InsetIndex*>(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;
 }
index 76db96764f012d2ffc0e39d7c7e2f8c3797b9f5e..6470404e28bf5c8303930a9c8155953aa7678043 100644 (file)
@@ -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
index 52e8935c176af5ccba552526383d6b99d3a83764..139d32167d61931ba1efd4b52efa080a21f0ce85 100644 (file)
@@ -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<InsetInfo*>(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;
 }
 
index edd3e9fa1e33d76713bd6e7aea6d5ca566c6e6ca..5023a069fdc93e611f395663bcf60764544e6fac 100644 (file)
@@ -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
index 2ebb685295e86b4ca01490d5b20c2308b010f4aa..6ef9e342a8b22222210db400d1023adba3ea1e5a 100644 (file)
@@ -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 += "<label id=\"" + getContents() +"\" >";
        return 0;
 }
 
 
-int InsetLabel::DocBook(string &file)
+int InsetLabel::DocBook(string & file)
 {
        file += "<anchor id=\"" + getContents() +"\" >";
        return 0;
@@ -82,14 +82,14 @@ string InsetLabel::escape(string const & lab) const {
        char hexdigit[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
                              '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
        string enc;
-       for (string::size_type i=0; i<lab.length(); i++) {
-               unsigned char c=lab[i];
-               if (c >= 128 || c=='=' || c=='%') {
+       for (string::size_type i=0; i < lab.length(); ++i) {
+               unsigned char c = lab[i];
+               if (c >= 128 || c == '=' || c == '%') {
                        enc += '=';
-                       enc += hexdigit[c>>4];
+                       enc += hexdigit[c >> 4];
                        enc += hexdigit[c & 15];
                } else {
-                       enc += (char) c;
+                       enc += c;
                }
        }
        return enc;
index 229103330c8240d734e0f3c2239f778c01d44878..bebe75df8729469ac20c31ff230b95309658eec6 100644 (file)
@@ -4,13 +4,13 @@
  *
  *           LyX, The Document Processor
  *      
- *         Copyright (C) 1995 Matthias Ettrich
- *                       1995-1998 The LyX Team
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-1999 The LyX Team
  *
  *======================================================*/
 
-#ifndef _INSET_LABEL_H
-#define _INSET_LABEL_H
+#ifndef INSET_LABEL_H
+#define INSET_LABEL_H
 
 #ifdef __GNUG__
 #pragma interface
@@ -25,11 +25,11 @@ public:
        ///
        InsetLabel(string const & cmd);
        ///
-       InsetLabel() : InsetCommand("label") {;}
+       InsetLabel() : InsetCommand("label") {}
        ///
        ~InsetLabel();
        ///
-       Inset* Clone();
+       Inset * Clone();
        ///
        Inset::Code LyxCode() const { return Inset::LABEL_CODE; }
        ///
@@ -41,13 +41,13 @@ public:
        ///
        unsigned char Editable() const { return 0; }
        ///
-       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);
 private:
        /// This function escapes 8-bit characters
        string escape(string const &) const;
index 5dbce1539056d240e5d8130fdd10ff19fdfa4183..dbc6fd826212dbcc8e3a846956b1c5fc6d264149 100644 (file)
@@ -6,7 +6,7 @@
  *         Copyright 1995 Matthias Ettrich
  *          Copyright 1995-1999 The LyX Team.
  *
- *======================================================*/
+ * ======================================================*/
 
 #include <config.h>
 
@@ -37,26 +37,26 @@ InsetLatex::~InsetLatex()
 }
 
 
-int InsetLatex::Ascent(LyXFont const &font) const
+int InsetLatex::Ascent(LyXFont const & font) const
 {
        return font.maxAscent() + 1;
 }
 
 
-int InsetLatex::Descent(LyXFont const &font) const
+int InsetLatex::Descent(LyXFont const & font) const
 {
        return font.maxDescent() + 1;
 }
 
 
-int InsetLatex::Width(LyXFont const &font) const
+int InsetLatex::Width(LyXFont const & font) const
 {
        return 6 + font.stringWidth(contents);
 }
 
 
-void InsetLatex::Draw(LyXFont font, LyXScreen &scr,
-                     int baseline, float &x)
+void InsetLatex::Draw(LyXFont font, LyXScreen & scr,
+                     int baseline, float & x)
 {
        // Latex-insets are always LaTeX, so just correct the font */ 
        font.setLatex(LyXFont::ON);
@@ -64,15 +64,9 @@ void InsetLatex::Draw(LyXFont font, LyXScreen &scr,
        // Draw it as a box with the LaTeX text
        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);
        
@@ -81,49 +75,46 @@ void InsetLatex::Draw(LyXFont font, LyXScreen &scr,
 }
 
 
-void InsetLatex::Write(FILE *file)
+void InsetLatex::Write(FILE * file)
 {
        fprintf(file, "Latex %s\n", contents.c_str());
 }
 
 
-void InsetLatex::Read(LyXLex &lex)
+void InsetLatex::Read(LyXLex & lex)
 {
-       FILE *file = lex.getFile();
-       int i = 0;
-       char c='\0';
-       char tmp[100];
+       FILE * file = lex.getFile();
+       char c = 0;
+       string tmp;
        while (!feof(file) && (c = fgetc(file)) != '\n') {
-               tmp[i]=c;
-               i++;
+               tmp += char(c);
        }
-       tmp[i]='\0';
        contents = tmp;
 }
 
 
-int InsetLatex::Latex(FILE *file, signed char /*fragile*/)
+int InsetLatex::Latex(FILE * file, signed char /*fragile*/)
 {
        fprintf(file, "%s", contents.c_str());
        return 0;
 }
 
 
-int InsetLatex::Latex(string &file, signed char /*fragile*/)
+int InsetLatex::Latex(string & file, signed char /*fragile*/)
 {
        file += contents;
        return 0;
 }
 
 
-int InsetLatex::Linuxdoc(string &file)
+int InsetLatex::Linuxdoc(string & file)
 {
        file += contents;
        return 0;
 }
 
 
-int InsetLatex::DocBook(string &file)
+int InsetLatex::DocBook(string & file)
 {
        file += contents;
        return 0;
@@ -136,9 +127,9 @@ bool InsetLatex::Deletable() const
 }
 
 
-Inset* InsetLatex::Clone()
+Inset * InsetLatex::Clone()
 {
-       InsetLatex *result = new InsetLatex(contents);
+       InsetLatex * result = new InsetLatex(contents);
        return result;
 }
 
index 4950d09dbad5a03dfc771537aa6db491a295cc15..8c163183eee42f2dc5607e169ed3eaaf6a84bca9 100644 (file)
@@ -6,10 +6,10 @@
  *      
  *         Copyright (C) 1995 Matthias Ettrich
  *
- *======================================================*/
+ * ======================================================*/
 
-#ifndef _INSET_LATEX_H
-#define _INSET_LATEX_H
+#ifndef INSET_LATEX_H
+#define INSET_LATEX_H
 
 #ifdef __GNUG__
 #pragma interface
@@ -33,29 +33,29 @@ public:
        ///
        ~InsetLatex();
        ///
-       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 Deletable() const;
        ///
-       Inset* Clone();
+       Inset * Clone();
        ///
        Inset::Code LyxCode() const;
 private:
index 31c415afa8a587ca46684e76aad519bd79017b8a..169c02a2b0fb0674fec20b6e3c091f77d2f451b2 100644 (file)
@@ -60,7 +60,7 @@ void InsetLatexAccent::checkContents()
 {
         candisp = false;
 
-       if (contents.empty() || contents.length()<2) return;
+       if (contents.empty() || contents.length() < 2) return;
 
        // REMOVE IN 0.13
        // Dirty Hack for backward compability. remove in 0.13 (Lgb)
@@ -239,17 +239,17 @@ void InsetLatexAccent::checkContents()
                                remdot = true;
                        else
                                return;
-               } else if ( (ic=='i'|| ic=='j') && contents[4]=='}') {
+               } else if ( (ic == 'i'|| ic == 'j') && contents[4] == '}') {
                    // Do a rewrite: \<foo>{i} --> \<foo>{\i}
-                   string temp=contents;
+                   string temp = contents;
                    temp.erase(3, string::npos);
-                   temp+='\\';
-                       temp+=char(ic);
+                   temp += '\\';
+                   temp += char(ic);
                    for(string::size_type j = 4; j < contents.length(); ++j)
                                temp+=contents[j];
                    contents=temp;
                    i++;
-                       remdot=true;
+                       remdot = true;
                }    
 
                // demand a '}' at the end
@@ -267,7 +267,7 @@ void InsetLatexAccent::checkContents()
 }
 
 
-int InsetLatexAccent::Ascent(LyXFont const &font) const
+int InsetLatexAccent::Ascent(LyXFont const & font) const
 {
        int max;
        if (candisp) {
@@ -283,7 +283,7 @@ int InsetLatexAccent::Ascent(LyXFont const &font) const
 }
 
 
-int InsetLatexAccent::Descent(LyXFont const &font) const
+int InsetLatexAccent::Descent(LyXFont const & font) const
 {
        int max;
        if (candisp) {
@@ -299,7 +299,7 @@ int InsetLatexAccent::Descent(LyXFont const &font) const
 }
 
 
-int InsetLatexAccent::Width(LyXFont const &font) const
+int InsetLatexAccent::Width(LyXFont const & font) const
 {
        if (candisp)
                return font.textWidth(&ic, 1);
@@ -308,11 +308,10 @@ int InsetLatexAccent::Width(LyXFont const &font) const
 }
 
 
-
 bool InsetLatexAccent::DisplayISO8859_9(LyXFont font,
-                           LyXScreen &scr,
+                           LyXScreen & scr,
                            int baseline, 
-                           float &x)
+                           float & x)
 {
        unsigned char tmpic = ic;
        
@@ -354,9 +353,9 @@ bool InsetLatexAccent::DisplayISO8859_9(LyXFont font,
 
 
 void InsetLatexAccent::Draw(LyXFont font,
-                           LyXScreen &scr,
+                           LyXScreen & scr,
                            int baseline, 
-                           float &x)
+                           float & x)
 {
        if (lyxrc->font_norm=="iso8859-9")
                if (DisplayISO8859_9 (font, scr, baseline, x))  
@@ -368,7 +367,7 @@ void InsetLatexAccent::Draw(LyXFont font,
                int asc = Ascent(font);
                int desc = Descent(font);
                int wid = Width(font);
-               float x2 = x+(float(wid)/2);
+               float x2 = x + float(wid/2);
                float hg35;
                int hg, y;
                if (plusasc) {
@@ -567,19 +566,11 @@ void InsetLatexAccent::Draw(LyXFont font,
                }
                }
        } else {
-               //scr.drawFilledRectangle(int(x+1), baseline - Ascent(font)+1,
-               //                      Width(font)-2,
-               //                      Ascent(font)+Descent(font)-2,
-               //                      FL_GRAY80);
                scr.fillRectangle(gc_lighted,
                                  int(x+1), baseline - Ascent(font)+1,
                                  Width(font)-2,
                                  Ascent(font)+Descent(font)-2);
                
-               //scr.drawRectangle(int(x), baseline - Ascent(font),
-               //                Width(font)-1,
-               //                Ascent(font)+Descent(font)-1,
-               //                FL_GRAY80);
                scr.drawRectangle(gc_lighted,
                                  int(x), baseline - Ascent(font),
                                  Width(font)-1,
@@ -590,13 +581,13 @@ void InsetLatexAccent::Draw(LyXFont font,
 }
 
 
-void InsetLatexAccent::Write(FILE *file)
+void InsetLatexAccent::Write(FILE * file)
 {
        fprintf(file, "\\i %s\n", contents.c_str());
 }
 
 
-void InsetLatexAccent::Read(LyXLex &lex)
+void InsetLatexAccent::Read(LyXLex & lex)
 {
        lex.EatLine();
        contents = lex.GetString();
@@ -604,28 +595,28 @@ void InsetLatexAccent::Read(LyXLex &lex)
 }
 
 
-int InsetLatexAccent::Latex(FILE *file, signed char /*fragile*/)
+int InsetLatexAccent::Latex(FILE * file, signed char /*fragile*/)
 {
        fprintf(file, "%s", contents.c_str());
        return 0;
 }
 
 
-int InsetLatexAccent::Latex(string &file, signed char /*fragile*/)
+int InsetLatexAccent::Latex(string & file, signed char /*fragile*/)
 {
        file += contents;
        return 0;
 }
 
 
-int InsetLatexAccent::Linuxdoc(string &file)
+int InsetLatexAccent::Linuxdoc(string & file)
 {
        file += contents;
        return 0;
 }
 
 
-int InsetLatexAccent::DocBook(string &file)
+int InsetLatexAccent::DocBook(string & file)
 {
        file += contents;
        return 0;
@@ -646,7 +637,7 @@ bool InsetLatexAccent::DirectWrite() const
 
 Inset* InsetLatexAccent::Clone()
 {
-       InsetLatexAccent *result = new InsetLatexAccent(contents);
+       InsetLatexAccent * result = new InsetLatexAccent(contents);
        return result;
 }
 
@@ -657,7 +648,7 @@ Inset::Code InsetLatexAccent::LyxCode() const
 }
 
 
-bool InsetLatexAccent::IsEqual(Inset* other)
+bool InsetLatexAccent::IsEqual(Inset * other)
 {
        if (other && other->LyxCode() == Inset::ACCENT_CODE){
                InsetLatexAccent* otheraccent = (InsetLatexAccent*) other;
index 024ef9fe991589fec5d620569a5729934a279c80..acf1afbfd6319ccd686afe7c891bbe6c7ff35052 100644 (file)
@@ -34,42 +34,42 @@ public:
        ///
        InsetLatexAccent(string const & string);
        ///
-       InsetLatexAccent(InsetLatexAccent const&);
+       InsetLatexAccent(InsetLatexAccent const &);
        ///
        ~InsetLatexAccent();
        ///
-       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;
        ///
-       bool DisplayISO8859_9(LyXFont font, LyXScreen &scr,
-                             int baseline, float &x);
+       bool DisplayISO8859_9(LyXFont font, LyXScreen & scr,
+                             int baseline, float & x);
        ///
-       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 Deletable() const;
        ///
        bool DirectWrite() const;
        ///
-       Inset* Clone();
+       Inset * Clone();
        ///
        Inset::Code LyxCode()const;
        ///
-       bool IsEqual(Inset* other);
+       bool IsEqual(Inset * other);
        ///
        inline bool CanDisplay();
 private:
@@ -145,4 +145,3 @@ bool InsetLatexAccent::CanDisplay()
 }
 
 #endif
-
index 71b5582477629e3c9f1e1b09aa71905e6fcafa03..8578b959ed3077221c48cd8ecef9ff763ca6feef 100644 (file)
@@ -4,16 +4,15 @@
  *
  *           LyX, The Document Processor
  *      
- *         Copyright (C) 1995 Matthias Ettrich
- *          Copyright (C) 1996-1998 The LyX Team.
+ *          Copyright (C) 1995 Matthias Ettrich
+ *          Copyright (C) 1996-1999 The LyX Team.
  * 
- *======================================================*/
+ * ======================================================*/
 
 // Created by Bernhard 970908
 
 #include <config.h>
 
-
 #ifdef __GNUG__
 #pragma implementation "insetloa.h"
 #pragma implementation "insetlof.h"
@@ -25,5 +24,7 @@
 #include "insetlof.h"
 #include "insetlot.h"
 
-void InsetLOA::Validate(LaTeXFeatures &features) const 
-{ features.algorithm = true; }
+void InsetLOA::Validate(LaTeXFeatures & features) const 
+{
+       features.algorithm = true;
+}
index c67e0bee1d8c9246c7bfc068fc3470eada9cb15b..91434c520a1199cc0c682f7e5cebfe823ed5448f 100644 (file)
@@ -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_LOA_H
-#define _INSET_LOA_H
+#ifndef INSET_LOA_H
+#define INSET_LOA_H
 
 #ifdef __GNUG__
 #pragma interface
@@ -28,11 +28,11 @@ public:
        ///
        InsetLOA(): InsetCommand("listofalgorithms") {}
        ///
-       InsetLOA(Buffer *b): InsetCommand("listofalgorithms"),owner(b) {}
+       InsetLOA(Buffer * b): InsetCommand("listofalgorithms"),owner(b) {}
         ///
-       void Validate(LaTeXFeatures &features) const;
+       void Validate(LaTeXFeatures & features) const;
         ///
-        Inset* Clone() { return new InsetLOA(owner); }
+        Inset * Clone() { return new InsetLOA(owner); }
        ///
        string getScreenLabel() const { return _("List of Algorithms"); }
 
@@ -48,7 +48,7 @@ public:
        Inset::Code LyxCode() const { return Inset::LOA_CODE; }
 private:
        ///
-       Buffer *owner;
+       Buffer * owner;
 };
 
 #endif
index 2a2435cff91acbfd2d7dfe355116ea44293981ff..0de6628d36666c004e94a935702f18b986ec9a1b 100644 (file)
@@ -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_LOF_H
-#define _INSET_LOF_H
+#ifndef INSET_LOF_H
+#define INSET_LOF_H
 
 #ifdef __GNUG__
 #pragma interface
@@ -28,9 +28,9 @@ public:
        ///
        InsetLOF(): InsetCommand("listoffigures") {}
        ///
-       InsetLOF(Buffer *b): InsetCommand("listoffigures"),owner(b) {}
+       InsetLOF(Buffer * b): InsetCommand("listoffigures"),owner(b) {}
         ///
-        Inset* Clone() { return new InsetLOF(owner); }
+        Inset * Clone() { return new InsetLOF(owner); }
        ///
        string getScreenLabel() const { return _("List of Figures"); }
         
@@ -45,7 +45,6 @@ public:
        Inset::Code LyxCode() const { return Inset::LOF_CODE; }
 private:
        ///
-       Buffer *owner;
+       Buffer * owner;
 };
-
 #endif
index 34bb9cb0e2cf8a75c8bedb169e94bf13457af375..edc7bd78fa26ad1c5af931dc7fc37fbb6517c227 100644 (file)
@@ -4,13 +4,13 @@
  *
  *           LyX, The Document Processor
  *      
- *         Copyright (C) 1995 Matthias Ettrich
- *                        1996-1998 LyX Team
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1996-1999 LyX Team
  * 
  *======================================================*/
 
-#ifndef _INSET_LOT_H
-#define _INSET_LOT_H
+#ifndef INSET_LOT_H
+#define INSET_LOT_H
 
 #ifdef __GNUG__
 #pragma interface
@@ -28,9 +28,9 @@ public:
        ///
        InsetLOT(): InsetCommand("listoftables") {}
        ///
-       InsetLOT(Buffer *b): InsetCommand("listoftables"), owner(b) {}
+       InsetLOT(Buffer * b): InsetCommand("listoftables"), owner(b) {}
         ///
-        Inset* Clone() { return new InsetLOT(owner); }
+        Inset * Clone() { return new InsetLOT(owner); }
        ///
        string getScreenLabel() const { return _("List of Tables"); }
         
@@ -45,7 +45,7 @@ public:
        Inset::Code LyxCode() const { return Inset::LOT_CODE; }
 private:
        ///
-       Buffer *owner;
+       Buffer * owner;
 };
 
 #endif
index d94d1227a42194c1e875ee8fb9ea995ec212190d..173072f885f31a2ffc8cfd96d9b23009238e03bf 100644 (file)
@@ -3,9 +3,9 @@
  *
  *           LyX, The Document Processor
  *      
- *         Copyright (C) 1997-1998 LyX Team
+ *           Copyright (C) 1997-1999 LyX Team
  * 
- *======================================================*/
+ * ======================================================*/
 
 
 // Created by asierra 970813
 #include "commandtags.h"
 
 
-extern BufferView *current_view;
+extern BufferView * current_view;
 
 
-InsetParent::InsetParent(string fn, Buffer* owner): InsetCommand("lyxparent")
+InsetParent::InsetParent(string fn, Buffer * owner): InsetCommand("lyxparent")
 {
     if (owner)
        setContents(MakeAbsPath(fn, OnlyPath(owner->getFileName())));
@@ -43,7 +43,7 @@ void InsetParent::Edit(int, int)
 }
 
 // LaTeX must just ignore this command
-int InsetParent::Latex(FILE *file, signed char fragile)
+int InsetParent::Latex(FILE * file, signed char fragile)
 {
     fprintf(file, "%%#{lyx}");
     InsetCommand::Latex(file, fragile);
@@ -51,7 +51,7 @@ int InsetParent::Latex(FILE *file, signed char fragile)
 }
 
 // LaTeX must just ignore this command
-int InsetParent::Latex(string &file, signed char fragile)
+int InsetParent::Latex(string & file, signed char fragile)
 {
     file += "%%#{lyx}";
     InsetCommand::Latex(file, fragile);
index 2dafd19f66c287261c7cdad283827f74273bd3c5..3c50159b9a8764998d3be7d3f990869d6b6ad6bf 100644 (file)
@@ -4,12 +4,12 @@
  *
  *           LyX, The Document Processor
  *      
- *         Copyright (C) 1997-1998 LyX Team
+ *           Copyright (C) 1997-1999 LyX Team
  * 
- *======================================================*/
+ * ======================================================*/
 
-#ifndef _INSET_PARENT_H
-#define _INSET_PARENT_H
+#ifndef INSET_PARENT_H
+#define INSET_PARENT_H
 
 #ifdef __GNUG__
 #pragma interface
@@ -29,15 +29,15 @@ public:
        /// Non-standard LyX macro
        InsetParent(): InsetCommand("lyxparent") { }
        ///
-        InsetParent(string fn, Buffer* owner=0);
+        InsetParent(string fn, Buffer * owner=0);
        ///
         ~InsetParent() {}
        /// 
-       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);
         ///
-        Inset* Clone() { return new InsetParent(getContents()); }
+        Inset * Clone() { return new InsetParent(getContents()); }
        ///
        string getScreenLabel() const { return string(_("Parent:"))+getContents(); }
         ///
@@ -51,5 +51,4 @@ public:
         ///
         void setParent(string fn) { setContents(fn); }
 };
-
 #endif
index 408f6a1ca80781c07bec9e37ca2583600880b824..3fba432722d2a7fb9f9bf3c7378a0abd80c99910 100644 (file)
@@ -88,9 +88,10 @@ InsetQuotes::InsetQuotes(char c, BufferParams const & params)
 }
 
 
-void InsetQuotes::ParseString(string str)
+void InsetQuotes::ParseString(string const & s)
 {
        int i;
+       string str(s);
        if (str.length() != 3) {
                lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
                        " bad string length." << endl;
@@ -137,8 +138,7 @@ void InsetQuotes::ParseString(string str)
 string InsetQuotes::DispString() const
 {
        string disp;
-
-       disp = quote_char[quote_index[side][language]];
+       disp += quote_char[quote_index[side][language]];
        if (times == InsetQuotes::DoubleQ)
                disp += disp;
 
@@ -307,7 +307,7 @@ void InsetQuotes::Validate(LaTeXFeatures & features) const
        }
 }
 
-Inset* InsetQuotes::Clone()
+Inset * InsetQuotes::Clone()
 {
   return new InsetQuotes(language, side, times);
 }
index eb4fb347476b4216a2828c9c44e728f40c39e83e..91c105e3589ef927459a82d7244a0a33e0f89bfb 100644 (file)
@@ -113,9 +113,8 @@ private:
         */
        InsetQuotes(quote_language l, quote_side s, quote_times t);
        ///
-       void ParseString(string str);
+       void ParseString(string const &);
        ///
        string DispString() const;
 };
-
 #endif
index fc2f68342689e428b3e6807fd1ac4fd903376c8f..a66d536ade98408df1c6ddc8880f76a2515db893 100644 (file)
@@ -1,6 +1,6 @@
 #include <config.h>
 
-#include <stdlib.h>
+#include <cstdlib>
 
 #ifdef __GNUG__
 #pragma implementation
 #include "commandtags.h"
 #include "gettext.h"
 
-extern BufferView *current_view;
+extern BufferView * current_view;
 
-// Temporarily disabled the GUI code. Reasons:
-// - Only page-ref button works currently, IMO we should use a LyX action
-//   instead, to toggle the kind of refs.
-// - To change the label, IMO it's faster to delete the old one and insert
-//   a new one.
-// - To goto to the label, IMO it's much faster to just click on the
-//   inset. That's how I've implemented it now, I hope you'll like it.
-// - The more GUI code we can remove, the less work we'll have at
-//   the toolkit switch.
-//   (ale 970723)
 
-#if 0
-
-/* Header file generated with fdesign. */
-
-/**** Callback routines ****/
-
-static void ref_close_cb(FL_OBJECT *, long);
-static void goto_label_cb(FL_OBJECT *, long);
-static void label_change_cb(FL_OBJECT *, long);
-
-/**** Forms and Objects ****/
-
-typedef struct {
-       FL_FORM *ref;
-       void *vdata;
-       long ldata;
-       FL_OBJECT *pg_grp;
-       FL_OBJECT *flag1;
-       FL_OBJECT *flag2;
-} FD_ref;
-
-/* Form definition file generated with fdesign. */
-
-static
-FD_ref *create_form_ref(void)
-{
-  FL_OBJECT *obj;
-  FD_ref *fdui = (FD_ref *) fl_calloc(1, sizeof(*fdui));
-
-  fdui->ref = fl_bgn_form(FL_NO_BOX, 210, 170);
-  obj = fl_add_box(FL_UP_BOX,0,0,210,170,"");
-  obj = fl_add_frame(FL_ENGRAVED_FRAME,10,20,130,60,"");
-  obj = fl_add_button(FL_RETURN_BUTTON,120,130,80,30,_("Close"));
-    fl_set_object_lsize(obj,FL_NORMAL_SIZE);
-    fl_set_object_callback(obj,ref_close_cb,0);
-  obj = fl_add_text(FL_NORMAL_TEXT,20,10,110,20,_("Reference Type"));
-    fl_set_object_lsize(obj,FL_NORMAL_SIZE);
-    fl_set_object_lalign(obj,FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
-  obj = fl_add_button(FL_NORMAL_BUTTON,10,130,100,30,_("Goto Label"));
-    fl_set_object_lsize(obj,FL_NORMAL_SIZE);
-    fl_set_object_callback(obj,goto_label_cb,0);
-  obj = fl_add_button(FL_NORMAL_BUTTON,10,90,100,30,_("Change Label"));
-    fl_set_object_lsize(obj,FL_NORMAL_SIZE);
-    fl_set_object_callback(obj,label_change_cb,0);
-
-  fdui->pg_grp = fl_bgn_group();
-  fdui->flag1 = obj = fl_add_checkbutton(FL_RADIO_BUTTON,20,30,20,20,_("Page Number"));
-    fl_set_object_lsize(obj,FL_NORMAL_SIZE);
-  fdui->flag2 = obj = fl_add_checkbutton(FL_RADIO_BUTTON,20,50,20,20,_("Reference"));
-    fl_set_object_lsize(obj,FL_NORMAL_SIZE);
-  fl_end_group();
-
-  fl_end_form();
-
-  fdui->ref->fdui = fdui;
-
-  return fdui;
-}
-/*---------------------------------------*/
-
-
-static FD_ref *form = 0;
-
-
-static
-void ref_close_cb(FL_OBJECT *, long)
-{
-       InsetRef *inset = (InsetRef*)form->vdata;
-
-       if (fl_get_button(form->flag1)) {
-               inset->setFlag(InsetRef::PAGE_REF);
-               inset->setCmdName("pageref");
-       } else {
-               inset->setFlag(InsetRef::REF);
-               inset->setCmdName("ref");
-       }
-               
-       fl_hide_form(form->ref);
-}
-
-
-static
-void goto_label_cb(FL_OBJECT *, long)
-{
-       // code yet to be written
-       InsetRef *inset = (InsetRef*)form->vdata;
-        inset->gotoLabel();
-#warning MAKEME!
-}
-
-
-static
-void label_change_cb(FL_OBJECT *, long)
-{
-       // code yet to be written
-       InsetRef *inset = (InsetRef*)form->vdata;
-#warning MAKEME!
-}
-
-#endif
-
-InsetRef::InsetRef(string const & cmd, Buffer *bf)
+InsetRef::InsetRef(string const & cmd, Buffer * bf)
        : master(bf)
 {
        scanCommand(cmd);
@@ -141,7 +30,7 @@ InsetRef::InsetRef(string const & cmd, Buffer *bf)
 }
 
 
-InsetRef::InsetRef(InsetCommand const &inscmd, Buffer *bf)
+InsetRef::InsetRef(InsetCommand const & inscmd, Buffer * bf)
        : master(bf)
 {
        setCmdName(inscmd.getCmdName());
@@ -161,26 +50,8 @@ InsetRef::~InsetRef()
 
 void InsetRef::Edit(int, int)
 {
-        current_view->getOwner()->getLyXFunc()->Dispatch(LFUN_REFGOTO
-                                                        , getContents().c_str());
-//        gotoLabel();
-/*    
-        if (!form) { 
-                form = create_form_ref();
-               fl_set_form_atclose(form->ref, IgnoreCloseBoxCB, 0);
-       }
-        form->vdata = this; 
-    
-       fl_set_button(form->flag1, (flag == InsetRef::REF) ? 1 : 0);
-       fl_set_button(form->flag2, (flag == InsetRef::PAGE_REF) ? 1 : 0);
-       
-        if (form->ref->visible) {
-               fl_raise_form(form->ref);
-       } else {
-               fl_show_form(form->ref,FL_PLACE_MOUSE, FL_FULLBORDER,
-                            _("Cross-Reference"));
-       }
- */
+        current_view->getOwner()->getLyXFunc()
+               ->Dispatch(LFUN_REFGOTO, getContents().c_str());
 }
 
 
@@ -192,7 +63,8 @@ string InsetRef::getScreenLabel() const
        else 
                temp += _("Ref: ");
        temp += getContents();
-       if(!current_view->currentBuffer()->isLatex() && !getOptions().empty()) {
+       if(!current_view->currentBuffer()->isLatex()
+          && !getOptions().empty()) {
                temp += "||";
                temp += getOptions();
        }
@@ -200,7 +72,7 @@ string InsetRef::getScreenLabel() const
 }
 
 
-int InsetRef::Latex(FILE *file, signed char /*fragile*/)
+int InsetRef::Latex(FILE * file, signed char /*fragile*/)
 {
        if(getOptions().empty())
                fprintf(file, "%s", escape(getCommand()).c_str());
@@ -213,7 +85,7 @@ int InsetRef::Latex(FILE *file, signed char /*fragile*/)
 }
 
 
-int InsetRef::Latex(string &file, signed char /*fragile*/)
+int InsetRef::Latex(string & file, signed char /*fragile*/)
 {
        if(getOptions().empty())
                file += escape(getCommand());
@@ -226,17 +98,19 @@ int InsetRef::Latex(string &file, signed char /*fragile*/)
 }
 
 
-int InsetRef::Linuxdoc(string &file)
+int InsetRef::Linuxdoc(string & file)
 {
-       file += "<ref id=\"" + getContents() + "\" name=\""+ getOptions() +"\" >" ;
+       file += "<ref id=\"" + getContents()
+               + "\" name=\""+ getOptions() +"\" >" ;
 
        return 0;
 }
 
 
-int InsetRef::DocBook(string &file)
+int InsetRef::DocBook(string & file)
 {
-       file += "<link linkend=\"" + getContents() + "\">"+ getOptions() +"</link>" ;
+       file += "<link linkend=\"" + getContents()
+               + "\">"+ getOptions() +"</link>" ;
 
        return 0;
 }
@@ -255,7 +129,7 @@ string InsetRef::escape(string const & lab) const {
                        enc += hexdigit[c>>4];
                        enc += hexdigit[c & 15];
                } else {
-                       enc += (char) c;
+                       enc += c;
                }
        }
        return enc;
index a64e02d27e64a008f8e6d0b91f403c934f06de6f..857e651402239dca803e7c966d9645a222724034 100644 (file)
@@ -8,8 +8,8 @@
  * 
  *======================================================*/
 
-#ifndef _INSET_REF_H
-#define _INSET_REF_H
+#ifndef INSET_REF_H
+#define INSET_REF_H
 
 #ifdef __GNUG__
 #pragma interface
@@ -33,15 +33,15 @@ public:
        };
        
        ///
-       InsetRef(): InsetCommand("ref") { flag = InsetRef::REF; }
+       InsetRef() : InsetCommand("ref") { flag = InsetRef::REF; }
        ///
-       InsetRef(string const &, Buffer*);
+       InsetRef(string const &, Buffer *);
        ///
-       InsetRef(InsetCommand const&, Buffer*);
+       InsetRef(InsetCommand const &, Buffer *);
        ///
        ~InsetRef();
         ///
-        Inset* Clone() { return new InsetRef (getCommand(), master); }
+        Inset * Clone() { return new InsetRef (getCommand(), master); }
        ///
        Inset::Code LyxCode() const { return Inset::REF_CODE; }
        ///
@@ -61,20 +61,20 @@ public:
         ///
         void gotoLabel();
        ///
-       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);
 private:
        /// This function escapes 8-bit characters
        string escape(string const &) const;
        ///
         Ref_Flags flag;
         ///
-       Buffer *master;
+       Buffer * master;
 };
 
 
@@ -85,5 +85,4 @@ void InsetRef::gotoLabel()
        master->gotoLabel(getContents());
     }
 }
-
 #endif
index 2e61e5f20b90d8ec2b852d9e3c1eb72a3bbefbd4..019e238195f5b20a758bd3662f4e579f6ba7cb13 100644 (file)
@@ -34,19 +34,19 @@ InsetSpecialChar::~InsetSpecialChar()
 }
 
 
-int InsetSpecialChar::Ascent(LyXFont const&font) const
+int InsetSpecialChar::Ascent(LyXFont const & font) const
 {
        return font.maxAscent();
 }
 
 
-int InsetSpecialChar::Descent(LyXFont const&font) const
+int InsetSpecialChar::Descent(LyXFont const & font) const
 {
        return font.maxDescent();
 }
 
 
-int InsetSpecialChar::Width(LyXFont const&font) const
+int InsetSpecialChar::Width(LyXFont const & font) const
 {
        LyXFont f = font;
        switch (kind) {
@@ -73,8 +73,8 @@ int InsetSpecialChar::Width(LyXFont const&font) const
 }
 
 
-void InsetSpecialChar::Draw(LyXFont font, LyXScreen &scr,
-                           int baseline, float &x)
+void InsetSpecialChar::Draw(LyXFont font, LyXScreen & scr,
+                           int baseline, float & x)
 {
        switch (kind) {
        case HYPHENATION:
@@ -117,7 +117,7 @@ void InsetSpecialChar::Draw(LyXFont font, LyXScreen &scr,
 
 
 // In lyxf3 this will be just LaTeX
-void InsetSpecialChar::Write(FILE *file)
+void InsetSpecialChar::Write(FILE * file)
 {
        string command;
        switch (kind) {
@@ -131,7 +131,7 @@ void InsetSpecialChar::Write(FILE *file)
 
 
 // This function will not be necessary when lyx3
-void InsetSpecialChar::Read(LyXLex &lex)
+void InsetSpecialChar::Read(LyXLex & lex)
 {    
        lex.nextToken();
        string command = lex.GetString();
@@ -149,7 +149,7 @@ void InsetSpecialChar::Read(LyXLex &lex)
 }
 
 
-int InsetSpecialChar::Latex(FILE *file, signed char /*fragile*/)
+int InsetSpecialChar::Latex(FILE * file, signed char /*fragile*/)
 {
        string command;
        signed char dummy = 0;
@@ -159,7 +159,7 @@ int InsetSpecialChar::Latex(FILE *file, signed char /*fragile*/)
 }
 
 
-int InsetSpecialChar::Latex(string &file, signed char /*fragile*/)
+int InsetSpecialChar::Latex(string & file, signed char /*fragile*/)
 {
        switch (kind) {
        case HYPHENATION:       file += "\\-";  break;
@@ -171,7 +171,7 @@ int InsetSpecialChar::Latex(string &file, signed char /*fragile*/)
 }
 
 
-int InsetSpecialChar::Linuxdoc(string &file)
+int InsetSpecialChar::Linuxdoc(string & file)
 {
        switch (kind) {
        case HYPHENATION:       file += "";     break;
@@ -183,7 +183,7 @@ int InsetSpecialChar::Linuxdoc(string &file)
 }
 
 
-int InsetSpecialChar::DocBook(string &file)
+int InsetSpecialChar::DocBook(string & file)
 {
        switch (kind) {
        case HYPHENATION:       file += "";     break;
@@ -195,14 +195,14 @@ int InsetSpecialChar::DocBook(string &file)
 }
 
 
-Inset* InsetSpecialChar::Clone()
+Inset * InsetSpecialChar::Clone()
 {
-       InsetSpecialChar *result = new InsetSpecialChar(kind);
+       InsetSpecialChar * result = new InsetSpecialChar(kind);
        return result;
 }
 
 
-void InsetSpecialChar::Validate(LaTeXFeatures& features) const
+void InsetSpecialChar::Validate(LaTeXFeatures & features) const
 {
        if (kind == MENU_SEPARATOR) {
                features.lyxarrow = true;
index cd20bdfefb53941268b0f9566e0b97d3dc1d58d3..e01b32e6d44cd06fa7243f94f0cd64fa6a8b24f8 100644 (file)
@@ -6,10 +6,10 @@
  *      
  *         Copyright (C) 1997 Asger Alstrup
  *
- *======================================================*/
+ * ======================================================*/
 
-#ifndef _INSET_SPECIALCHAR_H
-#define _INSET_SPECIALCHAR_H
+#ifndef INSET_SPECIALCHAR_H
+#define INSET_SPECIALCHAR_H
 
 #ifdef __GNUG__
 #pragma interface
@@ -43,27 +43,27 @@ public:
        ///
        ~InsetSpecialChar();
        ///
-       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);
        /// Will not be used when lyxf3
-       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);
        ///
-       Inset* Clone();
+       Inset * Clone();
        ///  
        Inset::Code LyxCode() const
        {
index d56ff97a0913d1156ffbf25f4af7092efaee41e5..77ad1928d9aa324dde00bdcf88c7f61b6c7c13b3 100644 (file)
 #include "lyxfunc.h"
 #include "LyXView.h"
 
-extern BufferView *current_view;
+extern BufferView * current_view;
 
 void InsetTOC::Edit(int, int)
 {
        current_view->getOwner()->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
 }
 
-int InsetTOC::Linuxdoc(string &file)
+int InsetTOC::Linuxdoc(string & file)
 {
        file += "<toc>";
        return 0;
 }
 
 
-int InsetTOC::DocBook(string &file)
+int InsetTOC::DocBook(string & file)
 {
        file += "<toc></toc>";
        return 0;
index 2bc060c5baa2a49af15c18c6e5348e0423aee9cf..8be5c8bebce345bc35e4b3936eea31e9e4c61663 100644 (file)
@@ -4,13 +4,13 @@
  *
  *           LyX, The Document Word Processor
  *      
- *         Copyright (C) 1995 Matthias Ettrich
- *                        1996-1998 The LyX Team.
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1996-1999 The LyX Team.
  * 
  *======================================================*/
 
-#ifndef _INSET_TOC_H
-#define _INSET_TOC_H
+#ifndef INSET_TOC_H
+#define INSET_TOC_H
 
 #ifdef __GNUG__
 #pragma interface
@@ -28,9 +28,9 @@ public:
        ///
        InsetTOC(): InsetCommand("tableofcontents") {}
        ///
-       InsetTOC(Buffer *b): InsetCommand("tableofcontents"),owner(b){}
+       InsetTOC(Buffer * b): InsetCommand("tableofcontents"),owner(b) {}
         ///
-        Inset* Clone() { return new InsetTOC(owner); }
+        Inset * Clone() { return new InsetTOC(owner); }
        ///
        string getScreenLabel() const { return _("Table of Contents"); }
        /// On edit, we open the TOC pop-up
@@ -44,12 +44,12 @@ public:
        ///
        Inset::Code LyxCode() const { return Inset::TOC_CODE; }
        ///
-       int Linuxdoc(string &file);
+       int Linuxdoc(string & file);
        ///
-       int DocBook(string &file);
+       int DocBook(string & file);
 private:
        ///
-       Buffer *owner;
+       Buffer * owner;
 };
 
 #endif
index 3c174139d3a7a91cd907eeacfaeef9cf9e9cd7a5..4d6fba49f33c24220d0f0487c96bcf3dcd42b49c 100644 (file)
@@ -1,6 +1,6 @@
 #include <config.h>
 
-#include <stdlib.h>
+#include <cstdlib>
 
 #ifdef __GNUG__
 #pragma implementation
@@ -14,8 +14,8 @@
 #include "LaTeXFeatures.h"
 #include "lyx_gui_misc.h" // CancelCloseBoxCB
 
-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);
 
 InsetUrl::InsetUrl(string const & cmd)
        : fd_form_url(0)
@@ -28,7 +28,7 @@ InsetUrl::InsetUrl(string const & cmd)
 }
 
 
-InsetUrl::InsetUrl(InsetCommand const &inscmd)
+InsetUrl::InsetUrl(InsetCommand const & inscmd)
        : fd_form_url(0)
 {
        setCmdName(inscmd.getCmdName());
@@ -41,8 +41,8 @@ InsetUrl::InsetUrl(InsetCommand const &inscmd)
 }
 
 
-InsetUrl::InsetUrl(string const &ins_name,string const &ins_cont,
-                  string const &ins_opt)
+InsetUrl::InsetUrl(string const & ins_name, string const & ins_cont,
+                  string const & ins_opt)
        : fd_form_url(0)
 {
        setCmdName(ins_name);
@@ -65,9 +65,9 @@ InsetUrl::~InsetUrl()
 }
 
 
-void InsetUrl::CloseUrlCB(FL_OBJECT *ob, long)
+void InsetUrl::CloseUrlCB(FL_OBJECT * ob, long)
 {
-       InsetUrl *inset = (InsetUrl*) ob->u_vdata;
+       InsetUrl * inset = static_cast<InsetUrl*>(ob->u_vdata);
        string url = fl_get_input(inset->fd_form_url->url_name);
        string name = fl_get_input(inset->fd_form_url->name_name);
        string cmdname;
@@ -76,7 +76,7 @@ void InsetUrl::CloseUrlCB(FL_OBJECT *ob, long)
        else
                cmdname = "url";
        
-       Buffer *buffer = current_view->currentBuffer();
+       Buffer * buffer = current_view->currentBuffer();
        
        if ((url != inset->getContents() ||
             name != inset->getOptions() ||
@@ -95,15 +95,18 @@ void InsetUrl::CloseUrlCB(FL_OBJECT *ob, long)
        
        if (inset->fd_form_url) {
                fl_hide_form(inset->fd_form_url->form_url);
+               fl_free_form(inset->fd_form_url->form_url);
                inset->fd_form_url = 0;
        }
 }
 
-extern "C" void C_InsetUrl_CloseUrlCB(FL_OBJECT *ob, long)
+
+extern "C" void C_InsetUrl_CloseUrlCB(FL_OBJECT * ob, long data)
 {
-       InsetUrl::CloseUrlCB(ob,0);
+       InsetUrl::CloseUrlCB(ob, data);
 }
 
+
 void InsetUrl::Edit(int, int)
 {
        static int ow = -1, oh;
@@ -158,7 +161,7 @@ string InsetUrl::getScreenLabel() const
 }
 
 
-int InsetUrl::Latex(FILE *file, signed char fragile)
+int InsetUrl::Latex(FILE * file, signed char fragile)
 {
        string latex_output;
        int res = Latex(latex_output, fragile);
@@ -181,7 +184,7 @@ int InsetUrl::Latex(string &file, signed char fragile)
 }
 
 
-int InsetUrl::Linuxdoc(string &file)
+int InsetUrl::Linuxdoc(string & file)
 {
        file +=  "<"+ getCmdName() +
                 " url=\""  + getContents()+"\"" +
@@ -191,7 +194,7 @@ int InsetUrl::Linuxdoc(string &file)
 }
 
 
-int InsetUrl::DocBook(string &file)
+int InsetUrl::DocBook(string & file)
 {
        file +=  "<ulink url=\""  + getContents() + "\">" +
                 getOptions() +"</ulink>";
@@ -200,7 +203,7 @@ int InsetUrl::DocBook(string &file)
 }
 
 
-void InsetUrl::Validate(LaTeXFeatures& features) const
+void InsetUrl::Validate(LaTeXFeatures & features) const
 {
        features.url = true;
 }
index eaf1c2159e9efc6b6d74d31e70cf6b8c3442ae64..9d5552f929c98ad4d527ee481cc39dbcf305e9c6 100644 (file)
@@ -6,10 +6,10 @@
  *      
  *         Copyright (C) 1997 LyX Team (this file was created this year)
  * 
- *======================================================*/
+ * ======================================================*/
 
-#ifndef _INSET_URL_H
-#define _INSET_URL_H
+#ifndef INSET_URL_H
+#define INSET_URL_H
 
 #ifdef __GNUG__
 #pragma interface
@@ -34,17 +34,19 @@ public:
        };
        
        ///
-       InsetUrl(): InsetCommand("url"), fd_form_url(0) { flag = InsetUrl::URL; }
+       InsetUrl(): InsetCommand("url"), fd_form_url(0) {
+               flag = InsetUrl::URL;
+       }
        ///
        InsetUrl(string const &);
        ///
-       InsetUrl(InsetCommand const&);
+       InsetUrl(InsetCommand const &);
        ///
-       InsetUrl(string const &,string const &,string const &);
+       InsetUrl(string const &, string const &, string const &);
        ///
        ~InsetUrl();
         ///
-        Inset* Clone() { return new InsetUrl(getCommand()); }
+        Inset * Clone() { return new InsetUrl(getCommand()); }
        ///
        Inset::Code LyxCode() const { return Inset::URL_CODE; }
        ///
@@ -56,32 +58,32 @@ public:
                return 1;
        }
        ///
-       char const* EditMessage() {return "Opened Url";}
+       char const * EditMessage() {return "Opened Url";}
         ///
        bool Display() const { return false; }
        ///
        string getScreenLabel() const;
        ///
-       InsetUrl::Url_Flags getFlag() { return flag; }
+       InsetUrl::Url_Flags getFlag() const { return flag; }
        ///
        void setFlag(InsetUrl::Url_Flags f) { flag = f; }
         ///
         void gotoLabel();
        ///
-       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);
        ///
        static void CloseUrlCB(FL_OBJECT *, long data);
 private:
        ///
         Url_Flags flag;
        ///
-        FD_form_url *fd_form_url;
+        FD_form_url * fd_form_url;
 };
 
 #endif
index c640f1d8f98d21997fc884530c7470c1dc218983..0e7cfce93daccda5835f96a7d660f3b999625a8a 100644 (file)
@@ -4,11 +4,13 @@
  * 
  *           LyX, The Document Processor
  *      
- *         Copyright (C) 1995 Matthias Ettrich
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-1999 the LyX Team.
  *
- *======================================================*/
-#ifndef _LYXINSET_H
-#define _LYXINSET_H
+ * ======================================================*/
+
+#ifndef LYXINSET_H
+#define LYXINSET_H
 
 #ifdef __GNUG__
 #pragma interface
@@ -77,21 +79,22 @@ public:
        };
 
        ///
-       virtual ~Inset(){};
+       virtual ~Inset() {}
        ///
-       virtual int Ascent(LyXFont const &font) const=0;
+       virtual int Ascent(LyXFont const & font) const = 0;
        ///
-       virtual int Descent(LyXFont const &font) const=0;
+       virtual int Descent(LyXFont const & font) const = 0;
        ///
-       virtual int Width(LyXFont const& font) const=0;
+       virtual int Width(LyXFont const & font) const = 0;
        ///
        virtual LyXFont ConvertFont(LyXFont font);
        ///
-       virtual void Draw(LyXFont font, LyXScreen &scr, int baseline, float &x)=0;
+       virtual void Draw(LyXFont font, LyXScreen & scr,
+                         int baseline, float & x) = 0;
        ///
        //virtual void setBuffer(Buffer const&) {;}
        /// what appears in the minibuffer when opening
-       virtual char const* EditMessage() {return _("Opened inset");}
+       virtual char const * EditMessage() {return _("Opened inset");}
        ///
        virtual void Edit(int, int);
        ///
@@ -99,21 +102,21 @@ public:
        ///
        virtual bool AutoDelete() const;
        ///
-       virtual void Write(FILE *file)=0;
+       virtual void Write(FILE * file)=0;
        ///
-       virtual void Read(LyXLex &lex)=0;
+       virtual void Read(LyXLex & lex)=0;
        /** returns the number of rows (\n's) of generated tex code.
         fragile != 0 means, that the inset should take care about
         fragile commands by adding a \protect before.
         */
-       virtual int Latex(FILE *file, signed char fragile)=0;
-       virtual int Latex(string &file, signed char fragile)=0;
+       virtual int Latex(FILE * file, signed char fragile) = 0;
+       virtual int Latex(string & file, signed char fragile) = 0;
        ///
        virtual int Linuxdoc(string &/*file*/) = 0;
        ///
        virtual int DocBook(string &/*file*/) = 0;
        /// Updates needed features for this inset.
-       virtual void Validate(LaTeXFeatures &features) const;
+       virtual void Validate(LaTeXFeatures & features) const;
        ///
        virtual bool Deletable() const;
 
@@ -126,12 +129,12 @@ public:
        }
 
        /// used for autocorrection
-       virtual bool IsEqual(Inset* /*other*/){
+       virtual bool IsEqual(Inset * /*other*/){
                return false;
        }
 
        ///
-       virtual Inset* Clone()=0;
+       virtual Inset * Clone() = 0;
 
        /// returns true to override begin and end inset in file
        virtual bool DirectWrite() const;
@@ -178,34 +181,32 @@ public:
 class UpdatableInset: public Inset {
 public:
        ///
-       virtual ~UpdatableInset() { };
+       virtual ~UpdatableInset() {}
        ///
        virtual unsigned char Editable() const;
    
        /// may call ToggleLockedInsetCursor
        virtual void ToggleInsetCursor();
        ///
-       virtual void GetCursorPos(int&, int&) { }
+       virtual void GetCursorPos(int &, int &) {}
        ///
        virtual void InsetButtonPress(int x, int y, int button);
        ///
        virtual void InsetButtonRelease(int x, int y, int button);
        
        ///
-       virtual void InsetKeyPress(XKeyEvent *ev);
+       virtual void InsetKeyPress(XKeyEvent * ev);
        ///
        virtual void InsetMotionNotify(int x, int y, int state);
        ///
        virtual void InsetUnlock();
    
        ///  An updatable inset could handle lyx editing commands
-       virtual bool LocalDispatch(int, char const*) { return false; };
+       virtual bool LocalDispatch(int, char const *) { return false; };
        //
        bool isCursorVisible() const { return cursor_visible; }
 protected:
        ///
        bool cursor_visible;
 };
-
-
 #endif
index 9808f34dd05afbebd96457b430720e0af4c37c2f..02a6b9e742a1f635c68030339e6ad8569995de33 100644 (file)
@@ -173,7 +173,7 @@ int kb_sequence::parse(char const*s)
        if(!s[0]) return 1;
        
        while(s[i]) {
-               if(s[i] && ((unsigned char) s[i]) <= ' ') i++;
+               if(s[i] && (s[i]) <= ' ') i++;
                if(!s[i]) break;
                
                if(s[i+1]=='-') { // is implicit that s[i]==true
@@ -212,7 +212,7 @@ int kb_sequence::parse(char const*s)
                        }
                } else {
                        int j = 0;
-                       for(j = i; s[j] && ((unsigned char)s[j])>' '; j++)
+                       for(j = i; s[j] && (s[j])>' '; j++)
                                tbuf[j-i] = s[j];    // (!!!check bounds :-)
                        
                        tbuf[j-i] = '\0';
index d2005145b20e92cecb8b03a822ad4b7d4488266d..a30deaba21ddf5b7c481c24cb20402827ce2df8b 100644 (file)
 #pragma implementation
 #endif
 
-#include "lyxlex.h"
+#include <fstream>
+#include <algorithm>
 #include "support/FileInfo.h"
 #include "lastfiles.h"
-#include "support/filetools.h"
 #include "debug.h"
 
-LastFiles::LastFiles(string const & filename, bool st, char num)
+LastFiles::LastFiles(string const & filename, bool st, unsigned int num)
        : dostat(st)
 {
        setNumberOfFiles(num);
-       files = new string[num_files];
        readFile(filename);
 }
 
 
-LastFiles::~LastFiles()
+void LastFiles::setNumberOfFiles(unsigned int no)
 {
-       delete[] files;
-}
-
-
-void LastFiles::setNumberOfFiles(char no)
-{
-       if (1 <= no && no <= ABSOLUTEMAXLASTFILES)
+       if (0 < no && no <= ABSOLUTEMAXLASTFILES)
                num_files = no;
        else {
                lyxerr << "LyX: lastfiles: too many files\n"
-                       "\tdefault (=" << int(DEFAULTFILES) // int() only because of anon enum
+                       "\tdefault (=" << int(DEFAULTFILES)
                       << ") used." << endl;
                num_files = DEFAULTFILES;
        }
@@ -52,48 +45,30 @@ void LastFiles::setNumberOfFiles(char no)
 void LastFiles::readFile(string const & filename)
 {
        // we will not complain if we can't find filename nor will
-       // we issue a warning. Lgb.
-       LyXLex lex(0, 0); /* LyXLex should be changed
-                             * to allow constructor with
-                             * no parameters. */
-       bool error = false;
-
-       lex.setFile(filename);
-
-       if (!lex.IsOK()) return;
-
+       // we issue a warning. (Lgb)
+       ifstream ifs(filename.c_str());
        string tmp;
        FileInfo fileInfo;
-       int i = 0;
-
-       while (lex.IsOK() && !error && i < num_files) {
-               switch(lex.lex()) {
-               case LyXLex::LEX_FEOF:
-                       error = true;
-                       break;
-               default:
-                       tmp = lex.GetString();
-                       // Check if the file exist
-                       if (dostat) {
-                               if (!(fileInfo.newFile(tmp).exist() &&
-                                     fileInfo.isRegular()))
-                                       break; // the file does not exist
-                       }
-                       files[i] = tmp;
-                       i++;
-                       break;
+
+       while(getline(ifs, tmp) && files.size() < num_files) {
+               if (dostat) {
+                       if (!(fileInfo.newFile(tmp).exist() &&
+                             fileInfo.isRegular()))
+                               continue;
                }
+               files.push_back(tmp);
        }
 }
 
 
 void LastFiles::writeFile(string const & filename) const
 {
-       FilePtr fd(filename, FilePtr::write);
-       if (fd()) {
-               for (int i = 0; i < num_files; i++) {
-                       if (!files[i].empty())
-                               fprintf(fd, "\"%s\"\n", files[i].c_str());
+       ofstream ofs(filename.c_str());
+       if (ofs) {
+               for (Files::const_iterator cit = files.begin();
+                    cit != files.end();
+                    ++cit) {
+                       ofs << (*cit) << '\n';
                }
        } else
                lyxerr << "LyX: Warning: unable to save LastFiles: "
@@ -103,12 +78,19 @@ void LastFiles::writeFile(string const & filename) const
 
 void LastFiles::newFile(string const & file)
 {
-       int n;
-       // Find this file in list. If not in list, point to last entry
-       for(n = 0; n < (num_files - 1); n++)
-               if(files[n] == file) break;
-
-       for(int i = n; i >= 1; i--)
-               files[i] = files[i - 1];
-       files[0] = file;
+       // If file already exist, delete it and reinsert at front.
+       Files::iterator it = find(files.begin(), files.end(), file);
+       if (it != files.end())
+               files.erase(it);
+       files.push_front(file);
+       if (files.size() > num_files)
+               files.pop_back();
+}
+
+
+string LastFiles::operator[](unsigned int i) const
+{
+       if (i < files.size())
+               return files[i];
+       return string();
 }
index 64dc4b528351b5eff34b006090acc3c0e4493300..0fdbf71e86e150807a1cec5736458bff70b403e7 100644 (file)
@@ -1,83 +1,88 @@
 // -*- C++ -*-
 /* This file is part of
-* ======================================================
-* 
-*           LyX, The Document Processor
-*       
-*          Copyright (C) 1995 1996 Matthias Ettrich
-*           and the LyX Team.
-*
-*======================================================*/
+ * ======================================================
+ 
+ *           LyX, The Document Processor
+ *      
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-1999 The LyX Team.
+ *
+ * ====================================================== */
 
-#ifndef _LASTFILES_H
-#define _LASTFILES_H
+#ifndef LASTFILES_H
+#define LASTFILES_H
 
 #ifdef __GNUG__
 #pragma interface
 #endif
 
+#include <deque>
 #include "LString.h"
 
 
 /** The latest documents loaded
-  This class takes care of the last .lyx files used by the LyX user. It
-  both reads and writes this information to a file. The number of files
-  kept are user defined, but defaults to four.
+    This class takes care of the last .lyx files used by the LyX user. It
+    both reads and writes this information to a file. The number of files
+    kept are user defined, but defaults to four.
 */
 class LastFiles 
 {
 public:
+       ///
+       typedef deque<string> Files;
+
        /**@name Constructors and Deconstructors */
        //@{
        /**
-         Parameters are: name of file to read. Whether you want LastFiles 
-         to check for file existance, and the number of files to remember.
-         */
-       LastFiles(string const &, bool dostat = true, char num = 4);
-       ///
-       ~LastFiles();
+          Parameters are: name of file to read. Whether LastFiles should
+          check for file existance, and the number of files to remember.
+       */
+       LastFiles(string const &, bool dostat = true, unsigned int num = 4);
        //@}
-
+       
        /**@name Methods */
        //@{
        /**
-         This funtion inserts #file# into the last files list. If the file
-         already exist it is moved to the top of the list. If it don't
-         exist it is placed on the top of the list. If the list already is
-         full the last visited file in the list is puched out and deleted.
-        */
+          This funtion inserts #file# into the last files list. If the file
+          already exist it is moved to the top of the list, else exist it
+          is placed on the top of the list. If the list is full the last
+          file in the list is popped from the end.
+       */
        void newFile(string const &);
-       /**  Writes the lastfiles table to disk. A " is placed around the
-         filenames to preserve special chars. (not all are preserved
-         anyway, but at least space is.)
-         */
+       /**  Writes the lastfiles table to disk. One file on each line, this
+            way we can at least have some special chars (e.g. space), but
+            newline in filenames are thus not allowed.
+       */
        void writeFile(string const &) const;
+       ///
+       string operator[](unsigned int) const;
+       ///
+       Files::const_iterator begin() const { return files.begin(); }
+       ///
+       Files::const_iterator end() const { return files.end(); }
        //@}
 private:
        /**@name const variables */
        //@{
-       /// 
-       enum {
-               ///
-               DEFAULTFILES = 4
-       };
-       /** There is no point in keeping more than this number of files
-         at the same time. However perhaps someday someone finds use for
-         more files and wants to change it. Please do. But don't show
-         the files in a menu...
-         */
        enum {
                ///
+               DEFAULTFILES = 4,
+               /** There is no point in keeping more than this number
+                   of files at the same time. However perhaps someday
+                   someone finds use for more files and wants to
+                   change it. Please do. But don't show the files in
+                   a menu...
+               */
                ABSOLUTEMAXLASTFILES = 20
        };
        //@}
-
+       
        /**@name Variables */
        //@{
-       /// an array of lastfiles
-       string *files;
+       /// a list of lastfiles
+       Files files;
        /// number of files in the lastfiles list.
-       char num_files;
+       unsigned int num_files;
        /// check for file existance or not.
        bool dostat;
        //@}
@@ -85,43 +90,13 @@ private:
        /**@name Methods */
        //@{
        /** reads the .lyx_lastfiles at the beginning of the LyX session.
-         This will read the lastfiles file (usually .lyx_lastfiles). It
-         will normally discard files that don't exist anymore, unless
-         LastFiles has been initialized with dostat = false. 
-        */
+           This will read the lastfiles file (usually .lyx_lastfiles). It
+           will normally discard files that don't exist anymore, unless
+           LastFiles has been initialized with dostat = false. 
+       */
        void readFile(string const &);
        /// used by the constructor to set the number of stored last files.
-        void setNumberOfFiles(char num);
-       //@}
-
-       /**@name Friends */
-       //@{
-       ///
-       friend class LastFiles_Iter;
+        void setNumberOfFiles(unsigned int num);
        //@}
 };
-
-
-/// An Iterator class for LastFiles
-class LastFiles_Iter {
-public:
-       ///
-       LastFiles_Iter(const LastFiles& la)
-       {cs = &la; index = 0;}
-       ///
-       string operator() ()
-       {
-               return (index < cs->num_files)? cs->files[index++] 
-                                               : string();
-       }
-       ///
-       string operator[] (int a)
-       { return cs->files[a];}
-private:
-       ///
-       const LastFiles *cs;
-       ///
-       char index;
-};
-
 #endif
index 7c73af5362cba619e95bd507049e079cc1cb375b..9c0dcf112542f0e4a60cf7c0b18912f2e015be62 100644 (file)
@@ -6,22 +6,7 @@
  *          Copyright 1995 Matthias Ettrich
  *          Copyright 1995-1999 The LyX Team.
  *
- * ======================================================*/
-
-/* Change log:
- * 
- *  14/11/1995,   Pascal André <andre@via.ecp.fr>
- *  Modified for external style definition. 
- * 
- *  15/11/1995,   Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
- *  Modified to use binary search and a small pseudo lexical analyzer.
- *  
- *  29/03/1996,  Dirk Niggeman
- *  Created classes LyXTextClass & LyXLayout.
- * 
- *  30/03/1996,  asierra
- *  Created class LyxLex and improved the lexical analyzer. 
- */
+ * ====================================================== */
 
 #include <config.h>
 
 #pragma implementation
 #endif
 
+#include <algorithm>
+
 #include "definitions.h"
-#include <cstdlib>
 #include "layout.h"
 #include "lyxlex.h"
 #include "support/filetools.h"
 #include "lyx_gui_misc.h"
 #include "debug.h"
 #include "gettext.h"
+#include "support/LAssert.h"
 
-/* Global variable: textclass table */
-LyXTextClassList lyxstyle;
+// Global variable: textclass table.
+LyXTextClassList textclasslist;
 
 // Reads the style files
 void LyXSetStyle()
 {
-       lyxerr.debug() << "LyXSetStyle: parsing configuration..." << endl;
+       lyxerr[Debug::TCLASS] << "LyXSetStyle: parsing configuration...\n";
        
-       if (!lyxstyle.Read()) {
-               lyxerr << "LyXSetStyle: an error occured during parsing.\n"
-                      << "             Exiting." << endl;
+       if (!textclasslist.Read()) {
+               lyxerr[Debug::TCLASS] << "LyXSetStyle: an error occured "
+                       "during parsing.\n             Exiting." << endl;
                exit(1);
        }
 
-       lyxerr.debug() << "LyXSetStyle: configuration parsed." << endl;
+       lyxerr[Debug::TCLASS] << "LyXSetStyle: configuration parsed." << endl;
 }
 
 
 //  The order of the LayoutTags enum is no more important. [asierra300396]
-/* tags indexes */
-enum _LayoutTags {
+// Tags indexes.
+enum LayoutTags {
        LT_ALIGN, LT_ALIGNPOSSIBLE, 
        LT_BLOCK, LT_MARGIN,
        LT_BOTTOMSEP, LT_CENTER, LT_CENTERED_TOP_ENVIRONMENT, LT_COLUMNS,
@@ -141,7 +128,7 @@ static keyword_item layoutTags[] = {
        { "labelindent",                LT_LABELINDENT },
        { "labelsep",                   LT_LABELSEP },
        { "labelstring",                LT_LABELSTRING },
-       { "labelstringappendix",                LT_LABELSTRING_APPENDIX },
+       { "labelstringappendix",        LT_LABELSTRING_APPENDIX },
        { "labeltype",                  LT_LABELTYPE },
        { "latex",                      LT_OTLATEX },
        { "latexname",                  LT_LATEXNAME },
@@ -192,7 +179,7 @@ static keyword_item layoutTags[] = {
 };
 
 
-/* ******************************************************************* */
+/////////////////////
 
 // Constructor for layout
 LyXLayout::LyXLayout ()
@@ -225,97 +212,49 @@ LyXLayout::LyXLayout ()
 }
 
 
-LyXLayout::~LyXLayout ()
-{
-}
-
-
-void LyXLayout::Copy (LyXLayout const &l)
-{
-       name = l.name;
-       obsoleted_by = l.obsoleted_by;
-       margintype = l.margintype;
-       latextype = l.latextype;
-       intitle = l.intitle;
-       needprotect = l.needprotect;
-       keepempty = l.keepempty;
-       latexname = l.latexname;
-       latexparam = l.latexparam;   //arrae970411
-       preamble = l.preamble;
-       font = l.font;
-       labelfont = l.labelfont;
-       resfont = l.resfont;
-       reslabelfont = l.reslabelfont;
-       nextnoindent = l.nextnoindent;
-       leftmargin = l.leftmargin;
-       rightmargin = l.rightmargin;
-       labelsep = l.labelsep;
-       labelindent = l.labelindent;
-       parindent = l.parindent;
-       parskip = l.parskip;
-       itemsep = l.itemsep;
-       topsep = l.topsep;
-       bottomsep = l.bottomsep;
-       labelbottomsep = l.labelbottomsep;
-       parsep = l.parsep;
-       align = l.align;
-       alignpossible = l.alignpossible;
-       labeltype = l.labeltype;
-       spacing = l.spacing;
-       labelstring = l.labelstring;
-       labelstring_appendix = l.labelstring_appendix;
-       fill_top = l.fill_top;
-       fill_bottom = l.fill_bottom;
-       newline_allowed = l.newline_allowed;
-       free_spacing = l.free_spacing;
-}
-
-
-/* Reads a layout definition from file */
-bool LyXLayout::Read (LyXLex & lexrc, LyXLayoutList * list)
+// Reads a layout definition from file
+bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
 {
        bool error = false;
        bool finished = false;
        
-       /* parse style section */
+       // parse style section
        while (!finished && lexrc.IsOK() && !error) {
                switch(lexrc.lex()) {
 
                case -2:
                        break;
 
-               case -1:                /* parse error */
+               case -1:                // parse error
                        lexrc.printError("Unknown tag `$$Token'");
                        error = true;
                        break;
 
-               case LT_END:            /* end of structure */
+               case LT_END:            // end of structure
                        finished = true;
                        break;
 
                case LT_COPYSTYLE:     // initialize with a known style
                        if (lexrc.next()) {
-                               LyXLayout * layout = list->GetLayout(lexrc.GetString());
-                               if (layout) {
-                                       string tmpname = name;
-                                       Copy(*layout);
-                                       name = tmpname;
+                               if (tclass.hasLayout(lexrc.GetString())) {
+                                       string tmpname = name_;
+                                       this->operator=(tclass.GetLayout(lexrc.GetString()));
+                                       name_ = tmpname;
                                } else {
-                                       lexrc.printError("Cannot copy unknown "
-                                                 "style `$$Token'");
+                                       lexrc.printError("Cannot copy known "
+                                                        "style `$$Token'");
                                }
                        }
                        break;
 
                case LT_OBSOLETEDBY:     // replace with a known style
                        if (lexrc.next()) {
-                               LyXLayout * layout = list->GetLayout(lexrc.GetString());
-                               if (layout) {
-                                       string tmpname = name;
-                                       Copy(*layout);
-                                       name = tmpname;
-                                       if (obsoleted_by.empty())
-                                               obsoleted_by = lexrc.GetString();
+                               if (tclass.hasLayout(lexrc.GetString())) {
+                                       string tmpname = name_;
+                                       this->operator=(tclass.GetLayout(lexrc.GetString()));
+                                       name_ = tmpname;
+                                       if (obsoleted_by().empty())
+                                         obsoleted_by_ = lexrc.GetString();
                                } else {
                                        lexrc.printError("Cannot replace with" 
                                                         " unknown style "
@@ -324,7 +263,7 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXLayoutList * list)
                        }
                        break;
 
-               case LT_MARGIN:         /* margin style definition */
+               case LT_MARGIN:         // Margin style definition.
                       
                        switch(lexrc.lex()) {
                        case LT_STATIC:
@@ -348,7 +287,7 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXLayoutList * list)
                        }
                        break;
 
-               case LT_LATEXTYPE:      /* latex style definition */
+               case LT_LATEXTYPE:      // Latex style definition.
                        switch (lexrc.lex()) {
                        case LT_PARAGRAPH:
                                latextype=LATEX_PARAGRAPH;
@@ -396,29 +335,28 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXLayoutList * list)
                        labelfont.lyxRead(lexrc);
                        break;
 
-               case LT_NEXTNOINDENT:   /* indent next paragraph ? */
+               case LT_NEXTNOINDENT:   // Indent next paragraph?
                        if (lexrc.next() && lexrc.GetInteger())
                                nextnoindent = true;
                        else
                                nextnoindent = false;
                        break;
 
-               case LT_LATEXNAME:      /* latex name */
+               case LT_LATEXNAME:
                        if (lexrc.next())
-                               latexname = lexrc.GetString();
+                               latexname_ = lexrc.GetString();
                        break;
                         
-                //arrae970411
-               case LT_LATEXPARAM:     /* latex parameter */
+               case LT_LATEXPARAM:
                        if (lexrc.next())
-                               latexparam = lexrc.GetString();
+                               latexparam_ = lexrc.GetString();
                        break;
 
                case LT_PREAMBLE:
-                       preamble = lexrc.getLongString("EndPreamble");
+                       preamble_ = lexrc.getLongString("EndPreamble");
                        break;
 
-               case LT_LABELTYPE:      /* label type */
+               case LT_LABELTYPE:
                        switch (lexrc.lex()) {
                        case LT_NO_LABEL:
                                labeltype = LABEL_NO_LABEL;
@@ -476,78 +414,78 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXLayoutList * list)
                        }
                        break;
 
-               case LT_LEFTMARGIN:     /* left margin type */
+               case LT_LEFTMARGIN:     // left margin type
                        if (lexrc.next())
                                leftmargin = lexrc.GetString();
                        break;                  
 
-               case LT_RIGHTMARGIN:    /* right margin type */
+               case LT_RIGHTMARGIN:    // right margin type
                        if (lexrc.next())
                                rightmargin = lexrc.GetString();
                        break;
 
-               case LT_LABELINDENT:    /* label indenting flag */
+               case LT_LABELINDENT:    // label indenting flag
                        if (lexrc.next())
                                labelindent = lexrc.GetString();
                        break;
 
-               case LT_PARINDENT:      /* paragraph indent. flag */
+               case LT_PARINDENT:      // paragraph indent. flag
                        if (lexrc.next())
                                parindent = lexrc.GetString();
                        break;
 
-               case LT_PARSKIP:        /* paragraph skip size */
+               case LT_PARSKIP:        // paragraph skip size
                        if (lexrc.next())
                                parskip = lexrc.GetFloat();
                        break;
 
-               case LT_ITEMSEP:        /* item separation size */
+               case LT_ITEMSEP:        // item separation size
                        if (lexrc.next())
                                itemsep = lexrc.GetFloat();
                        break;
 
-               case LT_TOPSEP:         /* top separation size */
+               case LT_TOPSEP:         // top separation size
                        if (lexrc.next())
                                topsep = lexrc.GetFloat();
                        break;
 
-               case LT_BOTTOMSEP:      /* bottom separation size */
+               case LT_BOTTOMSEP:      // bottom separation size
                        if (lexrc.next())
                                bottomsep = lexrc.GetFloat();
                        break;
 
-               case LT_LABEL_BOTTOMSEP:/* label bottom separation size */
+               case LT_LABEL_BOTTOMSEP: // label bottom separation size
                        if (lexrc.next())
                                labelbottomsep = lexrc.GetFloat();
                        break;
 
-               case LT_LABELSEP:       /* label separator */
+               case LT_LABELSEP:       // label separator
                        if (lexrc.next()) {
                                labelsep = subst(lexrc.GetString(), 'x', ' ');
                        }
                        break;
 
-               case LT_PARSEP:         /* par. separation size */
+               case LT_PARSEP:         // par. separation size
                        if (lexrc.next())
                                parsep = lexrc.GetFloat();
                        break;
 
-               case LT_FILL_TOP:       /* fill top flag */
+               case LT_FILL_TOP:       // fill top flag
                        if (lexrc.next())
                                fill_top = lexrc.GetInteger();
                        break;
 
-               case LT_FILL_BOTTOM:    /* fill bottom flag */
+               case LT_FILL_BOTTOM:    // fill bottom flag
                        if (lexrc.next())
                                fill_bottom = lexrc.GetInteger();
                        break;
 
-               case LT_NEWLINE:        /* newlines allowed ? */
+               case LT_NEWLINE:        // newlines allowed?
                        if (lexrc.next())
                                newline_allowed = lexrc.GetInteger();
                        break;
 
-               case LT_ALIGN:          /* paragraph align */
+               case LT_ALIGN:          // paragraph align
                        switch (lexrc.lex()) {
                        case LT_BLOCK:
                                align = LYX_ALIGN_BLOCK;
@@ -569,8 +507,8 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXLayoutList * list)
                        }
                        break;
 
-               case LT_ALIGNPOSSIBLE:  /* paragraph allowed align */
-               {       alignpossible = 0;
+               case LT_ALIGNPOSSIBLE:  // paragraph allowed align
+               {       alignpossible = LYX_ALIGN_NONE;
                      
                int lineno = lexrc.GetLineNo();
                do {
@@ -594,21 +532,21 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXLayoutList * list)
                                lexrc.printError("Unknown alignment `$$Token'");
 
                        }
-               } while (lineno==lexrc.GetLineNo());
+               } while (lineno == lexrc.GetLineNo());
                break;
                }
 
-               case LT_LABELSTRING:    /* label string definition */
+               case LT_LABELSTRING:    // label string definition
                        if (lexrc.next())
-                               labelstring = lexrc.GetString();
+                               labelstring_ = lexrc.GetString();
                        break;
 
-               case LT_LABELSTRING_APPENDIX:   /* label string appendix definition */
+               case LT_LABELSTRING_APPENDIX: // label string appendix definition
                        if (lexrc.next())
-                               labelstring_appendix = lexrc.GetString();
+                               labelstring_appendix_ = lexrc.GetString();
                        break;
 
-               case LT_FREE_SPACING:   /* Allow for free spacing. */
+               case LT_FREE_SPACING:   // Allow for free spacing.
                        if (lexrc.next())
                                free_spacing = lexrc.GetInteger();
                        break;
@@ -617,15 +555,12 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXLayoutList * list)
                        switch(lexrc.lex()) {
                        case LT_SPACING_SINGLE:
                                spacing.set(Spacing::Single);
-                               //spacing_value = 1.0;
                                break;
                        case LT_SPACING_ONEHALF:
                                spacing.set(Spacing::Onehalf);
-                               //spacing_value = 1.25;
                                break;
                        case LT_SPACING_DOUBLE:
                                spacing.set(Spacing::Double);
-                               //spacing_value = 1.667;
                                break;
                        case LT_OTHER:
                                lexrc.next();
@@ -646,195 +581,63 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXLayoutList * list)
        return error;
 }
 
-/* ******************************************************************* */
-
-LyXLayoutList::LyXLayoutList()
-{
-       l = 0;
-       eol = 0;
-       num_layouts = 0;
-}
-
-
-LyXLayoutList::~LyXLayoutList()
-{
-       //don't do anything. the layouts will be extracted by ToAr.
-       //destruction is done by Clean in emergencies
-}
-
-
-int LyXLayoutList::GetNum ()
-{
-       return num_layouts;
-}
-
-
-void LyXLayoutList::Add (LyXLayout *lay)
-{
-       LyXLayoutL * tmp = new LyXLayoutL;
-       tmp->layout = lay;
-       tmp->next = 0;
-       if (!eol) l = tmp; 
-       else eol->next = tmp;
-       eol = tmp;
-       num_layouts++;
-}
-
-
-bool LyXLayoutList::Delete (string const &name)
-{
-       LyXLayoutL * layoutl = l;
-       while(layoutl) {
-               if (layoutl->layout && layoutl->layout->name == name) {
-                       delete layoutl->layout;
-                       layoutl->layout = 0; // not sure it is necessary
-                       num_layouts--;
-                       return true;
-               }
-               layoutl = layoutl->next;
-       }
-       return false;
-}
-
-
-LyXLayout * LyXLayoutList::GetLayout (string const &name)
-{
-       LyXLayoutL * layoutl = l;
-       while(layoutl) {
-               if (layoutl->layout && layoutl->layout->name == name) 
-                       return layoutl->layout;
-               layoutl = layoutl->next;
-       }
-       return 0;
-}
-
-
-LyXLayout * LyXLayoutList::ToAr ()
-{
-       LyXLayoutL * lp, * op;
-       int idx = 0;
-       LyXLayout* ar = new LyXLayout [num_layouts];
-       lp = l;
-       while (lp) {
-               if (lp->layout) {
-                       ar[idx].Copy (*lp->layout);
-                       idx++;
-                       delete lp->layout;
-               }
-               op = lp;
-               lp = lp->next;
-               delete op;
-       }
-       return ar;
-}
-
-
-//wipe up any dead layouts
-void LyXLayoutList::Clean ()
-{
-       LyXLayoutL * lp, * op;
-       lp = l;
-       while (lp) {
-               delete lp->layout;
-               op = lp;
-               lp = lp->next;
-               delete op;
-       }
-}
 
 /* ******************************************************************* */
 
-LyXTextClass::LyXTextClass(string const &fn, string const &cln,
-                          string const &desc)
+LyXTextClass::LyXTextClass(string const & fn, string const & cln,
+                          string const & desc)
+       : name_(fn), latexname_(cln), description_(desc)
 {
-       name = fn;
-       latexname = cln;
-       description = desc;
-       output_type = LATEX;
-       style = 0;
-       columns = 1;
-       sides = 1;
-       secnumdepth = 3;
-       tocdepth = 3;
-       pagestyle = "default";
-       maxcounter = LABEL_COUNTER_CHAPTER;
-       defaultfont = LyXFont(LyXFont::ALL_SANE);
-       number_of_defined_layouts = 0;
-       opt_fontsize = "10|11|12";
-       opt_pagestyle = "empty|plain|headings|fancy";
-       provides_amsmath = false;
-       provides_makeidx = false;
-       provides_url = false;
+       outputType_ = LATEX;
+       columns_ = 1;
+       sides_ = OneSide;
+       secnumdepth_ = 3;
+       tocdepth_ = 3;
+       pagestyle_ = "default";
+       maxcounter_ = LABEL_COUNTER_CHAPTER;
+       defaultfont_ = LyXFont(LyXFont::ALL_SANE);
+       opt_fontsize_ = "10|11|12";
+       opt_pagestyle_ = "empty|plain|headings|fancy";
+       provides_ = nothing;
        loaded = false;
 }
 
 
-// This is not a proper copy.
-// It just references the style rather than copying it!
-void LyXTextClass::Copy (LyXTextClass const &l)
+bool LyXTextClass::do_readStyle(LyXLex & lexrc, LyXLayout & lay)
 {
-       name = l.name;
-       latexname = l.latexname;
-       description = l.description;
-       output_type = l.output_type;
-       preamble = l.preamble;
-       options = l.options;
-       if (style) delete style;
-       style = l.style; //just aliases NO COPY
-       number_of_defined_layouts = l.number_of_defined_layouts;
-       columns = l.columns;
-       sides = l.sides;
-       secnumdepth = l.secnumdepth;
-       tocdepth = l.tocdepth;
-       pagestyle = l.pagestyle;
-       maxcounter = l.maxcounter;
-       defaultfont = l.defaultfont;
-        opt_fontsize = l.opt_fontsize;
-        opt_pagestyle = l.opt_pagestyle;
-       provides_amsmath = l.provides_amsmath;
-       provides_makeidx = l.provides_makeidx;
-       provides_url = l.provides_url;
-        loaded = l.loaded;
-
-       leftmargin = l.leftmargin;
-       rightmargin = l.rightmargin;
-         
-}
-
-
-LyXTextClass::~LyXTextClass()
-{
-       //we can't delete the style here because otherwise 
-       //our list classes wouldn't work
+       lyxerr[Debug::TCLASS] << "Reading style " << lay.name() << endl;
+       if (!lay.Read(lexrc, *this)) {
+               // Reslove fonts
+               lay.resfont = lay.font;
+               lay.resfont.realize(defaultfont());
+               lay.reslabelfont = lay.labelfont;
+               lay.reslabelfont.realize(defaultfont());
+               return false; // no errors
+       } 
+       lyxerr << "Error parsing style `" << lay.name() << "'" << endl;
+       return true;
 }
 
 
-/* Reads a textclass structure from file */
-int LyXTextClass::Read (string const &filename, LyXLayoutList *list)
+// Reads a textclass structure from file.
+bool LyXTextClass::Read(string const & filename, bool merge)
 {
-       if (!list)
+       if (!merge)
                lyxerr[Debug::TCLASS] << "Reading textclass "
                                      << MakeDisplayPath(filename)
                                      << endl;
-       else 
+       else
                lyxerr[Debug::TCLASS] << "Reading input file "
-                                     << MakeDisplayPath(filename) << endl;
-
+                                    << MakeDisplayPath(filename)
+                                    << endl;
+       
        LyXLex lexrc(layoutTags, sizeof(layoutTags)/sizeof(keyword_item));
        bool error = false;
 
         lexrc.setFile(filename);
-       if (!lexrc.IsOK()) return -2; 
-
-       LyXLayoutList * l;
-       LyXLayout * tmpl;
+       if (!lexrc.IsOK()) error = true; 
 
-       if (list) 
-               l = list;
-       else 
-               l = new LyXLayoutList;
-
-       /* parsing */
+       // parsing
        while (lexrc.IsOK() && !error) {
                switch(lexrc.lex()) {
                case -2:
@@ -848,16 +651,16 @@ int LyXTextClass::Read (string const &filename, LyXLayoutList *list)
                case LT_OUTPUTTYPE:   // output type definition
                        switch(lexrc.lex()) {
                        case LT_OTLATEX:
-                               output_type=LATEX;
+                               outputType_ = LATEX;
                                break;
                        case LT_OTLINUXDOC:
-                               output_type=LINUXDOC;
+                               outputType_ = LINUXDOC;
                                break;
                        case LT_OTDOCBOOK:
-                               output_type=DOCBOOK;
+                               outputType_ = DOCBOOK;
                                break;
                        case LT_OTLITERATE:
-                               output_type=LITERATE;
+                               outputType_ = LITERATE;
                                break;
                        default:
                                lexrc.printError("Unknown output type `$$Token'");
@@ -871,7 +674,7 @@ int LyXTextClass::Read (string const &filename, LyXLayoutList *list)
                                                            lexrc.GetString(), 
                                                            "layout");
                                
-                               if (Read(tmp, l)) {
+                               if (Read(tmp, true)) {
                                        lexrc.printError("Error reading input"
                                                         "file: "+tmp);
                                        error = true;
@@ -881,40 +684,16 @@ int LyXTextClass::Read (string const &filename, LyXLayoutList *list)
 
                case LT_STYLE:
                        if (lexrc.next()) {
-                               bool is_new = false;
-
-                               string name = subst(lexrc.GetString(), '_', ' ');
-                               tmpl = l->GetLayout(name);
-                               if (!tmpl) {
-                                       is_new = true;
-                                       tmpl = new LyXLayout;
-                                       tmpl->name = name;
-                               }
-
-                               lyxerr[Debug::TCLASS] << "  Reading style "
-                                                     << tmpl->name
-                                                     << endl;
-
-                               if (!tmpl->Read(lexrc, l)) {
-                                       // Resolve fonts
-                                       tmpl->resfont = tmpl->font;
-                                       tmpl->resfont.realize(defaultfont);
-                                       tmpl->reslabelfont = tmpl->labelfont;
-                                       tmpl->reslabelfont.realize(defaultfont);
-                                       if (is_new) {
-                                               l->Add (tmpl);
-                                               // NB! we don't delete because 
-                                               // we just pass it in.... 
-                                       }
+                               string name = subst(lexrc.GetString(),
+                                                   '_', ' ');
+                               if (hasLayout(name)) {
+                                       LyXLayout & lay = GetLayout(name);
+                                       error = do_readStyle(lexrc, lay);
                                } else {
-                                       lexrc.printError(
-                                                      "Error parsing style `"
-                                                      +tmpl->name+'\'');
-                                       error = true;
-                                       if (is_new) {
-                                               delete tmpl;  
-                                               //we delete dead ones here
-                                       }
+                                       LyXLayout lay;
+                                       lay.name(name);
+                                       if (!(error =do_readStyle(lexrc, lay)))
+                                               layoutlist.push_back(lay);
                                }
                        }
                        else {
@@ -925,82 +704,94 @@ int LyXTextClass::Read (string const &filename, LyXLayoutList *list)
 
                case LT_NOSTYLE:
                        if (lexrc.next()) {
-                               string style = lexrc.GetString();
-                               if (!l->Delete(subst(style, '_', ' ')))
-                                       lexrc.printError("Cannot delete style `$$Token'");
+                               string style = subst(lexrc.GetString(),
+                                                    '_', ' ');
+                               if (!delete_layout(style))
+                                       lexrc.printError("Cannot delete style"
+                                                        " `$$Token'");
                        }
                        break;
 
                case LT_COLUMNS:
                        if (lexrc.next())
-                               columns = lexrc.GetInteger();
+                               columns_ = lexrc.GetInteger();
                        break;
                        
                case LT_SIDES:
-                       if (lexrc.next())
-                               sides = lexrc.GetInteger();
+                       if (lexrc.next()) {
+                               switch(lexrc.GetInteger()) {
+                               case 1: sides_ = OneSide; break;
+                               case 2: sides_ = TwoSides; break;
+                               default:
+                                       lyxerr << "Impossible number of page"
+                                               " sides, setting to one."
+                                              << endl;
+                                       sides_ = OneSide;
+                                       break;
+                               }
+                       }
                        break;
                        
                case LT_PAGESTYLE:
                        lexrc.next();
-                       pagestyle = strip(lexrc.GetString());
+                       pagestyle_ = strip(lexrc.GetString());
                        break;
                        
                case LT_DEFAULTFONT:
-                       defaultfont.lyxRead(lexrc);
-                       if (!defaultfont.resolved()) {
+                       defaultfont_.lyxRead(lexrc);
+                       if (!defaultfont_.resolved()) {
                                lexrc.printError("Warning: defaultfont should "
                                                 "be fully instantiated!");
-                               defaultfont.realize(LyXFont::ALL_SANE);
+                               defaultfont_.realize(LyXFont::ALL_SANE);
                        }
                        break;
 
                case LT_MAXCOUNTER:
                        switch (lexrc.lex()) {
                        case LT_COUNTER_CHAPTER:
-                               maxcounter = LABEL_COUNTER_CHAPTER;
+                               maxcounter_ = LABEL_COUNTER_CHAPTER;
                                break;
                        case LT_COUNTER_SECTION:
-                               maxcounter = LABEL_COUNTER_SECTION;
+                               maxcounter_ = LABEL_COUNTER_SECTION;
                                break;
                        case LT_COUNTER_SUBSECTION:
-                               maxcounter = LABEL_COUNTER_SUBSECTION;
+                               maxcounter_ = LABEL_COUNTER_SUBSECTION;
                                break;
                        case LT_COUNTER_SUBSUBSECTION:
-                               maxcounter = LABEL_COUNTER_SUBSUBSECTION;
+                               maxcounter_ = LABEL_COUNTER_SUBSUBSECTION;
                                break;
                        case LT_COUNTER_PARAGRAPH:
-                               maxcounter = LABEL_COUNTER_PARAGRAPH;
+                               maxcounter_ = LABEL_COUNTER_PARAGRAPH;
                                break;
                        case LT_COUNTER_SUBPARAGRAPH:
-                               maxcounter = LABEL_COUNTER_SUBPARAGRAPH;
+                               maxcounter_ = LABEL_COUNTER_SUBPARAGRAPH;
                                break;
                        case LT_COUNTER_ENUMI:
-                               maxcounter = LABEL_COUNTER_ENUMI;
+                               maxcounter_ = LABEL_COUNTER_ENUMI;
                                break;
                        case LT_COUNTER_ENUMII:
-                               maxcounter = LABEL_COUNTER_ENUMII;
+                               maxcounter_ = LABEL_COUNTER_ENUMII;
                                break;
                        case LT_COUNTER_ENUMIII:
-                               maxcounter = LABEL_COUNTER_ENUMIII;
+                               maxcounter_ = LABEL_COUNTER_ENUMIII;
                                break;
                        case LT_COUNTER_ENUMIV:
-                               maxcounter = LABEL_COUNTER_ENUMIV;
+                               maxcounter_ = LABEL_COUNTER_ENUMIV;
                                break;
                        }
                        break;
 
                case LT_SECNUMDEPTH:
                        lexrc.next();
-                       secnumdepth = lexrc.GetInteger();
+                       secnumdepth_ = lexrc.GetInteger();
                        break;
 
                case LT_TOCDEPTH:
                        lexrc.next();
-                       tocdepth = lexrc.GetInteger();
+                       tocdepth_ = lexrc.GetInteger();
                        break;
 
-        // First step to support options 
+                       // First step to support options 
                case LT_CLASSOPTIONS:
                {
                        bool getout = true;
@@ -1008,15 +799,15 @@ int LyXTextClass::Read (string const &filename, LyXLayoutList *list)
                                switch (lexrc.lex()) {
                                case LT_FONTSIZE:
                                        lexrc.next();
-                                       opt_fontsize = strip(lexrc.GetString());
+                                       opt_fontsize_ = strip(lexrc.GetString());
                                        break;
                                case LT_PAGESTYLE:
                                        lexrc.next();
-                                       opt_pagestyle = strip(lexrc.GetString()); 
+                                       opt_pagestyle_ = strip(lexrc.GetString()); 
                                        break;
                                case LT_OTHER:
                                        lexrc.next();
-                                       options = lexrc.GetString();
+                                       options_ = lexrc.GetString();
                                        break;
                                case LT_END: getout = false; break;
                                default:
@@ -1028,32 +819,32 @@ int LyXTextClass::Read (string const &filename, LyXLayoutList *list)
                }
 
                case LT_PREAMBLE:
-                       preamble = lexrc.getLongString("EndPreamble");
+                       preamble_ = lexrc.getLongString("EndPreamble");
                        break;
 
                case LT_PROVIDESAMSMATH:
-                       if (lexrc.next())
-                               provides_amsmath = lexrc.GetInteger();
+                       if (lexrc.next() && lexrc.GetInteger())
+                               provides_ |= amsmath;
                        break;
 
                case LT_PROVIDESMAKEIDX:
-                       if (lexrc.next())
-                               provides_makeidx = lexrc.GetInteger();
+                       if (lexrc.next() && lexrc.GetInteger())
+                               provides_ |= makeidx;
                        break;
 
                case LT_PROVIDESURL:
-                       if (lexrc.next())
-                               provides_url = lexrc.GetInteger();
+                       if (lexrc.next() && lexrc.GetInteger())
+                               provides_ = url;
                        break;
 
-               case LT_LEFTMARGIN:     /* left margin type */
+               case LT_LEFTMARGIN:     // left margin type
                        if (lexrc.next())
-                               leftmargin = lexrc.GetString();
+                               leftmargin_ = lexrc.GetString();
                        break;                  
 
-               case LT_RIGHTMARGIN:    /* right margin type */
+               case LT_RIGHTMARGIN:    // right margin type
                        if (lexrc.next())
-                               rightmargin = lexrc.GetString();
+                               rightmargin_ = lexrc.GetString();
                        break;
 
                default:
@@ -1062,22 +853,11 @@ int LyXTextClass::Read (string const &filename, LyXLayoutList *list)
                }
        }       
 
-       if (!list) { // we are at top level here.
-               if (error) {
-                       number_of_defined_layouts = 0;
-                       l->Clean(); //wipe any we may have found
-                       delete l;
-               }
-               else {
-                       style = l->ToAr();
-                       number_of_defined_layouts = l->GetNum();
-                       delete l;
-               }
+       if (!merge) { // we are at top level here.
                lyxerr[Debug::TCLASS] << "Finished reading textclass " 
                                      << MakeDisplayPath(filename)
                                      << endl;
-       }
-       else
+       } else
                lyxerr[Debug::TCLASS] << "Finished reading input file " 
                                      << MakeDisplayPath(filename)
                                      << endl;
@@ -1086,190 +866,209 @@ int LyXTextClass::Read (string const &filename, LyXLayoutList *list)
 }
 
 
+bool LyXTextClass::hasLayout(string const & name) const
+{
+       for (LayoutList::const_iterator cit = layoutlist.begin();
+            cit != layoutlist.end(); ++cit) {
+               if ((*cit).name() == name)
+                       return true;
+       }
+       return false;
+}
+
+
+LyXLayout const & LyXTextClass::GetLayout (string const & name) const
+{
+       for (LayoutList::const_iterator cit = layoutlist.begin();
+            cit != layoutlist.end(); ++cit) {
+               if ((*cit).name() == name)
+                       return (*cit);
+       }
+       Assert(false); // we actually require the name to exist.
+       return layoutlist.front();
+}
+
+
+LyXLayout & LyXTextClass::GetLayout(string const & name)
+{
+       for (LayoutList::iterator it = layoutlist.begin();
+            it != layoutlist.end(); ++it) {
+               if ((*it).name() == name)
+                       return (*it);
+       }
+       Assert(false); // we actually require the name to exist.
+       return layoutlist.front();
+}
+
+
+bool LyXTextClass::delete_layout (string const & name)
+{
+       for(LayoutList::iterator it = layoutlist.begin();
+           it != layoutlist.end(); ++it) {
+               if ((*it).name() == name) {
+                       layoutlist.erase(it);
+                       return true;
+               }
+       }
+       return false;
+}
+
+
 // Load textclass info if not loaded yet
 void LyXTextClass::load()
 {
-       if (loaded)
-               return;
+       if (loaded) return;
 
        // Read style-file
-       string real_file = LibFileSearch("layouts", name, "layout");
+       string real_file = LibFileSearch("layouts", name_, "layout");
 
        if (Read(real_file)) {
                lyxerr << "Error reading `"
                       << MakeDisplayPath(real_file)
-                      << "'\n(Check `" << name
+                      << "'\n(Check `" << name_
                       << "')\nCheck your installation and "
                        "try Options/Reconfigure..." << endl;
        }
        loaded = true;
 }
 
-/* ******************************************************************* */
-
-LyXTextClassList::LyXTextClassList()
-{
-       l = 0;
-       ar = 0;
-       num_textclass = 0;
-}
-
-
-LyXTextClassList::~LyXTextClassList()
-{
-       // The textclass list is in ar.
-       if (ar) {
-               delete [] ar;
-       }
-}
 
+//////////////////////////////////////////
 
 // Gets textclass number from name
-signed char LyXTextClassList::NumberOfClass(string const &textclass) 
+pair<bool, LyXTextClassList::ClassList::size_type>
+LyXTextClassList::NumberOfClass(string const & textclass) const
 {
-       int i = 0;
-   
-       while (i < num_textclass && textclass != ar[i].name)
-               i++;
-   
-       if (i >= num_textclass)
-               i = -1;
-
-       return i;
+       for (ClassList::const_iterator cit = classlist.begin();
+            cit != classlist.end(); ++cit) {
+               if ((*cit).name() == textclass)
+                       return make_pair(true, cit - classlist.begin());
+       }
+       return make_pair(false, 0);
 }
 
 
 // Gets layout structure from style number and textclass number
-LyXLayout *LyXTextClassList::Style(char textclass, char layout) 
+LyXLayout const &
+LyXTextClassList::Style(LyXTextClassList::ClassList::size_type textclass,
+                       LyXTextClass::LayoutList::size_type layout) const
 {
-       ar[textclass].load();
-
-       if (layout < ar[textclass].number_of_defined_layouts)
-               return &ar[textclass].style[layout];
-       else {
-               return &ar[textclass].style[0];
-       };
+       classlist[textclass].load();
+       if (layout < classlist[textclass].numLayouts())
+               return classlist[textclass][layout];
+       return classlist[textclass][0];
 }
 
 
 // Gets layout number from name and textclass number
-char LyXTextClassList::NumberOfLayout(char textclass, string const &name) 
+pair<bool, LyXTextClass::LayoutList::size_type>
+LyXTextClassList::NumberOfLayout(LyXTextClassList::ClassList::size_type textclass, string const & name) const
 {
-       ar[textclass].load();
-
-       int i = 0;
-       while (i < ar[textclass].number_of_defined_layouts 
-              && name != ar[textclass].style[i].name)
-               i++;
-
-       if (i >= ar[textclass].number_of_defined_layouts) {
-               if (name == "dummy")
-                       i = LYX_DUMMY_LAYOUT;
-               else
-                       // so that we can detect if the layout doesn't exist.
-                       i = -1; // not found
-       } 
-       return i;
+       classlist[textclass].load();
+       for(unsigned int i = 0; i < classlist[textclass].numLayouts(); ++i) {
+               if (classlist[textclass][i].name() == name)
+                       return make_pair(true, i);
+       }
+       if (name == "dummy")
+               return make_pair(true, LYX_DUMMY_LAYOUT);
+       return make_pair(false, 0); // not found
 }
 
 
 // Gets a layout (style) name from layout number and textclass number
-string LyXTextClassList::NameOfLayout(char textclass, char layout) 
+string const &
+LyXTextClassList::NameOfLayout(LyXTextClassList::ClassList::size_type textclass,
+                              LyXTextClass::LayoutList::size_type layout) const
 {
-       ar[textclass].load();
-
-       if (layout < ar[textclass].number_of_defined_layouts)
-               return ar[textclass].style[layout].name;
+       static string dummy("dummy");
+       static string end("@@end@@");
+       classlist[textclass].load();
+       if (layout < classlist[textclass].numLayouts())
+               return classlist[textclass][layout].name();
        else if (layout == LYX_DUMMY_LAYOUT)
-               return "dummy";
+               return dummy;
        else
-               return "@@end@@";
+               return end;
 }
 
 
 // Gets a textclass name from number
-string LyXTextClassList::NameOfClass(char number) 
+string const &
+LyXTextClassList::NameOfClass(LyXTextClassList::ClassList::size_type number) const
 {
-       if (num_textclass == 0) { 
-               if (number == 0) return "dummy";
-               else return "@@end@@";
+       static string dummy("dummy");
+       static string end("@@end@@");
+       if (classlist.size() == 0) {
+               if (number == 0) return dummy;
+               else return end;
        }
-       if (number < num_textclass)
-               return ar[number].name;
+       if (number < classlist.size())
+               return classlist[number].name();
        else
-               return "@@end@@";
+               return end;
 }
 
+
 // Gets a textclass latexname from number
-string LyXTextClassList::LatexnameOfClass(char number) 
+string const &
+LyXTextClassList::LatexnameOfClass(LyXTextClassList::ClassList::size_type number) const
 {
-       ar[number].load();
-
-       if (num_textclass == 0) { 
-               if (number == 0) return "dummy";
-               else return "@@end@@";
+       static string dummy("dummy");
+       static string end("@@end@@");
+       classlist[number].load();
+       if (classlist.size() == 0) {
+               if (number == 0) return dummy;
+               else return end;
        }
-       if (number < num_textclass)
-               return ar[number].latexname;
+       if (number < classlist.size())
+               return classlist[number].latexname();
        else
-               return "@@end@@";
+               return end;
 }
 
+
 // Gets a textclass description from number
-string LyXTextClassList::DescOfClass(char number) 
+string const &
+LyXTextClassList::DescOfClass(LyXTextClassList::ClassList::size_type number) const
 {
-       if (num_textclass == 0) { 
-               if (number == 0) return "dummy";
-               else return "@@end@@";
+       static string dummy("dummy");
+       static string end("@@end@@");
+       if (classlist.size() == 0) {
+               if (number == 0) return dummy;
+               else return end;
        }
-       if (number < num_textclass)
-               return ar[number].description;
+       if (number < classlist.size())
+               return classlist[number].description();
        else
-               return "@@end@@";
+               return end;
 }
 
 
 // Gets a textclass structure from number
-LyXTextClass * LyXTextClassList::TextClass(char textclass) 
+LyXTextClass const &
+LyXTextClassList::TextClass(LyXTextClassList::ClassList::size_type textclass) const
 {
-       ar[textclass].load();
-       if (textclass < num_textclass)
-               return &ar[textclass];
+       classlist[textclass].load();
+       if (textclass < classlist.size())
+               return classlist[textclass];
        else
-               return &ar[0];
+               return classlist[0];
 }
 
 
-void LyXTextClassList::Add (LyXTextClass *t)
+void LyXTextClassList::Add(LyXTextClass const & t)
 {
-       LyXTextClassL ** h = &l;
-       string const desc = t->description;
-       while (*h && compare_no_case((*h)->textclass->description, desc) < 0)
-               h = &((*h)->next);
-       LyXTextClassL * tmp = new LyXTextClassL;
-       tmp->textclass = t;
-       tmp->next = *h;
-       *h = tmp;
-       num_textclass++;
+       classlist.push_back(t);
 }
 
 
-void LyXTextClassList::ToAr ()
-{
-       LyXTextClassL * lp, *op;
-       int idx = 0;
-       ar = new LyXTextClass [num_textclass];
-       lp = l;
-       while (lp) {
-               ar[idx].Copy (*lp->textclass);
-               idx++;
-               delete lp->textclass; // note we don't delete layouts
-                                     // here at all 
-               op = lp;
-               lp = lp->next;
-               delete op;
+// used when sorting the textclass list.
+class less_textclass_desc {
+public:
+       int operator()(LyXTextClass const & tc1, LyXTextClass const & tc2) {
+               return tc1.description() < tc2.description();
        }
-}
+};
 
 
 // Reads LyX textclass definitions according to textclass config file
@@ -1305,8 +1104,6 @@ bool LyXTextClassList::Read ()
        }
        bool finished = false;
        string fname, clname, desc;
-       LyXTextClass * tmpl;
-
        // Parse config-file
        while (lex.IsOK() && !finished) {
                switch (lex.lex()) {
@@ -1326,45 +1123,47 @@ bool LyXTextClassList::Read ()
                                                      << "Desc: " << desc << endl;
                                              // This code is run when we have
                                              // fname, clname and desc
-                                             tmpl =new LyXTextClass(fname,
-                                                                    clname,
-                                                                    desc);
-                                             Add (tmpl);
+                                             LyXTextClass tmpl(fname,
+                                                               clname,
+                                                               desc);
                                              if (lyxerr.
                                                  debugging(Debug::TCLASS)) {
-                                                   tmpl->load();
+                                                     tmpl.load();
                                              }
+                                             Add (tmpl);
                                }
                        }
                }
        }
        
-       if (num_textclass == 0) {
-               lyxerr << "LyXTextClassList::Read: no textclass found!" << endl;
+       if (classlist.size() == 0) {
+               lyxerr << "LyXTextClassList::Read: no textclass found!"
+                      << endl;
                WriteAlert(_("LyX wasn't able to find any layout description!"),
                           _("Check the contents of  the file \"textclass.lst\""),
                           _("Sorry, has to exit :-("));
                return false;
        }
-       else { 
-               ToAr();
-               return true;
-       }
+       // Ok everything loaded ok, now sort the list.
+       sort(classlist.begin(), classlist.end(), less_textclass_desc());
+       return true;
 }
 
-// Load textclass
-/* Returns false if this fails */
-bool LyXTextClassList::Load (char const number)
-{
-       bool result = 1;
        
-       if (number < num_textclass) {
-               ar[number].load();
-               if (!ar[number].number_of_defined_layouts) {
-                       result = 0;
+/* Load textclass
+   Returns false if this fails
+*/
+bool
+LyXTextClassList::Load (LyXTextClassList::ClassList::size_type number) const
+{
+       bool result = true;
+       if (number < classlist.size()) {
+               classlist[number].load();
+               if (classlist[number].numLayouts() == 0) {
+                       result = false;
                }
        } else {
-               result = 0;
+               result = false;
        }
        return result;
 }
index 0c18294c2f7753022444a0984595e12749cf6a56..96231b143c3515dded30564af5e722619fb3a97a 100644 (file)
@@ -1,27 +1,30 @@
 // -*- C++ -*-
 /* This file is part of
  * ======================================================
-* 
-*           LyX, The Document Processor
-*       
-*          Copyright (C) 1995 Matthias Ettrich
-*
-*======================================================*/
+ * 
+ *           LyX, The Document Processor
+ *      
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-1999 The LyX Team.
+ *
+ * ====================================================== */
 
-#ifndef _LAYOUT_H
-#define _LAYOUT_H
+#ifndef LAYOUT_H
+#define LAYOUT_H
 
 #ifdef __GNUG__
 #pragma interface
 #endif
 
+#include <vector>
+
 #include "definitions.h"
 #include "lyxlex.h"
 #include "lyxfont.h"
 #include "Spacing.h"
 
 /// Reads the style files
-void LyXSetStyle();
+extern void LyXSetStyle();
 
 /// The different output types
 enum OutputType {
@@ -50,7 +53,9 @@ enum LYX_MARGIN_TYPE {
 };
 
 ///
-enum LYX_ALIGNMENT {
+enum LyXAlignment {
+       ///
+       LYX_ALIGN_NONE = 0,
        ///
        LYX_ALIGN_BLOCK = 1,
        ///
@@ -64,6 +69,9 @@ enum LYX_ALIGNMENT {
        ///
         LYX_ALIGN_SPECIAL = 32
 };
+inline void operator|=(LyXAlignment & la1, LyXAlignment la2) {
+       la1 = static_cast<LyXAlignment>(la1 | la2);
+}
 
 /// The different LaTeX-Types
 enum LYX_LATEX_TYPES {
@@ -123,25 +131,28 @@ enum LYX_LABEL_TYPES {
 
 
 /* Fix labels are printed flushright, manual labels flushleft. 
-* MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
-* MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL. 
-* This seems a funny restriction, but I think other combinations are
-* not needed, so I will not change it yet. 
-* Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC */
+ * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
+ * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL. 
+ * This seems a funny restriction, but I think other combinations are
+ * not needed, so I will not change it yet. 
+ * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
+ */
 
 
 /* There is a parindent and a parskip. Which one is used depends on the 
-* paragraph_separation-flag of the text-object. 
-* BUT: parindent is only thrown away, if a parskip is defined! So if you
-* want a space between the paragraphs and a parindent at the same time, 
-* you should set parskip to zero and use topsep, parsep and bottomsep.
-* 
-* The standard layout is an exception: its parindent is only set, if the 
-* previous paragraph is standard too. Well, this is LateX and it is good! */ 
+ * paragraph_separation-flag of the text-object. 
+ * BUT: parindent is only thrown away, if a parskip is defined! So if you
+ * want a space between the paragraphs and a parindent at the same time, 
+ * you should set parskip to zero and use topsep, parsep and bottomsep.
+ * 
+ * The standard layout is an exception: its parindent is only set, if the 
+ * previous paragraph is standard too. Well, this is LateX and it is good!
+ */ 
 
 
 /// Attributes of a layout/paragraph environment
-class LyXLayoutList;
+class LyXTextClass;
+
 ///
 class LyXLayout {
 public:
@@ -149,45 +160,41 @@ public:
        LyXLayout ();
 
        ///
-       ~LyXLayout ();
-
-       ///
-       void Copy (LyXLayout const &l);
-
-       ///
-       bool Read (LyXLex&, LyXLayoutList *);
-
-       /// Name of the layout/paragraph environment
-       string name;
-
-       /// Name of an layout that has replaced this layout. 
-       /** This is used to rename a layout, while keeping backward
-           compatibility 
-       */
-       string obsoleted_by;
-
-       /// Default font for this layout/environment
-       /** The main font for this kind of environment. If an attribute has
-       LyXFont::INHERITED_*, it means that the value is specified by
-       the defaultfont for the entire layout. If we are nested, the font 
-       is inherited from the font in the environment one level up until the 
-       font is resolved. The values LyXFont::IGNORE_* and LyXFont::TOGGLE 
-       are illegal here.
+       bool Read (LyXLex &, LyXTextClass const &);
+
+       string const & name() const { return name_; }
+       void name(string const & n) { name_ = n; }
+       string const & obsoleted_by() const { return obsoleted_by_; }
+       string const & latexname() const { return latexname_; }
+       string const & labelstring() const { return labelstring_; }
+       string const & preamble() const { return preamble_; }
+       string const & latexparam() const { return latexparam_; }
+       string const & labelstring_appendix() const { return labelstring_appendix_; }
+       /** Default font for this layout/environment.
+           The main font for this kind of environment. If an attribute has
+           LyXFont::INHERITED_*, it means that the value is specified by
+           the defaultfont for the entire layout. If we are nested, the
+           font is inherited from the font in the environment one level
+           up until the font is resolved. The values LyXFont::IGNORE_*
+           and LyXFont::TOGGLE are illegal here.
        */
        LyXFont font;
 
-       /// Default font for labels
-       /** Interpretation the same as for font above */
+       /** Default font for labels.
+           Interpretation the same as for font above
+       */
        LyXFont labelfont;
 
-       /// Resolved version of the font for this layout/environment
-       /** This is a resolved version the default font. The font is resolved
-       against the defaultfont of the entire layout. */
+       /** Resolved version of the font for this layout/environment.
+           This is a resolved version the default font. The font is resolved
+           against the defaultfont of the entire layout.
+       */
        LyXFont resfont;
 
-       /// Resolved version of the font used for labels
-       /** This is a resolved version the label font. The font is resolved
-       against the defaultfont of the entire layout. */
+       /** Resolved version of the font used for labels.
+           This is a resolved version the label font. The font is resolved
+           against the defaultfont of the entire layout.
+       */
        LyXFont reslabelfont;
 
        /// Text that dictates how wide the left margin is on the screen
@@ -202,24 +209,11 @@ public:
        /// Text that dictates how much space to leave before a potential label
        string labelindent;
 
-       /// Text that dictates the width of the indentation of indented paragraphs
+       /** Text that dictates the width of the indentation of
+           indented paragraphs.
+       */
        string parindent;
 
-       /// Label string. "Abstract", "Reference", "Caption"...
-       string labelstring;
-
-       /// Label string inside appendix. "Appendix", ...
-       string labelstring_appendix;
-
-       /// LaTeX name for environment
-       string latexname;
-
-       /// LaTeX parameter for environment
-        string latexparam;   //arrae970411
-
-        /// Macro definitions needed for this layout
-       string preamble;
-
        ///
        float parskip;
 
@@ -242,10 +236,10 @@ public:
        Spacing spacing;
 
        ///
-       char align; // add approp. signedness
+       LyXAlignment align; // add approp. signedness
 
        ///
-       char alignpossible; // add approp. signedness
+       LyXAlignment alignpossible; // add approp. signedness
 
        ///
        char labeltype; // add approp. signedness
@@ -290,192 +284,238 @@ public:
        LYX_LATEX_TYPES latextype;
        /// Does this object belong in the title part of the document?
        bool intitle;
+private:
+       /// Name of the layout/paragraph environment
+       string name_;
+
+       /** Name of an layout that has replaced this layout.
+           This is used to rename a layout, while keeping backward
+           compatibility 
+       */
+       string obsoleted_by_;
+
+       /// LaTeX name for environment
+       string latexname_;
+
+       /// Label string. "Abstract", "Reference", "Caption"...
+       string labelstring_;
+
+       /// Label string inside appendix. "Appendix", ...
+       string labelstring_appendix_;
+
+       /// LaTeX parameter for environment
+        string latexparam_;
+
+        /// Macro definitions needed for this layout
+       string preamble_;
 };
 
 
 ///
-class LyXLayoutList {
+class LyXTextClass {
 public:
        ///
-       LyXLayoutList();
+       typedef vector<LyXLayout> LayoutList;
+
+       ///
+       LyXTextClass (string const & = string(), 
+                     string const & = string(), 
+                     string const & = string());
+
+       ///
+       LayoutList::const_iterator begin() const { return layoutlist.begin(); }
        ///
-       ~LyXLayoutList();
+       LayoutList::const_iterator end() const { return layoutlist.end(); }
+       
        ///
-       void Add (LyXLayout *l);
+       bool Read(string const & filename, bool merge = false);
+
        ///
-       bool Delete (string const &name);
-        ///
-       LyXLayout *GetLayout (string const &name);
+       bool hasLayout(string const & name) const;
+
        ///
-       LyXLayout *ToAr();
+       LyXLayout const & GetLayout(string const & vname) const;
+
        ///
-       int GetNum();
+       LyXLayout & GetLayout(string const & vname);
+
+       /// Sees to that the textclass structure has been loaded
+       void load();
+
        ///
-       void Clean(); 
-private:
+       string const & name() const { return name_; }
        ///
-       struct LyXLayoutL {
-               ///
-               LyXLayout* layout;
-               ///
-               LyXLayoutL *next;
-       };
+       string const & latexname() const { return latexname_; }
        ///
-       LyXLayoutL * l;
+       string const & description() const { return description_; }
        ///
-       LyXLayoutL *eol;
+       string const & opt_fontsize() const { return opt_fontsize_; }
        ///
-       int num_layouts;
-};
-
+       string const & opt_pagestyle() const { return opt_pagestyle_; }
+       ///
+       string const & options() const { return options_; }
+       ///
+       string const & pagestyle() const { return pagestyle_; }
+       ///
+       string const & preamble() const { return preamble_; }
 
-///
-class LyXTextClass  {
-public:
+       /// Packages that are already loaded by the class
+       enum Provides {
+               nothing = 0,
+               amsmath = 1,
+               makeidx = 2,
+               url = 4
+       };
+       bool provides(Provides p) const { return provides_ & p; }
+       
        ///
-       LyXTextClass (string const & = string(), 
-                     string const & = string(), 
-                     string const & = string());
+       unsigned int columns() const { return columns_; }
+       ///
+       enum PageSides {
+               OneSide,
+               TwoSides
+       };
        ///
-       ~LyXTextClass();
+       PageSides sides() const { return sides_; }
+       ///
+       int secnumdepth() const { return secnumdepth_; }
+       ///
+       int tocdepth() const { return tocdepth_; }
 
-       /// Not a real copy, just reference!
-       void Copy (LyXTextClass const &l);
+        ///
+        OutputType outputType() const { return outputType_; }
 
-       /// Reads a textclass structure from file
-       int Read (string const & filename, LyXLayoutList *list = 0);
+       ///
+       LyXFont const & defaultfont() const { return defaultfont_; }
 
-       /// Sees to that the textclass structure has been loaded
-       void load();
+       /// Text that dictates how wide the left margin is on the screen
+       string const & leftmargin() const { return leftmargin_; }
 
+       /// Text that dictates how wide the right margin is on the screen
+       string const & rightmargin() const { return rightmargin_; }
+        ///
+       int maxcounter() const { return maxcounter_; }
        ///
-       string name;
+       LayoutList::size_type numLayouts() const { return layoutlist.size(); }
        ///
-       string latexname;
+       LyXLayout const & operator[](LayoutList::size_type i) const {
+               return layoutlist[i];
+       }
+private:
        ///
-       string description;
-        ///
-        OutputType output_type;
-
-       /// Specific class options
-        string opt_fontsize;
+       bool delete_layout(string const &);
        ///
-        string opt_pagestyle;
+       bool do_readStyle(LyXLex &, LyXLayout &);
        ///
-       string options;
-
-       /// Packages that are already loaded by the class
-       bool provides_amsmath;
+       string name_;
        ///
-       bool provides_makeidx;
-       /// 
-       bool provides_url;
-    
-       /// Base font. This one has to be fully instantiated.
-       /** Base font. The paragraph and layout fonts are resolved against
-       this font. Attributes LyXFont::INHERIT, LyXFont::IGNORE, and 
-       LyXFont::TOGGLE are extremely illegal.
-       */
-       LyXFont defaultfont;
-       /// Array of styles in this textclass
-       LyXLayout* style;
+       string latexname_;
        ///
-       unsigned char number_of_defined_layouts;
+       string description_;
+       /// Specific class options
+        string opt_fontsize_;
        ///
-       unsigned char columns;
+        string opt_pagestyle_;
        ///
-       unsigned char sides;
+       string options_;
        ///
-       signed char secnumdepth;
+       string pagestyle_;
        ///
-       signed char tocdepth;
+       string preamble_;
        ///
-       string pagestyle;
+       Provides provides_;
        ///
-       string preamble;
+       unsigned int columns_;
        ///
-       /// Text that dictates how wide the left margin is on the screen
-       string leftmargin;
+       PageSides sides_;
+       ///
+       int secnumdepth_;
+       ///
+       int tocdepth_;
         ///
+        OutputType outputType_;
+       /** Base font. The paragraph and layout fonts are resolved against
+           this font. This has to be fully instantiated. Attributes
+           LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
+           extremely illegal.
+       */
+       LyXFont defaultfont_;
+       /// Text that dictates how wide the left margin is on the screen
+       string leftmargin_;
+
        /// Text that dictates how wide the right margin is on the screen
-       string rightmargin;
+       string rightmargin_;
         ///
-       char maxcounter; // add approp. signedness
-private:
+       int maxcounter_; // add approp. signedness
+
+       ///
+       LayoutList layoutlist;
+
        /// Has this layout file been loaded yet?
        bool loaded;
 };
 
+///
+inline void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
+{
+       p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
+}
+
 
 ///
 class LyXTextClassList {
 public:
        ///
-       LyXTextClassList();
-
-       ///
-       ~LyXTextClassList();
-
+       typedef vector<LyXTextClass> ClassList;
        /// Gets layout structure from layout number and textclass number
-       LyXLayout *Style(char textclass, char layout);
+       LyXLayout const & Style(ClassList::size_type textclass,
+                               LyXTextClass::LayoutList::size_type layout) const;
 
        /// Gets layout number from textclass number and layout name
-       char NumberOfLayout(char textclass, string const & name); // add approp. signedness
+       pair<bool, LyXTextClass::LayoutList::size_type>
+       NumberOfLayout(ClassList::size_type textclass,
+                      string const & name) const;
 
        /// Gets a layout name from layout number and textclass number
-       string NameOfLayout(char textclass, char layout); // add approp. signedness
+       string const &
+       NameOfLayout(ClassList::size_type textclass,
+                    LyXTextClass::LayoutList::size_type layout) const;
 
-       /// Gets textclass number from name
-       /** Returns -1 if textclass name does not exist */
-       signed char NumberOfClass(string const & textclass);
+       /** Gets textclass number from name.
+           Returns -1 if textclass name does not exist
+       */
+       pair<bool, ClassList::size_type>
+       NumberOfClass(string const & textclass) const;
 
        ///
-       string NameOfClass(char number); // add approp. signedness
+       string const & NameOfClass(ClassList::size_type number) const;
 
        ///
-       string LatexnameOfClass(char number); // add approp. signedness
+       string const & LatexnameOfClass(ClassList::size_type number) const;
 
        ///
-       string DescOfClass(char number); // add approp. signedness
+       string const & DescOfClass(ClassList::size_type number) const;
 
        ///
-       LyXTextClass * TextClass(char textclass); // add approp. signedness
+       LyXTextClass const & TextClass(ClassList::size_type textclass) const;
 
-       /// Read textclass list
-       /** Returns false if this fails */
+       /** Read textclass list.
+           Returns false if this fails
+       */
        bool Read();
 
-       /// Load textclass
-       /** Returns false if this fails */
-       bool Load(const char number);
+       /** Load textclass.
+           Returns false if this fails
+       */
+       bool Load(ClassList::size_type number) const;
 private:
        ///
-       struct LyXTextClassL {
-               ///
-               LyXTextClass * textclass;
-               ///
-               LyXTextClassL * next;
-       };
-
-       ///
-       LyXTextClassL * l;
-
+       mutable ClassList classlist;
        ///
-       int num_textclass;
-
-       /// After reading, this arrays holds the textclasses
-       LyXTextClass * ar;
-
-       /// Add a textclass to list
-       void Add (LyXTextClass *l);
-
-       /// Convert final linked list to array
-       /** We read the textclasses into a linked list. After the reading,
-       the list is converted to an array, and the linked list is nuked. */
-       void ToAr();
+       void Add (LyXTextClass const &);
 };
 
 /// Should not be declared here!! (Lgb) Why not? (Asger)
-extern LyXTextClassList lyxstyle;
+extern LyXTextClassList textclasslist;
  
 #endif
index f3443ab3e51b562f929a39c45cd36d33e778c8fe..958ec4973ec1dec0cff968e9a9fdca54c713cc02 100644 (file)
@@ -58,6 +58,7 @@
 #include "lyxrc.h"
 #include "lyxtext.h"
 #include "gettext.h"
+#include "layout.h"
 
 extern MiniBuffer *minibuffer;
 extern Combox *combo_language;
@@ -425,30 +426,11 @@ void MenuWriteAs(Buffer *buffer)
        MenuWrite(buffer);
 }    
 
-#if 0
-extern bool gsworking();
-#endif
 
 int MenuRunLaTeX(Buffer *buffer)
 {
        int ret = 0;
 
-#if 0
-       if (gsworking()) {
-               WriteAlert(_("Sorry, can't do this while pictures are being rendered."),
-                          _("Please wait a few seconds for this to finish and try again."),
-                          _("(or kill runaway gs processes by hand and try again.)"));
-               return 1;
-       }
-       extern pid_t isp_pid; // from spellchecker.C
-       if(isp_pid != -1)
-       {
-         WriteAlert(_("Can't do this while the spellchecker is running."),
-           _("Stop the spellchecker first."));
-         return 1;
-       }
-#endif
-       
        if (buffer->isLinuxDoc())
                ret = RunLinuxDoc(1, buffer->getFileName());
        else if (buffer->isLiterate())
@@ -1130,8 +1112,12 @@ void InsertAsciiFile(string const & f, bool asParagraph)
        tmppar->readSimpleWholeFile(myfile);
        
        // set the end of the string
+#ifdef NEW_TEXT
+       // I don't think this is needed. Actually it might be plain wrong.
+       tmppar->InsertChar(tmppar->text.size() - 1,'\0');
+#else
        tmppar->InsertChar(tmppar->last-1,'\0');
-      
+#endif 
        // insert the string
        current_view->getScreen()->HideCursor();
       
@@ -1340,15 +1326,15 @@ int RunDocBook(int flag, string const & filename)
                return 0;
        
        current_view->currentBuffer()->makeDocBookFile(name,0);
-#if 0
-       string add_flags;
-       LYX_PAPER_SIZE ps = (LYX_PAPER_SIZE) current_view->currentBuffer()->params.papersize;
-       switch (ps) {
-       case PAPER_A4PAPER:  add_flags = "-p a4";     break;
-       case PAPER_USLETTER: add_flags = "-p letter"; break;
-       default: /* nothing to be done yet ;-) */     break; 
-       }
-#endif 
+
+       // Shall this code go or should it stay? (Lgb)
+//     string add_flags;
+//     LYX_PAPER_SIZE ps = (LYX_PAPER_SIZE) current_view->currentBuffer()->params.papersize;
+//     switch (ps) {
+//     case PAPER_A4PAPER:  add_flags = "-p a4";     break;
+//     case PAPER_USLETTER: add_flags = "-p letter"; break;
+//     default: /* nothing to be done yet ;-) */     break; 
+//     }
        ProhibitInput();
        
        Systemcalls one;
@@ -1568,8 +1554,8 @@ bool UpdateLayoutParagraph()
 
        int align = buf->text->cursor.par->GetAlign();
        if (align == LYX_ALIGN_LAYOUT)
-               align = lyxstyle.Style(buf->params.textclass,
-                                      buf->text->cursor.par->GetLayout())->align;
+               align = textclasslist.Style(buf->params.textclass,
+                                      buf->text->cursor.par->GetLayout()).align;
         
        switch (align) {
        case LYX_ALIGN_RIGHT:
@@ -1786,10 +1772,10 @@ bool UpdateLayoutDocument(BufferParams *params)
 
        if (params == 0)
                params = &current_view->currentBuffer()->params;
-       LyXTextClass *tclass = lyxstyle.TextClass(params->textclass);
+       LyXTextClass const & tclass = textclasslist.TextClass(params->textclass);
        
        fl_set_choice_text(fd_form_document->choice_class, 
-                          lyxstyle.DescOfClass(params->textclass).c_str());
+                          textclasslist.DescOfClass(params->textclass).c_str());
        combo_language->select_text(params->language.c_str());
        
        fl_set_choice_text(fd_form_document->choice_fonts, 
@@ -1803,18 +1789,18 @@ bool UpdateLayoutDocument(BufferParams *params)
        fl_clear_choice(fd_form_document->choice_fontsize);
        fl_addto_choice(fd_form_document->choice_fontsize, "default");
        fl_addto_choice(fd_form_document->choice_fontsize, 
-                       tclass->opt_fontsize.c_str());
+                       tclass.opt_fontsize().c_str());
        fl_set_choice(fd_form_document->choice_fontsize, 
-                     tokenPos(tclass->opt_fontsize, '|', params->fontsize) + 2);
+                     tokenPos(tclass.opt_fontsize(), '|', params->fontsize) + 2);
 
        // ale970405+lasgoutt970513
        fl_clear_choice(fd_form_document->choice_pagestyle);
        fl_addto_choice(fd_form_document->choice_pagestyle, "default");
        fl_addto_choice(fd_form_document->choice_pagestyle, 
-                       tclass->opt_pagestyle.c_str());
+                       tclass.opt_pagestyle().c_str());
     
        fl_set_choice(fd_form_document->choice_pagestyle,
-                     tokenPos(tclass->opt_pagestyle, '|', params->pagestyle) + 2);
+                     tokenPos(tclass.opt_pagestyle(), '|', params->pagestyle) + 2);
 
        fl_set_button(fd_form_document->radio_indent, 0);
        fl_set_button(fd_form_document->radio_skip, 0);
@@ -2301,8 +2287,8 @@ string CurrentState()
                // font. (Asger)
                Buffer * buffer = current_view->currentBuffer();
                LyXFont font = buffer->text->real_current_font;
-               LyXFont defaultfont = lyxstyle.TextClass(buffer->
-                                                        params.textclass)->defaultfont;
+               LyXFont defaultfont = textclasslist.TextClass(buffer->
+                                                        params.textclass).defaultfont();
                font.reduce(defaultfont);
                state = _("Font: ") + font.stateText();
 
@@ -2650,10 +2636,8 @@ extern "C" void ParagraphApplyCB(FL_OBJECT *, long)
        if (!current_view->available())
                return;
        
-       bool line_top, line_bottom;
-       bool pagebreak_top, pagebreak_bottom;
        VSpace space_top, space_bottom;
-       char align;
+       LyXAlignment align;
        string labelwidthstring;
        bool noindent;
 
@@ -2668,10 +2652,10 @@ extern "C" void ParagraphApplyCB(FL_OBJECT *, long)
                fl_set_choice (fd_form_paragraph->choice_space_below, 1);
        }
    
-       line_top = fl_get_button(fd_form_paragraph->check_lines_top);
-       line_bottom = fl_get_button(fd_form_paragraph->check_lines_bottom);
-       pagebreak_top = fl_get_button(fd_form_paragraph->check_pagebreaks_top);
-       pagebreak_bottom = fl_get_button(fd_form_paragraph->check_pagebreaks_bottom);
+       bool line_top = fl_get_button(fd_form_paragraph->check_lines_top);
+       bool line_bottom = fl_get_button(fd_form_paragraph->check_lines_bottom);
+       bool pagebreak_top = fl_get_button(fd_form_paragraph->check_pagebreaks_top);
+       bool pagebreak_bottom = fl_get_button(fd_form_paragraph->check_pagebreaks_bottom);
        switch (fl_get_choice (fd_form_paragraph->choice_space_above)) {
        case 1: space_top = VSpace(VSpace::NONE); break;
        case 2: space_top = VSpace(VSpace::DEFSKIP); break;
@@ -2786,7 +2770,7 @@ void UpdateDocumentButtons(BufferParams const &params)
 extern "C" void ChoiceClassCB(FL_OBJECT *ob, long)
 {
        ProhibitInput();
-       if (lyxstyle.Load(fl_get_choice(ob)-1)) {
+       if (textclasslist.Load(fl_get_choice(ob)-1)) {
                if (AskQuestion(_("Should I set some parameters to"),
                                fl_get_choice_text(ob),
                                _("the defaults of this document class?"))) {
@@ -2894,10 +2878,10 @@ extern "C" void DocumentApplyCB(FL_OBJECT *, long)
        if (!current_view->available())
                return;
 
-       char new_class = fl_get_choice(fd_form_document->choice_class) - 1;
+       LyXTextClassList::ClassList::size_type new_class = fl_get_choice(fd_form_document->choice_class) - 1;
        if (params->textclass != new_class) {
                // try to load new_class
-               if (lyxstyle.Load(new_class)) {
+               if (textclasslist.Load(new_class)) {
                        // successfully loaded
                        redo = true;
                        minibuffer->Set(_("Converting document to new document class..."));
@@ -2959,9 +2943,9 @@ extern "C" void DocumentApplyCB(FL_OBJECT *, long)
        else
                params->columns = 1;
        if (fl_get_button(fd_form_document->radio_sides_two))
-               params->sides = 2;
+               params->sides = LyXTextClass::TwoSides;
        else
-               params->sides = 1;
+               params->sides = LyXTextClass::OneSide;
 
        Spacing tmpSpacing = params->spacing;
        switch(fl_get_choice(fd_form_document->choice_spacing)) {
@@ -2986,14 +2970,14 @@ extern "C" void DocumentApplyCB(FL_OBJECT *, long)
        if (tmpSpacing != params->spacing)
                redo = true;
        
-       signed char tmpchar = (signed char) 
-               fl_get_counter_value(fd_form_document->slider_secnumdepth);;
+       signed char tmpchar =  
+               static_cast<signed char>(fl_get_counter_value(fd_form_document->slider_secnumdepth));
        if (params->secnumdepth != tmpchar)
                redo = true;
        params->secnumdepth = tmpchar;
    
-       params->tocdepth = (signed char) 
-               fl_get_counter_value(fd_form_document->slider_tocdepth);;
+       params->tocdepth =  
+               static_cast<int>(fl_get_counter_value(fd_form_document->slider_tocdepth));
 
        params->float_placement =
                fl_get_input(fd_form_document->input_float_placement);
@@ -3721,8 +3705,8 @@ extern "C" void TocCancelCB(FL_OBJECT *, long)
 
 extern "C" void TocUpdateCB(FL_OBJECT *, long)
 {
-       static LyXParagraph* stapar = 0;
-       TocList *tmptoclist = 0;
+       static LyXParagraph * stapar = 0;
+       TocList * tmptoclist = 0;
    
        /* deleted the toclist */ 
        if (toclist){
@@ -3743,10 +3727,9 @@ extern "C" void TocUpdateCB(FL_OBJECT *, long)
        }
        fl_hide_object(fd_form_toc->browser_toc);
        /* get the table of contents */ 
-       LyXParagraph *par = current_view->currentBuffer()->paragraph;
+       LyXParagraph * par = current_view->currentBuffer()->paragraph;
        char labeltype;
-       char* line = new char[200];
-       //int i = 0;
+       char * line = new char[200];
        int pos = 0;
        unsigned char c;
        int topline = 0;
@@ -3756,8 +3739,8 @@ extern "C" void TocUpdateCB(FL_OBJECT *, long)
        stapar = par;
    
        while (par) {
-               labeltype = lyxstyle.Style(current_view->currentBuffer()->params.textclass, 
-                                          par->GetLayout())->labeltype;
+               labeltype = textclasslist.Style(current_view->currentBuffer()->params.textclass, 
+                                          par->GetLayout()).labeltype;
       
                if (labeltype >= LABEL_COUNTER_CHAPTER
                    && labeltype <= LABEL_COUNTER_CHAPTER +
@@ -3767,13 +3750,12 @@ extern "C" void TocUpdateCB(FL_OBJECT *, long)
                        
                        for (pos=0; 
                             pos < (labeltype - 
-                                   lyxstyle.TextClass(current_view->currentBuffer()->
-                                                      params.textclass)->maxcounter) * 4 + 2;
+                                   textclasslist.TextClass(current_view->currentBuffer()->
+                                                      params.textclass).maxcounter()) * 4 + 2;
                             pos++)
                                line[pos] = ' ';
                        
                        // Then the labestring
-                       //i = 0;
                        if (!par->labelstring.empty()) {
                                string::size_type i = 0;
                                while (pos < 199 && i < par->labelstring.length()) {
@@ -3786,11 +3768,16 @@ extern "C" void TocUpdateCB(FL_OBJECT *, long)
                        line[pos] = ' ';
                        pos++;
                        
-                       /* now the contents */ 
+                       /* now the contents */
+#ifdef NEW_TEXT
+                       LyXParagraph::size_type i = 0;
+                       while (pos < 199 && i < par->size()) {
+#else
                        int i = 0;
                        while (pos < 199 && i < par->last) {
+#endif
                                c = par->GetChar(i);
-                               if (isprint((unsigned char) c) || c >= 128) {
+                               if (isprint(c) || c >= 128) {
                                        line[pos] = c;
                                        pos++;
                                }
index 0260d6d28268d68f4cc8e6a194620435976c01d8..4df85410b499eec7d91a3e6a9d398ffe0487bbc4 100644 (file)
@@ -49,9 +49,6 @@ extern FD_form_sendto * fd_form_sendto;
 extern FD_form_figure * fd_form_figure;
 extern FD_form_toc * fd_form_toc;
 extern FD_form_ref * fd_form_ref;
-#if 0
-extern FD_form_url * fd_form_url;
-#endif
 extern FD_form_paragraph_extra * fd_form_paragraph_extra;
 extern FD_LaTeXLog * fd_latex_log;
 extern FD_form_spell_check * fd_form_spell_check;
@@ -129,11 +126,6 @@ void CloseAllBufferRelatedPopups()
        if (fd_form_ref->form_ref->visible) {
                fl_hide_form(fd_form_ref->form_ref);
        }
-#if 0
-       if (fd_form_url->form_url->visible) {
-               fl_hide_form(fd_form_url->form_url);
-       }
-#endif
        if (fd_form_paper->form_paper->visible) {
                fl_hide_form(fd_form_paper->form_paper);
        }
index 53113e06d84c22302ca54f56d307c58f29c65656..fe94a10cea8d67f17294bfff3f7b6846e44e30ec 100644 (file)
@@ -3,8 +3,8 @@
  * 
  *           LyX, The Document Processor
  *      
- *         Copyright 1995 Matthias Ettrich
- *          Copyright 1995-1999 The LyX Team.
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-1999 The LyX Team.
  *
  * ======================================================*/
 
@@ -39,25 +39,21 @@ string user_lyxdir; // Default $HOME/.lyx
 // Should this be kept global? Asger says Yes.
 DebugStream lyxerr;
 
-LastFiles *lastfiles;
-LyXRC *lyxrc;
+LastFiles * lastfiles;
+LyXRC * lyxrc;
 
 // This is the global bufferlist object
 BufferList bufferlist;
 
-LyXServer *lyxserver = 0;
+LyXServer * lyxserver = 0;
 // this should be static, but I need it in buffer.C
 bool finished = false; // flag, that we are quitting the program
 
 // convenient to have it here.
-kb_keymap *toplevel_keymap;
+kb_keymap * toplevel_keymap;
 
-// from spellchecker.C
-#if 0
-extern void sigchldhandler(int sig);
-#endif
 
-LyX::LyX(int *argc, char *argv[])
+LyX::LyX(int * argc, char * argv[])
 {
        // Prevent crash with --help
        lyxGUI = 0;
@@ -95,7 +91,7 @@ LyX::LyX(int *argc, char *argv[])
        else if ((*argc)>2)
                lyxerr.debug() << "Opening documents..." << endl;
 
-       Buffer *last_loaded = 0;
+       Buffer * last_loaded = 0;
 
        for (int argi = (*argc) - 1; argi >= 1; argi--) {
                Buffer * loadb = bufferlist.loadLyXFile(argv[argi]);
@@ -146,14 +142,6 @@ void LyX::init(int */*argc*/, char **argv)
        signal(SIGINT, error_handler);
        signal(SIGTERM, error_handler);
 
-#if 0
-       // Install the SIGCHLD handler
-       act_.sa_handler = sigchldhandler;
-        //act_.sa_mask = SIGCHLD;
-        act_.sa_flags = 0;
-       //act_.sa_flags = SA_RESTART; //perhaps
-        sigaction(SIGCHLD, &act_, 0);
-#endif
        //
        // Determine path of binary
        //
@@ -478,10 +466,10 @@ void commandLineHelp()
 }
 
 
-bool LyX::easyParse(int *argc, char *argv[])
+bool LyX::easyParse(int * argc, char * argv[])
 {
        bool gui = true;
-       for(int i=1; i < *argc; i++) {
+       for(int i = 1; i < *argc; ++i) {
                string arg = argv[i];
                // Check for -dbg int
                if (arg == "-dbg") {
index 322dd38dc9375edd268cfaff51d5d01db2c73c87..12a25b08188b48681c53556e34a0a15a46fa57e3 100644 (file)
@@ -7,19 +7,26 @@
  *         Copyright (C) 1995 Matthias Ettrich
  *
  *======================================================*/
-#ifndef _LYXCURSOR_H
-#define _LYXCURSOR_H
 
-class LyXParagraph;
+#ifndef LYXCURSOR_H
+#define LYXCURSOR_H
+
+#include "lyxparagraph.h"
+
 struct Row;
 
 /** All these variavles should be explained. Matthias?
  */
 struct LyXCursor {
        ///
-       LyXParagraph *par;
+       LyXParagraph * par;
+#ifdef NEW_TEXT
+       ///
+       LyXParagraph::size_type pos;
+#else
        ///
        int pos;
+#endif
        ///
        int x;
        ///
@@ -27,7 +34,7 @@ struct LyXCursor {
        ///
        long y;
        ///
-       Row *row;
+       Row * row;
 };
 
 #endif
index d6ec93f0fc6cdb92f589d31daaab08d8762f1638..dbc815f96790278c1d2d45d8cd0e6783d633be83 100644 (file)
@@ -837,9 +837,9 @@ int LyXFont::ascent(char c) const
 {
        XFontStruct *finfo = getXFontstruct();
        if (finfo->per_char
-           && (unsigned int) c >= finfo->min_char_or_byte2
-           && (unsigned int) c <= finfo->max_char_or_byte2) {
-               unsigned int index = (unsigned int) c - finfo->min_char_or_byte2;
+           && c >= static_cast<char>(finfo->min_char_or_byte2)
+           && c <= static_cast<char>(finfo->max_char_or_byte2)) {
+               unsigned int index = c - finfo->min_char_or_byte2;
                return finfo->per_char[index].ascent;
        } else
                return finfo->ascent;
@@ -850,9 +850,9 @@ int LyXFont::descent(char c) const
 {
        XFontStruct *finfo = getXFontstruct();
        if (finfo->per_char
-           && (unsigned int) c >= finfo->min_char_or_byte2
-           && (unsigned int) c <= finfo->max_char_or_byte2) {
-               unsigned int index = (unsigned int) c - finfo->min_char_or_byte2;
+           && c >= static_cast<char>(finfo->min_char_or_byte2)
+           && c <= static_cast<char>(finfo->max_char_or_byte2)) {
+               unsigned int index = c - finfo->min_char_or_byte2;
                return finfo->per_char[index].descent;
        } else
                return finfo->descent;
@@ -884,8 +884,8 @@ int LyXFont::textWidth(char const *s, int n) const
                smallfont.setShape(LyXFont::UP_SHAPE);
                for (int i=0; i < n; i++){
                        c = s[i];
-                       if (islower((unsigned char) c)){
-                               c = toupper( (unsigned char) c );
+                       if (islower(c)){
+                               c = toupper(c);
                                result += XTextWidth(smallfont.getXFontstruct(), &c, 1);
                        } else {
                                result += XTextWidth(getXFontstruct(), &c, 1);
@@ -935,8 +935,8 @@ int LyXFont::drawText(char const* s, int n, Pixmap pm,
                smallfont.setShape(LyXFont::UP_SHAPE);
                for (i=0; i < n; i++){
                        c = s[i];
-                       if (islower((unsigned char) c)){
-                               c = toupper((unsigned char) c);
+                       if (islower(c)){
+                               c = toupper(c);
                                XDrawString(fl_display,
                                            pm,
                                            smallfont.getGC(),
index ee35ba89820594536181a8052c500dc860f860fa..233ac3cfbb44faf2b988da32438ed47f32417236 100644 (file)
@@ -67,30 +67,34 @@ bool IsLetterCharOrDigit(char ch)
 
 // Returns the current selection. If nothing is selected or if the selection
 // spans 2 paragraphs, an empty string is returned.
-string const GetCurrentSelectionAsString(LyXText *lt) 
+string const GetCurrentSelectionAsString(LyXText * lt) 
 {
-       LyXParagraph    *par;
-       int             pos;
-       int             endpos;
-       int             i;
        char            sz[LYXSEARCH_MAXLEN];
-       char            ch;
-       bool            fPrevIsSpace;
 
        sz[0] = 0;
-       par = lt->cursor.par;
+       LyXParagraph * par = lt->cursor.par;
        if (lt->selection && (lt->sel_cursor.par == par)) {
                // (selected) and (begin/end in same paragraph)
-               pos = lt->sel_start_cursor.pos;
-               endpos = lt->sel_end_cursor.pos;
-               i = 0;
-               fPrevIsSpace = false;
+#ifdef NEW_TEXT
+               LyXParagraph::size_type pos =
+                       lt->sel_start_cursor.pos;
+               LyXParagraph::size_type endpos =
+                       lt->sel_end_cursor.pos;
+#else
+               int pos =
+                       lt->sel_start_cursor.pos;
+               int endpos =
+                       lt->sel_end_cursor.pos;
+#endif
+               int i = 0;
+               bool fPrevIsSpace = false;
+               char ch;
                while ((i < LYXSEARCH_MAXLEN-2) && 
                        (pos < par->Last()) && (pos < endpos)) {
                        ch = par->GetChar(pos);
 
                        //HB??: Maybe (ch <= ' ') 
-                       if ((ch == ' ') || ((unsigned char)ch <= LYX_META_INSET)) {
+                       if ((ch == ' ') || (ch <= LYX_META_INSET)) {
                                // consecutive spaces --> 1 space char
                                if (fPrevIsSpace) {
                                        pos++;          // Next text pos
@@ -293,13 +297,14 @@ bool LyXFindReplace1::SearchCB(bool fForward)
 // if the string can be found: return true and set the cursor to
 // the new position 
 // (was: LyXText::SearchForward(char const* string) in text2.C )
-bool LyXFindReplace1::SearchForward(LyXText *lt)
+bool LyXFindReplace1::SearchForward(LyXText * lt)
 {
-       LyXParagraph *par;
-       int pos;
-
-       par = lt->cursor.par;
-       pos = lt->cursor.pos;
+       LyXParagraph * par = lt->cursor.par;
+#ifdef NEW_TEXT
+       LyXParagraph::size_type pos = lt->cursor.pos;
+#else
+       int pos = lt->cursor.pos;
+#endif
 
        while (par && !IsSearchStringInText(par,pos)) {
                if (pos<par->Last()-1)
@@ -356,48 +361,46 @@ int LyXFindReplace1::CompareChars(char chSearch, char chText)
 {
        if (CaseSensitive())
                return (chSearch - chText);
-       return (toupper((unsigned char) chSearch) - toupper((unsigned char) chText));
+       return (toupper(chSearch) - toupper(chText));
 }
 
 
 // returns true if the search string is at the specified position 
 // (Copied from the original "LyXText::IsStringInText" in text2.C )
-bool LyXFindReplace1::IsSearchStringInText(LyXParagraph *par, int pos)
+#ifdef NEW_TEXT
+bool LyXFindReplace1::IsSearchStringInText(LyXParagraph * par,
+                                          LyXParagraph::size_type pos)
+#else
+bool LyXFindReplace1::IsSearchStringInText(LyXParagraph * par,
+                                          int pos)
+#endif
 {
        char            chSrch = 0;
        char            chText;
-       bool            fPrevIsSpace;
-       int             iText;
-       string::size_type iSrch;
 
        if (!par) 
                return false;
 
-       fPrevIsSpace = false;
-       iText = 0; iSrch = 0;
-       while (pos+iText < par->Last() && 
+       bool fPrevIsSpace = false;
+       int iText = 0;
+       string::size_type iSrch = 0;
+       while (pos + iText < par->Last() && 
               iSrch < SearchString().length()) {
                chSrch = SearchString()[iSrch];
                chText = par->GetChar(pos+iText);
-// Why was this code there ??? Insets are *not* spaces!
-// It seems that there is some code here to handle multiple spaces. I
-// wonder why this is useful...  (JMarc)
-//             if ((chText == ' ') || 
-//                 ((unsigned char)chText <= LYX_META_INSET)) 
                if (chText == ' ') {
                        if (fPrevIsSpace) {
                                iText++;  // next Text pos
                                continue; // same search pos
                        }
-//                     chText = ' ';                           
                        fPrevIsSpace = true;
                } else
                        fPrevIsSpace = false;
                if (CompareChars(chSrch, chText) != 0)
                        break;
                
-               iSrch++;
-               iText++;
+               ++iSrch;
+               ++iText;
        }
 
        if (iSrch < SearchString().length())
@@ -405,7 +408,7 @@ bool LyXFindReplace1::IsSearchStringInText(LyXParagraph *par, int pos)
 
        if (!MatchWord() 
            || ((pos <= 0 || !IsLetterCharOrDigit(par->GetChar(pos-1)))
-               && (pos+iText >= par->Last() 
+               && (pos + iText >= par->Last() 
                    || !IsLetterCharOrDigit(par->GetChar(pos + iText))))) {
                iLenSelected = iText;
                return true;
index e4307b0c70f65bd0a3fa9eaa8f626232f0df7fac..f05a44aa4e2650b979fd06ffa1c4257ccf98037a 100644 (file)
@@ -7,8 +7,9 @@
 #endif
 
 #include FORMS_H_LOCATION
+#include "lyxparagraph.h"
+
 class  LyXText;
-class  LyXParagraph;
 
 /**
   LyXFindReplace1"
@@ -53,8 +54,12 @@ protected:
            \end{itemize}
        */
        int CompareChars(char chSearch, char chText);
-
+#ifdef NEW_TEXT
        /// returns true if the specified string is at the specified position 
-       bool IsSearchStringInText(LyXParagraph *par, int pos);
+       bool IsSearchStringInText(LyXParagraph * par, LyXParagraph::size_type pos);
+#else
+       /// returns true if the specified string is at the specified position 
+       bool IsSearchStringInText(LyXParagraph * par, int pos);
+#endif
 };
 #endif
index 4b4500199e4a88fea8014c3328c156d4c7a15ee0..11f52abe0037a60c27aa2573e57d9244c34f0592 100644 (file)
@@ -50,6 +50,7 @@
 #include "lyx_gui_misc.h"
 #include "support/filetools.h"
 #include "support/FileInfo.h"
+#include "support/LAssert.h"
 #include "lyxscreen.h"
 #include "debug.h"
 #include "lyxrc.h"
@@ -61,6 +62,7 @@
 #include "support/syscall.h"
 #include "support/lstrings.h"
 #include "support/path.h"
+#include "layout.h"
 
 extern bool cursor_follows_scrollbar;
 
@@ -68,12 +70,12 @@ extern void InsertAsciiFile(string const &, bool);
 extern void math_insert_symbol(char const*);
 extern Bool math_insert_greek(char const); // why "Bool"?
 extern BufferList bufferlist;
-extern LyXServer *lyxserver;
+extern LyXServer * lyxserver;
 extern short greek_kb_flag;
-extern FD_form_toc *fd_form_toc;
+extern FD_form_toc * fd_form_toc;
 extern bool selection_possible;
 
-extern kb_keymap *toplevel_keymap;
+extern kb_keymap * toplevel_keymap;
 
 extern void BeforeChange();
 extern void MenuWrite(Buffer*);
@@ -1074,7 +1076,7 @@ string LyXFunc::Dispatch(int ac,
 
                // Pretend we got the name instead.
                Dispatch(int(LFUN_LAYOUT), 
-                        lyxstyle.NameOfLayout(owner->currentBuffer()->
+                        textclasslist.NameOfLayout(owner->currentBuffer()->
                                               text->parameters->
                                               textclass,
                                               sel).c_str());
@@ -1090,11 +1092,11 @@ string LyXFunc::Dispatch(int ac,
                // and current buffer's textclass (number). */    
                int layoutno = -1;
                layoutno =
-                       lyxstyle.NumberOfLayout(owner->
+                       textclasslist.NumberOfLayout(owner->
                                                currentBuffer()->
                                                text->parameters->
                                                textclass,
-                                               argument);
+                                               argument).second;
 
                // see if we found the layout number:
                if (layoutno == -1) {
@@ -1201,7 +1203,7 @@ string LyXFunc::Dispatch(int ac,
        case LFUN_UPCASE_WORD:
                owner->currentBuffer()->update(-2);
                FreeUpdateTimer();
-               owner->currentBuffer()->text->ChangeWordCase(2);
+               owner->currentBuffer()->text->ChangeWordCase(LyXText::text_uppercase);
                owner->currentBuffer()->update(1);
                SetUpdateTimer();
                break;
@@ -1209,7 +1211,7 @@ string LyXFunc::Dispatch(int ac,
        case LFUN_LOWCASE_WORD:
                owner->currentBuffer()->update(-2);
                FreeUpdateTimer();
-               owner->currentBuffer()->text->ChangeWordCase(0);
+               owner->currentBuffer()->text->ChangeWordCase(LyXText::text_lowercase);
                owner->currentBuffer()->update(1);
                SetUpdateTimer();
                break;
@@ -1217,7 +1219,7 @@ string LyXFunc::Dispatch(int ac,
        case LFUN_CAPITALIZE_WORD:
                owner->currentBuffer()->update(-2);
                FreeUpdateTimer();
-               owner->currentBuffer()->text->ChangeWordCase(1);
+               owner->currentBuffer()->text->ChangeWordCase(LyXText::text_capitalization);
                owner->currentBuffer()->update(1);
                SetUpdateTimer();
                break;
@@ -1845,8 +1847,14 @@ string LyXFunc::Dispatch(int ac,
 
        case LFUN_CHARATCURSOR:
        {
+#ifdef NEW_TEXT
+               LyXParagraph::size_type pos =
+                 owner->currentBuffer()->text->cursor.pos;
+               if(pos < owner->currentBuffer()->text->cursor.par->size())
+#else
                int pos = owner->currentBuffer()->text->cursor.pos;
                if(pos < owner->currentBuffer()->text->cursor.par->last)
+#endif
                        dispatch_buffer = owner->currentBuffer()->text->
                                cursor.par->text[pos];
                else
@@ -2205,7 +2213,7 @@ string LyXFunc::Dispatch(int ac,
        case LFUN_INDEX_INSERT:
        case LFUN_INDEX_INSERT_LAST:
        {
-               InsetIndex *new_inset = new InsetIndex();
+               InsetIndex * new_inset = new InsetIndex();
                if (!argument.empty()) {
                        string lsarg(argument);
                        new_inset->setContents(lsarg);
@@ -2217,19 +2225,25 @@ string LyXFunc::Dispatch(int ac,
                  
                  // grab a word
 
-                 int lastpos =owner->currentBuffer()->text->cursor.pos-1;
-
+#ifdef NEW_TEXT
+                 LyXParagraph::size_type lastpos =
+                         owner->currentBuffer()->text->cursor.pos - 1;
+                 // If this can't happen, let's make sure that it really don't
+                 Assert(owner->currentBuffer()->text->cursor.pos - 1 >= 0);
+#else
+                 int lastpos =owner->currentBuffer()->text->cursor.pos - 1;
                  //this shouldn't happen, but let's be careful
                  if (lastpos < 0) lastpos=0;
-                 
+#endif
                  // get the current word
                  // note that this must be done before 
                  // inserting the inset, or the inset will break
                  // the word
-                 string curstring(owner->currentBuffer()->text->cursor.par->GetWord(lastpos));
+                 string curstring(owner->currentBuffer()
+                                  ->text->cursor.par->GetWord(lastpos));
 
                  //make the new inset and write the current word into it
-                 InsetIndex *new_inset = new InsetIndex();
+                 InsetIndex * new_inset = new InsetIndex();
 
                  new_inset->setContents(curstring);
 
@@ -2825,13 +2839,17 @@ void LyXFunc::CloseBuffer()
 }
 
 
-Inset* LyXFunc::getInsetByCode(Inset::Code code)
+Inset * LyXFunc::getInsetByCode(Inset::Code code)
 {
        bool found = false;
-       Inset* inset = 0;
+       Inset * inset = 0;
        LyXCursor cursor = owner->currentBuffer()->text->cursor;
+#ifdef NEW_TEXT
+       LyXParagraph::size_type pos = cursor.pos;
+#else
        int pos = cursor.pos;
-       LyXParagraph *par = cursor.par;
+#endif
+       LyXParagraph * par = cursor.par;
        
        while (par && !found) {
                while ((inset = par->ReturnNextInsetPointer(pos))){
index 1e8185ecfca7cbee19b0b986d9694126b090fcd9..6e74a4a211a80716b986d6bc122c64d69c590e1f 100644 (file)
@@ -4,10 +4,10 @@
  * 
  *           LyX, The Document Processor
  *      
- *         Copyright (C) 1995 Matthias Ettrich
- *          Copyright (C) 1995-1999 The LyX Team.
+ *         Copyright 1995 Matthias Ettrich
+ *          Copyright 1995-1999 The LyX Team.
  *
- *======================================================*/
+ * ====================================================== */
 
 #ifndef LYXPARAGRAPH_H
 #define LYXPARAGRAPH_H
 #pragma interface
 #endif
 
+#define NEW_TEXT 1
+#define NEW_TABLE 1
+
+#ifdef NEW_TABLE
+#include <list>
+#endif
+
+#ifdef NEW_TEXT
+//#include <vector>
+#include <deque>
+#endif
+
 #include "definitions.h"
 #include "insets/lyxinset.h"
 #include "table.h"
 #include "support/textutils.h"
 #include "vspace.h"
 #include "insets/insetbib.h"
+#include "layout.h"
 
 class BufferParams;
 class LyXBuffer;
-class LyXLayout;
 class TexRow;
 struct LaTeXFeatures;
 
 /// A LyXParagraph holds all text, attributes and insets in a text paragraph
 class LyXParagraph  {
 public:
-
        /// The footnoteflag
        enum footnote_flag {
                ///
@@ -64,18 +75,15 @@ public:
        ///
        LyXParagraph();
        /// this konstruktor inserts the new paragraph in a list
-       LyXParagraph(LyXParagraph *par);
+       LyXParagraph(LyXParagraph * par);
        /// the destruktors removes the new paragraph from the list
        ~LyXParagraph();
 
        ///
-       void writeFile(FILE*, BufferParams &, char, char);
-
-       // ///
-       //void writeLaTeX(FILE*, BufferParams &);
+       void writeFile(FILE *, BufferParams &, char, char);
 
        ///
-       void validate(LaTeXFeatures&);
+       void validate(LaTeXFeatures &);
        
        ///
        int GetID(){
@@ -85,17 +93,18 @@ public:
        void SetID(int id_arg){
                id = id_arg;
        }
-       
+
+#ifndef NEW_TEXT
        /** allocates more memory for the specified paragraph
          pos is needed to specify the paragraph correctly. Remember the
          closed footnotes
          */
        void Enlarge(int pos, int number);
-
        /** make the allocated memory fit to the needed size
          used to make a paragraph smaller
          */
        void FitSize();
+#endif
        
        ///
        void read();
@@ -104,38 +113,49 @@ public:
        void readSimpleWholeFile(FILE *);
 
        ///
-       LyXParagraph* TeXOnePar(string &file, TexRow &texrow,
-                               string &foot, TexRow &foot_texrow,
-                               int &foot_count);
+       LyXParagraph * TeXOnePar(string & file, TexRow & texrow,
+                               string & foot, TexRow & foot_texrow,
+                               int & foot_count);
 
        ///
-       LyXParagraph* TeXEnvironment(string &file, TexRow &texrow,
-                                    string &foot, TexRow &foot_texrow,
-                                    int &foot_count);
+       LyXParagraph * TeXEnvironment(string & file, TexRow & texrow,
+                                    string & foot, TexRow & foot_texrow,
+                                    int & foot_count);
        
        ///
-       LyXParagraph* Clone();
+       LyXParagraph * Clone();
        
        ///
-       bool HasSameLayout(LyXParagraph *par);
+       bool HasSameLayout(LyXParagraph * par);
        
        ///
-       void MakeSameLayout(LyXParagraph *par);
+       void MakeSameLayout(LyXParagraph * par);
 
        /// Is it the first par with same depth and layout?
        bool IsFirstInSequence() {
-               LyXParagraph *dhook = DepthHook(GetDepth());
+               LyXParagraph * dhook = DepthHook(GetDepth());
                return (dhook == this
                        || dhook->GetLayout() != GetLayout()
                        || dhook->GetDepth() != GetDepth());
        }
 
+
+#ifdef NEW_TEXT
+       ///
+       typedef deque<char> TextContainer;
+       typedef int size_type;
+       ///
+       TextContainer text;
+       ///
+       size_type size() const { return text.size(); }
+#else
+       ///
+       int last;
        ///
        int size;
-       
        ///
-       char *text;
-
+       char * text;
+#endif
        /// 
        VSpace added_space_top;
        
@@ -143,7 +163,7 @@ public:
        VSpace added_space_bottom;
        
        ///
-       signed char layout;
+       LyXTextClass::LayoutList::size_type layout;
        
        /**
          \begin{itemize}
@@ -172,7 +192,7 @@ public:
        bool pagebreak_bottom;
        
        ///
-       char align;
+       LyXAlignment align;
        
        ///
        char depth;
@@ -222,44 +242,49 @@ public:
        //@}
        
        ///
-       int last;
-       ///
-       LyXParagraph *next;
+       LyXParagraph * next;
        ///
-       LyXParagraph *previous;
+       LyXParagraph * previous;
 
        /* table stuff -- begin*/
        ///
-       LyXTable *table;
+       LyXTable * table;
        /* table stuff -- end*/
 
         /// 
-        InsetBibKey* bibkey;  // ale970302
+        InsetBibKey * bibkey;  // ale970302
 
        /** these function are able to hide closed footnotes
         */
-       LyXParagraph *Next();
+       LyXParagraph * Next();
        
        ///
-       LyXParagraph *Previous();
+       LyXParagraph * Previous();
 
        /** these function are able to hide open and closed footnotes
         */ 
-       LyXParagraph *NextAfterFootnote();
+       LyXParagraph * NextAfterFootnote();
        ///
-       LyXParagraph *PreviousBeforeFootnote();
+       LyXParagraph * PreviousBeforeFootnote();
        ///
-       LyXParagraph *LastPhysicalPar();
+       LyXParagraph * LastPhysicalPar();
        ///
-       LyXParagraph *FirstPhysicalPar();
-       
+       LyXParagraph * FirstPhysicalPar();
+
+#ifdef NEW_TEXT
        /// returns the physical paragraph
-       LyXParagraph *ParFromPos(int pos);
+       LyXParagraph * ParFromPos(size_type pos);
+       /// returns the position in the physical par
+       int PositionInParFromPos(size_type pos);
+#else
+       /// returns the physical paragraph
+       LyXParagraph * ParFromPos(int pos);
        /// returns the position in the physical par
        int PositionInParFromPos(int pos);
+#endif
 
        /// for the environments
-       LyXParagraph* DepthHook(int depth);
+       LyXParagraph * DepthHook(int depth);
        ///
        int BeginningOfMainBody();
        ///
@@ -268,46 +293,128 @@ public:
        /// the next two functions are for the manual labels
        string GetLabelWidthString();
        ///
-       void SetLabelWidthString(const string &s);
+       void SetLabelWidthString(string const & s);
        ///
-       int GetLayout();
+       LyXTextClass::LayoutList::size_type GetLayout();
        ///
        char GetAlign();
        ///
        char GetDepth();
        ///
-       void SetLayout(char new_layout);
+       void SetLayout(LyXTextClass::LayoutList::size_type new_layout);
        ///
-       void SetOnlyLayout(char new_layout);
+       void SetOnlyLayout(LyXTextClass::LayoutList::size_type new_layout);
        ///
        int GetFirstCounter(int i);
+#ifdef NEW_TEXT
        ///
-       int Last();
-       
-       /** This one resets all layout and dtp switches but not the font
-        of the single characters
+       size_type Last();
+       ///
+       void Erase(size_type pos);
+       /** the flag determines wether the layout should be copied
         */ 
-       void Clear();
+       void BreakParagraph(size_type pos, int flag);
+       ///
+       void BreakParagraphConservative(size_type pos);
+       /** Get unistantiated font setting. Returns the difference
+         between the characters font and the layoutfont.
+         This is what is stored in the fonttable
+        */
+       LyXFont GetFontSettings(size_type pos);
+       /** Get fully instantiated font. If pos == -1, use the layout
+         font attached to this paragraph.
+         If pos == -2, use the label font of the layout attached here.
+         In all cases, the font is instantiated, i.e. does not have any
+         attributes with values LyXFont::INHERIT, LyXFont::IGNORE or 
+         LyXFont::TOGGLE.
+         */
+       LyXFont getFont(size_type pos);
+       ///
+       char GetChar(size_type pos);
+       ///
+       void SetFont(size_type pos, LyXFont const & font);
+       ///
+        string GetWord(size_type &);
+       /// Returns the height of the highest font in range
+       LyXFont::FONT_SIZE HighestFontInRange(size_type startpos, size_type endpos) const;
+       ///
+       void InsertChar(size_type pos, char c);
+       ///
+       void InsertInset(size_type pos, Inset * inset);
+       ///
+       Inset * GetInset(size_type pos);
+       ///
+       Inset * ReturnNextInsetPointer(size_type & pos);
+       ///
+       void OpenFootnote(size_type pos);
+       ///
+       void CloseFootnote(size_type pos);
+       /// important for cut and paste
+       void CopyIntoMinibuffer(size_type pos);
+       ///
+       void CutIntoMinibuffer(size_type pos);
+       ///
+       void InsertFromMinibuffer(size_type pos);
+       ///
+       bool IsHfill(size_type pos) {
+               return IsHfillChar(GetChar(pos));
+       }
+       
+       ///
+       bool IsInset(size_type pos) {
+               return IsInsetChar(GetChar(pos));
+       }
+       
+       ///
+       bool IsFloat(size_type pos) {
+               return IsFloatChar(GetChar(pos));
+       }
+       
+       ///
+       bool IsNewline(size_type pos) {
+               bool tmp = false;
+               if (pos >= 0)
+                       tmp= IsNewlineChar(GetChar(pos));
+               return tmp;
+       }
+       
+       ///
+       bool IsSeparator(size_type pos) {
+               return IsSeparatorChar(GetChar(pos));
+       }
+       
+       ///
+       bool IsLineSeparator(size_type pos) {
+               return IsLineSeparatorChar(GetChar(pos));
+       }
+       
+       ///
+       bool IsKomma(size_type pos){
+               return IsKommaChar(GetChar(pos));
+       }
+       
+       /// Used by the spellchecker
+       bool IsLetter(size_type pos);
+       
+       /// 
+       bool IsWord(size_type pos ) {
+         return IsWordChar( GetChar(pos) ) ;
+       }
+#else
+       ///
+       int Last();
        ///
        void Erase(int pos);
-
        /** the flag determines wether the layout should be copied
         */ 
        void BreakParagraph(int pos, int flag);
        ///
        void BreakParagraphConservative(int pos);
-
-       /** paste this paragraph with the next one
-         be carefull, this doesent make any check at all
-         */ 
-       void PasteParagraph();
-
        /** Get unistantiated font setting. Returns the difference
          between the characters font and the layoutfont.
          This is what is stored in the fonttable
-        */ 
+        */
        LyXFont GetFontSettings(int pos);
-       
        /** Get fully instantiated font. If pos == -1, use the layout
          font attached to this paragraph.
          If pos == -2, use the label font of the layout attached here.
@@ -316,50 +423,32 @@ public:
          LyXFont::TOGGLE.
          */
        LyXFont getFont(int pos);
-       
        ///
        char GetChar(int pos);
        ///
-        string GetWord(int &);
-       ///
        void SetFont(int pos, LyXFont const & font);
+       ///
+        string GetWord(int &);
        /// Returns the height of the highest font in range
        LyXFont::FONT_SIZE HighestFontInRange(int startpos, int endpos) const;
        ///
        void InsertChar(int pos, char c);
        ///
-       void InsertInset(int pos, Inset *inset);
+       void InsertInset(int pos, Inset * inset);
        ///
-       Inset* GetInset(int pos);
-       
-       /// used to remove the error messages
-       int AutoDeleteInsets();
-
+       Inset * GetInset(int pos);
        ///
-       Inset* ReturnNextInsetPointer(int &pos);
-       
-       /// returns -1 if inset not found
-       int GetPositionOfInset(Inset* inset);
-       
-       /// ok and now some footnote functions
-       void OpenFootnotes();
+       Inset * ReturnNextInsetPointer(int & pos);
        ///
        void OpenFootnote(int pos);
        ///
-       void CloseFootnotes();
-       ///
        void CloseFootnote(int pos);
-   
        /// important for cut and paste
        void CopyIntoMinibuffer(int pos);
        ///
        void CutIntoMinibuffer(int pos);
        ///
        void InsertFromMinibuffer(int pos);
-       
-       ///
-       LyXParagraph *FirstSelfrowPar();
-       
        ///
        bool IsHfill(int pos) {
                return IsHfillChar(GetChar(pos));
@@ -377,8 +466,8 @@ public:
        
        ///
        bool IsNewline(int pos) {
-               bool tmp=false;
-               if (pos>=0)
+               bool tmp = false;
+               if (pos >= 0)
                        tmp= IsNewlineChar(GetChar(pos));
                return tmp;
        }
@@ -405,10 +494,35 @@ public:
        bool IsWord( int pos ) {
          return IsWordChar( GetChar(pos) ) ;
        }
+#endif
+       /** This one resets all layout and dtp switches but not the font
+        of the single characters
+        */ 
+       void Clear();
+
+       /** paste this paragraph with the next one
+         be carefull, this doesent make any check at all
+         */ 
+       void PasteParagraph();
+
+       /// used to remove the error messages
+       int AutoDeleteInsets();
+
+       /// returns -1 if inset not found
+       int GetPositionOfInset(Inset * inset);
+       
+       /// ok and now some footnote functions
+       void OpenFootnotes();
+
+       ///
+       void CloseFootnotes();
+   
+       ///
+       LyXParagraph * FirstSelfrowPar();
 
        ///
        int ClearParagraph(){
-               int i=0;
+               int i = 0;
                if (!IsDummy() && !table){
                        while (Last()
                               && (IsNewline(0) 
@@ -434,19 +548,29 @@ public:
         /* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
            I have to set it on each of it's elements */
        ///
-        void SetPExtraType(int type, const char *width, const char *widthp);
+        void SetPExtraType(int type, char const * width, char const * widthp);
        ///
         void UnsetPExtraType();
+#ifdef NEW_TEXT
+       ///
+       bool RoffContTableRows(FILE * file, size_type i,
+                              int actcell);
+       ///
+       void DocBookContTableRows(string & file, string & extra, int & desc_on,
+                                 size_type i,
+                                 int current_cell_number, int & column);
+#else
        ///
-       bool RoffContTableRows(FILE *file, int i, int actcell);
+       bool RoffContTableRows(FILE * file, int i, int actcell);
        ///
-       bool linuxDocConvertChar(char c, string &sgml_string);
+       void DocBookContTableRows(string & file, string & extra, int & desc_on,
+                                 int i, int current_cell_number, int & column);
+#endif
        ///
-       void SimpleDocBookOneTablePar(string &file, string &extra,
-                                     int &desc_on, int depth);
+       bool linuxDocConvertChar(char c, string & sgml_string);
        ///
-       void DocBookContTableRows(string &file, string &extra, int &desc_on,
-                                 int i, int current_cell_number, int &column);
+       void SimpleDocBookOneTablePar(string & file, string & extra,
+                                     int & desc_on, int depth);
 private:
        /** A font entry covers a range of positions. Notice that the
          entries in the list are inserted in random order.
@@ -455,11 +579,17 @@ private:
          is limited. (Asger)
        */
        struct FontTable  {
+#ifdef NEW_TEXT
+               /// Start position of paragraph this font attribute covers
+               size_type pos;
+               /// Ending position of paragraph this font attribute covers
+               size_type pos_end;
+#else
                /// Start position of paragraph this font attribute covers
                int pos;
                /// Ending position of paragraph this font attribute covers
                int pos_end;
-
+#endif
                /** Font. Interpretation of the font values:
                If a value is LyXFont::INHERIT_*, it means that the font 
                attribute is inherited from either the layout of this
@@ -470,47 +600,86 @@ private:
                allowed in these font tables.
                */
                LyXFont font;
+#ifndef NEW_TABLE
                /// Pointer to next font entry
-               FontTable *next;
+               FontTable * next;
+#endif
        };
        ///
        struct InsetTable {
+#ifdef NEW_TEXT
+               ///
+               size_type pos;
+#else
                ///
                int pos;
+#endif
                ///
-               Inset *inset;
+               Inset * inset;
+#ifndef NEW_TABLE
                ///
-               InsetTable *next;
+               InsetTable * next;
+#endif
        };
+#ifdef NEW_TABLE
+       ///
+       typedef list<FontTable> FontList;
+       ///
+       typedef list<InsetTable> InsetList;
+       ///
+       FontList fontlist;
+       ///
+       InsetList insetlist;
+#else
        ///
-       FontTable *fonttable;
+       FontTable * fonttable;
        ///
-       InsetTable *insettable;
+       InsetTable * insettable;
+#endif
+       ///
+       LyXParagraph * TeXDeeper(string & file, TexRow & texrow,
+                                  string & foot, TexRow & foot_texrow,
+                                  int & foot_count);
+       ///
+       LyXParagraph * TeXFootnote(string & file, TexRow & texrow,
+                                  string & foot, TexRow & foot_texrow,
+                                  int & foot_count);
        ///
-       LyXParagraph * TeXDeeper(string &file, TexRow &texrow,
-                                  string &foot, TexRow &foot_texrow,
-                                  int &foot_count);
+       bool SimpleTeXOnePar(string & file, TexRow & texrow);
        ///
-       LyXParagraph * TeXFootnote(string &file, TexRow &texrow,
-                                  string &foot, TexRow &foot_texrow,
-                                  int &foot_count);
+       bool SimpleTeXOneTablePar(string & file, TexRow & texrow);
+#ifdef NEW_TEXT
        ///
-       bool SimpleTeXOnePar(string &file, TexRow &texrow);
+       bool TeXContTableRows(string & file, size_type i,
+                             int current_cell_number,
+                              int & column, TexRow & texrow);
        ///
-       bool SimpleTeXOneTablePar(string &file, TexRow &texrow);
+       void SimpleTeXBlanks(string & file, TexRow & texrow,
+                            size_type const i,
+                            int & column, LyXFont const & font,
+                            LyXLayout const & style);
        ///
-       bool TeXContTableRows(string &file, int i, int current_cell_number,
-                              int &column, TexRow &texrow);
+       void SimpleTeXSpecialChars(string & file, TexRow & texrow,
+                                  LyXFont & font, LyXFont & running_font,
+                                  LyXFont & basefont, bool & open_font,
+                                  LyXLayout const & style,
+                                  size_type & i,
+                                  int & column, char const c);
+#else
        ///
-       void SimpleTeXBlanks(string &file, TexRow &texrow,
-                            int const i, int &column, LyXFont const &font,
-                            LyXLayout const * const style);
+       bool TeXContTableRows(string & file, int i, int current_cell_number,
+                              int & column, TexRow & texrow);
        ///
-       void SimpleTeXSpecialChars(string &file, TexRow &texrow,
-                                  LyXFont &font, LyXFont &running_font,
-                                  LyXFont &basefont, bool &open_font,
-                                  LyXLayout const * const style,
-                                  int &i, int &column, char const c);
+       void SimpleTeXBlanks(string & file, TexRow & texrow,
+                            int const i, int & column, LyXFont const & font,
+                            LyXLayout const & style);
+       ///
+       void SimpleTeXSpecialChars(string & file, TexRow & texrow,
+                                  LyXFont & font, LyXFont & running_font,
+                                  LyXFont & basefont, bool & open_font,
+                                  LyXLayout const & style,
+                                  int & i, int & column, char const c);
+#endif
        ///
        int id;
        ///
index 5761c35fc94ab9617d5addeb879261b1d76b8677..520fcc6f42ae538ee5784315bebe56dcd234d687 100644 (file)
@@ -299,11 +299,7 @@ LyXRC::LyXRC()
 }
 
 
-LyXRC::~LyXRC()
-{
-}
-
-int LyXRC::ReadBindFile(string name)
+int LyXRC::ReadBindFile(string const & name)
 {
        hasBindFile = true;
        string tmp = i18nLibFileSearch("bind",name,"bind");
index df5e4b5f373251884f3e84931df2168294c0f1ab..6b2a89ec43118976b196d2c1452699b788f49945 100644 (file)
@@ -24,15 +24,13 @@ public:
        ///
        LyXRC();
        ///
-       ~LyXRC();
-       ///
        int Read (string const & filename);
        ///
         void Print();
        /// Is a bind file already (or currently) read?
        bool hasBindFile;
        ///
-       int ReadBindFile(string name = "cua");
+       int ReadBindFile(string const & name = "cua");
        ///
        Toolbar toolbar;
        ///
index 64089fc711991ca6d840590817cb21e470351203..1f7416c02149dcfda244a07589a55ab5f5c6b127 100644 (file)
@@ -4,26 +4,28 @@
  * 
  *           LyX, The Document Processor
  *      
- *         Copyright (C) 1995 Matthias Ettrich
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-1999 The LyX Team.
  *
- *======================================================*/
+ * ====================================================== */
 
-#ifndef _LYXROW_H
-#define _LYXROW_H
+#ifndef LYXROW_H
+#define LYXROW_H
 
-//#include "lyxparagraph.h"
-
-class LyXParagraph;
+#include "lyxparagraph.h"
 
 ///
 struct Row {
        ///
-       LyXParagraph *par;
+       LyXParagraph * par;
        ///
+#ifdef NEW_TEXT
+       LyXParagraph::size_type pos;
+#else
        int pos;
+#endif
        ///
        unsigned short  baseline;
-       ///
        /** what is missing to a full row can be negative.
          Needed for hfills, flushright, block etc. */
        int fill;
@@ -33,9 +35,9 @@ struct Row {
        unsigned short ascent_of_text;
        
        ///
-       Row* next;
+       Row * next;
        ///
-       Row* previous;
+       Row * previous;
 };
 
 #endif
index 912f59e53dc1f5425d04e094d718e79605a7de41..a4fe92f2272e3126357e1a2f6092d7e4177b319c 100644 (file)
 #endif
 
 #include "definitions.h"
-#include "layout.h"
 #include "lyxfont.h"
 #include "lyxrow.h"
 #include "undo.h"
 #include "lyxcursor.h"
+#include "lyxparagraph.h"
 
 class Buffer;
 class BufferParams;
@@ -45,9 +45,9 @@ public:
        };
 
        /// points to Buffer.params
-       BufferParams *parameters;
+       BufferParams * parameters;
        /// points to Buffer
-       Buffer *params;
+       Buffer * params;
        ///
        int number_of_rows;
        ///
@@ -63,13 +63,22 @@ public:
        /// Destructor
        ~LyXText();
    
+#ifdef NEW_TEXT
        ///
-       LyXFont GetFont(LyXParagraph* par, int pos);
+       LyXFont GetFont(LyXParagraph * par,
+                       LyXParagraph::size_type pos);
        ///
-       void SetCharFont(LyXParagraph *par, int pos, LyXFont font);
-   
+       void SetCharFont(LyXParagraph * par,
+                        LyXParagraph::size_type pos,
+                        LyXFont font);
+#else
+       ///
+       LyXFont GetFont(LyXParagraph * par, int pos);
+       ///
+       void SetCharFont(LyXParagraph * par, int pos, LyXFont font);
+#endif
        /// returns a pointer to the very first LyXParagraph
-       LyXParagraph *FirstParagraph();
+       LyXParagraph * FirstParagraph();
   
        /// what you expect when pressing <enter> at cursor position
        void BreakParagraph(char keep_layout = 0);
@@ -80,7 +89,7 @@ public:
        void SetLayout(char layout);
        
        /// used in setlayout
-       void MakeFontEntriesLayoutSpecific(LyXParagraph *par);
+       void MakeFontEntriesLayoutSpecific(LyXParagraph * par);
        
        /** increment depth over selection and make a total rebreak of those 
          paragraphs
@@ -99,19 +108,19 @@ public:
          paragraphs.
          toggleall defaults to false.
          */
-       void SetFont(LyXFont font, bool toggleall=false);
+       void SetFont(LyXFont font, bool toggleall = false);
        
        /** deletes and inserts again all paragaphs between the cursor
          and the specified par .The Cursor is needed to set the refreshing
          parameters. 
          This function is needed after SetLayout and SetFont etc.
          */
-       void RedoParagraphs(LyXCursor cursor, LyXParagraph *end_par);
+       void RedoParagraphs(LyXCursor cursor, LyXParagraph * end_par);
        ///
        void RedoParagraph();
        
        ///
-       void ToggleFree(LyXFont font,bool toggleall=false);
+       void ToggleFree(LyXFont font, bool toggleall = false);
        
        /** recalculates the heights of all previous rows of the
            specified paragraph.  needed, if the last characters font
@@ -129,17 +138,17 @@ public:
          */
        void InsertChar(char c);
        ///
-       void InsertInset(Inset *inset);
+       void InsertInset(Inset * inset);
    
        /// completes the insertion with a full rebreak
        int FullRebreak();
    
        /// may be important for the menu
-       char* GetLayout(int row);
+       char * GetLayout(int row);
        ///
        LyXParagraph::footnote_flag GetFootnoteFlag(int row);
        ///
-       Row* need_break_row;
+       Row * need_break_row;
        ///
        long refresh_y;
        ///
@@ -149,7 +158,7 @@ public:
        ///
        int refresh_x;
        ///
-       Row *refresh_row;
+       Row * refresh_row;
        ///
        int refresh_pos;
        
@@ -162,18 +171,22 @@ public:
          (relative to the whole text). y is set to the real beginning
          of this row
          */ 
-       Row* GetRowNearY(long &y);
+       Row * GetRowNearY(long & y);
        
        /** returns the column near the specified x-coordinate of the row 
         x is set to the real beginning of this column
         */ 
-       int GetColumnNearX(Row *row, int& x);
+       int GetColumnNearX(Row * row, int & x);
        
        /** returns a pointer to a specified row. y is set to the beginning
         of the row
         */
-       Row* GetRow(LyXParagraph *par, int pos, long &y);
-       
+#ifdef NEW_TEXT
+       Row * GetRow(LyXParagraph * par,
+                    LyXParagraph::size_type pos, long & y);
+#else
+       Row * GetRow(LyXParagraph * par, int pos, long & y);
+#endif
        /** returns the height of a default row, needed  for scrollbar
         */
        int DefaultHeight();
@@ -218,13 +231,22 @@ public:
         to the beginning of this word. 
         With SelectSelectedWord can this be highlighted really
         */ 
-       char* SelectNextWord(float &value);
+       char * SelectNextWord(float & value);
        ///
        void SelectSelectedWord();
+#ifdef NEW_TEXT
        ///
-       void SetCursor(LyXParagraph *par, int pos);
+       void SetCursor(LyXParagraph * par,
+                      LyXParagraph::size_type pos);
        ///
-       void SetCursorIntern(LyXParagraph *par, int pos);
+       void SetCursorIntern(LyXParagraph * par,
+                            LyXParagraph::size_type pos);
+#else
+       ///
+       void SetCursor(LyXParagraph * par, int pos);
+       ///
+       void SetCursorIntern(LyXParagraph * par, int pos);
+#endif
        ///
        void SetCursorFromCoordinates(int x, long y);
        ///
@@ -266,17 +288,23 @@ public:
        ///
        int SelectWordWhenUnderCursor();
        /// Change the case of the word at cursor position
-       /** action is 0 for lower case, 1 for capitalization and 2 for
+       /** Change the case of the word at cursor position.
+           action is 0 for lower case, 1 for capitalization and 2 for
            uppercase. 
         */
-       void ChangeWordCase(int action);
+       enum TextCase {
+               text_lowercase = 0,
+               text_capitalization = 1,
+               text_uppercase = 2
+       };
+       void ChangeWordCase(TextCase action);
 
        /** returns a printed row in a pixmap. The y value is needed to
          decide, wether it is selected text or not. This is a strange
          solution but faster.
         */ 
-       void GetVisibleRow(LyXScreen &scr, int offset, 
-                          Row *row_ptr, long y);
+       void GetVisibleRow(LyXScreen & scr, int offset, 
+                          Row * row_ptr, long y);
                                           
        /* footnotes: */
        ///
@@ -326,12 +354,12 @@ public:
        void SetParagraph(bool line_top, bool line_bottom,
                          bool pagebreak_top, bool pagebreak_bottom,
                          VSpace space_top, VSpace space_bottom,
-                         char align, 
+                         LyXAlignment align, 
                          string labelwidthstring,
                          bool noindent);
         void SetParagraphExtraOpt(int type,
-                                  const char *width,
-                                  const char *widthp,
+                                  char const * width,
+                                  char const * widthp,
                                   int alignment, bool hfill,
                                   bool start_minipage);
 
@@ -340,28 +368,39 @@ public:
        /** returns true if the specified string is at the specified
          position
          */
-       bool IsStringInText(LyXParagraph *par, int pos, char const* string);
-
+#ifdef NEW_TEXT
+       bool IsStringInText(LyXParagraph * par,
+                           LyXParagraph::size_type pos,
+                           char const * str);
+#else
+       bool IsStringInText(LyXParagraph * par, int pos, char const * str);
+#endif
        /** sets the selection over the number of characters of string,
          no check!!
          */
-       void SetSelectionOverString(char const* string);
+       void SetSelectionOverString(char const * str);
 
        /** simple replacing. The font of the first selected character
          is used
          */
-       void ReplaceSelectionWithString(char const* string);
+       void ReplaceSelectionWithString(char const * string);
 
        /** if the string can be found: return true and set the cursor to
          the new position */
-       bool SearchForward(char const* string);
-       bool SearchBackward(char const* string);
+       bool SearchForward(char const * string);
+       bool SearchBackward(char const * string);
+
+#ifdef NEW_TEXT
        /// needed to insert the selection
-       void InsertStringA(char* string);
+       void InsertStringA(LyXParagraph::TextContainer const & text);
        /// needed to insert the selection
-       void InsertStringB(char* string);
-   
+       void InsertStringB(LyXParagraph::TextContainer const & text);
+#endif
+       /// needed to insert the selection
+       void InsertStringA(char const * string);
+       /// needed to insert the selection
+       void InsertStringB(char const * string);
+
        /// usefull when texing from within LyX
        bool GotoNextError();
 
@@ -372,42 +411,58 @@ public:
          for a list of paragraphs beginning with the specified par 
          return value is the number of wrong conversions
          */ 
-       int SwitchLayoutsBetweenClasses(char class1, char class2, LyXParagraph *par);
+       int SwitchLayoutsBetweenClasses(char class1, char class2,
+                                       LyXParagraph * par);
 
        /* for the greater insets */
   
        /// returns 0 if inset wasn't found
-       int UpdateInset(Inset* inset);
+       int UpdateInset(Inset * inset);
+#ifdef NEW_TEXT
        ///
-       void CheckParagraph(LyXParagraph* par, int pos);
-
+       void CheckParagraph(LyXParagraph * par,
+                           LyXParagraph::size_type pos);
+       ///
+       int NumberOfCell(LyXParagraph * par,
+                        LyXParagraph::size_type pos);
+#else
+       ///
+       void CheckParagraph(LyXParagraph * par, int pos);
+       ///
+       int NumberOfCell(LyXParagraph * par, int pos);
+#endif
        /* table stuff -- begin*/
 
        /** all table features of the text-class are put together in
          this function. Possible values of feature are defined in table.h
          */
-       void TableFeatures(int feature,string val);
+       void TableFeatures(int feature, string val);
         ///
        void TableFeatures(int feature);
-       ///
-       int NumberOfCell(LyXParagraph *par, int pos);
 
        /** pos points at the beginning of the next cell (if there is one)
         */
-       int WidthOfCell(LyXParagraph *par, int &pos);
+#ifdef NEW_TEXT
+       int WidthOfCell(LyXParagraph * par, LyXParagraph::size_type & pos);
+       ///
+       void CheckParagraphInTable(LyXParagraph * par,
+                                  LyXParagraph::size_type pos);
+#else
+       int WidthOfCell(LyXParagraph * par, int & pos);
+       ///
+       void CheckParagraphInTable(LyXParagraph * par, int pos);
+#endif
        ///
        void InsertCharInTable(char c);
        ///
        void BackspaceInTable();
        ///
-       void CheckParagraphInTable(LyXParagraph* par, int pos);
-       ///
-       char HitInTable(Row* row, int x);
+       char HitInTable(Row * row, int x);
        ///
        bool MouseHitInTable(int x, long y);
        /* table stuff -- end*/
        ///
-       LyXParagraph* GetParFromID(int id);
+       LyXParagraph * GetParFromID(int id);
 
        // undo functions
        /// returns false if no undo possible
@@ -415,7 +470,7 @@ public:
        /// returns false if no redo possible
        bool  TextRedo();
        /// used by TextUndo/TextRedo
-       bool TextHandleUndo(Undo* undo);
+       bool TextHandleUndo(Undo * undo);
        /// makes sure the next operation will be stored
        void FinishUndo();
        /// this is dangerous and for internal use only
@@ -427,11 +482,14 @@ public:
        /// a flag
        bool undo_frozen;
        ///
-       void SetUndo(Undo::undo_kind kind, LyXParagraph *before, LyXParagraph *end);
+       void SetUndo(Undo::undo_kind kind, LyXParagraph * before,
+                    LyXParagraph * end);
        ///
-       void SetRedo(Undo::undo_kind kind, LyXParagraph *before, LyXParagraph *end);
+       void SetRedo(Undo::undo_kind kind, LyXParagraph * before,
+                    LyXParagraph * end);
        ///
-       Undo *CreateUndo(Undo::undo_kind kind, LyXParagraph *before, LyXParagraph *end);
+       Undo * CreateUndo(Undo::undo_kind kind, LyXParagraph * before,
+                         LyXParagraph * end);
        /// for external use in lyx_cb.C
        void SetCursorParUndo();
        ///
@@ -439,9 +497,9 @@ public:
        ///
        void CursorRightIntern();
         ///
-        void RemoveTableRow(LyXCursor *cursor);
+        void RemoveTableRow(LyXCursor * cursor);
         ///
-        bool IsEmptyTableRow(LyXCursor *cursor);
+        bool IsEmptyTableRow(LyXCursor * cursor);
         ///
         bool IsEmptyTableCell();
         ///
@@ -449,9 +507,9 @@ public:
 
 private:
        ///
-       Row* firstrow;
+       Row * firstrow;
        ///
-       Row* lastrow;
+       Row * lastrow;
 
        /** Copybuffer for copy environment type
          Asger has learned that this should be a buffer-property instead
@@ -460,7 +518,7 @@ private:
        char copylayouttype;
 
        /// the currentrow is needed to access rows faster*/ 
-       Row* currentrow;                       /* pointer to the current row  */
+       Row * currentrow;               /* pointer to the current row  */
        /// position in the text 
        long  currentrow_y;
        /// width of the paper
@@ -468,99 +526,132 @@ private:
    
        /** inserts a new row behind the specified row, increments
         * the touched counters */
-       void InsertRow(Row *row, LyXParagraph *par, int pos );
-
+#ifdef NEW_TEXT
+       void InsertRow(Row * row, LyXParagraph * par,
+                      LyXParagraph::size_type pos );
+#else
+       void InsertRow(Row * row, LyXParagraph * par, int pos );
+#endif
        /** removes the row and reset the touched counters */
-       void RemoveRow(Row *row);
+       void RemoveRow(Row * row);
 
        /** remove all following rows of the paragraph of the specified row. */
-       void RemoveParagraph(Row *row);
+       void RemoveParagraph(Row * row);
 
        /** insert the specified paragraph behind the specified row */
-       void InsertParagraph(LyXParagraph *par, Row *row);
+       void InsertParagraph(LyXParagraph * par, Row * row);
 
        /** appends  the implizit specified paragraph behind the specified row,
         * start at the implizit given position */
-       void AppendParagraph(Row *row);
+       void AppendParagraph(Row * row);
    
        ///
-       void BreakAgain(Row *row);
+       void BreakAgain(Row * row);
        ///
-       void BreakAgainOneRow(Row *row);
+       void BreakAgainOneRow(Row * row);
        ///
-       void SetHeightOfRow(Row *row_ptr); /* calculate and set the height 
+       void SetHeightOfRow(Row * row_ptr); /* calculate and set the height 
                                            * of the row */
 
        /** this calculates the specified parameters. needed when setting
         * the cursor and when creating a visible row */ 
-       void PrepareToPrint(Row *row, float &x, float &fill_separator, 
-                           float &fill_hfill, float &fill_label_hfill);
+       void PrepareToPrint(Row * row, float & x, float & fill_separator, 
+                           float & fill_hfill, float & fill_label_hfill);
        ///
        void DeleteEmptyParagraphMechanism(LyXCursor old_cursor);
 
        /** Updates all counters starting BEHIND the row. Changed paragraphs
         * with a dynamic left margin will be rebroken. */ 
-       void UpdateCounters(Row *row);
+       void UpdateCounters(Row * row);
        ///
-       void SetCounter(LyXParagraph *par);
+       void SetCounter(LyXParagraph * par);
    
        /*
         * some low level functions
         */
        
+#ifdef NEW_TEXT
        ///
-       int SingleWidth(LyXParagraph *par, int pos);
+       int SingleWidth(LyXParagraph * par,
+                       LyXParagraph::size_type pos);
        ///
-       int SingleWidth(LyXParagraph *par, int pos, char c);
+       int SingleWidth(LyXParagraph * par,
+                       LyXParagraph::size_type pos, char c);
        ///
-       void Draw(Row *row, int &pos, LyXScreen &scr, int offset, float &x);
+       void Draw(Row * row, LyXParagraph::size_type & pos,
+                 LyXScreen & scr,
+                 int offset, float & x);
        /// get the next breakpoint in a given paragraph
-       int NextBreakPoint(Row* row, int width);
+       LyXParagraph::size_type NextBreakPoint(Row * row,
+                                              int width);
+#else
+       ///
+       int SingleWidth(LyXParagraph * par, int pos);
+       ///
+       int SingleWidth(LyXParagraph * par, int pos, char c);
+       ///
+       void Draw(Row * row, int & pos, LyXScreen & scr,
+                 int offset, float & x);
+       /// get the next breakpoint in a given paragraph
+       int NextBreakPoint(Row * row, int width);
+#endif
        /// returns the minimum space a row needs on the screen in pixel
-       int Fill(Row *row, int paperwidth);
+       int Fill(Row * row, int paperwidth);
        
        /** returns the minimum space a manual label needs on the
          screen in pixel */ 
-       int LabelFill(Row *row);
-       
+       int LabelFill(Row * row);
+
+#ifdef NEW_TEXT
        ///
-       int BeginningOfMainBody(LyXParagraph *par);
-       
+       LyXParagraph::size_type BeginningOfMainBody(LyXParagraph * par);
+#else
+       ///
+       int BeginningOfMainBody(LyXParagraph * par);
+#endif
        /** Returns the left beginning of the text.
          This information cannot be taken from the layouts-objekt, because
          in LaTeX the beginning of the text fits in some cases
          (for example sections) exactly the label-width.
          */
-       int LeftMargin(Row *row);
+       int LeftMargin(Row * row);
        ///
-       int RightMargin(Row *row);
+       int RightMargin(Row * row);
        ///
-       int LabelEnd (Row *row);
+       int LabelEnd (Row * row);
 
        /** returns the number of separators in the specified row.
          The separator on the very last column doesnt count
          */ 
-       int NumberOfSeparators(Row *row);
+       int NumberOfSeparators(Row * row);
 
        /** returns the number of hfills in the specified row. The
          LyX-Hfill is a LaTeX \hfill so that the hfills at the
          beginning and at the end were ignored. This is {\em MUCH}
          more usefull than not to ignore!
          */
-       int NumberOfHfills(Row *row);
+       int NumberOfHfills(Row * row);
    
        /// like NumberOfHfills, but only those in the manual label!
-       int NumberOfLabelHfills(Row *row);
+       int NumberOfLabelHfills(Row * row);
 
        /** returns true, if a expansion is needed. Rules are given by 
          LaTeX
-         */ 
-       bool HfillExpansion(Row *row_ptr, int pos);
-   
+         */
+#ifdef NEW_TEXT
+       bool HfillExpansion(Row * row_ptr,
+                           LyXParagraph::size_type pos);
        /** returns the paragraph position of the last character in the 
          specified row
          */
-       int RowLast(Row *row);
+       LyXParagraph::size_type RowLast(Row * row);
+#else
+       bool HfillExpansion(Row * row_ptr, int pos);
+       /** returns the paragraph position of the last character in the 
+         specified row
+         */
+       int RowLast(Row * row);
+#endif
 };
 
 #endif
index 31aca999eac6133cc80efc98b1b3f600969f4c49..2940da6ab39a9da898db94b73b81d59a9d7385a6 100644 (file)
@@ -21,9 +21,6 @@
 extern BufferList bufferlist;
 extern void MenuWrite(Buffer *);
 
-#if 0
-extern bool gsworking();
-#endif
 
 LyXVC::LyXVC()
 {
@@ -146,7 +143,7 @@ void LyXVC::scanMaster()
 }
 
 
-void LyXVC::setBuffer(Buffer *buf)
+void LyXVC::setBuffer(Buffer * buf)
 {
        _owner = buf;
 }
@@ -302,22 +299,23 @@ string const LyXVC::getLocker() const
 }
 
 // This is a hack anyway so I'll put it here in the mean time.
-void LyXVC::logClose(FL_OBJECT *obj, long)
+void LyXVC::logClose(FL_OBJECT * obj, long)
 {
-       LyXVC *This = (LyXVC*)obj->form->u_vdata;
+       LyXVC * This = static_cast<LyXVC*>(obj->form->u_vdata);
        fl_hide_form(This->browser->LaTeXLog);
 }
 
+
 // and, hack over hack, here is a C wrapper :)
-extern "C" void C_LyXVC_logClose(FL_OBJECT *ob, long data)
+extern "C" void C_LyXVC_logClose(FL_OBJECT * ob, long data)
 {
        LyXVC::logClose(ob, data);
 }
 
 
-void LyXVC::logUpdate(FL_OBJECT *obj, long)
+void LyXVC::logUpdate(FL_OBJECT * obj, long)
 {
-       LyXVC *This = (LyXVC*)obj->form->u_vdata;
+       LyXVC * This = static_cast<LyXVC*>(obj->form->u_vdata);
        This->showLog();
 }
 
@@ -332,14 +330,17 @@ void LyXVC::viewLog(string const & fil)
        static int ow = -1, oh;
 
        if (!browser) {
-               FL_OBJECT *obj;
+               FL_OBJECT * obj;
                browser = (FD_LaTeXLog *) fl_calloc(1, sizeof(*browser));
                
                browser->LaTeXLog = fl_bgn_form(FL_NO_BOX, 470, 380);
-               browser->LaTeXLog->u_vdata = (void*)this;
+               browser->LaTeXLog->u_vdata = this;
                obj = fl_add_box(FL_UP_BOX, 0, 0, 470, 380, "");
-               browser->browser_latexlog = fl_add_browser(FL_NORMAL_BROWSER, 10, 10, 450, 320, "");
-               obj = fl_add_button(FL_RETURN_BUTTON, 270, 340, 90, 30, _("Close"));
+               browser->browser_latexlog = fl_add_browser(FL_NORMAL_BROWSER,
+                                                          10, 10,
+                                                          450, 320, "");
+               obj = fl_add_button(FL_RETURN_BUTTON, 270, 340, 90, 30,
+                                   _("Close"));
                fl_set_object_lsize(obj, FL_NORMAL_SIZE);
                fl_set_object_callback(obj, C_LyXVC_logClose, 0);
                obj = fl_add_button(FL_NORMAL_BUTTON,370,340,90,30,
@@ -352,7 +353,8 @@ void LyXVC::viewLog(string const & fil)
        }
 
        if (!fl_load_browser(browser->browser_latexlog, fil.c_str()))
-               fl_add_browser_line(browser->browser_latexlog, _("No RCS History!"));
+               fl_add_browser_line(browser->browser_latexlog,
+                                   _("No RCS History!"));
        
        if (browser->LaTeXLog->visible) {
                fl_raise_form(browser->LaTeXLog);
@@ -371,26 +373,6 @@ void LyXVC::viewLog(string const & fil)
 
 void LyXVC::showLog()
 {
-       // This I really don't like, but we'll look at this problem
-       // in 0.13. Then we can make a clean solution.
-#if 0
-       if (gsworking()) {
-                WriteAlert(_("Sorry, can't do this while"
-                            " pictures are being rendered."),
-                           _("Please wait a few seconds for"
-                            " this to finish and try again."),
-                           _("(or kill runaway gs processes"
-                            " by hand and try again.)"));
-                return;
-        }
-        extern pid_t isp_pid; // from spellchecker.C
-        if(isp_pid != -1) {
-               WriteAlert(_("Can't do this while the"
-                            " spellchecker is running."),
-                          _("Stop the spellchecker first."));
-               return;
-       }
-#endif
        string tmpf = tmpnam(0);
        doVCCommand("rlog \""
                    + OnlyFilename(_owner->getFileName()) + "\" > " + tmpf);
index e36ba7e85ed49de98efdf22a3f28617f61ebad75..072ae17914b948dec4c48b3cbad831bf551791f3 100644 (file)
@@ -265,9 +265,9 @@ int mathed_char_height(short type, int size, byte c, int& asc, int& des)
 
 
 // In a near future maybe we use a better fonts renderer
-void MathedInset::drawStr(short type, int size, int x, int y, byte* s, int ls)
+void MathedInset::drawStr(short type, int siz, int x, int y, byte* s, int ls)
 {
-    mathed_set_font(type, size);
+    mathed_set_font(type, siz);
     byte sx[80];
     if (MathIsBinary(type)) {
        byte *ps = &sx[0];
@@ -281,7 +281,7 @@ void MathedInset::drawStr(short type, int size, int x, int y, byte* s, int ls)
        s = &sx[0];
     }
     GC gc = (type==LM_TC_TEX) ? latexGC: mathGC;
-    XDrawString(fl_display, pm, gc, x, y, (char*)s, ls);
+    XDrawString(fl_display, pm, gc, x, y, reinterpret_cast<char*>(s), ls);
     XFlush(fl_display);
 }
 
@@ -621,25 +621,25 @@ int InsetFormula::GetNumberOfLabels() const
 string InsetFormula::getLabel(int il) const
 {
 //#warning This is dirty, I know. Ill clean it at 0.11
-    // Correction, the only way to clean this is with a new kernel: 0.13.
+       // Correction, the only way to clean this is with a new kernel: 0.13.
        if (par->GetType()==LM_OT_MPARN) {
-       string label;
-       MathMatrixInset *mt = (MathMatrixInset*)par;
-       int nl=0;
-       MathedRowSt const* crow = mt->getRowSt();
-       while (crow) {
-          if (crow->getLabel()) {
-              if (nl==il) {
-                  label = crow->getLabel();
-                  break;
-              }
-              nl++;
-          }
-          crow = crow->getNext();
-       }
-       return label;
-   }
-   return label;
+               string lab;
+               MathMatrixInset * mt = (MathMatrixInset*)par;
+               int nl=0;
+               MathedRowSt const * crow = mt->getRowSt();
+               while (crow) {
+                       if (crow->getLabel()) {
+                               if (nl==il) {
+                                       lab = crow->getLabel();
+                                       break;
+                               }
+                               nl++;
+                       }
+                       crow = crow->getNext();
+               }
+               return lab;
+       }
+       return label;
 }
 
 void InsetFormula::UpdateLocal()
index c7551ad1672d56a38a8af32d73ad49f757a3b864..209baf8a7deb21d7d333eaf0882601b6fcfc18d3 100644 (file)
@@ -41,12 +41,14 @@ inline bool IsAlpha(char c)
 }
 
 // This was very smaller, I'll change it later 
-inline bool IsMacro(short token, int id)
+inline bool IsMacro(short tok, int id)
 {
-   return (token!=LM_TK_STACK && token!=LM_TK_FRAC && token!=LM_TK_SQRT && token!=LM_TK_WIDE &&
-          token!=LM_TK_SPACE && token!=LM_TK_DOTS &&  token!=LM_TK_FUNCLIM &&
-          token!=LM_TK_BIGSYM && token!=LM_TK_ACCENT && 
-          !(token==LM_TK_SYM && id<255));
+   return (tok != LM_TK_STACK && tok != LM_TK_FRAC && tok != LM_TK_SQRT
+          && tok != LM_TK_WIDE
+          && tok != LM_TK_SPACE && tok != LM_TK_DOTS
+          && tok != LM_TK_FUNCLIM
+          && tok != LM_TK_BIGSYM && tok != LM_TK_ACCENT && 
+          !(tok == LM_TK_SYM && id < 255));
 }
 
 // Yes, mathed isn't using string yet.
index 4ffea9b6a2476defd3a5699f2bd88d382e306c98..e826d0f54e8d8fd802292c169e468236290d633d 100644 (file)
@@ -363,8 +363,8 @@ MathBigopInset::Metrics()
       t = LM_TC_TEXTRM;
    }
    mathed_set_font(t, size);
-   mathed_string_height(t, size, (unsigned char const *)s, ls, ascent, descent);
-   width = mathed_string_width(t, size, (unsigned char const *)s, ls);
+   mathed_string_height(t, size, reinterpret_cast<const unsigned char*>(s), ls, ascent, descent);
+   width = mathed_string_width(t, size, reinterpret_cast<const unsigned char*>(s), ls);
    if (sym==LM_oint) width += 2;
 }
 
index df1895f87430e1f2adc9dc803456e6cae346ce25..02f5ac52478ba5a6593897b1eddf8690351fa30e 100644 (file)
@@ -361,20 +361,20 @@ in_word_set (register const char *str, register int len)
 
       if (key <= MAX_HASH_VALUE && key >= 0)
         {
-          register int index = lookup[key];
+          register int idx = lookup[key];
 
-          if (index >= 0 && index < MAX_HASH_VALUE)
+          if (idx >= 0 && idx < MAX_HASH_VALUE)
             {
-              register char const *s = wordlist[index].name;
+              register char const * s = wordlist[idx].name;
 
               if (*s == *str && !strcmp (str + 1, s + 1))
-                return &wordlist[index];
+                return &wordlist[idx];
             }
-          else if (index < 0 && index >= -MAX_HASH_VALUE)
+          else if (idx < 0 && idx >= -MAX_HASH_VALUE)
             return 0;
           else
             {
-              register int offset = key + index + (index > 0 ? -MAX_HASH_VALUE : MAX_HASH_VALUE);
+              register int offset = key + idx + (idx > 0 ? -MAX_HASH_VALUE : MAX_HASH_VALUE);
               register struct latexkeys *base = &wordlist[-lookup[offset]];
               register struct latexkeys *ptr = base + -lookup[offset + 1];
 
index 902e40fcb9c3fda0d8a0a197bd90c4969c633d20..b977e6b5ce5250ebd6d7d5e374fe4af7a276cb61 100644 (file)
@@ -284,7 +284,7 @@ MathMatrixInset::MathMatrixInset(int m, int n, short st):
     ws = new int[nc]; 
     v_align = 0;
     h_align = new char[nc+1];
-    for (int i =0; i<nc; i++) h_align[i] = 'c'; 
+    for (int i =0; i < nc; i++) h_align[i] = 'c'; 
     h_align[nc] = '\0';
     nr = 0;
     row = 0;
@@ -292,10 +292,10 @@ MathMatrixInset::MathMatrixInset(int m, int n, short st):
     if (n>0) {
            row = new MathedRowSt(nc+1);
        MathedXIter it(this);
-       for (int i=1; i<n; i++) it.addRow();
+       for (int j = 1; j < n; j++) it.addRow();
        nr = n;
        if (nr==1 && nc>1) {
-           for (int i=0; i<nc-1; i++) 
+           for (int j = 0; j < nc - 1; j++) 
              it.Insert('T', LM_TC_TAB);
        }
     } else if (n<0) {
@@ -515,8 +515,8 @@ MathedInset *MathAccentInset::Clone()
 }
 
 
-MathBigopInset::MathBigopInset(char const* name, int id, short st): 
-  MathedInset(name, LM_OT_BIGOP, st), sym(id)
+MathBigopInset::MathBigopInset(char const* nam, int id, short st): 
+  MathedInset(nam, LM_OT_BIGOP, st), sym(id)
 {
    lims = -1;
 }
@@ -527,8 +527,8 @@ MathedInset *MathBigopInset::Clone()
    return p;
 }
  
-MathDotsInset::MathDotsInset(char const* name, int id, short st):
-  MathedInset(name, LM_OT_DOTS, st), code(id)
+MathDotsInset::MathDotsInset(char const* nam, int id, short st):
+  MathedInset(nam, LM_OT_DOTS, st), code(id)
 {
 }
 
index a66179803fcfc774d0e5ea46cafde953b162a7a2..5d5833d62930fff3d888935f69ba832e97a8dcaa 100644 (file)
@@ -273,7 +273,7 @@ void MathedIter::Insert(MathedInset* p, int type)
 //      array->bf[pos-1] = type;
     {
        unsigned char *pt = &array->bf[pos];
-       unsigned char *ps = (unsigned char *)&p;
+       unsigned char *ps = reinterpret_cast<unsigned char*>(&p);
        size_t i;
        *pt++ = type;
        for(i = 0; i < sizeof(p); i++) {
@@ -574,9 +574,9 @@ void MathedXIter::SetData(MathParInset *pp)
 byte* MathedXIter::GetString(int& ls)
 {  
    static byte s[255];
-   byte const *sx =  MathedIter::GetString(ls);
+   byte const *sxs =  MathedIter::GetString(ls);
    if (ls>0) {
-       strncpy((char *)s, (char const*)sx, ls);
+       strncpy(reinterpret_cast<char*>(s), reinterpret_cast<const char*>(sxs), ls);
        x += mathed_string_width(fcode, size, s, ls);
        return &s[0];
    }       
@@ -862,7 +862,7 @@ void MathedXIter::IMetrics(int pos2, int& width, int& ascent, int& descent)
        byte cx, cxp=0;// *s;
        int x1;// ls;
     int asc=0, des=0;
-    bool limits = false;
+    bool limit = false;
   
     descent = ascent = width = 0;
     if (!array) return;
@@ -875,7 +875,7 @@ void MathedXIter::IMetrics(int pos2, int& width, int& ascent, int& descent)
            mathed_char_height(FCode(), size, cx, asc, des);
            if (asc > ascent) ascent = asc;
            if (des > descent) descent = des;
-           limits = false;
+           limit = false;
        } else
        if (MathIsInset(cx)) {
            MathedInset *pp = GetInset();
@@ -883,7 +883,7 @@ void MathedXIter::IMetrics(int pos2, int& width, int& ascent, int& descent)
                if (!asc && p) {
                    int xx, yy;
                    p->GetXY(xx, yy);
-                   ((MathParInset*)pp)->GetXY(xx, asc);
+                   static_cast<MathParInset*>(pp)->GetXY(xx, asc);
                    asc = yy - asc;
                }
                asc += ((limits) ? pp->Height()+4: pp->Ascent());
@@ -892,12 +892,12 @@ void MathedXIter::IMetrics(int pos2, int& width, int& ascent, int& descent)
                  if (!des && p) {
                      int xx, yy;
                      p->GetXY(xx, yy);
-                     ((MathParInset*)pp)->GetXY(xx, des);
+                     static_cast<MathParInset*>(pp)->GetXY(xx, des);
                      if (des-pp->Height()<yy && !asc)
                        asc = yy - (des-pp->Height());
                      des -= yy;
                  }
-                 des += ((limits) ? pp->Height()+4: pp->Height()-pp->Ascent()/2);
+                 des += (limit ? pp->Height()+4: pp->Height()-pp->Ascent()/2);
              } else {
                  asc = pp->Ascent();
                  des = pp->Descent();
@@ -905,10 +905,10 @@ void MathedXIter::IMetrics(int pos2, int& width, int& ascent, int& descent)
            if (asc > ascent) ascent = asc;
            if (des > descent) descent = des;
            if (cx!=LM_TC_UP && cx!=LM_TC_DOWN)
-             limits = pp->GetLimits();
+             limit = pp->GetLimits();
        } else 
        if (cx==LM_TC_TAB) {
-           limits = false;                   
+           limit = false;                   
        }      
        else {
                lyxerr[Debug::MATHED]
@@ -916,7 +916,7 @@ void MathedXIter::IMetrics(int pos2, int& width, int& ascent, int& descent)
                        << cx << ']' << endl;
            break;
        }       
-       if (pos<pos2)  Next();
+       if (pos < pos2)  Next();
        cxp = cx;
    }
     width = x - x1;
@@ -953,7 +953,7 @@ MathedRowSt *MathedXIter::adjustVerticalSt()
            crow = new MathedRowSt(ncols+1); // this leaks
     }
 //    lyxerr<< " CRW[" << crow << "] ";
-    MathedRowSt *row = crow;
+    MathedRowSt *mrow = crow;
     while (OK()) {
        if (IsCR()) {
            if (col>=ncols) ncols = col+1; 
@@ -965,6 +965,6 @@ MathedRowSt *MathedXIter::adjustVerticalSt()
        }   
        Next(); 
     }
-    return row;
+    return mrow;
 }
 
index 3402ee91879ac948327c6470ea59be45078ad102..e83314379af315f9ca3fc3b6e462fbb2cf65cbbf 100644 (file)
@@ -45,8 +45,9 @@
 #include "lyxrc.h"
 #include "lyxtext.h"
 #include "gettext.h"
+#include "layout.h"
 
-extern FD_form_screen *fd_form_screen;
+extern FD_form_screen * fd_form_screen;
 extern BufferList bufferlist;
 
 // I would really prefere to see most or all of these 'extern's disappear.
@@ -55,7 +56,7 @@ extern BufferList bufferlist;
 extern void MenuLayoutSave();
 extern void ShowCredits();
 extern void ShowCopyright();
-extern void show_symbols_form(LyXFunc*);
+extern void show_symbols_form(LyXFunc *);
 extern void BeforeChange();
 extern void ProhibitInput();
 extern void AllowInput();
@@ -66,53 +67,53 @@ extern void LaTeXOptions();
 
 // A bunch of wrappers
 
-extern "C" void C_Menus_ShowFileMenu(FL_OBJECT *ob, long data)
+extern "C" void C_Menus_ShowFileMenu(FL_OBJECT * ob, long data)
 {
        Menus::ShowFileMenu(ob, data);
 }
 
-extern "C" void C_Menus_ShowFileMenu2(FL_OBJECT *ob, long data)
+extern "C" void C_Menus_ShowFileMenu2(FL_OBJECT * ob, long data)
 {
        Menus::ShowFileMenu2(ob, data);
 }
 
-extern "C" void C_Menus_ShowEditMenu(FL_OBJECT *ob, long data)
+extern "C" void C_Menus_ShowEditMenu(FL_OBJECT * ob, long data)
 {
        Menus::ShowEditMenu(ob, data);
 }
 
-extern "C" void C_Menus_ShowLayoutMenu(FL_OBJECT *ob, long data)
+extern "C" void C_Menus_ShowLayoutMenu(FL_OBJECT * ob, long data)
 {
        Menus::ShowLayoutMenu(ob, data);
 }
 
-extern "C" void C_Menus_ShowInsertMenu(FL_OBJECT *ob, long data)
+extern "C" void C_Menus_ShowInsertMenu(FL_OBJECT * ob, long data)
 {
        Menus::ShowInsertMenu(ob, data);
 }
 
-extern "C" void C_Menus_ShowMathMenu(FL_OBJECT *ob, long data)
+extern "C" void C_Menus_ShowMathMenu(FL_OBJECT * ob, long data)
 {
        Menus::ShowMathMenu(ob, data);
 }
 
-extern "C" void C_Menus_ShowOptionsMenu(FL_OBJECT *ob, long data)
+extern "C" void C_Menus_ShowOptionsMenu(FL_OBJECT * ob, long data)
 {
        Menus::ShowOptionsMenu(ob, data);
 }
 
-extern "C" void C_Menus_ShowBufferMenu(FL_OBJECT *ob, long data)
+extern "C" void C_Menus_ShowBufferMenu(FL_OBJECT * ob, long data)
 {
        Menus::ShowBufferMenu(ob, data);
 }
 
-extern "C" void C_Menus_ShowHelpMenu(FL_OBJECT *ob, long data)
+extern "C" void C_Menus_ShowHelpMenu(FL_OBJECT * ob, long data)
 {
        Menus::ShowHelpMenu(ob, data);
 }
 
 
-Menus::Menus(LyXView *view,int air)
+Menus::Menus(LyXView * view, int air)
        : _view(view)
 {      
        create_menus(air);
@@ -132,7 +133,7 @@ Menus::Menus(LyXView *view,int air)
 }
 
 
-inline BufferView *Menus::currentView() 
+inline BufferView * Menus::currentView() 
 {
        return _view->currentView(); 
 }
@@ -152,7 +153,7 @@ void Menus::hideMenus()
 }
 
 
-void Menus::openByName(string const &menuName)
+void Menus::openByName(string const & menuName)
        /* Opens the visible menu of given name, or simply does nothing
           when the name is not known. NOTE THE EXTREMELY STUPID
           IMPLEMENTATION! :-) There are probably hundred ways to do
@@ -161,20 +162,31 @@ void Menus::openByName(string const &menuName)
           experienced GG (GUI Guy/Girl). RVDK_PATCH_5. */
 {
        if (menu_file->visible) {
-               if (menuName == _("File"))           ShowFileMenu(menu_file, 0);
-               else if (menuName == _("Edit"))      ShowEditMenu(menu_edit, 0);
-               else if (menuName == _("Layout"))    ShowLayoutMenu(menu_layout, 0);
-               else if (menuName == _("Insert"))    ShowInsertMenu(menu_insert, 0);
-               else if (menuName == _("Math"))      ShowMathMenu(menu_math, 0);
-               else if (menuName == _("Options"))   ShowOptionsMenu(menu_options, 0);
-               else if (menuName == _("Documents")) ShowBufferMenu(menu_buffer, 0);
-               else if (menuName == _("Help"))      ShowHelpMenu(menu_help, 0);
+               if (menuName == _("File"))
+                       ShowFileMenu(menu_file, 0);
+               else if (menuName == _("Edit"))
+                       ShowEditMenu(menu_edit, 0);
+               else if (menuName == _("Layout"))
+                       ShowLayoutMenu(menu_layout, 0);
+               else if (menuName == _("Insert"))
+                       ShowInsertMenu(menu_insert, 0);
+               else if (menuName == _("Math"))
+                       ShowMathMenu(menu_math, 0);
+               else if (menuName == _("Options"))
+                       ShowOptionsMenu(menu_options, 0);
+               else if (menuName == _("Documents"))
+                       ShowBufferMenu(menu_buffer, 0);
+               else if (menuName == _("Help"))
+                       ShowHelpMenu(menu_help, 0);
                else lyxerr << "The menu '" << menuName
                            << "' is not available." << endl;
        } else {
-               if (menuName == _("File"))           ShowFileMenu2(menu_file2, 0);
-               else if (menuName == _("Options"))   ShowOptionsMenu(menu_options2, 0);
-               else if (menuName == _("Help"))      ShowHelpMenu(menu_help2, 0);
+               if (menuName == _("File"))
+                       ShowFileMenu2(menu_file2, 0);
+               else if (menuName == _("Options"))
+                       ShowOptionsMenu(menu_options2, 0);
+               else if (menuName == _("Help"))
+                       ShowHelpMenu(menu_help2, 0);
                else lyxerr << "The menu '" << menuName
                            << "' is not available." << endl;
        }
@@ -183,11 +195,11 @@ void Menus::openByName(string const &menuName)
 
 void Menus::create_menus(int air)
 {
-       FL_FORM *form = _view->getForm(); 
+       FL_FORM * form = _view->getForm(); 
 
        // Here I'd really like to see code like:
        // addMenuBar();
-       FL_OBJECT *obj;
+       FL_OBJECT * obj;
 
        const int MENU_LABEL_SIZE = FL_NORMAL_SIZE;
        const int mheight = 30;
@@ -216,7 +228,7 @@ void Menus::create_menus(int air)
        moffset += obj->w + air;
        fl_set_object_shortcut(obj, scex(_("MB|#F")), 1);
        fl_set_object_callback(obj,C_Menus_ShowFileMenu, 0);
-       obj->u_ldata = (long)this;
+       obj->u_vdata = this;
        
        // Edit menu button
        menu_edit = obj =
@@ -230,7 +242,7 @@ void Menus::create_menus(int air)
        moffset += obj->w + air;
        fl_set_object_shortcut(obj, scex(_("MB|#E")),1);
        fl_set_object_callback(obj,C_Menus_ShowEditMenu,0);
-       obj->u_ldata = (long) this;
+       obj->u_vdata = this;
        
        // Layout menu button
        menu_layout = obj =
@@ -244,7 +256,7 @@ void Menus::create_menus(int air)
        moffset += obj->w + air;
        fl_set_object_shortcut(obj, scex(_("MB|#L")), 1);
        fl_set_object_callback(obj,C_Menus_ShowLayoutMenu,0);
-       obj->u_ldata = (long) this;
+       obj->u_vdata = this;
        
        // Insert menu button button
        menu_insert = obj =
@@ -258,7 +270,7 @@ void Menus::create_menus(int air)
        moffset += obj->w + air;
        fl_set_object_shortcut(obj, scex(_("MB|#I")), 1);
        fl_set_object_callback(obj,C_Menus_ShowInsertMenu,0);
-       obj->u_ldata = (long) this;
+       obj->u_vdata = this;
        
        // Math menu button
        menu_math = obj =
@@ -272,7 +284,7 @@ void Menus::create_menus(int air)
        moffset += obj->w + air;
        fl_set_object_shortcut(obj, scex(_("MB|#M")), 1);
        fl_set_object_callback(obj,C_Menus_ShowMathMenu,0);
-       obj->u_ldata = (long) this;
+       obj->u_vdata = this;
        
        // Options menu button
        menu_options = obj =
@@ -286,7 +298,7 @@ void Menus::create_menus(int air)
        moffset += obj->w + air;
        fl_set_object_shortcut(obj, scex(_("MB|#O")), 1);
        fl_set_object_callback(obj,C_Menus_ShowOptionsMenu, 0);
-       obj->u_ldata = (long) this;
+       obj->u_vdata = this;
 
        // Documents menu button
        menu_buffer = obj =
@@ -300,7 +312,7 @@ void Menus::create_menus(int air)
        moffset += obj->w + air;
        fl_set_object_shortcut(obj, scex(_("MB|#D")), 1);
        fl_set_object_callback(obj,C_Menus_ShowBufferMenu,0);
-       obj->u_ldata = (long) this;
+       obj->u_vdata = this;
        
        // Help menu button
        menu_help = obj =
@@ -314,7 +326,7 @@ void Menus::create_menus(int air)
        moffset += obj->w + air;
        fl_set_object_shortcut(obj, scex(_("MB|#H")), 1);
        fl_set_object_callback(obj,C_Menus_ShowHelpMenu,0);
-       obj->u_ldata = (long) this;
+       obj->u_vdata = this;
        
        fl_end_group();
 
@@ -347,7 +359,7 @@ void Menus::create_menus(int air)
        moffset += obj->w + air;
        fl_set_object_shortcut(obj, scex(_("MB|#F")), 1);
        fl_set_object_callback(obj,C_Menus_ShowFileMenu2, 0);
-       obj->u_ldata = (long)this;
+       obj->u_vdata = this;
        
        // Options menu button
        menu_options2 = obj =
@@ -361,7 +373,7 @@ void Menus::create_menus(int air)
        moffset += obj->w + air;
        fl_set_object_shortcut(obj, scex(_("MB|#O")), 1);
        fl_set_object_callback(obj,C_Menus_ShowOptionsMenu, 0);
-       obj->u_ldata = (long) this;
+       obj->u_vdata = this;
 
        // Help menu button
        menu_help2 = obj =
@@ -375,7 +387,7 @@ void Menus::create_menus(int air)
        moffset += obj->w + air;
        fl_set_object_shortcut(obj, scex(_("MB|#H")), 1);
        fl_set_object_callback(obj,C_Menus_ShowHelpMenu,0);
-       obj->u_ldata = (long) this;
+       obj->u_vdata = this;
        
        fl_end_group();
 
@@ -429,9 +441,9 @@ void Menus::ScreenOptions()
 // Here comes all the menu callbacks.
 //
 
-void Menus::ShowFileMenu(FL_OBJECT *ob, long)
+void Menus::ShowFileMenu(FL_OBJECT * ob, long)
 {
-       Menus *men = (Menus*) ob->u_ldata;
+       Menus * men = static_cast<Menus*>(ob->u_vdata);
 
        // Regarding the pseudo-menu-button:
        // ok, ok this is a hack. It would be better to use the menus of the
@@ -446,8 +458,8 @@ void Menus::ShowFileMenu(FL_OBJECT *ob, long)
        fl_set_button(ob, 0);
        fl_redraw_object(ob);
 
-       Buffer *tmpbuffer = men->_view->currentBuffer();
-       LyXFunc *tmpfunc = men->_view->getLyXFunc();
+       Buffer * tmpbuffer = men->_view->currentBuffer();
+       LyXFunc * tmpfunc = men->_view->getLyXFunc();
 
        bool LinuxDoc = tmpbuffer->isLinuxDoc();
        bool DocBook  = tmpbuffer->isDocBook();
@@ -455,12 +467,13 @@ void Menus::ShowFileMenu(FL_OBJECT *ob, long)
 
        // Import sub-menu
 
-       int SubFileImport =fl_defpup(FL_ObjWin(ob),
-                                    _("Import%t"
-                                      "|LaTeX...%x30"
-                                      "|Ascii Text as Lines...%x31"
-                                      "|Ascii Text as Paragraphs%x32"
-                                      "|Noweb%x33"));
+       int SubFileImport = fl_defpup(FL_ObjWin(ob),
+                                     _("Import%t"
+                                       "|LaTeX...%x30"
+                                       "|Ascii Text as Lines...%x31"
+                                       "|Ascii Text as Paragraphs%x32"
+                                       "|Noweb%x33"));
+       
        fl_setpup_shortcut(SubFileImport, 30, scex(_("FIM|Ll#l#L")));
        fl_setpup_shortcut(SubFileImport, 31, scex(_("FIM|Aa#a#A")));
        fl_setpup_shortcut(SubFileImport, 32, scex(_("FIM|Pp#p#P")));
@@ -472,28 +485,28 @@ void Menus::ShowFileMenu(FL_OBJECT *ob, long)
        // and now docbook also.
        int SubFileExport = 0;
        if (!LinuxDoc && !DocBook)
-            SubFileExport=fl_defpup(FL_ObjWin(ob),
-                                     _("Export%t"
-                                       "|as LaTeX...%x40"
-                                       "|as DVI...%x41"
-                                       "|as PostScript...%x42"
-                                       "|as Ascii Text...%x43"
-                                       "|as HTML...%x44"
-                                       "|Custom...%x45"));
+               SubFileExport=fl_defpup(FL_ObjWin(ob),
+                                       _("Export%t"
+                                         "|as LaTeX...%x40"
+                                         "|as DVI...%x41"
+                                         "|as PostScript...%x42"
+                                         "|as Ascii Text...%x43"
+                                         "|as HTML...%x44"
+                                         "|Custom...%x45"));
         else if(LinuxDoc)
-            SubFileExport=fl_defpup(FL_ObjWin(ob),
-                                     _("Export%t"
-                                       "|as LinuxDoc...%x40"
-                                       "|as DVI...%x41"
-                                       "|as PostScript...%x42"
-                                       "|as Ascii Text...%x43"));
+               SubFileExport=fl_defpup(FL_ObjWin(ob),
+                                       _("Export%t"
+                                         "|as LinuxDoc...%x40"
+                                         "|as DVI...%x41"
+                                         "|as PostScript...%x42"
+                                         "|as Ascii Text...%x43"));
         else if(DocBook)
-            SubFileExport=fl_defpup(FL_ObjWin(ob),
-                                     _("Export%t"
-                                       "|as DocBook...%x40"
-                                       "|as DVI...%x41"
-                                       "|as PostScript...%x42"
-                                       "|as Ascii Text...%x43"));
+               SubFileExport=fl_defpup(FL_ObjWin(ob),
+                                       _("Export%t"
+                                         "|as DocBook...%x40"
+                                         "|as DVI...%x41"
+                                         "|as PostScript...%x42"
+                                         "|as Ascii Text...%x43"));
 
        fl_setpup_shortcut(SubFileExport, 40, scex(_("FEX|Ll#l#L")));
        fl_setpup_shortcut(SubFileExport, 41, scex(_("FEX|Dd#d#D")));
@@ -589,20 +602,14 @@ void Menus::ShowFileMenu(FL_OBJECT *ob, long)
        fl_setpup_shortcut(FileMenu, 17, scex(_("FM|xX#x#X")));
 
        // make the lastfiles menu
-       LastFiles_Iter liter(*lastfiles); // :-)
-       string filname;
        int ii = 1;
-       while( ii < 10 && !(filname = liter()).empty() ) {
-               string tmp;
-               string tmp2;
-               string relbuf = MakeDisplayPath(filname,30);
-               tmp += tostr(ii);
-               tmp2 = tmp;
-               tmp += ". " + relbuf;
-               tmp2 += string("#") + tostr(ii);
+       for (LastFiles::Files::const_iterator cit = lastfiles->begin();
+            cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
+               string tmp = tostr(ii);
+               string tmp2 = tmp + "#" + tmp;;
+               tmp += ". " + MakeDisplayPath((*cit), 30);
                fl_addtopup(FileMenu, tmp.c_str());
                fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
-               ii++;
        }
 
        // place popup
@@ -665,7 +672,9 @@ void Menus::ShowFileMenu(FL_OBJECT *ob, long)
                // Lastfiles:
        case 18: // The first item with lastfiles.
        default:
-               men->currentView()->setBuffer(bufferlist.loadLyXFile(liter[choice-18])); // ok one more
+               men->currentView()
+                       ->setBuffer(bufferlist
+                                   .loadLyXFile((*lastfiles)[choice - 18]));
                break;
        }
        fl_freepup(SubFileImport);
@@ -676,9 +685,9 @@ void Menus::ShowFileMenu(FL_OBJECT *ob, long)
 }
 
 
-void Menus::ShowFileMenu2(FL_OBJECT *ob, long)
+void Menus::ShowFileMenu2(FL_OBJECT * ob, long)
 {
-       Menus *men = (Menus*) ob->u_ldata;
+       Menus * men = static_cast<Menus*>(ob->u_vdata);
 
        // Regarding the pseudo-menu-button:
        // ok, ok this is a hack. It would be better to use the menus of the
@@ -693,7 +702,7 @@ void Menus::ShowFileMenu2(FL_OBJECT *ob, long)
        fl_set_button(ob, 0);
        fl_redraw_object(ob);
 
-       LyXFunc *tmpfunc = men->_view->getLyXFunc();
+       LyXFunc * tmpfunc = men->_view->getLyXFunc();
 
        // Import sub-menu
        
@@ -703,6 +712,7 @@ void Menus::ShowFileMenu2(FL_OBJECT *ob, long)
                                       "|Ascii Text as Lines...%x16"
                                       "|Ascii Text as Paragraphs...%x17"
                                       "|Noweb...%x18"));
+       
        fl_setpup_shortcut(SubFileImport, 15, scex(_("FIM|Ll#l#L")));
        fl_setpup_shortcut(SubFileImport, 16, scex(_("FIM|Aa#a#A")));
        fl_setpup_shortcut(SubFileImport, 17, scex(_("FIM|Pp#p#P")));
@@ -722,6 +732,7 @@ void Menus::ShowFileMenu2(FL_OBJECT *ob, long)
                                 "|Open...%l"
                                 "|Import%m%l"
                                 "|Exit%l"), SubFileImport);
+       
        fl_setpup_shortcut(FileMenu, 1, scex(_("FM|Nn#n#N")));
        fl_setpup_shortcut(FileMenu, 2, scex(_("FM|tT#t#T")));
        fl_setpup_shortcut(FileMenu, 3, scex(_("FM|Oo#o#O")));
@@ -729,20 +740,14 @@ void Menus::ShowFileMenu2(FL_OBJECT *ob, long)
        fl_setpup_shortcut(FileMenu, 5, scex(_("FM|xX#x#X")));
        
        // make the lastfiles menu
-       LastFiles_Iter liter(*lastfiles); // :-)
-       string filname;
        int ii = 1;
-       while( ii < 10 && !(filname = liter()).empty() ) {
-               string tmp;
-               string tmp2;
-               string relbuf = MakeDisplayPath(filname,30);
-               tmp += tostr(ii);
-               tmp2 = tmp;
-               tmp += ". " + relbuf;
-               tmp2 += string("#") + tostr(ii);
+       for (LastFiles::Files::const_iterator cit = lastfiles->begin();
+            cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
+               string tmp = tostr(ii);
+               string tmp2 = tmp + "#" + tmp;;
+               tmp += ". " + MakeDisplayPath((*cit), 30);
                fl_addtopup(FileMenu, tmp.c_str());
-               fl_setpup_shortcut(FileMenu, 6 - 1 + ii, tmp2.c_str());
-               ii++;
+               fl_setpup_shortcut(FileMenu, 18 - 1 + ii, tmp2.c_str());
        }
 
        // place popup
@@ -781,8 +786,11 @@ void Menus::ShowFileMenu2(FL_OBJECT *ob, long)
                tmpfunc->Dispatch(LFUN_QUIT);
                break;
                // Lastfiles:
+       case 6: // The first item with lastfiles.
        default:
-               men->currentView()->setBuffer(bufferlist.loadLyXFile(liter[choice-6]));
+               men->currentView()
+                       ->setBuffer(bufferlist
+                                   .loadLyXFile((*lastfiles)[choice - 6]));
                break;
        }
 
@@ -793,17 +801,17 @@ void Menus::ShowFileMenu2(FL_OBJECT *ob, long)
 }
 
 
-void Menus::ShowEditMenu(FL_OBJECT *ob, long)
+void Menus::ShowEditMenu(FL_OBJECT * ob, long)
 {
-       Menus *men = (Menus*) ob->u_ldata;
+       Menus * men = static_cast<Menus*>(ob->u_vdata);
        
        // set the pseudo menu-button
        fl_set_object_boxtype(ob, FL_UP_BOX);
        fl_set_button(ob, 0);
        fl_redraw_object(ob);
 
-       Buffer *tmpbuffer = men->_view->currentBuffer();
-       LyXFunc *tmpfunc = men->_view->getLyXFunc();
+       Buffer * tmpbuffer = men->_view->currentBuffer();
+       LyXFunc * tmpfunc = men->_view->getLyXFunc();
 
        // Floats & Insets submenu
        int SubEditFloats=fl_defpup(FL_ObjWin(ob),
@@ -814,8 +822,8 @@ void Menus::ShowEditMenu(FL_OBJECT *ob, long)
                                    "|Close All Footnotes/Margin Notes%x24"
                                    "|Open All Figures/Tables%x25"
                                    "|Close All Figures/Tables%x26%l"
-                                   "|Remove all Error Boxes%x27")
-               );
+                                   "|Remove all Error Boxes%x27"));
+       
        fl_setpup_shortcut(SubEditFloats, 21, scex(_("EMF|Oo#o#O")));
        fl_setpup_shortcut(SubEditFloats, 22, scex(_("EMF|Mm#m#M")));
        fl_setpup_shortcut(SubEditFloats, 23, scex(_("EMF|Aa#a#A")));
@@ -1115,9 +1123,9 @@ void Menus::ShowEditMenu(FL_OBJECT *ob, long)
 }
 
 
-void Menus::ShowLayoutMenu(FL_OBJECT *ob, long)
+void Menus::ShowLayoutMenu(FL_OBJECT * ob, long)
 {
-       Menus *men = (Menus*) ob->u_ldata;
+       Menus * men = static_cast<Menus*>(ob->u_vdata);
 
        if (!men->currentView()->available())
                return;
@@ -1127,8 +1135,8 @@ void Menus::ShowLayoutMenu(FL_OBJECT *ob, long)
        fl_set_button(ob, 0);
        fl_redraw_object(ob);
    
-       Buffer *tmpbuffer = men->_view->currentBuffer();
-       LyXFunc *tmpfunc = men->_view->getLyXFunc();
+       Buffer * tmpbuffer = men->_view->currentBuffer();
+       LyXFunc * tmpfunc = men->_view->getLyXFunc();
 
        int LayoutMenu = fl_newpup(FL_ObjWin(ob));
        fl_addtopup(LayoutMenu, _("Character..."
@@ -1202,33 +1210,29 @@ void Menus::ShowLayoutMenu(FL_OBJECT *ob, long)
        case 10: tmpfunc->Dispatch(LFUN_TEX); break;
        case 11: tmpfunc->Dispatch(LFUN_DEPTH_PLUS); break;
        case 12: tmpfunc->Dispatch(LFUN_LAYOUT_PREAMBLE); break;
-       case 13: tmpfunc->Dispatch(LFUN_LAYOUT_SAVE_DEFAULT); break;//MenuLayoutSave(); break;
+       case 13: tmpfunc->Dispatch(LFUN_LAYOUT_SAVE_DEFAULT); break;
        }
        fl_freepup(LayoutMenu); 
 }
 
 
-void Menus::ShowInsertMenu(FL_OBJECT *ob, long /*data*/)
+void Menus::ShowInsertMenu(FL_OBJECT * ob, long)
 {
-       Menus *men = (Menus*) ob->u_ldata;
+       Menus * men = static_cast<Menus*>(ob->u_vdata);
        
        // set the pseudo menu-button
        fl_set_object_boxtype(ob, FL_UP_BOX);
        fl_set_button(ob, 0);
        fl_redraw_object(ob);
  
-       Buffer *tmpbuffer = men->_view->currentBuffer();
-       LyXFunc *tmpfunc = men->_view->getLyXFunc();
-
-#if 0
-       // Is textclass LinuxDoc?
-       bool LinuxDoc = tmpbuffer->isLinuxDoc();
-#endif
+       Buffer * tmpbuffer = men->_view->currentBuffer();
+       LyXFunc * tmpfunc = men->_view->getLyXFunc();
 
        int SubInsertAscii = fl_defpup(FL_ObjWin(ob),
                                       _("Import ASCII file%t"
                                       "|As Lines%x41"
                                       "|As Paragraphs%x42"));
+       
        fl_setpup_shortcut(SubInsertAscii, 41, scex(_("IMA|Ll#l#L")));
        fl_setpup_shortcut(SubInsertAscii, 42, scex(_("IMA|Pp#p#P")));
 
@@ -1239,7 +1243,8 @@ void Menus::ShowInsertMenu(FL_OBJECT *ob, long /*data*/)
                                           "|List of Tables%x23"
                                           "|List of Algorithms%x24"
                                           "|Index List%x25"
-                                          "|BibTeX Reference%x26"));      
+                                          "|BibTeX Reference%x26"));
+       
        fl_setpup_shortcut(SubInsertTableList, 21, scex(_("IMT|Cc#c#C")));
        fl_setpup_shortcut(SubInsertTableList, 22, scex(_("IMT|Ff#f#F")));
        fl_setpup_shortcut(SubInsertTableList, 23, scex(_("IMT|Tt#t#T")));
@@ -1247,30 +1252,21 @@ void Menus::ShowInsertMenu(FL_OBJECT *ob, long /*data*/)
        fl_setpup_shortcut(SubInsertTableList, 25, scex(_("IMT|Ii#i#I")));
        fl_setpup_shortcut(SubInsertTableList, 26, scex(_("IMT|Bb#b#B")));
 
-       int SubInsertFloatList;
-       //if (men->_view->currentBuffer()->params.columns == 1) {
-       // SubInsertFloatList = fl_defpup(FL_ObjWin(ob),
-       //                               _("Floats%t"
-       //                                 "|Figure Float%x71"
-       //                                 "|Table Float%l%x72"
-       //                                 "|Algorithm Float%x73"));
-       //}
-       //else {
-         SubInsertFloatList = fl_defpup(FL_ObjWin(ob),
-                                        _("Floats%t"
-                                          "|Figure Float%x71"
-                                          "|Table Float%x72"
-                                          "|Wide Figure Float%x73"
-                                          "|Wide Table Float%l%x74"
-                                          "|Algorithm Float%x75"));
-         //}
+       int SubInsertFloatList = fl_defpup(FL_ObjWin(ob),
+                                      _("Floats%t"
+                                        "|Figure Float%x71"
+                                        "|Table Float%x72"
+                                        "|Wide Figure Float%x73"
+                                        "|Wide Table Float%l%x74"
+                                        "|Algorithm Float%x75"));
+       
        fl_setpup_shortcut(SubInsertFloatList, 71, scex(_("IMF|gG#g#G")));
        fl_setpup_shortcut(SubInsertFloatList, 72, scex(_("IMF|Tt#t#T")));
        fl_setpup_shortcut(SubInsertFloatList, 73, scex(_("IMF|Ww#w#W")));
        fl_setpup_shortcut(SubInsertFloatList, 74, scex(_("IMF|iI#i#I")));
        fl_setpup_shortcut(SubInsertFloatList, 75, scex(_("IMF|Aa#a#A")));
        
-       int SubInsertSpecial=fl_defpup(FL_ObjWin(ob),
+       int SubInsertSpecial = fl_defpup(FL_ObjWin(ob),
                                       _("Special Character%t"
                                         "|HFill%x31"
                                         "|Hyphenation Point%x32"
@@ -1329,25 +1325,13 @@ void Menus::ShowInsertMenu(FL_OBJECT *ob, long /*data*/)
        fl_setpup_shortcut(InsertMenu, 15, scex(_("IM|dD#d#D")));
        fl_setpup_shortcut(InsertMenu, 16, scex(_("IM|wW#w#W")));
 
-#if 0
-       if (LinuxDoc) {
-               /* for linuxdoc sgml */
-#endif
-               fl_addtopup(InsertMenu, _("|URL..."));
-               fl_setpup_shortcut(InsertMenu, 17, scex(_("IM|Uu#u#U")));
-#if 0
-       }      
-#endif
+       fl_addtopup(InsertMenu, _("|URL..."));
+       fl_setpup_shortcut(InsertMenu, 17, scex(_("IM|Uu#u#U")));
+
        if (tmpbuffer->isReadonly()) {
                 for (int ii = 1; ii <= 16; ii++)
                        fl_setpup_mode(InsertMenu, ii, FL_PUP_GREY);
-#if 0
-                if (LinuxDoc) {
-#endif
-                        fl_setpup_mode(InsertMenu, 17, FL_PUP_GREY);
-#if 0
-                }
-#endif
+               fl_setpup_mode(InsertMenu, 17, FL_PUP_GREY);
        }
 
        fl_setpup_position(
@@ -1433,19 +1417,19 @@ void Menus::ShowInsertMenu(FL_OBJECT *ob, long /*data*/)
 }
 
 
-void Menus::ShowMathMenu(FL_OBJECT *ob, long)
+void Menus::ShowMathMenu(FL_OBJECT * ob, long)
 {
-       extern void math_insert_symbol(char const* s);
+       extern void math_insert_symbol(char const * s);
 
-       Menus *men = (Menus*) ob->u_ldata;
+       Menus * men = static_cast<Menus*>(ob->u_vdata);
 
        // set the pseudo menu-button
        fl_set_object_boxtype(ob, FL_UP_BOX);
        fl_set_button(ob, 0);
        fl_redraw_object(ob);
 
-       Buffer *tmpbuffer = men->_view->currentBuffer();
-       LyXFunc *tmpfunc = men->_view->getLyXFunc();
+       Buffer * tmpbuffer = men->_view->currentBuffer();
+       LyXFunc * tmpfunc = men->_view->getLyXFunc();
 
        int MathMenu = fl_defpup(FL_ObjWin(ob), 
                                 _("Fraction"
@@ -1519,9 +1503,9 @@ void Menus::ShowMathMenu(FL_OBJECT *ob, long)
 }
 
 
-void Menus::ShowOptionsMenu(FL_OBJECT *ob, long)
+void Menus::ShowOptionsMenu(FL_OBJECT * ob, long)
 {
-       Menus *men = (Menus*) ob->u_ldata;
+       Menus * men = static_cast<Menus*>(ob->u_vdata);
 
        // set the pseudo menu-button
        fl_set_object_boxtype(ob, FL_UP_BOX);
@@ -1529,7 +1513,7 @@ void Menus::ShowOptionsMenu(FL_OBJECT *ob, long)
        fl_redraw_object(ob);
 
        //Buffer *tmpbuffer = men->_view->currentBuffer();
-       LyXFunc *tmpfunc = men->_view->getLyXFunc();
+       LyXFunc * tmpfunc = men->_view->getLyXFunc();
 
        int OptionsMenu = fl_defpup(FL_ObjWin(ob),
                                    _("Screen Fonts..."
@@ -1568,9 +1552,9 @@ void Menus::ShowOptionsMenu(FL_OBJECT *ob, long)
 }
 
 
-void Menus::ShowBufferMenu(FL_OBJECT *ob, long)
+void Menus::ShowBufferMenu(FL_OBJECT * ob, long)
 {
-       Menus *men = (Menus*) ob->u_ldata;
+       Menus * men = static_cast<Menus*>(ob->u_vdata);
        
        // set the pseudo menu-button
        fl_set_object_boxtype(ob, FL_UP_BOX);
@@ -1596,14 +1580,14 @@ void Menus::ShowBufferMenu(FL_OBJECT *ob, long)
 
 
 static
-char const *doc_files [] = {"Intro", "Tutorial", 
-                           "UserGuide", "Extended",
-                           "Customization", "Reference",
-                           "BUGS", "LaTeXConfig"}; 
+char const * doc_files [] = {"Intro", "Tutorial", 
+                            "UserGuide", "Extended",
+                            "Customization", "Reference",
+                            "BUGS", "LaTeXConfig"}; 
 
-void Menus::ShowHelpMenu(FL_OBJECT *ob, long)
+void Menus::ShowHelpMenu(FL_OBJECT * ob, long)
 {
-       Menus *men = (Menus*) ob->u_ldata;
+       Menus * men = static_cast<Menus*>(ob->u_vdata);
 
        // set the pseudo menu-button
        fl_set_object_boxtype(ob, FL_UP_BOX);
@@ -1669,7 +1653,7 @@ void Menus::ShowHelpMenu(FL_OBJECT *ob, long)
 }
 
 
-void Menus::MenuDocu(string const &docname) 
+void Menus::MenuDocu(string const & docname) 
 {
        string fname = i18nLibFileSearch("doc", docname, "lyx");
        _view->getMiniBuffer()->Set(_("Opening help file"),
index ea982871803c09b1940c228aa73e7e7fa6962f73..c9b50aa40684c391903fde58f6affaa7f6348f1b 100644 (file)
@@ -3,7 +3,7 @@
  * 
  *           LyX, The Document Processor
  *      
- *         Copyright 1995 Matthias Ettrich
+ *           Copyright 1995 Matthias Ettrich
  *           Copyright 1995-1999 The LyX Team. 
  *
  * ======================================================*/
 #include "lyx_gui_misc.h"
 #include "texrow.h"
 
+#ifndef NEW_TEXT
 #define INITIAL_SIZE_PAR 10 /*Number of bytes in one paragraph*/
 #define STEP_SIZE_PAR 10 /*Number of bytes added when reallocated*/
+#endif
 
 extern void addNewlineAndDepth(string & file, int const depth); // Jug 990923
 extern unsigned char GetCurrentTextClass(); // this should be fixed/removed
 int tex_code_break_column = 72;  // needs non-zero initialization. set later.
 // this is a bad idea, but how can LyXParagraph find its buffer to get
 // parameters? (JMarc)
-extern BufferView *current_view;
-extern LyXRC *lyxrc;
+extern BufferView * current_view;
+extern LyXRC * lyxrc;
 
 
 // ale970405
@@ -45,7 +47,7 @@ extern string bibitemWidthest();
 /* this is a minibuffer */
 static char minibuffer_char;
 static LyXFont minibuffer_font;
-static Inset *minibuffer_inset;
+static Inset * minibuffer_inset;
 
 
 // Initialization of the counter for the paragraph id's,
@@ -55,17 +57,21 @@ unsigned int LyXParagraph::paragraph_id = 0;
 
 LyXParagraph::LyXParagraph()
 {
+#ifndef NEW_TEXT
        size = INITIAL_SIZE_PAR;
-       last = 0;
        text = new char[size];
-       for (int i=0; i<10; i++) setCounter(i , 0);
+       last = 0;
+#endif
+       for (int i = 0; i < 10; ++i) setCounter(i , 0);
        appendix = false;
        enumdepth = 0;
        itemdepth = 0;
        next = 0;
        previous = 0;
+#ifndef NEW_TABLE
        fonttable = 0;
        insettable = 0;
+#endif
        footnoteflag = LyXParagraph::NO_FOOTNOTE;
 
        align = LYX_ALIGN_BLOCK;
@@ -80,12 +86,14 @@ LyXParagraph::LyXParagraph()
 
 
 /* this konstruktor inserts the new paragraph in a list */ 
-LyXParagraph::LyXParagraph(LyXParagraph *par)
+LyXParagraph::LyXParagraph(LyXParagraph * par)
 {
+#ifndef NEW_TEXT
        size = INITIAL_SIZE_PAR;
-       last = 0;
        text = new char[size];
-       for (int i=0; i<10; i++) setCounter(i, 0);
+       last = 0;
+#endif
+       for (int i = 0; i < 10; ++i) setCounter(i, 0);
        appendix = false;
        enumdepth = 0;
        itemdepth = 0;
@@ -94,8 +102,10 @@ LyXParagraph::LyXParagraph(LyXParagraph *par)
                next->previous = this;
        previous = par;
        previous->next = this;
+#ifndef NEW_TABLE
        fonttable = 0;
        insettable = 0;
+#endif
        footnoteflag = LyXParagraph::NO_FOOTNOTE;
        footnotekind = LyXParagraph::FOOTNOTE;
        
@@ -105,17 +115,16 @@ LyXParagraph::LyXParagraph(LyXParagraph *par)
        id = paragraph_id++;
 
         bibkey = 0; // ale970302        
-        // ale970302
-//        lyxerr << "new bib " << endl;
-//        if (par->bibkey) {
-//         bibkey = new InsetBibKey(par->bibkey);
-//        }
     
        Clear();
 }
 
 /// Used by the spellchecker
-bool LyXParagraph::IsLetter(int pos){
+#ifdef NEW_TEXT
+bool LyXParagraph::IsLetter(LyXParagraph::size_type pos) {
+#else
+bool LyXParagraph::IsLetter(int pos) {
+#endif
        unsigned char c = GetChar(pos);
        if (IsLetterChar(c))
                return true;
@@ -131,11 +140,11 @@ bool LyXParagraph::IsLetter(int pos){
 }
 
 
-void LyXParagraph::writeFile(FILE *file, BufferParams &params,
+void LyXParagraph::writeFile(FILE * file, BufferParams & params,
                             char footflag, char dth)
 {
        LyXFont font1, font2;
-       Inset *inset;
+       Inset * inset;
        int column = 0;
        int h = 0;
        char c = 0;
@@ -174,7 +183,8 @@ void LyXParagraph::writeFile(FILE *file, BufferParams &params,
 
                /* First write the layout */ 
                fprintf(file, "\n\\layout %s\n",
-                       lyxstyle.NameOfLayout(params.textclass,layout).c_str());
+                       textclasslist.NameOfLayout(params.textclass,layout)
+                       .c_str());
 
                /* maybe some vertical spaces */ 
                if (added_space_top.kind() != VSpace::NONE)
@@ -228,14 +238,17 @@ void LyXParagraph::writeFile(FILE *file, BufferParams &params,
                                        fprintf(file, " \\pextra_hfill %d",
                                                pextra_hfill);
                                if (pextra_start_minipage)
-                                       fprintf(file, " \\pextra_start_minipage %d",
+                                       fprintf(file,
+                                               " \\pextra_start_minipage %d",
                                                pextra_start_minipage);
                         }
                         if (!pextra_width.empty()) {
                                fprintf(file, " \\pextra_width %s",
-                                        VSpace(pextra_width).asLyXCommand().c_str());
+                                        VSpace(pextra_width)
+                                       .asLyXCommand().c_str());
                         } else if (!pextra_widthp.empty()) {
-                               fprintf(file, " \\pextra_widthp %s",pextra_widthp.c_str());
+                               fprintf(file, " \\pextra_widthp %s",
+                                       pextra_widthp.c_str());
                         }
                         fprintf(file,"\n");
                 }
@@ -259,12 +272,20 @@ void LyXParagraph::writeFile(FILE *file, BufferParams &params,
        font1 = LyXFont(LyXFont::ALL_INHERIT);
 
        column = 0;
+#ifdef NEW_TEXT
+       for (size_type i = 0; i < size(); i++) {
+               if (!i){
+                       fprintf(file, "\n");
+                       column = 0;
+               }
+#else
        for (int i = 0; i < last; i++) {
                if (!i){
                        fprintf(file, "\n");
                        column = 0;
                }
-
+#endif
+               
                // Write font changes
                font2 = GetFontSettings(i);
                if (font2 != font1) {
@@ -308,11 +329,19 @@ void LyXParagraph::writeFile(FILE *file, BufferParams &params,
                        column = 0;
                        break;
                case '.':
+#ifdef NEW_TEXT
+                       if (i + 1 < size() && GetChar(i + 1) == ' ') {
+                               fprintf(file, ".\n");
+                               column = 0;
+                       } else
+                               fprintf(file, ".");
+#else
                        if (i + 1 < last && GetChar(i + 1) == ' ') {
                                fprintf(file, ".\n");
                                column = 0;
                        } else
                                fprintf(file, ".");
+#endif
                        break;
                default:
                        if ((column > 70 && c==' ')
@@ -338,10 +367,10 @@ void LyXParagraph::writeFile(FILE *file, BufferParams &params,
 }
 
 
-void LyXParagraph::validate(LaTeXFeatures &features)
+void LyXParagraph::validate(LaTeXFeatures & features)
 {
        // this will be useful later
-       LyXLayout *layout = lyxstyle.Style(GetCurrentTextClass(), 
+       LyXLayout const & layout = textclasslist.Style(GetCurrentTextClass(), 
                                           GetLayout());
        
        // check the params.
@@ -351,8 +380,32 @@ void LyXParagraph::validate(LaTeXFeatures &features)
        // then the layouts
        features.layout[GetLayout()] = true;
 
+#ifdef NEW_TABLE
+       for (FontList::const_iterator cit = fontlist.begin();
+            cit != fontlist.end(); ++cit) {
+               if ((*cit).font.noun() == LyXFont::ON) {
+                       lyxerr[Debug::LATEX] << "font.noun: "
+                                            << (*cit).font.noun()
+                                            << endl;
+                       features.noun = true;
+                       lyxerr[Debug::LATEX] << "Noun enabled. Font: "
+                                            << (*cit).font.stateText()
+                                            << endl;
+               }
+               switch ((*cit).font.color()) {
+               case LyXFont::NONE:
+               case LyXFont::INHERIT_COLOR:
+               case LyXFont::IGNORE_COLOR:  break;
+               default:
+                       features.color = true;
+                       lyxerr[Debug::LATEX] << "Color enabled. Font: "
+                                            << (*cit).font.stateText()
+                                            << endl;
+               }
+       }
+#else
        // then the fonts
-       FontTable *tmpfonttable = fonttable;
+       FontTable * tmpfonttable = fonttable;
        while (tmpfonttable) {
                if (tmpfonttable->font.noun() == LyXFont::ON) {
                        lyxerr[Debug::LATEX] << "font.noun: " 
@@ -376,22 +429,29 @@ void LyXParagraph::validate(LaTeXFeatures &features)
                }
                tmpfonttable = tmpfonttable->next;
        }
-       
+#endif
+#ifdef NEW_TABLE
+       for (InsetList::const_iterator cit = insetlist.begin();
+            cit != insetlist.end(); ++cit) {
+               (*cit).inset->Validate(features);
+       }
+#else
        // then the insets
-       InsetTable *tmpinsettable = insettable;
+       InsetTable * tmpinsettable = insettable;
        while (tmpinsettable) {
                if (tmpinsettable->inset) {
                        tmpinsettable->inset->Validate(features);
                }
                tmpinsettable = tmpinsettable->next;
        }
+#endif
         if (table && table->IsLongTable())
                features.longtable = true;
         if (pextra_type == PEXTRA_INDENT)
                 features.LyXParagraphIndent = true;
         if (pextra_type == PEXTRA_FLOATFLT)
                 features.floatflt = true;
-        if (layout->needprotect 
+        if (layout.needprotect 
            && next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
                features.NeedLyXFootnoteCode = true;
         if ((current_view->currentBuffer()->params.paragraph_separation == LYX_PARSEP_INDENT) &&
@@ -405,7 +465,11 @@ void LyXParagraph::validate(LaTeXFeatures &features)
 
 
 /* first few functions needed for cut and paste and paragraph breaking */
+#ifdef NEW_TEXT
+void LyXParagraph::CopyIntoMinibuffer(LyXParagraph::size_type pos)
+#else 
 void LyXParagraph::CopyIntoMinibuffer(int pos)
+#endif
 {
        minibuffer_char = GetChar(pos);
        minibuffer_font = GetFontSettings(pos);
@@ -421,8 +485,11 @@ void LyXParagraph::CopyIntoMinibuffer(int pos)
        }
 }
 
-
+#ifdef NEW_TEXT
+void LyXParagraph::CutIntoMinibuffer(LyXParagraph::size_type pos)
+#else
 void LyXParagraph::CutIntoMinibuffer(int pos)
+#endif
 {
        minibuffer_char = GetChar(pos);
        minibuffer_font = GetFontSettings(pos);
@@ -430,18 +497,27 @@ void LyXParagraph::CutIntoMinibuffer(int pos)
        if (minibuffer_char == LYX_META_INSET) {
                if (GetInset(pos)) {
                        minibuffer_inset = GetInset(pos);
-                       /* This is a little hack since I want exactly the inset,
-                          not just a clone. Otherwise the inset would be deleted
-                          when calling Erase(pos) */
-                       
+                       // This is a little hack since I want exactly
+                       // the inset, not just a clone. Otherwise
+                       // the inset would be deleted when calling Erase(pos)
+#ifdef NEW_TABLE
+                       for (InsetList::iterator it = insetlist.begin();
+                            it != insetlist.end(); ++it) {
+                               if ((*it).pos == pos) {
+                                       (*it).inset = 0;
+                                       break;
+                               }
+                       }
+#else
                        /* find the entry */ 
-                       InsetTable *tmpi = insettable;
+                       InsetTable * tmpi = insettable;
                        while (tmpi && tmpi->pos != pos) {
                                tmpi=tmpi->next;
                        }
                        if (tmpi) {  /* This should always be true */
                                tmpi->inset = 0;
                        }
+#endif
                } else {
                        minibuffer_inset = 0;
                        minibuffer_char = ' ';
@@ -454,7 +530,11 @@ void LyXParagraph::CutIntoMinibuffer(int pos)
 }
 
 
+#ifdef NEW_TEXT
+void LyXParagraph::InsertFromMinibuffer(LyXParagraph::size_type pos)
+#else
 void LyXParagraph::InsertFromMinibuffer(int pos)
+#endif
 {
        InsertChar(pos, minibuffer_char);
        SetFont(pos, minibuffer_font);
@@ -505,10 +585,13 @@ LyXParagraph::~LyXParagraph()
        if (next)
                next->previous = previous;
 
+#ifndef NEW_TEXT
        if (text)
                delete[] text;
-   
-       InsetTable *tmpinset;
+#endif
+
+#ifndef NEW_TABLE
+       InsetTable * tmpinset;
        while (insettable) {
                tmpinset = insettable;
                insettable = insettable->next;
@@ -527,12 +610,13 @@ LyXParagraph::~LyXParagraph()
                }
        }
 
-       FontTable *tmpfont;
+       FontTable * tmpfont;
        while (fonttable) {
                tmpfont = fonttable;
                fonttable = fonttable->next;
                delete tmpfont;
        }
+#endif
 
        /* table stuff -- begin*/ 
        if (table)
@@ -545,12 +629,24 @@ LyXParagraph::~LyXParagraph()
 }
 
 
+#ifdef NEW_TEXT
+void LyXParagraph::Erase(LyXParagraph::size_type pos)
+#else
 void LyXParagraph::Erase(int pos)
+#endif
 {
-       int i;
-
        /* > because last is the next unused position, and you can 
         * use it if you want  */
+#ifdef NEW_TEXT
+       if (pos > size()) {
+               if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+                       NextAfterFootnote()->Erase(pos - text.size() - 1);
+               else 
+                       lyxerr.debug() << "ERROR (LyXParagraph::Erase): "
+                               "position does not exist." << endl;
+               return;
+       }
+#else
        if (pos > last) {
                if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
                        NextAfterFootnote()->Erase(pos - last - 1);
@@ -559,8 +655,26 @@ void LyXParagraph::Erase(int pos)
                                "position does not exist." << endl;
                return;
        }
+#endif
+#ifdef NEW_TEXT
+       if (pos < size()) { // last is free for insertation, but should be empty
+#else
        if (pos < last) { // last is free for insertation, but should be empty
-      
+#endif
+#ifdef NEW_TABLE
+               /* if it is an inset, delete the inset entry */ 
+               if (text[pos] == LYX_META_INSET) {
+                       /* find the entry */
+                       for(InsetList::iterator it = insetlist.begin();
+                           it != insetlist.end(); ++it) {
+                               if ((*it).pos == pos) {
+                                       delete (*it).inset;
+                                       insetlist.erase(it);
+                                       break;
+                               }
+                       }
+               }
+#else
                /* if it is an inset, delete the inset entry */ 
                if (text[pos] == LYX_META_INSET) {
                        /* find the entry */ 
@@ -580,17 +694,48 @@ void LyXParagraph::Erase(int pos)
                                delete tmpi;
                        }
                }
-
+#endif
+#ifdef NEW_TEXT
+               text.erase(text.begin() + pos);
+#else
                // Shift rest of text      
-               for (i = pos; i < last - 1; i++) {
+               for (int i = pos; i < last - 1; i++) {
                        text[i]=text[i+1];
                }
                last--;
+#endif
+#ifdef NEW_TABLE
+               /* erase entries in the tables */
+               for(FontList::iterator it = fontlist.begin();
+                   it != fontlist.end(); ++it) {
+                       if (pos >= (*it).pos && pos <= (*it).pos_end) {
+                               if ((*it).pos == (*it).pos_end) {
+                                       fontlist.erase(it);
+                                       break;
+                               }
+                       }
+               }
 
+               /* update all other entries */
+               for(FontList::iterator it = fontlist.begin();
+                   it != fontlist.end(); ++it) {
+                       if ((*it).pos > pos)
+                               (*it).pos--;
+                       if ((*it).pos_end >= pos)
+                               (*it).pos_end--;
+               }
+      
+               /* update the inset table */
+               for(InsetList::iterator it = insetlist.begin();
+                   it != insetlist.end(); ++it) {
+                       if ((*it).pos > pos)
+                               (*it).pos--;
+               }
+#else
                /* erase entries in the tables */ 
                int found = 0;
-               FontTable *tmp = fonttable;
-               FontTable *prev = 0;
+               FontTable * tmp = fonttable;
+               FontTable * prev = 0;
                while (tmp && !found) {
                        if (pos >= tmp->pos && pos <= tmp->pos_end)
                                found = 1;
@@ -624,13 +769,13 @@ void LyXParagraph::Erase(int pos)
                }
       
                /* update the inset table */ 
-               InsetTable *tmpi = insettable;
+               InsetTable * tmpi = insettable;
                while (tmpi) {
                        if (tmpi->pos > pos)
                                tmpi->pos--;
                        tmpi=tmpi->next;
                }
-      
+#endif      
        } else {
                lyxerr << "ERROR (LyXParagraph::Erase): "
                        "can't erase non-existant char." << endl;
@@ -638,12 +783,11 @@ void LyXParagraph::Erase(int pos)
 }
 
 
+#ifndef NEW_TEXT
 /* pos is needed to specify the paragraph correctly. Remember the
 * closed footnotes */ 
 void LyXParagraph::Enlarge(int pos, int number)
 {
-       int i;
-
        /* > because last is the next unused position, and you can 
         * use it if you want  */
        if (pos > last) {
@@ -657,67 +801,100 @@ void LyXParagraph::Enlarge(int pos, int number)
 
        if (size - last < number) {
                size += number - size + last + STEP_SIZE_PAR;
-               char *tmp = new char[size];
-               for (i = 0; i < last; i++)
+               char * tmp = new char[size];
+               for (int i = 0; i < last; ++i)
                        tmp[i] = text[i];
                delete[] text;
                text = tmp;
        }
 }
+#endif
 
 
+#ifndef NEW_TEXT
 /* make the allocated memory fit to the needed size */
 /* used to make a paragraph smaller */
 void LyXParagraph::FitSize()
 {
-       int i;
-  
        if (size - last > STEP_SIZE_PAR) {
                size = last + STEP_SIZE_PAR;
-               char *tmp = new char[size];
-               for (i = 0; i < last; i++)
+               char * tmp = new char[size];
+               for (int i = 0; i < last; ++i)
                        tmp[i] = text[i];
                delete[] text;
                text = tmp;
        }
 }
+#endif
 
-
+#ifdef NEW_TEXT
+void LyXParagraph::InsertChar(LyXParagraph::size_type pos, char c)
+#else
 void LyXParagraph::InsertChar(int pos, char c)
+#endif
 {
-       register int i;
-   
+#ifdef NEW_TEXT
+       /* > because last is the next unused position, and you can 
+        * use it if you want  */
+       if (pos > size()) {
+               if (next
+                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+                       NextAfterFootnote()->InsertChar(pos - text.size() - 1,
+                                                       c);
+               else 
+                       lyxerr.debug() << "ERROR (LyXParagraph::InsertChar): "
+                               "position does not exist." << endl;
+               return;
+       }
+       text.insert(text.begin() + pos, c);
+#else
        /* > because last is the next unused position, and you can 
         * use it if you want  */
        if (pos > last) {
-               if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+               if (next
+                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
                        NextAfterFootnote()->InsertChar(pos - last - 1, c);
                else 
                        lyxerr.debug() << "ERROR (LyXParagraph::InsertChar): "
                                "position does not exist." << endl;
                return;
        }
-
        // Are we full? If so, enlarge.
        if (last == size) {
                size += STEP_SIZE_PAR;
-               char *tmp = new char[size];
-               for (i = 0; i < last; i++)
+               char * tmp = new char[size];
+               for (int i = 0; i < last; i++)
                        tmp[i] = text[i];
                delete[] text;
                text = tmp;
        }
 
        // Shift rest of character
-       for (i = last; i>pos; i--) {
-               text[i]=text[i-1];
+       for (int i = last; i>pos; i--) {
+               text[i] = text[i - 1];
        }
 
-       text[pos]=c;
+       text[pos] = c;
        last++;
-   
+#endif
+#ifdef NEW_TABLE
+       // update the font table
+       for(FontList::iterator it = fontlist.begin();
+           it != fontlist.end(); ++it) {
+               if ((*it).pos >= pos)
+                       (*it).pos++;
+               if ((*it).pos_end >= pos)
+                       (*it).pos_end++;
+       }
+       // update the inset table
+       for(InsetList::iterator it = insetlist.begin();
+           it != insetlist.end(); ++it) {
+               if ((*it).pos >= pos)
+                       (*it).pos++;
+       }
+#else
        /* update the font table */ 
-       FontTable *tmp = fonttable;
+       FontTable * tmp = fonttable;
        while (tmp) {
                if (tmp->pos >= pos)
                        tmp->pos++;
@@ -727,59 +904,124 @@ void LyXParagraph::InsertChar(int pos, char c)
        }
    
        /* update the inset table */ 
-       InsetTable *tmpi = insettable;
+       InsetTable * tmpi = insettable;
        while (tmpi) {
                if (tmpi->pos >= pos)
                        tmpi->pos++;
                tmpi=tmpi->next;
        }
+#endif
 }
 
-
-void LyXParagraph::InsertInset(int pos, Inset *inset)
+#ifdef NEW_TEXT
+void LyXParagraph::InsertInset(LyXParagraph::size_type pos,
+                              Inset * inset)
+#else
+void LyXParagraph::InsertInset(int pos, Inset * inset)
+#endif
 {
        /* > because last is the next unused position, and you can 
         * use it if you want  */
+#ifdef NEW_TEXT
+       if (pos > size()) {
+               if (next
+                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+                       NextAfterFootnote()
+                               ->InsertInset(pos - text.size() - 1, inset);
+               else 
+                       lyxerr << "ERROR (LyXParagraph::InsertInset): " 
+                               "position does not exist: " << pos << endl;
+               return;
+       }
+#else
        if (pos > last) {
-               if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
-                       NextAfterFootnote()->InsertInset(pos - last - 1, inset);
+               if (next
+                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+                       NextAfterFootnote()
+                               ->InsertInset(pos - last - 1, inset);
                else 
                        lyxerr << "ERROR (LyXParagraph::InsertInset): " 
                                "position does not exist: " << pos << endl;
                return;
        }
-
-       if (text[pos]!=LYX_META_INSET) {
+#endif
+       if (text[pos] != LYX_META_INSET) {
                lyxerr << "ERROR (LyXParagraph::InsertInset): "
                        "there is no LYX_META_INSET" << endl;
                return;
        }
 
+#ifdef NEW_TABLE
+       if (inset) {
+               InsetTable tmp;
+               tmp.pos = pos;
+               tmp.inset = inset;
+               insetlist.push_back(tmp);
+       }
+               
+#else
        if (inset) {
                /* add a new entry in the inset table */ 
-               InsetTable *tmpi = new InsetTable;
+               InsetTable * tmpi = new InsetTable;
                tmpi->pos = pos;
                tmpi->inset = inset;
                tmpi->next = insettable;
                insettable = tmpi;
        }
+#endif
 }
 
-
-Inset* LyXParagraph::GetInset(int pos)
+#ifdef NEW_TEXT
+Inset * LyXParagraph::GetInset(LyXParagraph::size_type pos)
+#else
+Inset * LyXParagraph::GetInset(int pos)
+#endif
 {
+#ifdef NEW_TEXT
+       if (pos >= size()) {
+               if (next
+                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+                       return NextAfterFootnote()
+                               ->GetInset(pos - text.size() - 1);
+               else { 
+                       lyxerr << "ERROR (LyXParagraph::GetInset): "
+                               "position does not exist: "
+                              << pos << endl;
+               }
+               return 0;
+       }
+#else
        if (pos >= last) {
-               if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+               if (next
+                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
                        return NextAfterFootnote()->GetInset(pos - last - 1);
                else { 
-                       lyxerr << "ERROR (LyXParagraph::GetInset): position does not exist: "
+                       lyxerr << "ERROR (LyXParagraph::GetInset): "
+                               "position does not exist: "
                               << pos << endl;
                }
                return 0;
        }
-
+#endif
+#ifdef NEW_TABLE
+       /* find the inset */
+       for(InsetList::iterator it = insetlist.begin();
+           it != insetlist.end(); ++it) {
+               if ((*it).pos == pos) {
+                       return (*it).inset;
+               }
+       }
+       lyxerr << "ERROR (LyXParagraph::GetInset): "
+               "Inset does not exist: " << pos << endl;
+       text[pos] = ' '; /// WHY!!! does this set the pos to ' '????
+       // Did this commenting out introduce a bug? So far I have not
+       // seen any, please enlighten me. (Lgb)
+       // My guess is that since the inset does not exist, we might
+       // as well replace it with a space to prevent crashes. (Asger)
+       return 0;
+#else
        /* find the inset */ 
-       InsetTable *tmpi = insettable;
+       InsetTable * tmpi = insettable;
 
        while (tmpi && tmpi->pos != pos)
                tmpi = tmpi->next;
@@ -796,27 +1038,80 @@ Inset* LyXParagraph::GetInset(int pos)
                // as well replace it with a space to prevent crashes. (Asger)
                return 0;
        }
+#endif
 }
 
 
 // Gets uninstantiated font setting at position.
 // Optimized after profiling. (Asger)
+#ifdef NEW_TEXT
+LyXFont LyXParagraph::GetFontSettings(LyXParagraph::size_type pos)
+#else
 LyXFont LyXParagraph::GetFontSettings(int pos)
+#endif
 {
+#ifdef NEW_TEXT
+       if (pos < size()) {
+#ifdef NEW_TABLE
+               for(FontList::iterator it = fontlist.begin();
+                   it != fontlist.end(); ++it) {
+                       if (pos >= (*it).pos && pos <= (*it).pos_end)
+                               return (*it).font;
+               }
+#else
+               FontTable * tmp = fonttable;
+               while (tmp) {
+                       if (pos >= tmp->pos && pos <= tmp->pos_end) 
+                               return tmp->font;
+                       tmp = tmp->next;
+               }
+#endif
+       }
+       /* > because last is the next unused position, and you can 
+        * use it if you want  */
+       else if (pos > size()) {
+               if (next
+                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+                       return NextAfterFootnote()
+                               ->GetFontSettings(pos - text.size() - 1);
+               else {
+                       // Why is it an error to ask for the font of a
+                       // position that does not exist? Would it be
+                       // enough for this to be anable on debug?
+                       // We want strict error checking, but it's ok to only
+                       // have it when debugging. (Asger)
+                       lyxerr << "ERROR (LyXParagraph::GetFontSettings): "
+                               "position does not exist. "
+                              << pos << " (" << static_cast<int>(pos)
+                              << ")\n";
+               }
+       } else if (pos) {
+               return GetFontSettings(pos - 1);
+       }
+#else
        if (pos < last) {
-               FontTable *tmp = fonttable;
+#ifdef NEW_TABLE
+               for(FontList::iterator it = fontlist.begin();
+                   it != fontlist.end(); ++it) {
+                       if (pos >= (*it).pos && pos <= (*it).pos_end)
+                               return (*it).font;
+               }
+#else
+               FontTable * tmp = fonttable;
                while (tmp) {
                        if (pos >= tmp->pos && pos <= tmp->pos_end) 
                                return tmp->font;
                        tmp = tmp->next;
                }
+#endif
        }
-
        /* > because last is the next unused position, and you can 
         * use it if you want  */
        else if (pos > last) {
-               if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
-                       return NextAfterFootnote()->GetFontSettings(pos - last - 1);
+               if (next
+                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+                       return NextAfterFootnote()
+                               ->GetFontSettings(pos - last - 1);
                else {
                        // Why is it an error to ask for the font of a
                        // position that does not exist? Would it be
@@ -829,6 +1124,7 @@ LyXFont LyXParagraph::GetFontSettings(int pos)
        } else if (pos) {
                return GetFontSettings(pos - 1);
        }
+#endif
        return LyXFont(LyXFont::ALL_INHERIT);
 }
 
@@ -840,30 +1136,37 @@ LyXFont LyXParagraph::GetFontSettings(int pos)
 // the true picture of the buffer. (Asger)
 // If position is -1, we get the layout font of the paragraph.
 // If position is -2, we get the font of the manual label of the paragraph.
+#ifdef NEW_TEXT
+LyXFont LyXParagraph::getFont(LyXParagraph::size_type pos)
+#else
 LyXFont LyXParagraph::getFont(int pos)
+#endif
 {
        LyXFont tmpfont;
-       LyXLayout *layout = lyxstyle.Style(GetCurrentTextClass(), 
+       LyXLayout const & layout = textclasslist.Style(GetCurrentTextClass(), 
                                           GetLayout());
-   
-       int main_body=0;
-       if (layout->labeltype == LABEL_MANUAL)
+#ifdef NEW_TEXT
+       LyXParagraph::size_type main_body = 0;
+#else
+       int main_body = 0;
+#endif
+       if (layout.labeltype == LABEL_MANUAL)
                main_body = BeginningOfMainBody();
 
        if (pos >= 0){
                LyXFont layoutfont;
                if (pos < main_body)
-                       layoutfont = layout->labelfont;
+                       layoutfont = layout.labelfont;
                else
-                       layoutfont = layout->font;
+                       layoutfont = layout.font;
                tmpfont = GetFontSettings(pos);
                tmpfont.realize(layoutfont);
        } else {
                // process layoutfont for pos == -1 and labelfont for pos < -1
                if (pos == -1)
-                       tmpfont = layout->font;
+                       tmpfont = layout.font;
                else
-                       tmpfont = layout->labelfont;
+                       tmpfont = layout.labelfont;
        }
 
        // check for environment font information
@@ -872,24 +1175,37 @@ LyXFont LyXParagraph::getFont(int pos)
        while (par && par_depth && !tmpfont.resolved()) {
                par = par->DepthHook(par_depth - 1);
                if (par) {
-                       tmpfont.realize(lyxstyle.
+                       tmpfont.realize(textclasslist.
                                        Style(GetCurrentTextClass(),
-                                             par->GetLayout())->font);
+                                             par->GetLayout()).font);
                        par_depth = par->GetDepth();
                }
        }
 
-       tmpfont.realize(lyxstyle.TextClass(GetCurrentTextClass())->defaultfont);
+       tmpfont.realize(textclasslist.TextClass(GetCurrentTextClass()).defaultfont());
        return tmpfont;
 }
 
 
 /// Returns the height of the highest font in range
+#ifdef NEW_TEXT
+LyXFont::FONT_SIZE LyXParagraph::HighestFontInRange(LyXParagraph::size_type startpos, LyXParagraph::size_type endpos) const
+#else
 LyXFont::FONT_SIZE LyXParagraph::HighestFontInRange(int startpos, int endpos) const
+#endif
 {
        LyXFont::FONT_SIZE maxsize = LyXFont::SIZE_TINY;
-
-       FontTable *tmp = fonttable;
+#ifdef NEW_TABLE
+       for(FontList::const_iterator cit = fontlist.begin();
+           cit != fontlist.end(); ++cit) {
+               if (startpos <= (*cit).pos_end && endpos >= (*cit).pos) {
+                       LyXFont::FONT_SIZE size = (*cit).font.size();
+                       if (size > maxsize && size <= LyXFont::SIZE_HUGER)
+                               maxsize = size;
+               }
+       }
+#else
+       FontTable * tmp = fonttable;
        while (tmp) {
                if (startpos <= tmp->pos_end && endpos >= tmp->pos) {
                        LyXFont::FONT_SIZE size = tmp->font.size();
@@ -898,11 +1214,16 @@ LyXFont::FONT_SIZE LyXParagraph::HighestFontInRange(int startpos, int endpos) co
                }
                tmp = tmp->next;
        }
+#endif
        return maxsize;
 }
 
 
+#ifdef NEW_TEXT
+char LyXParagraph::GetChar(LyXParagraph::size_type pos)
+#else
 char LyXParagraph::GetChar(int pos)
+#endif
 {
 #ifdef DEVEL_VERSION
        /* a workaround to 'fix' some bugs in text-class */
@@ -915,10 +1236,27 @@ char LyXParagraph::GetChar(int pos)
        }
 #endif
 
+#ifdef NEW_TEXT
+       if (pos < size()) {
+               return text[pos];
+       }
+       /* > because last is the next unused position, and you can 
+        * use it if you want  */
+       else if (pos > size()) {
+               if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) 
+                       return NextAfterFootnote()
+                               ->GetChar(pos - text.size() - 1);
+               else {
+                       lyxerr << "ERROR (LyXParagraph::GetChar): "
+                               "position does not exist."
+                              << pos << " (" << static_cast<int>(pos)
+                              << ")\n";
+               }
+               return '\0';
+#else
        if (pos < last) {
                return text[pos];
        }
-
        /* > because last is the next unused position, and you can 
         * use it if you want  */
        else if (pos > last) {
@@ -926,14 +1264,16 @@ char LyXParagraph::GetChar(int pos)
                        return NextAfterFootnote()->GetChar(pos - last - 1);
                else 
                        lyxerr << "ERROR (LyXParagraph::GetChar): "
-                               "position does not exist." << endl;
+                               "position does not exist." << pos << endl;
                return '\0';
-       } else { // pos==last
+#endif
+       } else {
                /* we should have a footnote environment */ 
                if (!next || next->footnoteflag == LyXParagraph::NO_FOOTNOTE) {
-// Notice that LyX does request the last char from time to time. (Asger)
-//                     lyxerr << "ERROR (LyXParagraph::GetChar): "
-//                                   "expected footnote." << endl;
+                       // Notice that LyX does request the
+                       // last char from time to time. (Asger)
+                       //lyxerr << "ERROR (LyXParagraph::GetChar): "
+                       //      "expected footnote." << endl;
                        return '\0';
                }
                switch (next->footnotekind) {
@@ -950,28 +1290,16 @@ char LyXParagraph::GetChar(int pos)
                case LyXParagraph::ALGORITHM:
                        return LYX_META_ALGORITHM;
                }
-//             if (next->footnotekind == LyXParagraph::FOOTNOTE)
-//                     return LYX_META_FOOTNOTE;
-//             if (next->footnotekind == LyXParagraph::MARGIN)
-//                     return LYX_META_MARGIN;
-//             if (next->footnotekind == LyXParagraph::FIG)
-//                     return LYX_META_FIG;
-//             if (next->footnotekind == LyXParagraph::TAB)
-//                     return LYX_META_TAB;
-//             if (next->footnotekind == LyXParagraph::ALGORITHM)
-//                     return LYX_META_ALGORITHM;
-//             lyxerr << "ERROR (LyXParagraph::GetChar): "
-//                           "unknown footnote kind." << endl;
-//             return 'F';             /* this should not happen!  */
-               // This _can_ not happen, due to the type of next->footnotekind
-               // being LyXParagraph::footnot_kind
                return '\0'; // to shut up gcc
        }
 }
 
 
+#ifdef NEW_TEXT
+string LyXParagraph::GetWord(LyXParagraph::size_type & lastpos)
+#else
 string LyXParagraph::GetWord(int & lastpos)
-
+#endif
 
   //Added 98/9/21 by REH
   // return an string of the current word, and the end of the word
@@ -1038,56 +1366,127 @@ string LyXParagraph::GetWord(int & lastpos)
 
 }
 
-
+#ifdef NEW_TEXT
+LyXParagraph::size_type LyXParagraph::Last()
+#else 
 int LyXParagraph::Last()
+#endif
 {
+#ifdef NEW_TEXT
        if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
-               return last + NextAfterFootnote()->Last() + 1;   /* the 1 is the symbol
-                                                                 * for the footnote */
+               return text.size() + NextAfterFootnote()->Last() + 1;
+                                                  /* the 1 is the symbol
+                                                     for the footnote */
+       else
+               return text.size();
+#else
+       if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
+               return last + NextAfterFootnote()->Last() + 1;
+                                                 /* the 1 is the symbol
+                                                    for the footnote */
        else
                return last;
+#endif
 }
 
 
-LyXParagraph *LyXParagraph::ParFromPos(int pos)
+#ifdef NEW_TEXT
+LyXParagraph * LyXParagraph::ParFromPos(LyXParagraph::size_type pos)
+#else
+LyXParagraph * LyXParagraph::ParFromPos(int pos)
+#endif
 {
+#ifdef NEW_TEXT
+       /* > because last is the next unused position, and you can 
+        * use it if you want  */
+       if (pos > size()) {
+               if (next
+                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+                       return NextAfterFootnote()
+                               ->ParFromPos(pos - text.size() - 1);
+               else 
+                       lyxerr << "ERROR (LyXParagraph::ParFromPos): "
+                               "position does not exist." << endl;
+               return this;
+       }
+#else
        /* > because last is the next unused position, and you can 
         * use it if you want  */
        if (pos > last) {
-               if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+               if (next
+                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
                        return NextAfterFootnote()->ParFromPos(pos - last - 1);
                else 
                        lyxerr << "ERROR (LyXParagraph::ParFromPos): "
                                "position does not exist." << endl;
                return this;
        }
+#endif
        else
                return this;
 }
 
 
+#ifdef NEW_TEXT
+int LyXParagraph::PositionInParFromPos(LyXParagraph::size_type pos)
+#else
 int LyXParagraph::PositionInParFromPos(int pos)
+#endif
 {
        /* > because last is the next unused position, and you can 
         * use it if you want  */
+#ifdef NEW_TEXT
+       if (pos > size()) {
+               if (next
+                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+                       return NextAfterFootnote()
+                               ->PositionInParFromPos(pos - text.size() - 1);
+               else 
+                       lyxerr <<
+                               "ERROR (LyXParagraph::PositionInParFromPos): "
+                               "position does not exist." << endl;
+               return pos;
+       }
+#else
        if (pos > last) {
-               if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
-                       return NextAfterFootnote()->PositionInParFromPos(pos - last - 1);
+               if (next
+                   && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) 
+                       return NextAfterFootnote()
+                               ->PositionInParFromPos(pos - last - 1);
                else 
                        lyxerr <<
                                "ERROR (LyXParagraph::PositionInParFromPos): "
                                "position does not exist." << endl;
                return pos;
        }
+#endif
        else
                return pos;
 }
 
 
+#ifdef NEW_TEXT
+void LyXParagraph::SetFont(LyXParagraph::size_type pos,
+                          LyXFont const & font)
+#else
 void LyXParagraph::SetFont(int pos, LyXFont const & font)
+#endif
 {
        /* > because last is the next unused position, and you can 
         * use it if you want  */
+#ifdef NEW_TEXT
+       if (pos > size()) {
+               if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
+                       NextAfterFootnote()->SetFont(pos - text.size() - 1,
+                                                    font);
+               } else {
+                       lyxerr << "ERROR (LyXParagraph::SetFont): "
+                               "position does not exist." << endl;
+               }
+               return;
+       }
+#else
        if (pos > last) {
                if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
                        NextAfterFootnote()->SetFont(pos - last - 1, font);
@@ -1097,19 +1496,106 @@ void LyXParagraph::SetFont(int pos, LyXFont const & font)
                }
                return;
        }
-
+#endif
        LyXFont patternfont(LyXFont::ALL_INHERIT);
 
 // First, reduce font against layout/label font
 // Update: The SetCharFont() routine in text2.C already reduces font, so
 // we don't need to do that here. (Asger)
 // No need to simplify this because it will disappear in a new kernel. (Asger)
-
+#ifdef NEW_TABLE
        // Next search font table
-       FontTable *tmp2;
+       for(FontList::iterator it = fontlist.begin();
+           it != fontlist.end(); ++it) {
+               if (pos >= (*it).pos && pos <= (*it).pos_end) {
+                       // found it
+                       // we found a font entry. maybe we have to
+                       // split it and create a new one 
+                       
+                       if ((*it).pos != (*it).pos_end) {
+                               // more than one character
+                               if (pos == (*it).pos) {
+                                       // maybe we could enlarge
+                                       // the left fonttable
+                                       for(FontList::iterator fit = fontlist.begin();
+                                           fit != fontlist.end(); ++fit) {
+                                               if (pos - 1 >= (*fit).pos
+                                                   && pos - 1 <= (*fit).pos_end
+                                                   && (*fit).font == font) {
+                                                       // put the position
+                                                       // under the font
+                                                       (*fit).pos_end++;
+                                                       (*it).pos++;
+                                                       return;
+                                               }
+                                       }
+                                       // Add a new entry in the 
+                                       // fonttable for the position
+                                       FontTable tmp;
+                                       tmp.pos = pos + 1;
+                                       tmp.pos_end = (*it).pos_end;
+                                       tmp.font = (*it).font;
+                                       (*it).pos_end = pos;
+                                       fontlist.push_back(tmp);
+                               } else if (pos == (*it).pos_end) {
+                                       // Add a new entry in the 
+                                       // fonttable for the position
+                                       FontTable tmp;
+                                       tmp.pos = (*it).pos;
+                                       tmp.pos_end = (*it).pos_end - 1;
+                                       tmp.font = (*it).font;
+                                       (*it).pos = (*it).pos_end;
+                                       fontlist.push_back(tmp);
+                               } else {
+                                       // Add a new entry in the 
+                                       // fonttable for the position
+                                       FontTable tmp;
+                                       tmp.pos = (*it).pos;
+                                       tmp.pos_end = pos - 1;
+                                       tmp.font = (*it).font;
+                                       fontlist.push_back(tmp);
+
+                                       tmp.pos = pos + 1;
+                                       tmp.pos_end = (*it).pos_end;
+                                       tmp.font = (*it).font;
+                                       fontlist.push_back(tmp);
+                                       
+                                       (*it).pos = pos;
+                                       (*it).pos_end = pos;
+                               }
+                       }
+                       (*it).font = font;
+                       return;
+               }
+       }
+       
+       // if we did not find a font entry, but if the font at hand
+       // is the same as default, we just forget it
+       if (font == patternfont) return;
+
+       // ok, we did not find a font entry. But maybe there is exactly
+       // the needed font entry one position left
+       for(FontList::iterator it = fontlist.begin();
+           it != fontlist.end(); ++it) {
+               if (pos - 1 >= (*it).pos && pos - 1 <= (*it).pos_end
+                   && (*it).font == font) {
+                       (*it).pos_end++;
+                       return;
+               }
+       }
+       // Add a new entry in the 
+       // fonttable for the position
+       FontTable tmp;
+       tmp.pos = pos;
+       tmp.pos_end = pos;
+       tmp.font = patternfont;
+       fontlist.push_back(tmp);
+#else
+       // Next search font table
+       FontTable * tmp2;
 
        bool found = false;
-       FontTable *tmp = fonttable;
+       FontTable * tmp = fonttable;
        while (tmp && !found) {
                if (pos >= tmp->pos && pos <= tmp->pos_end)
                        found = true;
@@ -1149,8 +1635,7 @@ void LyXParagraph::SetFont(int pos, LyXFont const & font)
                tmp->font = patternfont;
                tmp->next = fonttable;
                fonttable = tmp;
-       }
-       else {
+       } else {
                /* we found a font entry. maybe we have to split it and create
                 * a new one */ 
 
@@ -1219,22 +1704,23 @@ void LyXParagraph::SetFont(int pos, LyXFont const & font)
                        }
                }
        }
-
        tmp->font = font;
+#endif
 }
 
    
 /* this function is able to hide closed footnotes */
-LyXParagraph *LyXParagraph::Next()
+LyXParagraph * LyXParagraph::Next()
 {
-       LyXParagraph *tmp;
        if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
-               tmp = next;
-               while (tmp && tmp->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
+               LyXParagraph * tmp = next;
+               while (tmp
+                      && tmp->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
                        tmp = tmp->next;
                if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) 
-                       return tmp->Next(); /* there can be more than one footnote
-                                            * in a logical paragraph */
+                       return tmp->Next(); /* there can be more than one
+                                              footnote in a logical
+                                              paragraph */
                else
                        return next;    /* this should never happen! */
        }
@@ -1243,49 +1729,47 @@ LyXParagraph *LyXParagraph::Next()
 }
 
 
-LyXParagraph *LyXParagraph::NextAfterFootnote()
+LyXParagraph * LyXParagraph::NextAfterFootnote()
 {
-       LyXParagraph *tmp;
        if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
-               tmp = next;
+               LyXParagraph * tmp = next;
                while (tmp && tmp->footnoteflag != LyXParagraph::NO_FOOTNOTE)
                        tmp = tmp->next;
                if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) 
-                       return tmp;            /* there can be more than one footnote
-                                               * in a logical paragraph */
+                       return tmp;   /* there can be more than one footnote
+                                        in a logical paragraph */
                else
-                       return next;                   /* this should never happen! */
+                       return next;     /* this should never happen! */
        }
        else
                return next;
 }
 
 
-LyXParagraph *LyXParagraph::PreviousBeforeFootnote()
+LyXParagraph * LyXParagraph::PreviousBeforeFootnote()
 {
-       LyXParagraph *tmp;
+       LyXParagraph * tmp;
        if (previous && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
                tmp = next;
                while (tmp && tmp->footnoteflag != LyXParagraph::NO_FOOTNOTE)
                        tmp = tmp->previous;
                if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) 
-                       return tmp;            /* there can be more than one footnote
-                                               * in a logical paragraph */
+                       return tmp;    /* there can be more than one footnote
+                                         in a logical paragraph */
                else
-                       return previous;                       /* this should never happen! */
+                       return previous;   /* this should never happen! */
        }
        else
                return previous;
 }
 
 
-LyXParagraph *LyXParagraph::LastPhysicalPar()
+LyXParagraph * LyXParagraph::LastPhysicalPar()
 {
-       LyXParagraph *tmp;
        if (footnoteflag != LyXParagraph::NO_FOOTNOTE)
                return this;
    
-       tmp = this;
+       LyXParagraph * tmp = this;
        while (tmp->next && tmp->next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
                tmp = tmp->NextAfterFootnote();
    
@@ -1294,11 +1778,11 @@ LyXParagraph *LyXParagraph::LastPhysicalPar()
 }
 
 
-LyXParagraph *LyXParagraph::FirstPhysicalPar()
+LyXParagraph * LyXParagraph::FirstPhysicalPar()
 {
        if (!IsDummy())
                return this;
-       LyXParagraph *tmppar = this;
+       LyXParagraph * tmppar = this;
 
        while (tmppar && (tmppar->IsDummy()
                          || tmppar->footnoteflag != LyXParagraph::NO_FOOTNOTE))
@@ -1312,15 +1796,17 @@ LyXParagraph *LyXParagraph::FirstPhysicalPar()
 
 
 /* this function is able to hide closed footnotes */
-LyXParagraph *LyXParagraph::Previous()
+LyXParagraph * LyXParagraph::Previous()
 {
-       LyXParagraph *tmp = previous;
+       LyXParagraph * tmp = previous;
        if (!tmp)
                return tmp;
    
-       if (tmp->previous && tmp->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
+       if (tmp->previous
+           && tmp->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
                tmp = tmp->previous;
-               while (tmp && tmp->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
+               while (tmp
+                      && tmp->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
                        tmp = tmp->previous;
                if (tmp && tmp->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) 
                        return tmp->next->Previous();   
@@ -1332,16 +1818,23 @@ LyXParagraph *LyXParagraph::Previous()
                return previous;
 }
 
-   
+#ifdef NEW_TEXT
+void LyXParagraph::BreakParagraph(LyXParagraph::size_type pos,
+                                 int flag)
+#else
 void LyXParagraph::BreakParagraph(int pos, int flag)
+#endif
 {
+#ifdef NEW_TEXT
+       size_type i, pos_end, pos_first;
+#else
        int i, pos_end, pos_first;
-
+#endif
        /* create a new paragraph */
-       LyXParagraph *par = ParFromPos(pos);
-       LyXParagraph *firstpar = FirstPhysicalPar();
+       LyXParagraph * par = ParFromPos(pos);
+       LyXParagraph * firstpar = FirstPhysicalPar();
    
-       LyXParagraph *tmp = new LyXParagraph(par);
+       LyXParagraph * tmp = new LyXParagraph(par);
    
        tmp->footnoteflag = footnoteflag;
        tmp->footnotekind = footnotekind;
@@ -1370,21 +1863,24 @@ void LyXParagraph::BreakParagraph(int pos, int flag)
                tmp->depth = firstpar->depth;
                tmp->noindent = firstpar->noindent;
    
-               /* copy everything behind the break-position to the new paragraph */
+               /* copy everything behind the break-position
+                  to the new paragraph
+               */
                pos_first = 0;
                while (ParFromPos(pos_first) != par)
                        pos_first++;
-   
+
+#ifdef NEW_TEXT
+               pos_end = pos_first + par->text.size() - 1;
+#else
                pos_end = pos_first + par->last - 1;
-   
                /* make sure there is enough memory for the now larger
                   paragraph. This is not neccessary, because
                   InsertFromMinibuffer will enlarge the memory (it uses
                   InsertChar of course). But doing it by hand
                   is MUCH faster! (only one time, not thousend times!!) */
-
                tmp->Enlarge(0, pos_end - pos);
-
+#endif
                for (i = pos; i <= pos_end; i++) {
                        par->CutIntoMinibuffer(i - pos_first);
                        tmp->InsertFromMinibuffer(i - pos);
@@ -1392,8 +1888,10 @@ void LyXParagraph::BreakParagraph(int pos, int flag)
 
                for (i = pos_end; i >= pos; i--)
                        par->Erase(i - pos_first);
+#ifndef NEW_TEXT
                /* free memory of the now shorter paragraph*/
                par->FitSize();
+#endif
        }
 
        /* just an idea of me */ 
@@ -1413,7 +1911,7 @@ void LyXParagraph::BreakParagraph(int pos, int flag)
 }
 
 
-void LyXParagraph::MakeSameLayout(LyXParagraph *par)
+void LyXParagraph::MakeSameLayout(LyXParagraph * par)
 {
        par = par->FirstPhysicalPar();
        footnoteflag = par->footnoteflag;
@@ -1443,13 +1941,13 @@ void LyXParagraph::MakeSameLayout(LyXParagraph *par)
 }
 
 
-LyXParagraph *LyXParagraph::FirstSelfrowPar()
+LyXParagraph * LyXParagraph::FirstSelfrowPar()
 {
-       LyXParagraph *tmppar;
-   
-       tmppar = this;
+       LyXParagraph * tmppar = this;
        while (tmppar && (
-               (tmppar->IsDummy() && tmppar->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
+               (tmppar->IsDummy()
+                && tmppar->previous->footnoteflag ==
+                LyXParagraph::CLOSED_FOOTNOTE)
                || tmppar->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE))
                tmppar = tmppar->previous;
    
@@ -1460,12 +1958,10 @@ LyXParagraph *LyXParagraph::FirstSelfrowPar()
 }
 
 
-LyXParagraph *LyXParagraph::Clone()
+LyXParagraph * LyXParagraph::Clone()
 {
-       int i;
-   
        /* create a new paragraph */
-       LyXParagraph *result = new LyXParagraph();
+       LyXParagraph * result = new LyXParagraph();
    
        result->MakeSameLayout(this);
 
@@ -1486,22 +1982,27 @@ LyXParagraph *LyXParagraph::Clone()
     
        /* copy everything behind the break-position to the new paragraph */
    
+#ifdef NEW_TEXT
+       for (size_type i = 0; i < size(); i++) {
+               CopyIntoMinibuffer(i);
+               result->InsertFromMinibuffer(i);
+       }
+#else
        /* make shure there is enough memory for the now larger paragraph.
         * This is not neccessary, because InsertFromMinibuffer will enlarge
         * the memory (it uses InsertChar of course). But doing it by hand
         * is MUCH faster! (only one time, not thousend times!!) */
-   
        result->Enlarge(0, last+2);
-   
-       for (i = 0; i < last; i++) {
+       for (int i = 0; i < last; i++) {
                CopyIntoMinibuffer(i);
                result->InsertFromMinibuffer(i);
        }
+#endif
        return result;
 }
 
 
-bool LyXParagraph::HasSameLayout(LyXParagraph* par)
+bool LyXParagraph::HasSameLayout(LyXParagraph * par)
 {
        par = par->FirstPhysicalPar();
 
@@ -1534,15 +2035,22 @@ bool LyXParagraph::HasSameLayout(LyXParagraph* par)
                par->depth == depth);
 }
 
-
+#ifdef NEW_TEXT
+void LyXParagraph::BreakParagraphConservative(LyXParagraph::size_type pos)
+#else
 void LyXParagraph::BreakParagraphConservative(int pos)
+#endif
 {
+#ifdef NEW_TEXT
+       size_type i, pos_end, pos_first;
+#else
        int i, pos_end, pos_first;
-   
+#endif
+       
        /* create a new paragraph */
-       LyXParagraph *par = ParFromPos(pos);
+       LyXParagraph * par = ParFromPos(pos);
 
-       LyXParagraph *tmp = new LyXParagraph(par);
+       LyXParagraph * tmp = new LyXParagraph(par);
    
        tmp->MakeSameLayout(par);
    
@@ -1552,17 +2060,19 @@ void LyXParagraph::BreakParagraphConservative(int pos)
                pos_first = 0;
                while (ParFromPos(pos_first) != par)
                        pos_first++;
-   
+#ifdef NEW_TEXT
+               pos_end = pos_first + par->text.size() - 1;
+#else
                pos_end = pos_first + par->last - 1;
-   
+#endif
                /* make shure there is enough memory for the now larger
                   paragraph. This is not neccessary, because
                   InsertFromMinibuffer will enlarge the memory (it uses
                   InsertChar of course). But doing it by hand
                   is MUCH faster! (only one time, not thousend times!!) */
-   
+#ifndef NEW_TEXT   
                tmp->Enlarge(0, pos_end - pos);
-   
+#endif
                for (i = pos; i <= pos_end; i++) {
       
                        par->CutIntoMinibuffer(i - pos_first);
@@ -1570,9 +2080,10 @@ void LyXParagraph::BreakParagraphConservative(int pos)
                }
                for (i = pos_end; i >= pos; i--)
                        par->Erase(i - pos_first);
-
+#ifndef NEW_TEXT
                /* free memory of the now shorter paragraph*/
                par->FitSize();
+#endif
        }
 }
    
@@ -1580,27 +2091,30 @@ void LyXParagraph::BreakParagraphConservative(int pos)
 /* be carefull, this does not make any check at all */ 
 void LyXParagraph::PasteParagraph()
 {
-       int i, pos_end, pos_insert;
-       LyXParagraph *the_next;
-   
        /* copy the next paragraph to this one */
-       the_next = Next();
+       LyXParagraph * the_next = Next();
    
-       LyXParagraph *firstpar = FirstPhysicalPar();
+       LyXParagraph * firstpar = FirstPhysicalPar();
    
        /* first the DTP-stuff */ 
        firstpar->line_bottom = the_next->line_bottom;
        firstpar->added_space_bottom = the_next->added_space_bottom;
        firstpar->pagebreak_bottom = the_next->pagebreak_bottom;
-   
-       pos_end = the_next->last - 1;
-       pos_insert = Last();
-   
+
+#ifdef NEW_TEXT
+       size_type pos_end = the_next->text.size() - 1;
+       size_type pos_insert = Last();
+       size_type i;
+#else
+       int pos_end = the_next->last - 1;
+       int pos_insert = Last();
        /* enlarge the paragraph. This is faster than enlarge it
         * every 10th insertion. */ 
        if (pos_end >= 0)
                Enlarge(pos_insert, pos_end);
-      
+       int i;
+#endif
+
        /* ok, now copy the paragraph */ 
        for (i = 0; i <= pos_end; i++) {
                the_next->CutIntoMinibuffer(i);
@@ -1611,10 +2125,13 @@ void LyXParagraph::PasteParagraph()
        delete the_next;
 }
 
-
+#ifdef NEW_TEXT
+void LyXParagraph::OpenFootnote(LyXParagraph::size_type pos)
+#else
 void LyXParagraph::OpenFootnote(int pos)
+#endif
 {
-       LyXParagraph *par = ParFromPos(pos);
+       LyXParagraph * par = ParFromPos(pos);
        par = par->next;
        while (par && par->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
                par->footnoteflag = LyXParagraph::OPEN_FOOTNOTE;
@@ -1622,10 +2139,13 @@ void LyXParagraph::OpenFootnote(int pos)
        }
 }
 
-
+#ifdef NEW_TEXT
+void LyXParagraph::CloseFootnote(LyXParagraph::size_type pos)
+#else
 void LyXParagraph::CloseFootnote(int pos)
+#endif
 {
-       LyXParagraph *par = ParFromPos(pos);
+       LyXParagraph * par = ParFromPos(pos);
        par = par->next;
        while (par && par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
                par->footnoteflag = LyXParagraph::CLOSED_FOOTNOTE;
@@ -1634,7 +2154,7 @@ void LyXParagraph::CloseFootnote(int pos)
 }
 
 
-int LyXParagraph::GetLayout()
+LyXTextClass::LayoutList::size_type LyXParagraph::GetLayout()
 {
        return FirstPhysicalPar()->layout;
 }
@@ -1676,18 +2196,17 @@ string LyXParagraph::GetLabelWidthString()
 
 void LyXParagraph::SetLabelWidthString(string const & s)
 {
-       LyXParagraph *par = FirstPhysicalPar();
+       LyXParagraph * par = FirstPhysicalPar();
 
        par->labelwidthstring = s;
 }
 
 
-void LyXParagraph::SetOnlyLayout(char new_layout)
+void LyXParagraph::SetOnlyLayout(LyXTextClass::LayoutList::size_type new_layout)
 {
-       LyXParagraph
-               *par = FirstPhysicalPar(),
-               *ppar = 0,
-                *npar = 0;
+       LyXParagraph * par = FirstPhysicalPar();
+       LyXParagraph * ppar = 0;
+       LyXParagraph * npar = 0;
 
        par->layout = new_layout;
        /* table stuff -- begin*/ 
@@ -1728,17 +2247,16 @@ void LyXParagraph::SetOnlyLayout(char new_layout)
 }
 
 
-void LyXParagraph::SetLayout(char new_layout)
+void LyXParagraph::SetLayout(LyXTextClass::LayoutList::size_type new_layout)
 {
        LyXParagraph
-               *par = FirstPhysicalPar(),
-               *ppar = 0,
-               *npar = 0;
+               * par = FirstPhysicalPar(),
+               * ppar = 0,
+               * npar = 0;
 
         par->layout = new_layout;
        par->labelwidthstring.clear();
        par->align = LYX_ALIGN_LAYOUT;
-       //par->depth = 0;
        par->added_space_top = VSpace(VSpace::NONE);
        par->added_space_bottom = VSpace(VSpace::NONE);
        /* table stuff -- begin*/ 
@@ -1791,14 +2309,36 @@ int LyXParagraph::BeginningOfMainBody()
        if (FirstPhysicalPar() != this)
                return -1;
    
-       int i = 0;
    
-//     while (i < last   &&  !(i > 1 && GetChar(i-1)==' ')
-//            && GetChar(i)!=LYX_META_NEWLINE)
-//             i++;
-// Unroll the first two cycles of this loop
+// Unroll the first two cycles of the loop
 // and remember the previous character to remove unnecessary GetChar() calls
+#ifdef NEW_TEXT
+       size_type i = 0;
+       if (i < size()
+           && GetChar(i) != LYX_META_NEWLINE) {
+               ++i;
+               char previous_char, temp;
+               if (i < size()
+                   && (previous_char = GetChar(i)) != LYX_META_NEWLINE) {
+                       // Yes, this  ^ is supposed to be "=" not "=="
+                       ++i;
+                       while (i < size()
+                              && previous_char != ' '
+                              && (temp = GetChar(i)) != LYX_META_NEWLINE) {
+                               ++i;
+                               previous_char = temp;
+                       }
+               }
+       }
 
+       if (i == 0 && i == size() &&
+           !(footnoteflag==LyXParagraph::NO_FOOTNOTE
+             && next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE))
+               i++;                           /* the cursor should not jump  
+                                               * to the main body if there
+                                               * is nothing in! */
+#else
+       int i = 0;
        if (i < last
            && GetChar(i) != LYX_META_NEWLINE) {
                ++i;
@@ -1823,13 +2363,14 @@ int LyXParagraph::BeginningOfMainBody()
                i++;                           /* the cursor should not jump  
                                                * to the main body if there
                                                * is nothing in! */
+#endif
        return i;
 }
 
 
-LyXParagraph* LyXParagraph::DepthHook(int deth)
+LyXParagraph * LyXParagraph::DepthHook(int deth)
 {
-       LyXParagraph *newpar = this;
+       LyXParagraph * newpar = this;
        if (deth < 0)
                return 0;
    
@@ -1850,9 +2391,20 @@ LyXParagraph* LyXParagraph::DepthHook(int deth)
 
 int LyXParagraph::AutoDeleteInsets()
 {
-       InsetTable *tmpi = insettable;
-       InsetTable *tmpi2 = tmpi;
-       int i=0;
+#ifdef NEW_TABLE
+       int i = 0;
+       for (InsetList::iterator it = insetlist.begin();
+            it != insetlist.end(); ++it) {
+               if ((*it).inset->AutoDelete()) {
+                       ++i;
+                       Erase((*it).pos);
+               }
+       }
+       return i;
+#else
+       InsetTable * tmpi = insettable;
+       InsetTable * tmpi2 = tmpi;
+       int i = 0;
        while (tmpi) {
                tmpi2 = tmpi;
                tmpi = tmpi->next;
@@ -1866,13 +2418,33 @@ int LyXParagraph::AutoDeleteInsets()
                                "cannot auto-delete insets" << endl;
        }
        return i;
+#endif
 }
 
 
-Inset* LyXParagraph::ReturnNextInsetPointer(int &pos)
+#ifdef NEW_TEXT
+Inset * LyXParagraph::ReturnNextInsetPointer(LyXParagraph::size_type & pos)
+#else
+Inset * LyXParagraph::ReturnNextInsetPointer(int & pos)
+#endif
 {
-       InsetTable *tmpi = insettable;
-       InsetTable *tmpi2 = 0;
+#ifdef NEW_TABLE
+       InsetTable * tmp = 0;
+       for (InsetList::iterator it = insetlist.begin();
+            it != insetlist.end(); ++it) {
+               if ((*it).pos >= pos && (!tmp || (*it).pos < tmp->pos)) {
+                       tmp = &(*it);
+               }
+       }
+       if (tmp) {
+               pos = tmp->pos;
+               return tmp->inset;
+       }
+       return 0;
+               
+#else
+       InsetTable * tmpi = insettable;
+       InsetTable * tmpi2 = 0;
        while (tmpi){
                if (tmpi->pos >= pos) {
                        if (!tmpi2 || tmpi->pos < tmpi2->pos)
@@ -1886,16 +2458,38 @@ Inset* LyXParagraph::ReturnNextInsetPointer(int &pos)
        }
        else
                return 0;
+#endif
 }
 
 
 /* returns -1 if inset not found */
-int LyXParagraph::GetPositionOfInset(Inset* inset)
+int LyXParagraph::GetPositionOfInset(Inset * inset)
 {
+#ifdef NEW_TABLE
+       for (InsetList::iterator it = insetlist.begin();
+            it != insetlist.end(); ++it) {
+               if ((*it).inset == inset) {
+                       return (*it).pos;
+               }
+       }
+       // Think about footnotes
+       if (footnoteflag == LyXParagraph::NO_FOOTNOTE
+           && next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
+               int further = NextAfterFootnote()->GetPositionOfInset(inset);
+#ifdef NEW_TEXT
+               if (further != -1)
+                       return size() + 1 + further;
+#else
+               if (further != -1)
+                       return last + 1 + further;
+#endif
+       }
+       return -1;
+#else
        /* find the entry */ 
-       InsetTable *tmpi = insettable;
+       InsetTable * tmpi = insettable;
        while (tmpi && tmpi->inset != inset) {
-               tmpi=tmpi->next;
+               tmpi = tmpi->next;
        }
        if (tmpi && tmpi->inset)
                return tmpi->pos;
@@ -1905,45 +2499,56 @@ int LyXParagraph::GetPositionOfInset(Inset* inset)
                    && next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
                        int further =
                                NextAfterFootnote()->GetPositionOfInset(inset);
+#ifdef NEW_TEXT
+                       if (further != -1)
+                               return text.size() + 1 + further;
+#else
                        if (further != -1)
                                return last + 1 + further;
+#endif
                }
                return -1;
        }
+#endif
 }
 
 
-void LyXParagraph::readSimpleWholeFile(FILE *myfile)
+void LyXParagraph::readSimpleWholeFile(FILE * myfile)
 {
-       char c;
 
+#ifndef NEW_TEXT
        FileInfo fileInfo(fileno(myfile));
        long file_size = fileInfo.getSize();
        /* it is horrible, I know, but faster.
         * I should not use InsertString for that :-( */
-   
+
        /* I will write a better insertion in the future */ 
        Enlarge(0, file_size + 10);
-   
+#endif
        rewind(myfile);
    
        if (!feof(myfile)) {
+               char c = 0;
                do {
                        c = fgetc(myfile);
+#ifdef NEW_TEXT
+                       InsertChar(text.size(), c);
+#else
                        InsertChar(last,c);
+#endif
                } while (!feof(myfile));
       
        }
 }
 
 
-LyXParagraph* LyXParagraph::TeXOnePar(string &file, TexRow &texrow,
-                                     string &foot, TexRow &foot_texrow,
-                                     int &foot_count)
+LyXParagraph * LyXParagraph::TeXOnePar(string & file, TexRow & texrow,
+                                     string & foot, TexRow & foot_texrow,
+                                     int & foot_count)
 {
        lyxerr[Debug::LATEX] << "TeXOnePar...     " << this << endl;
-       LyXParagraph *par = next;
-       LyXLayout * style = lyxstyle.Style(GetCurrentTextClass(), layout);
+       LyXParagraph * par = next;
+       LyXLayout const & style = textclasslist.Style(GetCurrentTextClass(), layout);
 
        bool further_blank_line = false;
        if (IsDummy())
@@ -1954,7 +2559,7 @@ LyXParagraph* LyXParagraph::TeXOnePar(string &file, TexRow &texrow,
                texrow.newline();
        }
 
-       if (tex_code_break_column && style->isCommand()){
+       if (tex_code_break_column && style.isCommand()){
                file += '\n';
                texrow.newline();
        }
@@ -1979,11 +2584,11 @@ LyXParagraph* LyXParagraph::TeXOnePar(string &file, TexRow &texrow,
                texrow.newline();
        }
 
-       switch (style->latextype) {
+       switch (style.latextype) {
        case LATEX_COMMAND:
                file += '\\';
-               file += style->latexname;
-               file += style->latexparam;
+               file += style.latexname();
+               file += style.latexparam();
                break;
        case LATEX_ITEM_ENVIRONMENT:
                if (bibkey) 
@@ -2016,25 +2621,25 @@ LyXParagraph* LyXParagraph::TeXOnePar(string &file, TexRow &texrow,
        // to this font. (Matthias)
        LyXFont font = getFont(Last()-1);
        if (need_par) {
-               if (style->resfont.size() != font.size()) {
+               if (style.resfont.size() != font.size()) {
                        file += '\\';
                        file += font.latexSize();
                        file += ' ';
                }
                file += "\\par}";
-       } else if (lyxstyle.Style(GetCurrentTextClass(),
-                                 GetLayout())->isCommand()){
-               if (style->resfont.size() != font.size()) {
+       } else if (textclasslist.Style(GetCurrentTextClass(),
+                                 GetLayout()).isCommand()){
+               if (style.resfont.size() != font.size()) {
                        file += '\\';
                        file += font.latexSize();
                        file += ' ';
                }
                file += '}';
-       } else if (style->resfont.size() != font.size()){
+       } else if (style.resfont.size() != font.size()){
                file += "{\\" + font.latexSize() + " \\par}";
        }
        
-       switch (style->latextype) {
+       switch (style.latextype) {
        case LATEX_ITEM_ENVIRONMENT:
        case LATEX_LIST_ENVIRONMENT:
                 if (par && (depth < par->depth)) {
@@ -2088,9 +2693,7 @@ LyXParagraph* LyXParagraph::TeXOnePar(string &file, TexRow &texrow,
        }
 
        if (!(footnoteflag != LyXParagraph::NO_FOOTNOTE && par &&
-              par->footnoteflag == LyXParagraph::NO_FOOTNOTE) // &&
-//            (pextra_type != PEXTRA_MINIPAGE ||
-/*             (par && !par->pextra_type == PEXTRA_MINIPAGE)) */ ) {
+              par->footnoteflag == LyXParagraph::NO_FOOTNOTE)) {
                file += '\n';
                texrow.newline();
        }
@@ -2101,7 +2704,7 @@ LyXParagraph* LyXParagraph::TeXOnePar(string &file, TexRow &texrow,
 
 
 // This one spits out the text of the paragraph
-bool LyXParagraph::SimpleTeXOnePar(string &file, TexRow &texrow)
+bool LyXParagraph::SimpleTeXOnePar(string & file, TexRow & texrow)
 {
        lyxerr[Debug::LATEX] << "SimpleTeXOnePar...     " << this << endl;
 
@@ -2109,17 +2712,19 @@ bool LyXParagraph::SimpleTeXOnePar(string &file, TexRow &texrow)
                return SimpleTeXOneTablePar(file, texrow);
 
        char c;
+#ifdef NEW_TEXT
+       size_type main_body;
+#else
        int main_body;
-       int column;
+#endif
        
        bool return_value = false;
-       //bool underbar = false;
 
-       LyXLayout * style = lyxstyle.Style(GetCurrentTextClass(), GetLayout());
+       LyXLayout const & style = textclasslist.Style(GetCurrentTextClass(), GetLayout());
        LyXFont basefont;
 
        /* maybe we have to create a optional argument */ 
-       if (style->labeltype != LABEL_MANUAL)
+       if (style.labeltype != LABEL_MANUAL)
                main_body = 0;
        else
                main_body = BeginningOfMainBody();
@@ -2131,12 +2736,16 @@ bool LyXParagraph::SimpleTeXOnePar(string &file, TexRow &texrow)
                basefont = getFont(-1); // Get layout font
        }
 
-       column = 0;
+       int column = 0;
 
        if (main_body >= 0
+#ifdef NEW_TEXT
+           && !text.size()
+#else
            && !last
+#endif
            && !IsDummy()) {
-               if (style->isCommand()) {
+               if (style.isCommand()) {
                        file += '{';
                        column++;
                } else if (align != LYX_ALIGN_LAYOUT) {
@@ -2152,8 +2761,12 @@ bool LyXParagraph::SimpleTeXOnePar(string &file, TexRow &texrow)
        bool open_font = false;
 
        texrow.start(this, 0);
-       for (int i = 0; i < last; i++) {
+
+#ifdef NEW_TEXT
+       for (size_type i = 0; i < size(); ++i) {
+#else
+       for (int i = 0; i < last; ++i) {
+#endif
                column++;
                // First char in paragraph or after label?
                if (i == main_body && !IsDummy()) {
@@ -2167,7 +2780,7 @@ bool LyXParagraph::SimpleTeXOnePar(string &file, TexRow &texrow)
                                file += ']';
                                column++;
                        }
-                       if (style->isCommand()) {
+                       if (style.isCommand()) {
                                file += '{';
                                column++;
                        } else if (align != LYX_ALIGN_LAYOUT) {
@@ -2181,6 +2794,10 @@ bool LyXParagraph::SimpleTeXOnePar(string &file, TexRow &texrow)
                                column += 10;
                        }
                        switch (align) {
+                       case LYX_ALIGN_NONE:
+                       case LYX_ALIGN_BLOCK:
+                       case LYX_ALIGN_LAYOUT:
+                       case LYX_ALIGN_SPECIAL: break;
                        case LYX_ALIGN_LEFT:
                                file += "\\raggedright ";
                                column+=13;
@@ -2203,13 +2820,20 @@ bool LyXParagraph::SimpleTeXOnePar(string &file, TexRow &texrow)
 
                // Spaces at end of font change are simulated to be
                // outside font change, i.e. we write "\textXX{text} "
-               // rather than "\textXX{text }". (Asger) 
+               // rather than "\textXX{text }". (Asger)
+#ifdef NEW_TEXT
+               if (open_font && c == ' ' && i <= size() - 2 
+                   && !getFont(i+1).equalExceptLatex(running_font) 
+                   && !getFont(i+1).equalExceptLatex(font)) {
+                       font = getFont(i+1);
+               }
+#else
                if (open_font && c == ' ' && i <= last-2 
                    && !getFont(i+1).equalExceptLatex(running_font) 
                    && !getFont(i+1).equalExceptLatex(font)) {
                        font = getFont(i+1);
                }
-
+#endif
                // We end font definition before blanks
                if (!font.equalExceptLatex(running_font) && open_font) {
                        column += running_font.latexWriteEndChanges(file, basefont);
@@ -2236,7 +2860,7 @@ bool LyXParagraph::SimpleTeXOnePar(string &file, TexRow &texrow)
                if (c == LYX_META_NEWLINE) {
                        // newlines are handled differently here than
                        // the default in SimpleTeXSpecialChars().
-                       if (!style->newline_allowed
+                       if (!style.newline_allowed
                            || font.latex() == LyXFont::ON) {
                                file += '\n';
                        } else {
@@ -2267,39 +2891,45 @@ bool LyXParagraph::SimpleTeXOnePar(string &file, TexRow &texrow)
                running_font.latexWriteEndChanges(file, basefont);
        }
 
+#ifdef NEW_TEXT
+       /* needed if there is an optional argument but no contents */ 
+       if (main_body > 0 && main_body == size()) {
+               file += "]~";
+               return_value = false;
+       }
+#else
        /* needed if there is an optional argument but no contents */ 
        if (main_body > 0 && main_body == last) {
                file += "]~";
                return_value = false;
        }
-
+#endif
        lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
        return return_value;
 }
 
 
 // This one spits out the text of a table paragraph
-bool LyXParagraph::SimpleTeXOneTablePar(string &file, TexRow &texrow)
+bool LyXParagraph::SimpleTeXOneTablePar(string & file, TexRow & texrow)
 {
        lyxerr[Debug::LATEX] << "SimpleTeXOneTablePar...     " << this << endl;
        char c;
-       int column, tmp;
+       int tmp;
    
        bool return_value = false;
        int current_cell_number = -1;
 
-       LyXLayout * style = lyxstyle.Style(GetCurrentTextClass(), GetLayout());
-       LyXFont basefont;
-
-       basefont = getFont(-1); // Get layout font
+       LyXLayout const & style =
+               textclasslist.Style(GetCurrentTextClass(), GetLayout());
+       LyXFont basefont = getFont(-1); // Get layout font
        // Which font is currently active?
        LyXFont running_font = basefont;
        // Do we have an open font change?
        bool open_font = false;
  
-       column = 0;
+       int column = 0;
        if (!IsDummy()) { // it is dummy if it is in a float!!!
-               if (style->isCommand()) {
+               if (style.isCommand()) {
                        file += '{';
                        column++;
                } else if (align != LYX_ALIGN_LAYOUT) {
@@ -2312,6 +2942,10 @@ bool LyXParagraph::SimpleTeXOneTablePar(string &file, TexRow &texrow)
                        column += 10;
                }
                switch (align) {
+               case LYX_ALIGN_NONE:
+               case LYX_ALIGN_BLOCK:
+               case LYX_ALIGN_LAYOUT:
+               case LYX_ALIGN_SPECIAL: break;
                case LYX_ALIGN_LEFT:
                        file += "\\raggedright ";
                        column+=13;
@@ -2328,12 +2962,16 @@ bool LyXParagraph::SimpleTeXOneTablePar(string &file, TexRow &texrow)
        }
        current_cell_number = -1;
        tmp = table->TexEndOfCell(file,current_cell_number);
-       for (;tmp>0;tmp--)
+       for (; tmp >0 ; --tmp)
                texrow.newline();
        
        texrow.start(this, 0);
 
-       for (int i = 0; i < last; i++) {
+#ifdef NEW_TEXT
+       for (size_type i = 0; i < size(); ++i) {
+#else
+       for (int i = 0; i < last; ++i) {
+#endif
                c = GetChar(i);
                if (table->IsContRow(current_cell_number+1)) {
                        if (c == LYX_META_NEWLINE)
@@ -2347,7 +2985,11 @@ bool LyXParagraph::SimpleTeXOneTablePar(string &file, TexRow &texrow)
 
                // Spaces at end of font change are simulated to be outside font change.
                // i.e. we write "\textXX{text} " rather than "\textXX{text }". (Asger)
-               if (open_font && c == ' ' && i <= last-2 
+#ifdef NEW_TEXT
+               if (open_font && c == ' ' && i <= size() - 2
+#else
+               if (open_font && c == ' ' && i <= last-2
+#endif
                    && getFont(i+1) != running_font && getFont(i+1) != font) {
                        font = getFont(i+1);
                }
@@ -2371,7 +3013,7 @@ bool LyXParagraph::SimpleTeXOneTablePar(string &file, TexRow &texrow)
                // Do we need to turn on LaTeX mode?
                if (font.latex() != running_font.latex()) {
                        if (font.latex() == LyXFont::ON
-                           && style->needprotect) {
+                           && style.needprotect) {
                                file += "\\protect ";
                                column += 9;
                        }
@@ -2419,7 +3061,7 @@ bool LyXParagraph::SimpleTeXOneTablePar(string &file, TexRow &texrow)
        }
        current_cell_number++;
        tmp = table->TexEndOfCell(file, current_cell_number);
-       for (;tmp>0;tmp--)
+       for (; tmp > 0; --tmp)
                texrow.newline();
        lyxerr[Debug::LATEX] << "SimpleTeXOneTablePar...done " << this << endl;
        return return_value;
@@ -2427,20 +3069,25 @@ bool LyXParagraph::SimpleTeXOneTablePar(string &file, TexRow &texrow)
 
 
 // This one spits out the text off ContRows in tables
-bool LyXParagraph::TeXContTableRows(string &file, int i,
+#ifdef NEW_TEXT
+bool LyXParagraph::TeXContTableRows(string & file,
+                                   LyXParagraph::size_type i,
+                                   int current_cell_number,
+                                   int & column, TexRow & texrow)
+#else
+bool LyXParagraph::TeXContTableRows(string & file, int i,
                                    int current_cell_number,
-                                   int &column, TexRow &texrow)
+                                   int & column, TexRow & texrow)
+#endif
 {
        lyxerr[Debug::LATEX] << "TeXContTableRows...     " << this << endl;
        if (!table)
                return false;
     
        char c;
-       int cell;
-       int lastpos;
    
        bool return_value = false;
-       LyXLayout * style = lyxstyle.Style(GetCurrentTextClass(), GetLayout());
+       LyXLayout const & style = textclasslist.Style(GetCurrentTextClass(), GetLayout());
        LyXFont basefont;
 
        basefont = getFont(-1); // Get layout font
@@ -2449,19 +3096,27 @@ bool LyXParagraph::TeXContTableRows(string &file, int i,
        // Do we have an open font change?
        bool open_font = false;
 
-       lastpos = i;
-       cell = table->CellHasContRow(current_cell_number);
+#ifdef NEW_TEXT
+       size_type lastpos = i;
+#else
+       int lastpos = i;
+#endif
+       int cell = table->CellHasContRow(current_cell_number);
        current_cell_number++;
        while(cell >= 0) {
                // first find the right position
                i = lastpos;
-               for (; (i<last) && (current_cell_number<cell); i++) {
+#ifdef NEW_TEXT
+               for (; (i < size()) && (current_cell_number<cell); ++i) {
+#else
+               for (; (i < last) && (current_cell_number<cell); ++i) {
+#endif
                        c = GetChar(i);
                        if (c == LYX_META_NEWLINE)
                                current_cell_number++;
                }
                lastpos = i;
-               c=GetChar(i);
+               c = GetChar(i);
                if (table->Linebreaks(table->FirstVirtualCell(cell))) {
                        file += " \\\\\n";
                        texrow.newline();
@@ -2469,17 +3124,30 @@ bool LyXParagraph::TeXContTableRows(string &file, int i,
                } else if ((c != ' ') && (c != LYX_META_NEWLINE)) {
                        file += ' ';
                }
-               for (; (i < last) && ((c=GetChar(i)) != LYX_META_NEWLINE); i++) {
-                       column++;
+#ifdef NEW_TEXT
+               for (; i < size() && (c = GetChar(i)) != LYX_META_NEWLINE;
+                    ++i) {
+#else
+               for (; (i < last) && ((c=GetChar(i)) != LYX_META_NEWLINE);
+                    ++i) {
+#endif
+                       ++column;
 
                        // Fully instantiated font
                        LyXFont font = getFont(i);
 
                        // Spaces at end of font change are simulated to be outside font change.
                        // i.e. we write "\textXX{text} " rather than "\textXX{text }". (Asger)
-                       if (open_font && c == ' ' && i <= last-2 
-                           && getFont(i+1) != running_font && getFont(i+1) != font) {
-                               font = getFont(i+1);
+#ifdef NEW_TEXT
+                       if (open_font && c == ' ' && i <= size() - 2 
+                           && getFont(i + 1) != running_font
+                           && getFont(i + 1) != font) {
+#else
+                       if (open_font && c == ' ' && i <= last - 2 
+                           && getFont(i + 1) != running_font
+                           && getFont(i + 1) != font) {
+#endif
+                               font = getFont(i + 1);
                        }
 
                        // We end font definition before blanks
@@ -2501,7 +3169,7 @@ bool LyXParagraph::TeXContTableRows(string &file, int i,
                        // Do we need to turn on LaTeX mode?
                        if (font.latex() != running_font.latex()) {
                                if (font.latex() == LyXFont::ON
-                                   && style->needprotect)
+                                   && style.needprotect)
                                        {
                                                file += "\\protect ";
                                                column += 9;
@@ -2524,7 +3192,7 @@ bool LyXParagraph::TeXContTableRows(string &file, int i,
 }
 
 
-bool LyXParagraph::linuxDocConvertChar(char c, string &sgml_string)
+bool LyXParagraph::linuxDocConvertChar(char c, string & sgml_string)
 {
        bool retval = false;
        switch (c) {
@@ -2590,35 +3258,38 @@ bool LyXParagraph::linuxDocConvertChar(char c, string &sgml_string)
        return retval;
 }
 
-void LyXParagraph::SimpleDocBookOneTablePar(string &file, string &extra,
+void LyXParagraph::SimpleDocBookOneTablePar(string & file, string & extra,
                                            int & desc_on, int depth) 
 {
        if (!table)
                return;
        lyxerr[Debug::LATEX] << "SimpleDocbookOneTablePar... " << this << endl;
        int column, tmp;
-       //bool return_value = false; // unused
        int current_cell_number = -1;
        LyXFont font1,font2;
        char c;
        Inset *inset;
-       int  main_body; //, j; // unused
-       string emph="emphasis";
+#ifdef NEW_TEXT
+       size_type main_body;
+#else
+       int  main_body;
+#endif
+       string emph = "emphasis";
        bool emph_flag=false;
        int char_line_count=0;
        
-       LyXLayout * style = lyxstyle.Style(GetCurrentTextClass(), GetLayout());
+       LyXLayout const & style = textclasslist.Style(GetCurrentTextClass(), GetLayout());
        
-       if (style->labeltype != LABEL_MANUAL)
+       if (style.labeltype != LABEL_MANUAL)
                main_body = 0;
        else
                main_body = 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;
        addNewlineAndDepth(file, depth);
@@ -2630,7 +3301,11 @@ void LyXParagraph::SimpleDocBookOneTablePar(string &file, string &extra,
        tmp = table->DocBookEndOfCell(file,current_cell_number, depth);
        
        /* parsing main loop */
-       for (int i = 0; i < last; i++) {
+#ifdef NEW_TEXT
+       for (size_type i = 0; i < size(); ++i) {
+#else
+       for (int i = 0; i < last; ++i) {
+#endif
                c = GetChar(i);
                if (table->IsContRow(current_cell_number+1)) {
                        if (c == LYX_META_NEWLINE)
@@ -2691,9 +3366,9 @@ void LyXParagraph::SimpleDocBookOneTablePar(string &file, string &extra,
                        //   and title should come first
                        //         desc_on==4
                        //
-                       if(desc_on!=3 || i!=0) {
-                               if(tmp_out[0]=='@') {
-                                       if(desc_on==4)
+                       if(desc_on != 3 || i != 0) {
+                               if(tmp_out[0] == '@') {
+                                       if(desc_on == 4)
                                                extra += frontStrip(tmp_out, '@');
                                        else
                                                file += frontStrip(tmp_out, '@');
@@ -2702,13 +3377,13 @@ void LyXParagraph::SimpleDocBookOneTablePar(string &file, string &extra,
                        }
                } else if (font2.latex() == LyXFont::ON) {
                        // "TeX"-Mode on ==> SGML-Mode on.
-                       if (c!='\0')
+                       if (c != '\0')
                                file += c;
                        char_line_count++;
                } else {
                        string sgml_string;
                        if (linuxDocConvertChar(c, sgml_string) 
-                           && !style->free_spacing) {
+                           && !style.free_spacing) {
                                // in freespacing mode, spaces are
                                // non-breaking characters
                                // char is ' '
@@ -2727,11 +3402,16 @@ void LyXParagraph::SimpleDocBookOneTablePar(string &file, string &extra,
                font1 = font2;
        }
        
-       /* needed if there is an optional argument but no contents */ 
+       /* needed if there is an optional argument but no contents */
+#ifdef NEW_TEXT
+       if (main_body > 0 && main_body == size()) {
+               font1 = style.font;
+       }
+#else
        if (main_body > 0 && main_body == last) {
-               font1 = style->font;
+               font1 = style.font;
        }
-       
+#endif
        if (emph_flag) {
                file += "</emphasis>";
        }
@@ -2752,36 +3432,50 @@ void LyXParagraph::SimpleDocBookOneTablePar(string &file, string &extra,
                             << this << endl;
 }
 
-void LyXParagraph::DocBookContTableRows(string &file, string &extra,
+#ifdef NEW_TEXT
+void LyXParagraph::DocBookContTableRows(string & file, string & extra,
+                                        int & desc_on, LyXParagraph::size_type i,
+                                        int current_cell_number, int &column) 
+
+#else
+void LyXParagraph::DocBookContTableRows(string & file, string & extra,
                                         int & desc_on, int i,
                                         int current_cell_number, int &column) 
+
+#endif
 {
        if (!table)
                return;
        
        lyxerr[Debug::LATEX] << "DocBookContTableRows... " << this << endl;
 
-       int cell, lastpos; //tmp; //unused
+       int cell;
        LyXFont font1,font2;
        char c;
-       Inset *inset;
-       int main_body; // , j; // unused
+       Inset * inset;
+#ifdef NEW_TEXT
+       size_type main_body;
+       size_type lastpos;
+#else
+       int main_body;
+       int lastpos;
+#endif
        string emph="emphasis";
        bool emph_flag=false;
        int char_line_count=0;
        
-       LyXLayout * style = lyxstyle.Style(GetCurrentTextClass(), GetLayout());
+       LyXLayout const & style = textclasslist.Style(GetCurrentTextClass(), GetLayout());
        
-       if (style->labeltype != LABEL_MANUAL)
+       if (style.labeltype != LABEL_MANUAL)
                main_body = 0;
        else
                main_body = BeginningOfMainBody();
        
        /* gets paragraph main font */
        if (main_body > 0)
-               font1 = style->labelfont;
+               font1 = style.labelfont;
        else
-               font1 = style->font;
+               font1 = style.font;
        
        lastpos = i;
        cell = table->CellHasContRow(current_cell_number);
@@ -2789,13 +3483,17 @@ void LyXParagraph::DocBookContTableRows(string &file, string &extra,
        while(cell >= 0) {
                // first find the right position
                i = lastpos;
-               for (; (i<last) && (current_cell_number<cell); i++) {
+#ifdef NEW_TEXT
+               for (; i < size() && current_cell_number < cell; ++i) {
+#else
+               for (; i < last && (current_cell_number < cell); ++i) {
+#endif
                        c = GetChar(i);
                        if (c == LYX_META_NEWLINE)
                                current_cell_number++;
                }
                lastpos = i;
-               c=GetChar(i);
+               c = GetChar(i);
                // I don't know how to handle this so I comment it
                 // for the moment (Jug)
 //             if (table->Linebreaks(table->FirstVirtualCell(cell))) {
@@ -2805,8 +3503,14 @@ void LyXParagraph::DocBookContTableRows(string &file, string &extra,
                if ((c != ' ') && (c != LYX_META_NEWLINE)) {
                        file += ' ';
                }
-               for (; (i < last) && ((c=GetChar(i)) != LYX_META_NEWLINE); i++) {
-                       column++;
+#ifdef NEW_TEXT
+               for (; i < size() && (c = GetChar(i)) != LYX_META_NEWLINE;
+                    ++i) {
+#else
+               for (; i < last && ((c = GetChar(i)) != LYX_META_NEWLINE);
+                    ++i) {
+#endif
+                       ++column;
                        
                        // Fully instantiated font
                        font2 = getFont(i);
@@ -2835,9 +3539,9 @@ void LyXParagraph::DocBookContTableRows(string &file, string &extra,
                                //   and title should come first
                                //       desc_on==4
                                //
-                               if(desc_on!=3 || i!=0) {
+                               if(desc_on != 3 || i != 0) {
                                        if(tmp_out[0]=='@') {
-                                               if(desc_on==4)
+                                               if(desc_on == 4)
                                                        extra += frontStrip(tmp_out, '@');
                                                else
                                                        file += frontStrip(tmp_out, '@');
@@ -2852,7 +3556,7 @@ void LyXParagraph::DocBookContTableRows(string &file, string &extra,
                        } else {
                                string sgml_string;
                                if (linuxDocConvertChar(c, sgml_string) 
-                                   && !style->free_spacing) {
+                                   && !style.free_spacing) {
                                // in freespacing mode, spaces are
                                // non-breaking characters
                                // char is ' '
@@ -2880,22 +3584,30 @@ void LyXParagraph::DocBookContTableRows(string &file, string &extra,
        lyxerr[Debug::LATEX] << "DocBookContTableRows...done " << this << endl;
 }
 
-
-//
-void LyXParagraph::SimpleTeXBlanks(string &file, TexRow &texrow,
-                                  int const i, int &column, LyXFont const &font,
-                                  LyXLayout const * const style)
+#ifdef NEW_TEXT
+void LyXParagraph::SimpleTeXBlanks(string & file, TexRow & texrow,
+                                  LyXParagraph::size_type const i, int & column, LyXFont const & font,
+                                  LyXLayout const & style)
+#else
+void LyXParagraph::SimpleTeXBlanks(string & file, TexRow & texrow,
+                                  int const i, int & column, LyXFont const & font,
+                                  LyXLayout const & style)
+#endif
 {
        if (column > tex_code_break_column
            && i 
-           && GetChar(i-1) != ' '
+           && GetChar(i - 1) != ' '
+#ifdef NEW_TEXT
+           && (i < size() - 1)
+#else
            && (i < last-1)
+#endif
            // In LaTeX mode, we don't want to
            // break lines since some commands
            // do not like this
            && ! (font.latex() == LyXFont::ON)
            // same in FreeSpacing mode
-           && !style->free_spacing
+           && !style.free_spacing
            // In typewriter mode, we want to avoid 
            // ! . ? : at the end of a line
            && !(font.family() == LyXFont::TYPEWRITER_FAMILY
@@ -2914,7 +3626,7 @@ void LyXParagraph::SimpleTeXBlanks(string &file, TexRow &texrow,
                texrow.start(this, i+1);
                column = 0;
        } else if (font.latex() == LyXFont::OFF) {
-               if (style->free_spacing) {
+               if (style.free_spacing) {
                        file += '~';
                } else {
                        file += ' ';
@@ -2923,23 +3635,31 @@ void LyXParagraph::SimpleTeXBlanks(string &file, TexRow &texrow,
 }
 
 
-//
-void LyXParagraph::SimpleTeXSpecialChars(string &file, TexRow &texrow,
-                                        LyXFont &font, LyXFont &running_font, LyXFont &basefont,
-                                        bool &open_font, LyXLayout const * const style,
-                                        int &i, int &column, char const c)
+#ifdef NEW_TEXT
+void LyXParagraph::SimpleTeXSpecialChars(string & file, TexRow & texrow,
+                                        LyXFont & font, LyXFont & running_font,
+                                        LyXFont & basefont,
+                                        bool & open_font,
+                                        LyXLayout const & style,
+                                        LyXParagraph::size_type & i, int &column, char const c)
+#else 
+void LyXParagraph::SimpleTeXSpecialChars(string & file, TexRow & texrow,
+                                        LyXFont & font, LyXFont & running_font,
+                                        LyXFont & basefont,
+                                        bool & open_font,
+                                        LyXLayout const & style,
+                                        int & i, int &column, char const c)
+#endif
 {
-       Inset* inset;
-
        // Two major modes:  LaTeX or plain
        // Handle here those cases common to both modes
        // and then split to handle the two modes separately.
        switch (c) {
-       case LYX_META_INSET:
-               inset = GetInset(i);
+       case LYX_META_INSET: {
+               Inset * inset = GetInset(i);
                if (inset) {
                        int len = file.length();
-                       int tmp = inset->Latex(file, style->isCommand());
+                       int tmp = inset->Latex(file, style.isCommand());
                        
                        if (tmp) {
                                column = 0;
@@ -2950,7 +3670,8 @@ void LyXParagraph::SimpleTeXSpecialChars(string &file, TexRow &texrow,
                                texrow.newline();
                        }
                }
-               break;
+       }
+       break;
 
        case LYX_META_NEWLINE:
                if (open_font) {
@@ -3020,7 +3741,11 @@ void LyXParagraph::SimpleTeXSpecialChars(string &file, TexRow &texrow,
                                        file += c;
                                        //... but we should avoid ligatures
                                        if ((c == '>' || c == '<')
-                                           && i <= last-2
+#ifdef NEW_TEXT
+                                           && i <= size() - 2
+#else
+                                           && i <= last - 2
+#endif
                                            && GetChar(i+1) == c){
                                                file += "\\textcompwordmark{}";
                                                column += 19;
@@ -3051,8 +3776,12 @@ void LyXParagraph::SimpleTeXSpecialChars(string &file, TexRow &texrow,
                                break;
 
                        case '-': // "--" in Typewriter mode -> "-{}-"
-                               if (i <= last-2
-                                   && GetChar(i+1) == '-'
+#ifdef NEW_TEXT
+                               if (i <= size() - 2
+#else
+                               if (i <= last - 2
+#endif
+                                   && GetChar(i + 1) == '-'
                                    && font.family() == LyXFont::TYPEWRITER_FAMILY) {
                                        file += "-{}";
                                        column += 2;
@@ -3110,46 +3839,62 @@ void LyXParagraph::SimpleTeXSpecialChars(string &file, TexRow &texrow,
                                /* idea for labels --- begin*/
                                /* check for LyX */
                                if (c ==  'L'
-                                   && i <= last-3
+#ifdef NEW_TEXT
+                                   && i <= size() - 3
+#else
+                                   && i <= last - 3
+#endif
                                    && font.family() != LyXFont::TYPEWRITER_FAMILY
-                                   && GetChar(i+1) == 'y'
-                                   && GetChar(i+2) == 'X') {
+                                   && GetChar(i + 1) == 'y'
+                                   && GetChar(i + 2) == 'X') {
                                        file += "\\LyX{}";
                                        i += 2;
                                        column += 5;
                                }
                                /* check for TeX */ 
                                else if (c == 'T'
+#ifdef NEW_TEXT
+                                        && i <= size() - 3
+#else
                                         && i <= last-3
+#endif
                                         && font.family() != LyXFont::TYPEWRITER_FAMILY
-                                        && GetChar(i+1) == 'e'
-                                        && GetChar(i+2) == 'X') {
+                                        && GetChar(i + 1) == 'e'
+                                        && GetChar(i + 2) == 'X') {
                                        file += "\\TeX{}";
                                        i += 2;
                                        column += 5;
                                }
                                /* check for LaTeX2e */ 
                                else if (c == 'L'
+#ifdef NEW_TEXT
+                                        && i <= size() - 7
+#else
                                         && i <= last-7
+#endif
                                         && font.family() != LyXFont::TYPEWRITER_FAMILY
-                                        && GetChar(i+1) == 'a'
-                                        && GetChar(i+2) == 'T'
-                                        && GetChar(i+3) == 'e'
-                                        && GetChar(i+4) == 'X'
-                                        && GetChar(i+5) == '2'
-                                        && GetChar(i+6) == 'e') {
+                                        && GetChar(i + 1) == 'a'
+                                        && GetChar(i + 2) == 'T'
+                                        && GetChar(i + 3) == 'e'
+                                        && GetChar(i + 4) == 'X'
+                                        && GetChar(i + 5) == '2'
+                                        && GetChar(i + 6) == 'e') {
                                        file += "\\LaTeXe{}";
                                        i += 6;
                                        column += 8;
                                }
                                /* check for LaTeX */ 
                                else if (c == 'L'
-                                        && i <= last-5
+#ifdef NEW_TEXT
+                                        && i <= size() - 5
+#else
+                                        && i <= last - 5
+#endif
                                         && font.family() != LyXFont::TYPEWRITER_FAMILY
-                                        && GetChar(i+1) == 'a'
-                                        && GetChar(i+2) == 'T'
-                                        && GetChar(i+3) == 'e'
-                                        && GetChar(i+4) == 'X') {
+                                        && GetChar(i + 1) == 'a'
+                                        && GetChar(i + 2) == 'T'
+                                        && GetChar(i + 3) == 'e'
+                                        && GetChar(i + 4) == 'X') {
                                        file += "\\LaTeX{}";
                                        i += 4;
                                        column += 7;
@@ -3163,43 +3908,50 @@ void LyXParagraph::SimpleTeXSpecialChars(string &file, TexRow &texrow,
        }
 }
 
-
-bool LyXParagraph::RoffContTableRows(FILE *fp, int i, int actcell)
+#ifdef NEW_TEXT
+bool LyXParagraph::RoffContTableRows(FILE * fp,
+                                    LyXParagraph::size_type i,
+                                    int actcell)
+#else
+bool LyXParagraph::RoffContTableRows(FILE * fp, int i, int actcell)
+#endif
 {
        if (!table)
                return false;
 
-       LyXFont
-               font1 = LyXFont(LyXFont::ALL_INHERIT),
-               font2;
-       Inset
-               *inset;
-       int
-               lastpos, cell;
-       char
-               c;
-       string
-               fname2;
-       FILE
-               *fp2;
-
-       fname2 = TmpFileName(string(),"RAT2");
-       lastpos = i;
-       cell = table->CellHasContRow(actcell);
+       LyXFont font1 = LyXFont(LyXFont::ALL_INHERIT);
+       LyXFont font2;
+       Inset * inset;
+       char c;
+       FILE * fp2;
+
+       string fname2 = TmpFileName(string(), "RAT2");
+       int lastpos = i;
+       int cell = table->CellHasContRow(actcell);
        actcell++;
        while(cell >= 0) {
                // first find the right position
                i = lastpos;
-               for (; (i<last) && (actcell<cell); i++) {
+#ifdef NEW_TEXT
+               for (; i < size() && actcell < cell; ++i) {
+#else
+               for (; i < last && actcell < cell; ++i) {
+#endif
                        c = GetChar(i);
                        if (c == LYX_META_NEWLINE)
                                actcell++;
                }
                lastpos = i;
-               c=GetChar(i);
+               c = GetChar(i);
                if ((c != ' ') && (c != LYX_META_NEWLINE))
                        fprintf(fp," ");
-               for (; (i < last) && ((c=GetChar(i)) != LYX_META_NEWLINE); i++) {
+#ifdef NEW_TEXT
+               for (; i < size() && (c = GetChar(i)) != LYX_META_NEWLINE;
+                    ++i) {
+#else
+               for (; (i < last) && ((c=GetChar(i)) != LYX_META_NEWLINE);
+                    ++i) {
+#endif
                        font2 = GetFontSettings(i);
                        if (font1.latex() != font2.latex()) {
                                if (font2.latex() != LyXFont::OFF)
@@ -3248,18 +4000,18 @@ bool LyXParagraph::RoffContTableRows(FILE *fp, int i, int actcell)
        return true;
 }
 
-LyXParagraph * LyXParagraph::TeXDeeper(string &file, TexRow &texrow,
-                                      string &foot, TexRow &foot_texrow,
-                                      int &foot_count)
+LyXParagraph * LyXParagraph::TeXDeeper(string & file, TexRow & texrow,
+                                      string & foot, TexRow & foot_texrow,
+                                      int & foot_count)
 {
        lyxerr[Debug::LATEX] << "TeXDeeper...     " << this << endl;
-       LyXParagraph *par = this;
+       LyXParagraph * par = this;
 
        while (par && par->depth == depth) {
                if (par->IsDummy())
                        lyxerr << "ERROR (LyXParagraph::TeXDeeper)" << endl;
-               if (lyxstyle.Style(GetCurrentTextClass(), 
-                                  par->layout)->isEnvironment()
+               if (textclasslist.Style(GetCurrentTextClass(), 
+                                  par->layout).isEnvironment()
                    || par->pextra_type != PEXTRA_NONE) 
                        {
                                par = par->TeXEnvironment(file, texrow,
@@ -3277,27 +4029,22 @@ LyXParagraph * LyXParagraph::TeXDeeper(string &file, TexRow &texrow,
 }
 
 
-LyXParagraph* LyXParagraph::TeXEnvironment(string &file, TexRow &texrow,
-                                          string &foot, TexRow &foot_texrow,
-                                          int &foot_count)
+LyXParagraph * LyXParagraph::TeXEnvironment(string & file, TexRow & texrow,
+                                          string & foot, TexRow & foot_texrow,
+                                          int & foot_count)
 {
-       bool
-               eindent_open = false;
-       bool
-               foot_this_level = false;
+       bool eindent_open = false;
+       bool foot_this_level = false;
                // flags when footnotetext should be appended to file.
-        static bool
-               minipage_open = false;
-        static int
-                minipage_open_depth = 0;
-       char
-               par_sep = current_view->currentBuffer()->params.paragraph_separation;
+        static bool minipage_open = false;
+        static int minipage_open_depth = 0;
+       char par_sep = current_view->currentBuffer()->params.paragraph_separation;
     
        lyxerr[Debug::LATEX] << "TeXEnvironment...     " << this << endl;
        if (IsDummy())
                lyxerr << "ERROR (LyXParagraph::TeXEnvironment)" << endl;
 
-       LyXLayout * style = lyxstyle.Style(GetCurrentTextClass(), layout);
+       LyXLayout const & style = textclasslist.Style(GetCurrentTextClass(), layout);
        
        if (pextra_type == PEXTRA_INDENT) {
                if (!pextra_width.empty()) {
@@ -3385,8 +4132,8 @@ LyXParagraph* LyXParagraph::TeXEnvironment(string &file, TexRow &texrow,
        //I disabled it because it breaks when lists span on several
        //pages (JMarc)
 #endif
-       if (style->isEnvironment()){
-               if (style->latextype == LATEX_LIST_ENVIRONMENT) {
+       if (style.isEnvironment()){
+               if (style.latextype == LATEX_LIST_ENVIRONMENT) {
 #ifdef FANCY_FOOTNOTE_CODE
                        if (foot_count < 0) {
                                // flag that footnote[mark][text] should be
@@ -3395,13 +4142,13 @@ LyXParagraph* LyXParagraph::TeXEnvironment(string &file, TexRow &texrow,
                                foot_this_level = true;
                        }
 #endif
-                       file += "\\begin{" + style->latexname + "}{"
+                       file += "\\begin{" + style.latexname() + "}{"
                                + labelwidthstring + "}\n";
-               } else if (style->labeltype == LABEL_BIBLIO) {
+               } else if (style.labeltype == LABEL_BIBLIO) {
                        // ale970405
-                       file += "\\begin{" + style->latexname + "}{"
+                       file += "\\begin{" + style.latexname() + "}{"
                                + bibitemWidthest() + "}\n";
-               } else if (style->latextype == LATEX_ITEM_ENVIRONMENT) {
+               } else if (style.latextype == LATEX_ITEM_ENVIRONMENT) {
 #ifdef FANCY_FOOTNOTE_CODE
                        if (foot_count < 0) {
                                // flag that footnote[mark][text] should be
@@ -3410,27 +4157,19 @@ LyXParagraph* LyXParagraph::TeXEnvironment(string &file, TexRow &texrow,
                                foot_this_level = true;
                        }
 #endif
-                       file += "\\begin{" + style->latexname + '}'
-                               + style->latexparam + '\n';
+                       file += "\\begin{" + style.latexname() + '}'
+                               + style.latexparam() + '\n';
                } else 
-                       file += "\\begin{" + style->latexname + '}'
-                               + style->latexparam + '\n';
+                       file += "\\begin{" + style.latexname() + '}'
+                               + style.latexparam() + '\n';
                texrow.newline();
        }
-       LyXParagraph *par = this;
+       LyXParagraph * par = this;
        do {
                par = par->TeXOnePar(file, texrow,
                                     foot, foot_texrow, foot_count);
-#if 0
-               if (eindent_open && par && par->pextra_type != PEXTRA_INDENT) {
-                       file += "\\end{LyXParagraphIndent}\n";
-                       texrow.newline();
-                       eindent_open = false;
-                       if (!style->isEnvironment())
-                               break;
-               }
-#endif
-                if (minipage_open && par && !style->isEnvironment() &&
+
+                if (minipage_open && par && !style.isEnvironment() &&
                     (par->pextra_type == PEXTRA_MINIPAGE) &&
                     par->pextra_start_minipage) {
                     file += "\\end{minipage}\n";
@@ -3442,8 +4181,8 @@ LyXParagraph* LyXParagraph::TeXEnvironment(string &file, TexRow &texrow,
                     minipage_open = false;
                 }
                if (par && par->depth > depth) {
-                       if (lyxstyle.Style(GetCurrentTextClass(),
-                                          par->layout)->isParagraph()
+                       if (textclasslist.Style(GetCurrentTextClass(),
+                                          par->layout).isParagraph()
                            && !par->table
                            && !suffixIs(file, "\n\n")) {
                            // There should be at least one '\n' already
@@ -3464,8 +4203,6 @@ LyXParagraph* LyXParagraph::TeXEnvironment(string &file, TexRow &texrow,
                                file += "\\hfill{}\n";
                                 texrow.newline();
                         }
-//                     else
-//                             file += '\n';
                        if (par_sep == LYX_PARSEP_INDENT) {
                                file += "{\\setlength\\parindent{0pt}\n";
                                texrow.newline();
@@ -3519,8 +4256,8 @@ LyXParagraph* LyXParagraph::TeXEnvironment(string &file, TexRow &texrow,
                 && par->depth == depth
                 && par->pextra_type == pextra_type);
  
-       if (style->isEnvironment()) {
-               file += "\\end{" + style->latexname + '}';
+       if (style.isEnvironment()) {
+               file += "\\end{" + style.latexname() + '}';
                // maybe this should go after the minipage closes?
                if (foot_this_level) {
                        if (foot_count >= 1) {
@@ -3557,7 +4294,6 @@ LyXParagraph* LyXParagraph::TeXEnvironment(string &file, TexRow &texrow,
                file += "\\end{LyXParagraphIndent}\n";
                texrow.newline();
        }
-//     if (tex_code_break_column){
         if (!(par && (par->pextra_type==PEXTRA_MINIPAGE) 
              && par->pextra_hfill)) {
                 file += '\n';
@@ -3568,20 +4304,20 @@ LyXParagraph* LyXParagraph::TeXEnvironment(string &file, TexRow &texrow,
 }
 
 
-LyXParagraph * LyXParagraph::TeXFootnote(string &file, TexRow &texrow,
-                                        string &foot, TexRow &foot_texrow,
-                                        int &foot_count)
+LyXParagraph * LyXParagraph::TeXFootnote(string & file, TexRow & texrow,
+                                        string & foot, TexRow & foot_texrow,
+                                        int & foot_count)
 {
        lyxerr[Debug::LATEX] << "TeXFootnote...  " << this << endl;
        if (footnoteflag == LyXParagraph::NO_FOOTNOTE)
                lyxerr << "ERROR (LyXParagraph::TeXFootnote): "
                        "No footnote!" << endl;
 
-       LyXParagraph *par = this;
-       LyXLayout * style = lyxstyle.Style(GetCurrentTextClass(), 
+       LyXParagraph * par = this;
+       LyXLayout const & style = textclasslist.Style(GetCurrentTextClass(), 
                                           previous->GetLayout());
        
-       if (style->needprotect && footnotekind != LyXParagraph::FOOTNOTE){
+       if (style.needprotect && footnotekind != LyXParagraph::FOOTNOTE){
                lyxerr << "ERROR (LyXParagraph::TeXFootnote): "
                        "Float other than footnote in command"
                        " with moving argument is illegal" << endl;
@@ -3601,11 +4337,11 @@ LyXParagraph * LyXParagraph::TeXFootnote(string &file, TexRow &texrow,
                texrow.newline();
        }
        
-       BufferParams *params = &current_view->currentBuffer()->params;
+       BufferParams * params = &current_view->currentBuffer()->params;
        bool footer_in_body = true;
        switch (footnotekind) {
        case LyXParagraph::FOOTNOTE:
-               if (style->intitle) {
+               if (style.intitle) {
                        file += "\\thanks{\n";
                        footer_in_body = false;
                } else {
@@ -3693,12 +4429,12 @@ LyXParagraph * LyXParagraph::TeXFootnote(string &file, TexRow &texrow,
            || !footer_in_body) {
                // Process text for all floats except footnotes in body
                do {
-                       LyXLayout *style = lyxstyle.Style(GetCurrentTextClass(),
+                       LyXLayout const & style = textclasslist.Style(GetCurrentTextClass(),
                                                          par->layout);
                        if (par->IsDummy())
                                lyxerr << "ERROR (LyXParagraph::TeXFootnote)"
                                       << endl;
-                       if (style->isEnvironment()
+                       if (style.isEnvironment()
                            || par->pextra_type == PEXTRA_MINIPAGE) { /* && !minipage_open ?? */
                                // Allows the use of minipages within float environments.
                                // Shouldn't be circular because we don't support
@@ -3726,12 +4462,12 @@ LyXParagraph * LyXParagraph::TeXFootnote(string &file, TexRow &texrow,
                TexRow dummy_texrow;
                int dummy_count = 0;
                do {
-                       LyXLayout *style = lyxstyle.Style(GetCurrentTextClass(),
+                       LyXLayout const & style = textclasslist.Style(GetCurrentTextClass(),
                                                          par->layout);
                        if (par->IsDummy())
                                lyxerr << "ERROR (LyXParagraph::TeXFootnote)"
                                       << endl;
-                       if (style->isEnvironment()
+                       if (style.isEnvironment()
                            || par->pextra_type == PEXTRA_MINIPAGE) { /* && !minipage_open ?? */
                                // Allows the use of minipages within float environments.
                                // Shouldn't be circular because we don't support
@@ -3808,17 +4544,18 @@ LyXParagraph * LyXParagraph::TeXFootnote(string &file, TexRow &texrow,
 }
 
 
-void LyXParagraph::SetPExtraType(int type, const char *width,const char *widthp)
+void LyXParagraph::SetPExtraType(int type, char const * width,
+                                char const * widthp)
 {
     pextra_type = type;
     pextra_width = width;
     pextra_widthp = widthp;
 
-    if (lyxstyle.Style(GetCurrentTextClass(), 
-                       layout)->isEnvironment()) {
+    if (textclasslist.Style(GetCurrentTextClass(), 
+                       layout).isEnvironment()) {
         LyXParagraph
-            *par = this,
-            *ppar = par;
+            * par = this,
+            * ppar = par;
 
         while (par && (par->layout == layout) && (par->depth == depth)) {
             ppar = par;
@@ -3854,11 +4591,11 @@ void LyXParagraph::UnsetPExtraType()
     pextra_width.clear();
     pextra_widthp.clear();
 
-    if (lyxstyle.Style(GetCurrentTextClass(), 
-                       layout)->isEnvironment()) {
+    if (textclasslist.Style(GetCurrentTextClass(), 
+                       layout).isEnvironment()) {
         LyXParagraph
-            *par = this,
-            *ppar = par;
+            * par = this,
+            * ppar = par;
 
         while (par && (par->layout == layout) && (par->depth == depth)) {
             ppar = par;
index b5b553727828aa8a7f293a542c3dd13a654cd9b8..d52063fe8044de8f2491b9d47dccfe289a03d7ee 100644 (file)
@@ -29,3 +29,4 @@ libsupport_a_SOURCES = \
        syscontr.h \
        syssingleton.C \
        textutils.h
+
index afe48aeaa88fc1b1dda225ad35d26fbfec326070..c1e82424ab8e127cea1a862e341c760e49c949cd 100644 (file)
@@ -604,7 +604,7 @@ bool AbsolutePath(string const & path)
 #ifndef __EMX__
        return (!path.empty() && path[0] == '/');
 #else
-       return (!path.empty() && (path[0]=='/' || (isalpha((unsigned char) path[0]) && path.length()>1 && path[1]==':')));
+       return (!path.empty() && (path[0]=='/' || (isalpha(static_cast<unsigned char>(path[0])) && path.length()>1 && path[1]==':')));
 #endif
 }
 
@@ -751,10 +751,10 @@ string ReplaceEnvironmentPath(string const & path)
                // Check for variable names
                // Situation ${} is detected as "No Environmentvariable"
                const char * cp1 = res1_contents+1;
-               bool result = isalpha((unsigned char) *cp1) || (*cp1 == UnderscoreChar);
+               bool result = isalpha(*cp1) || (*cp1 == UnderscoreChar);
                ++cp1;
                while (*cp1 && result) {
-                       result = isalnum((unsigned char) *cp1) || 
+                       result = isalnum(*cp1) || 
                                (*cp1 == UnderscoreChar); 
                        ++cp1;
                }
index 1d12bd51d24507c62975e7b640b24c347fd983ef..4481f4c2450850d335703f8b99cb40b1eb136087 100644 (file)
@@ -1200,6 +1200,7 @@ lyxstring::size_type lyxstring::find_last_not_of(value_type const * ptr,
 
        if (!n) return npos;
        size_type ii = min(rep->sz - 1, i);
+
        for (int t = ii; t >= 0; --t) {
                if(memchr(ptr, rep->s[t], n) == 0) return t;
        }
@@ -1675,10 +1676,10 @@ istream & getline(istream & is, lyxstring & s,
                  lyxstring::value_type delim)
 {
        // very bad solution
-       char tmp;
+       char tmp = 0;
        s.erase();
        while(is) {
-               is >> tmp;
+               is.get(tmp);
                if (tmp != delim) {
                        s += tmp;
                } else {
index 8b18c28704b51bdf7fe78431d27c2bdf49b8537e..77521afacd516c78fe40dad2717e531b2784d4e4 100644 (file)
@@ -17,7 +17,7 @@
 #include "support/lstrings.h"
 
 Systemcalls::Systemcalls() {
-       pid = (pid_t) 0; // No child yet
+       pid = 0; // No child yet
 }
 
 Systemcalls::Systemcalls(Starttype how, string const & what, Callbackfct cback)
index bd6ff67a1d2d83b9e7546bcfa4bb83b98b720692..06ec83ef292ef2d14c85c1e576067610a68a616a 100644 (file)
@@ -845,9 +845,6 @@ void LyXTable::Write(FILE* file)
     }
 }
 
-#ifdef WITH_WARNINGS
-#warning Clean up this code in 0.13 (Jug)
-#endif
 void LyXTable::Read(FILE* file)
 {
     int version;
@@ -873,14 +870,18 @@ void LyXTable::Read(FILE* file)
         version = atoi(s.c_str()+8);
     else
         version = 1;
+#ifdef WITH_WARNINGS
+#warning Insert a error message window here that this format is not supported anymore
+#endif
+    if (version < 5) {
+       fprintf(stderr,"Tabular format < 5 is not supported anymore\n"
+               "Get an older version of LyX (< 1.1.x) for conversion!\n");
+       return;
+    }
     a=b=c=d=-1;
-    if (version > 2) {
-        fgets(vtmp,sizeof(vtmp),file);
-        sscanf(vtmp, "%d %d %d %d %d %d %d %d\n", &rows_arg, &columns_arg,
-               &is_long_table_arg, &rotate_arg, &a, &b, &c, &d);
-    } else
-        fscanf(file, "%d %d\n",
-               &rows_arg, &columns_arg);
+    fgets(vtmp,sizeof(vtmp),file);
+    sscanf(vtmp, "%d %d %d %d %d %d %d %d\n", &rows_arg, &columns_arg,
+          &is_long_table_arg, &rotate_arg, &a, &b, &c, &d);
     Init(rows_arg, columns_arg);
     SetLongTable(is_long_table_arg);
     SetRotateTable(rotate_arg);
@@ -921,57 +922,37 @@ void LyXTable::Read(FILE* file)
         } else if (*stmp)
             column_info[i].p_width = stmp;
     }
-    if (version == 1){
-        for (i=0; i<rows;i++){
-            for (j=0;j<columns;j++){
-                fscanf(file, "%d %d\n", &a, &b);
-                cell_info[i][j].multicolumn = (char) a;
-                cell_info[i][j].alignment = (char) b;
-            }
-        }
-    } else if (version < 4) {
-        for (i=0; i<rows;i++){
-            for (j=0;j<columns;j++){
-                fscanf(file, "%d %d %d %d\n", &a, &b, &c, &d);
-                cell_info[i][j].multicolumn = (char) a;
-                cell_info[i][j].alignment = (char) b;
-                cell_info[i][j].top_line = (char) c;
-                cell_info[i][j].bottom_line = (char) d;
-            }
-        }
-    } else {
-        for (i=0; i<rows;i++){
-            for (j=0;j<columns;j++){
-                *stmp = 0;
-                *atmp = 0;
-                a=b=c=d=e=f=g=0;
-                fgets(vtmp,sizeof(vtmp),file);
-                sscanf(vtmp, "%d %d %d %d %d %d %d %s %s\n",
-                       &a, &b, &c, &d, &e, &f, &g, stmp, atmp);
-                cell_info[i][j].multicolumn = (char) a;
-                cell_info[i][j].alignment = (char) b;
-                cell_info[i][j].top_line = (char) c;
-                cell_info[i][j].bottom_line = (char) d;
-                cell_info[i][j].has_cont_row = (bool) e;
-                cell_info[i][j].rotate = (bool) f;
-                cell_info[i][j].linebreaks = (bool) g;
-                // this is only to see if I have an empty string first
-                // this clause should be always TRUE!!!
-                if (*stmp == '"') {
-                    *stmp = 0;
-                    *atmp = 0;
-                    if (stmp[1] == '"')
-                        sscanf(vtmp,"%*d %*d %*d %*d %*d %*d %*d %*s \"%[^\"]\"",
-                               atmp);
-                    else // otherwise after the first empty "" read is aborded
-                        sscanf(vtmp,"%*d %*d %*d %*d %*d %*d %*d \"%[^\"]\" \"%[^\"]\"",
-                               stmp, atmp);
-                    cell_info[i][j].align_special = stmp;
-                    cell_info[i][j].p_width = atmp;
-                } else if (*stmp)
-                    cell_info[i][j].align_special = stmp;
-            }
-        }
+    for (i=0; i<rows;i++){
+       for (j=0;j<columns;j++){
+           *stmp = 0;
+           *atmp = 0;
+           a=b=c=d=e=f=g=0;
+           fgets(vtmp,sizeof(vtmp),file);
+           sscanf(vtmp, "%d %d %d %d %d %d %d %s %s\n",
+                  &a, &b, &c, &d, &e, &f, &g, stmp, atmp);
+           cell_info[i][j].multicolumn = (char) a;
+           cell_info[i][j].alignment = (char) b;
+           cell_info[i][j].top_line = (char) c;
+           cell_info[i][j].bottom_line = (char) d;
+           cell_info[i][j].has_cont_row = (bool) e;
+           cell_info[i][j].rotate = (bool) f;
+           cell_info[i][j].linebreaks = (bool) g;
+           // this is only to see if I have an empty string first
+           // this clause should be always TRUE!!!
+           if (*stmp == '"') {
+               *stmp = 0;
+               *atmp = 0;
+               if (stmp[1] == '"')
+                   sscanf(vtmp,"%*d %*d %*d %*d %*d %*d %*d %*s \"%[^\"]\"",
+                          atmp);
+               else // otherwise after the first empty "" read is aborded
+                   sscanf(vtmp,"%*d %*d %*d %*d %*d %*d %*d \"%[^\"]\" \"%[^\"]\"",
+                          stmp, atmp);
+               cell_info[i][j].align_special = stmp;
+               cell_info[i][j].p_width = atmp;
+           } else if (*stmp)
+               cell_info[i][j].align_special = stmp;
+       }
     }
     set_row_column_number_info();
 }
@@ -1189,13 +1170,6 @@ int LyXTable::TexEndOfCell(string& file, int cell)
                 if (nvcell < numberofcells && (cell < GetNumberOfCells()-1) &&
                     !ShouldBeVeryLastCell(cell)) {
                     fcell = nvcell;
-#if 0
-                    // Now jump all ContRows
-                    while (IsContRow(fcell))
-                        fcell++;
-                    while (!IsFirstCell(fcell))
-                        fcell--;
-#endif
                     for (i=0; i < NumberOfCellsInRow(fcell); i++){
                         if (TopLine(fcell+i))
                             tmp++;
@@ -1469,46 +1443,6 @@ int LyXTable::DocBookEndOfCell(string& file, int cell, int &depth)
     //int tmp; // tmp2; // unused
     int nvcell; // fcell; // unused
     if (ShouldBeVeryLastCell(cell)) {
-#if 0
-        // the very end at the very beginning
-        if (Linebreaks(cell))
-            file += "\\smallskip{}}";
-        if (IsMultiColumn(cell))
-            file += '}';
-        if (RotateCell(cell)) {
-            file += "\n\\end{sideways}";
-            ret++;
-        }
-        file += "\\\\\n";
-        ret++;
-    
-        tmp = 0;
-        fcell = cell; 
-        while (!IsFirstCell(fcell))fcell--;
-        for (i=0; i < NumberOfCellsInRow(fcell); i++){
-            if (BottomLine(fcell+i))
-                tmp++;
-        }
-        if (tmp == NumberOfCellsInRow(fcell)){
-            file += "\\hline ";
-        } else {
-            tmp = 0;
-            for (i=0; i < NumberOfCellsInRow(fcell); i++){
-                if (BottomLine(fcell+i)){
-                   file += "\\cline{";
-                   file += column_of_cell(fcell+i)+1;
-                   file += '-';
-                   file += right_column_of_cell(fcell+i)+1;
-                   file += "} ";
-                    tmp = 1;
-                }
-            }
-        }
-        if (tmp){
-            file += '\n';
-            ret++;
-        }
-#endif
        addNewlineAndDepth(file,--depth);
         file += "</ENTRY>";
        addNewlineAndDepth(file,--depth);
@@ -1521,12 +1455,6 @@ int LyXTable::DocBookEndOfCell(string& file, int cell, int &depth)
         else
             file += "</TGROUP>";
        addNewlineAndDepth(file,--depth);
-#if 0
-        if (rotate) {
-            file += "\n\\end{sideways}";
-            ret++;
-        }
-#endif
         ret += 4;
     } else {
         nvcell = NextVirtualCell(cell+1);
@@ -1566,39 +1494,6 @@ int LyXTable::DocBookEndOfCell(string& file, int cell, int &depth)
                     file += '|';
 #endif
             }
-#if 0
-            tmp = 0;
-            if (GetNumberOfCells()) {
-                fcell = 0;
-                for (i=0; i < NumberOfCellsInRow(fcell); i++){
-                    if (TopLine(fcell+i))
-                        tmp++;
-                }
-                if (tmp == NumberOfCellsInRow(fcell)){
-                    file += "\\hline ";
-                } else {
-                    tmp = 0;
-                    for (i=0; i < NumberOfCellsInRow(fcell); i++){
-                        if (TopLine(fcell+i)){
-                           file += "\\cline{";
-                           file += column_of_cell(fcell+i)+1;
-                           file += '-';
-                           file += right_column_of_cell(fcell+i)+1;
-                           file += "} ";
-                            tmp = 1;
-                        }
-                    }
-                }
-                if (tmp){
-                    file += '\n';
-                    ret++;
-                }
-            }
-            if (RotateCell(0)) {
-                file += "\\begin{sideways}\n";
-                ret++;
-            }
-#endif
             file += "<TBODY>";
            addNewlineAndDepth(file,++depth);
             file += "<ROW>";
@@ -1615,18 +1510,6 @@ int LyXTable::DocBookEndOfCell(string& file, int cell, int &depth)
            addNewlineAndDepth(file,++depth);
             ret += 3;
         } else {
-#if 0
-            // usual cells
-            if (Linebreaks(cell))
-                file += "\\smallskip{}}";
-            if (IsMultiColumn(cell)){
-                file += '}';
-            }
-            if (RotateCell(cell)) {
-                file += "\n\\end{sideways}";
-                ret++;
-            }
-#endif
             if (IsLastCell(cell)) {
                addNewlineAndDepth(file,--depth);
                 file += "</ENTRY>";
@@ -1649,157 +1532,6 @@ int LyXTable::DocBookEndOfCell(string& file, int cell, int &depth)
                file += ">";
                addNewlineAndDepth(file,++depth);
                 ret += 4;
-#if 0
-                int row = row_of_cell(cell);
-                string hline1,hline2;
-                bool print_hline = true;
-                bool pr_top_hline,flag1,flag2;
-                flag1 = IsLongTable() &&
-                    ((row == endhead) || (row == endfirsthead) ||
-                     (row == endfoot) || (row == endlastfoot));
-                row++;
-                flag2 = IsLongTable() &&
-                    ((row <= endhead) || (row <= endfirsthead) ||
-                     (row <= endfoot) || (row <= endlastfoot));
-                row--;
-                // print the bottom hline only if (otherwise it is doubled):
-                // - is no LongTable
-                // - there IS a first-header
-                // - the next row is no special header/footer
-                //   & this row is no special header/footer
-                // - the next row is a special header/footer
-                //   & this row is a special header/footer
-                pr_top_hline = (flag1 && flag2) || (!flag1 && !flag2) ||
-                    (endfirsthead == endhead);
-                file += "\\\\\n";
-                ret++;
-                tmp = 0;
-                fcell = cell;
-                while (!IsFirstCell(fcell))
-                    fcell--;
-                for (i=0; i < NumberOfCellsInRow(cell); i++){
-                    if (BottomLine(fcell+i))
-                        tmp++;
-                }
-                if (tmp == NumberOfCellsInRow(cell)){
-                    file += "\\hline ";
-                    hline1 = "\\hline ";
-                } else {
-                    tmp = 0;
-                    for (i=0; i < NumberOfCellsInRow(fcell); i++){
-                        if (BottomLine(fcell+i)){
-                            file += "\\cline{";
-                            file += column_of_cell(fcell+i)+1;
-                            file += '-';
-                            file += right_column_of_cell(fcell+i)+1;
-                            file += "} ";
-                            hline1 += "\\cline{";
-                            hline1 += column_of_cell(fcell+i)+1;
-                            hline1 += '-';
-                            hline1 += right_column_of_cell(fcell+i)+1;
-                            hline1 += "} ";
-                            tmp = 1;
-                        }
-                    }
-                }
-                if (tmp){
-                    file += '\n';
-                    ret++;
-                }
-                if (IsLongTable() && (row == endfoot)) {
-                    file += "\\endfoot\n";
-                    ret++;
-                    print_hline = false; // no double line below footer
-                }
-                if (IsLongTable() && (row == endlastfoot)) {
-                    file += "\\endlastfoot\n";
-                    ret++;
-                    print_hline = false; // no double line below footer
-                }
-                if (IsLongTable() && row_info[row].newpage) {
-                    file += "\\newpage\n";
-                    ret++;
-                    print_hline = false; // no line below a \\newpage-command
-                }
-                tmp = 0;
-                if (nvcell < numberofcells && (cell < GetNumberOfCells()-1) &&
-                    !ShouldBeVeryLastCell(cell)) {
-                    fcell = nvcell;
-                    for (i=0; i < NumberOfCellsInRow(fcell); i++){
-                        if (TopLine(fcell+i))
-                            tmp++;
-                    }
-                    if (tmp == NumberOfCellsInRow(fcell)){
-                        if (print_hline)
-                            file += "\\hline ";
-                        hline2 = "\\hline ";
-                    }
-                    else {
-                        tmp = 0;
-                        for (i=0; i < NumberOfCellsInRow(fcell); i++){
-                            if (TopLine(fcell+i)){
-                                if (print_hline) {
-                                   file += "\\cline{";
-                                   file += column_of_cell(fcell+i)+1;
-                                   file += '-';
-                                   file += right_column_of_cell(fcell+i)+1;
-                                   file += "} ";
-                               }
-                                hline2 += "\\cline{";
-                                hline2 += column_of_cell(fcell+i)+1;
-                                hline2 += '-';
-                                hline2 += right_column_of_cell(fcell+i)+1;
-                                hline2 += "} ";
-                                tmp = 1;
-                            }
-                        }
-                    }
-                    if (tmp && print_hline){
-                        file += '\n';
-                        ret++;
-                    }
-                }
-                // the order here is important as if one defines two
-                // or more things in one line only the first entry is
-                // displayed the other are set to an empty-row. This
-                // is important if I have a footer and want that the
-                // lastfooter is NOT displayed!!!
-                bool sflag2 = (row == endhead) || (row == endfirsthead) ||
-                    (row == endfoot) || (row == endlastfoot);
-                row--;
-//                sflag2 = IsLongTable() && (row >= 0) &&
-//                    (sflag2 || (row == endhead) || (row == endfirsthead));
-                row += 2;
-                bool sflag1 = IsLongTable() && (row != endhead) &&
-                    (row != endfirsthead) &&
-                    ((row == endfoot) || (row == endlastfoot));
-                row--;
-                if (IsLongTable() && (row == endhead)) {
-                    file += "\\endhead\n";
-                    ret++;
-                }
-                if (IsLongTable() && (row == endfirsthead)) {
-                    file += "\\endfirsthead\n";
-                    ret++;
-                }
-                if (sflag1) { // add the \hline for next foot row
-                    if (!hline1.empty()) {
-                        file += hline1 + '\n';
-                        ret++;
-                    }
-                }
-                // add the \hline for the first row
-                if (pr_top_hline && sflag2) {
-                    if (!hline2.empty()) {
-                        file += hline2 + '\n';
-                        ret++;
-                    }
-                }
-                if (nvcell < numberofcells && RotateCell(nvcell)) {
-                    file += "\\begin{sideways}\n";
-                    ret++;
-                }
-#endif
             } else {
                addNewlineAndDepth(file,--depth);
                 file += "</ENTRY>";
@@ -1818,54 +1550,8 @@ int LyXTable::DocBookEndOfCell(string& file, int cell, int &depth)
                file += ">";
                addNewlineAndDepth(file,++depth);
                 ret += 3;
-#if 0
-                if (nvcell < numberofcells && RotateCell(nvcell)) {
-                    file += "\\begin{sideways}\n";
-                    ret++;
-                }
-#endif
             }
         }
-#if 0
-        if (nvcell < numberofcells && IsMultiColumn(nvcell)) {
-            file += "\\multicolumn{";
-            file += cells_in_multicolumn(nvcell);
-            file += "}{";
-            if (!cellinfo_of_cell(cell+1)->align_special.empty()) {
-                file += cellinfo_of_cell(cell+1)->align_special;
-                file += "}{";
-            } else {
-                if (LeftLine(nvcell))
-                    file += '|';
-                if (!GetPWidth(nvcell).empty()) {
-                    file += "p{";
-                    file += GetPWidth(nvcell);
-                    file += '}';
-                } else {
-                    switch (GetAlignment(nvcell)) {
-                      case LYX_ALIGN_LEFT: file += 'l'; break;
-                      case LYX_ALIGN_RIGHT: file += 'r'; break;
-                      default:  file += 'c'; break;
-                    }
-                }
-                if (RightLine(nvcell))
-                    file += '|';
-                //if (column_of_cell(cell+2)!=0 && LeftLine(cell+2))
-                if (((nvcell+1) < numberofcells) &&
-                    (NextVirtualCell(nvcell+1) < numberofcells) &&
-                    (column_of_cell(NextVirtualCell(nvcell+1))!=0) &&
-                    LeftLine(NextVirtualCell(nvcell+1)))
-                    file += '|';
-                file += "}{";
-            }
-        }
-        if (nvcell < numberofcells && Linebreaks(nvcell)) {
-//            !column_info[column_of_cell(nvcell)].p_width.empty()) {
-            file += "\\parbox{";
-            file += GetPWidth(nvcell);
-            file += "}{\\smallskip{}";
-        }
-#endif
     }
     return ret;
 }
index 11aa605740c374896276f56c3725ec6c8c1929ca..f71bc20507638102be7b39d82da3eb03b77df953 100644 (file)
@@ -4,13 +4,13 @@
  * 
  *           LyX, The Document Processor
  *      
- *         Copyright (C) 1995 Matthias Ettrich
- *          Copyright (C) 1995-1998 The LyX Team
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-1998 The LyX Team
  *
- *======================================================*/
+ * ====================================================== */
 
-#ifndef _TEXROW_H
-#define _TEXROW_H
+#ifndef TEXROW_H
+#define TEXROW_H
 
 #ifdef __GNUG__
 #pragma interface
index c497f3f259cb869a893c2a1cec05bc82999e571a..5e86c4b8ad7fbd897fd182a235304cc8f4726679 100644 (file)
@@ -34,23 +34,33 @@ static const int LYX_PAPER_MARGIN = 20;
 extern int mono_video;
 extern int reverse_video;
 extern int fast_selection;
-extern BufferView *current_view;
-extern int UnlockInset(UpdatableInset* inset);
+extern BufferView * current_view;
+extern int UnlockInset(UpdatableInset * inset);
 
 // ale070405
-extern int bibitemMaxWidth(const class LyXFont &);
+extern int bibitemMaxWidth(LyXFont const &);
 
 // dnaber 1999-02-02
-extern MiniBuffer *minibuffer;
+extern MiniBuffer * minibuffer;
 
-int LyXText::SingleWidth(LyXParagraph *par, int pos)
+#ifdef NEW_TEXT
+int LyXText::SingleWidth(LyXParagraph * par,
+                        LyXParagraph::size_type pos)
+#else
+int LyXText::SingleWidth(LyXParagraph * par, int pos)
+#endif
 {
        char c = par->GetChar(pos);
        return SingleWidth(par, pos, c);
 }
 
 
-int LyXText::SingleWidth(LyXParagraph *par, int pos, char c)
+#ifdef NEW_TEXT
+int LyXText::SingleWidth(LyXParagraph * par,
+                        LyXParagraph::size_type pos, char c)
+#else
+int LyXText::SingleWidth(LyXParagraph * par, int pos, char c)
+#endif
 {
        LyXFont font = GetFont(par, pos);
 
@@ -116,7 +126,11 @@ int LyXText::SingleWidth(LyXParagraph *par, int pos, char c)
 
 /* returns the paragraph position of the last character in the 
  * specified row */
-int LyXText::RowLast(Row *row)
+#ifdef NEW_TEXT
+LyXParagraph::size_type LyXText::RowLast(Row * row)
+#else
+int LyXText::RowLast(Row * row)
+#endif
 {
        if (row->next == 0)
                return row->par->Last()-1;
@@ -126,8 +140,13 @@ int LyXText::RowLast(Row *row)
                return row->next->pos - 1;
 }
 
-
-void LyXText::Draw(Row *row, int &pos, LyXScreen &scr, int offset, float &x)
+#ifdef NEW_TEXT
+void LyXText::Draw(Row * row, LyXParagraph::size_type & pos,
+                  LyXScreen & scr, int offset, float & x)
+#else
+void LyXText::Draw(Row * row, int & pos,
+                  LyXScreen & scr, int offset, float & x)
+#endif
 {
        char c = row->par->GetChar(pos);
 
@@ -223,9 +242,26 @@ void LyXText::Draw(Row *row, int &pos, LyXScreen &scr, int offset, float &x)
        // This is dirty, but fast. Notice that it will never be too small.
        // For the record, I'll note that Microsoft Word has a limit
        // of 768 here. We have none :-) (Asger)
+#if 0
        static char textstring[1024];
+#else
+       // Ok. I am the first to admit that the use of std::string will be
+       // a tiny bit slower. However, I claim that this slowdown is so
+       // small that it is close to inperceptive. So IMHO we should go
+       // with the easier and clearer implementation. And even if 1024
+       // is a large number here it might overflow, string will only
+       // overflow if the machine is out of memory...
+       static string textstring;
+       textstring = c;
+       ++pos;
+#endif
 
+#ifdef NEW_TEXT
+       LyXParagraph::size_type last = RowLast(row);
+#else
        int last = RowLast(row);
+#endif
+#if 0
        // Prevent crash in the extremely unlikely event
        // that our array is too small
        if (last > pos+1020) last = pos + 1020;
@@ -234,27 +270,46 @@ void LyXText::Draw(Row *row, int &pos, LyXScreen &scr, int offset, float &x)
        pos++;
 
        int i = 1;
-
+#endif
+       
        while (pos <= last &&
-              (unsigned char) (c = row->par->GetChar(pos)) > ' ' &&
+              static_cast<char>(c = row->par->GetChar(pos)) > ' ' &&
               font2 == GetFont(row->par, pos)) {
+#if 0
                textstring[i++] = c;
-               pos++;
+#else
+               textstring += c;
+#endif
+               ++pos;
        }
+#if 0
        textstring[i] = 0; 
-
+#endif
        float tmpx = x;
 
        // If monochrome and LaTeX mode, provide reverse background
        if (mono_video && font.latex() == LyXFont::ON) {
                int a=font.maxAscent(), d=font.maxDescent();
+#if 0
                scr.fillRectangle(gc_copy, int(tmpx), offset + row->baseline-a,
                                  font.textWidth(textstring, i), a+d);
+#else
+               scr.fillRectangle(gc_copy, int(tmpx), offset + row->baseline-a,
+                                 font.textWidth(textstring.c_str(),
+                                                textstring.length()), a+d);
+#endif
        }
-
+#if 0
        /* Draw text and set the new x position */ 
        x += scr.drawText(font, textstring, i, offset + row->baseline, 
                          int(x));
+#else
+       /* Draw text and set the new x position */ 
+       x += scr.drawText(font, textstring.c_str(), textstring.length(),
+                         offset + row->baseline, 
+                         int(x));
+#endif
+       
        /* what about underbars? */
        if (font.underbar() == LyXFont::ON && font.latex() != LyXFont::ON) {
                scr.drawLine(gc_copy, offset + row->baseline + 2,
@@ -271,26 +326,24 @@ void LyXText::Draw(Row *row, int &pos, LyXScreen &scr, int offset, float &x)
 * This information cannot be taken from the layouts-objekt, because in 
 * LaTeX the beginning of the text fits in some cases (for example sections)
 * exactly the label-width. */
-int LyXText::LeftMargin(Row* row)
+int LyXText::LeftMargin(Row * row)
 {
-   int x;
-   LyXLayout *layout;
    LyXFont labelfont;
-   LyXParagraph *newpar;
+   LyXParagraph * newpar;
    Row dummyrow;
-   layout = lyxstyle.Style(parameters->textclass, row->par->GetLayout());
+   LyXLayout const & layout = textclasslist.Style(parameters->textclass, row->par->GetLayout());
    
-   string parindent = layout->parindent; 
+   string parindent = layout.parindent; 
 
    /* table stuff -- begin*/ 
    if (row->par->table)
       parindent.clear();
    /* table stuff -- end*/       
 
-   x = LYX_PAPER_MARGIN;
+   int x = LYX_PAPER_MARGIN;
 
-   x += lyxstyle.TextClass(parameters->textclass)->
-     defaultfont.signedStringWidth(lyxstyle.TextClass(parameters->textclass)->leftmargin);
+   x += textclasslist.TextClass(parameters->textclass).
+     defaultfont().signedStringWidth(textclasslist.TextClass(parameters->textclass).leftmargin());
 
    if (row->par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE)  {
        LyXFont font(LyXFont::ALL_SANE);
@@ -306,7 +359,7 @@ int LyXText::LeftMargin(Row* row)
         /* find the previous same level paragraph */
         if (row->par->FirstPhysicalPar()->Previous()) {
            newpar = row->par->DepthHook(row->par->GetDepth());
-           if (newpar && lyxstyle.Style(parameters->textclass, newpar->GetLayout())->nextnoindent)
+           if (newpar && textclasslist.Style(parameters->textclass, newpar->GetLayout()).nextnoindent)
               parindent.clear();
         }
       }
@@ -320,8 +373,8 @@ int LyXText::LeftMargin(Row* row)
       
       /* check wether it is a sufficent paragraph */ 
       if (newpar && newpar->footnoteflag == row->par->footnoteflag
-         && lyxstyle.Style(parameters->textclass, 
-                           newpar->GetLayout())->isEnvironment()) {
+         && textclasslist.Style(parameters->textclass, 
+                           newpar->GetLayout()).isEnvironment()) {
             dummyrow.par = newpar;
             dummyrow.pos = newpar->Last();
             x = LeftMargin(&dummyrow);
@@ -339,56 +392,56 @@ int LyXText::LeftMargin(Row* row)
         if (newpar->FirstPhysicalPar()->noindent)
            parindent.clear();
         else
-           parindent = lyxstyle.Style(parameters->textclass, 
-                                      newpar->GetLayout())->parindent;
+           parindent = textclasslist.Style(parameters->textclass, 
+                                      newpar->GetLayout()).parindent;
       }
       
    }
    
    labelfont = GetFont(row->par, -2);
-   switch (layout->margintype) {
+   switch (layout.margintype) {
     case MARGIN_DYNAMIC:
-      if (!layout->leftmargin.empty()) {
-       x += lyxstyle.TextClass(parameters->textclass)->defaultfont.signedStringWidth(layout->leftmargin);
+      if (!layout.leftmargin.empty()) {
+       x += textclasslist.TextClass(parameters->textclass).defaultfont().signedStringWidth(layout.leftmargin);
       }
       if (!row->par->GetLabestring().empty()) {
-           x += labelfont.signedStringWidth(layout->labelindent);
+           x += labelfont.signedStringWidth(layout.labelindent);
            x += labelfont.stringWidth(row->par->GetLabestring());
-           x += labelfont.stringWidth(layout->labelsep);
+           x += labelfont.stringWidth(layout.labelsep);
       }
       break;
     case MARGIN_MANUAL:
-      x += labelfont.signedStringWidth(layout->labelindent);
+      x += labelfont.signedStringWidth(layout.labelindent);
       if (row->pos >= BeginningOfMainBody(row->par)) {
         if (!row->par->GetLabelWidthString().empty()) {
            x += labelfont.stringWidth(row->par->GetLabelWidthString());
-           x += labelfont.stringWidth(layout->labelsep);
+           x += labelfont.stringWidth(layout.labelsep);
         }
       }
       break;
     case MARGIN_STATIC:
-      x += ( lyxstyle.TextClass(parameters->textclass)->defaultfont.signedStringWidth(layout->leftmargin) * 4
+      x += ( textclasslist.TextClass(parameters->textclass).defaultfont().signedStringWidth(layout.leftmargin) * 4
             / (row->par->GetDepth() + 4));
       break;
     case MARGIN_FIRST_DYNAMIC:
-      if (layout->labeltype == LABEL_MANUAL) {
+      if (layout.labeltype == LABEL_MANUAL) {
         if (row->pos >= BeginningOfMainBody(row->par)) {
-           x += labelfont.signedStringWidth(layout->leftmargin);
+           x += labelfont.signedStringWidth(layout.leftmargin);
         } else {
-           x += labelfont.signedStringWidth(layout->labelindent);
+           x += labelfont.signedStringWidth(layout.labelindent);
         }
       } else {
         if (row->pos
             // Special case to fix problems with theorems (JMarc)
-            || (layout->labeltype == LABEL_STATIC
-                && layout->latextype == LATEX_ENVIRONMENT
+            || (layout.labeltype == LABEL_STATIC
+                && layout.latextype == LATEX_ENVIRONMENT
                 && ! row->par->IsFirstInSequence())) {
-                x += labelfont.signedStringWidth(layout->leftmargin);
-        } else if (layout->labeltype != LABEL_TOP_ENVIRONMENT
-                 && layout->labeltype != LABEL_BIBLIO
-                 && layout->labeltype != LABEL_CENTERED_TOP_ENVIRONMENT) {
-                x += labelfont.signedStringWidth(layout->labelindent);
-                x += labelfont.stringWidth(layout->labelsep);
+                x += labelfont.signedStringWidth(layout.leftmargin);
+        } else if (layout.labeltype != LABEL_TOP_ENVIRONMENT
+                 && layout.labeltype != LABEL_BIBLIO
+                 && layout.labeltype != LABEL_CENTERED_TOP_ENVIRONMENT) {
+                x += labelfont.signedStringWidth(layout.labelindent);
+                x += labelfont.stringWidth(layout.labelsep);
                 x += labelfont.stringWidth(row->par->GetLabestring());
         } 
       }
@@ -401,7 +454,7 @@ int LyXText::LeftMargin(Row* row)
        * allowed in the LaTeX realisation of this layout. */ 
       
       /* find the first row of this paragraph */ 
-      Row *tmprow = row;
+      Row * tmprow = row;
       while (tmprow->previous && tmprow->previous->par == row->par)
        tmprow = tmprow->previous;
       
@@ -412,7 +465,7 @@ int LyXText::LeftMargin(Row* row)
           minfill = tmprow->fill;
       }
       
-      x += lyxstyle.TextClass(parameters->textclass)->defaultfont.signedStringWidth(layout->leftmargin);
+      x += textclasslist.TextClass(parameters->textclass).defaultfont().signedStringWidth(layout.leftmargin);
       x += minfill;
     }
       break;
@@ -434,27 +487,27 @@ int LyXText::LeftMargin(Row* row)
    
    int align;
    if (row->par->FirstPhysicalPar()->align == LYX_ALIGN_LAYOUT)
-     align = layout->align;
+     align = layout.align;
    else
      align = row->par->FirstPhysicalPar()->align;
    
    /* set the correct parindent */
    if (row->pos == 0) {
-       if ((layout->labeltype == LABEL_NO_LABEL 
-           || layout->labeltype == LABEL_TOP_ENVIRONMENT 
-           || layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
-           || (layout->labeltype == LABEL_STATIC
-               && layout->latextype == LATEX_ENVIRONMENT
+       if ((layout.labeltype == LABEL_NO_LABEL 
+           || layout.labeltype == LABEL_TOP_ENVIRONMENT 
+           || layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
+           || (layout.labeltype == LABEL_STATIC
+               && layout.latextype == LATEX_ENVIRONMENT
                && ! row->par->IsFirstInSequence()))
           && row->par == row->par->FirstPhysicalPar()
           && align == LYX_ALIGN_BLOCK
           && !row->par->noindent
           && (row->par->layout ||
               parameters->paragraph_separation == LYX_PARSEP_INDENT))
-        x += lyxstyle.TextClass(parameters->textclass)->defaultfont.stringWidth(parindent);
+        x += textclasslist.TextClass(parameters->textclass).defaultfont().stringWidth(parindent);
        else 
-        if (layout->labeltype==LABEL_BIBLIO) { // ale970405 Right width for bibitems
-            x += bibitemMaxWidth(lyxstyle.TextClass(parameters->textclass)->defaultfont);
+        if (layout.labeltype==LABEL_BIBLIO) { // ale970405 Right width for bibitems
+            x += bibitemMaxWidth(textclasslist.TextClass(parameters->textclass).defaultfont());
         }
    }
 
@@ -464,17 +517,14 @@ int LyXText::LeftMargin(Row* row)
    
 int LyXText::RightMargin(Row *row)
 {
-   int  x;
-   LyXLayout* layout;
-   
-   LyXParagraph *newpar;
+   LyXParagraph * newpar;
    Row dummyrow;
-   layout = lyxstyle.Style(parameters->textclass, row->par->GetLayout());
+   LyXLayout const & layout = textclasslist.Style(parameters->textclass, row->par->GetLayout());
 
-   x = LYX_PAPER_MARGIN;
+   int x = LYX_PAPER_MARGIN;
 
-   x += lyxstyle.TextClass(parameters->textclass)->
-     defaultfont.signedStringWidth(lyxstyle.TextClass(parameters->textclass)->rightmargin);
+   x += textclasslist.TextClass(parameters->textclass).
+     defaultfont().signedStringWidth(textclasslist.TextClass(parameters->textclass).rightmargin());
    if (row->par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE)  {
      x += LYX_PAPER_MARGIN/2;
    }
@@ -498,8 +548,8 @@ int LyXText::RightMargin(Row *row)
 
       /* check wether it is a sufficent paragraph */ 
       if (newpar && newpar->footnoteflag == row->par->footnoteflag
-         && lyxstyle.Style(parameters->textclass,
-                           newpar->GetLayout())->isEnvironment()) {
+         && textclasslist.Style(parameters->textclass,
+                           newpar->GetLayout()).isEnvironment()) {
             dummyrow.par = newpar;
             dummyrow.pos = 0;
             x = RightMargin(&dummyrow);
@@ -515,16 +565,16 @@ int LyXText::RightMargin(Row *row)
    }
 
    //lyxerr << "rightmargin: " << layout->rightmargin << endl;
-   x += (lyxstyle.TextClass(parameters->textclass)->defaultfont.signedStringWidth(layout->rightmargin) * 4
+   x += (textclasslist.TextClass(parameters->textclass).defaultfont().signedStringWidth(layout.rightmargin) * 4
         / (row->par->GetDepth() + 4));
    return x;
    
 }
 
 
-int LyXText::LabelEnd (Row *row)
+int LyXText::LabelEnd (Row * row)
 {
-   if (lyxstyle.Style(parameters->textclass, row->par->GetLayout())->margintype == MARGIN_MANUAL) {
+   if (textclasslist.Style(parameters->textclass, row->par->GetLayout()).margintype == MARGIN_MANUAL) {
       Row tmprow;
       tmprow = *row;
       tmprow.pos = row->par->Last();
@@ -538,11 +588,20 @@ int LyXText::LabelEnd (Row *row)
 }
 
 
-/* table stuff -- begin*/ 
-int LyXText::NumberOfCell(LyXParagraph *par, int pos)
+/* table stuff -- begin*/
+#ifdef NEW_TEXT
+int LyXText::NumberOfCell(LyXParagraph * par,
+                         LyXParagraph::size_type pos)
+#else
+int LyXText::NumberOfCell(LyXParagraph * par, int pos)
+#endif
 {
    int cell = 0;
+#ifdef NEW_TEXT
+   LyXParagraph::size_type tmp_pos = 0;
+#else
    int tmp_pos = 0;
+#endif
    while (tmp_pos < pos) {
       if (par->IsNewline(tmp_pos))
         cell++;
@@ -551,8 +610,11 @@ int LyXText::NumberOfCell(LyXParagraph *par, int pos)
    return cell;
 }
 
-
-int LyXText::WidthOfCell(LyXParagraph *par, int &pos)
+#ifdef NEW_TEXT
+int LyXText::WidthOfCell(LyXParagraph * par, LyXParagraph::size_type & pos)
+#else
+int LyXText::WidthOfCell(LyXParagraph * par, int & pos)
+#endif
 {
    int w = 0;
    while (pos < par->Last() && !par->IsNewline(pos)) {
@@ -565,7 +627,7 @@ int LyXText::WidthOfCell(LyXParagraph *par, int &pos)
 }
 
 
-char LyXText::HitInTable(Row* row, int x)
+char LyXText::HitInTable(Row * row, int x)
 {
   float tmpx;
   float fill_separator, fill_hfill, fill_label_hfill;
@@ -578,7 +640,7 @@ char LyXText::HitInTable(Row* row, int x)
 
 bool LyXText::MouseHitInTable(int x, long y)
 {
-       Row *row = GetRowNearY(y);
+       Row * row = GetRowNearY(y);
         return HitInTable(row, x);
 }
 
@@ -587,20 +649,40 @@ bool LyXText::MouseHitInTable(int x, long y)
 
 
 /* get the next breakpoint in a given paragraph */
-int LyXText::NextBreakPoint(Row* row, int width)
+#ifdef NEW_TEXT
+LyXParagraph::size_type
+LyXText::NextBreakPoint(Row * row, int width)
+#else
+int LyXText::NextBreakPoint(Row * row, int width)
+#endif
 {
        int x = 0;
+#ifdef NEW_TEXT
+       LyXParagraph::size_type last_separator = -1;
+       /* position of the last possible breakpoint 
+        * -1 isn't a suitable value, but a flag */
+#else
        int last_separator = -1; /* position of the last possible breakpoint 
                                  * -1 isn't a suitable value, but a flag */
-       int i = 0;
+#endif
        int left_margin;
        
-       LyXParagraph *par = row->par;
+       LyXParagraph * par = row->par;
+#ifdef NEW_TEXT
+       LyXParagraph::size_type i = 0;
+       LyXParagraph::size_type pos = row->pos;
+#else
+       int i = 0;
        int pos = row->pos;
+#endif
        
        /* table stuff -- begin*/ 
        if (par->table) {
-               while (pos<par->last 
+#ifdef NEW_TEXT
+               while (pos < par->size()
+#else
+               while (pos<par->last
+#endif
                       && (!par->IsNewline(pos) 
                           || !par->table->IsFirstCell(NumberOfCell(par, pos+1)))) {
                        if (par->GetChar(pos) == LYX_META_INSET &&
@@ -615,12 +697,17 @@ int LyXText::NextBreakPoint(Row* row, int width)
        
        left_margin = LabelEnd(row);
        width -= RightMargin(row);
+#ifdef NEW_TEXT
+       LyXParagraph::size_type main_body =
+               BeginningOfMainBody(par);
+#else
        int main_body = BeginningOfMainBody(par);
-       LyXLayout* layout = lyxstyle.Style(parameters->textclass, par->GetLayout());
+#endif
+       LyXLayout const & layout = textclasslist.Style(parameters->textclass, par->GetLayout());
        i = pos;
        char c;
        
-       if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
+       if (layout.margintype == MARGIN_RIGHT_ADDRESS_BOX) {
                /* special code for right address boxes, only newlines count */
                while (i < par->Last()) {
                        if (par->IsNewline(i)) {
@@ -635,7 +722,12 @@ int LyXText::NextBreakPoint(Row* row, int width)
                }
        } else {
                // Last position is an invariant
+#ifdef NEW_TEXT
+               LyXParagraph::size_type const last =
+                       par->Last();
+#else
                int const last = par->Last();
+#endif
                /* this is the usual handling */ 
                x = LeftMargin(row);
                while (x < width && i < last) {
@@ -647,8 +739,8 @@ int LyXText::NextBreakPoint(Row* row, int width)
                                   par->GetInset(i) && par->GetInset(i)->Display()){
                                /* check wether a Display() inset is valid here .
                                   if not, change it to non-display*/ 
-                               if (layout->isCommand()
-                                   || (layout->labeltype == LABEL_MANUAL
+                               if (layout.isCommand()
+                                   || (layout.labeltype == LABEL_MANUAL
                                        && i < BeginningOfMainBody(par))){
                                        /* display istn't allowd */ 
                                        par->GetInset(i)->SetDisplay(false);
@@ -673,7 +765,7 @@ int LyXText::NextBreakPoint(Row* row, int width)
                        }
                        i++;
                        if (i == main_body) {
-                               x += GetFont(par, -2).stringWidth(layout->labelsep);
+                               x += GetFont(par, -2).stringWidth(layout.labelsep);
                                if (par->IsLineSeparator(i - 1))
                                        x-= SingleWidth(par, i - 1);
                                if (x < left_margin)
@@ -700,17 +792,24 @@ int LyXText::NextBreakPoint(Row* row, int width)
 
 
 /* returns the minimum space a row needs on the screen in pixel */
-int LyXText::Fill(Row *row, int paperwidth)
+int LyXText::Fill(Row * row, int paperwidth)
 {
-   int w,i, last, fill, left_margin;
+   int w, fill;
    /* get the pure distance */
-   last = RowLast(row);
-   
+#ifdef NEW_TEXT
+   LyXParagraph::size_type last = RowLast(row);
+#else
+   int last = RowLast(row);
+#endif
    /* table stuff -- begin*/
    if (row->par->table) {
       /* for tables FILL does calculate the widthes of each cell in 
-       * the row */ 
+       * the row */
+#ifdef NEW_TEXT
+      LyXParagraph::size_type pos = row->pos;
+#else
       int pos = row->pos;
+#endif
       int cell = NumberOfCell(row->par, pos);
       w = 0;
       do {
@@ -727,7 +826,7 @@ int LyXText::Fill(Row *row, int paperwidth)
    }
    /* table stuff -- end*/ 
 
-   left_margin = LabelEnd(row);
+   int left_margin = LabelEnd(row);
 
      /* if the row ends with newline, this newline will not be relevant */ 
      if (last >= 0 && row->par->IsNewline(last))
@@ -738,30 +837,35 @@ int LyXText::Fill(Row *row, int paperwidth)
        last--;
 
    /* special handling of the right address boxes */ 
-   if (lyxstyle.Style(parameters->textclass, row->par->GetLayout())->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
+   if (textclasslist.Style(parameters->textclass,
+                          row->par->GetLayout()).margintype
+       == MARGIN_RIGHT_ADDRESS_BOX) {
       int tmpfill = row->fill;
       row->fill = 0;                  /* the minfill in MarginLeft()  */
       w = LeftMargin(row);
       row->fill = tmpfill;
-      
-      /* the old way, impossible when using environments: */ 
-      /*  w = LyXStringWidth(lyxstyle.Style(parameters->textclass, row->par->GetLayout())->font, */ 
-      /*                        lyxstyle.Style(parameters->textclass, row->par->GetLayout())->leftmargin); */
    }
    else
      w = LeftMargin(row);
    
-   int main_body = BeginningOfMainBody(row->par);
-   LyXLayout *layout = lyxstyle.Style(parameters->textclass,
+   LyXLayout const & layout = textclasslist.Style(parameters->textclass,
                                      row->par->GetLayout());
-   i = row->pos;
-   while (i<= last) {
+#ifdef NEW_TEXT
+   LyXParagraph::size_type main_body =
+          BeginningOfMainBody(row->par);
+   LyXParagraph::size_type i = row->pos;
+   while (i < last) {
+#else
+   int main_body = BeginningOfMainBody(row->par);
+   int i = row->pos;
+   while (i <= last) {
+#endif
       w += SingleWidth(row->par, i);
-      i++;
+      ++i;
       if (i == main_body) {
-        w += GetFont(row->par, -2).stringWidth(layout->labelsep);
+        w += GetFont(row->par, -2).stringWidth(layout.labelsep);
         if (row->par->IsLineSeparator(i - 1))
-          w-= SingleWidth(row->par, i - 1);
+          w -= SingleWidth(row->par, i - 1);
         if (w < left_margin)
           w = left_margin;
       }
@@ -773,12 +877,14 @@ int LyXText::Fill(Row *row, int paperwidth)
 
 
 /* returns the minimum space a manual label needs on the screen in pixel */ 
-int LyXText::LabelFill(Row *row)
+int LyXText::LabelFill(Row * row)
 {
-   int w,i, last;
-   int fill=0;
-   
-   last = BeginningOfMainBody(row->par) - 1;
+
+#ifdef NEW_TEXT
+   LyXParagraph::size_type last = BeginningOfMainBody(row->par) - 1;
+#else
+   int last = BeginningOfMainBody(row->par) - 1;
+#endif
    /* -1 because a label ends either with a space that is in the label, 
     * or with the beginning of a footnote that is outside the label. */ 
 
@@ -786,19 +892,20 @@ int LyXText::LabelFill(Row *row)
    // 0 and this causes a crash. This fix seems to work correctly, but I
    // bet the real error is elsewhere.  The bug is triggered when you have an 
    // open footnote in a paragraph environment with a manual label. (Asger)
-   if (last<0) last = 0;
+   if (last < 0) last = 0;
 
    if (row->par->IsLineSeparator(last))    /* a sepearator at this end 
                                        * does not count */
      last--;
    
-   w = 0;
-   i = row->pos;
+   int w = 0;
+   int i = row->pos;
    while (i<= last) {
       w += SingleWidth(row->par, i);
       i++;
    }
    
+   int fill = 0;
    if (!row->par->labelwidthstring.empty()) {
       fill = GetFont(row->par, -2).stringWidth(row->par->labelwidthstring) - w;
    }
@@ -814,11 +921,9 @@ int LyXText::LabelFill(Row *row)
 * on the very last column doesnt count */ 
 int LyXText::NumberOfSeparators(Row *row)
 {
-   int n,p,last;
-   
-   last = RowLast(row);
-   n = 0;
-   p = row->pos;
+   int last = RowLast(row);
+   int n = 0;
+   int p = row->pos;
    int main_body = BeginningOfMainBody(row->par);
    if (p < main_body)
      p = main_body;
@@ -834,23 +939,21 @@ int LyXText::NumberOfSeparators(Row *row)
 /* returns the number of hfills in the specified row. The LyX-Hfill is
 * a LaTeX \hfill so that the hfills at the beginning and at the end were 
 * ignored. This is *MUCH* more usefull than not to ignore!  */
-int LyXText::NumberOfHfills(Row *row)
+int LyXText::NumberOfHfills(Row * row)
 {
-   int n,p,last, first;
-   
-   last = RowLast(row);
-   first = row->pos;
+   int last = RowLast(row);
+   int first = row->pos;
    if (first) {                               /* hfill *DO* count at the beginning 
                                        * of paragraphs! */
      while(first <= last && row->par->IsHfill(first))
        first++;
    }
 
-   n = 0;
    int main_body = BeginningOfMainBody(row->par);
    if (first < main_body)
      first = main_body;
-   for (p = first; p <= last; p++) {    /* last, because the end is ignored!  */
+   int n = 0;
+   for (int p = first; p <= last; p++) { // last, because the end is ignored!
       if (row->par->IsHfill(p)) {
         n++;
       }
@@ -860,27 +963,38 @@ int LyXText::NumberOfHfills(Row *row)
 
 
 /* like NumberOfHfills, but only those in the manual label! */ 
-int LyXText::NumberOfLabelHfills(Row *row)
+int LyXText::NumberOfLabelHfills(Row * row)
 {
-   int n,p,last, first;
-   
-   last = RowLast(row);
-   first = row->pos;
+#ifdef NEW_TEXT
+   LyXParagraph::size_type last = RowLast(row);
+   LyXParagraph::size_type first = row->pos;
+#else
+   int last = RowLast(row);
+   int first = row->pos;
+#endif
    if (first) {                               /* hfill *DO* count at the beginning 
                                        * of paragraphs! */
       while(first < last && row->par->IsHfill(first))
        first++;
    }
-
-   n = 0;
+#ifdef NEW_TEXT
+   LyXParagraph::size_type main_body =
+          BeginningOfMainBody(row->par);
+#else
    int main_body = BeginningOfMainBody(row->par);
-   
+#endif
    if (last > main_body)
      last = main_body;
-   
-   for (p = first; p < last; p++) {    /* last, because the end is ignored!  */
+
+   int n = 0;
+#ifdef NEW_TEXT
+   for (LyXParagraph::size_type p = first;
+       p < last; ++p) {  // last, because the end is ignored!
+#else
+   for (int p = first; p < last; p++) {  // last, because the end is ignored!
+#endif
       if (row->par->IsHfill(p)) {
-        n++;
+        ++n;
       }
    }
    return n;
@@ -888,8 +1002,13 @@ int LyXText::NumberOfLabelHfills(Row *row)
 
 
 /* returns true, if a expansion is needed.
- * Rules are given by LaTeX */ 
-bool LyXText::HfillExpansion(Row *row_ptr, int pos)
+ * Rules are given by LaTeX */
+#ifdef NEW_TEXT
+bool LyXText::HfillExpansion(Row * row_ptr,
+                            LyXParagraph::size_type pos)
+#else
+bool LyXText::HfillExpansion(Row * row_ptr, int pos)
+#endif
 {
    /* by the way, is it a hfill? */ 
    if (!row_ptr->par->IsHfill(pos))
@@ -905,15 +1024,18 @@ bool LyXText::HfillExpansion(Row *row_ptr, int pos)
      return true;
    
    /* in some labels  it does not count */ 
-   if ( lyxstyle.Style(parameters->textclass, row_ptr->par->GetLayout())->margintype != MARGIN_MANUAL &&
+   if ( textclasslist.Style(parameters->textclass, row_ptr->par->GetLayout()).margintype != MARGIN_MANUAL &&
        pos < BeginningOfMainBody(row_ptr->par))
      return false; 
    
    /* if there is anything between the first char of the row and
     * the sepcified position that is not a newline and not a hfill,
     * the hfill will count, otherwise not */ 
-   
+#ifdef NEW_TEXT
+   LyXParagraph::size_type i = row_ptr->pos;
+#else
    int i = row_ptr->pos;
+#endif
    while (i < pos && (row_ptr->par->IsNewline(i)
                      || row_ptr->par->IsHfill(i)))
      i++;
@@ -922,16 +1044,15 @@ bool LyXText::HfillExpansion(Row *row_ptr, int pos)
 }
 
 
-void LyXText::SetHeightOfRow(Row *row_ptr)
+void LyXText::SetHeightOfRow(Row * row_ptr)
 {
     /* get the maximum ascent and the maximum descent */
    int asc, maxasc, desc, maxdesc, pos_end, pos, labeladdon;
    float layoutasc = 0;
    float layoutdesc = 0;
    float tmptop = 0;
-   LyXParagraph *par, *firstpar;
    LyXFont tmpfont;
-   Inset *tmpinset;
+   Inset * tmpinset;
 
    /* this must not happen before the currentrow for clear reasons.
       so the trick is just to set the current row onto this row */
@@ -946,10 +1067,10 @@ void LyXText::SetHeightOfRow(Row *row_ptr)
    /* Correction: only the fontsize count. The other properties
       are taken from the layoutfont. Nicer on the screen :) */
    
-   par = row_ptr->par->LastPhysicalPar();
-   firstpar = row_ptr->par->FirstPhysicalPar();
+   LyXParagraph * par = row_ptr->par->LastPhysicalPar();
+   LyXParagraph * firstpar = row_ptr->par->FirstPhysicalPar();
    
-   LyXLayout *layout = lyxstyle.Style(parameters->textclass, firstpar->GetLayout());
+   LyXLayout const & layout = textclasslist.Style(parameters->textclass, firstpar->GetLayout());
    
    LyXFont font = GetFont(par, par->Last()-1);
    LyXFont::FONT_SIZE size = font.size();
@@ -959,10 +1080,10 @@ void LyXText::SetHeightOfRow(Row *row_ptr)
    LyXFont labelfont = GetFont(par, -2);
 
    maxasc = int(font.maxAscent() *
-                  layout->spacing.getValue() *
+                  layout.spacing.getValue() *
                   parameters->spacing.getValue());
    maxdesc = int(font.maxDescent() *
-                   layout->spacing.getValue() *
+                   layout.spacing.getValue() *
                    parameters->spacing.getValue());
 
    pos_end = RowLast(row_ptr);
@@ -1020,13 +1141,13 @@ void LyXText::SetHeightOfRow(Row *row_ptr)
       
       /* some parksips VERY EASY IMPLEMENTATION */ 
       if (parameters->paragraph_separation == LYX_PARSEP_SKIP) {
-        if (layout->isParagraph()
+        if (layout.isParagraph()
             && firstpar->GetDepth() == 0
             && firstpar->Previous())
            maxasc += parameters->getDefSkip().inPixels();
         else if (firstpar->Previous()
-                 && lyxstyle.Style(parameters->textclass,
-                          firstpar->Previous()->GetLayout())->isParagraph()
+                 && textclasslist.Style(parameters->textclass,
+                          firstpar->Previous()->GetLayout()).isParagraph()
                  && firstpar->Previous()->GetDepth() == 0)
           // is it right to use defskip here too? (AS)
           maxasc += parameters->getDefSkip().inPixels();
@@ -1051,31 +1172,31 @@ void LyXText::SetHeightOfRow(Row *row_ptr)
       
       /*  this is special code for the chapter, since the label of this
        * layout is printed in an extra row */ 
-      if (layout->labeltype == LABEL_COUNTER_CHAPTER
+      if (layout.labeltype == LABEL_COUNTER_CHAPTER
          && parameters->secnumdepth>=0) {
              labeladdon = int(labelfont.maxDescent() *
-                                 layout->spacing.getValue() *
+                                 layout.spacing.getValue() *
                                  parameters->spacing.getValue())
                      + int(labelfont.maxAscent() *
-                              layout->spacing.getValue() *
+                              layout.spacing.getValue() *
                               parameters->spacing.getValue());
       }
       
       /* special code for the top label */ 
-      if ((layout->labeltype == LABEL_TOP_ENVIRONMENT
-          || layout->labeltype == LABEL_BIBLIO
-          || layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
+      if ((layout.labeltype == LABEL_TOP_ENVIRONMENT
+          || layout.labeltype == LABEL_BIBLIO
+          || layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
          && row_ptr->par->IsFirstInSequence()
          && !row_ptr->par->GetLabestring().empty()) {
         labeladdon = int(
                 (labelfont.maxAscent() *
-                 layout->spacing.getValue() *
+                 layout.spacing.getValue() *
                  parameters->spacing.getValue())
                 +(labelfont.maxDescent() *
-                  layout->spacing.getValue() *
+                  layout.spacing.getValue() *
                   parameters->spacing.getValue())
-                + layout->topsep * DefaultHeight()
-                + layout->labelbottomsep *  DefaultHeight());
+                + layout.topsep * DefaultHeight()
+                + layout.labelbottomsep *  DefaultHeight());
       }
    
       /* and now the layout spaces, for example before and after a section, 
@@ -1089,19 +1210,19 @@ void LyXText::SetHeightOfRow(Row *row_ptr)
             && prev->GetDepth() == firstpar->GetDepth()
             && prev->GetLabelWidthString() == firstpar->GetLabelWidthString())
           {
-             layoutasc = (layout->itemsep * DefaultHeight());
+             layoutasc = (layout.itemsep * DefaultHeight());
           }
         else if (row_ptr->previous) {
-           tmptop = layout->topsep;
+           tmptop = layout.topsep;
            
            if (row_ptr->previous->par->GetDepth() >= row_ptr->par->GetDepth())
-              tmptop-=lyxstyle.Style(parameters->textclass, row_ptr->previous->par->GetLayout())->bottomsep;
+              tmptop-=textclasslist.Style(parameters->textclass, row_ptr->previous->par->GetLayout()).bottomsep;
            
            if (tmptop > 0)
               layoutasc = (tmptop * DefaultHeight());
         }
         else if (row_ptr->par->line_top){
-           tmptop = layout->topsep;
+           tmptop = layout.topsep;
            
            if (tmptop > 0)
               layoutasc = (tmptop * DefaultHeight());
@@ -1109,8 +1230,8 @@ void LyXText::SetHeightOfRow(Row *row_ptr)
         
         prev = row_ptr->par->DepthHook(row_ptr->par->GetDepth()-1);
         if (prev)  {
-           maxasc += int(lyxstyle.Style(parameters->textclass,
-                                        prev->GetLayout())->parsep * DefaultHeight());
+           maxasc += int(textclasslist.Style(parameters->textclass,
+                                        prev->GetLayout()).parsep * DefaultHeight());
         }
         else {
                if (firstpar->Previous()
@@ -1119,7 +1240,7 @@ void LyXText::SetHeightOfRow(Row *row_ptr)
                   /* avoid parsep */ 
                }
            else if (firstpar->Previous()){
-              maxasc += int(layout->parsep * DefaultHeight());
+              maxasc += int(layout.parsep * DefaultHeight());
            }
         }
       }
@@ -1155,12 +1276,12 @@ void LyXText::SetHeightOfRow(Row *row_ptr)
             float  unusual = 0;
             
             if (comparepar->GetDepth() > nextpar->GetDepth()) {
-               usual = (lyxstyle.Style(parameters->textclass, comparepar->GetLayout())->bottomsep * DefaultHeight());
+               usual = (textclasslist.Style(parameters->textclass, comparepar->GetLayout()).bottomsep * DefaultHeight());
                comparepar = comparepar->DepthHook(nextpar->GetDepth());
                if (comparepar->GetLayout()!=nextpar->GetLayout()
                    || nextpar->GetLabelWidthString() != 
                        comparepar->GetLabelWidthString())
-                 unusual = (lyxstyle.Style(parameters->textclass, comparepar->GetLayout())->bottomsep * DefaultHeight());
+                 unusual = (textclasslist.Style(parameters->textclass, comparepar->GetLayout()).bottomsep * DefaultHeight());
                
                if (unusual > usual)
                  layoutdesc = unusual;
@@ -1172,7 +1293,7 @@ void LyXText::SetHeightOfRow(Row *row_ptr)
                if (comparepar->GetLayout()!= nextpar->GetLayout()
                    || nextpar->GetLabelWidthString() !=
                        comparepar->GetLabelWidthString())
-                 layoutdesc = int(lyxstyle.Style(parameters->textclass, comparepar->GetLayout())->bottomsep * DefaultHeight());
+                 layoutdesc = int(textclasslist.Style(parameters->textclass, comparepar->GetLayout()).bottomsep * DefaultHeight());
             }
          }
        }
@@ -1200,24 +1321,19 @@ void LyXText::SetHeightOfRow(Row *row_ptr)
 
 /* Appends the implicit specified paragraph behind the specified row,
  * start at the implicit given position */
-void LyXText::AppendParagraph(Row *row)
+void LyXText::AppendParagraph(Row * row)
 {
-   int z;
-   Row *tmprow;
    bool not_ready = true;
    
-   // Get the width of the row
-   z = row->pos;
-
    // The last character position of a paragraph is an invariant so we can 
    // safely get it here. (Asger)
    int lastposition = row->par->Last();
 
    do {
       // Get the next breakpoint
-      z = NextBreakPoint(row, paperwidth);
+      int z = NextBreakPoint(row, paperwidth);
       
-      tmprow = row;
+      Row * tmprow = row;
 
       // Insert the new row
       if (z < lastposition) {
@@ -1237,20 +1353,19 @@ void LyXText::AppendParagraph(Row *row)
 }
 
 
-void LyXText::BreakAgain(Row *row)
+void LyXText::BreakAgain(Row * row)
 {
-   int z;
-   char not_ready;
-   z = row->pos;
-   Row *tmprow, *tmprow2;
-   
-   not_ready = 1;
+   bool not_ready = true;
    
    do  {
       /* get the next breakpoint */
-      z = NextBreakPoint(row, paperwidth);
-      
-      tmprow = row;
+#ifdef NEW_TEXT
+       LyXParagraph::size_type z =
+               NextBreakPoint(row, paperwidth);
+#else
+      int z = NextBreakPoint(row, paperwidth);
+#endif
+      Row * tmprow = row;
       
       if (z < row->par->Last() ) {
         if (!row->next || (row->next && row->next->par != row->par)) {
@@ -1259,21 +1374,19 @@ void LyXText::BreakAgain(Row *row)
            InsertRow(row, row->par, z);
            row = row->next;
            row->height = 0;
-        }
-        else  {
-           row=row->next;
+        } else  {
+           row = row->next;
            z++;
            if (row->pos == z)
-             not_ready = 0;           /* the rest will not change  */
+                   not_ready = false;     // the rest will not change
            else {
               row->pos = z;
            }
         }
-      }
-      else {
+      } else {
         /* if there are some rows too much, delete them */
         /* only if you broke the whole paragraph! */ 
-        tmprow2 = row;
+        Row * tmprow2 = row;
         while (tmprow2->next && tmprow2->next->par == row->par) {
            tmprow2 = tmprow2->next;
         }
@@ -1281,7 +1394,7 @@ void LyXText::BreakAgain(Row *row)
            tmprow2 = tmprow2->previous;
            RemoveRow(tmprow2->next);
         }
-        not_ready = 0;
+        not_ready = false;
       }
        
       /* set the dimensions of the row */ 
@@ -1292,19 +1405,15 @@ void LyXText::BreakAgain(Row *row)
 
 
 /* this is just a little changed version of break again */ 
-void LyXText::BreakAgainOneRow(Row *row)
+void LyXText::BreakAgainOneRow(Row * row)
 {
-   int z;
-   char not_ready;
-   z = row->pos;
-   Row *tmprow, *tmprow2;
-   
-   not_ready = 1;
-   
    /* get the next breakpoint */
-   z = NextBreakPoint(row, paperwidth);
-   
-   tmprow = row;
+#ifdef NEW_TEXT
+   LyXParagraph::size_type z = NextBreakPoint(row, paperwidth);
+#else
+   int z = NextBreakPoint(row, paperwidth);
+#endif
+   Row * tmprow = row;
    
    if (z < row->par->Last() ) {
       if (!row->next || (row->next && row->next->par != row->par)) {
@@ -1317,17 +1426,14 @@ void LyXText::BreakAgainOneRow(Row *row)
       else  {
         row=row->next;
         z++;
-        if (row->pos == z)
-          not_ready = 0;              /* the rest will not change  */
-        else {
+        if (row->pos != z)
            row->pos = z;
-        }
       }
    }
    else {
       /* if there are some rows too much, delete them */
       /* only if you broke the whole paragraph! */ 
-      tmprow2 = row;
+      Row * tmprow2 = row;
       while (tmprow2->next && tmprow2->next->par == row->par) {
         tmprow2 = tmprow2->next;
       }
@@ -1335,7 +1441,6 @@ void LyXText::BreakAgainOneRow(Row *row)
         tmprow2 = tmprow2->previous;
         RemoveRow(tmprow2->next);
       }
-      not_ready = 0;
    }
    
    /* set the dimensions of the row */ 
@@ -1346,13 +1451,17 @@ void LyXText::BreakAgainOneRow(Row *row)
 
 void LyXText::BreakParagraph(char keep_layout)
 {
-   LyXLayout *layout = lyxstyle.Style(parameters->textclass,
+   LyXLayout const & layout = textclasslist.Style(parameters->textclass,
                                      cursor.par->GetLayout());
    
    /* table stuff -- begin*/
    if (cursor.par->table) {
        // breaking of tables is only allowed at the beginning or the end */
+#ifdef NEW_TEXT
+       if (cursor.pos && cursor.pos < cursor.par->size() &&
+#else
        if (cursor.pos && cursor.pos < cursor.par->last &&
+#endif
            !cursor.par->table->ShouldBeVeryLastCell(NumberOfCell(cursor.par, cursor.pos)))
            return; /* no breaking of tables allowed */ 
    }
@@ -1361,7 +1470,7 @@ void LyXText::BreakParagraph(char keep_layout)
    /* this is only allowed, if the current paragraph is not empty or caption*/ 
    if ((cursor.par->Last() <= 0 && !cursor.par->IsDummy())
        && 
-       layout->labeltype!=LABEL_SENSITIVE)
+       layout.labeltype!=LABEL_SENSITIVE)
      return;
 
    SetUndo(Undo::INSERT, 
@@ -1372,7 +1481,11 @@ void LyXText::BreakParagraph(char keep_layout)
    if (cursor.par->table) {
        int cell = NumberOfCell(cursor.par, cursor.pos);
        if (cursor.par->table->ShouldBeVeryLastCell(cell))
-           SetCursor(cursor.par,cursor.par->last);
+#ifdef NEW_TEXT
+           SetCursor(cursor.par, cursor.par->text.size());
+#else
+           SetCursor(cursor.par, cursor.par->last);
+#endif
    }
    /* table stuff -- end*/
    /* please break alway behind a space */ 
@@ -1384,7 +1497,7 @@ void LyXText::BreakParagraph(char keep_layout)
    if (keep_layout)
      keep_layout = 2;
    else        
-     keep_layout = layout->isEnvironment();
+     keep_layout = layout.isEnvironment();
    cursor.par->BreakParagraph(cursor.pos, keep_layout);
 
    /* table stuff -- begin*/
@@ -1398,7 +1511,7 @@ void LyXText::BreakParagraph(char keep_layout)
    /* table stuff -- end*/
 
    /* well this is the caption hack since one caption is really enough */
-   if (layout->labeltype == LABEL_SENSITIVE){
+   if (layout.labeltype == LABEL_SENSITIVE){
      if (!cursor.pos)
        cursor.par->SetLayout(0); /* set the new paragraph to standard-layout */
      else
@@ -1420,7 +1533,7 @@ void LyXText::BreakParagraph(char keep_layout)
    refresh_y = cursor.y - cursor.row->baseline;
    
    /* Do not forget the special right address boxes */
-   if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
+   if (layout.margintype == MARGIN_RIGHT_ADDRESS_BOX) {
       while (refresh_row->previous &&
             refresh_row->previous->par == refresh_row->par) {
                refresh_row = refresh_row->previous;
@@ -1458,10 +1571,10 @@ void LyXText::BreakParagraph(char keep_layout)
 
 void LyXText::OpenFootnote()
 {
-   LyXParagraph *par, *endpar,*tmppar;
-   Row *row;
+   LyXParagraph * endpar,* tmppar;
+   Row * row;
    
-   par = cursor.par->ParFromPos(cursor.pos);
+   LyXParagraph * par = cursor.par->ParFromPos(cursor.pos);
    
    /* if there is no footnote in this paragraph, just return. */ 
    if (!par->next
@@ -1473,7 +1586,12 @@ void LyXText::OpenFootnote()
    /* just a little faster than using CursorRight() */
    for (cursor.pos=0; cursor.par->ParFromPos(cursor.pos)!=par; cursor.pos++);
    /* now the cursor is at the beginning of the physical par */
+#ifdef NEW_TEXT
+   SetCursor(cursor.par,
+            cursor.pos + cursor.par->ParFromPos(cursor.pos)->text.size());
+#else
    SetCursor(cursor.par, cursor.pos + cursor.par->ParFromPos(cursor.pos)->last);
+#endif
    
    /* the cursor must be exactly before the footnote */ 
    par = cursor.par->ParFromPos(cursor.pos);
@@ -1510,13 +1628,10 @@ void LyXText::OpenFootnote()
 
 void LyXText::TableFeatures(int feature, string val)
 {
-    int
-        actCell;
-    
     if (!cursor.par->table)
         return; /* this should never happen */
   
-    actCell = NumberOfCell(cursor.par, cursor.pos);
+    int actCell = NumberOfCell(cursor.par, cursor.pos);
     SetUndo(Undo::FINISH, 
             cursor.par->ParFromPos(cursor.pos)->previous, 
             cursor.par->ParFromPos(cursor.pos)->next); 
@@ -1538,18 +1653,15 @@ void LyXText::TableFeatures(int feature, string val)
 
 void LyXText::TableFeatures(int feature)
 {
-    int
-        setLines = 0,
-        setAlign = LYX_ALIGN_LEFT,
-        lineSet,
-        actCell;
-    bool
-        what;
+       int setLines = 0;
+       int setAlign = LYX_ALIGN_LEFT;
+       int lineSet;
+       bool what;
     
     if (!cursor.par->table)
         return; /* this should never happen */
   
-    actCell = NumberOfCell(cursor.par, cursor.pos);
+    int actCell = NumberOfCell(cursor.par, cursor.pos);
     SetUndo(Undo::FINISH, 
             cursor.par->ParFromPos(cursor.pos)->previous, 
             cursor.par->ParFromPos(cursor.pos)->next); 
@@ -1569,7 +1681,11 @@ void LyXText::TableFeatures(int feature)
     }
     switch (feature){
       case LyXTable::APPEND_ROW: {
+#ifdef NEW_TEXT
+             LyXParagraph::size_type pos = cursor.pos;
+#else
          int pos = cursor.pos;
+#endif
           /* move to the next row */
           int cell_org = actCell;
           int cell = cell_org;
@@ -1611,8 +1727,7 @@ void LyXText::TableFeatures(int feature)
                
           /* insert the new cells */ 
           int number = cursor.par->table->NumberOfCellsInRow(cell_org);
-          int i;
-          for (i=0; i<number; i++)
+          for (int i = 0; i < number; ++i)
               cursor.par->InsertChar(pos, LYX_META_NEWLINE);
                
           /* append the row into the table */
@@ -1621,7 +1736,11 @@ void LyXText::TableFeatures(int feature)
           return;
       }
       case LyXTable::APPEND_CONT_ROW: {
+#ifdef NEW_TEXT
+             LyXParagraph::size_type pos = cursor.pos;
+#else
           int pos = cursor.pos;
+#endif
           /* move to the next row */
           int cell_org = actCell;
           int cell = cell_org;
@@ -1656,22 +1775,26 @@ void LyXText::TableFeatures(int feature)
           RedoParagraph();
           return;
       }
-      case LyXTable::APPEND_COLUMN: { 
+      case LyXTable::APPEND_COLUMN: {
+#ifdef NEW_TEXT
+             LyXParagraph::size_type pos = 0;
+#else
           int pos = 0;
+#endif
           int cell_org = actCell;
           int cell = 0;
           do{
               if (pos && (cursor.par->IsNewline(pos-1))){
                   if (cursor.par->table->AppendCellAfterCell(cell_org, cell)){
                       cursor.par->InsertChar(pos, LYX_META_NEWLINE);
-                      if (pos<=cursor.pos)
+                      if (pos <= cursor.pos)
                           cursor.pos++;
-                      pos++;
+                      ++pos;
                   }
-                  cell++;
+                  ++cell;
               }
-              pos++;
-          } while (pos<= cursor.par->Last());
+              ++pos;
+          } while (pos <= cursor.par->Last());
           /* remember that the very last cell doesn't end with a newline.
              This saves one byte memory per table ;-) */ 
           if (cursor.par->table->AppendCellAfterCell(cell_org, cell))
@@ -1691,7 +1814,11 @@ void LyXText::TableFeatures(int feature)
           return;
        
       case LyXTable::DELETE_COLUMN: {
+#ifdef NEW_TEXT
+             LyXParagraph::size_type pos = 0;
+#else
           int pos = 0;
+#endif
           int cell_org = actCell;
           int cell = 0;
           if (current_view->currentBuffer()->the_locking_inset)
@@ -1706,12 +1833,12 @@ void LyXText::TableFeatures(int feature)
                           cursor.par->Erase(pos);
                       else 
                           cursor.par->Erase(pos - 1); // the missing newline at the end of a table
-                      pos--; // because of pos++ below
+                      --pos; // because of pos++ below
                   }   
-                  cell++;
+                  ++cell;
               }
-              pos++;
-          } while (pos<= cursor.par->Last());
+              ++pos;
+          } while (pos <= cursor.par->Last());
                
           /* delete the column from the table */ 
           cursor.par->table->DeleteColumn(cell_org);
@@ -1726,10 +1853,15 @@ void LyXText::TableFeatures(int feature)
           if (!selection){
               cursor.par->table->SetTopLine(actCell,lineSet);
           } else {
+#ifdef NEW_TEXT
+                 LyXParagraph::size_type i;
+                 int n = -1, m = -2;
+#else
               int i,n=-1,m=-2;
-              for (i=sel_start_cursor.pos; i<=sel_end_cursor.pos; i++){
-                  if ((n=NumberOfCell(sel_start_cursor.par,i)) != m) {
-                      cursor.par->table->SetTopLine(n,lineSet);
+#endif
+              for (i = sel_start_cursor.pos; i <= sel_end_cursor.pos; ++i){
+                  if ((n = NumberOfCell(sel_start_cursor.par, i)) != m) {
+                      cursor.par->table->SetTopLine(n, lineSet);
                       m = n;
                   }
               }
@@ -1742,10 +1874,15 @@ void LyXText::TableFeatures(int feature)
           if (!selection){
               cursor.par->table->SetBottomLine(actCell,lineSet);
           } else {
-              int i,n=-1,m=-2;
-              for (i=sel_start_cursor.pos; i<=sel_end_cursor.pos; i++){
-                  if ((n=NumberOfCell(sel_start_cursor.par,i)) != m) {
-                      cursor.par->table->SetBottomLine(n,lineSet);
+#ifdef NEW_TEXT
+                 LyXParagraph::size_type i;
+                 int n = -1, m = -2;
+#else
+              int i, n = -1, m = -2;
+#endif
+              for (i = sel_start_cursor.pos; i <= sel_end_cursor.pos; ++i) {
+                  if ((n = NumberOfCell(sel_start_cursor.par, i)) != m) {
+                      cursor.par->table->SetBottomLine(n, lineSet);
                       m = n;
                   }
               }
@@ -1758,8 +1895,13 @@ void LyXText::TableFeatures(int feature)
           if (!selection){
               cursor.par->table->SetLeftLine(actCell,lineSet);
           } else {
+#ifdef NEW_TEXT
+                 LyXParagraph::size_type i;
+                 int n = -1, m = -2;
+#else
               int i,n=-1,m=-2;
-              for (i=sel_start_cursor.pos; i<=sel_end_cursor.pos; i++){
+#endif
+              for (i = sel_start_cursor.pos; i <= sel_end_cursor.pos; ++i){
                   if ((n=NumberOfCell(sel_start_cursor.par,i)) != m) {
                       cursor.par->table->SetLeftLine(n,lineSet);
                       m = n;
@@ -1774,7 +1916,12 @@ void LyXText::TableFeatures(int feature)
           if (!selection){
               cursor.par->table->SetRightLine(actCell,lineSet);
           } else {
+#ifdef NEW_TEXT
+                 LyXParagraph::size_type i;
+                 int n = -1, m = -2;
+#else
               int i,n=-1,m=-2;
+#endif
               for (i=sel_start_cursor.pos; i<=sel_end_cursor.pos; i++){
                   if ((n=NumberOfCell(sel_start_cursor.par,i)) != m) {
                       cursor.par->table->SetRightLine(n,lineSet);
@@ -1791,7 +1938,12 @@ void LyXText::TableFeatures(int feature)
           if (!selection){
               cursor.par->table->SetAlignment(actCell,setAlign);
           } else {
+#ifdef NEW_TEXT
+                 LyXParagraph::size_type i;
+              int n = -1, m = -2;
+#else
               int i,n=-1,m=-2;
+#endif
               for (i=sel_start_cursor.pos; i<=sel_end_cursor.pos; i++){
                   if ((n=NumberOfCell(sel_start_cursor.par,i)) != m) {
                       cursor.par->table->SetAlignment(n,setAlign);
@@ -1809,8 +1961,12 @@ void LyXText::TableFeatures(int feature)
           // temporary: Should put table in simple_cut_buffer (with before and after
           // dummy-paragraph !! 
           // not necessar anymore with UNDO :)
-          int i;
-          for (i = cursor.par->last-1; i>=0; i--)
+#ifdef NEW_TEXT
+          for (LyXParagraph::size_type i =
+                      cursor.par->text.size() - 1; i >= 0; --i)
+#else
+          for (int i = cursor.par->last-1; i>=0; i--)
+#endif
              cursor.par->Erase(i);
           RedoParagraph();
           return;
@@ -1826,8 +1982,12 @@ void LyXText::TableFeatures(int feature)
 
           if (multicol){
              int newlines = cursor.par->table->UnsetMultiColumn(actCell);
+#ifdef NEW_TEXT
+             LyXParagraph::size_type pos = cursor.pos;
+#else
              int pos = cursor.pos;
-             while (pos<cursor.par->Last() && !cursor.par->IsNewline(pos))
+#endif
+             while (pos < cursor.par->Last() && !cursor.par->IsNewline(pos))
                   pos++;
              for (;newlines;newlines--)
                   cursor.par->InsertChar(pos, LYX_META_NEWLINE);
@@ -1845,15 +2005,20 @@ void LyXText::TableFeatures(int feature)
              }
              else {
                   if (sel_start_cursor.row == sel_end_cursor.row){
+#ifdef NEW_TEXT
+                      LyXParagraph::size_type i;
+#else
                       int i;
+#endif
                       number = 1;
-                      for (i=sel_start_cursor.pos; i<sel_end_cursor.pos; i++){
+                      for (i = sel_start_cursor.pos;
+                          i < sel_end_cursor.pos; ++i){
                           if (sel_start_cursor.par->IsNewline(i)){
                               sel_start_cursor.par->Erase(i);
                               // check for double-blanks
                               if ((i && !sel_start_cursor.par->IsLineSeparator(i-1))
                                   &&
-                                  (i<sel_start_cursor.par->Last() 
+                                  (i < sel_start_cursor.par->Last() 
                                    && !sel_start_cursor.par->IsLineSeparator(i)))
                                   sel_start_cursor.par->InsertChar(i, ' ');
                               else {
@@ -1888,8 +2053,13 @@ void LyXText::TableFeatures(int feature)
                                                           cursor.pos),
                                              setLines);
           } else {
+#ifdef NEW_TEXT
+                 LyXParagraph::size_type i;
+                 int n = -1, m = -2;
+#else
               int i,n=-1,m=-2;
-              for (i=sel_start_cursor.pos; i<=sel_end_cursor.pos; i++){
+#endif
+              for (i = sel_start_cursor.pos; i <= sel_end_cursor.pos; ++i) {
                   if ((n=NumberOfCell(sel_start_cursor.par,i)) != m) {
                       cursor.par->table->SetAllLines(n,setLines);
                       m = n;
@@ -1914,9 +2084,14 @@ void LyXText::TableFeatures(int feature)
           if (!selection){
               cursor.par->table->SetRotateCell(actCell,true);
           } else {
+#ifdef NEW_TEXT
+                 LyXParagraph::size_type i;
+                 int n = -1, m = -2;
+#else
               int i,n=-1,m=-2;
-              for (i=sel_start_cursor.pos; i<=sel_end_cursor.pos; i++){
-                  if ((n=NumberOfCell(sel_start_cursor.par,i)) != m) {
+#endif
+              for (i = sel_start_cursor.pos; i <= sel_end_cursor.pos; ++i){
+                  if ((n = NumberOfCell(sel_start_cursor.par,i)) != m) {
                       cursor.par->table->SetRotateCell(n,true);
                       m = n;
                   }
@@ -1927,7 +2102,12 @@ void LyXText::TableFeatures(int feature)
           if (!selection){
               cursor.par->table->SetRotateCell(actCell,false);
           } else {
-              int i,n=-1,m=-2;
+#ifdef NEW_TEXT
+                 LyXParagraph::size_type i;
+                 int n = -1, m = -2;
+#else
+              int i, n = -1, m = -2;
+#endif
               for (i=sel_start_cursor.pos; i<=sel_end_cursor.pos; i++){
                   if ((n=NumberOfCell(sel_start_cursor.par,i)) != m) {
                       cursor.par->table->SetRotateCell(n,false);
@@ -1941,9 +2121,14 @@ void LyXText::TableFeatures(int feature)
           if (!selection){
               cursor.par->table->SetLinebreaks(actCell,what);
           } else {
-              int i,n=-1,m=-2;
-              for (i=sel_start_cursor.pos; i<=sel_end_cursor.pos; i++){
-                  if ((n=NumberOfCell(sel_start_cursor.par,i)) != m) {
+#ifdef NEW_TEXT
+                 LyXParagraph::size_type i;
+                 int n = -1, m = -2;
+#else
+              int i, n = -1, m = -2;
+#endif
+              for (i = sel_start_cursor.pos; i <= sel_end_cursor.pos; ++i) {
+                  if ((n = NumberOfCell(sel_start_cursor.par,i)) != m) {
                       cursor.par->table->SetLinebreaks(n,what);
                       m = n;
                   }
@@ -1972,8 +2157,8 @@ void LyXText::TableFeatures(int feature)
 
 void LyXText::InsertCharInTable(char c)
 {
-       Row *row;
-       Row *tmprow;
+       Row * row;
+       Row * tmprow;
        long y;
        bool jumped_over_space;
        
@@ -1991,7 +2176,12 @@ void LyXText::InsertCharInTable(char c)
                                            * current font */
 
        // Get the font that is used to calculate the baselineskip
+#ifdef NEW_TEXT
+       LyXParagraph::size_type const lastpos =
+               cursor.par->Last();
+#else
        int const lastpos = cursor.par->Last();
+#endif
        LyXFont rawparfont = cursor.par->GetFontSettings(lastpos - 1);
 
        jumped_over_space = false;
@@ -2019,11 +2209,6 @@ void LyXText::InsertCharInTable(char c)
                 TableFeatures(LyXTable::APPEND_CONT_ROW);
                 CursorDown();
             }
-         /* the newline character is the separator of the cells */
-         // cursor.par->InsertChar(cursor.pos, c);
-         // SetCharFont(cursor.par, cursor.pos, rawtmpfont);
-         // RedoParagraphs(cursor, cursor.par->Next());
-         // SetCursor(cursor.par, cursor.pos+1);
          return;
        }
    
@@ -2056,23 +2241,30 @@ void LyXText::InsertCharInTable(char c)
                RedoHeightOfParagraph(cursor);
 }
 
-
-void LyXText::CheckParagraphInTable(LyXParagraph* par, int pos)
+#ifdef NEW_TEXT
+void LyXText::CheckParagraphInTable(LyXParagraph * par,
+                                   LyXParagraph::size_type pos)
+#else
+void LyXText::CheckParagraphInTable(LyXParagraph * par, int pos)
+#endif
 {
-       Row *row;
-       long y;
        
        if (par->GetChar(pos) == LYX_META_INSET &&
            par->GetInset(pos) && par->GetInset(pos)->Display()){
          par->GetInset(pos)->SetDisplay(false);
        }
 
-       row = GetRow(par, pos, y);
+       long y;
+       Row * row = GetRow(par, pos, y);
        
        int tmpheight = row->height;
        SetHeightOfRow(row);
-       
+
+#ifdef NEW_TEXT
+       LyXParagraph::size_type tmp_pos = pos;
+#else
        int tmp_pos = pos;
+#endif
        /* update the table information */
        while (tmp_pos && !par->IsNewline(tmp_pos - 1))
                tmp_pos--;
@@ -2105,7 +2297,7 @@ void LyXText::CheckParagraphInTable(LyXParagraph* par, int pos)
 
 void LyXText::BackspaceInTable()
 {
-       Row *tmprow, *row;
+       Row * tmprow, * row;
        long y;
        
        LyXFont rawtmpfont = current_font;
@@ -2206,14 +2398,19 @@ void LyXText::RedoParagraph()
  * same Paragraph one to the right and make a rebreak */
 void  LyXText::InsertChar(char c)
 {
-       Row *row;
-       Row *tmprow;
-       int z;
+       Row * row;
+       Row * tmprow;
        long y;
        bool jumped_over_space;
        LyXFont realtmpfont;
        LyXFont rawtmpfont;
+#ifdef NEW_TEXT
+       LyXParagraph::size_type z;
+       LyXParagraph::size_type lastpos;
+#else
+       int z;
        int lastpos;
+#endif
        LyXFont rawparfont;
    
        SetUndo(Undo::INSERT, 
@@ -2223,15 +2420,8 @@ void  LyXText::InsertChar(char c)
        /* When the free-spacing option is set for the current layout,
         * all spaces are converted to protected spaces. */
        bool freeSpacingBo =
-               lyxstyle.Style(parameters->textclass,
-                              cursor.row->par->GetLayout())->free_spacing;
-       //
-       // Is this wanted? There cannot be a line break between protected
-       // separators. Therefore I suggest the way implemented below
-       // (Matthias)
-       //
-       //   if ( freeSpacingBo && IsLineSeparatorChar(c) )
-       //         c = LYX_META_PROTECTED_SEPARATOR;
+               textclasslist.Style(parameters->textclass,
+                              cursor.row->par->GetLayout()).free_spacing;
    
        if (freeSpacingBo && IsLineSeparatorChar(c) 
            && (!cursor.pos || cursor.par->IsLineSeparator(cursor.pos-1))) 
@@ -2436,8 +2626,8 @@ void  LyXText::InsertChar(char c)
                RedoHeightOfParagraph(cursor);
        } else {
                /* now the special right address boxes */
-               if (lyxstyle.Style(parameters->textclass,
-                                  cursor.par->GetLayout())->margintype
+               if (textclasslist.Style(parameters->textclass,
+                                  cursor.par->GetLayout()).margintype
                    == MARGIN_RIGHT_ADDRESS_BOX) {
                        RedoDrawingOfParagraph(cursor); 
                }
@@ -2457,12 +2647,12 @@ void  LyXText::InsertChar(char c)
 }
    
    
-void LyXText::PrepareToPrint(Row *row, float &x, float &fill_separator, 
-                            float &fill_hfill, float &fill_label_hfill)
+void LyXText::PrepareToPrint(Row * row, float & x, float & fill_separator, 
+                            float & fill_hfill, float & fill_label_hfill)
 {
-       float w, nh, nlh, ns;
+       float nh, nlh, ns;
        
-       w = row->fill;
+       float w = row->fill;
        fill_hfill = 0;
        fill_label_hfill = 0;
        fill_separator = 0;
@@ -2471,10 +2661,10 @@ void LyXText::PrepareToPrint(Row *row, float &x, float &fill_separator,
        x = LeftMargin(row);
        
        /* is there a manual margin with a manual label */ 
-       if (lyxstyle.Style(parameters->textclass,
-                          row->par->GetLayout())->margintype == MARGIN_MANUAL
-           && lyxstyle.Style(parameters->textclass,
-                             row->par->GetLayout())->labeltype == LABEL_MANUAL) {
+       if (textclasslist.Style(parameters->textclass,
+                          row->par->GetLayout()).margintype == MARGIN_MANUAL
+           && textclasslist.Style(parameters->textclass,
+                             row->par->GetLayout()).labeltype == LABEL_MANUAL) {
               
                nlh = NumberOfLabelHfills(row) + 1; /* one more since labels 
                                                    * are left aligned*/ 
@@ -2501,7 +2691,7 @@ void LyXText::PrepareToPrint(Row *row, float &x, float &fill_separator,
            * set x how you need it */
           int align;
           if (row->par->FirstPhysicalPar()->align == LYX_ALIGN_LAYOUT)
-            align = lyxstyle.Style(parameters->textclass, row->par->GetLayout())->align;
+            align = textclasslist.Style(parameters->textclass, row->par->GetLayout()).align;
           else
             align = row->par->FirstPhysicalPar()->align;
           
@@ -2703,9 +2893,9 @@ int LyXText::SelectWordWhenUnderCursor()
 
 // This function is only used by the spellchecker for NextWord().
 // It doesn't handle LYX_ACCENTs and probably never will.
-char* LyXText::SelectNextWord(float &value)
+char * LyXText::SelectNextWord(float & value)
 {
-       LyXParagraph* tmppar = cursor.par;
+       LyXParagraph * tmppar = cursor.par;
        
        // If this is not the very first word, skip rest of
        // current word because we are probably in the middle
@@ -2751,19 +2941,22 @@ char* LyXText::SelectNextWord(float &value)
                cursor.pos++;
 
        // Finally, we copy the word to a string and return it
-       char* string = 0;
+       char * str = 0;
 
        if (sel_cursor.pos < cursor.pos) {
-               string = new char [cursor.pos - sel_cursor.pos + 2];
+               str = new char [cursor.pos - sel_cursor.pos + 2];
+#ifdef NEW_TEXT
+               LyXParagraph::size_type i, j;
+#else
                int i,j;
-               
-               for (i=sel_cursor.pos, j=0; i<cursor.pos; i++) {
+#endif 
+               for (i = sel_cursor.pos, j = 0; i < cursor.pos; ++i) {
                        if (cursor.par->GetChar(i) != LYX_META_INSET)
-                               string[j++] = cursor.par->GetChar(i);
+                               str[j++] = cursor.par->GetChar(i);
                }
-               string[j] = '\0';
+               str[j] = '\0';
        }
-       return string;
+       return str;
 }
 
 
@@ -2828,7 +3021,7 @@ void LyXText::DeleteWordBackward()
        if (!cursor.par->Last())
          CursorLeft();
        else{
-         selection = True; // to avoid deletion 
+         selection = true; // to avoid deletion 
          CursorLeftOneWord();
          sel_cursor = cursor;
          cursor = tmpcursor;
@@ -2857,6 +3050,7 @@ void LyXText::DeleteLineForward()
        }
 }
 
+
 // Change the case of a word at cursor position. The meaning of action
 // is:
 // 0  change to lowercase
@@ -2868,34 +3062,40 @@ void LyXText::DeleteLineForward()
 // LyXParagraph, but it will have to change for 1.1 anyway. At least
 // it does not access outside of the allocated array as the older
 // version did. (JMarc) 
-void LyXText::ChangeWordCase(int action) 
+void LyXText::ChangeWordCase(LyXText::TextCase action) 
 {
-       LyXParagraph *tmppar = cursor.par->ParFromPos(cursor.pos);
-       int tmppos = cursor.par->PositionInParFromPos(cursor.pos);
+       LyXParagraph * tmppar = cursor.par->ParFromPos(cursor.pos);
 
        SetUndo(Undo::FINISH, tmppar->previous, tmppar->next); 
 
+#ifdef NEW_TEXT
+       LyXParagraph::size_type tmppos =
+               cursor.par->PositionInParFromPos(cursor.pos);
+       while (tmppos < tmppar->size()) {
+#else
+       int tmppos = cursor.par->PositionInParFromPos(cursor.pos);
        while (tmppos < tmppar->last) {
+#endif
                unsigned char c = tmppar->text[tmppos];
                if (IsKommaChar(c) || IsLineSeparatorChar(c))
                        break;
                if (c != LYX_META_INSET) {
                        switch (action) {
-                       case 0:
+                       case text_lowercase:
                                c = tolower(c);
                                break;
-                       case 1:
+                       case text_capitalization:
                                c = toupper(c);
-                               action = 0;
+                               action = text_lowercase;
                                break;
-                       case 2:
+                       case text_uppercase:
                                c = toupper(c);
                                break;
                        }
                }
                
                tmppar->text[tmppos] = c;
-               tmppos++;
+               ++tmppos;
        }
        CheckParagraph(tmppar, tmppos);
        CursorRightOneWord();
@@ -2905,7 +3105,6 @@ void LyXText::ChangeWordCase(int action)
 void  LyXText::Delete()
 {
    LyXCursor old_cursor = cursor;
-   LyXCursor tmpcursor;
    /* this is a very easy implementation*/ 
    
    /* just move to the right */ 
@@ -2917,7 +3116,7 @@ void  LyXText::Delete()
    
    /* if you had success make a backspace */ 
    if (old_cursor.par != cursor.par || old_cursor.pos != cursor.pos) {
-     tmpcursor = cursor;
+     LyXCursor tmpcursor = cursor;
      cursor = old_cursor; // to make sure undo gets the right cursor position
      SetUndo(Undo::DELETE, 
             cursor.par->ParFromPos(cursor.pos)->previous, 
@@ -2930,8 +3129,8 @@ void  LyXText::Delete()
 
 void  LyXText::Backspace()
 {
-       LyXParagraph *tmppar;
-       Row *tmprow, *row;
+       LyXParagraph * tmppar;
+       Row * tmprow, * row;
        long y;
        int tmpheight;
 
@@ -2995,14 +3194,16 @@ void  LyXText::Backspace()
                tmppar = cursor.par;
                tmprow = cursor.row;
                CursorLeftIntern();
-               /* Pasting is not allowed, if the paragraphs have different layout.
-                * I think it is a real bug of all other word processors to allow
-                * it. It confuses the user. Even so with a footnote paragraph and
-                * a non-footnote paragraph. I will not allow pasting in this case, 
-                * because the user would be confused if the footnote behaves 
-                * different wether it is open or closed.
-                * 
-                * Correction: Pasting is always allowed with standard-layout */
+               /* Pasting is not allowed, if the paragraphs have different
+                  layout. I think it is a real bug of all other
+                  word processors to allow it. It confuses the user.
+                  Even so with a footnote paragraph and a non-footnote
+                  paragraph. I will not allow pasting in this case, 
+                  because the user would be confused if the footnote behaves 
+                  different wether it is open or closed.
+                 
+                  Correction: Pasting is always allowed with standard-layout
+               */
                if (cursor.par != tmppar
                    && (cursor.par->GetLayout() == tmppar->GetLayout()
                        || !tmppar->GetLayout())
@@ -3029,9 +3230,6 @@ void  LyXText::Backspace()
                        RemoveParagraph(tmprow);
                        RemoveRow(tmprow);  
                        
-                       /* break the paragraph again */ 
-                       /* BreakAgain(cursor.row); */ 
-                       
                        AppendParagraph(cursor.row);
                        UpdateCounters(cursor.row);
                        
@@ -3061,8 +3259,11 @@ void  LyXText::Backspace()
                
                row = cursor.row;
                y = cursor.y - row->baseline;
+#ifdef NEW_TEXT
+               LyXParagraph::size_type z;
+#else
                int z;
-               
+#endif 
                /* remember that a space at the end of a row doesnt count
                 * when calculating the fill */ 
                if (cursor.pos < RowLast(row) ||
@@ -3125,8 +3326,7 @@ void  LyXText::Backspace()
                        /* delete newlines at the beginning of paragraphs */ 
                        while (cursor.par->Last() &&
                               cursor.par->IsNewline(cursor.pos) &&
-                              cursor.pos == BeginningOfMainBody(cursor.par)
-                               ) {
+                              cursor.pos == BeginningOfMainBody(cursor.par)) {
                                cursor.par->Erase(cursor.pos);
                                /* refresh the positions */
                                tmprow = row;
@@ -3233,24 +3433,27 @@ void  LyXText::Backspace()
                RedoHeightOfParagraph(cursor);
        } else {
                /* now the special right address boxes */
-               if (lyxstyle.Style(parameters->textclass,
-                                  cursor.par->GetLayout())->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
+               if (textclasslist.Style(parameters->textclass,
+                                  cursor.par->GetLayout()).margintype == MARGIN_RIGHT_ADDRESS_BOX) {
                        RedoDrawingOfParagraph(cursor); 
                }
        }
 }
 
 
-void LyXText::GetVisibleRow(LyXScreen &scr, int offset, 
-                           Row *row_ptr, long y)
+void LyXText::GetVisibleRow(LyXScreen & scr, int offset, 
+                           Row * row_ptr, long y)
 {
        /* returns a printed row */
-       
+#ifdef NEW_TEXT
+       LyXParagraph::size_type pos, pos_end;
+#else
        int pos, pos_end;
+#endif
        float x, tmpx;
        int y_top, y_bottom;
        float fill_separator, fill_hfill, fill_label_hfill;
-       LyXParagraph *par, *firstpar;
+       LyXParagraph * par, * firstpar;
        int left_margin;
        LyXFont font;
        int maxdesc;
@@ -3261,9 +3464,13 @@ void LyXText::GetVisibleRow(LyXScreen &scr, int offset,
        left_margin = LabelEnd(row_ptr);
        PrepareToPrint(row_ptr, x, fill_separator,
                       fill_hfill, fill_label_hfill);
-       
+
+#ifdef NEW_TEXT
+       LyXParagraph::size_type main_body =
+               BeginningOfMainBody(row_ptr->par);
+#else
        int main_body = BeginningOfMainBody(row_ptr->par);
-       
+#endif
        /* initialize the pixmap */
        
        scr.fillRectangle(gc_clear,
@@ -3402,7 +3609,7 @@ void LyXText::GetVisibleRow(LyXScreen &scr, int offset,
                }
        }
        
-       LyXLayout* layout = lyxstyle.Style(parameters->textclass,
+       LyXLayout const & layout = textclasslist.Style(parameters->textclass,
                                           row_ptr->par->GetLayout());
        firstpar = row_ptr->par->FirstPhysicalPar();
        
@@ -3452,13 +3659,13 @@ void LyXText::GetVisibleRow(LyXScreen &scr, int offset,
                /* think about the parskip */ 
                /* some parskips VERY EASY IMPLEMENTATION */ 
                if (parameters->paragraph_separation == LYX_PARSEP_SKIP) {
-                       if (layout->latextype == LATEX_PARAGRAPH
+                       if (layout.latextype == LATEX_PARAGRAPH
                            && firstpar->GetDepth() == 0
                            && firstpar->Previous())
                                y_top += parameters->getDefSkip().inPixels();
                        else if (firstpar->Previous()
-                                && lyxstyle.Style(parameters->textclass,
-                                                  firstpar->Previous()->GetLayout())->latextype == LATEX_PARAGRAPH
+                                && textclasslist.Style(parameters->textclass,
+                                                  firstpar->Previous()->GetLayout()).latextype == LATEX_PARAGRAPH
                                 && firstpar->Previous()->GetDepth() == 0)
                                // is it right to use defskip here, too? (AS) 
                                y_top += parameters->getDefSkip().inPixels();
@@ -3473,28 +3680,28 @@ void LyXText::GetVisibleRow(LyXScreen &scr, int offset,
                }
                
                /* should we print a label? */ 
-               if (layout->labeltype >= LABEL_STATIC
-                   && (layout->labeltype != LABEL_STATIC
-                       || layout->latextype != LATEX_ENVIRONMENT
+               if (layout.labeltype >= LABEL_STATIC
+                   && (layout.labeltype != LABEL_STATIC
+                       || layout.latextype != LATEX_ENVIRONMENT
                        || row_ptr->par->IsFirstInSequence())) {
                        font = GetFont(row_ptr->par, -2);
                        if (!row_ptr->par->GetLabestring().empty()) {
                                tmpx = x;
                                string tmpstring = row_ptr->par->GetLabestring();
                                
-                               if (layout->labeltype == LABEL_COUNTER_CHAPTER) {
+                               if (layout.labeltype == LABEL_COUNTER_CHAPTER) {
                                        if (parameters->secnumdepth >=0){
                                                /* this is special code for the chapter layout. This is printed in
                                                 * an extra row and has a pagebreak at the top. */
-                                               maxdesc = int(font.maxDescent() * layout->spacing.getValue() * parameters->spacing.getValue())
-                                                       + int(layout->parsep) * DefaultHeight();
+                                               maxdesc = int(font.maxDescent() * layout.spacing.getValue() * parameters->spacing.getValue())
+                                                       + int(layout.parsep) * DefaultHeight();
                                                scr.drawString(font, tmpstring,
                                                               offset + row_ptr->baseline
                                                               - row_ptr->ascent_of_text - maxdesc,
                                                               int(x));
                                        }
                                } else {
-                                       x -= font.stringWidth( layout->labelsep);
+                                       x -= font.stringWidth( layout.labelsep);
                                        x -= font.stringWidth( tmpstring);
                                        /* draw it! */
                                        scr.drawString(font, tmpstring,
@@ -3503,19 +3710,19 @@ void LyXText::GetVisibleRow(LyXScreen &scr, int offset,
                                x = tmpx;
                        }
                        /* the labels at the top of an environment. More or less for bibliography */ 
-               } else if (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
-                          layout->labeltype == LABEL_BIBLIO ||
-                          layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
+               } else if (layout.labeltype == LABEL_TOP_ENVIRONMENT ||
+                          layout.labeltype == LABEL_BIBLIO ||
+                          layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
                        if (row_ptr->par->IsFirstInSequence()) {
                                font = GetFont(row_ptr->par, -2);
                                if (!row_ptr->par->GetLabestring().empty()) {
                                        string tmpstring = row_ptr->par->GetLabestring();
                                        
-                                       maxdesc = int(font.maxDescent() * layout->spacing.getValue() * parameters->spacing.getValue()
-                                                        + (layout->labelbottomsep * DefaultHeight()));
+                                       maxdesc = int(font.maxDescent() * layout.spacing.getValue() * parameters->spacing.getValue()
+                                                        + (layout.labelbottomsep * DefaultHeight()));
                                        
                                        int top_label_x = int(x);
-                                       if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT){
+                                       if (layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT){
                                                top_label_x = int(x + (paperwidth - RightMargin(row_ptr) - x) / 2); 
                                                top_label_x -= (font.stringWidth( tmpstring)/2);
                                        }
@@ -3527,10 +3734,10 @@ void LyXText::GetVisibleRow(LyXScreen &scr, int offset,
                                }
                        }
                }
-               if (layout->labeltype==LABEL_BIBLIO) { // ale970302
+               if (layout.labeltype==LABEL_BIBLIO) { // ale970302
                        if (row_ptr->par->bibkey) {
                                tmpx = x;
-                               x -= font.stringWidth(layout->labelsep);
+                               x -= font.stringWidth(layout.labelsep);
                                font = GetFont(row_ptr->par, -1);
                                x -= row_ptr->par->bibkey->Width(font);
                                row_ptr->par->bibkey->Draw(font, scr,
@@ -3649,7 +3856,7 @@ void LyXText::GetVisibleRow(LyXScreen &scr, int offset,
                                        x+=SingleWidth(row_ptr->par, pos);
                                        /* -------> Only draw protected spaces when not in
                                         * free-spacing mode. */
-                                       if (row_ptr->par->GetChar(pos)==LYX_META_PROTECTED_SEPARATOR && !layout->free_spacing) {
+                                       if (row_ptr->par->GetChar(pos)==LYX_META_PROTECTED_SEPARATOR && !layout.free_spacing) {
                                                scr.drawVerticalLine(gc_fill, int(tmpx),
                                                                     offset + row_ptr->baseline - 3,
                                                                     offset + row_ptr->baseline - 1);
@@ -3750,7 +3957,7 @@ void LyXText::GetVisibleRow(LyXScreen &scr, int offset,
                                                x+= fill_separator;
                                        /* -------> Only draw protected spaces when not in
                                         * free-spacing mode. */
-                                       if (row_ptr->par->GetChar(pos)==LYX_META_PROTECTED_SEPARATOR && !layout->free_spacing) {
+                                       if (row_ptr->par->GetChar(pos)==LYX_META_PROTECTED_SEPARATOR && !layout.free_spacing) {
                                                
                                                scr.drawVerticalLine(gc_fill, int(tmpx),
                                                                     offset + row_ptr->baseline - 3,
@@ -3778,7 +3985,7 @@ void LyXText::GetVisibleRow(LyXScreen &scr, int offset,
                        }
                        if (pos == main_body) {
                                x += GetFont(row_ptr->par, -2).stringWidth(
-                                       layout->labelsep);
+                                       layout.labelsep);
                                if (row_ptr->par->IsLineSeparator(pos - 1))
                                        x-= SingleWidth(row_ptr->par, pos - 1);
                                if (x < left_margin)
@@ -3824,27 +4031,25 @@ int LyXText::DefaultHeight()
    
 /* returns the column near the specified x-coordinate of the row 
 * x is set to the real beginning of this column  */ 
-int  LyXText::GetColumnNearX(Row *row, int& x)
+int  LyXText::GetColumnNearX(Row * row, int& x)
 {
-       int c; 
        float tmpx = 0.0;
        float fill_separator, fill_hfill, fill_label_hfill;
-       int left_margin;
    
-       left_margin = LabelEnd(row);
+       int left_margin = LabelEnd(row);
        PrepareToPrint(row, tmpx, fill_separator,
                       fill_hfill, fill_label_hfill);
        int main_body = BeginningOfMainBody(row->par);
    
-       c = row->pos;
+       int c = row->pos;
 
        int last = RowLast(row);
        if (row->par->IsNewline(last))
                last--;
    
-       LyXLayout *layout = lyxstyle.Style(parameters->textclass,
+       LyXLayout const & layout = textclasslist.Style(parameters->textclass,
                                           row->par->GetLayout());
-       /* table stuff -- begin*/
+       /* table stuff -- begin */
        if (row->par->table) {
                if (!row->next || row->next->par != row->par)
                        last = RowLast(row); /* the last row doesn't need a newline at the end*/
@@ -3878,7 +4083,7 @@ int  LyXText::GetColumnNearX(Row *row, int& x)
                        if (c && c == main_body
                            && !row->par->IsLineSeparator(c - 1)) {
                                tmpx += GetFont(row->par, -2)
-                                       .stringWidth(layout->labelsep);
+                                       .stringWidth(layout.labelsep);
                                if (tmpx < left_margin)
                                        tmpx = left_margin;
                        }
@@ -3898,7 +4103,7 @@ int  LyXText::GetColumnNearX(Row *row, int& x)
                        if (c == main_body
                            && row->par->IsLineSeparator(c - 1)) {
                                tmpx += GetFont(row->par, -2)
-                                       .stringWidth(layout->labelsep);
+                                       .stringWidth(layout.labelsep);
                                tmpx-= SingleWidth(row->par, c - 1);
                                if (tmpx < left_margin)
                                        tmpx = left_margin;
@@ -4020,8 +4225,8 @@ void LyXText::InsertFootnoteEnvironment(LyXParagraph::footnote_kind kind)
                || kind == LyXParagraph::WIDE_TAB
               || kind == LyXParagraph::WIDE_FIG 
                || kind == LyXParagraph::ALGORITHM) {
-                  int lay = lyxstyle.NumberOfLayout(parameters->textclass,
-                                                    "Caption");
+                  int lay = textclasslist.NumberOfLayout(parameters->textclass,
+                                                    "Caption").second;
                   if (lay == -1) // layout not found
                           // use default layout "Standard" (0)
                           lay = 0;
@@ -4056,9 +4261,13 @@ void LyXText::InsertFootnoteEnvironment(LyXParagraph::footnote_kind kind)
    
 
 /* returns pointer to a specified row */
-Row* LyXText::GetRow(LyXParagraph *par, int pos, long &y)
+#ifdef NEW_TEXT
+Row * LyXText::GetRow(LyXParagraph * par, LyXParagraph::size_type pos, long &y)
+#else
+Row * LyXText::GetRow(LyXParagraph * par, int pos, long &y)
+#endif
 {
-   Row* tmprow;
+   Row * tmprow;
 
    if (currentrow){
      if (par == currentrow->par || par == currentrow->par->Previous()){
index 6515b58c7aef9fdf121a4a9ebebbf47c00046c52..75535d20da3bc8d426bf20e2a5e328de8798b5d1 100644 (file)
 #include "lyxtext.h"
 #include "gettext.h"
 
-extern MiniBuffer *minibuffer;
+extern MiniBuffer * minibuffer;
 
 // Constructor
-LyXText::LyXText(int pw, Buffer *p)
+LyXText::LyXText(int pw, Buffer * p)
 {
        firstrow = 0;
        lastrow = 0;
@@ -48,7 +48,7 @@ LyXText::LyXText(int pw, Buffer *p)
        number_of_rows = 0;
        refresh_y= 0;
        status = LyXText::UNCHANGED;
-       LyXParagraph *par = p->paragraph;
+       LyXParagraph * par = p->paragraph;
        current_font = GetFont(par, 0);
    
        height = 0;
@@ -82,7 +82,7 @@ LyXText::LyXText(int pw, Buffer *p)
 LyXText::~LyXText()
 {
        // Delete all rows, this does not touch the paragraphs!
-       Row *tmprow = firstrow;
+       Row * tmprow = firstrow;
        while (firstrow) {
                tmprow = firstrow->next;
                delete firstrow;
@@ -98,31 +98,36 @@ LyXText::~LyXText()
 // smaller. (Asger)
 // If position is -1, we get the layout font of the paragraph.
 // If position is -2, we get the font of the manual label of the paragraph.
-LyXFont LyXText::GetFont(LyXParagraph* par, int pos)
+#ifdef NEW_TEXT
+LyXFont LyXText::GetFont(LyXParagraph * par,
+                        LyXParagraph::size_type pos)
+#else
+LyXFont LyXText::GetFont(LyXParagraph * par, int pos)
+#endif
 {
-       LyXLayout *layout = 
-               lyxstyle.Style(parameters->textclass, par->GetLayout());
+       LyXLayout const & layout = 
+               textclasslist.Style(parameters->textclass, par->GetLayout());
 
        char par_depth = par->GetDepth();
        // We specialize the 95% common case:
        if (par->footnoteflag == LyXParagraph::NO_FOOTNOTE && !par_depth) {
                if (pos >= 0){
                        // 95% goes here
-                       if (layout->labeltype == LABEL_MANUAL
+                       if (layout.labeltype == LABEL_MANUAL
                            && pos < BeginningOfMainBody(par)) {
                                // 1% goes here
                                return par->GetFontSettings(pos).
-                                               realize(layout->reslabelfont);
+                                               realize(layout.reslabelfont);
                        } else
                                return par->GetFontSettings(pos).
-                                               realize(layout->resfont);
+                                               realize(layout.resfont);
                } else {
                        // 5% goes here.
                        // process layoutfont for pos == -1 and labelfont for pos < -1
                        if (pos == -1)
-                               return layout->resfont;
+                               return layout.resfont;
                        else
-                               return layout->reslabelfont;
+                               return layout.reslabelfont;
                }
        }
 
@@ -134,36 +139,34 @@ LyXFont LyXText::GetFont(LyXParagraph* par, int pos)
                // 95% goes here
                if (pos < BeginningOfMainBody(par)) {
                        // 1% goes here
-                       layoutfont = layout->labelfont;
+                       layoutfont = layout.labelfont;
                } else {
                        // 99% goes here
-                       layoutfont = layout->font;
+                       layoutfont = layout.font;
                }
                tmpfont = par->GetFontSettings(pos);
                tmpfont.realize(layoutfont);
-       } else{
+       } else {
                // 5% goes here.
                // process layoutfont for pos == -1 and labelfont for pos < -1
                if (pos == -1)
-                       tmpfont = layout->font;
+                       tmpfont = layout.font;
                else
-                       tmpfont = layout->labelfont;
+                       tmpfont = layout.labelfont;
        }
 
        // Resolve against environment font information
-       //if (par->GetDepth()){ // already in while condition
-               while (par && par_depth && !tmpfont.resolved()) {
-                       par = par->DepthHook(par_depth - 1);
-                       if (par) {
-                               tmpfont.realize(lyxstyle.
-                                               Style(parameters->textclass,
-                                                     par->GetLayout())->font);
-                               par_depth = par->GetDepth();
-                       }
+       while (par && par_depth && !tmpfont.resolved()) {
+               par = par->DepthHook(par_depth - 1);
+               if (par) {
+                       tmpfont.realize(textclasslist.
+                                       Style(parameters->textclass,
+                                             par->GetLayout()).font);
+                       par_depth = par->GetDepth();
                }
-       //}
+       }
 
-       tmpfont.realize(lyxstyle.TextClass(parameters->textclass)->defaultfont);
+       tmpfont.realize(textclasslist.TextClass(parameters->textclass).defaultfont());
 
        // Cosmetic improvement: If this is an open footnote, make the font 
        // smaller.
@@ -176,7 +179,13 @@ LyXFont LyXText::GetFont(LyXParagraph* par, int pos)
 }
 
 
-void LyXText::SetCharFont(LyXParagraph *par, int pos, LyXFont font)
+#ifdef NEW_TEXT
+void LyXText::SetCharFont(LyXParagraph * par,
+                         LyXParagraph::size_type pos,
+                         LyXFont font)
+#else
+void LyXText::SetCharFont(LyXParagraph * par, int pos, LyXFont font)
+#endif
 {
        /* let the insets convert their font */ 
        if (par->GetChar(pos) == LYX_META_INSET) {
@@ -184,16 +193,16 @@ void LyXText::SetCharFont(LyXParagraph *par, int pos, LyXFont font)
                        font = par->GetInset(pos)->ConvertFont(font);
        }
 
-       LyXLayout *layout = lyxstyle.Style(parameters->textclass,
+       LyXLayout const & layout = textclasslist.Style(parameters->textclass,
                                           par->GetLayout());
 
        // Get concrete layout font to reduce against
        LyXFont layoutfont;
 
        if (pos < BeginningOfMainBody(par))
-               layoutfont = layout->labelfont;
+               layoutfont = layout.labelfont;
        else
-               layoutfont = layout->font;
+               layoutfont = layout.font;
 
        // Realize against environment font information
        if (par->GetDepth()){
@@ -201,13 +210,13 @@ void LyXText::SetCharFont(LyXParagraph *par, int pos, LyXFont font)
                while (!layoutfont.resolved() && tp && tp->GetDepth()) {
                        tp = tp->DepthHook(tp->GetDepth()-1);
                        if (tp)
-                               layoutfont.realize(lyxstyle.
+                               layoutfont.realize(textclasslist.
                                                Style(parameters->textclass,
-                                                     tp->GetLayout())->font);
+                                                     tp->GetLayout()).font);
                }
        }
 
-       layoutfont.realize(lyxstyle.TextClass(parameters->textclass)->defaultfont);
+       layoutfont.realize(textclasslist.TextClass(parameters->textclass).defaultfont());
 
        if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
            && par->footnotekind == LyXParagraph::FOOTNOTE) {
@@ -223,9 +232,14 @@ void LyXText::SetCharFont(LyXParagraph *par, int pos, LyXFont font)
 
 /* inserts a new row behind the specified row, increments
  * the touched counters */
-void LyXText::InsertRow(Row *row, LyXParagraph *par, int pos)
+#ifdef NEW_TEXT
+void LyXText::InsertRow(Row * row, LyXParagraph * par,
+                       LyXParagraph::size_type pos)
+#else
+void LyXText::InsertRow(Row * row, LyXParagraph * par, int pos)
+#endif
 {
-       Row *tmprow = new Row;
+       Row * tmprow = new Row;
        if (!row) {
                tmprow->previous = 0;
                tmprow->next = firstrow;
@@ -254,7 +268,7 @@ void LyXText::InsertRow(Row *row, LyXParagraph *par, int pos)
 
 
 /* removes the row and reset the touched counters */
-void LyXText::RemoveRow(Row *row)
+void LyXText::RemoveRow(Row * row)
 {
        /* this must not happen before the currentrow for clear reasons.
           so the trick is just to set the current row onto the previous
@@ -281,16 +295,16 @@ void LyXText::RemoveRow(Row *row)
        height -= row->height;         /* the text becomes smaller  */
    
        delete row;
-       number_of_rows--;                              /* one row less  */
+       --number_of_rows;                              /* one row less  */
 }
 
+
 /* remove all following rows of the paragraph of the specified row. */
-void LyXText::RemoveParagraph(Row *row)
+void LyXText::RemoveParagraph(Row * row)
 {
-       LyXParagraph *tmppar;
-       Row *tmprow;
+       Row * tmprow;
 
-       tmppar = row->par;
+       LyXParagraph * tmppar = row->par;
        row = row->next;
     
        while (row && row->par == tmppar) {
@@ -302,7 +316,7 @@ void LyXText::RemoveParagraph(Row *row)
    
   
 /* insert the specified paragraph behind the specified row */
-void LyXText::InsertParagraph(LyXParagraph *par, Row *row)
+void LyXText::InsertParagraph(LyXParagraph * par, Row * row)
 {
        InsertRow(row, par, 0);        /* insert a new row, starting 
                                        * at postition 0 */
@@ -323,9 +337,7 @@ void LyXText::InsertParagraph(LyXParagraph *par, Row *row)
 
 void LyXText::ToggleFootnote()
 {
-       LyXParagraph *par;
-   
-       par = cursor.par->ParFromPos(cursor.pos);
+       LyXParagraph * par = cursor.par->ParFromPos(cursor.pos);
        if (par->next && par->next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE){
                OpenFootnote();
                minibuffer->Set(_("Opened float"));
@@ -358,10 +370,10 @@ void LyXText::OpenStuff()
 
 void LyXText::CloseFootnote()
 {
-       LyXParagraph *par, *endpar,*tmppar;
-       Row *row;
+       LyXParagraph * endpar, * tmppar;
+       Row * row;
    
-       par = cursor.par->ParFromPos(cursor.pos);
+       LyXParagraph * par = cursor.par->ParFromPos(cursor.pos);
    
        /* if the cursor is not in an open footnote, or 
         * there is no open footnote in this paragraph, just return. */ 
@@ -378,14 +390,16 @@ void LyXText::CloseFootnote()
                /* just a little faster than using CursorRight() */
                for (cursor.pos=0; cursor.par->ParFromPos(cursor.pos)!=par; cursor.pos++);
                /* now the cursor is at the beginning of the physical par */
+#ifdef NEW_TEXT
+               SetCursor(cursor.par,
+                         cursor.pos +
+                         cursor.par->ParFromPos(cursor.pos)->text.size());
+#else
                SetCursor(cursor.par, cursor.pos + cursor.par->ParFromPos(cursor.pos)->last);
+#endif
        }
        else  {
                /* we are in a footnote, so let us move at the beginning */ 
-               /*      while (cursor.par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE)
-                       cursor.par = cursor.par->Previous();
-              
-                       SetCursor(cursor.par, cursor.par->Last()); */
                /* this is just faster than using just CursorLeft() */ 
        
                tmppar = cursor.par;
@@ -409,10 +423,6 @@ void LyXText::CloseFootnote()
    
        tmppar->CloseFootnote(cursor.pos);
 
-       /* set the dimensions of the cursor row */
-       /* row->fill = Fill(row, paperwidth);
-          SetHeightOfRow(row);  */ 
-   
        while (tmppar != endpar) {
                RemoveRow(row->next);
                if (row->next)
@@ -434,19 +444,22 @@ void LyXText::CloseFootnote()
 
 /* used in setlayout */
 // Asger is not sure we want to do this...
-void LyXText::MakeFontEntriesLayoutSpecific(LyXParagraph *par)
+void LyXText::MakeFontEntriesLayoutSpecific(LyXParagraph * par)
 {
        LyXFont layoutfont, tmpfont;
    
-       int pos;
-   
-       LyXLayout* layout = lyxstyle.Style(parameters->textclass, par->GetLayout());
-   
-       for (pos = 0; pos < par->Last(); pos++) {
+       LyXLayout const & layout = textclasslist.Style(parameters->textclass, par->GetLayout());
+
+#ifdef NEW_TEXT
+       for (LyXParagraph::size_type pos = 0;
+            pos < par->Last(); ++pos) {
+#else
+       for (int pos = 0; pos < par->Last(); pos++) {
+#endif
                if (pos < BeginningOfMainBody(par))
-                       layoutfont = layout->labelfont;
+                       layoutfont = layout.labelfont;
                else
-                       layoutfont = layout->font;
+                       layoutfont = layout.font;
       
                tmpfont = par->GetFontSettings(pos);
                tmpfont.reduce(layoutfont);
@@ -466,12 +479,11 @@ void  LyXText::SetLayout(char layout)
                sel_end_cursor = cursor;
        }
 
-       LyXParagraph *endpar = sel_end_cursor.par->LastPhysicalPar()->Next();
-       LyXParagraph *undoendpar = endpar;
+       LyXParagraph * endpar = sel_end_cursor.par->LastPhysicalPar()->Next();
+       LyXParagraph * undoendpar = endpar;
 
        if (endpar && endpar->GetDepth()) {
                while (endpar && endpar->GetDepth()) {
-                       //endpar->depth = 0;
                        endpar = endpar->LastPhysicalPar()->Next();
                        undoendpar = endpar;
                }
@@ -490,7 +502,7 @@ void  LyXText::SetLayout(char layout)
         * and sel_end cursor */ 
        cursor = sel_start_cursor;
    
-       LyXLayout * lyxlayout = lyxstyle.Style(parameters->textclass, layout);
+       LyXLayout const & lyxlayout = textclasslist.Style(parameters->textclass, layout);
    
        while (cursor.par != sel_end_cursor.par) {
                if (cursor.par->footnoteflag ==
@@ -498,13 +510,13 @@ void  LyXText::SetLayout(char layout)
                        cursor.par->SetLayout(layout);
                        MakeFontEntriesLayoutSpecific(cursor.par);
                        LyXParagraph* fppar = cursor.par->FirstPhysicalPar();
-                       fppar->added_space_top = lyxlayout->fill_top ?
+                       fppar->added_space_top = lyxlayout.fill_top ?
                                VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
-                       fppar->added_space_bottom = lyxlayout->fill_bottom ? 
+                       fppar->added_space_bottom = lyxlayout.fill_bottom ? 
                                VSpace(VSpace::VFILL) : VSpace(VSpace::NONE); 
-                       if (lyxlayout->margintype == MARGIN_MANUAL)
-                               cursor.par->SetLabelWidthString(lyxlayout->labelstring);
-                       if (lyxlayout->labeltype != LABEL_BIBLIO
+                       if (lyxlayout.margintype == MARGIN_MANUAL)
+                               cursor.par->SetLabelWidthString(lyxlayout.labelstring());
+                       if (lyxlayout.labeltype != LABEL_BIBLIO
                            && fppar->bibkey) {
                                delete fppar->bibkey;
                                fppar->bibkey = 0;
@@ -517,13 +529,13 @@ void  LyXText::SetLayout(char layout)
                cursor.par->SetLayout(layout);
                MakeFontEntriesLayoutSpecific(cursor.par);
                LyXParagraph* fppar = cursor.par->FirstPhysicalPar();
-               fppar->added_space_top = lyxlayout->fill_top ?
+               fppar->added_space_top = lyxlayout.fill_top ?
                        VSpace(VSpace::VFILL) : VSpace(VSpace::NONE);
-               fppar->added_space_bottom = lyxlayout->fill_bottom ? 
+               fppar->added_space_bottom = lyxlayout.fill_bottom ? 
                        VSpace(VSpace::VFILL) : VSpace(VSpace::NONE); 
-               if (lyxlayout->margintype == MARGIN_MANUAL)
-                       cursor.par->SetLabelWidthString(lyxlayout->labelstring);
-               if (lyxlayout->labeltype != LABEL_BIBLIO
+               if (lyxlayout.margintype == MARGIN_MANUAL)
+                       cursor.par->SetLabelWidthString(lyxlayout.labelstring());
+               if (lyxlayout.labeltype != LABEL_BIBLIO
                    && fppar->bibkey) {
                        delete fppar->bibkey;
                        fppar->bibkey = 0;
@@ -555,8 +567,8 @@ void  LyXText::IncDepth()
        }
 
        // We end at the next paragraph with depth 0
-       LyXParagraph *endpar = sel_end_cursor.par->LastPhysicalPar()->Next();
-       LyXParagraph *undoendpar = endpar;
+       LyXParagraph * endpar = sel_end_cursor.par->LastPhysicalPar()->Next();
+       LyXParagraph * undoendpar = endpar;
 
        if (endpar && endpar->GetDepth()) {
                while (endpar && endpar->GetDepth()) {
@@ -584,15 +596,15 @@ void  LyXText::IncDepth()
                // NOTE: you can't change the depth of a bibliography entry
                if (cursor.par->footnoteflag ==
                    sel_start_cursor.par->footnoteflag
-                   && lyxstyle.Style(parameters->textclass,
+                   && textclasslist.Style(parameters->textclass,
                                      cursor.par->GetLayout()
-                                    )->labeltype != LABEL_BIBLIO) {
+                                    ).labeltype != LABEL_BIBLIO) {
                        LyXParagraph * prev = cursor.par->FirstPhysicalPar()->Previous();
                        if (prev 
                            && (prev->GetDepth() - cursor.par->GetDepth() > 0
                                || (prev->GetDepth() == cursor.par->GetDepth()
-                                   && lyxstyle.Style(parameters->textclass,
-                                                     prev->GetLayout())->isEnvironment()))) {
+                                   && textclasslist.Style(parameters->textclass,
+                                                     prev->GetLayout()).isEnvironment()))) {
                                cursor.par->FirstPhysicalPar()->depth++;
                                anything_changed = true;
                                }
@@ -637,8 +649,8 @@ void  LyXText::DecDepth()
                sel_end_cursor = cursor;
        }
    
-       LyXParagraph *endpar = sel_end_cursor.par->LastPhysicalPar()->Next();
-       LyXParagraph *undoendpar = endpar;
+       LyXParagraph * endpar = sel_end_cursor.par->LastPhysicalPar()->Next();
+       LyXParagraph * undoendpar = endpar;
 
        if (endpar && endpar->GetDepth()) {
                while (endpar && endpar->GetDepth()) {
@@ -696,7 +708,6 @@ void  LyXText::SetFont(LyXFont font, bool toggleall)
                        layoutfont = GetFont(cursor.par, -2);
                else
                        layoutfont = GetFont(cursor.par, -1);
-
                // Update current font
                real_current_font.update(font,toggleall);
 
@@ -751,15 +762,11 @@ void  LyXText::SetFont(LyXFont font, bool toggleall)
 
 void LyXText::RedoHeightOfParagraph(LyXCursor cursor)
 {
-       Row *tmprow;
-       LyXParagraph *first_phys_par;
-       long y;
-   
-       tmprow = cursor.row;
-   
-       y = cursor.y - tmprow->baseline;
+       Row * tmprow = cursor.row;
+       long y = cursor.y - tmprow->baseline;
+
        SetHeightOfRow(tmprow);
-       first_phys_par = tmprow->par->FirstPhysicalPar();
+       LyXParagraph * first_phys_par = tmprow->par->FirstPhysicalPar();
        /* find the first row of the paragraph */
        if (first_phys_par != tmprow->par)
                while (tmprow->previous && tmprow->previous->par != first_phys_par)  {
@@ -783,15 +790,11 @@ void LyXText::RedoHeightOfParagraph(LyXCursor cursor)
 
 void LyXText::RedoDrawingOfParagraph(LyXCursor cursor)
 {
-       Row *tmprow;
-       LyXParagraph *first_phys_par;
-       long y;
+       Row * tmprow = cursor.row;
    
-       tmprow = cursor.row;
-   
-       y = cursor.y - tmprow->baseline;
+       long y = cursor.y - tmprow->baseline;
        SetHeightOfRow(tmprow);
-       first_phys_par = tmprow->par->FirstPhysicalPar();
+       LyXParagraph * first_phys_par = tmprow->par->FirstPhysicalPar();
        /* find the first row of the paragraph */
        if (first_phys_par != tmprow->par)
                while (tmprow->previous && tmprow->previous->par != first_phys_par)  {
@@ -817,15 +820,14 @@ void LyXText::RedoDrawingOfParagraph(LyXCursor cursor)
 /* deletes and inserts again all paragaphs between the cursor
 * and the specified par 
 * This function is needed after SetLayout and SetFont etc. */
-void LyXText::RedoParagraphs(LyXCursor cursor, LyXParagraph *endpar)
+void LyXText::RedoParagraphs(LyXCursor cursor, LyXParagraph * endpar)
 {
-       Row *tmprow, *tmprow2;
-       LyXParagraph *tmppar, *first_phys_par;
-       long y;
+       Row * tmprow2;
+       LyXParagraph * tmppar, * first_phys_par;
    
-       tmprow = cursor.row;
+       Row * tmprow = cursor.row;
    
-       y = cursor.y - tmprow->baseline;
+       long y = cursor.y - tmprow->baseline;
    
        if (!tmprow->previous){
                first_phys_par = FirstParagraph();   // a trick/hack for UNDO
@@ -897,12 +899,6 @@ void LyXText::RedoParagraphs(LyXCursor cursor, LyXParagraph *endpar)
    
        if (tmprow && tmprow->next)
                SetHeightOfRow(tmprow->next);
-   
-       /* restore the correct refresh row  */
-/*    if (refresh_row)
-      refresh_row = refresh_row->next;
-      else
-      refresh_row = firstrow;*/ 
 }
 
 
@@ -1030,9 +1026,9 @@ void  LyXText::CursorBottom()
 /* returns a pointer to the row near the specified y-coordinate
 * (relative to the whole text). y is set to the real beginning
 * of this row */ 
-Row* LyXText::GetRowNearY(long& y)
+Row * LyXText::GetRowNearY(long & y)
 {
-       Row* tmprow;
+       Row * tmprow;
        long tmpy;
    
        if (currentrow){
@@ -1092,9 +1088,14 @@ void LyXText::ToggleFree(LyXFont font, bool toggleall)
 }
 
 
-int LyXText::BeginningOfMainBody(LyXParagraph *par)
+#ifdef NEW_TEXT
+LyXParagraph::size_type
+LyXText::BeginningOfMainBody(LyXParagraph * par)
+#else
+int LyXText::BeginningOfMainBody(LyXParagraph * par)
+#endif
 {
-       if (lyxstyle.Style(parameters->textclass, par->GetLayout())->labeltype != LABEL_MANUAL)
+       if (textclasslist.Style(parameters->textclass, par->GetLayout()).labeltype != LABEL_MANUAL)
                return 0;
        else
                return par->BeginningOfMainBody();
@@ -1105,7 +1106,7 @@ int LyXText::BeginningOfMainBody(LyXParagraph *par)
 * in the selection, otherwise just the environment you are in */ 
 void LyXText::MeltFootnoteEnvironment()
 {
-       LyXParagraph *tmppar, *firsttmppar;
+       LyXParagraph * tmppar, * firsttmppar;
    
        ClearSelection();
    
@@ -1128,8 +1129,12 @@ void LyXText::MeltFootnoteEnvironment()
        firsttmppar = cursor.par->ParFromPos(cursor.pos);
        tmppar = firsttmppar;
        /* tmppar is now the paragraph right before the footnote */
-   
+
+#ifdef NEW_TEXT
+       char first_footnote_par_is_not_empty = tmppar->next->text.size();
+#else
        char first_footnote_par_is_not_empty = tmppar->next->last;
+#endif
    
        while (tmppar->next && tmppar->next->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
                tmppar = tmppar->next;         /* I use next instead of Next(),
@@ -1139,8 +1144,8 @@ void LyXText::MeltFootnoteEnvironment()
                tmppar->footnoteflag = LyXParagraph::NO_FOOTNOTE;
       
                /* remember the captions and empty paragraphs */
-               if ((lyxstyle.Style(parameters->textclass,
-                                   tmppar->GetLayout())->labeltype == LABEL_SENSITIVE)
+               if ((textclasslist.Style(parameters->textclass,
+                                   tmppar->GetLayout()).labeltype == LABEL_SENSITIVE)
                    || !tmppar->Last())
                        tmppar->SetLayout(0);
        }
@@ -1168,8 +1173,13 @@ void LyXText::MeltFootnoteEnvironment()
         * (only if the previous par and the footnotepar are not empty!) */
        if ((!firsttmppar->next->GetLayout() && !firsttmppar->next->table)
            || firsttmppar->HasSameLayout(firsttmppar->next)) {
+#ifdef NEW_TEXT
+               if (firsttmppar->text.size()
+                   && !firsttmppar->IsSeparator(firsttmppar->text.size() - 1)
+#else
                if (firsttmppar->last
                    && !firsttmppar->IsSeparator(firsttmppar->last - 1)
+#endif
                    && first_footnote_par_is_not_empty) {
                        firsttmppar->next->InsertChar(0, ' ');
                }
@@ -1182,7 +1192,7 @@ void LyXText::MeltFootnoteEnvironment()
        SetCursor(cursor.par, cursor.pos);
    
        /* sometimes it can happen, that there is a counter change */ 
-       Row *row = cursor.row;
+       Row * row = cursor.row;
        while (row->next && row->par != tmppar && row->next->par != tmppar)
                row = row->next;
        UpdateCounters(row);
@@ -1201,21 +1211,19 @@ void LyXText::MeltFootnoteEnvironment()
 void LyXText::SetParagraph(bool line_top, bool line_bottom,
                           bool pagebreak_top, bool pagebreak_bottom,
                           VSpace space_top, VSpace space_bottom,
-                          char align, 
+                          LyXAlignment align, 
                           string labelwidthstring,
                           bool noindent) 
 {
-       LyXCursor tmpcursor;
-       tmpcursor = cursor;
-       LyXParagraph *tmppar;
+       LyXCursor tmpcursor = cursor;
        if (!selection) {
                sel_start_cursor = cursor;
                sel_end_cursor = cursor;
        }
 
        // make sure that the depth behind the selection are restored, too
-       LyXParagraph *endpar = sel_end_cursor.par->LastPhysicalPar()->Next();
-       LyXParagraph *undoendpar = endpar;
+       LyXParagraph * endpar = sel_end_cursor.par->LastPhysicalPar()->Next();
+       LyXParagraph * undoendpar = endpar;
 
        if (endpar && endpar->GetDepth()) {
                while (endpar && endpar->GetDepth()) {
@@ -1232,42 +1240,41 @@ void LyXText::SetParagraph(bool line_top, bool line_bottom,
                undoendpar);
 
        
-       tmppar = sel_end_cursor.par;
-       while (tmppar != sel_start_cursor.par->FirstPhysicalPar()->Previous())
-               {
-                       SetCursor(tmppar->FirstPhysicalPar(), 0);
-                       status = LyXText::NEED_MORE_REFRESH;
-                       refresh_row = cursor.row;
-                       refresh_y = cursor.y - cursor.row->baseline;
-                       if (cursor.par->footnoteflag ==
-                           sel_start_cursor.par->footnoteflag) {
-                               cursor.par->line_top = line_top;
-                               cursor.par->line_bottom = line_bottom;
-                               cursor.par->pagebreak_top = pagebreak_top;
-                               cursor.par->pagebreak_bottom = pagebreak_bottom;
-                               cursor.par->added_space_top = space_top;
-                               cursor.par->added_space_bottom = space_bottom;
-                               /* does the layout allow the new alignment? */ 
-                               if (align == LYX_ALIGN_LAYOUT)
-                                       align = lyxstyle.Style(parameters->textclass, cursor.par->GetLayout())->align;
-                               if (align & lyxstyle.Style(parameters->textclass, cursor.par->GetLayout())->alignpossible) {
-                                       if (align == lyxstyle.Style(parameters->textclass, cursor.par->GetLayout())->align)
-                                               cursor.par->align = LYX_ALIGN_LAYOUT;
-                                       else
-                                               cursor.par->align = align;
-                               }
-                               cursor.par->SetLabelWidthString(labelwidthstring);
-                               cursor.par->noindent = noindent;
+       LyXParagraph * tmppar = sel_end_cursor.par;
+       while (tmppar != sel_start_cursor.par->FirstPhysicalPar()->Previous()){
+               SetCursor(tmppar->FirstPhysicalPar(), 0);
+               status = LyXText::NEED_MORE_REFRESH;
+               refresh_row = cursor.row;
+               refresh_y = cursor.y - cursor.row->baseline;
+               if (cursor.par->footnoteflag ==
+                   sel_start_cursor.par->footnoteflag) {
+                       cursor.par->line_top = line_top;
+                       cursor.par->line_bottom = line_bottom;
+                       cursor.par->pagebreak_top = pagebreak_top;
+                       cursor.par->pagebreak_bottom = pagebreak_bottom;
+                       cursor.par->added_space_top = space_top;
+                       cursor.par->added_space_bottom = space_bottom;
+                               /* does the layout allow the new alignment? */
+                       if (align == LYX_ALIGN_LAYOUT)
+                               align = textclasslist
+                                       .Style(parameters->textclass,
+                                              cursor.par->GetLayout()).align;
+                       if (align & textclasslist
+                           .Style(parameters->textclass,
+                                  cursor.par->GetLayout()).alignpossible) {
+                               if (align == textclasslist
+                                   .Style(parameters->textclass,
+                                          cursor.par->GetLayout()).align)
+                                       cursor.par->align = LYX_ALIGN_LAYOUT;
+                               else
+                                       cursor.par->align = align;
                        }
-          
-                       /* 
-                          tmprow = cursor.row;
-                          while (tmprow->next && tmprow->next->par->previous != cursor.par->LastPhysicalPar())
-                          tmprow = tmprow->next;
-                          SetHeightOfRow(tmprow);
-                          SetHeightOfRow(cursor.row); */ 
-                       tmppar = cursor.par->FirstPhysicalPar()->Previous();
+                       cursor.par->SetLabelWidthString(labelwidthstring);
+                       cursor.par->noindent = noindent;
                }
+               
+               tmppar = cursor.par->FirstPhysicalPar()->Previous();
+       }
        
        RedoParagraphs(sel_start_cursor, endpar);
        
@@ -1281,22 +1288,21 @@ void LyXText::SetParagraph(bool line_top, bool line_bottom,
 
 
 void LyXText::SetParagraphExtraOpt(int type,
-                                   const char *width,
-                                   const char *widthp,
+                                   char const * width,
+                                   char const * widthp,
                                    int alignment, bool hfill,
                                    bool start_minipage)
 {
-       LyXCursor tmpcursor;
-       tmpcursor = cursor;
-       LyXParagraph *tmppar;
+       LyXCursor tmpcursor = cursor;
+       LyXParagraph * tmppar;
        if (!selection) {
                sel_start_cursor = cursor;
                sel_end_cursor = cursor;
        }
 
        // make sure that the depth behind the selection are restored, too
-       LyXParagraph *endpar = sel_end_cursor.par->LastPhysicalPar()->Next();
-       LyXParagraph *undoendpar = endpar;
+       LyXParagraph * endpar = sel_end_cursor.par->LastPhysicalPar()->Next();
+       LyXParagraph * undoendpar = endpar;
 
        if (endpar && endpar->GetDepth()) {
                while (endpar && endpar->GetDepth()) {
@@ -1344,13 +1350,13 @@ void LyXText::SetParagraphExtraOpt(int type,
 }
 
 
-static char alphaCounter(int n){
+static char const * alphaCounter(int n){
   static char result[2];
   result[1] = 0;
   if (n == 0)
     return "";
   else {
-    result[0] = 64+n;
+    result[0] = 64 + n;
     if (n > 26)
       return "??";
   }
@@ -1359,17 +1365,17 @@ static char*  alphaCounter(int n){
 
 
 /* set the counter of a paragraph. This includes the labels */ 
-void LyXText::SetCounter(LyXParagraph *par)
+void LyXText::SetCounter(LyXParagraph * par)
 {
        int i;
    
        /* this is only relevant for the beginning of paragraph */ 
        par = par->FirstPhysicalPar();
 
-       LyXLayout* layout = lyxstyle.Style(parameters->textclass, 
+       LyXLayout const & layout = textclasslist.Style(parameters->textclass, 
                                           par->GetLayout());
 
-       LyXTextClass *textclass = lyxstyle.TextClass(parameters->textclass);
+       LyXTextClass const & textclass = textclasslist.TextClass(parameters->textclass);
 
        /* copy the prev-counters to this one, unless this is the start of a 
           footnote or of a bibliography or the very first paragraph */
@@ -1377,10 +1383,10 @@ void LyXText::SetCounter(LyXParagraph *par)
            && !(par->Previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE 
                    && par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
                    && par->footnotekind == LyXParagraph::FOOTNOTE)
-           && !(lyxstyle.Style(parameters->textclass,
+           && !(textclasslist.Style(parameters->textclass,
                                par->Previous()->GetLayout()
-                               )->labeltype != LABEL_BIBLIO
-                && layout->labeltype == LABEL_BIBLIO)) {
+                               ).labeltype != LABEL_BIBLIO
+                && layout.labeltype == LABEL_BIBLIO)) {
                for (i=0; i<10; i++) {
                        par->setCounter(i, par->Previous()->GetFirstCounter(i));
                }
@@ -1412,9 +1418,9 @@ void LyXText::SetCounter(LyXParagraph *par)
            && par->Previous()
            && par->Previous()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE
            && (par->PreviousBeforeFootnote()
-               && lyxstyle.Style(parameters->textclass,
+               && textclasslist.Style(parameters->textclass,
                                  par->PreviousBeforeFootnote()->GetLayout()
-                                )->labeltype >= LABEL_COUNTER_ENUMI)) {
+                                ).labeltype >= LABEL_COUNTER_ENUMI)) {
                 // Any itemize or enumerate environment in a marginnote
                 // that is embedded in an itemize or enumerate
                 // paragraph is seen by LaTeX as being at a deeper
@@ -1434,14 +1440,14 @@ void LyXText::SetCounter(LyXParagraph *par)
         */
        if (par->Previous()
            && par->Previous()->GetDepth() < par->GetDepth()
-           && lyxstyle.Style(parameters->textclass,
+           && textclasslist.Style(parameters->textclass,
                              par->Previous()->GetLayout()
-                            )->labeltype == LABEL_COUNTER_ENUMI
+                            ).labeltype == LABEL_COUNTER_ENUMI
            && par->enumdepth < 3
            && !(par->Previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE 
                    && par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
                    && par->footnotekind == LyXParagraph::FOOTNOTE)
-           && layout->labeltype != LABEL_BIBLIO) {
+           && layout.labeltype != LABEL_BIBLIO) {
                par->enumdepth++;
        }
 
@@ -1451,7 +1457,7 @@ void LyXText::SetCounter(LyXParagraph *par)
            && !(par->Previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE
                    && par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
                    && par->footnotekind == LyXParagraph::FOOTNOTE)
-           && layout->labeltype != LABEL_BIBLIO) {
+           && layout.labeltype != LABEL_BIBLIO) {
                par->enumdepth = par->DepthHook(par->GetDepth())->enumdepth;
                par->setCounter(6 + par->enumdepth,
                        par->DepthHook(par->GetDepth())->getCounter(6 + par->enumdepth));
@@ -1466,9 +1472,9 @@ void LyXText::SetCounter(LyXParagraph *par)
                par->labelstring.clear();
        }
    
-       if (layout->margintype == MARGIN_MANUAL) {
+       if (layout.margintype == MARGIN_MANUAL) {
                if (par->labelwidthstring.empty()) {
-                       par->SetLabelWidthString(layout->labelstring);
+                       par->SetLabelWidthString(layout.labelstring());
                }
        }
        else {
@@ -1476,31 +1482,31 @@ void LyXText::SetCounter(LyXParagraph *par)
        }
    
        /* is it a layout that has an automatic label ? */ 
-       if (layout->labeltype >=  LABEL_FIRST_COUNTER) {
+       if (layout.labeltype >=  LABEL_FIRST_COUNTER) {
       
-               i = layout->labeltype - LABEL_FIRST_COUNTER;
-               if (i>=0 && i<=parameters->secnumdepth) {
+               i = layout.labeltype - LABEL_FIRST_COUNTER;
+               if (i >= 0 && i<=parameters->secnumdepth) {
                        par->incCounter(i);     // increment the counter  
         
                        char * s = new char[50];
 
                        // Is there a label? Useful for Chapter layout
                        if (!par->appendix){
-                               if (!layout->labelstring.empty())
-                                       par->labelstring = layout->labelstring;
+                               if (!layout.labelstring().empty())
+                                       par->labelstring = layout.labelstring();
                                else
                                        par->labelstring.clear();
                         }
                        else {
-                               if (!layout->labelstring_appendix.empty())
-                                       par->labelstring = layout->labelstring_appendix;
+                               if (!layout.labelstring_appendix().empty())
+                                       par->labelstring = layout.labelstring_appendix();
                                else
                                        par->labelstring.clear();
                        }
  
                        if (!par->appendix){
                                switch (2 * LABEL_FIRST_COUNTER -
-                                       textclass->maxcounter + i) {
+                                       textclass.maxcounter() + i) {
                                case LABEL_COUNTER_CHAPTER:
                                        sprintf(s, "%d",
                                                par->getCounter(i));
@@ -1546,7 +1552,7 @@ void LyXText::SetCounter(LyXParagraph *par)
                                }
                        }
                        else {
-                               switch (2 * LABEL_FIRST_COUNTER - textclass->maxcounter+ i) {
+                               switch (2 * LABEL_FIRST_COUNTER - textclass.maxcounter() + i) {
                                case LABEL_COUNTER_CHAPTER:
                                        sprintf(s, "%s",
                                                alphaCounter(par->getCounter(i)));
@@ -1599,12 +1605,12 @@ void LyXText::SetCounter(LyXParagraph *par)
                                /* reset the following counters  */
                                par->setCounter(i, 0);
                        }
-               } else if (layout->labeltype < LABEL_COUNTER_ENUMI) {
+               } else if (layout.labeltype < LABEL_COUNTER_ENUMI) {
                        for (i++; i<10; i++) {
                                /* reset the following counters  */
                                par->setCounter(i, 0);
                        }
-               } else if (layout->labeltype == LABEL_COUNTER_ENUMI) {
+               } else if (layout.labeltype == LABEL_COUNTER_ENUMI) {
                        par->incCounter(i + par->enumdepth);
                        char * s = new char[25];
                        int number = par->getCounter(i + par->enumdepth);
@@ -1646,23 +1652,23 @@ void LyXText::SetCounter(LyXParagraph *par)
                                par->setCounter(i, 0);  /* reset the following counters  */
         
                } 
-       } else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
+       } else if (layout.labeltype == LABEL_BIBLIO) {// ale970302
            i = LABEL_COUNTER_ENUMI - LABEL_FIRST_COUNTER + par->enumdepth;
            par->incCounter(i);
            int number = par->getCounter(i);
            if (!par->bibkey)
              par->bibkey = new InsetBibKey();
            par->bibkey->setCounter(number);
-           par->labelstring = layout->labelstring;
+           par->labelstring = layout.labelstring();
            
            // In biblio should't be following counters but...
        }                                               
        else  {
-               string s = layout->labelstring;
+               string s = layout.labelstring();
       
                /* the caption hack: */
       
-               if (layout->labeltype == LABEL_SENSITIVE) {
+               if (layout.labeltype == LABEL_SENSITIVE) {
                        if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE
                            && (par->footnotekind == LyXParagraph::FIG
                            || par->footnotekind == LyXParagraph::WIDE_FIG))
@@ -1693,9 +1699,9 @@ void LyXText::SetCounter(LyXParagraph *par)
 
 /* Updates all counters BEHIND the row. Changed paragraphs
 * with a dynamic left margin will be rebroken. */ 
-void LyXText::UpdateCounters(Row *row)
+void LyXText::UpdateCounters(Row * row)
 {
-       LyXParagraph *par;
+       LyXParagraph * par;
        if (!row) {
                row = firstrow;
                par = row->par;
@@ -1717,8 +1723,8 @@ void LyXText::UpdateCounters(Row *row)
                /* now  check for the headline layouts. remember that they
                 * have a dynamic left margin */ 
                if (!par->IsDummy()
-                   && ( lyxstyle.Style(parameters->textclass, par->layout)->margintype == MARGIN_DYNAMIC
-                        || lyxstyle.Style(parameters->textclass, par->layout)->labeltype == LABEL_SENSITIVE)
+                   && ( textclasslist.Style(parameters->textclass, par->layout).margintype == MARGIN_DYNAMIC
+                        || textclasslist.Style(parameters->textclass, par->layout).labeltype == LABEL_SENSITIVE)
                        ){
         
                        /* Rebreak the paragraph */ 
@@ -1760,7 +1766,7 @@ void LyXText::InsertInset(Inset *inset)
 
 
 /* this is for the simple cut and paste mechanism */ 
-static LyXParagraph *simple_cut_buffer = 0;
+static LyXParagraph * simple_cut_buffer = 0;
 static char simple_cut_buffer_textclass = 0;
 
 void DeleteSimpleCutBuffer()
@@ -1799,8 +1805,7 @@ void LyXText::CutSelection(bool doclear)
    
        /* OK, we have a selection. This is always between sel_start_cursor
         * and sel_end cursor */
-       LyXParagraph *tmppar;
-       int i;
+       LyXParagraph * tmppar;
    
        /* Check whether there are half footnotes in the selection */
        if (sel_start_cursor.par->footnoteflag != LyXParagraph::NO_FOOTNOTE
@@ -1826,8 +1831,8 @@ void LyXText::CutSelection(bool doclear)
        /* table stuff -- end*/
 
        // make sure that the depth behind the selection are restored, too
-       LyXParagraph *endpar = sel_end_cursor.par->LastPhysicalPar()->Next();
-       LyXParagraph *undoendpar = endpar;
+       LyXParagraph * endpar = sel_end_cursor.par->LastPhysicalPar()->Next();
+       LyXParagraph * undoendpar = endpar;
 
        if (endpar && endpar->GetDepth()) {
                while (endpar && endpar->GetDepth()) {
@@ -1871,13 +1876,13 @@ cut and pasted in a functional manner.
 This is not implemented yet.
 */
 
-       char space_wrapped =
+       bool space_wrapped =
                sel_end_cursor.par->IsLineSeparator(sel_end_cursor.pos);
        if (sel_end_cursor.pos > 0
            && sel_end_cursor.par->IsLineSeparator(sel_end_cursor.pos - 1)) {
                sel_end_cursor.pos--;  /* please break before a space at
                                        * the end */
-               space_wrapped = True;
+               space_wrapped = true;
        }
 
        // cut behind a space if there is one
@@ -1894,7 +1899,13 @@ This is not implemented yet.
            == sel_end_cursor.par->ParFromPos(sel_end_cursor.pos)) {
                /* only within one paragraph */
                simple_cut_buffer = new LyXParagraph();
-               for (i=sel_start_cursor.pos; i< sel_end_cursor.pos; i++){
+#ifdef NEW_TEXT
+               LyXParagraph::size_type i =
+                       sel_start_cursor.pos;
+#else
+               int i = sel_start_cursor.pos;
+#endif
+               for (; i< sel_end_cursor.pos; i++){
                        /* table stuff -- begin*/
                        if (sel_start_cursor.par->table
                            && sel_start_cursor.par->IsNewline(sel_start_cursor.pos)){
@@ -2007,8 +2018,11 @@ This is not implemented yet.
     
 void LyXText::CopySelection()
 {
-       int i=0;
-   
+#ifdef NEW_TEXT
+       LyXParagraph::size_type i = 0;
+#else
+       int i = 0;
+#endif
        /* this doesnt make sense, if there is no selection */ 
        if (!selection) {
                return;
@@ -2016,7 +2030,7 @@ void LyXText::CopySelection()
 
        /* ok we have a selection. This is always between sel_start_cursor
         * and sel_end cursor */
-       LyXParagraph *tmppar;
+       LyXParagraph * tmppar;
    
        /* check wether there are half footnotes in the selection */
        if (sel_start_cursor.par->footnoteflag != LyXParagraph::NO_FOOTNOTE
@@ -2057,8 +2071,8 @@ void LyXText::CopySelection()
        if (sel_start_cursor.par->ParFromPos(sel_start_cursor.pos) 
            == sel_end_cursor.par->ParFromPos(sel_end_cursor.pos)) {
                /* only within one paragraph */
-               simple_cut_buffer = new LyXParagraph();
-               for (i=sel_start_cursor.pos; i< sel_end_cursor.pos; i++){
+               simple_cut_buffer = new LyXParagraph;
+               for (i = sel_start_cursor.pos; i < sel_end_cursor.pos; ++i){
                        sel_start_cursor.par->CopyIntoMinibuffer(i);
                        simple_cut_buffer->InsertFromMinibuffer(i - sel_start_cursor.pos);
                }
@@ -2089,19 +2103,28 @@ void LyXText::CopySelection()
                }
      
                /* the simple_cut_buffer paragraph is too big */
-               int tmpi2;
-
-               tmpi2 = sel_start_cursor.par->PositionInParFromPos(sel_start_cursor.pos);
+#ifdef NEW_TEXT
+               LyXParagraph::size_type tmpi2 =
+                       sel_start_cursor.par->PositionInParFromPos(sel_start_cursor.pos);
+#else
+               int tmpi2 =
+                       sel_start_cursor.par->PositionInParFromPos(sel_start_cursor.pos);
+#endif
                for (;tmpi2;tmpi2--)
                        simple_cut_buffer->Erase(0);
 
                /* now tmppar 2 is too big, delete all after sel_end_cursor.pos */
      
                tmpi2 = sel_end_cursor.par->PositionInParFromPos(sel_end_cursor.pos);
+#ifdef NEW_TEXT
+               while (tmppar2->size() > tmpi2) {
+                       tmppar2->Erase(tmppar2->text.size() - 1);
+               }
+#else
                while (tmppar2->last > tmpi2) {
                        tmppar2->Erase(tmppar2->last-1);
                }
-
+#endif
        }
 }
           
@@ -2112,8 +2135,8 @@ void LyXText::PasteSelection()
        if (!simple_cut_buffer)
                return;
 
-       LyXParagraph *tmppar;
-       LyXParagraph *endpar;
+       LyXParagraph * tmppar;
+       LyXParagraph * endpar;
 
        LyXCursor tmpcursor;
 
@@ -2162,7 +2185,12 @@ void LyXText::PasteSelection()
                /* table stuff -- begin*/
                bool table_too_small = false;
                if (tmpcursor.par->table) {
+#ifdef NEW_TEXT
+                       while (simple_cut_buffer->text.size()
+                              && !table_too_small) {
+#else
                        while (simple_cut_buffer->last && !table_too_small){
+#endif
                                if (simple_cut_buffer->IsNewline(0)){
                                        while(tmpcursor.pos < tmpcursor.par->Last() && !tmpcursor.par->IsNewline(tmpcursor.pos))
                                                tmpcursor.pos++;
@@ -2180,7 +2208,11 @@ void LyXText::PasteSelection()
                        }
                } else {
                        /* table stuff -- end*/
+#ifdef NEW_TEXT
+                       while (simple_cut_buffer->text.size()){
+#else
                        while (simple_cut_buffer->last){
+#endif
                                simple_cut_buffer->CutIntoMinibuffer(0);
                                simple_cut_buffer->Erase(0);
                                tmpcursor.par->InsertFromMinibuffer(tmpcursor.pos);
@@ -2196,8 +2228,8 @@ void LyXText::PasteSelection()
 
                /* make a copy of the simple cut_buffer */
                tmppar = simple_cut_buffer;
-               LyXParagraph *simple_cut_clone = tmppar->Clone();
-               LyXParagraph *tmppar2 = simple_cut_clone;
+               LyXParagraph * simple_cut_clone = tmppar->Clone();
+               LyXParagraph * tmppar2 = simple_cut_clone;
                if (cursor.par->footnoteflag){
                        tmppar->footnoteflag = cursor.par->footnoteflag;
                        tmppar->footnotekind = cursor.par->footnotekind;
@@ -2250,7 +2282,11 @@ void LyXText::PasteSelection()
                if ((!cursor.par->Last()
                     || cursor.par->IsLineSeparator(cursor.pos - 1)
                     || cursor.par->IsNewline(cursor.pos - 1))
+#ifdef NEW_TEXT
+                   && simple_cut_buffer->text.size()
+#else
                    && simple_cut_buffer->last
+#endif
                    && simple_cut_buffer->IsLineSeparator(0))
                        simple_cut_buffer->Erase(0);
      
@@ -2336,24 +2372,28 @@ void LyXText::PasteSelection()
    
 
 /* returns a pointer to the very first LyXParagraph */ 
-LyXParagraph* LyXText::FirstParagraph()
+LyXParagraph * LyXText::FirstParagraph()
 {
        return params->paragraph;
 }
 
 
 /* returns true if the specified string is at the specified position */
-bool LyXText::IsStringInText(LyXParagraph *par, int pos, char const* string)
+#ifdef NEW_TEXT
+bool LyXText::IsStringInText(LyXParagraph * par,
+                            LyXParagraph::size_type pos,
+                            char const * str)
+#else 
+bool LyXText::IsStringInText(LyXParagraph * par, int pos, char const * str)
+#endif
 {
        if (par) {
                int i = 0;
-               while (pos+i < par->Last() && string[i] && 
-                      string[i]==par->GetChar(pos+i))
-               {
+               while (pos + i < par->Last() && str[i] && 
+                      str[i]==par->GetChar(pos+i)) {
                        i++;
                }
-
-               if (!string[i])
+               if (!str[i])
                        return true;
        }
        return false;
@@ -2361,18 +2401,17 @@ bool LyXText::IsStringInText(LyXParagraph *par, int pos, char const* string)
 
 
 /* sets the selection over the number of characters of string, no check!! */
-void LyXText::SetSelectionOverString(char const* string)
+void LyXText::SetSelectionOverString(char const * string)
 {
        sel_cursor = cursor;
-       int i;
-       for (i=0; string[i]; i++)
+       for (int i = 0; string[i]; ++i)
                CursorRight();
        SetSelection();
 }
 
 
 /* simple replacing. The font of the first selected character is used */
-void LyXText::ReplaceSelectionWithString(char const* string)
+void LyXText::ReplaceSelectionWithString(char const * str)
 {
        SetCursorParUndo();
        FreezeUndo();
@@ -2383,14 +2422,18 @@ void LyXText::ReplaceSelectionWithString(char const* string)
        }
 
        // Get font setting before we cut
+#ifdef NEW_TEXT
+       LyXParagraph::size_type pos = sel_end_cursor.pos;
+#else
        int pos = sel_end_cursor.pos;
+#endif
        LyXFont font = sel_start_cursor.par->GetFontSettings(sel_start_cursor.pos);
 
        // Insert the new string
-       for (int i=0; string[i];i++) {
-               sel_end_cursor.par->InsertChar(pos, string[i]);
+       for (int i = 0; str[i]; ++i) {
+               sel_end_cursor.par->InsertChar(pos, str[i]);
                sel_end_cursor.par->SetFont(pos, font);
-               pos++;
+               ++pos;
        }
 
        // Cut the selection
@@ -2402,14 +2445,17 @@ void LyXText::ReplaceSelectionWithString(char const* string)
 
 /* if the string can be found: return true and set the cursor to
  * the new position */
-bool LyXText::SearchForward(char const* string)
+bool LyXText::SearchForward(char const * str)
 {
-       LyXParagraph *par = cursor.par;
+       LyXParagraph * par = cursor.par;
+#ifdef NEW_TEXT
+       LyXParagraph::size_type pos = cursor.pos;
+#else
        int pos = cursor.pos;
-
-       while (par && !IsStringInText(par,pos,string)) {
-               if (pos<par->Last()-1)
-                       pos++;
+#endif
+       while (par && !IsStringInText(par, pos, str)) {
+               if (pos < par->Last() - 1)
+                       ++pos;
                else {
                        pos = 0;
                        par = par->Next();
@@ -2424,9 +2470,9 @@ bool LyXText::SearchForward(char const* string)
 }
 
 
-bool LyXText::SearchBackward(char const* string)
+bool LyXText::SearchBackward(char const * string)
 {
-       LyXParagraph *par = cursor.par;
+       LyXParagraph * par = cursor.par;
        int pos = cursor.pos;
 
        do {
@@ -2451,77 +2497,123 @@ bool LyXText::SearchBackward(char const* string)
 }
 
 
+#ifdef NEW_TEXT
+void LyXText::InsertStringA(LyXParagraph::TextContainer const & text)
+{
+       char * str = new char[text.size() + 1];
+       // shoudl use std::copy or something
+       for (LyXParagraph::size_type i = 0; i < static_cast<int>(text.size());
+            ++i) {
+               str[i] = text[i];
+       }
+       str[text.size()] = '\0';
+       InsertStringA(str);
+       delete [] str;
+}
+#endif
+
 /* needed to insert the selection */
-void LyXText::InsertStringA(char* string)
+void LyXText::InsertStringA(char const * str)
 {
-       LyXParagraph *par = cursor.par;
+       LyXParagraph * par = cursor.par;
+#ifdef NEW_TEXT
+       LyXParagraph::size_type pos = cursor.pos;
+       LyXParagraph::size_type a = 0;
+#else
        int pos = cursor.pos;
        int a = 0;
+#endif
         int cell = 0;
-       LyXParagraph *endpar = cursor.par->Next();
+       LyXParagraph * endpar = cursor.par->Next();
 
        SetCursorParUndo();
 
-       char flag = lyxstyle.Style(parameters->textclass, 
-                                  cursor.par->GetLayout())->isEnvironment();
+       char flag = textclasslist.Style(parameters->textclass, 
+                                  cursor.par->GetLayout()).isEnvironment();
        /* only to be sure, should not be neccessary */ 
        ClearSelection();
    
        /* insert the string, don't insert doublespace */ 
-       int i=0;
+       int i = 0;
+#ifndef NEW_TEXT
        int i2 = 0;
-
-       for (i2=i;string[i2]&&string[i2]!='\n';i2++);
+       for (i2 = i; str[i2] && str[i2] != '\n'; ++i2);
        par->Enlarge(pos, i2 - i);
-       while (string[i]) {
-               if (string[i]!='\n') {
-                       if (string[i]==' ' && (string[i+1]!=' ')
+#endif
+       while (str[i]) {
+               if (str[i]!='\n') {
+                       if (str[i]==' ' && (str[i+1]!=' ')
                            && pos && par->GetChar(pos-1)!=' ') {
                                par->InsertChar(pos,' ');
                                pos++;
                        }
                         else if (par->table) {
-                            if (string[i] == '\t') {
+                            if (str[i] == '\t') {
+#ifdef NEW_TEXT
+                                while((pos < par->size()) &&
+                                      (par->GetChar(pos) != LYX_META_NEWLINE))
+                                        ++pos;
+                                if (pos < par->size())
+                                        ++pos;
+#else
                                 while((pos < par->last) &&
                                       (par->GetChar(pos) != LYX_META_NEWLINE))
-                                        pos++;
+                                        ++pos;
                                 if (pos < par->last)
-                                        pos++;
+                                        ++pos;
+#endif
                                 else // no more fields to fill skip the rest
                                         break;
-                            } else if ((string[i] != 13) &&
-                                (((unsigned char) string[i] & 127) >= ' ')) {
-                                par->InsertChar(pos,string[i]);
+                            } else if ((str[i] != 13) &&
+                                ((str[i] & 127) >= ' ')) {
+                                par->InsertChar(pos,str[i]);
                                 pos++;
                             }
                         }
-                       else if (string[i]==' ') {
+                       else if (str[i]==' ') {
                                par->InsertChar(pos,LYX_META_PROTECTED_SEPARATOR);
                                pos++;
                        }
-                       else if (string[i]=='\t') {
-                               for (a=pos; a<(pos/8+1)*8 ; a++) {
-                                       par->InsertChar(a,LYX_META_PROTECTED_SEPARATOR);
+                       else if (str[i]=='\t') {
+                               for (a = pos; a < (pos/8 + 1) * 8 ; ++a) {
+                                       par->InsertChar(a, LYX_META_PROTECTED_SEPARATOR);
                                }
                                pos = a;
                        }
-                       else if (string[i]!=13 && 
+                       else if (str[i]!=13 && 
                                 // Ignore unprintables
-                                ((unsigned char) string[i] & 127) >= ' ') {
-                               par->InsertChar(pos,string[i]);
+                                (str[i] & 127) >= ' ') {
+                               par->InsertChar(pos,str[i]);
                                pos++;
                        }
                } else {
                         if (par->table) {
-                                if (!string[i+1]) {
+                                if (!str[i+1]) {
                                         pos++;
                                         break;
                                 }
+#ifdef NEW_TEXT
+                                while((pos < par->size()) &&
+#else
                                 while((pos < par->last) &&
+#endif
                                       (par->GetChar(pos) != LYX_META_NEWLINE))
                                         pos++;
                                 pos++;
                                 cell=NumberOfCell(par,pos);
+#ifdef NEW_TEXT
+                                while((pos < par->size()) &&
+                                      !(par->table->IsFirstCell(cell))) {
+                                        while((pos < par->size()) &&
+                                              (par->GetChar(pos) != LYX_META_NEWLINE))
+                                                ++pos;
+                                        ++pos;
+                                        cell=NumberOfCell(par,pos);
+                                }
+                                if (pos >= par->size())
+                                        // no more fields to fill skip the rest
+                                        break;
+#else
                                 while((pos < par->last) &&
                                       !(par->table->IsFirstCell(cell))) {
                                         while((pos < par->last) &&
@@ -2533,8 +2625,13 @@ void LyXText::InsertStringA(char* string)
                                 if (pos >= par->last)
                                         // no more fields to fill skip the rest
                                         break;
+#endif
                         } else {
+#ifdef NEW_TEXT
+                                if (!par->text.size()) {
+#else
                                 if (!par->last) {
+#endif
                                         par->InsertChar(pos,LYX_META_PROTECTED_SEPARATOR);
                                         pos++;
                                 }
@@ -2542,8 +2639,10 @@ void LyXText::InsertStringA(char* string)
                                 par = par->Next();
                                 pos = 0;
                         }
-                       for (i2=i;string[i2]&&string[i2]!='\n';i2++);
+#ifndef NEW_TEXT
+                       for (i2 = i; str[i2] && str[i2] != '\n'; i2++);
                        par->Enlarge(pos, i2 - i);
+#endif
                }
       
                i++;
@@ -2556,37 +2655,54 @@ void LyXText::InsertStringA(char* string)
        SetSelection();
 }
 
+
+#ifdef NEW_TEXT
+void LyXText::InsertStringB(LyXParagraph::TextContainer const & text)
+{
+       char * str = new char[text.size() + 1];
+       // should use std::copy or something
+       for(LyXParagraph::size_type i = 0; i < static_cast<int>(text.size());
+           ++i) {
+               str[i] = text[i];
+       }
+       str[text.size()] = '\0';
+       InsertStringB(str);
+       delete [] str;
+}
+#endif
 /* turns double-CR to single CR, others where converted into one blank and 13s 
  * that are ignored .Double spaces are also converted into one. Spaces at
  * the beginning of a paragraph are forbidden. tabs are converted into one
  * space. then InsertStringA is called */ 
-void LyXText::InsertStringB(char* string)
-{
-       LyXParagraph *par = cursor.par;
-       int i=1;
-       while (string[i]) {
-               if (string[i]=='\t' && !par->table)
-                       string[i] = ' ';
-               if (string[i]==' ' && string[i+1]==' ')
-                       string[i] = 13;
-               if (string[i]=='\n' && string[i+1] && !par->table){
-                       if (string[i+1]!='\n') {
-                               if (string[i-1]!=' ')
-                                       string[i]=' ';
+void LyXText::InsertStringB(char const * s)
+{
+       string str(s);
+       LyXParagraph * par = cursor.par;
+       int i = 1;
+       while (str[i]) {
+               if (str[i] == '\t' && !par->table)
+                       str[i] = ' ';
+               if (str[i] == ' ' && str[i + 1] == ' ')
+                       str[i] = 13;
+               if (str[i] == '\n' && str[i + 1] && !par->table){
+                       if (str[i + 1] != '\n') {
+                               if (str[i - 1] != ' ')
+                                       str[i] = ' ';
                                else
-                                       string[i]= 13;
+                                       str[i] = 13;
                        }
-                       while (string[i+1] && (string[i+1]==' '
-                                              || string[i+1]=='\t'
-                                              || string[i+1]=='\n'
-                                              || string[i+1]==13)) {
-                               string[i+1]=13;
-                               i++;
+                       while (str[i + 1] && (str[i + 1] == ' '
+                                              || str[i + 1] == '\t'
+                                              || str[i + 1] == '\n'
+                                              || str[i + 1] == 13)) {
+                               str[i + 1] = 13;
+                               ++i;
                        }
                }
-               i++;
+               ++i;
        }
-       InsertStringA(string);
+       InsertStringA(str.c_str());
 }
 
 
@@ -2594,7 +2710,7 @@ bool LyXText::GotoNextError()
 {
        LyXCursor res=cursor;
        do {
-               if (res.pos < res.par->Last()-1) {
+               if (res.pos < res.par->Last() - 1) {
                        res.pos++;
                }
                else  {
@@ -2641,7 +2757,7 @@ bool LyXText::GotoNextNote()
 
 
 int LyXText::SwitchLayoutsBetweenClasses(char class1, char class2,
-                                        LyXParagraph *par)
+                                        LyXParagraph * par)
 {
        InsetError * new_inset = 0;
        int ret = 0;
@@ -2649,20 +2765,25 @@ int LyXText::SwitchLayoutsBetweenClasses(char class1, char class2,
                return ret;
        par = par->FirstPhysicalPar();
        while (par) {
-               string name = lyxstyle.NameOfLayout(class1, par->layout);
-               int lay = lyxstyle.NumberOfLayout(class2, name);
-               if (lay == -1) // layout not found
-                       // use default layout "Stadard" (0)
+               string name = textclasslist.NameOfLayout(class1, par->layout);
+               int lay = 0;
+               pair<bool, LyXTextClass::LayoutList::size_type> pp =
+                       textclasslist.NumberOfLayout(class2, name);
+               if (pp.first) {
+                       lay = pp.second;
+               } else { // layout not found
+                       // use default layout "Standard" (0)
                        lay = 0;
+               }
                par->layout = lay;
       
-               if (name != lyxstyle.NameOfLayout(class2, par->layout)) {
+               if (name != textclasslist.NameOfLayout(class2, par->layout)) {
                        ret++;
-                       string s= "Layout had to be changed from\n"
-                               + name + " to " + lyxstyle.NameOfLayout(class2, par->layout)
+                       string s = "Layout had to be changed from\n"
+                               + name + " to " + textclasslist.NameOfLayout(class2, par->layout)
                                + "\nbecause of class conversion from\n"
-                               + lyxstyle.NameOfClass(class1) + " to "
-                               + lyxstyle.NameOfClass(class2);
+                               + textclasslist.NameOfClass(class1) + " to "
+                               + textclasslist.NameOfClass(class2);
                        new_inset = new InsetError(s);
                        par->InsertChar(0, LYX_META_INSET);
                        par->InsertInset(0, new_inset);
@@ -2674,7 +2795,12 @@ int LyXText::SwitchLayoutsBetweenClasses(char class1, char class2,
 }
 
 
-void LyXText::CheckParagraph(LyXParagraph* par, int pos)
+#ifdef NEW_TEXT
+void LyXText::CheckParagraph(LyXParagraph * par,
+                            LyXParagraph::size_type pos)
+#else
+void LyXText::CheckParagraph(LyXParagraph * par, int pos)
+#endif
 {
   
        LyXCursor tmpcursor;
@@ -2688,9 +2814,12 @@ void LyXText::CheckParagraph(LyXParagraph* par, int pos)
                /* table stuff -- end*/
      
                long y = 0;
+#ifdef NEW_TEXT
+               LyXParagraph::size_type z;
+#else
                int z;
-     
-               Row* row = GetRow(par, pos, y);
+#endif
+               Row * row = GetRow(par, pos, y);
      
                /* is there a break one row above */ 
                if (row->previous && row->previous->par == row->par) {
@@ -2712,7 +2841,11 @@ void LyXText::CheckParagraph(LyXParagraph* par, int pos)
                }
 
                int tmpheight = row->height;
+#ifdef NEW_TEXT
+               LyXParagraph::size_type tmplast = RowLast(row);
+#else
                int tmplast = RowLast(row);
+#endif
                refresh_y = y;
                refresh_row = row;
 
@@ -2723,7 +2856,7 @@ void LyXText::CheckParagraph(LyXParagraph* par, int pos)
                        status = LyXText::NEED_MORE_REFRESH; 
    
                /* check the special right address boxes */
-               if (lyxstyle.Style(parameters->textclass, par->GetLayout())->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
+               if (textclasslist.Style(parameters->textclass, par->GetLayout()).margintype == MARGIN_RIGHT_ADDRESS_BOX) {
                        tmpcursor.par = par;
                        tmpcursor.row = row;
                        tmpcursor.y = y;
@@ -2755,13 +2888,10 @@ void LyXText::CheckParagraph(LyXParagraph* par, int pos)
 
 
 /* returns 0 if inset wasn't found */
-int LyXText::UpdateInset(Inset* inset)
+int LyXText::UpdateInset(Inset * inset)
 {
-       int pos;
-       LyXParagraph *par;
-
        /* first check the current paragraph */
-       pos = cursor.par->GetPositionOfInset(inset);
+       int pos = cursor.par->GetPositionOfInset(inset);
        if (pos != -1){
                CheckParagraph(cursor.par, pos);
                return 1;
@@ -2769,7 +2899,7 @@ int LyXText::UpdateInset(Inset* inset)
   
        /* check every paragraph */
   
-       par = FirstParagraph();
+       LyXParagraph * par = FirstParagraph();
        do {
                /* make sure the paragraph is open */
                if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){
@@ -2786,7 +2916,12 @@ int LyXText::UpdateInset(Inset* inset)
 }
 
 
-void LyXText::SetCursor(LyXParagraph *par, int pos)
+#ifdef NEW_TEXT
+void LyXText::SetCursor(LyXParagraph * par,
+                       LyXParagraph::size_type pos)
+#else
+void LyXText::SetCursor(LyXParagraph * par, int pos)
+#endif
 {
        LyXCursor old_cursor = cursor;
        SetCursorIntern(par, pos);
@@ -2794,12 +2929,16 @@ void LyXText::SetCursor(LyXParagraph *par, int pos)
 }
 
 
-void LyXText::SetCursorIntern(LyXParagraph *par, int pos)
+#ifdef NEW_TEXT
+void LyXText::SetCursorIntern(LyXParagraph * par, LyXParagraph::size_type pos)
+#else
+void LyXText::SetCursorIntern(LyXParagraph * par, int pos)
+#endif
 {
        long y;
-       Row *row;
+       Row * row;
        int left_margin;
-       LyXParagraph *tmppar;
+       LyXParagraph * tmppar;
    
        /* correct the cursor position if impossible */
        if (pos > par->Last()){
@@ -2815,12 +2954,20 @@ void LyXText::SetCursorIntern(LyXParagraph *par, int pos)
                        par = par->previous ;
                        if (par->IsDummy() &&
                            par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
+#ifdef NEW_TEXT
+                               pos += par->text.size() + 1;
+#else
                                pos += par->last + 1;
+#endif
                }
                if (par->previous) {
                        par = par->previous;
                }
+#ifdef NEW_TEXT
+               pos += par->text.size() + 1;
+#else
                pos += par->last + 1;
+#endif
        }
 
        cursor.par = par;
@@ -2839,8 +2986,12 @@ void LyXText::SetCursorIntern(LyXParagraph *par, int pos)
        float fill_separator, fill_hfill, fill_label_hfill;
        left_margin = LabelEnd(row);
        PrepareToPrint(row, x, fill_separator, fill_hfill, fill_label_hfill);
+#ifdef NEW_TEXT
+       LyXParagraph::size_type main_body =
+               BeginningOfMainBody(row->par);
+#else
        int main_body = BeginningOfMainBody(row->par);
-      
+#endif 
        /* table stuff -- begin*/
        if (row->par->table) {
                int cell = NumberOfCell(row->par, row->pos);
@@ -2863,7 +3014,7 @@ void LyXText::SetCursorIntern(LyXParagraph *par, int pos)
                        if (pos && pos == main_body
                            && !row->par->IsLineSeparator(pos - 1)) {
                                x += GetFont(row->par, -2).stringWidth(
-                                                   lyxstyle.Style(parameters->textclass, row->par->GetLayout())->labelsep);
+                                                   textclasslist.Style(parameters->textclass, row->par->GetLayout()).labelsep);
                                if (x < left_margin)
                                        x = left_margin;
                        }
@@ -2882,7 +3033,7 @@ void LyXText::SetCursorIntern(LyXParagraph *par, int pos)
                        if (pos + 1 == main_body
                            && row->par->IsLineSeparator(pos)) {
                                x += GetFont(row->par, -2).stringWidth(
-                                                   lyxstyle.Style(parameters->textclass, row->par->GetLayout())->labelsep);
+                                                   textclasslist.Style(parameters->textclass, row->par->GetLayout()).labelsep);
                                if (row->par->IsLineSeparator(pos))
                                        x-= SingleWidth(row->par, pos);
                                if (x < left_margin)
@@ -2911,20 +3062,15 @@ void LyXText::SetCursorIntern(LyXParagraph *par, int pos)
 
 void LyXText::SetCursorFromCoordinates(int x, long y)
 {
-       Row *row;
-       int column;
-
-       LyXCursor old_cursor;
-   
-       old_cursor = cursor;
+       LyXCursor old_cursor = cursor;
    
        /* get the row first */ 
    
-       row = GetRowNearY(y);
+       Row * row = GetRowNearY(y);
    
        cursor.par = row->par;
    
-       column = GetColumnNearX(row, x);
+       int column = GetColumnNearX(row, x);
        cursor.pos = row->pos + column;
        cursor.x = x;
        cursor.y = y + row->baseline;
@@ -3067,8 +3213,8 @@ void LyXText::DeleteEmptyParagraphMechanism(LyXCursor old_cursor)
         return;
 
     // Paragraph should not be deleted if empty
-    if ((lyxstyle.Style(parameters->textclass,
-                        old_cursor.par->GetLayout()))->keepempty)
+    if ((textclasslist.Style(parameters->textclass,
+                        old_cursor.par->GetLayout())).keepempty)
         return;
 
     LyXCursor tmpcursor;
@@ -3078,18 +3224,7 @@ void LyXText::DeleteEmptyParagraphMechanism(LyXCursor old_cursor)
               || (old_cursor.par->Last() == 1
                   && (old_cursor.par->IsLineSeparator(0))))
              && old_cursor.par->FirstPhysicalPar()
-             == old_cursor.par->LastPhysicalPar()
-             //&& (
-             // impossible to insert your own \caption with
-             // this set. made it impossible to use the
-             // optional argument...
-             // also empty pars in fig or tab never was removed(?)(Lgb)
-             //lyxstyle.Style(parameters->textclass,
-//                                     old_cursor.par->GetLayout())->labeltype!=LABEL_SENSITIVE || 
-             //     (old_cursor.par->footnoteflag == LyXParagraph::NO_FOOTNOTE
-             //|| (old_cursor.par->footnotekind != LyXParagraph::FIG
-             //          && old_cursor.par->footnotekind != LyXParagraph::TAB)))
-             ) {
+             == old_cursor.par->LastPhysicalPar()) {
                        
             /* ok, we will delete anything */ 
                        
@@ -3213,9 +3348,9 @@ void LyXText::DeleteEmptyParagraphMechanism(LyXCursor old_cursor)
 }
 
 
-LyXParagraph* LyXText::GetParFromID(int id)
+LyXParagraph * LyXText::GetParFromID(int id)
 {
-       LyXParagraph* result = FirstParagraph();
+       LyXParagraph * result = FirstParagraph();
        while (result && result->GetID() != id)
                result = result->next;
        return result;
@@ -3225,7 +3360,7 @@ LyXParagraph* LyXText::GetParFromID(int id)
 // undo functions
 bool  LyXText::TextUndo()
 { // returns false if no undo possible
-       Undo *undo = params->undostack.Pop();
+       Undo * undo = params->undostack.Pop();
        if (undo){
                FinishUndo();
                if (!undo_frozen)
@@ -3239,7 +3374,7 @@ bool  LyXText::TextUndo()
 
 bool LyXText::TextRedo()
 { // returns false if no redo possible
-       Undo *undo = params->redostack.Pop();
+       Undo * undo = params->redostack.Pop();
        if (undo){
                FinishUndo();
                if (!undo_frozen)
@@ -3251,29 +3386,18 @@ bool LyXText::TextRedo()
 }
 
 
-bool LyXText::TextHandleUndo(Undo* undo){ // returns false if no undo possible
+bool LyXText::TextHandleUndo(Undo * undo){ // returns false if no undo possible
        bool result = false;
        if (undo){
-               LyXParagraph* before = GetParFromID(undo->number_of_before_par); 
-               LyXParagraph* behind = GetParFromID(undo->number_of_behind_par); 
-               LyXParagraph* tmppar;
-               LyXParagraph* tmppar2;
-               LyXParagraph* tmppar3;
-               LyXParagraph* tmppar4;
-               LyXParagraph* endpar;
-               LyXParagraph* tmppar5;
+               LyXParagraph * before = GetParFromID(undo->number_of_before_par); 
+               LyXParagraph * behind = GetParFromID(undo->number_of_behind_par); 
+               LyXParagraph * tmppar;
+               LyXParagraph * tmppar2;
+               LyXParagraph * tmppar3;
+               LyXParagraph * tmppar4;
+               LyXParagraph * endpar;
+               LyXParagraph * tmppar5;
     
-               /*
-                 if (before){
-                 before->text[before->last] = 0;
-                 printf("before: %s\n", before->text);
-                 }
-                 if (behind){
-                 behind->text[behind->last] = 0;
-                 printf("behind: %s\n", behind->text);
-                 }
-                 */ 
-
                // if there's no before take the beginning of the document for redoing
                if (!before)
                        SetCursorIntern(FirstParagraph(), 0);
@@ -3302,7 +3426,11 @@ bool LyXText::TextHandleUndo(Undo* undo){ // returns false if no undo possible
                                // is stored in the undo. So restore the text informations.
                                if (undo->kind == Undo::EDIT){
                                        tmppar2->text = tmppar->text;
+#ifdef NEW_TEXT
+                                       tmppar->text.clear();
+#else
                                        tmppar->text = 0;
+#endif
                                        tmppar2 = tmppar2->next;
                                }
                                if ( currentrow && currentrow->par == tmppar )
@@ -3399,7 +3527,8 @@ void LyXText::UnFreezeUndo()
 }
 
 
-void LyXText::SetUndo(Undo::undo_kind kind, LyXParagraph *before, LyXParagraph *behind)
+void LyXText::SetUndo(Undo::undo_kind kind, LyXParagraph * before,
+                     LyXParagraph * behind)
 {
        if (!undo_frozen)
                params->undostack.Push(CreateUndo(kind, before, behind));
@@ -3407,14 +3536,15 @@ void LyXText::SetUndo(Undo::undo_kind kind, LyXParagraph *before, LyXParagraph *
 }
 
 
-void LyXText::SetRedo(Undo::undo_kind kind, LyXParagraph *before, LyXParagraph *behind)
+void LyXText::SetRedo(Undo::undo_kind kind, LyXParagraph * before,
+                     LyXParagraph * behind)
 {
        params->redostack.Push(CreateUndo(kind, before, behind));
 }
 
 
-Undo* LyXText::CreateUndo(Undo::undo_kind kind, LyXParagraph *before,
-                         LyXParagraph *behind)
+Undo * LyXText::CreateUndo(Undo::undo_kind kind, LyXParagraph * before,
+                         LyXParagraph * behind)
 {
        int before_number = -1;
        int behind_number = -1;
@@ -3441,12 +3571,12 @@ Undo* LyXText::CreateUndo(Undo::undo_kind kind, LyXParagraph *before,
                }
        }
        // create a new Undo
-       LyXParagraph* undopar;
-       LyXParagraph* tmppar;
-       LyXParagraph *tmppar2;
+       LyXParagraph * undopar;
+       LyXParagraph * tmppar;
+       LyXParagraph * tmppar2;
 
-       LyXParagraph* start = 0;
-       LyXParagraph* end = 0;
+       LyXParagraph * start = 0;
+       LyXParagraph * end = 0;
   
        if (before)
                start = before->next;
@@ -3467,9 +3597,13 @@ Undo* LyXText::CreateUndo(Undo::undo_kind kind, LyXParagraph *before,
 
                // a memory optimization: Just store the layout information when only edit
                if (kind == Undo::EDIT){
+#ifdef NEW_TEXT
+                       tmppar2->text.clear();
+#else
                        if (tmppar2->text)
                                delete[] tmppar2->text;
                        tmppar2->text = 0;
+#endif
                }
 
                undopar = tmppar2;
@@ -3480,9 +3614,13 @@ Undo* LyXText::CreateUndo(Undo::undo_kind kind, LyXParagraph *before,
                        tmppar2->next->SetID(tmppar->GetID());
                        // a memory optimization: Just store the layout information when only edit
                        if (kind == Undo::EDIT){
+#ifdef NEW_TEXT
+                               tmppar2->next->text.clear();
+#else
                                if (tmppar2->next->text)
                                        delete[] tmppar2->next->text;
                                tmppar2->next->text = 0;
+#endif
                        }
                        tmppar2->next->previous = tmppar2;
                        tmppar2=tmppar2->next;
@@ -3495,7 +3633,7 @@ Undo* LyXText::CreateUndo(Undo::undo_kind kind, LyXParagraph *before,
        int cursor_par = cursor.par->ParFromPos(cursor.pos)->GetID();
        int cursor_pos =  cursor.par->PositionInParFromPos(cursor.pos);
 
-       Undo* undo = new Undo(kind, 
+       Undo * undo = new Undo(kind, 
                              before_number, behind_number,  
                              cursor_par, cursor_pos, 
                              undopar);
@@ -3512,7 +3650,7 @@ void LyXText::SetCursorParUndo()
                cursor.par->ParFromPos(cursor.pos)->next); 
 }
 
-void LyXText::RemoveTableRow(LyXCursor *cursor)
+void LyXText::RemoveTableRow(LyXCursor * cursor)
 {
     int
         cell_act,
@@ -3563,7 +3701,8 @@ void LyXText::RemoveTableRow(LyXCursor *cursor)
     return;
 }
 
-bool LyXText::IsEmptyTableRow(LyXCursor *old_cursor)
+
+bool LyXText::IsEmptyTableRow(LyXCursor * old_cursor)
 {
        if (!old_cursor->par->table)
                return false;
@@ -3598,20 +3737,23 @@ bool LyXText::IsEmptyTableRow(LyXCursor *old_cursor)
 
 bool LyXText::IsEmptyTableCell()
 {
+#ifdef NEW_TEXT
+       LyXParagraph::size_type pos = cursor.pos - 1;
+#else
        int pos = cursor.pos - 1;
-       
-       while ((pos>=0) && (pos < cursor.par->Last()) &&
-              !cursor.par->IsNewline(pos))
-               pos--;
-       return cursor.par->IsNewline(pos+1);
+#endif
+       while (pos >= 0 && pos < cursor.par->Last()
+              && !cursor.par->IsNewline(pos))
+               --pos;
+       return cursor.par->IsNewline(pos + 1);
 }
 
 void LyXText::toggleAppendix(){
-  LyXParagraph* par = cursor.par->FirstPhysicalPar();
+  LyXParagraph * par = cursor.par->FirstPhysicalPar();
   bool start = !par->start_of_appendix;
 
   /* ensure that we have only one start_of_appendix in this document */
-  LyXParagraph* tmp = FirstParagraph();
+  LyXParagraph * tmp = FirstParagraph();
   for (;tmp;tmp=tmp->next)
     tmp->start_of_appendix = 0;
   par->start_of_appendix = start;
index b9c8834b4d7187fa831179887ad0a7c2b60f2a37..d189884938055bfce1f08e312411316a84362372 100644 (file)
@@ -183,7 +183,7 @@ void Trans::AddDeadkey(tex_accent accent,const string& keys,
        
        for(string::size_type i = 0; i < keys.length(); ++i) {
                char * temp;
-               temp = keymap_[(unsigned char)keys[i]] = new char[2];
+               temp = keymap_[keys[i]] = new char[2];
                temp[0] = 0; temp[1] = accent;
        }
        kmod_list_[accent]->exception_list=0;
@@ -294,7 +294,7 @@ int Trans::Load(LyXLex &lex)
                        if (lex.next(true)) {
                                char const *t = lex.text();
                                string_to = strcpy(new char[strlen(t)+1],t);
-                               keymap_[(unsigned char)key_from]=string_to;
+                               keymap_[key_from]=string_to;
                                if (lyxerr.debugging(Debug::KBMAP))
                                        lyxerr << "\t`" << string_to << "'"
                                               << endl;
index 6ff2ac3cecf0588e4c4fe14daf478337b3ffe759..839caa462cc256b8aa65f1eb236826bfc079f9b3 100644 (file)
@@ -97,7 +97,7 @@ private:
 
 char* Trans::Match(char c)
 {
-       return keymap_[(unsigned char)c];
+       return keymap_[c];
 }
 
 #endif 
index dfb2c3b3886df71361dcdd348f69549e92f3f7cb..2aa68aa8ca36dee5e52597e676bd95567ea5dd07 100644 (file)
@@ -57,7 +57,7 @@ static LyXLength::UNIT unit[4]   = { LyXLength::UNIT_NONE,
 //static int number_index, unit_index;
 int number_index, unit_index;
 
-static inline void advance (string & data, unsigned int n)
+static inline void lyx_advance (string & data, unsigned int n)
 {
        data.erase(0, n);
 }
@@ -73,19 +73,19 @@ static char nextToken (string & data)
        if (data.empty())
                return '\0';
        else if (data[0] == '+') {
-               advance (data, 1);
+               lyx_advance (data, 1);
                return '+';
        }
        else if (prefixIs(data, "plus")) {
-               advance (data, 4);
+               lyx_advance (data, 4);
                return '+';
        }
        else if (data[0] == '-') {
-               advance (data, 1);
+               lyx_advance (data, 1);
                return '-';
        }
         else if (prefixIs(data, "minus")) {
-               advance (data, 5);
+               lyx_advance (data, 5);
                return '-';
        }
        else {
@@ -97,7 +97,7 @@ static char nextToken (string & data)
                         string buffer = data.substr(0, i + 1);
                        if (sscanf (buffer.c_str(),
                                    "%f", &number[number_index]) == 1) {
-                               advance (data, i + 1);
+                               lyx_advance (data, i + 1);
                                ++number_index;
                                return 'n';
                        } else 
@@ -108,7 +108,7 @@ static char nextToken (string & data)
                        string buffer = data.substr(0, i + 1);
                        unit[unit_index] = unitFromString (buffer);
                        if (unit[unit_index] != LyXLength::UNIT_NONE) {
-                               advance (data, i + 1);
+                               lyx_advance (data, i + 1);
                                ++unit_index;
                                return 'u';
                        } else
@@ -165,11 +165,11 @@ bool isValidGlueLength (string const & data, LyXGlueLength * result)
        short val_sign = 1; // positive as default
        switch(buffer[0]) {
        case '-':
-               advance(buffer, 1);
+               lyx_advance(buffer, 1);
                val_sign = -1;
                break;
        case '+':
-               advance(buffer, 1);
+               lyx_advance(buffer, 1);
                // fall through
        default:
                // no action
@@ -229,11 +229,11 @@ bool isValidLength(string const & data, LyXLength * result)
        short val_sign = 1; // positive as default
        switch(buffer[0]) {
        case '-':
-               advance(buffer, 1);
+               lyx_advance(buffer, 1);
                val_sign = -1;
                break;
        case '+':
-               advance(buffer, 1);
+               lyx_advance(buffer, 1);
                // fall through
        default:
                // no action
index c33233d602822547c646c59c41f11503157247be..ee1922d5d0fbda1e69f9c0906b7bc619f8a9ad53 100644 (file)
@@ -17,6 +17,7 @@
 #endif
 
 #include <cstdio>
+#include "LString.h"
 
 ///  LyXLength Class
 class LyXLength {
@@ -210,5 +211,3 @@ private:
 };
 
 #endif
-
-