]> git.lyx.org Git - lyx.git/commitdiff
change to use ostreams instead of string when writing files. fiddling with insettext...
authorLars Gullik Bjønnes <larsbj@gullik.org>
Mon, 6 Mar 2000 02:42:40 +0000 (02:42 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Mon, 6 Mar 2000 02:42:40 +0000 (02:42 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@584 a592a061-630c-0410-9148-cb99ea01b6c8

57 files changed:
ChangeLog
development/Code_rules/Rules
lib/layouts/seminar.layout [new file with mode: 0644]
lib/lyxrc.example
src/LyXAction.C
src/WorkArea.C
src/buffer.C
src/buffer.h
src/insets/figinset.C
src/insets/figinset.h
src/insets/inset.C
src/insets/insetbib.C
src/insets/insetcommand.C
src/insets/insetcommand.h
src/insets/inseterror.C
src/insets/inseterror.h
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetinfo.C
src/insets/insetinfo.h
src/insets/insetlabel.C
src/insets/insetlabel.h
src/insets/insetlatexaccent.C
src/insets/insetlatexaccent.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/insettext.C
src/insets/insettext.h
src/insets/insettoc.C
src/insets/insettoc.h
src/insets/inseturl.C
src/insets/inseturl.h
src/insets/lyxinset.h
src/lyx_cb.C
src/lyx_gui.C
src/lyxfont.C
src/lyxfont.h
src/lyxparagraph.h
src/lyxrc.C
src/lyxrc.h
src/mathed/formula.C
src/mathed/formula.h
src/mathed/formulamacro.C
src/mathed/formulamacro.h
src/mathed/math_macro.C
src/paragraph.C
src/spellchecker.C
src/support/lstrings.h
src/support/lyxmanip.h [new file with mode: 0644]
src/table.C
src/table.h
src/tex-accent.C
src/text.C

index 0c3ecbe56564bcfafe1a7d69876e4fd6da366e1b..bcbeb080652ad0b3e781a9cfda4c9738db611f94 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,47 @@
+2000-03-06  Lars Gullik Bjønnes  <larsbj@lyx.org>
+
+       * lib/layouts/seminar.layout: feeble attempt at a layout for
+       seminar.cls, far from completet and could really use some looking
+       at from people used to write layout files.
+
+       * src/support/lyxmanip.h (newlineAndDepth): ostream manipulator to
+       use instead of the AddNewlineAndDepth funtion in lyx_cb.C. This is
+       a lot nicer and works nicely with ostreams.
+
+       * src/mathed/formula.C (draw): a slightly different solution that
+       the one posted to the list, but I think this one works too. (font
+       size wrong in headers.)
+
+       * src/insets/insettext.C (computeTextRows): some fiddling on
+       Jürgens turf, added some comments that he should read.
+
+       * src/lyxrc.C: remove all traces of RC_NOMENUACCELERATORS, never
+       used and it gave compiler warnings.
+       RC_SHOW_BANNER + "\\show_banner" added, also to reading and
+       writing of lyxrc.
+
+       * src/lyx_gui.C (create_forms): do the right thing when
+       show_banner is true/false.
+
+       * src/lyx_cb.C (TimerCB): no need to close or do anything if
+       show_banner is false.
+
+       * most file writing files: Now use iostreams to do almost all of
+       the writing. Also instead of passing string &, we now use
+       stringstreams. mathed output is still not adapted to iostreams.
+       This change can be turned off by commenting out all the occurences
+       of the "#define USE_OSTREAM_ONLY 1" lines.
+       
+       * src/WorkArea.C (createPixmap): don't output debug messages.
+       (WorkArea): don't output debug messages.
+
+       * lib/lyxrc.example: added a comment about the new variable
+       \show_banner 
+
+       * development/Code_rules/Rules: Added some more commente about how
+       to build class interfaces and on how better encapsulation can be
+       achieved. 
+
 2000-03-03  Juergen Vigna  <jug@sad.it>
 
        * src/insets/insetert.C (InsetERT): Now ERT-insets break row
index 62d14269d8d465bc6f01d035e4d9809c98548519..7b35986bf34d62a80ec6a7af7900b507d18086c4 100644 (file)
@@ -167,3 +167,42 @@ and enums.
     own. In case you have to change the generated files for any of the
     reasons above, you should provide a patch against the clean generated
     file. Your callbacks must be in a separate file.
+
+ *************************************************************
+
+ How to create class interfaces.
+ (a.k.a How Non-Member Functions Improve Encapsulation)
+ ======================================================
+
+       I recently read an article by Scott Meyers in C/C++ Users
+Journal (Vol.18,No.2), where he makes a strong case on how non-member
+functions makes classes more encapsulated, not less. Just to skipping
+to the core of this provides us with the following algorithm for
+deciding what kind of function to add to a class interface:
+
+       - We need to add a function f to the class C's API.
+
+       if (f needs to be virtual)
+               make f a member function of C;
+       else if (f is operator>> or operator<<) {
+               make f a non-member funtion;
+               if (f needs access to non-public members of C)
+                       make f a friend of C;
+       } else if (f needs type conversions on its left-most argument) {
+               make f a non-member function;
+               if (f needs access to non-public members of C)
+                       make f a friend of C;
+       } else if (f can be implemented via C's public interface)
+               make f a non-member function;
+       else
+               make f a member function of C;
+Unfortunately, to make the best use of this kind of Class API's we
+need namespaces. As soon as Jean-Marc stop using gcc 2.8 and other
+compilers seem more or less up to date on namespaces we will begin to
+use them. _BUT_ we should begin to use the above algoritm ASAP. We
+should also go through old code and apply this algorithm to the
+existing member functions. That will help maintainability in the
+future.
+
+(I'll feel in more from Scott Meyers article when time allows.)
diff --git a/lib/layouts/seminar.layout b/lib/layouts/seminar.layout
new file mode 100644 (file)
index 0000000..7275b87
--- /dev/null
@@ -0,0 +1,112 @@
+#% Do not delete the line below; configure depends on this
+#  \DeclareLaTeXClass{seminar}
+# Initial attemt at makeing a LyX layout file for the seminar class.
+# Author : Lars Gullik Bjønnes <larsbj@lyx.org>
+
+# Input general definitions
+Input stdclass.inc
+
+Sides  1
+Columns        1
+
+ClassOptions
+       FontSize 8|9|10|11|12|14|17
+       Other slidesec
+End
+
+# There are no chapters in an article.
+NoStyle Chapter
+NoStyle Chapter*
+
+MaxCounter             Counter_Section
+SecNumDepth            3
+TocDepth               3
+
+# Change a bit Part and Part*
+Style Part
+  Align                        Left
+  AlignPossible                Left
+  TopSep                2
+  BottomSep             1.5
+
+  Font
+    Size               Larger
+  EndFont
+End
+
+Style Part*
+  Align                        Left
+  AlignPossible                Left
+  TopSep                2
+  BottomSep             1.5
+
+  Font
+    Size               Larger
+  EndFont
+End
+
+
+Style LandscapeSlide
+       CopyStyle       Standard
+       LatexType       Environment
+       LatexName       slide
+       KeepEmpty       1
+       Labeltype       Static
+       LabelString     "Landscape Slide"
+       LabelSep        "MMMMMMM"
+End
+
+Style PortraitSlide
+       CopyStyle       Standard
+       LatexType       Environment
+       LatexName       slide*
+       KeepEmpty       1
+       Labeltype       Static
+       LabelString     "Portrait Slide"
+End
+
+Style Slide
+       Obsoletedby     LandscapeSlide
+End
+
+Style Slide*
+       Obsoletedby     PortraitSlide
+End
+
+Style SlideHeading
+       CopyStyle       Section
+       LatexName       slideheading
+End
+
+Style SlideSubHeading
+       CopyStyle       Subsection
+       LatexName       slidesubheading
+End
+
+Style ListOfSlides
+       KeepEmpty       1
+       Align           Center
+       LatexType       Command
+       LatexName       listofslides
+       Labeltype       Static
+       LabelString     "List Of Slides"
+End
+
+Style SlideContents
+       KeepEmpty       1
+       Align           Center
+       LatexType       Command
+       LatexName       slidecontents
+       Labeltype       Static
+       LabelString     "Slidecontents"
+End
+
+Style ProgressContents
+       KeepEmpty       1
+       Align           Center
+       LatexType       Command
+       LatexName       Slidecontents
+       Labeltype       Static
+       LabelString     "Progress Contents"
+End
+
index e0395a1cb510fa2200bbffdc847aaf7a89ef9225..15f4016fa176bbf783dbf1dcade728fb7b7996e7 100644 (file)
 # MISC SECTION ###########################################################
 #
 
+# Set this to false if you don't want the startup banner.
+# Default is true.
+#\show_banner true
+
 # Set to false if you don't want the current selection to be replaced
 # automatically by what you type. Default is true.
 #\auto_region_delete false
index ed378223aacd12ddcd4aac701a1e123915826aa4..275c59f07b494ac8804f2559bbffdeb7d5d989ed 100644 (file)
@@ -497,9 +497,10 @@ int LyXAction::LookupFunc(string const & func) const
 }
 
 
-#ifdef WITH_WARNINGS
-#warning Not working as it should.
-#endif
+//#ifdef WITH_WARNINGS
+//#warning Not working as it should.
+//#endif
+// I have no clue what is wrong with it... (Lgb)
 int LyXAction::getApproxFunc(string const & func) const
        // This func should perhaps also be able to return a list of all
        // actions that has func as a prefix. That should actually be quite
index 900db135a4055fb382e46b4d85d42d09d65ca5f4..5f95e0cada78a26bbfe15c90a711b138fc8f6626 100644 (file)
@@ -64,10 +64,11 @@ WorkArea::WorkArea(BufferView * o, int xpos, int ypos, int width, int height)
        fl_freeze_all_forms();
 
        figinset_canvas = 0;
-       
-       lyxerr << "Creating work area: +"
-              << xpos << '+' << ypos << ' '
-              << width << 'x' << height << endl;
+
+       if (lyxerr.debugging())
+               lyxerr << "Creating work area: +"
+                      << xpos << '+' << ypos << ' '
+                      << width << 'x' << height << endl;
        //
        FL_OBJECT * obj;
        const int bw = int(abs(float(fl_get_border_width())));
@@ -81,9 +82,10 @@ WorkArea::WorkArea(BufferView * o, int xpos, int ypos, int width, int height)
        fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity);
        
        // a box
-       lyxerr << "\tbackground box: +"
-              << xpos << '+' << ypos << ' '
-              << width - 15 << 'x' << height << endl;
+       if (lyxerr.debugging())
+               lyxerr << "\tbackground box: +"
+                      << xpos << '+' << ypos << ' '
+                      << width - 15 << 'x' << height << endl;
        backgroundbox = obj = fl_add_box(FL_BORDER_BOX,
                                         xpos, ypos,
                                         width - 15,
@@ -98,9 +100,10 @@ WorkArea::WorkArea(BufferView * o, int xpos, int ypos, int width, int height)
        // up - scrollbar button
        fl_set_border_width(-1);
 
-       lyxerr << "\tup button: +"
-              << xpos + width - 15 << '+' << ypos << ' '
-              << 15 << 'x' << 15 << endl;
+       if (lyxerr.debugging())
+               lyxerr << "\tup button: +"
+                      << xpos + width - 15 << '+' << ypos << ' '
+                      << 15 << 'x' << 15 << endl;
        button_up = obj = fl_add_pixmapbutton(FL_TOUCH_BUTTON,
                                              xpos + width - 15,
                                              ypos,
@@ -118,9 +121,11 @@ WorkArea::WorkArea(BufferView * o, int xpos, int ypos, int width, int height)
 
        // the scrollbar slider
        fl_set_border_width(-bw);
-       lyxerr << "\tscrollbar slider: +"
-              << xpos + width - 15 << '+' << ypos + 15 << ' '
-              << 15 << 'x' << height - 30 << endl;
+
+       if (lyxerr.debugging())
+               lyxerr << "\tscrollbar slider: +"
+                      << xpos + width - 15 << '+' << ypos + 15 << ' '
+                      << 15 << 'x' << height - 30 << endl;
        scrollbar = obj = fl_add_slider(FL_VERT_SLIDER,
                                        xpos + width - 15,
                                        ypos + 15,
@@ -136,9 +141,11 @@ WorkArea::WorkArea(BufferView * o, int xpos, int ypos, int width, int height)
        // down - scrollbar button
        fl_set_border_width(-1);
 
-       lyxerr << "\tdown button: +"
-              << xpos + width - 15 << '+' << ypos + height - 15 << ' '
-              << 15 << 'x' << 15 << endl;
+       if (lyxerr.debugging())
+               lyxerr << "\tdown button: +"
+                      << xpos + width - 15 << '+'
+                      << ypos + height - 15 << ' '
+                      << 15 << 'x' << 15 << endl;
        button_down = obj = fl_add_pixmapbutton(FL_TOUCH_BUTTON,
                                                xpos + width - 15,
                                                ypos + height - 15,
@@ -167,9 +174,12 @@ WorkArea::WorkArea(BufferView * o, int xpos, int ypos, int width, int height)
        
        // We add this object as late as possible to avoit problems
        // with drawing.
-       lyxerr << "\tfree object: +"
-              << xpos + bw << '+' << ypos + bw << ' '
-              << width - 15 - 2 * bw << 'x' << height - 2 * bw << endl;
+       if (lyxerr.debugging())
+               lyxerr << "\tfree object: +"
+                      << xpos + bw << '+' << ypos + bw << ' '
+                      << width - 15 - 2 * bw << 'x'
+                      << height - 2 * bw << endl;
+       
        work_area = obj = fl_add_free(FL_INPUT_FREE,
                                      xpos + bw, ypos + bw,
                                      width - 15 - 2 * bw, // scrollbarwidth
@@ -245,15 +255,18 @@ void WorkArea::createPixmap(int width, int height)
 
        if (workareapixmap)
                XFreePixmap(fl_display, workareapixmap);
-       
-       lyxerr << "Creating pixmap (" << width << 'x' << height << ")" << endl;
+
+       if (lyxerr.debugging())
+               lyxerr << "Creating pixmap ("
+                      << width << 'x' << height << ")" << endl;
        
        workareapixmap = XCreatePixmap(fl_display,
                                       RootWindow(fl_display, 0),
                                       width,
                                       height, 
                                       fl_get_visual_depth());
-       lyxerr << "\tpixmap=" << workareapixmap << endl;
+       if (lyxerr.debugging())
+               lyxerr << "\tpixmap=" << workareapixmap << endl;
 }
 
 
@@ -328,8 +341,8 @@ void WorkArea::scroll_cb(FL_OBJECT * ob, long)
 bool Lgb_bug_find_hack = false;
 
 int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
-                                 FL_Coord, FL_Coord ,
-                                 int /*key*/, void * xev)
+                               FL_Coord, FL_Coord ,
+                               int /*key*/, void * xev)
 {
        static int x_old = -1;
        static int y_old = -1;
@@ -381,16 +394,16 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
        // Done by the raw callback:
        //  case FL_KEYBOARD: WorkAreaKeyPress(ob, 0,0,0,ev,0); break;
        case FL_FOCUS:
-               lyxerr << "Workarea event: FOCUS" << endl;
+               lyxerr.debug() << "Workarea event: FOCUS" << endl;
                break;
        case FL_UNFOCUS:
-               lyxerr << "Workarea event: UNFOCUS" << endl;
+               lyxerr.debug() << "Workarea event: UNFOCUS" << endl;
                break;
        case FL_ENTER:
-               lyxerr << "Workarea event: ENTER" << endl;
+               lyxerr.debug() << "Workarea event: ENTER" << endl;
                break;
        case FL_LEAVE:
-               lyxerr << "Workarea event: LEAVE" << endl;
+               lyxerr.debug() << "Workarea event: LEAVE" << endl;
                break;
        case FL_DBLCLICK:
                if (!ev) break;
index 0cc2d32515cece64086a49e1bd8df5f26b50dbf0..3eb78ad986cde7987ae2fa93924c9f0a093aca05 100644 (file)
@@ -1525,6 +1525,537 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
 }
 
 
+#ifdef USE_OSTREAM_ONLY
+void Buffer::makeLaTeXFile(string const & fname, 
+                          string const & original_path,
+                          bool nice, bool only_body)
+{
+       lyxerr[Debug::LATEX] << "makeLaTeXFile..." << endl;
+       
+       niceFile = nice; // this will be used by Insetincludes.
+
+       tex_code_break_column = lyxrc->ascii_linelen;
+
+        LyXTextClass const & tclass =
+               textclasslist.TextClass(params.textclass);
+
+       ofstream ofs(fname.c_str());
+       if (!ofs) {
+               WriteFSAlert(_("Error: Cannot open file: "), fname);
+               return;
+       }
+       
+       // validate the buffer.
+       lyxerr[Debug::LATEX] << "  Validating buffer..." << endl;
+       LaTeXFeatures features(tclass.numLayouts());
+       validate(features);
+       lyxerr[Debug::LATEX] << "  Buffer validation done." << endl;
+       
+       texrow.reset();
+       // The starting paragraph of the coming rows is the 
+       // first paragraph of the document. (Asger)
+       texrow.start(paragraph, 0);
+
+       if (!only_body && nice) {
+               ofs << "%% " LYX_DOCVERSION " created this file.  "
+                       "For more info, see http://www.lyx.org/.\n"
+                       "%% Do not edit unless you really know what "
+                       "you are doing.\n";
+               texrow.newline();
+               texrow.newline();
+       }
+       lyxerr.debug() << "lyx header finished" << endl;
+       // There are a few differences between nice LaTeX and usual files:
+       // usual is \batchmode and has a 
+       // special input@path to allow the including of figures
+       // with either \input or \includegraphics (what figinsets do).
+       // batchmode is not set if there is a tex_code_break_column.
+       // In this case somebody is interested in the generated LaTeX,
+       // so this is OK. input@path is set when the actual parameter
+       // original_path is set. This is done for usual tex-file, but not
+       // for nice-latex-file. (Matthias 250696)
+       if (!only_body) {
+               if (!nice){
+                       // code for usual, NOT nice-latex-file
+                       ofs << "\\batchmode\n"; // changed
+                       // from \nonstopmode
+                       texrow.newline();
+               }
+               if (!original_path.empty()) {
+                       ofs << "\\makeatletter\n"
+                           << "\\def\\input@path{{"
+                           << original_path << "/}}\n"
+                           << "\\makeatother\n";
+                       texrow.newline();
+                       texrow.newline();
+                       texrow.newline();
+               }
+               
+               ofs << "\\documentclass";
+               
+               string options; // the document class options.
+               
+               if (tokenPos(tclass.opt_fontsize(), '|', params.fontsize) >= 0) {
+                       // only write if existing in list (and not default)
+                       options += params.fontsize;
+                       options += "pt,";
+               }
+               
+               
+               if (!params.use_geometry &&
+                   (params.paperpackage == BufferParams::PACKAGE_NONE)) {
+                       switch (params.papersize) {
+                       case BufferParams::PAPER_A4PAPER:
+                               options += "a4paper,";
+                               break;
+                       case BufferParams::PAPER_USLETTER:
+                               options += "letterpaper,";
+                               break;
+                       case BufferParams::PAPER_A5PAPER:
+                               options += "a5paper,";
+                               break;
+                       case BufferParams::PAPER_B5PAPER:
+                               options += "b5paper,";
+                               break;
+                       case BufferParams::PAPER_EXECUTIVEPAPER:
+                               options += "executivepaper,";
+                               break;
+                       case BufferParams::PAPER_LEGALPAPER:
+                               options += "legalpaper,";
+                               break;
+                       }
+               }
+
+               // if needed
+               if (params.sides != tclass.sides()) {
+                       switch (params.sides) {
+                       case LyXTextClass::OneSide:
+                               options += "oneside,";
+                               break;
+                       case LyXTextClass::TwoSides:
+                               options += "twoside,";
+                               break;
+                       }
+
+               }
+
+               // if needed
+               if (params.columns != tclass.columns()) {
+                       if (params.columns == 2)
+                               options += "twocolumn,";
+                       else
+                               options += "onecolumn,";
+               }
+
+               if (!params.use_geometry 
+                   && params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
+                       options += "landscape,";
+               
+               // language should be a parameter to \documentclass             
+               if (params.language != "default") {
+                       if (params.language == "hebrew")
+                               options += "english,";
+                       else if (lyxrc->rtl_support)
+                               options += "hebrew,";
+                       options += params.language + ',';
+               } else if (lyxrc->rtl_support)
+                       options += "hebrew,english,";
+
+               // the user-defined options
+               if (!params.options.empty()) {
+                       options += params.options + ',';
+               }
+               
+               if (!options.empty()){
+                       options = strip(options, ',');
+                       ofs << '[' << options << ']';
+               }
+               
+               ofs << '{'
+                   << textclasslist.LatexnameOfClass(params.textclass)
+                   << "}\n";
+               texrow.newline();
+               // end of \documentclass defs
+               
+               // font selection must be done before loading fontenc.sty
+               if (params.fonts != "default") {
+                       ofs << "\\usepackage{" << params.fonts << "}\n";
+                       texrow.newline();
+               }
+               // this one is not per buffer
+               if (lyxrc->fontenc != "default") {
+                       ofs << "\\usepackage[" << lyxrc->fontenc
+                           << "]{fontenc}\n";
+                       texrow.newline();
+               }
+               if (params.inputenc != "default") {
+                       ofs << "\\usepackage[" << params.inputenc
+                           << "]{inputenc}\n";
+                       texrow.newline();
+               }
+               
+               /* at the very beginning the text parameters */
+               if (params.paperpackage != BufferParams::PACKAGE_NONE) {
+                       switch (params.paperpackage) {
+                       case BufferParams::PACKAGE_A4:
+                               ofs << "\\usepackage{a4}\n";
+                               texrow.newline();
+                               break;
+                       case BufferParams::PACKAGE_A4WIDE:
+                               ofs << "\\usepackage{a4wide}\n";
+                               texrow.newline();
+                               break;
+                       case BufferParams::PACKAGE_WIDEMARGINSA4:
+                               ofs << "\\usepackage[widemargins]{a4}\n";
+                               texrow.newline();
+                               break;
+                       }
+               }
+               if (params.use_geometry) {
+                       ofs << "\\usepackage{geometry}\n";
+                       texrow.newline();
+                       ofs << "\\geometry{verbose";
+                       if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
+                               ofs << ",landscape";
+                       switch (params.papersize2) {
+                       case BufferParams::VM_PAPER_CUSTOM:
+                               if (!params.paperwidth.empty())
+                                       ofs << ",paperwidth="
+                                           << params.paperwidth;
+                               if (!params.paperheight.empty())
+                                       ofs << ",paperheight="
+                                           << params.paperheight;
+                               break;
+                       case BufferParams::VM_PAPER_USLETTER:
+                               ofs << ",letterpaper";
+                               break;
+                       case BufferParams::VM_PAPER_USLEGAL:
+                               ofs << ",legalpaper";
+                               break;
+                       case BufferParams::VM_PAPER_USEXECUTIVE:
+                               ofs << ",executivepaper";
+                               break;
+                       case BufferParams::VM_PAPER_A3:
+                               ofs << ",a3paper";
+                               break;
+                       case BufferParams::VM_PAPER_A4:
+                               ofs << ",a4paper";
+                               break;
+                       case BufferParams::VM_PAPER_A5:
+                               ofs << ",a5paper";
+                               break;
+                       case BufferParams::VM_PAPER_B3:
+                               ofs << ",b3paper";
+                               break;
+                       case BufferParams::VM_PAPER_B4:
+                               ofs << ",b4paper";
+                               break;
+                       case BufferParams::VM_PAPER_B5:
+                               ofs << ",b5paper";
+                               break;
+                       default:
+                               // default papersize ie BufferParams::VM_PAPER_DEFAULT
+                               switch (lyxrc->default_papersize) {
+                               case BufferParams::PAPER_DEFAULT: // keep compiler happy
+                               case BufferParams::PAPER_USLETTER:
+                                       ofs << ",letterpaper";
+                                       break;
+                               case BufferParams::PAPER_LEGALPAPER:
+                                       ofs << ",legalpaper";
+                                       break;
+                               case BufferParams::PAPER_EXECUTIVEPAPER:
+                                       ofs << ",executivepaper";
+                                       break;
+                               case BufferParams::PAPER_A3PAPER:
+                                       ofs << ",a3paper";
+                                       break;
+                               case BufferParams::PAPER_A4PAPER:
+                                       ofs << ",a4paper";
+                                       break;
+                               case BufferParams::PAPER_A5PAPER:
+                                       ofs << ",a5paper";
+                                       break;
+                               case BufferParams::PAPER_B5PAPER:
+                                       ofs << ",b5paper";
+                                       break;
+                               }
+                       }
+                       if (!params.topmargin.empty())
+                               ofs << ",tmargin=" << params.topmargin;
+                       if (!params.bottommargin.empty())
+                               ofs << ",bmargin=" << params.bottommargin;
+                       if (!params.leftmargin.empty())
+                               ofs << ",lmargin=" << params.leftmargin;
+                       if (!params.rightmargin.empty())
+                               ofs << ",rmargin=" << params.rightmargin;
+                       if (!params.headheight.empty())
+                               ofs << ",headheight=" << params.headheight;
+                       if (!params.headsep.empty())
+                               ofs << ",headsep=" << params.headsep;
+                       if (!params.footskip.empty())
+                               ofs << ",footskip=" << params.footskip;
+                       ofs << "}\n";
+                       texrow.newline();
+               }
+               if (params.use_amsmath
+                   && !prefixIs(textclasslist.LatexnameOfClass(params.textclass), "ams")) {
+                       ofs << "\\usepackage{amsmath}\n";
+                       texrow.newline();
+               }
+
+               if (tokenPos(tclass.opt_pagestyle(), '|', params.pagestyle) >= 0) {
+                       if (params.pagestyle == "fancy") {
+                               ofs << "\\usepackage{fancyhdr}\n";
+                               texrow.newline();
+                       }
+                       ofs << "\\pagestyle{" << params.pagestyle << "}\n";
+                       texrow.newline();
+               }
+
+               // We try to load babel late, in case it interferes
+               // with other packages.
+               if (params.language != "default" || lyxrc->rtl_support ) {
+                       ofs << "\\usepackage{babel}\n";
+                       texrow.newline();
+               }
+
+               if (params.secnumdepth != tclass.secnumdepth()) {
+                       ofs << "\\setcounter{secnumdepth}{"
+                           << params.secnumdepth
+                           << "}\n";
+                       texrow.newline();
+               }
+               if (params.tocdepth != tclass.tocdepth()) {
+                       ofs << "\\setcounter{tocdepth}{"
+                           << params.tocdepth
+                           << "}\n";
+                       texrow.newline();
+               }
+               
+               if (params.paragraph_separation) {
+                       switch (params.defskip.kind()) {
+                       case VSpace::SMALLSKIP: 
+                               ofs << "\\setlength\\parskip{\\smallskipamount}\n";
+                               break;
+                       case VSpace::MEDSKIP:
+                               ofs << "\\setlength\\parskip{\\medskipamount}\n";
+                               break;
+                       case VSpace::BIGSKIP:
+                               ofs << "\\setlength\\parskip{\\bigskipamount}\n";
+                               break;
+                       case VSpace::LENGTH:
+                               ofs << "\\setlength\\parskip{"
+                                   << params.defskip.length().asLatexString()
+                                   << "}\n";
+                               break;
+                       default: // should never happen // Then delete it.
+                               ofs << "\\setlength\\parskip{\\medskipamount}\n";
+                               break;
+                       }
+                       texrow.newline();
+                       
+                       ofs << "\\setlength\\parindent{0pt}\n";
+                       texrow.newline();
+               }
+
+               // Now insert the LyX specific LaTeX commands...
+               string preamble, tmppreamble;
+
+               // The optional packages;
+               preamble = features.getPackages(params);
+
+               // this might be useful...
+               preamble += "\n\\makeatletter\n\n";
+
+               // Some macros LyX will need
+               tmppreamble = features.getMacros(params);
+
+               if (!tmppreamble.empty()) {
+                       preamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
+                               "LyX specific LaTeX commands.\n"
+                               + tmppreamble + '\n';
+               }
+
+               // the text class specific preamble 
+               tmppreamble = features.getTClassPreamble(params);
+               if (!tmppreamble.empty()) {
+                       preamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
+                               "Textclass specific LaTeX commands.\n"
+                               + tmppreamble + '\n';
+               }
+
+               /* the user-defined preamble */
+               if (!params.preamble.empty()) {
+                       preamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
+                               "User specified LaTeX commands.\n"
+                               + params.preamble + '\n';
+               }
+
+               preamble += "\\makeatother\n\n";
+
+               // Itemize bullet settings need to be last in case the user
+               // defines their own bullets that use a package included
+               // in the user-defined preamble -- ARRae
+               // Actually it has to be done much later than that
+               // since some packages like frenchb make modifications
+               // at \begin{document} time -- JMarc 
+               string bullets_def;
+               for (int i = 0; i < 4; ++i) {
+                       if (params.user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
+                               if (bullets_def.empty())
+                                       bullets_def="\\AtBeginDocument{\n";
+                               bullets_def += "  \\renewcommand{\\labelitemi";
+                               switch (i) {
+                               // `i' is one less than the item to modify
+                               case 0:
+                                       break;
+                               case 1:
+                                       bullets_def += 'i';
+                                       break;
+                               case 2:
+                                       bullets_def += "ii";
+                                       break;
+                               case 3:
+                                       bullets_def += 'v';
+                                       break;
+                               }
+                               bullets_def += "}{" + 
+                                 params.user_defined_bullets[i].getText() 
+                                 + "}\n";
+                       }
+               }
+
+               if (!bullets_def.empty())
+                 preamble += bullets_def + "}\n\n";
+
+               for (int j = countChar(preamble, '\n'); j-- ;) {
+                       texrow.newline();
+               }
+
+               ofs << preamble;
+
+               // make the body.
+               ofs << "\\begin{document}\n\n";
+               texrow.newline();
+               texrow.newline();
+       } // only_body
+       lyxerr.debug() << "preamble finished, now the body." << endl;
+       
+       bool was_title = false;
+       bool already_title = false;
+#ifdef HAVE_SSTREAM
+       ostringstream ftnote;
+#else
+       char * tmpholder = 0;
+#endif
+       TexRow ft_texrow;
+       int ftcount = 0;
+
+       LyXParagraph * par = paragraph;
+
+       // if only_body
+       while (par) {
+#ifndef HAVE_SSTREAM
+               ostrstream ftnote;
+               if (tmpholder) {
+                       ftnote << tmpholder;
+                       delete [] tmpholder;
+                       tmpholder = 0;
+               }
+#endif
+               if (par->IsDummy())
+                       lyxerr[Debug::LATEX] << "Error in MakeLateXFile."
+                                            << endl;
+               LyXLayout const & layout =
+                       textclasslist.Style(params.textclass,
+                                           par->layout);
+           
+               if (layout.intitle) {
+                       if (already_title) {
+                               lyxerr <<"Error in MakeLatexFile: You"
+                                       " should not mix title layouts"
+                                       " with normal ones." << endl;
+                       } else
+                               was_title = true;
+               } else if (was_title && !already_title) {
+                       ofs << "\\maketitle\n";
+                       texrow.newline();
+                       already_title = true;
+                       was_title = false;                  
+               }
+               // We are at depth 0 so we can just use
+               // ordinary \footnote{} generation
+               // flag this with ftcount
+               ftcount = -1;
+               if (layout.isEnvironment()
+                    || par->pextra_type != LyXParagraph::PEXTRA_NONE) {
+                       par = par->TeXEnvironment(ofs, texrow,
+                                                 ftnote, ft_texrow, ftcount);
+               } else {
+                       par = par->TeXOnePar(ofs, texrow,
+                                            ftnote, ft_texrow, ftcount);
+               }
+
+               // Write out what we've generated...
+               if (ftcount >= 1) {
+                       if (ftcount > 1) {
+                               ofs << "\\addtocounter{footnote}{-"
+                                   << ftcount - 1
+                                   << '}';
+                       }
+                       ofs << ftnote.str();
+                       texrow += ft_texrow;
+#ifdef HAVE_SSTREAM
+                       ftnote.str(string());
+#else
+                       delete [] ftnote.str();
+#endif
+                       ft_texrow.reset();
+                       ftcount = 0;
+               }
+#ifndef HAVE_SSTREAM
+               else {
+                       // I hate strstreams
+                       tmpholder = ftnote.str();
+               }
+#endif
+       }
+#ifndef HAVE_SSTREAM
+       delete [] tmpholder;
+#endif
+       // It might be that we only have a title in this document
+       if (was_title && !already_title) {
+               ofs << "\\maketitle\n";
+               texrow.newline();
+       }
+
+       if (!only_body) {
+               ofs << "\\end{document}\n";
+               texrow.newline();
+       
+               lyxerr[Debug::LATEX] << "makeLaTeXFile...done" << endl;
+       } else {
+               lyxerr[Debug::LATEX] << "LaTeXFile for inclusion made."
+                                    << endl;
+       }
+
+       // Just to be sure. (Asger)
+       texrow.newline();
+
+       // tex_code_break_column's value is used to decide
+       // if we are in batchmode or not (within mathed_write()
+       // in math_write.C) so we must set it to a non-zero
+       // value when we leave otherwise we save incorrect .lyx files.
+       tex_code_break_column = lyxrc->ascii_linelen;
+
+       ofs.close();
+       if (ofs.fail()) {
+               lyxerr << "File was not closed properly." << endl;
+       }
+       
+       lyxerr.debug() << "Finished making latex file." << endl;
+}
+#else
 void Buffer::makeLaTeXFile(string const & fname, 
                           string const & original_path,
                           bool nice, bool only_body)
@@ -2048,6 +2579,7 @@ void Buffer::makeLaTeXFile(string const & fname,
        ofs.close();
        lyxerr.debug() << "Finished making latex file." << endl;
 }
+#endif
 
 
 bool Buffer::isLatex() const
@@ -2285,7 +2817,6 @@ void Buffer::DocBookHandleCaption(ostream & os, string & inner_tag,
                                  LyXParagraph * & par)
 {
        LyXParagraph * tpar = par;
-       string tmp_par, extra_par;
        while (tpar && (tpar->footnoteflag != LyXParagraph::NO_FOOTNOTE) &&
               (tpar->layout != textclasslist.NumberOfLayout(params.textclass,
                                                             "Caption").second))
@@ -2294,11 +2825,18 @@ void Buffer::DocBookHandleCaption(ostream & os, string & inner_tag,
            tpar->layout == textclasslist.NumberOfLayout(params.textclass,
                                                         "Caption").second) {
                sgmlOpenTag(os, depth + 1, inner_tag);
+#ifdef USE_OSTREAM_ONLY
+               string extra_par;
+               SimpleDocBookOnePar(os, extra_par, tpar,
+                                   desc_on, depth + 2);
+#else
+               string tmp_par, extra_par;
                SimpleDocBookOnePar(tmp_par, extra_par, tpar,
                                    desc_on, depth + 2);
                tmp_par = strip(tmp_par);
                tmp_par = frontStrip(tmp_par);
                os << tmp_par;
+#endif
                sgmlCloseTag(os, depth+1, inner_tag);
                if(!extra_par.empty())
                        os << extra_par;
@@ -2317,13 +2855,15 @@ void Buffer::DocBookHandleFootnote(ostream & os, LyXParagraph * & par,
        // This is not how I like to see enums. They should not be anonymous
        // and variables of its type should not be declared right after the
        // last brace. (Lgb)
-       enum {
+       enum SOME_ENUM {
                NO_ONE,
                FOOTNOTE_LIKE,
                MARGIN_LIKE,
                FIG_LIKE,
                TAB_LIKE
-       } last = NO_ONE, present = FOOTNOTE_LIKE;
+       };
+       SOME_ENUM last = NO_ONE;
+       SOME_ENUM present = FOOTNOTE_LIKE;
 
        while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
                if(last == present) {
@@ -2339,7 +2879,8 @@ void Buffer::DocBookHandleFootnote(ostream & os, LyXParagraph * & par,
                                os << "\n";
                } else {
                        os << tmp_par;
-                       if(!inner_tag.empty()) sgmlCloseTag(os, depth+1, inner_tag);
+                       if(!inner_tag.empty()) sgmlCloseTag(os, depth + 1,
+                                                           inner_tag);
                        if(!extra_par.empty()) os << extra_par;
                        if(!tag.empty()) sgmlCloseTag(os, depth, tag);
                        extra_par.clear();
@@ -2385,8 +2926,24 @@ void Buffer::DocBookHandleFootnote(ostream & os, LyXParagraph * & par,
                // ignore all caption here, we processed them above!!!
                if (par->layout != textclasslist.NumberOfLayout(params.textclass,
                                                           "Caption").second) {
-                       SimpleDocBookOnePar(tmp_par, extra_par, par,
+#ifdef USE_OSTREAM_ONLY
+#ifdef HAVE_SSTREAM
+                       ostringstream ost;
+#else
+                       ostrstream ost;
+#endif
+                       SimpleDocBookOnePar(ost, extra_par, par,
                                            desc_on, depth + 2);
+#ifdef HAVE_SSTREAM
+                       tmp_par += ost.str().c_str();
+#else
+                       ost << '\0';
+                       char * ctmp = ost.str();
+                       tmp_par += ctmp;
+                       delete [] ctmp;
+#endif
+#else
+#endif
                }
                tmp_par = frontStrip(strip(tmp_par));
 
@@ -2394,7 +2951,7 @@ void Buffer::DocBookHandleFootnote(ostream & os, LyXParagraph * & par,
                par = par->next;
        }
        os << tmp_par;
-       if(!inner_tag.empty()) sgmlCloseTag(os, depth+1, inner_tag);
+       if(!inner_tag.empty()) sgmlCloseTag(os, depth + 1, inner_tag);
        if(!extra_par.empty()) os << extra_par;
        if(!tag.empty()) sgmlCloseTag(os, depth, tag);
 }
@@ -2597,9 +3154,13 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os, LyXParagraph * par,
                        ++char_line_count;
                } else if (c == LyXParagraph::META_INSET) {
                        inset = par->GetInset(i);
+#ifdef USE_OSTREAM_ONLY
+                       inset->Linuxdoc(os);
+#else
                        string tmp_out;
                        inset->Linuxdoc(tmp_out);
                        os << tmp_out;
+#endif
                }
                else {
                        string sgml_string;
@@ -2887,6 +3448,14 @@ void Buffer::makeDocBookFile(string const & fname, int column)
                }
 
                do {
+#ifdef USE_OSTREAM_ONLY
+                       string extra_par;
+                       SimpleDocBookOnePar(ofs, extra_par, par, desc_on,
+                                           depth + 1 + command_depth);
+                       par = par->next;
+                       DocBookHandleFootnote(ofs, par,
+                                             depth + 1 + command_depth);
+#else
                        string tmp_par, extra_par;
 
                        SimpleDocBookOnePar(tmp_par, extra_par, par, desc_on,
@@ -2896,6 +3465,7 @@ void Buffer::makeDocBookFile(string const & fname, int column)
                        par = par->next;
                        DocBookHandleFootnote(ofs, par,
                                              depth + 1 + command_depth);
+#endif
                }
                while(par && par->IsDummy());
 
@@ -2957,6 +3527,142 @@ void Buffer::makeDocBookFile(string const & fname, int column)
 }
 
 
+#ifdef USE_OSTREAM_ONLY
+void Buffer::SimpleDocBookOnePar(ostream & os, string & extra,
+                                LyXParagraph * par, int & desc_on,
+                                int const depth) 
+{
+       if (par->table) {
+               par->SimpleDocBookOneTablePar(os, extra, desc_on, depth);
+               return;
+       }
+       LyXFont font1, font2;
+       char c;
+       Inset * inset;
+       LyXParagraph::size_type main_body;
+       int j;
+       //string emph = "emphasis";
+       bool emph_flag = false;
+       int char_line_count = 0;
+
+       LyXLayout const & style = textclasslist.Style(params.textclass,
+                                                     par->GetLayout());
+
+       if (style.labeltype != LABEL_MANUAL)
+               main_body = 0;
+       else
+               main_body = par->BeginningOfMainBody();
+
+       // gets paragraph main font
+       if (main_body > 0)
+               font1 = style.labelfont;
+       else
+               font1 = style.font;
+
+       char_line_count = depth;
+       if(!style.free_spacing)
+               for (j = 0; j < depth; ++j)
+                       os << ' ';
+
+       // parsing main loop
+       for (LyXParagraph::size_type i = 0;
+            i < par->size(); ++i) {
+               font2 = par->getFont(i);
+
+               // handle <emphasis> tag
+               if (font1.emph() != font2.emph() && i) {
+                       if (font2.emph() == LyXFont::ON) {
+                               os << "<emphasis>";
+                               emph_flag= true;
+                       }else {
+                               os << "</emphasis>";
+                               emph_flag= false;
+                       }
+               }
+      
+               c = par->GetChar(i);
+
+               if (c == LyXParagraph::META_INSET) {
+                       inset = par->GetInset(i);
+#ifdef HAVE_SSTREAM
+                       ostringstream ost;
+                       inset->DocBook(ost);
+                       string tmp_out = ost.str().c_str();
+#else
+                       ostrstream ost;
+                       inset->DocBook(ost);
+                       ost << '\0';
+                       char * ctmp = ost.str();
+                       string tmp_out(ctmp);
+                       delete [] ctmp;
+#endif
+                       //
+                       // This code needs some explanation:
+                       // Two insets are treated specially
+                       //   label if it is the first element in a command paragraph
+                       //         desc_on == 3
+                       //   graphics inside tables or figure floats can't go on
+                       //   title (the equivalente in latex for this case is caption
+                       //   and title should come first
+                       //         desc_on == 4
+                       //
+                       if(desc_on!= 3 || i!= 0) {
+                               if(!tmp_out.empty() && tmp_out[0] == '@') {
+                                       if(desc_on == 4)
+                                               extra += frontStrip(tmp_out, '@');
+                                       else
+                                               os << frontStrip(tmp_out, '@');
+                               }
+                               else
+                                       os << tmp_out;
+                       }
+               } else if (font2.latex() == LyXFont::ON) {
+                       // "TeX"-Mode on ==> SGML-Mode on.
+                       if (c!= '\0')
+                               os << c;
+                       ++char_line_count;
+               }
+               else {
+                       string sgml_string;
+                       if (par->linuxDocConvertChar(c, sgml_string)
+                           && !style.free_spacing) { // in freespacing
+                                                    // mode, spaces are
+                                                    // non-breaking characters
+                               // char is ' '
+                               if (desc_on == 1) {
+                                       ++char_line_count;
+                                       os << "\n</term><listitem><para>";
+                                       desc_on = 2;
+                               }
+                               else  {
+                                       os << c;
+                               }
+                       }
+                       else {
+                               os << sgml_string;
+                       }
+               }
+               font1 = font2;
+       }
+
+       /* needed if there is an optional argument but no contents */
+       if (main_body > 0 && main_body == par->size()) {
+               font1 = style.font;
+       }
+       if (emph_flag) {
+               os << "</emphasis>";
+       }
+       
+       /* resets description flag correctly */
+       switch(desc_on){
+       case 1:
+               /* <term> not closed... */
+               os << "</term>";
+               break;
+       }
+       os << '\n';
+}
+#else
 void Buffer::SimpleDocBookOnePar(string & file, string & extra,
                                 LyXParagraph * par, int & desc_on,
                                 int const depth) 
@@ -2967,7 +3673,7 @@ void Buffer::SimpleDocBookOnePar(string & file, string & extra,
        }
        LyXFont font1, font2;
        char c;
-       Inset *inset;
+       Inset * inset;
        LyXParagraph::size_type main_body;
        int j;
        string emph= "emphasis";
@@ -3013,8 +3719,23 @@ void Buffer::SimpleDocBookOnePar(string & file, string & extra,
 
                if (c == LyXParagraph::META_INSET) {
                        inset = par->GetInset(i);
+#ifdef USE_OSTREAM_ONLY
+#ifdef HAVE_SSTREAM
+                       ostringstream ost;
+                       inset->DocBook(ost);
+                       string tmp_out = ost.str().c_str();
+#else
+                       ostrstream ost;
+                       inset->DocBook(ost);
+                       ost << '\0';
+                       char * ctmp = ost.str();
+                       string tmp_out(ctmp);
+                       delete [] ctmp;
+#endif
+#else
                        string tmp_out;
                        inset->DocBook(tmp_out);
+#endif
                        //
                        // This code needs some explanation:
                        // Two insets are treated specially
@@ -3082,6 +3803,7 @@ void Buffer::SimpleDocBookOnePar(string & file, string & extra,
        }
        file += '\n';
 }
+#endif
 
 
 int Buffer::runLaTeX()
index 8b141a54b65cc23fac09e87c10db328c28a18c2b..ebb6dcfd7ab33db8d6e6ae2cc99666eacee64a8f 100644 (file)
@@ -357,10 +357,17 @@ private:
         ///
        void SimpleLinuxDocOnePar(ostream & os, LyXParagraph * par,
                                  int desc_on, int const depth);
+#ifdef USE_OSTREAM_ONLY
+        ///
+       void SimpleDocBookOnePar(ostream &, string & extra,
+                                LyXParagraph * par, int & desc_on,
+                                int const depth);
+#else
         ///
        void SimpleDocBookOnePar(string & file, string & extra,
                                 LyXParagraph * par, int & desc_on,
                                 int const depth);
+#endif
 
        /// LinuxDoc.
        void push_tag(ostream & os, char const * tag,
index 6bc9176219f5299b3a7e14c18492db94ee756e63..5f8f1c4487aa9c37acdd752adbf20950c96626a0 100644 (file)
@@ -1209,7 +1209,6 @@ int InsetFig::Latex(string & file, signed char /* fragile*/ ) const
        file += cmd + ' ';
        return 0;
 }
-#endif
 
 
 int InsetFig::Linuxdoc(string &/*file*/) const
@@ -1229,6 +1228,26 @@ int InsetFig::DocBook(string & file) const
        return 0;
 }
 
+#else
+
+int InsetFig::Linuxdoc(ostream &) const
+{
+       return 0;
+}
+
+
+int InsetFig::DocBook(ostream & os) const
+{
+       string figurename = fname;
+
+       if(suffixIs(figurename, ".eps"))
+               figurename.erase(fname.length() - 5);
+
+       os << "@<graphic fileref=\"" << figurename << "\"></graphic>";
+       return 0;
+}
+#endif
+
 
 void InsetFig::Validate(LaTeXFeatures & features) const
 {
index 83234badc5c1e6c5eccd6829da9d8c2905517ba0..3b0a2b3ab6b2f79003658df26b14bed7cd64cc7d 100644 (file)
@@ -42,11 +42,16 @@ public:
 #ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
-#endif
        ///
        int Linuxdoc(string & file) const;
        ///
        int DocBook(string & file) const;
+#else
+       ///
+       int Linuxdoc(ostream &) const;
+       ///
+       int DocBook(ostream &) const;
+#endif
        /// Updates needed features for this inset.
        void Validate(LaTeXFeatures & features) const;
 
index 02b733c9a76b7461824fde8fa946a2175eeaf508..a8dce4e1b83fd59aa38e0babd3b87896483c255c 100644 (file)
@@ -110,12 +110,11 @@ void UpdatableInset::ToggleInsetCursor(BufferView *)
 
 void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
 {
-    LyXFont
-       font;
+    LyXFont font;
 
     scx = 0;
 
-    mx_scx=abs((width(bv->getPainter(), font) - bv->paperWidth())/2);
+    mx_scx=abs((width(bv->getPainter(), font) - bv->paperWidth()) / 2);
 }
 
 
@@ -132,6 +131,7 @@ void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool )
 {
 }
 
+
 ///  An updatable inset could handle lyx editing commands
 #ifdef SCROLL_INSET
 UpdatableInset::RESULT
index 61f71bcb4ad48df8e842e6e0ffeb2ec96258e5a1..fdc0998b35569832a9fd72a1ed7e08db89bb03fd 100644 (file)
@@ -239,6 +239,15 @@ void InsetBibKey::setCounter(int c)
 // of time cause LyX3 won't use lyxlex anyway.  (ale)
 void InsetBibKey::Write(ostream & os) const
 {
+#ifdef USE_OSTREAM_ONLY
+       os << "\\bibitem ";
+       if (!options.empty()) {
+               os << '['
+                  << options << ']';
+       }
+       os << '{'
+          << contents << "}\n";
+#else
        string s;
        if (!options.empty()) {
                s += '[';
@@ -247,6 +256,7 @@ void InsetBibKey::Write(ostream & os) const
        s += '{';
        s += contents + '}';
        os << "\\bibitem " << s << "\n";
+#endif
 }
 
 
index 9c7c8b1bda3dbf215a5e0b492ce437be7ff5f685..26157994538b1cfe76e4d4e136fdb343db212b5d 100644 (file)
@@ -257,7 +257,6 @@ int InsetCommand::Latex(string & file, signed char /*fragile*/) const
        file += getCommand();
        return 0;
 }
-#endif
 
 
 int InsetCommand::Linuxdoc(string &/*file*/) const
@@ -271,6 +270,20 @@ int InsetCommand::DocBook(string &/*file*/) const
        return 0;
 }
 
+#else
+
+int InsetCommand::Linuxdoc(ostream &) const
+{
+       return 0;
+}
+
+
+int InsetCommand::DocBook(ostream &) const
+{
+       return 0;
+}
+#endif
+
 
 Inset * InsetCommand::Clone() const
 {
index bc3cb17978710e5058d6c3193a18f452faac2cc2..afdbcb98c4766a1ab2a376c06e19d7a2e43b3e31 100644 (file)
@@ -51,11 +51,16 @@ public:
 #ifndef USE_OSTREAM_ONLY
        ///
        virtual int Latex(string & file, signed char fragile) const;
-#endif
        ///
        virtual int Linuxdoc(string & file) const;
        ///
        virtual int DocBook(string & file) const;
+#else
+       ///
+       virtual int Linuxdoc(ostream &) const;
+       ///
+       virtual int DocBook(ostream &) const;
+#endif
        ///
        Inset * Clone() const;
        ///  
index 93fbda4a4db18786a8693c9166508598cff82e7e..c2c873cf9082ebb3d5500e8ebc343f1d57506edc 100644 (file)
@@ -112,7 +112,6 @@ int InsetError::Latex(string &, signed char /*fragile*/) const
 {
        return 0;
 }
-#endif
 
 
 int InsetError::Linuxdoc(string &) const
@@ -126,6 +125,20 @@ int InsetError::DocBook(string &) const
        return 0;
 }
 
+#else
+
+int InsetError::Linuxdoc(ostream &) const
+{
+       return 0;
+}
+
+
+int InsetError::DocBook(ostream &) const
+{
+       return 0;
+}
+#endif
+
 
 bool InsetError::AutoDelete() const
 {
index 86f7c712f94c824109af727be2aa397989b3f7e2..47892510a68fa234c02a7690b85b6f7d13fd9427 100644 (file)
@@ -51,11 +51,16 @@ public:
 #ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
-#endif
        ///
        int Linuxdoc(string & file) const;
        ///
        int DocBook(string & file) const;
+#else
+       ///
+       int Linuxdoc(ostream &) const;
+       ///
+       int DocBook(ostream &) const;
+#endif
        ///
        bool AutoDelete() const;
        /// what appears in the minibuffer when opening
index dcbfc71a35766f87c6d776557733e2efeb955e3d..348546d42d647c8de336b420071795852eac0272 100644 (file)
@@ -230,7 +230,6 @@ int InsetGraphics::Latex(string & /*file*/, signed char /*fragile*/) const
 {
        return 0;
 }
-#endif
 
 
 int InsetGraphics::Linuxdoc(string & /*file*/) const
@@ -244,6 +243,20 @@ int InsetGraphics::DocBook(string & /*file*/) const
        return 0;
 }
 
+#else
+
+int InsetGraphics::Linuxdoc(ostream &) const
+{
+       return 0;
+}
+
+
+int InsetGraphics::DocBook(ostream &) const
+{
+       return 0;
+}
+#endif
+
 
 void InsetGraphics::Validate(LaTeXFeatures & /*features*/) const
 {
index f54d1f29adc2a3457087ba47a9489061ca91bfe6..df7fadf0d184f33767c27708fbaf23da805a2db7 100644 (file)
@@ -49,11 +49,16 @@ public:
 #ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
-#endif
        ///
        int Linuxdoc(string & /*file*/) const;
        ///
        int DocBook(string & /*file*/) const;
+#else
+       ///
+       int Linuxdoc(ostream &) const;
+       ///
+       int DocBook(ostream &) const;
+#endif
        /// Updates needed features for this inset.
        void Validate(LaTeXFeatures & features) const;
 
index 9499ec0de25fa74705dd9a005cce3008c7576fb6..fc9038013080e71b49e153ca71d8b391c23be1a0 100644 (file)
@@ -137,7 +137,6 @@ int InsetInfo::Latex(string &, signed char /*fragile*/) const
 {
        return 0;
 }
-#endif
 
 
 int InsetInfo::Linuxdoc(string &) const
@@ -151,6 +150,20 @@ int InsetInfo::DocBook(string &) const
        return 0;
 }
 
+#else
+
+int InsetInfo::Linuxdoc(ostream &) const
+{
+       return 0;
+}
+
+
+int InsetInfo::DocBook(ostream &) const
+{
+       return 0;
+}
+#endif
+
 
 unsigned char InsetInfo::Editable() const
 {
index 5fa617c66b68b5fb3a5f825fec1830972b1ae5b2..3ae6a47e7c40186a52395439a379bfee854e0d84 100644 (file)
@@ -53,11 +53,16 @@ public:
 #ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
-#endif
        ///
        int Linuxdoc(string & file) const;
        ///
        int DocBook(string & file) const;
+#else
+       ///
+       int Linuxdoc(ostream &) const;
+       ///
+       int DocBook(ostream &) const;
+#endif
        /// what appears in the minibuffer when opening
        const char * EditMessage() const {return _("Opened note");}
        ///
index 697a524079e1da3088df8820d33eb4218134d388..0a2a94f0447a72394fff9b18029200533f47beff 100644 (file)
@@ -56,7 +56,6 @@ int InsetLabel::Latex(string & file, signed char /*fragile*/) const
        file += escape(getCommand());
        return 0;
 }
-#endif
 
 
 int InsetLabel::Linuxdoc(string & file) const
@@ -72,6 +71,24 @@ int InsetLabel::DocBook(string & file) const
        return 0;
 }
 
+#else
+
+int InsetLabel::Linuxdoc(ostream & os) const
+{
+       os << "<label id=\"" << getContents() << "\" >";
+       return 0;
+}
+
+
+int InsetLabel::DocBook(ostream & os) const
+{
+       os << "<anchor id=\"" << getContents() << "\" >";
+       return 0;
+}
+#endif
+
+
+
 
 // This function escapes 8-bit characters and other problematic characters
 // It's exactly the same code as in insetref.C.
index 9c95af71ef2a578d9b1bdc66abad6119754367d4..be251cb1defbba005bcba9d5e1e40b36fc529e6d 100644 (file)
@@ -43,11 +43,16 @@ public:
 #ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
-#endif
        ///
        int Linuxdoc(string & file) const;
        ///
        int DocBook(string & file) const;
+#else
+       ///
+       int Linuxdoc(ostream &) const;
+       ///
+       int DocBook(ostream &) const;
+#endif
 private:
        /// This function escapes 8-bit characters
        string escape(string const &) const;
index 0adb04841d2622fb7f65fbca782705da41df87bf..661ba931cb5cf5a00dd512a43cbf1bde87747753 100644 (file)
@@ -758,7 +758,6 @@ int InsetLatexAccent::Latex(string & file, signed char /*fragile*/) const
        file += contents;
        return 0;
 }
-#endif
 
 
 int InsetLatexAccent::Linuxdoc(string & file) const
@@ -774,6 +773,22 @@ int InsetLatexAccent::DocBook(string & file) const
        return 0;
 }
 
+#else
+
+int InsetLatexAccent::Linuxdoc(ostream & os) const
+{
+       os << contents;
+       return 0;
+}
+
+
+int InsetLatexAccent::DocBook(ostream & os) const
+{
+       os << contents;
+       return 0;
+}
+#endif
+
 
 bool InsetLatexAccent::Deletable() const
 {
index 1da3e79482f77f1df5e7d7de1adfb65497e4eda9..affb09a1104d524b0941aa7fa1aa50aeaf4cf74a 100644 (file)
@@ -57,11 +57,16 @@ public:
 #ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
-#endif
        ///
        int Linuxdoc(string & file) const;
        ///
        int DocBook(string & file) const;
+#else
+       ///
+       int Linuxdoc(ostream &) const;
+       ///
+       int DocBook(ostream &) const;
+#endif
        ///
        bool Deletable() const;
        ///
index 3e044d20c5ce6189a2cc1c0b25eeee50711aee1d..05e029d7ca789adfdc6cc38215b7a983898e0223 100644 (file)
@@ -304,7 +304,6 @@ int InsetQuotes::Latex(string & file, signed char /*fragile*/) const
        file += qstr;
        return 0;
 }
-#endif
 
 
 int InsetQuotes::Linuxdoc(string & file) const
@@ -331,6 +330,32 @@ int InsetQuotes::DocBook(string & file) const
        return 0;
 }
 
+#else
+
+int InsetQuotes::Linuxdoc(ostream & os) const
+{
+       os << "\"";
+       return 0;
+}
+
+
+int InsetQuotes::DocBook(ostream & os) const
+{
+       if(times == InsetQuotes::DoubleQ) {
+               if (side == InsetQuotes::LeftQ)
+                       os << "&ldquo;";
+               else
+                       os << "&rdquo;";
+       } else {
+               if (side == InsetQuotes::LeftQ)
+                       os << "&lsquo;";
+               else
+                       os << "&rsquo;";
+       }
+       return 0;
+}
+#endif
+
 
 void InsetQuotes::Validate(LaTeXFeatures & features) const 
 {
index cd554cf2803bccdefeaa8bb07bf70de703dfeb59..515a8168d1752de2b0e93cbb6a2cb6da33992683 100644 (file)
@@ -89,11 +89,16 @@ public:
 #ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
-#endif
        ///
        int Linuxdoc(string & file) const;
        ///
        int DocBook(string & file) const;
+#else
+       ///
+       int Linuxdoc(ostream &) const;
+       ///
+       int DocBook(ostream &) const;
+#endif
        ///
        void Validate(LaTeXFeatures &) const;
        ///
index bd0fa93757b74553131b9556ce25789e4eb18bb5..0a13720d03237c5e0dbd1968c9b4a2c24ab77e57 100644 (file)
@@ -94,7 +94,6 @@ int InsetRef::Latex(string & file, signed char /*fragile*/) const
        }
        return 0;
 }
-#endif
 
 
 int InsetRef::Linuxdoc(string & file) const
@@ -114,6 +113,24 @@ int InsetRef::DocBook(string & file) const
        return 0;
 }
 
+#else
+
+int InsetRef::Linuxdoc(ostream & os) const
+{
+       os << "<ref id=\"" << getContents()
+          << "\" name=\"" << getOptions() << "\" >";
+       return 0;
+}
+
+
+int InsetRef::DocBook(ostream & os) const
+{
+       os << "<link linkend=\"" << getContents()
+          << "\">" << getOptions() << "</link>";
+       return 0;
+}
+#endif
+
 
 // This function escapes 8-bit characters and other problematic characters
 // It's exactly the same code as in insetlabel.C.
index 4c897c93f7a3de1907911d67e3dd62f2ad78620e..2d6d2b45fcfdfbb65dd9d4df707afa258c0cbb9a 100644 (file)
@@ -65,11 +65,16 @@ public:
 #ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
-#endif
        ///
        int Linuxdoc(string & file) const;
        ///
        int DocBook(string & file) const;
+#else
+       ///
+       int Linuxdoc(ostream &) const;
+       ///
+       int DocBook(ostream &) const;
+#endif
 private:
        /// This function escapes 8-bit characters
        string escape(string const &) const;
index 2db0639952729161b8e0c490c524d9d2fef18f71..1792545ea2cd8689828c99e776c8a795d725ab57 100644 (file)
@@ -220,7 +220,6 @@ int InsetSpecialChar::Latex(string & file, signed char /*fragile*/) const
        }
        return 0;
 }
-#endif
 
 
 int InsetSpecialChar::Linuxdoc(string & file) const
@@ -248,6 +247,34 @@ int InsetSpecialChar::DocBook(string & file) const
        return 0;
 }
 
