fix bugs 200, 201, 196

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3421 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2002-01-19 20:24:04 +00:00
parent f0a372d294
commit 34e27f8c26
8 changed files with 124 additions and 81 deletions

View File

@ -1,5 +1,13 @@
2002-01-19 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr> 2002-01-19 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* 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 * vspace.C (inPixels): adapt to the change below
(inPixels): [later] more cleanups (remove unused variables) (inPixels): [later] more cleanups (remove unused variables)

View File

@ -2545,15 +2545,15 @@ void Buffer::latexParagraphs(ostream & ofs, Paragraph * par,
if ((in == 0) || !in->forceDefaultParagraphs(in)) { if ((in == 0) || !in->forceDefaultParagraphs(in)) {
LyXLayout const & layout = LyXLayout const & layout =
textclasslist.Style(params.textclass, par->layout); textclasslist.Style(params.textclass, par->layout);
if (layout.intitle) { if (layout.intitle) {
if (already_title) { if (already_title) {
lyxerr <<"Error in latexParagraphs: You" lyxerr <<"Error in latexParagraphs: You"
" should not mix title layouts" " should not mix title layouts"
" with normal ones." << endl; " with normal ones." << endl;
} else } else
was_title = true; was_title = true;
} else if (was_title && !already_title) { } else if (was_title && !already_title) {
ofs << "\\maketitle\n"; ofs << "\\maketitle\n";
texrow.newline(); texrow.newline();
already_title = true; already_title = true;

View File

@ -1,5 +1,8 @@
2002-01-19 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr> 2002-01-19 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* ControlDialog_impl.h (ControlConnectBI>): make ControlDialogBI
derive from ControlDialog<ControlConnectBI> (fixes bug #196)
* helper_funcs.C (browseRelFile): forgot to pass dir2 to browseFile * helper_funcs.C (browseRelFile): forgot to pass dir2 to browseFile
2002-01-17 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr> 2002-01-17 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>

View File

@ -18,5 +18,5 @@ ControlDialogBD::ControlDialogBD(LyXView & lv, Dialogs & d)
ControlDialogBI::ControlDialogBI(LyXView & lv, Dialogs & d) ControlDialogBI::ControlDialogBI(LyXView & lv, Dialogs & d)
: ControlDialog<ControlConnectBD>(lv, d) : ControlDialog<ControlConnectBI>(lv, d)
{} {}

View File

@ -28,7 +28,7 @@ public:
}; };
class ControlDialogBI : public ControlDialog<ControlConnectBD> class ControlDialogBI : public ControlDialog<ControlConnectBI>
{ {
public: public:
/// ///

View File

@ -894,7 +894,7 @@ void Paragraph::breakParagraph(BufferParams const & bparams,
// copy everything behind the break-position // copy everything behind the break-position
// to the new paragraph // to the new paragraph
pos_type pos_end = pimpl_->size() - 1; pos_type pos_end = size() - 1;
pos_type i = pos; pos_type i = pos;
pos_type j = pos; pos_type j = pos;
for (; i <= pos_end; ++i) { for (; i <= pos_end; ++i) {
@ -970,7 +970,7 @@ void Paragraph::breakParagraphConservative(BufferParams const & bparams,
if (size() > pos) { if (size() > pos) {
// copy everything behind the break-position to the new // copy everything behind the break-position to the new
// paragraph // paragraph
pos_type pos_end = pimpl_->size() - 1; pos_type pos_end = size() - 1;
//pos_type i = pos; //pos_type i = pos;
//pos_type j = pos; //pos_type j = pos;
@ -1440,6 +1440,88 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
return next_; 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 // This one spits out the text of the paragraph
bool Paragraph::simpleTeXOnePar(Buffer const * buf, bool Paragraph::simpleTeXOnePar(Buffer const * buf,
@ -1485,13 +1567,6 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
basefont = getLayoutFont(bparams); basefont = getLayoutFont(bparams);
} }
if (main_body >= 0 && !pimpl_->size()) {
if (style.isCommand()) {
os << '{';
++column;
}
}
moving_arg |= style.needprotect; moving_arg |= style.needprotect;
// Which font is currently active? // Which font is currently active?
@ -1501,6 +1576,17 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
texrow.start(this, 0); 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) { for (pos_type i = 0; i < size(); ++i) {
++column; ++column;
// First char in paragraph or after label? // First char in paragraph or after label?
@ -1519,45 +1605,11 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
os << '{'; os << '{';
++column; ++column;
} }
if (!asdefault) {
if (params().noindent()) {
os << "\\noindent ";
column += 10;
}
switch (params().align()) { if (!asdefault)
case LYX_ALIGN_NONE: column += startTeXParParams(bparams, os);
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;
}
}
} }
value_type c = getChar(i); value_type c = getChar(i);
// Fully instantiated font // Fully instantiated font
@ -1663,35 +1715,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
} }
if (!asdefault) { if (!asdefault) {
switch (params().align()) { column += endTeXParParams(bparams, os);
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;
}
} }
lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl; lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;

View File

@ -123,6 +123,14 @@ public:
Paragraph * TeXOnePar(Buffer const *, BufferParams const &, Paragraph * TeXOnePar(Buffer const *, BufferParams const &,
std::ostream &, TexRow & texrow, std::ostream &, TexRow & texrow,
bool moving_arg); bool moving_arg);
///
int startTeXParParams(BufferParams const &, std::ostream &) const;
///
int endTeXParParams(BufferParams const &, std::ostream &) const;
/// ///
bool simpleTeXOnePar(Buffer const *, BufferParams const &, bool simpleTeXOnePar(Buffer const *, BufferParams const &,
std::ostream &, TexRow & texrow, bool moving_arg); std::ostream &, TexRow & texrow, bool moving_arg);

View File

@ -2653,7 +2653,7 @@ void LyXTabular::Validate(LaTeXFeatures & features) const
features.require("longtable"); features.require("longtable");
if (NeedRotating()) if (NeedRotating())
features.require("rotating"); 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) if (GetVAlignment(cell) != LYX_VALIGN_TOP)
features.require("array"); features.require("array");
GetCellInset(cell)->validate(features); GetCellInset(cell)->validate(features);