+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
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.)
--- /dev/null
+#% 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
+
# 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
}
-#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
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())));
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,
// 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,
// 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,
// 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,
// 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
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;
}
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;
// 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;
}
+#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)
ofs.close();
lyxerr.debug() << "Finished making latex file." << endl;
}
+#endif
bool Buffer::isLatex() const
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))
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;
// 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) {
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();
// 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));
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);
}
++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;
}
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,
par = par->next;
DocBookHandleFootnote(ofs, par,
depth + 1 + command_depth);
+#endif
}
while(par && par->IsDummy());
}
+#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)
}
LyXFont font1, font2;
char c;
- Inset *inset;
+ Inset * inset;
LyXParagraph::size_type main_body;
int j;
string emph= "emphasis";
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
}
file += '\n';
}
+#endif
int Buffer::runLaTeX()
///
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,
file += cmd + ' ';
return 0;
}
-#endif
int InsetFig::Linuxdoc(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
{
#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;
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);
}
{
}
+
/// An updatable inset could handle lyx editing commands
#ifdef SCROLL_INSET
UpdatableInset::RESULT
// 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 += '[';
s += '{';
s += contents + '}';
os << "\\bibitem " << s << "\n";
+#endif
}
file += getCommand();
return 0;
}
-#endif
int InsetCommand::Linuxdoc(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
{
#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;
///
{
return 0;
}
-#endif
int InsetError::Linuxdoc(string &) const
return 0;
}
+#else
+
+int InsetError::Linuxdoc(ostream &) const
+{
+ return 0;
+}
+
+
+int InsetError::DocBook(ostream &) const
+{
+ return 0;
+}
+#endif
+
bool InsetError::AutoDelete() const
{
#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
{
return 0;
}
-#endif
int InsetGraphics::Linuxdoc(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
{
#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;
{
return 0;
}
-#endif
int InsetInfo::Linuxdoc(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
{
#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");}
///
file += escape(getCommand());
return 0;
}
-#endif
int InsetLabel::Linuxdoc(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.
#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;
file += contents;
return 0;
}
-#endif
int InsetLatexAccent::Linuxdoc(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
{
#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;
///
file += qstr;
return 0;
}
-#endif
int InsetQuotes::Linuxdoc(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 << "“";
+ else
+ os << "”";
+ } else {
+ if (side == InsetQuotes::LeftQ)
+ os << "‘";
+ else
+ os << "’";
+ }
+ return 0;
+}
+#endif
+
void InsetQuotes::Validate(LaTeXFeatures & features) const
{
#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;
///
}
return 0;
}
-#endif
int InsetRef::Linuxdoc(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.
#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;
}
return 0;
}
-#endif
int InsetSpecialChar::Linuxdoc(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
{
#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;
///
int baseline, float & x) const
{
// if (init_inset) {
- computeTextRows(pain);
+ computeTextRows(pain, x);
// init_inset = false;
// }
UpdatableInset::draw(pain, f, baseline, x);
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);
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;
}
-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,
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;
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;
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
// 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);
#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;
///
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;
///
bv->owner()->getLyXFunc()->Dispatch(LFUN_TOCVIEW);
}
+#ifndef USE_OSTREAM_ONLY
int InsetTOC::Linuxdoc(string & file) const
{
file += "<toc>";
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
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;
return 0;
}
-#endif
int InsetUrl::Linuxdoc(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
{
#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:
#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;
///
/// To convert old binary dispatch results
RESULT DISPATCH_RESULT(bool b) {
- return (b) ? DISPATCHED: FINISHED;
+ return b ? DISPATCHED : FINISHED;
}
///
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; }
///
{ 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 &);
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);
}
fl_hide_form(fd_form_ref->form_ref);
}
+#ifndef USE_OSTREAM_ONLY
#ifdef WITH_WARNINGS
#warning UGLY!!
#endif
file += '\n';
file.append(depth, ' ');
}
+#endif
//
// 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,
// 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);
+ }
}
/// 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
{
}
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)
++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
#undef OFF
#endif
+#define USE_OSTREAM_ONLY 1
+
class LyXLex;
///
/// 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
*/
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;
///
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;
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.
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,
LyXLayout const & style,
size_type & i,
int & column, char const c);
+#endif
///
unsigned int id_;
///
RC_AUTOREGIONDELETE,
RC_BIND,
RC_SERVERPIPE,
- RC_NOMENUACCELERATORS,
RC_INPUT,
RC_BINDFILE,
RC_KBMAP,
RC_PDF_TO_PS_COMMAND,
RC_DVI_TO_PS_COMMAND,
RC_DATE_INSERT_FORMAT,
+ RC_SHOW_BANNER,
RC_LAST
};
{ "\\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 },
use_kbmap = false;
hasBindFile = false;
rtl_support = false;
- defaultKeyBindings();
- ///
date_insert_format = "%A, %e %B %Y";
+ show_banner = true;
+ //
+ defaultKeyBindings();
}
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
}
}
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();
}
string date_insert_format;
///
bool rtl_support;
+ ///
+ bool show_banner;
private:
///
void defaultKeyBindings();
mathed_write(par, file, &ret, fragile, label.c_str());
return ret;
}
-#endif
int InsetFormula::Linuxdoc(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
}
-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);
#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;
///
tmacro->WriteDef(file);
return ret;
}
-#endif
int InsetFormulaMacro::Linuxdoc(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)
{
#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;
}
-void MathMacroTemplate::WriteDef(string &file)
+void MathMacroTemplate::WriteDef(string & file)
{
file += "\n\\newcommand{\\";
file += name;
#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)
}
+#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)
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;
main_body = BeginningOfMainBody();
if (main_body > 0) {
- file += '[';
+ os << '[';
basefont = getFont(-2); // Get label font
} else {
basefont = getFont(-1); // Get layout font
&& !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;
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) {
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;
}
}
// 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;
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);
}
}
// 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;
}
// 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);
}
// 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;
++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);
}
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,
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 = "&";
+ break;
+ case '<':
+ sgml_string = "<";
+ break;
+ case '>':
+ sgml_string = ">";
+ break;
+ case '$':
+ sgml_string = "$";
+ break;
+ case '#':
+ sgml_string = "#";
+ break;
+ case '%':
+ sgml_string = "%";
+ break;
+ case '[':
+ sgml_string = "[";
+ break;
+ case ']':
+ sgml_string = "]";
+ break;
+ case '{':
+ sgml_string = "{";
+ break;
+ case '}':
+ sgml_string = "}";
+ break;
+ case '~':
+ sgml_string = "˜";
+ break;
+ case '"':
+ sgml_string = """;
+ break;
+ case '\\':
+ sgml_string = "\";
+ 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 = "&";
- break;
- case '<':
- sgml_string = "<";
- break;
- case '>':
- sgml_string = ">";
- break;
- case '$':
- sgml_string = "$";
- break;
- case '#':
- sgml_string = "#";
- break;
- case '%':
- sgml_string = "%";
- break;
- case '[':
- sgml_string = "[";
- break;
- case ']':
- sgml_string = "]";
- break;
- case '{':
- sgml_string = "{";
- break;
- case '}':
- sgml_string = "}";
- break;
- case '~':
- sgml_string = "˜";
- break;
- case '"':
- sgml_string = """;
- break;
- case '\\':
- sgml_string = "\";
- 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)
{
char c;
Inset * inset;
size_type main_body;
- string emph = "emphasis";
bool emph_flag = false;
LyXLayout const & style =
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
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,
LyXFont font2;
char c;
Inset * inset;
- string emph= "emphasis";
+ //string emph = "emphasis";
bool emph_flag= false;
int char_line_count= 0;
}
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
}
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,
}
}
}
-
-
+#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,
}
}
}
+#endif
#if 0
#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)
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,
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 = ¤t_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,
lyxerr[Debug::LATEX] << "TeXFootnote...done " << par->next << endl;
return par;
}
+#endif
void LyXParagraph::SetPExtraType(int type, char const * width,
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 {
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
--- /dev/null
+// -*- 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
*
* 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.
*
* ======================================================
*/
#include "vspace.h"
#include "layout.h"
#include "support/lstrings.h"
-
#include <algorithm>
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;
}
+#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)
}
return ret;
}
+#endif
#if 0
}
}
+
+#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)
}
return ret;
}
+#endif
bool LyXTable::IsMultiColumn(int cell)
#include "LString.h"
#include "support/LOstream.h"
+#define USE_OSTREAM_ONLY 1
+
/* The features the text class offers for tables */
///
// 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);
{
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;
}
/* 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;