+#else
+
+int InsetSpecialChar::Linuxdoc(ostream & os) const
+{
+       switch (kind) {
+       case HYPHENATION:         os << "";     break;
+       case END_OF_SENTENCE:     os << "";     break;
+       case LDOTS:               os << "...";  break;
+       case MENU_SEPARATOR:      os << "->";   break;
+       case PROTECTED_SEPARATOR: os << " ";   break;
+       }
+       return 0;
+}
+
+
+int InsetSpecialChar::DocBook(ostream & os) const
+{
+       switch (kind) {
+       case HYPHENATION:         os << "";     break;
+       case END_OF_SENTENCE:     os << "";     break;
+       case LDOTS:               os << "...";  break;
+       case MENU_SEPARATOR:      os << "->";   break;
+       case PROTECTED_SEPARATOR: os << " ";   break;
+       }
+       return 0;
+}
+#endif
+
 
 Inset * InsetSpecialChar::Clone() const
 {
index 410b66ed16d7478d05d35dbbef6046bc847acbfa..d591dc594373759f4539286d6b8d02d73212ec9a 100644 (file)
@@ -63,11 +63,16 @@ public:
 #ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
-#endif
        ///
        int Linuxdoc(string & file) const;
        ///
        int DocBook(string & file) const;
+#else
+       ///
+       int Linuxdoc(ostream &) const;
+       ///
+       int DocBook(ostream &) const;
+#endif
        ///
        Inset * Clone() const;
        ///  
index 082e2e10481749f1594453d574c89041e56b27e8..b42e189a9151b389909285d383f71732abd14e96 100644 (file)
@@ -199,7 +199,7 @@ void InsetText::draw(Painter & pain, LyXFont const & f,
                     int baseline, float & x) const
 {
 //    if (init_inset) {
-       computeTextRows(pain);
+       computeTextRows(pain, x);
 //     init_inset = false;
 //    }
     UpdatableInset::draw(pain, f, baseline, x);
@@ -208,7 +208,7 @@ void InsetText::draw(Painter & pain, LyXFont const & f,
     top_x = int(x);
     top_baseline = baseline;
     computeBaselines(baseline);
-    for(unsigned int r = 0; r < rows.size() - 1; ++r) {
+    for(RowList::size_type r = 0; r < rows.size() - 1; ++r) {
         drawRowSelection(pain, rows[r].pos, rows[r + 1].pos, r, 
                          rows[r].baseline, x);
         drawRowText(pain, rows[r].pos, rows[r + 1].pos, rows[r].baseline, x);
@@ -600,10 +600,8 @@ InsetText::LocalDispatch(BufferView * bv,
 int InsetText::Latex(ostream & os, signed char /*fragile*/) const
 {
 #ifdef USE_OSTREAM_ONLY
-       string fstr;
        TexRow texrow;
-       int ret = par->SimpleTeXOnePar(fstr, texrow);
-       os << fstr;
+       int ret = par->SimpleTeXOnePar(os, texrow);
        return ret;
 #else
     string fstr;
@@ -1050,7 +1048,29 @@ void InsetText::SetCharFont(int pos, LyXFont const & f)
 }
 
 
-void InsetText::computeTextRows(Painter & pain) const
+// Ok, Jürgen. Here is my small secret message to you. As you can see I
+// played a bit witht he Textinset. (But only through the InsetERT so far).
+// As you can see below I have changed the code to use max/min instead of
+// the if < construct, imo this makes it faster and easier to read. I have
+// also changed rows[rows.size() - 1] to rows.back() makes it clearer that
+// we speak about the last element in the vector. I added a second arg to
+// to this func as well. This makes it possible to take the position of the
+// inset into account when drawing the inset, this is especially needed when
+// the ERT inset is first in a paragraph. I am not sure, but this might have
+// made short ERT (less than one line, just a couple of words) draw
+// incorrectly. You should perhaps have a look yourselves at this.
+// Also (phu...) I use pain to get at paperWidth().
+// This is beginning to look like a very nice Inset (speaking of the ERT
+// inset that is), but in afterthought, do we really need it? Wouldn't a
+// non dynamic inset working in the same way as the floats be more usefull
+// and easier to work with? Jean-Marc has already aired this thought.
+// I tested also a bit on the raw insettext, it seems that it can't break
+// over several lines properly. Other than that it seems to create the basis
+// for insetfloat, insetmarginal and insetfoot just fine. How about a
+// updatable inset that does not open, unless you click on it? uff... I just
+// ramble on. Feel free to remove my comments after you have read them.
+// Lgb
+void InsetText::computeTextRows(Painter & pain, float x) const
 {
     int p,
        nwp = 0,
@@ -1064,7 +1084,8 @@ void InsetText::computeTextRows(Painter & pain) const
     row_struct row;
 
     if (rows.size())
-       rows.erase(rows.begin(),rows.end());
+           rows.clear();
+           //rows.erase(rows.begin(),rows.end());
     int width = wordAscent = wordDescent = 0;
     insetWidth = maxAscent = maxDescent = 0;
     row.asc      = 0;
@@ -1076,10 +1097,12 @@ void InsetText::computeTextRows(Painter & pain) const
        for(p = 0; p < par->Last(); ++p) {
            insetWidth += SingleWidth(pain, par, p);
            SingleHeight(pain, par, p, asc, desc);
-           if (asc > maxAscent)
-               maxAscent = asc;
-           if (desc > maxDescent)
-               maxDescent = desc;
+           maxAscent = max(maxAscent, asc);
+           //if (asc > maxAscent)
+           //maxAscent = asc;
+           maxDescent = max(maxDescent, desc);
+           //if (desc > maxDescent)
+           //maxDescent = desc;
        }
        rows[0].asc = maxAscent;
        rows[0].desc = maxDescent;
@@ -1091,112 +1114,127 @@ void InsetText::computeTextRows(Painter & pain) const
 
     bool is_first_word_in_row = true;
 
-    int cw,
-       lastWordWidth = 0;
+    int cw, lastWordWidth = 0;
 
-    maxWidth = buffer->getUser()->paperWidth();
+    //maxWidth = buffer->getUser()->paperWidth();
+    maxWidth = pain.paperWidth();
     for(p = 0; p < par->Last(); ++p) {
        cw = SingleWidth(pain, par, p);
        width += cw;
        lastWordWidth += cw;
        SingleHeight(pain, par, p, asc, desc);
-       if (asc > wordAscent)
-           wordAscent = asc;
-       if (desc > wordDescent)
-           wordDescent = desc;
+       wordAscent = max(wordAscent, asc);
+       //if (asc > wordAscent)
+       //    wordAscent = asc;
+       wordDescent = max(wordDescent, desc);
+       //if (desc > wordDescent)
+       //    wordDescent = desc;
        Inset const * inset = 0;
        if (((p + 1) < par->Last()) &&
            (par->GetChar(p + 1)==LyXParagraph::META_INSET))
            inset = par->GetInset(p + 1);
        if (inset && inset->display()) {
-           if (!is_first_word_in_row && (width >= maxWidth)) {
+           if (!is_first_word_in_row && (width >= maxWidth - x)) {
                // we have to split also the row above
-               rows[rows.size() - 1].asc = oasc;
-               rows[rows.size() - 1].desc = odesc;
+               rows.back().asc = oasc;
+               rows.back().desc = odesc;
                row.pos = nwp;
                rows.push_back(row);
                oasc = wordAscent;
                odesc = wordDescent;
-               if (insetWidth < owidth)
-                   insetWidth = owidth;
+               insetWidth = max(insetWidth, owidth);
+               //if (insetWidth < owidth)
+               //    insetWidth = owidth;
                width = lastWordWidth;
                lastWordWidth = 0;
            } else {
-               if (oasc < wordAscent)
-                   oasc = wordAscent;
-               if (odesc < wordDescent)
-                   odesc = wordDescent;
+                   oasc = max(oasc, wordAscent);
+                   //if (oasc < wordAscent)
+                   //oasc = wordAscent;
+                   odesc = max(odesc, wordDescent);
+                   //if (odesc < wordDescent)
+                   //odesc = wordDescent;
            }
-           rows[rows.size() - 1].asc = oasc;
-           rows[rows.size() - 1].desc = odesc;
+           rows.back().asc = oasc;
+           rows.back().desc = odesc;
            row.pos = ++p;
            rows.push_back(row);
            SingleHeight(pain, par, p, asc, desc);
-           rows[rows.size() - 1].asc = asc;
-           rows[rows.size() - 1].desc = desc;
+           rows.back().asc = asc;
+           rows.back().desc = desc;
            row.pos = nwp = p + 1;
            rows.push_back(row);
            oasc = odesc = width = lastWordWidth = 0;
            is_first_word_in_row = true;
            wordAscent = wordDescent = 0;
+           x = 0.0;
            continue;
        } else if (par->IsSeparator(p)) {
-           if (width >= maxWidth) {
+           if (width >= maxWidth - x) {
                if (is_first_word_in_row) {
-                   rows[rows.size() - 1].asc = wordAscent;
-                   rows[rows.size() - 1].desc = wordDescent;
+                   rows.back().asc = wordAscent;
+                   rows.back().desc = wordDescent;
                    row.pos = p + 1;
                    rows.push_back(row);
                    oasc = odesc = width = 0;
                } else {
-                   rows[rows.size() - 1].asc = oasc;
-                   rows[rows.size() - 1].desc = odesc;
+                   rows.back().asc = oasc;
+                   rows.back().desc = odesc;
                    row.pos = nwp;
                    rows.push_back(row);
                    oasc = wordAscent;
                    odesc = wordDescent;
-                   if (insetWidth < owidth)
-                       insetWidth = owidth;
+                   insetWidth = max(insetWidth, owidth);
+                   //if (insetWidth < owidth)
+                   //insetWidth = owidth;
                    width = lastWordWidth;
                }
                wordAscent = wordDescent = lastWordWidth = 0;
                nwp = p + 1;
+               x = 0.0;
                continue;
            }
            owidth = width;
-           if (oasc < wordAscent)
-               oasc = wordAscent;
-           if (odesc < wordDescent)
-               odesc = wordDescent;
+           oasc = max(oasc, wordAscent);
+           //if (oasc < wordAscent)
+           //oasc = wordAscent;
+           odesc = max(odesc, wordDescent);
+           //if (odesc < wordDescent)
+           //odesc = wordDescent;
            wordAscent = wordDescent = lastWordWidth = 0;
            nwp = p + 1;
            is_first_word_in_row = false;
        }
+       x = 0.0;
     }
     // if we have some data in the paragraph we have ascent/descent
     if (p) {
        if (width >= maxWidth) {
            // assign upper row
-           rows[rows.size() - 1].asc = oasc;
-           rows[rows.size() - 1].desc = odesc;
+           rows.back().asc = oasc;
+           rows.back().desc = odesc;
            // assign and allocate lower row
            row.pos = nwp;
            rows.push_back(row);
-           rows[rows.size() - 1].asc = wordAscent;
-           rows[rows.size() - 1].desc = wordDescent;
-           if (insetWidth < owidth)
-               insetWidth = owidth;
+           rows.back().asc = wordAscent;
+           rows.back().desc = wordDescent;
+           insetWidth = max(insetWidth, owidth);
+           //if (insetWidth < owidth)
+           //insetWidth = owidth;
            width -= owidth;
-           if (insetWidth < width)
-               insetWidth = width;
+           insetWidth = max(insetWidth, width);
+           //if (insetWidth < width)
+           //insetWidth = width;
        } else {
            // assign last row data
-           if (oasc < wordAscent)
-               oasc = wordAscent;
-           if (odesc < wordDescent)
-               odesc = wordDescent;
-           rows[rows.size() - 1].asc = oasc;
-           rows[rows.size() - 1].desc = odesc;
+               oasc = max(oasc, wordAscent);
+               //if (oasc < wordAscent)
+               //oasc = wordAscent;
+               odesc = min(odesc, wordDescent);
+               //if (odesc < wordDescent)
+               //odesc = wordDescent;
+           rows.back().asc = oasc;
+           rows.back().desc = odesc;
        }
     }
     // alocate a dummy row for the endpos
@@ -1205,9 +1243,10 @@ void InsetText::computeTextRows(Painter & pain) const
     // calculate maxAscent/Descent
     maxAscent = rows[0].asc;
     maxDescent = rows[0].desc;
-    for (unsigned int i = 1; i < rows.size() - 1; ++i) {
+    for (RowList::size_type i = 1; i < rows.size() - 1; ++i) {
        maxDescent += rows[i].asc + rows[i].desc + interline_space;
     }
+    lyxerr << "Rows: " << rows.size() << endl;
 #if 0
     if (the_locking_inset) {
        computeBaselines(top_baseline);
index f3bfbd8629fe844bd508199165f7da2b977e1bd2..86965826cb4c9545de3011ec8b3219f6f292f98f 100644 (file)
@@ -84,11 +84,16 @@ public:
 #ifndef USE_OSTREAM_ONLY
     ///
     int Latex(string &, signed char) const;
-#endif
     ///
     int Linuxdoc(string &) const { return 0; }
     ///
     int DocBook(string &) const { return 0; }
+#else
+    ///
+    int Linuxdoc(ostream &) const { return 0; }
+    ///
+    int DocBook(ostream &) const { return 0; }
+#endif
     ///
     void Validate(LaTeXFeatures & features) const;
     ///
@@ -147,7 +152,7 @@ private:
     void drawRowText(Painter &, int startpos, int endpos, int baseline,
                      float x) const;
     ///
-    void computeTextRows(Painter &) const;
+    void computeTextRows(Painter &, float x = 0.0) const;
     ///
     void computeBaselines(int) const;
     ///
index a4f89da74c1d7a18d6ae321a20c8d7ab85e56f1f..5936bfc9f409a93920792b3be2f59270926fab6a 100644 (file)
@@ -17,6 +17,7 @@ void InsetTOC::Edit(BufferView * bv, int, int, unsigned int)
        bv->owner()->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
 }
 
+#ifndef USE_OSTREAM_ONLY
 int InsetTOC::Linuxdoc(string & file) const
 {
        file += "<toc>";
@@ -29,3 +30,19 @@ int InsetTOC::DocBook(string & file) const
        file += "<toc></toc>";
        return 0;
 }
+
+#else
+
+int InsetTOC::Linuxdoc(ostream & os) const
+{
+       os << "<toc>";
+       return 0;
+}
+
+
+int InsetTOC::DocBook(ostream & os) const
+{
+       os << "<toc></toc>";
+       return 0;
+}
+#endif
index dbe4d446684a7a330a95dece06e689c23b457f23..f6d08a5611e00da26d4bc1ee91175570df713053 100644 (file)
@@ -43,10 +43,17 @@ public:
        bool display() const { return true; }
        ///
        Inset::Code LyxCode() const { return Inset::TOC_CODE; }
+#ifdef USE_OSTREAM_ONLY
+       ///
+       int Linuxdoc(ostream &) const;
+       ///
+       int DocBook(ostream &) const;
+#else
        ///
        int Linuxdoc(string & file) const;
        ///
        int DocBook(string & file) const;
+#endif
 private:
        ///
        Buffer * owner;
index 9416d82660695e8b8fc3b8f3a86d43bfaa57021d..540ac5bf458c3a65b40f6eabc04b289ba92417f9 100644 (file)
@@ -197,7 +197,6 @@ int InsetUrl::Latex(string & file, signed char fragile) const
 
        return 0;
 }
-#endif
 
 
 int InsetUrl::Linuxdoc(string & file) const
@@ -218,6 +217,26 @@ int InsetUrl::DocBook(string & file) const
        return 0;
 }
 
+#else
+
+int InsetUrl::Linuxdoc(ostream & os) const
+{
+       os << "<" << getCmdName()
+          << " url=\""  << getContents() << "\""
+          << " name=\"" << getOptions() << "\">";
+
+       return 0;
+}
+
+
+int InsetUrl::DocBook(ostream & os) const
+{
+       os << "<ulink url=\"" << getContents() << "\">"
+          << getOptions() << "</ulink>";
+       return 0;
+}
+#endif
+
 
 void InsetUrl::Validate(LaTeXFeatures & features) const
 {
index f6f84f4acfd9091ca0aa72b042f97e993049c81f..f0580239ff171b39e39e53c4c7410a95adcb4578 100644 (file)
@@ -74,11 +74,16 @@ public:
 #ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
-#endif
        ///
        int Linuxdoc(string & file) const;
        ///
        int DocBook(string & file) const;
+#else
+       ///
+       int Linuxdoc(ostream &) const;
+       ///
+       int DocBook(ostream &) const;
+#endif
        ///
        static void CloseUrlCB(FL_OBJECT *, long data);
 private:
index 9bcc94243c342a7cc0236affb641d4d95f92e1df..83365627869c36228ee6636520c26d726d984928 100644 (file)
@@ -118,11 +118,16 @@ public:
 #ifndef USE_OSTREAM_ONLY
        ///
        virtual int Latex(string & file, signed char fragile) const = 0;
-#endif
        ///
        virtual int Linuxdoc(string & /*file*/) const = 0;
        ///
        virtual int DocBook(string & /*file*/) const = 0;
+#else
+       ///
+       virtual int Linuxdoc(ostream &) const = 0;
+       ///
+       virtual int DocBook(ostream &) const = 0;
+#endif
        /// Updates needed features for this inset.
        virtual void Validate(LaTeXFeatures & features) const;
        ///
@@ -203,7 +208,7 @@ public:
     
        /// To convert old binary dispatch results
        RESULT DISPATCH_RESULT(bool b) {
-               return (b) ? DISPATCHED: FINISHED;
+               return b ? DISPATCHED : FINISHED;
        }
 
        ///
@@ -234,7 +239,8 @@ public:
        virtual void draw(Painter &, LyXFont const &,
                          int baseline, float & x) const;
        ///
-       virtual void SetFont(BufferView *, LyXFont const &, bool toggleall=false);
+       virtual void SetFont(BufferView *, LyXFont const &,
+                            bool toggleall = false);
        ///
        virtual bool InsertInset(BufferView *, Inset *) { return false; }
        ///
@@ -246,7 +252,7 @@ public:
                { return false; }
        ///
        virtual bool UnlockInsetInInset(BufferView *, Inset *,
-                                       bool /*lr*/=false)
+                                       bool /*lr*/ = false)
                { return false; }
        ///  An updatable inset could handle lyx editing commands
        virtual RESULT LocalDispatch(BufferView *, int, string const &);
index 235d8fb032ee35d69b4c749824afc0276b022bc8..6733d5b35014e53a3e2859f867bdc6414691a256 100644 (file)
@@ -2313,7 +2313,7 @@ void Free()
 extern "C" void TimerCB(FL_OBJECT *, long)
 {
        // only if the form still exists
-       if (fd_form_title->form_title != 0) {
+       if (lyxrc->show_banner && fd_form_title->form_title != 0) {
                if (fd_form_title->form_title->visible) {
                        fl_hide_form(fd_form_title->form_title);
                }
@@ -3542,6 +3542,7 @@ extern "C" void RefHideCB(FL_OBJECT *, long)
        fl_hide_form(fd_form_ref->form_ref);
 }
 
+#ifndef USE_OSTREAM_ONLY
 #ifdef WITH_WARNINGS
 #warning UGLY!!
 #endif
@@ -3554,3 +3555,4 @@ void addNewlineAndDepth(string & file, int depth)
        file += '\n';
        file.append(depth, ' ');
 }
+#endif
index 20cde249053e92e508c2a5b4fd30a8cfab411da4..e9bd2c685d70a12016d1c021d0829a555ef6bc1b 100644 (file)
@@ -300,42 +300,44 @@ void LyXGUI::create_forms()
        //
 
        // the title form
-       fd_form_title = create_form_form_title();
-       fl_set_form_dblbuffer(fd_form_title->form_title, 1); // use dbl buffer
-       fl_set_form_atclose(fd_form_title->form_title, CancelCloseBoxCB, 0);
-       fl_addto_form(fd_form_title->form_title);
+       if (lyxrc->show_banner) {
+               fd_form_title = create_form_form_title();
+               fl_set_form_dblbuffer(fd_form_title->form_title, 1); // use dbl buffer
+               fl_set_form_atclose(fd_form_title->form_title, CancelCloseBoxCB, 0);
+               fl_addto_form(fd_form_title->form_title);
 #ifdef TWO_COLOR_ICONS
-       FL_OBJECT *obj = fl_add_bitmapbutton(FL_NORMAL_BUTTON, 0, 0, 425, 290, "");
-         fl_set_bitmapbutton_data(obj, banner_bw_width,
-                                  banner_bw_height, banner_bw_bits);
-         fl_set_object_color(obj, FL_WHITE, FL_BLACK);
+               FL_OBJECT *obj = fl_add_bitmapbutton(FL_NORMAL_BUTTON, 0, 0, 425, 290, "");
+               fl_set_bitmapbutton_data(obj, banner_bw_width,
+                                        banner_bw_height, banner_bw_bits);
+               fl_set_object_color(obj, FL_WHITE, FL_BLACK);
 #else
-       FL_OBJECT *obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 0, 0, 425, 290, "");
-         fl_set_pixmapbutton_data(obj, const_cast<char **>(banner));
-
-         fl_set_pixmapbutton_focus_outline(obj, 3);
+               FL_OBJECT *obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 0, 0, 425, 290, "");
+               fl_set_pixmapbutton_data(obj, const_cast<char **>(banner));
+               
+               fl_set_pixmapbutton_focus_outline(obj, 3);
 #endif
-         fl_set_button_shortcut(obj, "^M ^[", 1);
-         fl_set_object_boxtype(obj, FL_NO_BOX);
-         fl_set_object_callback(obj, TimerCB, 0);
-
-       obj = fl_add_text(FL_NORMAL_TEXT, 248, 265, 170, 16, LYX_VERSION);
-         fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+               fl_set_button_shortcut(obj, "^M ^[", 1);
+               fl_set_object_boxtype(obj, FL_NO_BOX);
+               fl_set_object_callback(obj, TimerCB, 0);
+               
+               obj = fl_add_text(FL_NORMAL_TEXT, 248, 265, 170, 16, LYX_VERSION);
+               fl_set_object_lsize(obj, FL_NORMAL_SIZE);
 #ifdef TWO_COLOR_ICONS
-         fl_set_object_color(obj, FL_WHITE, FL_WHITE);
-         fl_set_object_lcol(obj, FL_BLACK);
+               fl_set_object_color(obj, FL_WHITE, FL_WHITE);
+               fl_set_object_lcol(obj, FL_BLACK);
 #else
 //       fl_set_object_color(obj, FL_WHITE, FL_WHITE);
 //       fl_set_object_lcol(obj, FL_BLACK);
-          fl_mapcolor(FL_FREE_COL2, 0x05, 0x2e, 0x4c);
-          fl_mapcolor(FL_FREE_COL3, 0xe1, 0xd2, 0x9b);
-         fl_set_object_color(obj, FL_FREE_COL2, FL_FREE_COL2);
-         fl_set_object_lcol(obj, FL_FREE_COL3);
+               fl_mapcolor(FL_FREE_COL2, 0x05, 0x2e, 0x4c);
+               fl_mapcolor(FL_FREE_COL3, 0xe1, 0xd2, 0x9b);
+               fl_set_object_color(obj, FL_FREE_COL2, FL_FREE_COL2);
+               fl_set_object_lcol(obj, FL_FREE_COL3);
 #endif
-         fl_set_object_lalign(obj, FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
-         fl_set_object_lstyle(obj, FL_BOLD_STYLE);
-       fl_end_form();
-
+               fl_set_object_lalign(obj, FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
+               fl_set_object_lstyle(obj, FL_BOLD_STYLE);
+               fl_end_form();
+       }
+       
        // the paragraph form
        fd_form_paragraph = create_form_form_paragraph();
        fl_set_form_atclose(fd_form_paragraph->form_paragraph,
@@ -558,23 +560,28 @@ void LyXGUI::create_forms()
        // Did we get a valid position?
        if (xpos>= 0 && ypos>= 0) {
                lyxViews->setPosition(xpos, ypos);
-               // show the title form in the middle of the main form
-               fl_set_form_position(fd_form_title->form_title,
-                       abs(xpos + (width/2) - (370 / 2)),
-                       abs(ypos + (height/2) - (290 / 2)));
-               // The use of abs() above is a trick to ensure valid positions
-               main_placement = FL_PLACE_POSITION;
-               title_placement = FL_PLACE_GEOMETRY;
+               if (lyxrc->show_banner) {
+                       // show the title form in the middle of the main form
+                       fl_set_form_position(fd_form_title->form_title,
+                                            abs(xpos + (width/2) - (370 / 2)),
+                                            abs(ypos + (height/2) - (290 / 2)));
+                       title_placement = FL_PLACE_GEOMETRY;
+                       // The use of abs() above is a trick to ensure
+                       // valid positions
+               }
+                       main_placement = FL_PLACE_POSITION;
        }
        lyxViews->show(main_placement, FL_FULLBORDER, "LyX");
-       fl_show_form(fd_form_title->form_title, 
-                    title_placement, FL_NOBORDER, 
-                    _("LyX Banner"));
-       fl_redraw_form(fd_form_title->form_title);
-       fl_raise_form(fd_form_title->form_title);
-
-       // Show the title form at most 7 secs (lowered from 10 secs)
-       fl_set_timer(fd_form_title->timer_title, 7);
+       if (lyxrc->show_banner) {
+               fl_show_form(fd_form_title->form_title, 
+                            title_placement, FL_NOBORDER, 
+                            _("LyX Banner"));
+               fl_redraw_form(fd_form_title->form_title);
+               fl_raise_form(fd_form_title->form_title);
+
+               // Show the title form at most 7 secs (lowered from 10 secs)
+               fl_set_timer(fd_form_title->timer_title, 7);
+       }
 }
 
 
index 20a991fdd7d2948cd2ab2fec3cf3dfb5ab12745b..e245f92648791a295d32e796aeb419f86d870f9a 100644 (file)
@@ -663,6 +663,91 @@ void LyXFont::lyxWriteChanges(LyXFont const & orgfont, ostream & os) const
 
 /// Writes the head of the LaTeX needed to impose this font
 // Returns number of chars written.
+#ifdef USE_OSTREAM_ONLY
+int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base,
+                                   LyXFont const & prev) const
+{
+       LyXFont f = *this;
+       f.reduce(base);
+       
+       if (f.bits == inherit)
+               return 0;
+       
+       int count = 0;
+       bool env = false;
+
+       FONT_DIRECTION direction = f.direction();
+       if (direction != prev.direction()) {
+               if (direction == LTR_DIR) {
+                       os << "\\L{";
+                       count += 3;
+                       env = true; //We have opened a new environment
+               }
+               if (direction == RTL_DIR) {
+                       os << "\\R{";
+                       count += 3;
+                       env = true; //We have opened a new environment
+               }
+       }
+
+       if (f.family() != INHERIT_FAMILY) {
+               os << '\\'
+                  << LaTeXFamilyNames[f.family()]
+                  << '{'
+                  << LaTeXFamilyNames[f.family()].length() + 2;
+               env = true; //We have opened a new environment
+       }
+       if (f.series() != INHERIT_SERIES) {
+               os << '\\'
+                  << LaTeXSeriesNames[f.series()]
+                  << '{';
+               count += LaTeXSeriesNames[f.series()].length() + 2;
+               env = true; //We have opened a new environment
+       }
+       if (f.shape() != INHERIT_SHAPE) {
+               os << '\\'
+                  << LaTeXShapeNames[f.shape()]
+                  << '{';
+               count += LaTeXShapeNames[f.shape()].length() + 2;
+               env = true; //We have opened a new environment
+       }
+       if (f.color() != LColor::inherit) {
+               os << "\\textcolor{"
+                  << lcolor.getLaTeXName(f.color())
+                  << "}{";
+               count += lcolor.getLaTeXName(f.color()).length() + 13;
+               env = true; //We have opened a new environment
+       }
+       if (f.emph() == ON) {
+               os << "\\emph{";
+               count += 6;
+               env = true; //We have opened a new environment
+       }
+       if (f.underbar() == ON) {
+               os << "\\underbar{";
+               count += 10;
+               env = true; //We have opened a new environment
+       }
+       // \noun{} is a LyX special macro
+       if (f.noun() == ON) {
+               os << "\\noun{";
+               count += 8;
+               env = true; //We have opened a new environment
+       }
+       if (f.size() != INHERIT_SIZE) {
+               // If we didn't open an environment above, we open one here
+               if (!env) {
+                       os << '{';
+                       ++count;
+               }
+               os << '\\'
+                  << LaTeXSizeNames[f.size()]
+                  << ' ';
+               count += LaTeXSizeNames[f.size()].length() + 2;
+       }
+       return count;
+}
+#else
 int LyXFont::latexWriteStartChanges(string & file, LyXFont const & base,
                                    LyXFont const & prev) const
 {
@@ -746,8 +831,10 @@ int LyXFont::latexWriteStartChanges(string & file, LyXFont const & base,
        }
        return count;
 }
+#endif
 
 
+#ifndef USE_OSTREAM_ONLY
 /// Writes ending block of LaTeX needed to close use of this font
 // Returns number of chars written
 // This one corresponds to latexWriteStartChanges(). (Asger)
@@ -816,9 +903,80 @@ int LyXFont::latexWriteEndChanges(string & file, LyXFont const & base,
                        ++count;
                }
        }
+       return count;
+}
+#else
+/// Writes ending block of LaTeX needed to close use of this font
+// Returns number of chars written
+// This one corresponds to latexWriteStartChanges(). (Asger)
+int LyXFont::latexWriteEndChanges(ostream & os, LyXFont const & base,
+                                 LyXFont const & next) const
+{
+       LyXFont f = *this; // why do you need this?
+       f.reduce(base); // why isn't this just "reduce(base);" (Lgb)
+       // Because this function is const. Everything breaks if this
+       // method changes the font it represents. There is no speed penalty
+       // by using the temporary. (Asger)
+
+       if (f.bits == inherit)
+               return 0;
        
+       int count = 0;
+       bool env = false;
+
+       FONT_DIRECTION direction = f.direction();
+       if ( direction != next.direction()
+           && (direction == RTL_DIR || direction == LTR_DIR) ) {
+               os << '}';
+               ++count;
+               env = true; // Size change need not bother about closing env.
+       }
+
+       if (f.family() != INHERIT_FAMILY) {
+               os << '}';
+               ++count;
+               env = true; // Size change need not bother about closing env.
+       }
+       if (f.series() != INHERIT_SERIES) {
+               os << '}';
+               ++count;
+               env = true; // Size change need not bother about closing env.
+       }
+       if (f.shape() != INHERIT_SHAPE) {
+               os << '}';
+               ++count;
+               env = true; // Size change need not bother about closing env.
+       }
+       if (f.color() != LColor::inherit) {
+               os << '}';
+               ++count;
+               env = true; // Size change need not bother about closing env.
+       }
+       if (f.emph() == ON) {
+               os << '}';
+               ++count;
+               env = true; // Size change need not bother about closing env.
+       }
+       if (f.underbar() == ON) {
+               os << '}';
+               ++count;
+               env = true; // Size change need not bother about closing env.
+       }
+       if (f.noun() == ON) {
+               os << '}';
+               ++count;
+               env = true; // Size change need not bother about closing env.
+       }
+       if (f.size() != INHERIT_SIZE) {
+               // We only have to close if only size changed
+               if (!env) {
+                       os << '}';
+                       ++count;
+               }
+       }
        return count;
 }
+#endif
 
 
 LColor::color LyXFont::realColor() const
index 816de4753e6b3ff4ed37977a193fb37c40dcd5d0..bd32445f7e6584f62251f26081551fa9d1919046 100644 (file)
@@ -35,6 +35,8 @@
 #undef OFF
 #endif
 
+#define USE_OSTREAM_ONLY 1
+
 class LyXLex;
 
 ///
@@ -292,6 +294,22 @@ public:
        /// Writes the changes from this font to orgfont in .lyx format in file
        void lyxWriteChanges(LyXFont const & orgfont, ostream &) const;
 
+
+#ifdef USE_OSTREAM_ONLY
+       /** Writes the head of the LaTeX needed to change to this font.
+           Writes to string, the head of the LaTeX needed to change
+           to this font. Returns number of chars written. Base is the
+           font state active now.
+       */
+       int latexWriteStartChanges(ostream &, LyXFont const & base,
+                                  LyXFont const & prev) const;
+       /** Writes tha tail of the LaTeX needed to chagne to this font.
+           Returns number of chars written. Base is the font state we want
+           to achieve.
+       */
+       int latexWriteEndChanges(ostream &, LyXFont const & base,
+                                LyXFont const & next) const;
+#else
        /** Writes the head of the LaTeX needed to change to this font.
            Writes to string, the head of the LaTeX needed to change
            to this font. Returns number of chars written. Base is the
@@ -299,14 +317,13 @@ public:
        */
        int latexWriteStartChanges(string &, LyXFont const & base,
                                   LyXFont const & prev) const;
-
        /** Writes tha tail of the LaTeX needed to chagne to this font.
            Returns number of chars written. Base is the font state we want
            to achieve.
        */
        int latexWriteEndChanges(string &, LyXFont const & base,
                                 LyXFont const & next) const;
+#endif 
        /// Build GUI description of font state
        string stateText() const;
 
index 270055d316c45e2e67efa52c7f429a9b4f361b53..cfc020804c71d10e6a47134898a13f97dbb97053 100644 (file)
@@ -150,18 +150,31 @@ public:
        ///
        void readSimpleWholeFile(istream &);
 
+#ifdef USE_OSTREAM_ONLY
+       ///
+       LyXParagraph * TeXOnePar(ostream &, TexRow & texrow,
+                                ostream & foot, TexRow & foot_texrow,
+                                int & foot_count);
+       ///
+       bool SimpleTeXOnePar(ostream &, TexRow & texrow);
+
+       ///
+       LyXParagraph * TeXEnvironment(ostream &, TexRow & texrow,
+                                     ostream & foot, TexRow & foot_texrow,
+                                     int & foot_count);
+#else
        ///
        LyXParagraph * TeXOnePar(string & file, TexRow & texrow,
-                               string & foot, TexRow & foot_texrow,
-                               int & foot_count);
+                                string & foot, TexRow & foot_texrow,
+                                int & foot_count);
        ///
        bool SimpleTeXOnePar(string & file, TexRow & texrow);
 
        ///
        LyXParagraph * TeXEnvironment(string & file, TexRow & texrow,
-                                    string & foot, TexRow & foot_texrow,
-                                    int & foot_count);
-       
+                                     string & foot, TexRow & foot_texrow,
+                                     int & foot_count);
+#endif 
        ///
        LyXParagraph * Clone() const;
        
@@ -470,14 +483,24 @@ public:
        bool RoffContTableRows(ostream &, size_type i, int actcell);
 #endif
        ///
-       void DocBookContTableRows(string & file, string & extra, int & desc_on,
+       bool linuxDocConvertChar(char c, string & sgml_string);
+#ifdef USE_OSTREAM_ONLY
+       ///
+       void DocBookContTableRows(ostream &, string & extra, int & desc_on,
                                  size_type i,
                                  int current_cell_number, int & column);
        ///
-       bool linuxDocConvertChar(char c, string & sgml_string);
+       void SimpleDocBookOneTablePar(ostream &, string & extra,
+                                     int & desc_on, int depth);
+#else
+       ///
+       void DocBookContTableRows(string & file, string & extra, int & desc_on,
+                                 size_type i,
+                                 int current_cell_number, int & column);
        ///
        void SimpleDocBookOneTablePar(string & file, string & extra,
                                      int & desc_on, int depth);
+#endif
 private:
        /** A font entry covers a range of positions. Notice that the
          entries in the list are inserted in random order.
@@ -516,6 +539,35 @@ private:
        typedef list<InsetTable> InsetList;
        ///
        InsetList insetlist;
+#ifdef USE_OSTREAM_ONLY
+       ///
+       LyXParagraph * TeXDeeper(ostream &, TexRow & texrow,
+                                ostream & foot, TexRow & foot_texrow,
+                                int & foot_count);
+       ///
+       LyXParagraph * TeXFootnote(ostream &, TexRow & texrow,
+                                  ostream & foot, TexRow & foot_texrow,
+                                  int & foot_count,
+                                  LyXDirection par_direction);
+       ///
+       bool SimpleTeXOneTablePar(ostream &, TexRow & texrow);
+       ///
+       bool TeXContTableRows(ostream &, size_type i,
+                             int current_cell_number,
+                              int & column, TexRow & texrow);
+       ///
+       void SimpleTeXBlanks(ostream &, TexRow & texrow,
+                            size_type const i,
+                            int & column, LyXFont const & font,
+                            LyXLayout const & style);
+       ///
+       void SimpleTeXSpecialChars(ostream &, TexRow & texrow,
+                                  LyXFont & font, LyXFont & running_font,
+                                  LyXFont & basefont, bool & open_font,
+                                  LyXLayout const & style,
+                                  size_type & i,
+                                  int & column, char const c);
+#else
        ///
        LyXParagraph * TeXDeeper(string & file, TexRow & texrow,
                                   string & foot, TexRow & foot_texrow,
@@ -543,6 +595,7 @@ private:
                                   LyXLayout const & style,
                                   size_type & i,
                                   int & column, char const c);
+#endif
        ///
        unsigned int id_;
        ///
index 38a3bd925e08ec8d5919e9d041c5e06df67f5e43..3b75919eec4763c3d5c0bf998bec893a3e2f2fbc 100644 (file)
@@ -91,7 +91,6 @@ enum LyXRCTags {
        RC_AUTOREGIONDELETE,
        RC_BIND,
        RC_SERVERPIPE,
-       RC_NOMENUACCELERATORS,
        RC_INPUT,
        RC_BINDFILE,
        RC_KBMAP,
@@ -136,6 +135,7 @@ enum LyXRCTags {
        RC_PDF_TO_PS_COMMAND,
        RC_DVI_TO_PS_COMMAND,
        RC_DATE_INSERT_FORMAT,
+       RC_SHOW_BANNER,
        RC_LAST
 };
 
@@ -219,6 +219,7 @@ static keyword_item lyxrcTags[] = {
        { "\\selection_color", RC_SELECTION_COLOR },
        { "\\serverpipe", RC_SERVERPIPE },
        { "\\sgml_extra_options", RC_SGML_EXTRA_OPTIONS },
+       { "\\show_banner", RC_SHOW_BANNER },
        { "\\spell_command", RC_SPELL_COMMAND },
        { "\\tempdir_path", RC_TEMPDIRPATH },
        { "\\template_path", RC_TEMPLATEPATH },
@@ -328,9 +329,10 @@ LyXRC::LyXRC()
        use_kbmap = false;
        hasBindFile = false;
        rtl_support = false;
-       defaultKeyBindings();
-       ///
        date_insert_format = "%A, %e %B %Y";
+       show_banner = true;
+       //
+       defaultKeyBindings();
 }
 
 
@@ -922,6 +924,10 @@ int LyXRC::read(string const & filename)
                        if (lexrc.next())
                                rtl_support = lexrc.GetBool();
                        break;
+               case RC_SHOW_BANNER:
+                       if (lexrc.next())
+                               show_banner = lexrc.GetBool();
+                       break;
                case RC_LAST: break; // this is just a dummy
                }
        }
@@ -1215,7 +1221,9 @@ void LyXRC::output(ostream & os) const
                os << "\\make_backup " << tostr(make_backup) << "\n";
        case RC_DATE_INSERT_FORMAT:
                os << "\\date_insert_format \"" << date_insert_format
-                  << "\"\n"; 
+                  << "\"\n";
+       case RC_SHOW_BANNER:
+               os << "\\show_banner " << tostr(show_banner) << "\n";
        }
        os.flush();
 }
index eecba9f191f4eba0014513d4a20adb1d8b836a69..c9c757b9029f6dbb3dffc9db246f255c73cfefad 100644 (file)
@@ -203,6 +203,8 @@ public:
        string date_insert_format;
        ///
        bool rtl_support;
+       ///
+       bool show_banner;
 private:
        ///
        void defaultKeyBindings();
index d98625962f301f36ed65c62fe889c895c6b741fe..7762aef8cd8adb931f22cdef62ad04c6ceb8ffc8 100644 (file)
@@ -334,7 +334,6 @@ int InsetFormula::Latex(string & file, signed char fragile) const
         mathed_write(par, file, &ret, fragile, label.c_str());
     return ret;
 }
-#endif
 
 
 int InsetFormula::Linuxdoc(string &/*file*/) const
@@ -348,6 +347,20 @@ int InsetFormula::DocBook(string &/*file*/) const
     return 0;
 }
 
+#else
+
+int InsetFormula::Linuxdoc(ostream &) const
+{
+    return 0;
+}
+
+
+int InsetFormula::DocBook(ostream&) const
+{
+    return 0;
+}
+#endif
+
 
 // Check if uses AMS macros 
 void InsetFormula::Validate(LaTeXFeatures & features) const
@@ -404,11 +417,12 @@ int InsetFormula::width(Painter &, LyXFont const & f) const
 }
 
 
-void InsetFormula::draw(Painter & pain, LyXFont const &,
+void InsetFormula::draw(Painter & pain, LyXFont const & f,
                        int baseline, float & x) const
 {
+       // Seems commenting out solves a problem.
        LyXFont font = mathed_get_font(LM_TC_TEXTRM, LM_ST_TEXT);
-
+       font.setSize(f.size());
        lfont_size = font.size();
        /// Let's try to wait a bit with this... (Lgb)
        //UpdatableInset::draw(pain, font, baseline, x);
index 7c87264e5016e374e16b41a185f6871267361a5a..22d35af33e57822f95b489650edfa5a32bcc27ad 100644 (file)
@@ -53,11 +53,16 @@ public:
 #ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
-#endif
        ///
        int Linuxdoc(string & file) const;
        ///
        int DocBook(string & file) const;
+#else
+       ///
+       int Linuxdoc(ostream &) const;
+       ///
+       int DocBook(ostream &) const;
+#endif
        ///
        void Validate(LaTeXFeatures &) const;
        ///
index d971ac8b2bfa18b9fd125275a5b6b3cd57de65a1..031ecc1d1c7d9dc553731eca359fe53c651bed7a 100644 (file)
@@ -85,7 +85,6 @@ int InsetFormulaMacro::Latex(string &file, signed char /*fragile*/) const
     tmacro->WriteDef(file);
     return ret;
 }
-#endif
 
 
 int InsetFormulaMacro::Linuxdoc(string &/*file*/) const
@@ -99,6 +98,20 @@ int InsetFormulaMacro::DocBook(string &/*file*/) const
     return 0;
 }
 
+#else
+
+int InsetFormulaMacro::Linuxdoc(ostream &) const
+{
+    return 0;
+}
+
+
+int InsetFormulaMacro::DocBook(ostream &) const
+{
+    return 0;
+}
+#endif
+
 
 void InsetFormulaMacro::Read(LyXLex & lex)
 {
index 8b9a6ae6c19469dcfbfa13513c387777915a68e3..8aa623e240d3010fbb63361dd06051f84453ee2e 100644 (file)
@@ -52,11 +52,16 @@ public:
 #ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
-#endif
        ///
        int Linuxdoc(string & file) const;
        ///
        int DocBook(string & file) const;
+#else
+       ///
+       int Linuxdoc(ostream &) const;
+       ///
+       int DocBook(ostream &) const;
+#endif
        ///
        Inset * Clone() const;
 
index 93d50d7636eaef5b7587a3675e3e30a8965b578b..81287ea45bb988f0bb50328377d5cc634b9c6c0e 100644 (file)
@@ -386,7 +386,7 @@ void MathMacroTemplate::WriteDef(ostream & os)
 }
 
 
-void MathMacroTemplate::WriteDef(string &file)
+void MathMacroTemplate::WriteDef(string & file)
 {
     file += "\n\\newcommand{\\";
     file += name;
index 7da6e8ce0a9a1519659800db2cb4a30e94cde368..96a747857b8f2f585ff3139c87663f80eb5538c4 100644 (file)
@@ -35,7 +35,11 @@ using std::ios;
 #include "texrow.h"
 
 
+#ifdef USE_OSTREAM_ONLY
+#include "support/lyxmanip.h"
+#else
 extern void addNewlineAndDepth(string & file, int depth); // Jug 990923
+#endif
 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)
@@ -1867,6 +1871,188 @@ void LyXParagraph::readSimpleWholeFile(istream & is)
 }
 
 
+#ifdef USE_OSTREAM_ONLY
+LyXParagraph * LyXParagraph::TeXOnePar(ostream & os, TexRow & texrow,
+                                      ostream & foot, TexRow & foot_texrow,
+                                      int & foot_count)
+{
+       lyxerr[Debug::LATEX] << "TeXOnePar...     " << this << endl;
+       LyXParagraph * par = next;
+       LyXLayout const & style =
+               textclasslist.Style(current_view->buffer()->params.textclass,
+                                   layout);
+
+       bool further_blank_line = false;
+       if (IsDummy())
+               lyxerr << "ERROR (LyXParagraph::TeXOnePar) is dummy." << endl;
+
+       if (start_of_appendix) {
+               os << "\\appendix\n";
+               texrow.newline();
+       }
+
+       if (tex_code_break_column && style.isCommand()){
+               os << '\n';
+               texrow.newline();
+       }
+
+       if (pagebreak_top) {
+               os << "\\newpage";
+               further_blank_line = true;
+       }
+       if (added_space_top.kind() != VSpace::NONE) {
+               os << added_space_top.asLatexCommand(current_view->buffer()->params);
+               further_blank_line = true;
+       }
+      
+       if (line_top) {
+               os << "\\lyxline{\\" << getFont(0).latexSize() << '}'
+                  << "\\vspace{-1\\parskip}";
+               further_blank_line = true;
+       }
+
+       if (further_blank_line){
+               os << '\n';
+               texrow.newline();
+       }
+
+       LyXDirection direction = getParDirection();
+       LyXDirection global_direction =
+               current_view->buffer()->params.getDocumentDirection();
+       if (direction != global_direction) {
+               if (direction == LYX_DIR_LEFT_TO_RIGHT)
+                       os << "\\unsethebrew\n";
+               else
+                       os << "\\sethebrew\n";
+               texrow.newline();
+       }
+       
+
+       switch (style.latextype) {
+       case LATEX_COMMAND:
+               os << '\\'
+                  << style.latexname()
+                  << style.latexparam();
+               break;
+       case LATEX_ITEM_ENVIRONMENT:
+               if (bibkey) {
+                       bibkey->Latex(os, false);
+               } else
+                       os << "\\item ";
+               break;
+       case LATEX_LIST_ENVIRONMENT:
+               os << "\\item ";
+               break;
+       default:
+               break;
+       }
+
+       bool need_par = SimpleTeXOnePar(os, texrow);
+       // Spit out footnotes
+       while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE
+              && par->footnoteflag != footnoteflag) {
+               par = par->TeXFootnote(os, texrow,
+                                      foot, foot_texrow, foot_count,
+                                      direction);
+               par->SimpleTeXOnePar(os, texrow);
+               par = par->next;
+       }
+
+       // Make sure that \\par is done with the font of the last
+       // character if this has another size as the default.
+       // This is necessary because LaTeX (and LyX on the screen)
+       // calculates the space between the baselines according
+       // to this font. (Matthias)
+       LyXFont font = getFont(Last() - 1);
+       if (need_par) {
+               if (style.resfont.size() != font.size()) {
+                       os << '\\'
+                          << font.latexSize()
+                          << ' ';
+               }
+               os << "\\par}";
+       } else if (textclasslist.Style(current_view->buffer()->params.textclass,
+                                      GetLayout()).isCommand()){
+               if (style.resfont.size() != font.size()) {
+                       os << '\\'
+                          << font.latexSize()
+                          << ' ';
+               }
+               os << '}';
+       } else if (style.resfont.size() != font.size()){
+               os << "{\\" << font.latexSize() << " \\par}";
+       }
+
+       if (direction != global_direction)
+               if (direction == LYX_DIR_LEFT_TO_RIGHT)
+                       os << "\\sethebrew";
+               else
+                       os << "\\unsethebrew";
+       
+       switch (style.latextype) {
+       case LATEX_ITEM_ENVIRONMENT:
+       case LATEX_LIST_ENVIRONMENT:
+                if (par && (depth < par->depth)) {
+                        os << '\n';
+                        texrow.newline();
+                }
+               break;
+       case LATEX_ENVIRONMENT:
+               // if its the last paragraph of the current environment
+               // skip it otherwise fall through
+               if (par
+                   && (par->layout != layout
+                       || par->depth != depth
+                       || par->pextra_type != pextra_type))
+                       break;
+       default:
+               if (!(footnoteflag != LyXParagraph::NO_FOOTNOTE
+                     && footnotekind != LyXParagraph::FOOTNOTE
+                     && footnotekind != LyXParagraph::MARGIN
+                     && (table
+                         || (par
+                             && par->table)))) {
+                       // don't insert this if we would be adding it
+                       // before or after a table in a float.  This 
+                       // little trick is needed in order to allow
+                       // use of tables in \subfigures or \subtables.
+                       os << '\n';
+                       texrow.newline();
+               }
+       }
+       
+       further_blank_line = false;
+       if (line_bottom) {
+               os << "\\lyxline{\\" << getFont(Last() - 1).latexSize() << '}';
+               further_blank_line = true;
+       }
+
+       if (added_space_bottom.kind() != VSpace::NONE) {
+               os << added_space_bottom.asLatexCommand(current_view->buffer()->params);
+               further_blank_line = true;
+       }
+      
+       if (pagebreak_bottom) {
+               os << "\\newpage";
+               further_blank_line = true;
+       }
+
+       if (further_blank_line){
+               os << '\n';
+               texrow.newline();
+       }
+
+       if (!(footnoteflag != LyXParagraph::NO_FOOTNOTE && par &&
+              par->footnoteflag == LyXParagraph::NO_FOOTNOTE)) {
+               os << '\n';
+               texrow.newline();
+       }
+
+       lyxerr[Debug::LATEX] << "TeXOnePar...done " << par << endl;
+       return par;
+}
+#else
 LyXParagraph * LyXParagraph::TeXOnePar(string & file, TexRow & texrow,
                                       string & foot, TexRow & foot_texrow,
                                       int & foot_count)
