From 34e27f8c2697f369cfe9c260125ea2d4559621a9 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Sat, 19 Jan 2002 20:24:04 +0000 Subject: [PATCH] fix bugs 200, 201, 196 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3421 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 8 + src/buffer.C | 6 +- src/frontends/controllers/ChangeLog | 3 + .../controllers/ControlDialog_impl.C | 2 +- .../controllers/ControlDialog_impl.h | 2 +- src/paragraph.C | 174 ++++++++++-------- src/paragraph.h | 8 + src/tabular.C | 2 +- 8 files changed, 124 insertions(+), 81 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 19dd09414c..62a9f6bfc1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,13 @@ 2002-01-19 Jean-Marc Lasgouttes + * tabular.C (Validate): remove broken optimization (fixes bug #201) + + * paragraph.C (startTeXParParams): + (endTeXParParams): new methods. The LaTeX code to + start/end paragraph formatting + (simpleTeXOnePar): call startTeXParParams also when paragraph is + empty (fixes bug #200) + * vspace.C (inPixels): adapt to the change below (inPixels): [later] more cleanups (remove unused variables) diff --git a/src/buffer.C b/src/buffer.C index e2ee686197..2e09363d36 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -2545,15 +2545,15 @@ void Buffer::latexParagraphs(ostream & ofs, Paragraph * par, if ((in == 0) || !in->forceDefaultParagraphs(in)) { LyXLayout const & layout = textclasslist.Style(params.textclass, par->layout); - - if (layout.intitle) { + + if (layout.intitle) { if (already_title) { lyxerr <<"Error in latexParagraphs: You" " should not mix title layouts" " with normal ones." << endl; } else was_title = true; - } else if (was_title && !already_title) { + } else if (was_title && !already_title) { ofs << "\\maketitle\n"; texrow.newline(); already_title = true; diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index f840ad4767..0061f42a16 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,5 +1,8 @@ 2002-01-19 Jean-Marc Lasgouttes + * ControlDialog_impl.h (ControlConnectBI>): make ControlDialogBI + derive from ControlDialog (fixes bug #196) + * helper_funcs.C (browseRelFile): forgot to pass dir2 to browseFile 2002-01-17 Jean-Marc Lasgouttes diff --git a/src/frontends/controllers/ControlDialog_impl.C b/src/frontends/controllers/ControlDialog_impl.C index d3df442bf9..357c4d80fc 100644 --- a/src/frontends/controllers/ControlDialog_impl.C +++ b/src/frontends/controllers/ControlDialog_impl.C @@ -18,5 +18,5 @@ ControlDialogBD::ControlDialogBD(LyXView & lv, Dialogs & d) ControlDialogBI::ControlDialogBI(LyXView & lv, Dialogs & d) - : ControlDialog(lv, d) + : ControlDialog(lv, d) {} diff --git a/src/frontends/controllers/ControlDialog_impl.h b/src/frontends/controllers/ControlDialog_impl.h index ed0b89eae5..5bc16cd87f 100644 --- a/src/frontends/controllers/ControlDialog_impl.h +++ b/src/frontends/controllers/ControlDialog_impl.h @@ -28,7 +28,7 @@ public: }; -class ControlDialogBI : public ControlDialog +class ControlDialogBI : public ControlDialog { public: /// diff --git a/src/paragraph.C b/src/paragraph.C index 2e3a09feb9..edbb0a429c 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -894,7 +894,7 @@ void Paragraph::breakParagraph(BufferParams const & bparams, // copy everything behind the break-position // to the new paragraph - pos_type pos_end = pimpl_->size() - 1; + pos_type pos_end = size() - 1; pos_type i = pos; pos_type j = pos; for (; i <= pos_end; ++i) { @@ -970,7 +970,7 @@ void Paragraph::breakParagraphConservative(BufferParams const & bparams, if (size() > pos) { // copy everything behind the break-position to the new // paragraph - pos_type pos_end = pimpl_->size() - 1; + pos_type pos_end = size() - 1; //pos_type i = pos; //pos_type j = pos; @@ -1440,6 +1440,88 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf, return next_; } +// This could go to ParagraphParameters if we want to +int Paragraph::startTeXParParams(BufferParams const & bparams, + ostream & os) const +{ + int column = 0; + + if (params().noindent()) { + os << "\\noindent "; + column += 10; + } + + switch (params().align()) { + case LYX_ALIGN_NONE: + case LYX_ALIGN_BLOCK: + case LYX_ALIGN_LAYOUT: + case LYX_ALIGN_SPECIAL: + break; + case LYX_ALIGN_LEFT: + if (getParLanguage(bparams)->babel() != "hebrew") { + os << "\\begin{flushleft}"; + column += 17; + } else { + os << "\\begin{flushright}"; + column += 18; + } + break; + case LYX_ALIGN_RIGHT: + if (getParLanguage(bparams)->babel() != "hebrew") { + os << "\\begin{flushright}"; + column += 18; + } else { + os << "\\begin{flushleft}"; + column += 17; + } + break; + case LYX_ALIGN_CENTER: + os << "\\begin{center}"; + column += 14; + break; + } + + return column; +} + +// This could go to ParagraphParameters if we want to +int Paragraph::endTeXParParams(BufferParams const & bparams, + ostream & os) const +{ + int column = 0; + + switch (params().align()) { + case LYX_ALIGN_NONE: + case LYX_ALIGN_BLOCK: + case LYX_ALIGN_LAYOUT: + case LYX_ALIGN_SPECIAL: + break; + case LYX_ALIGN_LEFT: + if (getParLanguage(bparams)->babel() != "hebrew") { + os << "\\end{flushleft}"; + column = 15; + } else { + os << "\\end{flushright}"; + column = 16; + } + break; + case LYX_ALIGN_RIGHT: + if (getParLanguage(bparams)->babel() != "hebrew") { + os << "\\end{flushright}"; + column+= 16; + } else { + os << "\\end{flushleft}"; + column = 15; + } + break; + case LYX_ALIGN_CENTER: + os << "\\end{center}"; + column = 12; + break; + } + return column; +} + // This one spits out the text of the paragraph bool Paragraph::simpleTeXOnePar(Buffer const * buf, @@ -1485,13 +1567,6 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf, basefont = getLayoutFont(bparams); } - if (main_body >= 0 && !pimpl_->size()) { - if (style.isCommand()) { - os << '{'; - ++column; - } - } - moving_arg |= style.needprotect; // Which font is currently active? @@ -1501,6 +1576,17 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf, texrow.start(this, 0); + // if the paragraph is empty, the loop will not be entered at all + if (!size()) { + if (style.isCommand()) { + os << '{'; + ++column; + } + if (!asdefault) + column += startTeXParParams(bparams, os); + + } + for (pos_type i = 0; i < size(); ++i) { ++column; // First char in paragraph or after label? @@ -1519,45 +1605,11 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf, os << '{'; ++column; } - - if (!asdefault) { - if (params().noindent()) { - os << "\\noindent "; - column += 10; - } - switch (params().align()) { - case LYX_ALIGN_NONE: - case LYX_ALIGN_BLOCK: - case LYX_ALIGN_LAYOUT: - case LYX_ALIGN_SPECIAL: - break; - case LYX_ALIGN_LEFT: - if (getParLanguage(bparams)->babel() != "hebrew") { - os << "\\begin{flushleft}"; - column += 17; - } else { - os << "\\begin{flushright}"; - column += 18; - } - break; - case LYX_ALIGN_RIGHT: - if (getParLanguage(bparams)->babel() != "hebrew") { - os << "\\begin{flushright}"; - column += 18; - } else { - os << "\\begin{flushleft}"; - column += 17; - } - break; - case LYX_ALIGN_CENTER: - os << "\\begin{center}"; - column += 14; - break; - } - } + if (!asdefault) + column += startTeXParParams(bparams, os); } - + value_type c = getChar(i); // Fully instantiated font @@ -1663,35 +1715,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf, } if (!asdefault) { - switch (params().align()) { - case LYX_ALIGN_NONE: - case LYX_ALIGN_BLOCK: - case LYX_ALIGN_LAYOUT: - case LYX_ALIGN_SPECIAL: - break; - case LYX_ALIGN_LEFT: - if (getParLanguage(bparams)->babel() != "hebrew") { - os << "\\end{flushleft}"; - column+= 15; - } else { - os << "\\end{flushright}"; - column+= 16; - } - break; - case LYX_ALIGN_RIGHT: - if (getParLanguage(bparams)->babel() != "hebrew") { - os << "\\end{flushright}"; - column+= 16; - } else { - os << "\\end{flushleft}"; - column+= 15; - } - break; - case LYX_ALIGN_CENTER: - os << "\\end{center}"; - column+= 12; - break; - } + column += endTeXParParams(bparams, os); } lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl; diff --git a/src/paragraph.h b/src/paragraph.h index 2aad07ade8..29b201d380 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -123,6 +123,14 @@ public: Paragraph * TeXOnePar(Buffer const *, BufferParams const &, std::ostream &, TexRow & texrow, bool moving_arg); + + /// + int startTeXParParams(BufferParams const &, std::ostream &) const; + + /// + int endTeXParParams(BufferParams const &, std::ostream &) const; + + /// bool simpleTeXOnePar(Buffer const *, BufferParams const &, std::ostream &, TexRow & texrow, bool moving_arg); diff --git a/src/tabular.C b/src/tabular.C index 3145039198..6e7c13aba4 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -2653,7 +2653,7 @@ void LyXTabular::Validate(LaTeXFeatures & features) const features.require("longtable"); if (NeedRotating()) features.require("rotating"); - for (int cell = 0; !features.isRequired("array") && (cell < numberofcells); ++cell) { + for (int cell = 0; cell < numberofcells; ++cell) { if (GetVAlignment(cell) != LYX_VALIGN_TOP) features.require("array"); GetCellInset(cell)->validate(features); -- 2.39.5