@@ -2062,15 +2248,17 @@ LyXParagraph * LyXParagraph::TeXOnePar(string & file, TexRow & texrow,
        lyxerr[Debug::LATEX] << "TeXOnePar...done " << par << endl;
        return par;
 }
+#endif
 
 
 // This one spits out the text of the paragraph
-bool LyXParagraph::SimpleTeXOnePar(string & file, TexRow & texrow)
+#ifdef USE_OSTREAM_ONLY
+bool LyXParagraph::SimpleTeXOnePar(ostream & os, TexRow & texrow)
 {
        lyxerr[Debug::LATEX] << "SimpleTeXOnePar...     " << this << endl;
 
        if (table)
-               return SimpleTeXOneTablePar(file, texrow);
+               return SimpleTeXOneTablePar(os, texrow);
 
        bool return_value = false;
 
@@ -2087,7 +2275,7 @@ bool LyXParagraph::SimpleTeXOnePar(string & file, TexRow & texrow)
                main_body = BeginningOfMainBody();
 
        if (main_body > 0) {
-               file += '[';
+               os << '[';
                basefont = getFont(-2); // Get label font
        } else {
                basefont = getFont(-1); // Get layout font
@@ -2099,17 +2287,17 @@ bool LyXParagraph::SimpleTeXOnePar(string & file, TexRow & texrow)
            && !text.size()
            && !IsDummy()) {
                if (style.isCommand()) {
-                       file += '{';
+                       os << '{';
                        ++column;
                } else if (align != LYX_ALIGN_LAYOUT) {
-                       file += '{';
+                       os << '{';
                        ++column;
                        return_value = true;
                }
        }
  
        // Which font is currently active?
-       LyXFont running_font = basefont;
+       LyXFont running_font(basefont);
        // Do we have an open font change?
        bool open_font = false;
 
@@ -2121,25 +2309,25 @@ bool LyXParagraph::SimpleTeXOnePar(string & file, TexRow & texrow)
                if (i == main_body && !IsDummy()) {
                        if (main_body > 0) {
                                if (open_font) {
-                                       column += running_font.latexWriteEndChanges(file, basefont, basefont);
+                                       column += running_font.latexWriteEndChanges(os, basefont, basefont);
                                        open_font = false;
                                }
                                basefont = getFont(-1); // Now use the layout font
                                running_font = basefont;
-                               file += ']';
+                               os << ']';
                                ++column;
                        }
                        if (style.isCommand()) {
-                               file += '{';
+                               os << '{';
                                ++column;
                        } else if (align != LYX_ALIGN_LAYOUT) {
-                               file += "{\\par";
+                               os << "{\\par";
                                column += 4;
                                return_value = true;
                        }
 
                        if (noindent) {
-                               file += "\\noindent ";
+                               os << "\\noindent ";
                                column += 10;
                        }
                        switch (align) {
@@ -2148,15 +2336,15 @@ bool LyXParagraph::SimpleTeXOnePar(string & file, TexRow & texrow)
                        case LYX_ALIGN_LAYOUT:
                        case LYX_ALIGN_SPECIAL: break;
                        case LYX_ALIGN_LEFT:
-                               file += "\\raggedright ";
+                               os << "\\raggedright ";
                                column+= 13;
                                break;
                        case LYX_ALIGN_RIGHT:
-                               file += "\\raggedleft ";
+                               os << "\\raggedleft ";
                                column+= 12;
                                break;
                        case LYX_ALIGN_CENTER:
-                               file += "\\centering ";
+                               os << "\\centering ";
                                column+= 11;
                                break;
                        }        
@@ -2178,7 +2366,7 @@ bool LyXParagraph::SimpleTeXOnePar(string & file, TexRow & texrow)
                }
                // We end font definition before blanks
                if (!font.equalExceptLatex(running_font) && open_font) {
-                       column += running_font.latexWriteEndChanges(file,
+                       column += running_font.latexWriteEndChanges(os,
                                                                    basefont,
                                                                    (i == main_body-1) ? basefont : font);
                        running_font = basefont;
@@ -2189,7 +2377,7 @@ bool LyXParagraph::SimpleTeXOnePar(string & file, TexRow & texrow)
                if (c == ' '){
                        // Do not print the separation of the optional argument
                        if (i != main_body - 1) {
-                               SimpleTeXBlanks(file, texrow, i,
+                               SimpleTeXBlanks(os, texrow, i,
                                                column, font, style);
                        }
                }
@@ -2197,7 +2385,8 @@ bool LyXParagraph::SimpleTeXOnePar(string & file, TexRow & texrow)
                // Do we need to change font?
                if (!font.equalExceptLatex(running_font)
                    && i != main_body-1) {
-                       column += font.latexWriteStartChanges(file, basefont, last_font);
+                       column += font.latexWriteStartChanges(os, basefont,
+                                                             last_font);
                        running_font = font;
                        open_font = true;
                }
@@ -2207,25 +2396,25 @@ bool LyXParagraph::SimpleTeXOnePar(string & file, TexRow & texrow)
                        // the default in SimpleTeXSpecialChars().
                        if (!style.newline_allowed
                            || font.latex() == LyXFont::ON) {
-                               file += '\n';
+                               os << '\n';
                        } else {
                                if (open_font) {
-                                       column += running_font.latexWriteEndChanges(file, basefont, basefont);
+                                       column += running_font.latexWriteEndChanges(os, basefont, basefont);
                                        open_font = false;
                                }
                                basefont = getFont(-1);
                                running_font = basefont;
                                if (font.family() == 
                                    LyXFont::TYPEWRITER_FAMILY) {
-                                       file += "~";
+                                       os << "~";
                                }
-                               file += "\\\\\n";
+                               os << "\\\\\n";
                        }
                        texrow.newline();
                        texrow.start(this, i + 1);
                        column = 0;
                } else {
-                       SimpleTeXSpecialChars(file, texrow,
+                       SimpleTeXSpecialChars(os, texrow,
                                              font, running_font, basefont,
                                              open_font, style, i, column, c);
                }
@@ -2233,33 +2422,52 @@ bool LyXParagraph::SimpleTeXOnePar(string & file, TexRow & texrow)
 
        // If we have an open font definition, we have to close it
        if (open_font) {
-               running_font.latexWriteEndChanges(file, basefont, basefont);
+               running_font.latexWriteEndChanges(os, basefont, basefont);
        }
 
        // Needed if there is an optional argument but no contents.
        if (main_body > 0 && main_body == size()) {
-               file += "]~";
+               os << "]~";
                return_value = false;
        }
 
        lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
        return return_value;
 }
+#else
+bool LyXParagraph::SimpleTeXOnePar(string & file, TexRow & texrow)
+{
+       lyxerr[Debug::LATEX] << "SimpleTeXOnePar...     " << this << endl;
 
+       if (table)
+               return SimpleTeXOneTablePar(file, texrow);
 
-// This one spits out the text of a table paragraph
-bool LyXParagraph::SimpleTeXOneTablePar(string & file, TexRow & texrow)
-{
-       lyxerr[Debug::LATEX] << "SimpleTeXOneTablePar...     " << this << endl;
-   
        bool return_value = false;
 
-       LyXLayout const & style = 
+       LyXLayout const & style =
                textclasslist.Style(current_view->buffer()->params.textclass,
                                    GetLayout());
+       LyXFont basefont, last_font;
+
+       // Maybe we have to create a optional argument.
+       size_type main_body;
+       if (style.labeltype != LABEL_MANUAL)
+               main_body = 0;
+       else
+               main_body = BeginningOfMainBody();
+
+       if (main_body > 0) {
+               file += '[';
+               basefont = getFont(-2); // Get label font
+       } else {
+               basefont = getFont(-1); // Get layout font
+       }
+
        int column = 0;
-       if (!IsDummy()) { // it is dummy if it is in a float!!!
+
+       if (main_body >= 0
+           && !text.size()
+           && !IsDummy()) {
                if (style.isCommand()) {
                        file += '{';
                        ++column;
@@ -2268,61 +2476,388 @@ bool LyXParagraph::SimpleTeXOneTablePar(string & file, TexRow & texrow)
                        ++column;
                        return_value = true;
                }
-               if (noindent) {
-                       file += "\\noindent ";
-                       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;
-                       break;
-               case LYX_ALIGN_RIGHT:
-                       file += "\\raggedleft ";
-                       column+= 12;
-                       break;
-               case LYX_ALIGN_CENTER:
-                       file += "\\centering ";
-                       column+= 11;
-                       break;
-               }
        }
-
-       LyXFont basefont = getFont(-1); // Get layout font
        // Which font is currently active?
        LyXFont running_font = basefont;
-       LyXFont last_font;
        // Do we have an open font change?
        bool open_font = false;
-       int current_cell_number = -1;
-       int tmp = table->TexEndOfCell(file, current_cell_number);
-       for (; tmp > 0 ; --tmp)
-               texrow.newline();
-       
+
        texrow.start(this, 0);
 
        for (size_type i = 0; i < size(); ++i) {
-               char c = GetChar(i);
-               if (table->IsContRow(current_cell_number + 1)) {
-                       if (c == LyXParagraph::META_NEWLINE)
-                               ++current_cell_number;
-                       continue;
-               }
                ++column;
-               
-               // Fully instantiated font
-               LyXFont font = getFont(i);
-               last_font = running_font;
-
-               // 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 <= size() - 2
+               // First char in paragraph or after label?
+               if (i == main_body && !IsDummy()) {
+                       if (main_body > 0) {
+                               if (open_font) {
+                                       column += running_font.latexWriteEndChanges(file, basefont, basefont);
+                                       open_font = false;
+                               }
+                               basefont = getFont(-1); // Now use the layout font
+                               running_font = basefont;
+                               file += ']';
+                               ++column;
+                       }
+                       if (style.isCommand()) {
+                               file += '{';
+                               ++column;
+                       } else if (align != LYX_ALIGN_LAYOUT) {
+                               file += "{\\par";
+                               column += 4;
+                               return_value = true;
+                       }
+
+                       if (noindent) {
+                               file += "\\noindent ";
+                               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;
+                               break;
+                       case LYX_ALIGN_RIGHT:
+                               file += "\\raggedleft ";
+                               column+= 12;
+                               break;
+                       case LYX_ALIGN_CENTER:
+                               file += "\\centering ";
+                               column+= 11;
+                               break;
+                       }        
+               }
+
+               int c = GetChar(i);
+
+               // Fully instantiated font
+               LyXFont font = getFont(i);
+               last_font = running_font;
+
+               // 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 <= size() - 2 
+                   && !getFont(i+1).equalExceptLatex(running_font) 
+                   && !getFont(i+1).equalExceptLatex(font)) {
+                       font = getFont(i + 1);
+               }
+               // We end font definition before blanks
+               if (!font.equalExceptLatex(running_font) && open_font) {
+                       column += running_font.latexWriteEndChanges(file,
+                                                                   basefont,
+                                                                   (i == main_body-1) ? basefont : font);
+                       running_font = basefont;
+                       open_font = false;
+               }
+
+               // Blanks are printed before start of fontswitch
+               if (c == ' '){
+                       // Do not print the separation of the optional argument
+                       if (i != main_body - 1) {
+                               SimpleTeXBlanks(file, texrow, i,
+                                               column, font, style);
+                       }
+               }
+
+               // Do we need to change font?
+               if (!font.equalExceptLatex(running_font)
+                   && i != main_body-1) {
+                       column += font.latexWriteStartChanges(file, basefont, last_font);
+                       running_font = font;
+                       open_font = true;
+               }
+
+               if (c == LyXParagraph::META_NEWLINE) {
+                       // newlines are handled differently here than
+                       // the default in SimpleTeXSpecialChars().
+                       if (!style.newline_allowed
+                           || font.latex() == LyXFont::ON) {
+                               file += '\n';
+                       } else {
+                               if (open_font) {
+                                       column += running_font.latexWriteEndChanges(file, basefont, basefont);
+                                       open_font = false;
+                               }
+                               basefont = getFont(-1);
+                               running_font = basefont;
+                               if (font.family() == 
+                                   LyXFont::TYPEWRITER_FAMILY) {
+                                       file += "~";
+                               }
+                               file += "\\\\\n";
+                       }
+                       texrow.newline();
+                       texrow.start(this, i + 1);
+                       column = 0;
+               } else {
+                       SimpleTeXSpecialChars(file, texrow,
+                                             font, running_font, basefont,
+                                             open_font, style, i, column, c);
+               }
+       }
+
+       // If we have an open font definition, we have to close it
+       if (open_font) {
+               running_font.latexWriteEndChanges(file, basefont, basefont);
+       }
+
+       // Needed if there is an optional argument but no contents.
+       if (main_body > 0 && main_body == size()) {
+               file += "]~";
+               return_value = false;
+       }
+
+       lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
+       return return_value;
+}
+#endif
+
+
+#ifdef USE_OSTREAM_ONLY
+// This one spits out the text of a table paragraph
+bool LyXParagraph::SimpleTeXOneTablePar(ostream & os, TexRow & texrow)
+{
+       lyxerr[Debug::LATEX] << "SimpleTeXOneTablePar...     " << this << endl;
+   
+       bool return_value = false;
+
+       LyXLayout const & style = 
+               textclasslist.Style(current_view->buffer()->params.textclass,
+                                   GetLayout());
+       int column = 0;
+       if (!IsDummy()) { // it is dummy if it is in a float!!!
+               if (style.isCommand()) {
+                       os << '{';
+                       ++column;
+               } else if (align != LYX_ALIGN_LAYOUT) {
+                       os << '{';
+                       ++column;
+                       return_value = true;
+               }
+               if (noindent) {
+                       os << "\\noindent ";
+                       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:
+                       os << "\\raggedright ";
+                       column+= 13;
+                       break;
+               case LYX_ALIGN_RIGHT:
+                       os << "\\raggedleft ";
+                       column+= 12;
+                       break;
+               case LYX_ALIGN_CENTER:
+                       os << "\\centering ";
+                       column+= 11;
+                       break;
+               }
+       }
+
+       LyXFont basefont = getFont(-1); // Get layout font
+       // Which font is currently active?
+       LyXFont running_font = basefont;
+       LyXFont last_font;
+       // Do we have an open font change?
+       bool open_font = false;
+       int current_cell_number = -1;
+       int tmp = table->TexEndOfCell(os, current_cell_number);
+       for (; tmp > 0 ; --tmp)
+               texrow.newline();
+       
+       texrow.start(this, 0);
+
+       for (size_type i = 0; i < size(); ++i) {
+               char c = GetChar(i);
+               if (table->IsContRow(current_cell_number + 1)) {
+                       if (c == LyXParagraph::META_NEWLINE)
+                               ++current_cell_number;
+                       continue;
+               }
+               ++column;
+               
+               // Fully instantiated font
+               LyXFont font = getFont(i);
+               last_font = running_font;
+
+               // 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 <= size() - 2
+                   && getFont(i + 1) != running_font
+                   && getFont(i + 1) != font) {
+                       font = getFont(i + 1);
+               }
+
+               // We end font definition before blanks
+               if (font != running_font && open_font) {
+                       column += running_font.latexWriteEndChanges(os,
+                                                                   basefont,
+                                                                   font);
+                       running_font = basefont;
+                       open_font = false;
+               }
+               // Blanks are printed before start of fontswitch
+               if (c == ' '){
+                       SimpleTeXBlanks(os, texrow, i, column, font, style);
+               }
+               // Do we need to change font?
+               if (font != running_font) {
+                       column += font.latexWriteStartChanges(os, basefont,
+                                                             last_font);
+                       running_font = font;
+                       open_font = true;
+               }
+               // Do we need to turn on LaTeX mode?
+               if (font.latex() != running_font.latex()) {
+                       if (font.latex() == LyXFont::ON
+                           && style.needprotect) {
+                               os << "\\protect ";
+                               column += 9;
+                       }
+               }
+               if (c == LyXParagraph::META_NEWLINE) {
+                       // special case for inside a table
+                       // different from default case in
+                       // SimpleTeXSpecialChars()
+                       if (open_font) {
+                               column += running_font
+                                       .latexWriteEndChanges(os, basefont,
+                                                             basefont);
+                               open_font = false;
+                       }
+                       basefont = getFont(-1);
+                       running_font = basefont;
+                       ++current_cell_number;
+                       if (table->CellHasContRow(current_cell_number) >= 0) {
+                               TeXContTableRows(os, i + 1,
+                                                current_cell_number,
+                                                column, texrow);
+                       }
+                       // if this cell follow only ContRows till end don't
+                       // put the EndOfCell because it is put after the
+                       // for(...)
+                       if (table->ShouldBeVeryLastCell(current_cell_number)) {
+                               --current_cell_number;
+                               break;
+                       }
+                       int tmp = table->TexEndOfCell(os,
+                                                     current_cell_number);
+                       if (tmp > 0) {
+                               column = 0;
+                       } else if (tmp < 0) {
+                               tmp = -tmp;
+                       }
+                       for (; tmp--;) {
+                               texrow.newline();
+                       }
+                       texrow.start(this, i + 1);
+               } else {
+                       SimpleTeXSpecialChars(os, texrow,
+                                             font, running_font, basefont,
+                                             open_font, style, i, column, c);
+               }
+       }
+
+       // If we have an open font definition, we have to close it
+       if (open_font) {
+               running_font.latexWriteEndChanges(os, basefont, basefont);
+       }
+       ++current_cell_number;
+       tmp = table->TexEndOfCell(os, current_cell_number);
+       for (; tmp > 0; --tmp)
+               texrow.newline();
+       lyxerr[Debug::LATEX] << "SimpleTeXOneTablePar...done " << this << endl;
+       return return_value;
+}
+#else
+// This one spits out the text of a table paragraph
+bool LyXParagraph::SimpleTeXOneTablePar(string & file, TexRow & texrow)
+{
+       lyxerr[Debug::LATEX] << "SimpleTeXOneTablePar...     " << this << endl;
+   
+       bool return_value = false;
+
+       LyXLayout const & style = 
+               textclasslist.Style(current_view->buffer()->params.textclass,
+                                   GetLayout());
+       int column = 0;
+       if (!IsDummy()) { // it is dummy if it is in a float!!!
+               if (style.isCommand()) {
+                       file += '{';
+                       ++column;
+               } else if (align != LYX_ALIGN_LAYOUT) {
+                       file += '{';
+                       ++column;
+                       return_value = true;
+               }
+               if (noindent) {
+                       file += "\\noindent ";
+                       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;
+                       break;
+               case LYX_ALIGN_RIGHT:
+                       file += "\\raggedleft ";
+                       column+= 12;
+                       break;
+               case LYX_ALIGN_CENTER:
+                       file += "\\centering ";
+                       column+= 11;
+                       break;
+               }
+       }
+
+       LyXFont basefont = getFont(-1); // Get layout font
+       // Which font is currently active?
+       LyXFont running_font = basefont;
+       LyXFont last_font;
+       // Do we have an open font change?
+       bool open_font = false;
+       int current_cell_number = -1;
+       int tmp = table->TexEndOfCell(file, current_cell_number);
+       for (; tmp > 0 ; --tmp)
+               texrow.newline();
+       
+       texrow.start(this, 0);
+
+       for (size_type i = 0; i < size(); ++i) {
+               char c = GetChar(i);
+               if (table->IsContRow(current_cell_number + 1)) {
+                       if (c == LyXParagraph::META_NEWLINE)
+                               ++current_cell_number;
+                       continue;
+               }
+               ++column;
+               
+               // Fully instantiated font
+               LyXFont font = getFont(i);
+               last_font = running_font;
+
+               // 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 <= size() - 2
                    && getFont(i+1) != running_font && getFont(i+1) != font) {
                        font = getFont(i+1);
                }
@@ -2369,44 +2904,155 @@ bool LyXParagraph::SimpleTeXOneTablePar(string & file, TexRow & texrow)
                                                 current_cell_number,
                                                 column, texrow);
                        }
-                       // if this cell follow only ContRows till end don't
-                       // put the EndOfCell because it is put after the
-                       // for(...)
-                       if (table->ShouldBeVeryLastCell(current_cell_number)) {
-                               --current_cell_number;
-                               break;
+                       // if this cell follow only ContRows till end don't
+                       // put the EndOfCell because it is put after the
+                       // for(...)
+                       if (table->ShouldBeVeryLastCell(current_cell_number)) {
+                               --current_cell_number;
+                               break;
+                       }
+                       int tmp = table->TexEndOfCell(file,
+                                                     current_cell_number);
+                       if (tmp > 0) {
+                               column = 0;
+                       } else if (tmp < 0) {
+                               tmp = -tmp;
+                       }
+                       for (; tmp--;) {
+                               texrow.newline();
+                       }
+                       texrow.start(this, i + 1);
+               } else {
+                       SimpleTeXSpecialChars(file, texrow,
+                                             font, running_font, basefont,
+                                             open_font, style, i, column, c);
+               }
+       }
+
+       // If we have an open font definition, we have to close it
+       if (open_font) {
+               running_font.latexWriteEndChanges(file, basefont, basefont);
+       }
+       ++current_cell_number;
+       tmp = table->TexEndOfCell(file, current_cell_number);
+       for (; tmp > 0; --tmp)
+               texrow.newline();
+       lyxerr[Debug::LATEX] << "SimpleTeXOneTablePar...done " << this << endl;
+       return return_value;
+}
+#endif
+
+
+#ifdef USE_OSTREAM_ONLY
+// This one spits out the text off ContRows in tables
+bool LyXParagraph::TeXContTableRows(ostream & os,
+                                   LyXParagraph::size_type i,
+                                   int current_cell_number,
+                                   int & column, TexRow & texrow)
+{
+       lyxerr[Debug::LATEX] << "TeXContTableRows...     " << this << endl;
+       if (!table)
+               return false;
+    
+       char c;
+   
+       bool return_value = false;
+       LyXLayout const & style =
+               textclasslist.Style(current_view->buffer()->params.textclass,
+                                   GetLayout());
+       LyXFont basefont = getFont(-1); // Get layout font
+       LyXFont last_font;
+       // Which font is currently active?
+       LyXFont running_font = basefont;
+       // Do we have an open font change?
+       bool open_font = false;
+
+       size_type lastpos = i;
+       int cell = table->CellHasContRow(current_cell_number);
+       ++current_cell_number;
+       while(cell >= 0) {
+               // first find the right position
+               i = lastpos;
+               for (; (i < size()) && (current_cell_number<cell); ++i) {
+                       c = GetChar(i);
+                       if (c == LyXParagraph::META_NEWLINE)
+                               ++current_cell_number;
+               }
+               lastpos = i;
+               c = GetChar(i);
+               if (table->Linebreaks(table->FirstVirtualCell(cell))) {
+                       os << " \\\\\n";
+                       texrow.newline();
+                       column = 0;
+               } else if ((c != ' ') && (c != LyXParagraph::META_NEWLINE)) {
+                       os << ' ';
+               }
+
+               for (; i < size()
+                            && (c = GetChar(i)) != LyXParagraph::META_NEWLINE;
+                    ++i) {
+                       ++column;
+
+                       // Fully instantiated font
+                       LyXFont font = getFont(i);
+                       last_font = running_font;
+
+                       // 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 <= size() - 2 
+                           && getFont(i + 1) != running_font
+                           && getFont(i + 1) != font) {
+                               font = getFont(i + 1);
+                       }
+
+                       // We end font definition before blanks
+                       if (font != running_font && open_font) {
+                               column += running_font.latexWriteEndChanges(os, basefont, font);
+                               running_font = basefont;
+                               open_font = false;
+                       }
+                       // Blanks are printed before start of fontswitch
+                       if (c == ' '){
+                               SimpleTeXBlanks(os, texrow, i,
+                                               column, font, style);
                        }
-                       int tmp = table->TexEndOfCell(file,
-                                                     current_cell_number);
-                       if (tmp > 0) {
-                               column = 0;
-                       } else if (tmp < 0) {
-                               tmp = -tmp;
+                       // Do we need to change font?
+                       if (font != running_font) {
+                               column +=
+                                       font.latexWriteStartChanges(os,
+                                                                   basefont,
+                                                                   last_font);
+                               running_font = font;
+                               open_font = true;
                        }
-                       for (; tmp--;) {
-                               texrow.newline();
+                       // Do we need to turn on LaTeX mode?
+                       if (font.latex() != running_font.latex()) {
+                               if (font.latex() == LyXFont::ON
+                                   && style.needprotect) {
+                                       os << "\\protect ";
+                                       column += 9;
+                               }
                        }
-                       texrow.start(this, i + 1);
-               } else {
-                       SimpleTeXSpecialChars(file, texrow,
-                                             font, running_font, basefont,
+                       SimpleTeXSpecialChars(os, texrow, font,
+                                             running_font, basefont,
                                              open_font, style, i, column, c);
                }
+               // If we have an open font definition, we have to close it
+               if (open_font) {
+                       running_font.latexWriteEndChanges(os, basefont,
+                                                         basefont);
+                       open_font = false;
+               }
+               basefont = getFont(-1);
+               running_font = basefont;
+               cell = table->CellHasContRow(current_cell_number);
        }
-
-       // If we have an open font definition, we have to close it
-       if (open_font) {
-               running_font.latexWriteEndChanges(file, basefont, basefont);
-       }
-       ++current_cell_number;
-       tmp = table->TexEndOfCell(file, current_cell_number);
-       for (; tmp > 0; --tmp)
-               texrow.newline();
-       lyxerr[Debug::LATEX] << "SimpleTeXOneTablePar...done " << this << endl;
+       lyxerr[Debug::LATEX] << "TeXContTableRows...done " << this << endl;
        return return_value;
 }
-
-
+#else
 // This one spits out the text off ContRows in tables
 bool LyXParagraph::TeXContTableRows(string & file,
                                    LyXParagraph::size_type i,
@@ -2489,102 +3135,279 @@ bool LyXParagraph::TeXContTableRows(string & file,
                                running_font = font;
                                open_font = true;
                        }
-                       // Do we need to turn on LaTeX mode?
-                       if (font.latex() != running_font.latex()) {
-                               if (font.latex() == LyXFont::ON
-                                   && style.needprotect)
-                                       {
-                                               file += "\\protect ";
-                                               column += 9;
-                                       }
+                       // Do we need to turn on LaTeX mode?
+                       if (font.latex() != running_font.latex()) {
+                               if (font.latex() == LyXFont::ON
+                                   && style.needprotect)
+                                       {
+                                               file += "\\protect ";
+                                               column += 9;
+                                       }
+                       }
+                       SimpleTeXSpecialChars(file, texrow, font,
+                                             running_font, basefont,
+                                             open_font, style, i, column, c);
+               }
+               // If we have an open font definition, we have to close it
+               if (open_font) {
+                       running_font.latexWriteEndChanges(file, basefont, basefont);
+                       open_font = false;
+               }
+               basefont = getFont(-1);
+               running_font = basefont;
+               cell = table->CellHasContRow(current_cell_number);
+       }
+       lyxerr[Debug::LATEX] << "TeXContTableRows...done " << this << endl;
+       return return_value;
+}
+#endif
+
+
+bool LyXParagraph::linuxDocConvertChar(char c, string & sgml_string)
+{
+       bool retval = false;
+       switch (c) {
+       case LyXParagraph::META_HFILL:
+               sgml_string.clear();
+               break;
+#if 0
+       case LyXParagraph::META_PROTECTED_SEPARATOR: 
+               sgml_string = ' ';
+               break;
+#endif
+       case LyXParagraph::META_NEWLINE:
+               sgml_string = '\n';
+               break;
+       case '&': 
+               sgml_string = "&amp;";
+               break;
+       case '<': 
+               sgml_string = "&lt;"; 
+               break;
+       case '>':
+               sgml_string = "&gt;"; 
+               break;
+       case '$': 
+               sgml_string = "&dollar;"; 
+               break;
+       case '#': 
+               sgml_string = "&num;";
+               break;
+       case '%': 
+               sgml_string = "&percnt;";
+               break;
+       case '[': 
+               sgml_string = "&lsqb;";
+               break;
+       case ']': 
+               sgml_string = "&rsqb;";
+               break;
+       case '{': 
+               sgml_string = "&lcub;";
+               break;
+       case '}': 
+               sgml_string = "&rcub;";
+               break;
+       case '~': 
+               sgml_string = "&tilde;";
+               break;
+       case '"': 
+               sgml_string = "&quot;";
+               break;
+       case '\\': 
+               sgml_string = "&bsol;";
+               break;
+       case ' ':
+               retval = true;
+               sgml_string = ' ';
+               break;
+       case '\0': // Ignore :-)
+               sgml_string.clear();
+               break;
+       default:
+               sgml_string = c;
+               break;
+       }
+       return retval;
+}
+
+
+#ifdef USE_OSTREAM_ONLY
+void LyXParagraph::SimpleDocBookOneTablePar(ostream & os, string & extra,
+                                           int & desc_on, int depth) 
+{
+       if (!table) return;
+       lyxerr[Debug::LATEX] << "SimpleDocbookOneTablePar... " << this << endl;
+       int column = 0;
+       LyXFont font1, font2;
+       char c;
+       Inset * inset;
+       size_type main_body;
+       bool emph_flag = false;
+       
+       LyXLayout const & style =
+               textclasslist.Style(current_view->buffer()->params.textclass,
+                                   GetLayout());
+       
+       if (style.labeltype != LABEL_MANUAL)
+               main_body = 0;
+       else
+               main_body = BeginningOfMainBody();
+       
+       // Gets paragraph main font.
+       if (main_body > 0)
+               font1 = style.labelfont;
+       else
+               font1 = style.font;
+       
+       int char_line_count = depth;
+       os << newlineAndDepth(depth);
+       if (footnoteflag == LyXParagraph::NO_FOOTNOTE) {
+               os << "<INFORMALTABLE>"
+                  << newlineAndDepth(++depth);
+       }
+       int current_cell_number = -1;
+       int tmp = table->DocBookEndOfCell(os, current_cell_number, depth);
+       
+       // Parsing main loop.
+       for (size_type i = 0; i < size(); ++i) {
+               c = GetChar(i);
+               if (table->IsContRow(current_cell_number+1)) {
+                       if (c == LyXParagraph::META_NEWLINE)
+                               ++current_cell_number;
+                       continue;
+               }
+               ++column;
+               
+               // Fully instantiated font
+               font2 = getFont(i);
+               
+               // Handle <emphasis> tag.
+               if (font1.emph() != font2.emph() && i) {
+                       if (font2.emph() == LyXFont::ON) {
+                               os << "<emphasis>";
+                               emph_flag= true;
+                       } else if (emph_flag) {
+                               os << "</emphasis>";
+                               emph_flag= false;
+                       }
+               }
+               if (c == LyXParagraph::META_NEWLINE) {
+                       // We have only to control for emphasis open here!
+                       if (emph_flag) {
+                               os << "</emphasis>";
+                               emph_flag= false;
+                       }
+                       font1 = font2 = getFont(-1);
+                       ++current_cell_number;
+                       if (table->CellHasContRow(current_cell_number) >= 0) {
+                               DocBookContTableRows(os, extra, desc_on, i + 1,
+                                                    current_cell_number,
+                                                    column);
+                       }
+                       // if this cell follow only ContRows till end don't
+                       // put the EndOfCell because it is put after the
+                       // for(...)
+                       if (table->ShouldBeVeryLastCell(current_cell_number)) {
+                               --current_cell_number;
+                               break;
+                       }
+                       tmp = table->DocBookEndOfCell(os,
+                                                     current_cell_number,
+                                                     depth);
+                       
+                       if (tmp > 0)
+                               column = 0;
+               } else if (c == LyXParagraph::META_INSET) {
+                       inset = GetInset(i);
+#ifdef HAVE_SSTREAM
+                       ostringstream ost;
+                       inset->DocBook(ost);
+                       string tmp_out = ost.str().c_str();
+#else
+                       ostrstream ost;
+                       inset->DocBook(ost);
+                       ost << '\0';
+                       char * ctmp = ost.str();
+                       string tmp_out(ctmp);
+                       delete [] ctmp;
+#endif
+                       //
+                       // This code needs some explanation:
+                       // Two insets are treated specially
+                       //   label if it is the first element in a
+                       //   command paragraph
+                       //         desc_on == 3
+                       //   graphics inside tables or figure floats
+                       //   can't go on
+                       //   title (the equivalente in latex for this
+                       //   case is caption
+                       //   and title should come first
+                       //         desc_on == 4
+                       //
+                       if(desc_on != 3 || i != 0) {
+                               if(tmp_out[0] == '@') {
+                                       if(desc_on == 4)
+                                               extra += frontStrip(tmp_out,
+                                                                   '@');
+                                       else
+                                               os << frontStrip(tmp_out,
+                                                                '@');
+                               } else
+                                       os << tmp_out;
+                       }
+               } else if (font2.latex() == LyXFont::ON) {
+                       // "TeX"-Mode on == > SGML-Mode on.
+                       if (c != '\0')
+                               os << c;
+                       ++char_line_count;
+               } else {
+                       string sgml_string;
+                       if (linuxDocConvertChar(c, sgml_string) 
+                           && !style.free_spacing) {
+                               // in freespacing mode, spaces are
+                               // non-breaking characters
+                               // char is ' '
+                               if (desc_on == 1) {
+                                       ++char_line_count;
+                                       os << '\n'
+                                          << "</term><listitem><para>";
+                                       desc_on = 2;
+                               } else  {
+                                       os << c;
+                               }
+                       } else {
+                               os << sgml_string;
                        }
-                       SimpleTeXSpecialChars(file, texrow, font,
-                                             running_font, basefont,
-                                             open_font, style, i, column, c);
-               }
-               // If we have an open font definition, we have to close it
-               if (open_font) {
-                       running_font.latexWriteEndChanges(file, basefont, basefont);
-                       open_font = false;
                }
-               basefont = getFont(-1);
-               running_font = basefont;
-               cell = table->CellHasContRow(current_cell_number);
+               font1 = font2;
+       }
+       
+       // Needed if there is an optional argument but no contents.
+       if (main_body > 0 && main_body == size()) {
+               font1 = style.font;
        }
-       lyxerr[Debug::LATEX] << "TeXContTableRows...done " << this << endl;
-       return return_value;
-}
-
 
-bool LyXParagraph::linuxDocConvertChar(char c, string & sgml_string)
-{
-       bool retval = false;
-       switch (c) {
-       case LyXParagraph::META_HFILL:
-               sgml_string.clear();
-               break;
-#if 0
-       case LyXParagraph::META_PROTECTED_SEPARATOR: 
-               sgml_string = ' ';
-               break;
-#endif
-       case LyXParagraph::META_NEWLINE:
-               sgml_string = '\n';
-               break;
-       case '&': 
-               sgml_string = "&amp;";
-               break;
-       case '<': 
-               sgml_string = "&lt;"; 
-               break;
-       case '>':
-               sgml_string = "&gt;"; 
-               break;
-       case '$': 
-               sgml_string = "&dollar;"; 
-               break;
-       case '#': 
-               sgml_string = "&num;";
-               break;
-       case '%': 
-               sgml_string = "&percnt;";
-               break;
-       case '[': 
-               sgml_string = "&lsqb;";
-               break;
-       case ']': 
-               sgml_string = "&rsqb;";
-               break;
-       case '{': 
-               sgml_string = "&lcub;";
-               break;
-       case '}': 
-               sgml_string = "&rcub;";
-               break;
-       case '~': 
-               sgml_string = "&tilde;";
-               break;
-       case '"': 
-               sgml_string = "&quot;";
-               break;
-       case '\\': 
-               sgml_string = "&bsol;";
-               break;
-       case ' ':
-               retval = true;
-               sgml_string = ' ';
-               break;
-       case '\0': // Ignore :-)
-               sgml_string.clear();
-               break;
-       default:
-               sgml_string = c;
+       if (emph_flag) {
+               os << "</emphasis>";
+       }
+       
+       ++current_cell_number;
+       tmp = table->DocBookEndOfCell(os, current_cell_number, depth);
+       // Resets description flag correctly.
+       switch(desc_on){
+       case 1:
+               // <term> not closed...
+               os << "</term>";
                break;
        }
-       return retval;
+       if (footnoteflag == LyXParagraph::NO_FOOTNOTE)
+               os << "</INFORMALTABLE>";
+       os << '\n';
+       lyxerr[Debug::LATEX] << "SimpleDocbookOneTablePar...done "
+                            << this << endl;
 }
-
-
+#else
 void LyXParagraph::SimpleDocBookOneTablePar(string & file, string & extra,
                                            int & desc_on, int depth) 
 {
@@ -2595,7 +3418,6 @@ void LyXParagraph::SimpleDocBookOneTablePar(string & file, string & extra,
        char c;
        Inset * inset;
        size_type main_body;
-       string emph = "emphasis";
        bool emph_flag = false;
        
        LyXLayout const & style =
@@ -2673,8 +3495,23 @@ void LyXParagraph::SimpleDocBookOneTablePar(string & file, string & extra,
                                column = 0;
                } else if (c == LyXParagraph::META_INSET) {
                        inset = GetInset(i);
+#ifdef USE_OSTREAM_ONLY
+#ifdef HAVE_SSTREAM
+                       ostringstream ost;
+                       inset->DocBook(ost);
+                       string tmp_out = ost.str().c_str();
+#else
+                       ostrstream ost;
+                       inset->DocBook(ost);
+                       ost << '\0';
+                       char * ctmp = ost.str();
+                       string tmp_out(ctmp);
+                       delete [] ctmp;
+#endif
+#else
                        string tmp_out;
                        inset->DocBook(tmp_out);
+#endif
                        //
                        // This code needs some explanation:
                        // Two insets are treated specially
@@ -2744,14 +3581,162 @@ void LyXParagraph::SimpleDocBookOneTablePar(string & file, string & extra,
                file += "</term>";
                break;
        }
-       if (footnoteflag == LyXParagraph::NO_FOOTNOTE)
-               file += "</INFORMALTABLE>";
-       file += '\n';
-       lyxerr[Debug::LATEX] << "SimpleDocbookOneTablePar...done "
-                            << this << endl;
+       if (footnoteflag == LyXParagraph::NO_FOOTNOTE)
+               file += "</INFORMALTABLE>";
+       file += '\n';
+       lyxerr[Debug::LATEX] << "SimpleDocbookOneTablePar...done "
+                            << this << endl;
+}
+#endif
+
+
+#ifdef USE_OSTREAM_ONLY
+void LyXParagraph::DocBookContTableRows(ostream & os, string & extra,
+                                        int & desc_on,
+                                       LyXParagraph::size_type i,
+                                        int current_cell_number, int &column) 
+
+{
+       if (!table) return;
+       
+       lyxerr[Debug::LATEX] << "DocBookContTableRows... " << this << endl;
+
+       LyXFont font2;
+       char c;
+       Inset * inset;
+       //string emph = "emphasis";
+       bool emph_flag = false;
+       int char_line_count = 0;
+       
+       LyXLayout const & style =
+               textclasslist.Style(current_view->buffer()->params.textclass,
+                                   GetLayout());
+       
+       size_type main_body;
+       if (style.labeltype != LABEL_MANUAL)
+               main_body = 0;
+       else
+               main_body = BeginningOfMainBody();
+       
+       // Gets paragraph main font.
+       LyXFont font1;
+       if (main_body > 0)
+               font1 = style.labelfont;
+       else
+               font1 = style.font;
+       
+       size_type lastpos = i;
+       int cell = table->CellHasContRow(current_cell_number);
+       ++current_cell_number;
+       while(cell >= 0) {
+               // first find the right position
+               i = lastpos;
+               for (; i < size() && current_cell_number < cell; ++i) {
+                       c = GetChar(i);
+                       if (c == LyXParagraph::META_NEWLINE)
+                               ++current_cell_number;
+               }
+               lastpos = 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))) {
+//                     file += " \\\\\n";
+//                     column = 0;
+//             } else
+               if ((c != ' ') && (c != LyXParagraph::META_NEWLINE)) {
+                       os << ' ';
+               }
+
+               for (; i < size()
+                            && (c = GetChar(i)) != LyXParagraph::META_NEWLINE;
+                    ++i) {
+                       ++column;
+                       
+                       // Fully instantiated font
+                       font2 = getFont(i);
+                       
+                       // Handle <emphasis> tag.
+                       if (font1.emph() != font2.emph() && i) {
+                               if (font2.emph() == LyXFont::ON) {
+                                       os << "<emphasis>";
+                                       emph_flag= true;
+                               } else if (emph_flag) {
+                                       os << "</emphasis>";
+                                       emph_flag= false;
+                               }
+                       }
+                       if (c == LyXParagraph::META_INSET) {
+                               inset = GetInset(i);
+#ifdef HAVE_SSTREAM
+                               ostringstream ost;
+                               inset->DocBook(ost);
+                               string tmp_out = ost.str().c_str();
+#else
+                               ostrstream ost;
+                               inset->DocBook(ost);
+                               ost << '\0';
+                               char * ctmp = ost.str();
+                               string tmp_out(ctmp);
+                               delete [] ctmp;
+#endif
+                               //
+                               // This code needs some explanation:
+                               // Two insets are treated specially
+                               //   label if it is the first element in a
+                               //   command paragraph
+                               //       desc_on == 3
+                               //   graphics inside tables or figure floats
+                               //   can't go on title (the equivalente in
+                               //   latex for this case is caption and title
+                               //   should come first
+                               //       desc_on == 4
+                               //
+                               if(desc_on != 3 || i != 0) {
+                                       if(tmp_out[0] == '@') {
+                                               if(desc_on == 4)
+                                                       extra += frontStrip(tmp_out, '@');
+                                               else
+                                                       os << frontStrip(tmp_out, '@');
+                                       } else
+                                               os << tmp_out;
+                               }
+                       } else if (font2.latex() == LyXFont::ON) {
+                               // "TeX"-Mode on == > SGML-Mode on.
+                               if (c!= '\0')
+                                       os << c;
+                               ++char_line_count;
+                       } else {
+                               string sgml_string;
+                               if (linuxDocConvertChar(c, sgml_string) 
+                                   && !style.free_spacing) {
+                                       // in freespacing mode, spaces are
+                                       // non-breaking characters
+                                       // char is ' '
+                                       if (desc_on == 1) {
+                                               ++char_line_count;
+                                               os << '\n'
+                                                  << "</term><listitem><para>";
+                                               desc_on = 2;
+                                       } else  {
+                                               os << c;
+                                       }
+                               } else {
+                                       os << sgml_string;
+                               }
+                       }
+               }
+               // we have only to control for emphasis open here!
+               if (emph_flag) {
+                       os << "</emphasis>";
+                       emph_flag= false;
+               }
+               font1 = font2 = getFont(-1);
+               cell = table->CellHasContRow(current_cell_number);
+       }
+       lyxerr[Debug::LATEX] << "DocBookContTableRows...done " << this << endl;
 }
-
-
+#else
 void LyXParagraph::DocBookContTableRows(string & file, string & extra,
                                         int & desc_on,
                                        LyXParagraph::size_type i,
@@ -2765,7 +3750,7 @@ void LyXParagraph::DocBookContTableRows(string & file, string & extra,
        LyXFont font2;
        char c;
        Inset * inset;
-       string emph= "emphasis";
+       //string emph = "emphasis";
        bool emph_flag= false;
        int char_line_count= 0;
        
@@ -2829,8 +3814,23 @@ void LyXParagraph::DocBookContTableRows(string & file, string & extra,
                        }
                        if (c == LyXParagraph::META_INSET) {
                                inset = GetInset(i);
+#ifdef USE_OSTREAM_ONLY
+#ifdef HAVE_SSTREAM
+                               ostringstream ost;
+                               inset->DocBook(ost);
+                               string tmp_out = ost.str().c_str();
+#else
+                               ostrstream ost;
+                               inset->DocBook(ost);
+                               ost << '\0';
+                               char * ctmp = ost.str();
+                               string tmp_out(ctmp);
+                               delete [] ctmp;
+#endif
+#else
                                string tmp_out;
                                inset->DocBook(tmp_out);
+#endif
                                //
                                // This code needs some explanation:
                                // Two insets are treated specially
@@ -2887,8 +3887,51 @@ void LyXParagraph::DocBookContTableRows(string & file, string & extra,
        }
        lyxerr[Debug::LATEX] << "DocBookContTableRows...done " << this << endl;
 }
+#endif
 
 
+#ifdef USE_OSTREAM_ONLY
+void LyXParagraph::SimpleTeXBlanks(ostream & os, TexRow & texrow,
+                                  LyXParagraph::size_type const i,
+                                  int & column, LyXFont const & font,
+                                  LyXLayout const & style)
+{
+       if (column > tex_code_break_column
+           && i 
+           && GetChar(i - 1) != ' '
+           && (i < size() - 1)
+           // 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
+           // In typewriter mode, we want to avoid 
+           // ! . ? : at the end of a line
+           && !(font.family() == LyXFont::TYPEWRITER_FAMILY
+                && (GetChar(i-1) == '.'
+                    || GetChar(i-1) == '?' 
+                    || GetChar(i-1) == ':'
+                    || GetChar(i-1) == '!'))) {
+               if (tex_code_break_column == 0) {
+                       // in batchmode we need LaTeX to still
+                       // see it as a space not as an extra '\n'
+                       os << " %\n";
+               } else {
+                       os << '\n';
+               }
+               texrow.newline();
+               texrow.start(this, i + 1);
+               column = 0;
+       } else if (font.latex() == LyXFont::OFF) {
+               if (style.free_spacing) {
+                       os << '~';
+               } else {
+                       os << ' ';
+               }
+       }
+}
+#else
 void LyXParagraph::SimpleTeXBlanks(string & file, TexRow & texrow,
                                   LyXParagraph::size_type const i,
                                   int & column, LyXFont const & font,
@@ -2929,8 +3972,269 @@ void LyXParagraph::SimpleTeXBlanks(string & file, TexRow & texrow,
                }
        }
 }
-
-
+#endif
+
+
+#ifdef USE_OSTREAM_ONLY
+void LyXParagraph::SimpleTeXSpecialChars(ostream & os, TexRow & texrow,
+                                        LyXFont & font,
+                                        LyXFont & running_font,
+                                        LyXFont & basefont,
+                                        bool & open_font,
+                                        LyXLayout const & style,
+                                        LyXParagraph::size_type & i,
+                                        int & column, char const c)
+{
+       // 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 LyXParagraph::META_INSET: {
+               Inset * inset = GetInset(i);
+               if (inset) {
+                       bool close = false;
+                       int len = os.tellp();
+                       if ((inset->LyxCode() == Inset::GRAPHICS_CODE
+                            || inset->LyxCode() == Inset::MATH_CODE
+                            || inset->LyxCode() == Inset::URL_CODE)
+                           && running_font.getFontDirection()
+                           == LYX_DIR_RIGHT_TO_LEFT) {
+                               os << "\\L{";
+                               close = true;
+                       }
+
+                       int tmp = inset->Latex(os, style.isCommand());
+
+                       if (close)
+                               os << "}";
+                       
+                       if (tmp) {
+                               column = 0;
+                       } else {
+                               column += os.tellp() - len;
+                       }
+                       for (; tmp--;) {
+                               texrow.newline();
+                       }
+               }
+       }
+       break;
+
+       case LyXParagraph::META_NEWLINE:
+               if (open_font) {
+                       column += running_font.latexWriteEndChanges(os,
+                                                                   basefont,
+                                                                   basefont);
+                       open_font = false;
+               }
+               basefont = getFont(-1);
+               running_font = basefont;
+               break;
+
+       case LyXParagraph::META_HFILL: 
+               os << "\\hfill{}";
+               column += 7;
+               break;
+
+       default:
+               // And now for the special cases within each mode
+               // Are we in LaTeX mode?
+               if (font.latex() == LyXFont::ON) {
+                       // at present we only have one option
+                       // but I'll leave it as a switch statement
+                       // so its simpler to extend. (ARRae)
+                       switch (c) {
+#if 0
+                       case LyXParagraph::META_PROTECTED_SEPARATOR: 
+                               os << ' ';
+                               break;
+#endif
+                       default:
+                               // make sure that we will not print
+                               // error generating chars to the tex
+                               // file. This test would not be needed
+                               // if it were done in the buffer
+                               // itself.
+                               if (c != '\0') {
+                                       os << c;
+                               }
+                               break;
+                       }
+               } else {
+                       // Plain mode (i.e. not LaTeX)
+                       switch (c) {
+#if 0
+                       case LyXParagraph::META_PROTECTED_SEPARATOR: 
+                               os << '~';
+                               break;
+#endif
+                       case '\\': 
+                               os << "\\textbackslash{}";
+                               column += 15;
+                               break;
+               
+                       case '°': case '±': case '²': case '³':  
+                       case '×': case '÷': case '¹': case 'ª':
+                       case 'º': case '¬': case 'µ':
+                               if (current_view->buffer()->params.inputenc == "latin1") {
+                                       os << "\\ensuremath{"
+                                          << c
+                                          << '}';
+                                       column += 13;
+                               } else {
+                                       os << c;
+                               }
+                               break;
+
+                       case '|': case '<': case '>':
+                               // In T1 encoding, these characters exist
+                               if (lyxrc->fontenc == "T1") {
+                                       os << c;
+                                       //... but we should avoid ligatures
+                                       if ((c == '>' || c == '<')
+                                           && i <= size() - 2
+                                           && GetChar(i + 1) == c){
+                                               os << "\\textcompwordmark{}";
+                                               column += 19;
+                                       }
+                                       break;
+                               }
+                               // Typewriter font also has them
+                               if (font.family() == LyXFont::TYPEWRITER_FAMILY) {
+                                       os << c;
+                                       break;
+                               } 
+                               // Otherwise, we use what LaTeX
+                               // provides us.
+                               switch(c) {
+                               case '<':
+                                       os << "\\textless{}";
+                                       column += 10;
+                                       break;
+                               case '>':
+                                       os << "\\textgreater{}";
+                                       column += 13;
+                                       break;
+                               case '|':
+                                       os << "\\textbar{}";
+                                       column += 9;
+                                       break;
+                               }
+                               break;
+
+                       case '-': // "--" in Typewriter mode -> "-{}-"
+                               if (i <= size() - 2
+                                   && GetChar(i + 1) == '-'
+                                   && font.family() == LyXFont::TYPEWRITER_FAMILY) {
+                                       os << "-{}";
+                                       column += 2;
+                               } else {
+                                       os << '-';
+                               }
+                               break;
+
+                       case '\"': 
+                               os << "\\char`\\\"{}";
+                               column += 9;
+                               break;
+
+                       case '£':
+                               if (current_view->buffer()->params.inputenc == "default") {
+                                       os << "\\pounds{}";
+                                       column += 8;
+                               } else {
+                                       os << c;
+                               }
+                               break;
+
+                       case '$': case '&':
+                       case '%': case '#': case '{':
+                       case '}': case '_':
+                               os << '\\' << c;
+                               column += 1;
+                               break;
+
+                       case '~':
+                               os << "\\textasciitilde{}";
+                               column += 16;
+                               break;
+
+                       case '^':
+                               os << "\\textasciicircum{}";
+                               column += 17;
+                               break;
+
+                       case '*': case '[': case ']':
+                               // avoid being mistaken for optional arguments
+                               os << '{' << c << '}';
+                               column += 2;
+                               break;
+
+                       case ' ':
+                               // Blanks are printed before font switching.
+                               // Sure? I am not! (try nice-latex)
+                               // I am sure it's correct. LyX might be smarter
+                               // in the future, but for now, nothing wrong is
+                               // written. (Asger)
+                               break;
+
+                       default:
+                               /* idea for labels --- begin*/
+                               // Check for "LyX"
+                               if (c ==  'L'
+                                   && i <= size() - 3
+                                   && font.family() != LyXFont::TYPEWRITER_FAMILY
+                                   && GetChar(i + 1) == 'y'
+                                   && GetChar(i + 2) == 'X') {
+                                       os << "\\LyX{}";
+                                       i += 2;
+                                       column += 5;
+                               }
+                               // Check for "TeX"
+                               else if (c == 'T'
+                                        && i <= size() - 3
+                                        && font.family() != LyXFont::TYPEWRITER_FAMILY
+                                        && GetChar(i + 1) == 'e'
+                                        && GetChar(i + 2) == 'X') {
+                                       os << "\\TeX{}";
+                                       i += 2;
+                                       column += 5;
+                               }
+                               // Check for "LaTeX2e"
+                               else if (c == 'L'
+                                        && i <= size() - 7
+                                        && 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') {
+                                       os << "\\LaTeXe{}";
+                                       i += 6;
+                                       column += 8;
+                               }
+                               // Check for "LaTeX"
+                               else if (c == 'L'
+                                        && i <= size() - 5
+                                        && font.family() != LyXFont::TYPEWRITER_FAMILY
+                                        && GetChar(i + 1) == 'a'
+                                        && GetChar(i + 2) == 'T'
+                                        && GetChar(i + 3) == 'e'
+                                        && GetChar(i + 4) == 'X') {
+                                       os << "\\LaTeX{}";
+                                       i += 4;
+                                       column += 7;
+                                       /* idea for labels --- end*/ 
+                               } else if (c != '\0') {
+                                       os << c;
+                               }
+                               break;
+                       }
+               }
+       }
+}
+#else
 void LyXParagraph::SimpleTeXSpecialChars(string & file, TexRow & texrow,
                                         LyXFont & font,
                                         LyXFont & running_font,
@@ -3204,6 +4508,7 @@ void LyXParagraph::SimpleTeXSpecialChars(string & file, TexRow & texrow,
                }
        }
 }
+#endif
 
 
 #if 0
@@ -3325,6 +4630,34 @@ bool LyXParagraph::RoffContTableRows(ostream & os,
 #endif
 
 
+#ifdef USE_OSTREAM_ONLY
+LyXParagraph * LyXParagraph::TeXDeeper(ostream & os, TexRow & texrow,
+                                      ostream & foot, TexRow & foot_texrow,
+                                      int & foot_count)
+{
+       lyxerr[Debug::LATEX] << "TeXDeeper...     " << this << endl;
+       LyXParagraph * par = this;
+
+       while (par && par->depth == depth) {
+               if (par->IsDummy())
+                       lyxerr << "ERROR (LyXParagraph::TeXDeeper)" << endl;
+               if (textclasslist.Style(current_view->buffer()->params.textclass, 
+                                       par->layout).isEnvironment()
+                   || par->pextra_type != PEXTRA_NONE) {
+                       par = par->TeXEnvironment(os, texrow,
+                                                 foot, foot_texrow,
+                                                 foot_count);
+               } else {
+                       par = par->TeXOnePar(os, texrow,
+                                            foot, foot_texrow,
+                                            foot_count);
+               }
+       }
+       lyxerr[Debug::LATEX] << "TeXDeeper...done " << par << endl;
+
+       return par;
+}
+#else
 LyXParagraph * LyXParagraph::TeXDeeper(string & file, TexRow & texrow,
                                       string & foot, TexRow & foot_texrow,
                                       int & foot_count)
@@ -3348,12 +4681,295 @@ LyXParagraph * LyXParagraph::TeXDeeper(string & file, TexRow & texrow,
                                                     foot_count);
                        }
        }
-       lyxerr[Debug::LATEX] << "TeXDeeper...done " << par << endl;
-
-       return par;
+       lyxerr[Debug::LATEX] << "TeXDeeper...done " << par << endl;
+
+       return par;
+}
+#endif
+
+
+#ifdef USE_OSTREAM_ONLY
+LyXParagraph * LyXParagraph::TeXEnvironment(ostream & os, TexRow & texrow,
+                                           ostream & foot,
+                                           TexRow & foot_texrow,
+                                           int & foot_count)
+{
+       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->buffer()->params.paragraph_separation;
+    
+       lyxerr[Debug::LATEX] << "TeXEnvironment...     " << this << endl;
+       if (IsDummy())
+               lyxerr << "ERROR (LyXParagraph::TeXEnvironment)" << endl;
+
+       LyXLayout const & style =
+               textclasslist.Style(current_view->buffer()->params.textclass,
+                                   layout);
+       
+       if (pextra_type == PEXTRA_INDENT) {
+               if (!pextra_width.empty()) {
+                       os << "\\begin{LyXParagraphIndent}{"
+                          << pextra_width << "}\n";
+               } else {
+                       //float ib = atof(pextra_widthp.c_str())/100;
+                       // string can't handle floats at present (971109)
+                       // so I'll do a conversion by hand knowing that
+                       // the limits are 0.0 to 1.0. ARRae.
+                       os << "\\begin{LyXParagraphIndent}{";
+                       switch (pextra_widthp.length()) {
+                       case 3:
+                               os << "1.00";
+                               break;
+                       case 2:
+                               os << "0."
+                                  << pextra_widthp;
+                               break;
+                       case 1:
+                               os << "0.0"
+                                  << pextra_widthp;
+                       }
+                       os << "\\columnwidth}\n";
+               }
+               texrow.newline();
+               eindent_open = true;
+       }
+       if ((pextra_type == PEXTRA_MINIPAGE) && !minipage_open) {
+               if (pextra_hfill && Previous() &&
+                   (Previous()->pextra_type == PEXTRA_MINIPAGE)) {
+                       os << "\\hfill{}\n";
+                       texrow.newline();
+               }
+               if (par_sep == BufferParams::PARSEP_INDENT) {
+                       os << "{\\setlength\\parindent{0pt}\n";
+                       texrow.newline();
+               }
+               os << "\\begin{minipage}";
+               switch(pextra_alignment) {
+               case MINIPAGE_ALIGN_TOP:
+                       os << "[t]";
+                       break;
+               case MINIPAGE_ALIGN_MIDDLE:
+                       os << "[m]";
+                       break;
+               case MINIPAGE_ALIGN_BOTTOM:
+                       os << "[b]";
+                       break;
+               }
+               if (!pextra_width.empty()) {
+                       os << '{' << pextra_width << "}\n";
+               } else {
+                       //float ib = atof(par->pextra_width.c_str())/100;
+                       // string can't handle floats at present
+                       // so I'll do a conversion by hand knowing that
+                       // the limits are 0.0 to 1.0. ARRae.
+                       os << '{';
+                       switch (pextra_widthp.length()) {
+                       case 3:
+                               os << "1.00";
+                               break;
+                       case 2:
+                               os << "0."
+                                  << pextra_widthp;
+                               break;
+                       case 1:
+                               os << "0.0"
+                                  << pextra_widthp;
+                       }
+                       os << "\\columnwidth}\n";
+               }
+               texrow.newline();
+               if (par_sep == BufferParams::PARSEP_INDENT) {
+                       os << "\\setlength\\parindent{\\LyXMinipageIndent}\n";
+                       texrow.newline();
+               }
+               minipage_open = true;
+                minipage_open_depth = depth;
+       }
+
+#ifdef WITH_WARNINGS
+#warning Define FANCY_FOOTNOTE_CODE to re-enable Allan footnote code
+       //I disabled it because it breaks when lists span on several
+       //pages (JMarc)
+#endif
+       if (style.isEnvironment()){
+               if (style.latextype == LATEX_LIST_ENVIRONMENT) {
+#ifdef FANCY_FOOTNOTE_CODE
+                       if (foot_count < 0) {
+                               // flag that footnote[mark][text] should be
+                               // used for any footnotes from now on
+                               foot_count = 0;
+                               foot_this_level = true;
+                       }
+#endif
+                       os << "\\begin{" << style.latexname() << "}{"
+                          << labelwidthstring << "}\n";
+               } else if (style.labeltype == LABEL_BIBLIO) {
+                       // ale970405
+                       os << "\\begin{" << style.latexname() << "}{"
+                          << bibitemWidthest(current_view->painter())
+                          << "}\n";
+               } else if (style.latextype == LATEX_ITEM_ENVIRONMENT) {
+#ifdef FANCY_FOOTNOTE_CODE
+                       if (foot_count < 0) {
+                               // flag that footnote[mark][text] should be
+                               // used for any footnotes from now on
+                               foot_count = 0;
+                               foot_this_level = true;
+                       }
+#endif
+                       os << "\\begin{" << style.latexname() << '}'
+                          << style.latexparam() << '\n';
+               } else 
+                       os << "\\begin{" << style.latexname() << '}'
+                          << style.latexparam() << '\n';
+               texrow.newline();
+       }
+       LyXParagraph * par = this;
+       do {
+               par = par->TeXOnePar(os, texrow,
+                                    foot, foot_texrow, foot_count);
+
+                if (minipage_open && par && !style.isEnvironment() &&
+                    (par->pextra_type == PEXTRA_MINIPAGE) &&
+                    par->pextra_start_minipage) {
+                       os << "\\end{minipage}\n";
+                       texrow.newline();
+                       if (par_sep == BufferParams::PARSEP_INDENT) {
+                               os << "}\n";
+                               texrow.newline();
+                       }
+                       minipage_open = false;
+                }
+               if (par && par->depth > depth) {
+                       if (textclasslist.Style(current_view->buffer()->params.textclass,
+                                               par->layout).isParagraph()
+                           && !par->table
+                           // Thinko!
+                           // How to handle this? (Lgb)
+                           //&& !suffixIs(os, "\n\n")
+                               ) {
+                               // There should be at least one '\n' already
+                               // but we need there to be two for Standard 
+                               // paragraphs that are depth-increment'ed to be
+                               // output correctly.  However, tables can
+                               // also be paragraphs so don't adjust them.
+                               // ARRae
+                               // Thinkee:
+                               // Will it ever harm to have one '\n' too
+                               // many? i.e. that we sometimes will have
+                               // three in a row. (Lgb)
+                               os << '\n';
+                               texrow.newline();
+                       }
+                       par = par->TeXDeeper(os, texrow,
+                                            foot, foot_texrow, foot_count);
+               }
+               if (par && par->layout == layout && par->depth == depth &&
+                   (par->pextra_type == PEXTRA_MINIPAGE) && !minipage_open) {
+                       if (par->pextra_hfill && par->Previous() &&
+                           (par->Previous()->pextra_type == PEXTRA_MINIPAGE)){
+                               os << "\\hfill{}\n";
+                                texrow.newline();
+                        }
+                       if (par_sep == BufferParams::PARSEP_INDENT) {
+                               os << "{\\setlength\\parindent{0pt}\n";
+                               texrow.newline();
+                       }
+                       os << "\\begin{minipage}";
+                       switch(par->pextra_alignment) {
+                       case MINIPAGE_ALIGN_TOP:
+                               os << "[t]";
+                               break;
+                       case MINIPAGE_ALIGN_MIDDLE:
+                               os << "[m]";
+                               break;
+                       case MINIPAGE_ALIGN_BOTTOM:
+                               os << "[b]";
+                               break;
+                       }
+                       if (!par->pextra_width.empty()) {
+                               os << '{' << par->pextra_width << "}\n";
+                       } else {
+                               //float ib = atof(par->pextra_widthp.c_str())/100;
+                               // string can't handle floats at present
+                               // so I'll do a conversion by hand knowing that
+                               // the limits are 0.0 to 1.0. ARRae.
+                               os << '{';
+                               switch (par->pextra_widthp.length()) {
+                               case 3:
+                                       os << "1.00";
+                                       break;
+                               case 2:
+                                       os << "0." << par->pextra_widthp;
+                                       break;
+                               case 1:
+                                       os << "0.0" << par->pextra_widthp;
+                               }
+                               os << "\\columnwidth}\n";
+                       }
+                       texrow.newline();
+                       if (par_sep == BufferParams::PARSEP_INDENT) {
+                               os << "\\setlength\\parindent{\\LyXMinipageIndent}\n";
+                               texrow.newline();
+                       }
+                       minipage_open = true;
+                        minipage_open_depth = par->depth;
+               }
+       } while (par
+                && par->layout == layout
+                && par->depth == depth
+                && par->pextra_type == pextra_type);
+       if (style.isEnvironment()) {
+               os << "\\end{" << style.latexname() << '}';
+               // maybe this should go after the minipage closes?
+               if (foot_this_level) {
+                       if (foot_count >= 1) {
+                               if (foot_count > 1) {
+                                       os << "\\addtocounter{footnote}{-"
+                                          << foot_count - 1
+                                          << '}';
+                               }
+                               os << foot;
+                               texrow += foot_texrow;
+                               foot.clear();
+                               foot_texrow.reset();
+                               foot_count = 0;
+                       }
+               }
+       }
+        if (minipage_open && (minipage_open_depth == depth) &&
+            (!par || par->pextra_start_minipage ||
+             par->pextra_type != PEXTRA_MINIPAGE)) {
+                os << "\\end{minipage}\n";
+               texrow.newline();
+                if (par_sep == BufferParams::PARSEP_INDENT) {
+                        os << "}\n";
+                       texrow.newline();
+                }
+                if (par && par->pextra_type != PEXTRA_MINIPAGE) {
+                        os << "\\medskip\n\n";
+                       texrow.newline();
+                       texrow.newline();
+                }
+                minipage_open = false;
+        }
+       if (eindent_open) {
+               os << "\\end{LyXParagraphIndent}\n";
+               texrow.newline();
+       }
+        if (!(par && (par->pextra_type == PEXTRA_MINIPAGE) 
+             && par->pextra_hfill)) {
+                os << '\n';
+               texrow.newline();
+       }
+       lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;
+       return par;  // ale970302
 }
-
-
+#else
 LyXParagraph * LyXParagraph::TeXEnvironment(string & file, TexRow & texrow,
                                            string & foot,
                                            TexRow & foot_texrow,
@@ -3632,8 +5248,276 @@ LyXParagraph * LyXParagraph::TeXEnvironment(string & file, TexRow & texrow,
        lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;
        return par;  // ale970302
 }
+#endif
+
+
+#ifdef USE_OSTREAM_ONLY
+LyXParagraph * LyXParagraph::TeXFootnote(ostream & os, TexRow & texrow,
+                                        ostream & foot, TexRow & foot_texrow,
+                                        int & foot_count,
+                                        LyXDirection par_direction)
+{
+       lyxerr[Debug::LATEX] << "TeXFootnote...  " << this << endl;
+       if (footnoteflag == LyXParagraph::NO_FOOTNOTE)
+               lyxerr << "ERROR (LyXParagraph::TeXFootnote): "
+                       "No footnote!" << endl;
+
+       LyXParagraph * par = this;
+       LyXLayout const & style =
+               textclasslist.Style(current_view->buffer()->params.textclass, 
+                                   previous->GetLayout());
+       
+       if (style.needprotect && footnotekind != LyXParagraph::FOOTNOTE){
+               lyxerr << "ERROR (LyXParagraph::TeXFootnote): "
+                       "Float other than footnote in command"
+                       " with moving argument is illegal" << endl;
+       }
+
+       if (footnotekind != LyXParagraph::FOOTNOTE
+           && footnotekind != LyXParagraph::MARGIN
+           && os.tellp()
+           // Thinko
+           // How to solve this?
+           //&& !suffixIs(file, '\n')
+               ) {
+               // we need to ensure that real floats like tables and figures
+               // have their \begin{} on a new line otherwise we can get
+               // incorrect results when using the endfloat.sty package
+               // especially if two floats follow one another.  ARRae 981022
+               // NOTE: if the file is length 0 it must have just been
+               //       written out so we assume it ended with a '\n'
+               // Thinkee:
+               // As far as I can see there is never any harm in writing
+               // a '\n' too much. Please tell me if I am wrong. (Lgb)
+               os << '\n';
+               texrow.newline();
+       }
+       
+       BufferParams * params = &current_view->buffer()->params;
+       bool footer_in_body = true;
+       switch (footnotekind) {
+       case LyXParagraph::FOOTNOTE:
+               if (style.intitle) {
+                       os << "\\thanks{\n";
+                       footer_in_body = false;
+               } else {
+                       if (foot_count == -1) {
+                               // we're at depth 0 so we can use:
+                               os << "\\footnote{%\n";
+                               footer_in_body = false;
+                       } else {
+                               os << "\\footnotemark{}%\n";
+                               if (foot_count) {
+                                       // we only need this when there are
+                                       // multiple footnotes
+                                       os << "\\stepcounter{footnote}";
+                               }
+                               os << "\\footnotetext{%\n";
+                               foot_texrow.start(this, 0);
+                               foot_texrow.newline();
+                               ++foot_count;
+                       }
+               }
+               break;
+       case LyXParagraph::MARGIN:
+               os << "\\marginpar{\n";
+               break;
+       case LyXParagraph::FIG:
+               if (pextra_type == PEXTRA_FLOATFLT
+                   && (!pextra_width.empty()
+                       || !pextra_widthp.empty())) {
+                       char bufr[80];
+                       if (!pextra_width.empty())
+                               sprintf(bufr, "\\begin{floatingfigure}{%s}\n",
+                                       pextra_width.c_str());
+                       else
+                               sprintf(bufr,
+                                       "\\begin{floatingfigure}{%f\\textwidth}\n",
+                                       atoi(pextra_widthp.c_str())/100.0);
+                       os << bufr;
+               } else {
+                       os << "\\begin{figure}";
+                       if (!params->float_placement.empty()) { 
+                               os << '[' << params->float_placement << "]\n";
+                       } else {
+                               os << '\n';
+                       }
+               }
+               break;
+       case LyXParagraph::TAB:
+               os << "\\begin{table}";
+               if (!params->float_placement.empty()) { 
+                       os << '[' << params->float_placement << "]\n";
+               } else {
+                       os << '\n';
+               }
+               break;
+       case LyXParagraph::WIDE_FIG:
+               os << "\\begin{figure*}";
+               if (!params->float_placement.empty()) { 
+                       os << '[' << params->float_placement << "]\n";
+               } else {
+                       os << '\n';
+               }
+               break;
+       case LyXParagraph::WIDE_TAB:
+               os << "\\begin{table*}";
+               if (!params->float_placement.empty()) { 
+                       os << '[' << params->float_placement << "]\n";
+               } else {
+                       os << '\n';
+               }
+               break;
+       case LyXParagraph::ALGORITHM:
+               os << "\\begin{algorithm}\n";
+               break;
+       }
+       texrow.newline();
+   
+       LyXDirection direction = getParDirection();
+       if (direction != par_direction) {
+               if (direction == LYX_DIR_LEFT_TO_RIGHT)
+                       os << "\\unsethebrew\n";
+               else
+                       os << "\\sethebrew\n";
+               texrow.newline();
+       }
+
+       if (footnotekind != LyXParagraph::FOOTNOTE
+           || !footer_in_body) {
+               // Process text for all floats except footnotes in body
+               do {
+                       LyXLayout const & style =
+                               textclasslist
+                               .Style(current_view->buffer()->params
+                                      .textclass,
+                                      par->layout);
+                       if (par->IsDummy())
+                               lyxerr << "ERROR (LyXParagraph::TeXFootnote)"
+                                      << endl;
+                       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 footnotes inside
+                               // floats (yet). ARRae
+                               par = par->TeXEnvironment(os, texrow,
+                                                         foot, foot_texrow,
+                                                         foot_count);
+                       } else {
+                               par = par->TeXOnePar(os, texrow,
+                                                    foot, foot_texrow,
+                                                    foot_count);
+                       }
+                       
+                       if (par && !par->IsDummy() && par->depth > depth) {
+                               par = par->TeXDeeper(os, texrow,
+                                                    foot, foot_texrow,
+                                                    foot_count);
+                       }
+               } while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE);
+       } else {
+               // process footnotes > depth 0 or in environments separately
+               // NOTE: Currently don't support footnotes within footnotes
+               //       even though that is possible using the \footnotemark
+#ifdef HAVE_SSTREAM
+               ostringstream dummy;
+#else
+               ostrstream dummy;
+#endif
+               TexRow dummy_texrow;
+               int dummy_count = 0;
+               do {
+                       LyXLayout const & style =
+                               textclasslist
+                               .Style(current_view->buffer()->params
+                                      .textclass,
+                                      par->layout);
+                       if (par->IsDummy())
+                               lyxerr << "ERROR (LyXParagraph::TeXFootnote)"
+                                      << endl;
+                       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 footnotes inside
+                               // floats (yet). ARRae
+                               par = par->TeXEnvironment(foot, foot_texrow,
+                                                         dummy, dummy_texrow,
+                                                         dummy_count);
+                       } else {
+                               par = par->TeXOnePar(foot, foot_texrow,
+                                                    dummy, dummy_texrow,
+                                                    dummy_count);
+                       }
+
+                       if (par && !par->IsDummy() && par->depth > depth) {
+                               par = par->TeXDeeper(foot, foot_texrow,
+                                                    dummy, dummy_texrow,
+                                                    dummy_count);
+                       }
+               } while (par
+                        && par->footnoteflag != LyXParagraph::NO_FOOTNOTE);
+               if (dummy_count) {
+                       lyxerr << "ERROR (LyXParagraph::TeXFootnote): "
+                               "Footnote in a Footnote -- not supported"
+                              << endl;
+               }
+#ifndef HAVE_OSTREAM
+               delete [] dummy.str();
+#endif
+       }
+
+       switch (footnotekind) {
+       case LyXParagraph::FOOTNOTE:
+               if (footer_in_body) {
+                       // This helps tell which of the multiple
+                       // footnotetexts an error was in.
+                       foot << "}%\n";
+                       foot_texrow.newline();
+               } else {
+                       os << '}';
+               }
+               break;
+       case LyXParagraph::MARGIN:
+               os << '}';
+               break;
+       case LyXParagraph::FIG:
+               if (pextra_type == PEXTRA_FLOATFLT
+                   && (!pextra_width.empty()
+                       || !pextra_widthp.empty()))
+                       os << "\\end{floatingfigure}";
+               else
+                       os << "\\end{figure}";
+               break;
+       case LyXParagraph::TAB:
+               os << "\\end{table}";
+               break;
+       case LyXParagraph::WIDE_FIG:
+               os << "\\end{figure*}";
+               break;
+       case LyXParagraph::WIDE_TAB:
+               os << "\\end{table*}";
+               break;
+       case LyXParagraph::ALGORITHM:
+               os << "\\end{algorithm}";
+               break;
+       }
 
+       if (footnotekind != LyXParagraph::FOOTNOTE
+           && footnotekind != LyXParagraph::MARGIN) {
+               // we need to ensure that real floats like tables and figures
+               // have their \end{} on a line of their own otherwise we can
+               // get incorrect results when using the endfloat.sty package.
+               os << "\n";
+               texrow.newline();
+       }
 
+       lyxerr[Debug::LATEX] << "TeXFootnote...done " << par->next << endl;
+       return par;
+}
+#else
 LyXParagraph * LyXParagraph::TeXFootnote(string & file, TexRow & texrow,
                                         string & foot, TexRow & foot_texrow,
                                         int & foot_count,
@@ -3894,6 +5778,7 @@ LyXParagraph * LyXParagraph::TeXFootnote(string & file, TexRow & texrow,
        lyxerr[Debug::LATEX] << "TeXFootnote...done " << par->next << endl;
        return par;
 }
+#endif
 
 
 void LyXParagraph::SetPExtraType(int type, char const * width,
index be3479aab617e52d52a58fb2f7b17c74c0c4c861..8ce786d25416e879e667238cc6c39fbbfad1a1c8 100644 (file)
@@ -767,8 +767,7 @@ bool RunSpellChecker(BufferView * bv)
    
        if(isp_pid!= -1) {
                ispell_terminate();
-               string word_msg;
-               word_msg += tostr(word_count);
+               string word_msg(tostr(word_count));
                if (word_count != 1) {
                        word_msg += _(" words checked.");
                } else {
index e962920ff481f065a7ab4c1115d9016d2d6f702d..b76e6137b73cd38afcd00aa837389043037f8e3f 100644 (file)
@@ -63,7 +63,7 @@ inline string tostr(T const & t)
        return ostr.str().c_str();
        // We need to use the .c_str since we sometimes are using
        // our own string class and that is not compatible with
-       // basic_string<char>.
+       // basic_string<char>. (of course we don't want this later)
 #else
        // The buf is probably a bit large, but if we want to be safer
        // we should leave it this big. As compiler/libs gets updated
diff --git a/src/support/lyxmanip.h b/src/support/lyxmanip.h
new file mode 100644 (file)
index 0000000..9b1bdcd
--- /dev/null
@@ -0,0 +1,20 @@
+// -*- C++ -*-
+#ifndef LYX_MANIP_H
+#define LYX_MANIP_H
+
+#include <iomanip>
+
+///
+inline
+ostream & newlineAndDepth_helper(ostream & s, int n)
+{
+       return s << '\n' << string(n, ' ');
+}
+///
+inline
+omanip<int> newlineAndDepth(int n)
+{
+       return omanip<int>(newlineAndDepth_helper, n);
+}
+
+#endif
index 3dd4bccfb244c9d6a4be327ec85054f7b61b0ad5..5156e53ba78d6d1f1d779aa11fa8fabce2c1f1a6 100644 (file)
@@ -3,8 +3,8 @@
  * 
  *           LyX, The Document Processor
  *      
- *       Copyright (C) 1995 Matthias Ettrich
- *        Copyright (C) 1995-1998 The LyX Team.
+ *       Copyright 1995 Matthias Ettrich
+ *        Copyright 1995-2000 The LyX Team.
  *
  * ====================================================== 
  */
@@ -16,7 +16,6 @@
 #include "vspace.h"
 #include "layout.h"
 #include "support/lstrings.h"
-
 #include <algorithm>
 using std::max;
 
@@ -24,7 +23,11 @@ using std::max;
 #pragma implementation
 #endif
 
+#ifdef USE_OSTREAM_ONLY
+#include "support/lyxmanip.h"
+#else
 extern void addNewlineAndDepth(string & file, int depth); // Jug 990923
+#endif
 
 static int const WIDTH_OF_LINE = 5;
 
@@ -953,6 +956,344 @@ void LyXTable::Read(istream & is)
 }
 
 
+#ifdef USE_OSTREAM_ONLY
+// cell <0 will tex the preamble
+// returns the number of printed newlines
+int LyXTable::TexEndOfCell(ostream & os, int cell)
+{
+    int i;
+    int ret = 0;
+    int tmp; // tmp2;
+    int fcell, nvcell;
+    if (ShouldBeVeryLastCell(cell)) {
+        // the very end at the very beginning
+        if (Linebreaks(cell))
+               os << "\\smallskip{}}";
+        if (IsMultiColumn(cell))
+               os << '}';
+        if (RotateCell(cell)) {
+               os << "\n\\end{sideways}";
+            ++ret;
+        }
+        os << "\\\\\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)) {
+               os << "\\hline ";
+        } else {
+            tmp = 0;
+            for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
+                if (BottomLine(fcell + i)) {
+                       os << "\\cline{"
+                          << column_of_cell(fcell + i) + 1
+                          << '-'
+                          << right_column_of_cell(fcell + i) + 1
+                          << "} ";
+                    tmp = 1;
+                }
+            }
+        }
+        if (tmp){
+               os << '\n';
+            ++ret;
+        }
+        if (is_long_table)
+               os << "\\end{longtable}";
+        else
+               os << "\\end{tabular}";
+        if (rotate) {
+               os << "\n\\end{sideways}";
+            ++ret;
+        }
+    } else {
+        nvcell = NextVirtualCell(cell + 1);
+        if (cell < 0){
+            // preamble
+            if (rotate) {
+                   os << "\\begin{sideways}\n";
+                ++ret;
+            }
+            if (is_long_table)
+                   os << "\\begin{longtable}{";
+            else
+                   os << "\\begin{tabular}{";
+            for (i = 0; i < columns; ++i) {
+                if (column_info[i].left_line)
+                       os << '|';
+                if (!column_info[i].align_special.empty()) {
+                       os << column_info[i].align_special;
+                } else if (!column_info[i].p_width.empty()) {
+                       os << "p{"
+                          << column_info[i].p_width
+                          << '}';
+                } else {
+                    switch (column_info[i].alignment) {
+                      case LYX_ALIGN_LEFT:
+                             os << 'l';
+                          break;
+                      case LYX_ALIGN_RIGHT:
+                             os << 'r';
+                          break;
+                      default:
+                             os << 'c';
+                          break;
+                    }
+                }
+                if (column_info[i].right_line)
+                       os << '|';
+            }
+            os << "}\n";
+            ++ret;
+            tmp = 0;
+            if (GetNumberOfCells()) {
+                fcell = 0;
+                for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
+                    if (TopLine(fcell + i))
+                        ++tmp;
+                }
+                if (tmp == NumberOfCellsInRow(fcell)){
+                       os << "\\hline ";
+                } else {
+                    tmp = 0;
+                    for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
+                        if (TopLine(fcell + i)) {
+                               os << "\\cline{"
+                                  << column_of_cell(fcell + i) + 1
+                                  << '-'
+                                  << right_column_of_cell(fcell + i) + 1
+                                  << "} ";
+                               tmp = 1;
+                        }
+                    }
+                }
+                if (tmp){
+                       os << '\n';
+                    ++ret;
+                }
+            }
+            if (RotateCell(0)) {
+                   os << "\\begin{sideways}\n";
+                ++ret;
+            }
+        } else {
+            // usual cells
+            if (Linebreaks(cell))
+                   os << "\\smallskip{}}";
+            if (IsMultiColumn(cell)){
+                   os << '}';
+            }
+            if (RotateCell(cell)) {
+                   os << "\n\\end{sideways}";
+                ++ret;
+            }
+            if (IsLastCell(cell)) {
+                int row = row_of_cell(cell);
+                string hline1, hline2;
+                bool print_hline = true;
+                bool flag1 = IsLongTable() &&
+                    ((row == endhead) || (row == endfirsthead) ||
+                     (row == endfoot) || (row == endlastfoot));
+                ++row;
+                bool 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
+                bool pr_top_hline = (flag1 && flag2) || (!flag1 && !flag2) ||
+                    (endfirsthead == endhead);
+                os << "\\\\\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)){
+                       os << "\\hline ";
+                    hline1 = "\\hline ";
+                } else {
+                    tmp = 0;
+                    for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
+                        if (BottomLine(fcell + i)){
+                               os << "\\cline{"
+                                  << column_of_cell(fcell + i) + 1
+                                  << '-'
+                                  << right_column_of_cell(fcell + i) + 1
+                                  << "} ";
+                            hline1 += "\\cline{";
+                            hline1 += tostr(column_of_cell(fcell + i) + 1);
+                            hline1 += '-';
+                            hline1 += tostr(right_column_of_cell(fcell + i) + 1);
+                            hline1 += "} ";
+                            tmp = 1;
+                        }
+                    }
+                }
+                if (tmp){
+                       os << '\n';
+                    ++ret;
+                }
+                if (IsLongTable() && (row == endfoot)) {
+                       os << "\\endfoot\n";
+                    ++ret;
+                    print_hline = false; // no double line below footer
+                }
+                if (IsLongTable() && (row == endlastfoot)) {
+                       os << "\\endlastfoot\n";
+                    ++ret;
+                    print_hline = false; // no double line below footer
+                }
+                if (IsLongTable() && row_info[row].newpage) {
+                       os << "\\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)
+                               os << "\\hline ";
+                        hline2 = "\\hline ";
+                    } else {
+                        tmp = 0;
+                        for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
+                            if (TopLine(fcell + i)) {
+                                if (print_hline) {
+                                       os << "\\cline{"
+                                          << column_of_cell(fcell + i) + 1
+                                          << '-'
+                                          << right_column_of_cell(fcell + i) + 1
+                                          << "} ";
+                               }
+                                hline2 += "\\cline{";
+                                hline2 += tostr(column_of_cell(fcell+i)+1);
+                                hline2 += '-';
+                                hline2 += tostr(right_column_of_cell(fcell+i)+1);
+                                hline2 += "} ";
+                                tmp = 1;
+                            }
+                        }
+                    }
+                    if (tmp && print_hline){
+                           os << '\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)) {
+                       os << "\\endhead\n";
+                    ++ret;
+                }
+                if (IsLongTable() && (row == endfirsthead)) {
+                       os << "\\endfirsthead\n";
+                    ++ret;
+                }
+                if (sflag1) { // add the \hline for next foot row
+                    if (!hline1.empty()) {
+                           os << hline1 + '\n';
+                        ++ret;
+                    }
+                }
+                // add the \hline for the first row
+                if (pr_top_hline && sflag2) {
+                    if (!hline2.empty()) {
+                           os << hline2 + '\n';
+                        ++ret;
+                    }
+                }
+                if (nvcell < numberofcells && RotateCell(nvcell)) {
+                       os << "\\begin{sideways}\n";
+                    ++ret;
+                }
+            } else {
+                   os << "&\n";
+                ++ret;
+                if (nvcell < numberofcells && RotateCell(nvcell)) {
+                       os << "\\begin{sideways}\n";
+                    ++ret;
+                }
+            }
+        }
+        if (nvcell < numberofcells && IsMultiColumn(nvcell)) {
+               os << "\\multicolumn{"
+                  << cells_in_multicolumn(nvcell)
+                  << "}{";
+            if (!cellinfo_of_cell(cell+1)->align_special.empty()) {
+                   os << cellinfo_of_cell(cell+1)->align_special
+                      << "}{";
+            } else {
+                if (LeftLine(nvcell))
+                       os << '|';
+                if (!GetPWidth(nvcell).empty()) {
+                       os << "p{"
+                          << GetPWidth(nvcell)
+                          << '}';
+                } else {
+                    switch (GetAlignment(nvcell)) {
+                   case LYX_ALIGN_LEFT: os << 'l'; break;
+                   case LYX_ALIGN_RIGHT: os << 'r'; break;
+                   default:  os << 'c'; break;
+                    }
+                }
+                if (RightLine(nvcell))
+                       os << '|';
+                //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)))
+                       os << '|';
+               
+               os << "}{";
+            }
+        }
+        if (nvcell < numberofcells && Linebreaks(nvcell)) {
+//            !column_info[column_of_cell(nvcell)].p_width.empty()) {
+               os << "\\parbox{"
+                  << GetPWidth(nvcell)
+                  << "}{\\smallskip{}";
+       }
+    }
+    return ret;
+}
+#else
 // cell <0 will tex the preamble
 // returns the number of printed newlines
 int LyXTable::TexEndOfCell(string & file, int cell)
@@ -1287,6 +1628,7 @@ int LyXTable::TexEndOfCell(string & file, int cell)
     }
     return ret;
 }
+#endif
 
 
 #if 0
@@ -1429,6 +1771,130 @@ char const *LyXTable::getDocBookAlign(int cell, bool isColumn)
     }
 }
 
+
+#ifdef USE_OSTREAM_ONLY
+// cell <0 will tex the preamble
+// returns the number of printed newlines
+int LyXTable::DocBookEndOfCell(ostream & os, int cell, int &depth)
+{
+    int i;
+    int ret = 0;
+    //int tmp; // tmp2; // unused
+    int nvcell; // fcell; // unused
+    if (ShouldBeVeryLastCell(cell)) {
+           os << newlineAndDepth(--depth)
+              << "</ENTRY>"
+              << newlineAndDepth(--depth)
+              << "</ROW>"
+              << newlineAndDepth(--depth)
+              << "</TBODY>"
+              << newlineAndDepth(--depth);
+        if (is_long_table)
+               os << "</TGROUP>";
+        else
+               os << "</TGROUP>"
+                  << newlineAndDepth(--depth);
+        ret += 4;
+    } else {
+        nvcell = NextVirtualCell(cell + 1);
+        if (cell < 0) {
+            // preamble
+            if (is_long_table)
+                   os << "<TGROUP ";
+            else
+                   os << "<TGROUP ";
+            os << "COLS='"
+              << columns
+              << "' COLSEP='1' ROWSEP='1'>"
+              << newlineAndDepth(++depth);
+            ++ret;
+            for (i = 0; i < columns; ++i) {
+                   os << "<COLSPEC ALIGN='"
+                      << getDocBookAlign(i, true)
+                      << "' COLNAME='col"
+                      << i + 1
+                      << "' COLNUM='"
+                      << i + 1
+                      << "' COLSEP='";
+               if (i == (columns-1)) {
+                      os << '1';
+               } else {
+                   if (column_info[i].right_line ||
+                       column_info[i+1].left_line)
+                          os << '1';
+                   else
+                          os << '0';
+               }
+               os << "'>"
+                 << newlineAndDepth(depth);
+                ++ret;
+#ifdef NOT_HANDLED_YET_AS_I_DONT_KNOW_HOW
+                if (column_info[i].left_line)
+                       os << '|';
+#endif
+            }
+            os << "<TBODY>"
+              << newlineAndDepth(++depth)
+              << "<ROW>"
+              << newlineAndDepth(++depth)
+              << "<ENTRY ALIGN='"
+              << getDocBookAlign(0)
+              << "'";
+           if (IsMultiColumn(0)) {
+                  os << " NAMEST='col1' NAMEEND='col"
+                     << cells_in_multicolumn(0)
+                     << "'";
+           }
+          os << ">"
+             << newlineAndDepth(++depth);
+            ret += 3;
+        } else {
+            if (IsLastCell(cell)) {
+                   os << newlineAndDepth(--depth)
+                      << "</ENTRY>"
+                      << newlineAndDepth(--depth)
+                      << "</ROW>"
+                      << newlineAndDepth(depth)
+                      << "<ROW>"
+                      << newlineAndDepth(++depth)
+                      << "<ENTRY ALIGN='"
+                      << getDocBookAlign(cell + 1)
+                      << "' VALIGN='middle'";
+               if (IsMultiColumn(cell + 1)) {
+                      os << " NAMEST='col"
+                         << column_of_cell(cell+1) + 1
+                         << "' NAMEEND='col"
+                         << column_of_cell(cell + 1) +
+                              cells_in_multicolumn(cell + 1)
+                         << "'";
+               }
+               os << ">"
+                 << newlineAndDepth(++depth);
+                ret += 4;
+            } else {
+                   os << newlineAndDepth(--depth)
+                      << "</ENTRY>"
+                      << newlineAndDepth(depth)
+                      << "<ENTRY ALIGN='"
+                      << getDocBookAlign(cell + 1)
+                      << "' VALIGN='middle'";
+               if (IsMultiColumn(cell + 1)) {
+                      os << " NAMEST='col"
+                         << column_of_cell(cell+1) + 1
+                         << "' NAMEEND='col"
+                         << column_of_cell(cell+1) +
+                              cells_in_multicolumn(cell+1)
+                         << "'";
+               }
+               os << ">"
+                 << newlineAndDepth(++depth);
+                ret += 3;
+            }
+        }
+    }
+    return ret;
+}
+#else
 // cell <0 will tex the preamble
 // returns the number of printed newlines
 int LyXTable::DocBookEndOfCell(string & file, int cell, int &depth)
@@ -1550,6 +2016,7 @@ int LyXTable::DocBookEndOfCell(string & file, int cell, int &depth)
     }
     return ret;
 }
+#endif
 
 
 bool LyXTable::IsMultiColumn(int cell)
index 66175320c09a3ae27bbf0abd4ec1d27a925c1244..cedac0fc88df3a61fcc8617bd7ea5a22a7b81fb6 100644 (file)
@@ -18,6 +18,8 @@
 #include "LString.h"
 #include "support/LOstream.h"
 
+#define USE_OSTREAM_ONLY 1
+
 /* The features the text class offers for tables */ 
 
 ///
@@ -164,16 +166,23 @@ public:
 
        // cell <0 will tex the preamble
        // returns the number of printed newlines
+#ifdef USE_OSTREAM_ONLY
+       ///
+       int TexEndOfCell(ostream &, int cell);
+       ///
+       int DocBookEndOfCell(ostream &, int cell, int & depth);
+#else
        ///
        int TexEndOfCell(string & file, int cell);
+       ///
+       int DocBookEndOfCell(string & file, int cell, int & depth);
+#endif
 #if 0
        ///
        int RoffEndOfCell(ostream &, int cell);
 #endif
        ///
        char const * getDocBookAlign(int cell, bool isColumn = false);
-       ///
-       int DocBookEndOfCell(string & file, int cell, int & depth);
 
        ///
        bool IsMultiColumn(int cell);
index f5e84708643735ff2efe95268a06bb999f9a6214..40671ec6a9f71587e9f7473fe4311f7b12a744c6 100644 (file)
@@ -76,13 +76,13 @@ string DoAccent(string const & s, tex_accent accent)
 {
        string res;
        
-       res+= lyx_accent_table[accent].cmd;
-       res+= '{';
+       res += lyx_accent_table[accent].cmd;
+       res += '{';
        if (s == "i" || s == "j") {
-               res+= '\\';
+               res += '\\';
        }
-       res+= s;
-       res+= '}';
+       res += s;
+       res += '}';
        return res;
 }
 
index e987c967655f33ead6c58c5327f94d6a3a027d5b..4485c4b8cd7e64b7310faae8505c9e19d31c470a 100644 (file)
@@ -2391,12 +2391,17 @@ void LyXText::InsertChar(char c)
 
        /* When the free-spacing option is set for the current layout,
         * all spaces are converted to protected spaces. */
+       // Thinko!
 #warning think about this
 #if 0
        bool freeSpacingBo = 
                textclasslist.Style(parameters->textclass,
                               cursor.row->par->GetLayout()).free_spacing;
 
+       // Thinkee: (not done)
+       // It seems that we should insert a InsetSpecialChar, do we really
+       // have to? I don't know the free spacing politics too deeply.
+       // Some others should have a look at this.
        if (freeSpacingBo && IsLineSeparatorChar(c) 
            && (!cursor.pos || cursor.par->IsLineSeparator(cursor.pos - 1))) {
                c = LyXParagraph::META_PROTECTED_SEPARATOR;