From 1c090286feaab81e446c36d0a1b98612b2f0ad09 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Fri, 6 Sep 2002 13:41:19 +0000 Subject: [PATCH] Alains patch for setting tabular column global settings. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5217 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 10 ++++++++++ src/LaTeXFeatures.C | 4 ++++ src/frontends/xforms/ChangeLog | 5 +++++ src/frontends/xforms/FormTabular.C | 17 ++++++++--------- src/lyx_sty.C | 4 ++++ src/lyx_sty.h | 2 ++ src/tabular.C | 26 ++++++++++++++++++++++---- 7 files changed, 55 insertions(+), 13 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 5e2b7501c7..cd01d69670 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2002-09-06 Alain Castera + + * tabular.C: uses \tabularnewline; uses >{...} construct from array + package to set the horizontal alignment on fixed width columns. + + * lyx_sty.C: + * lyx_sty.h: added tabularnewline macro def. + + * LaTeXFeatures.C: added NeedTabularnewline macro feature + 2002-09-06 John Levon * LyXAction.C: tooltips for sub/superscript diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index 7174eb91c8..6bc5141f2a 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -339,6 +339,10 @@ string const LaTeXFeatures::getMacros() const if (isRequired("NeedLyXFootnoteCode")) macros << floatingfootnote_def; + // some problems with tex->html converters + if (isRequired("NeedTabularnewline")) + macros << tabularnewline_def; + // floats getFloatDefinitions(macros); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 7c2c76e5cc..28db42fd8a 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2002-09-06 Alain Castera + + * FormTabular.C: leave the horizontal alignment buttons alive + on fixed width columns + 2002-09-05 Angus Leeming * all files: modify the headers as discussed on the list. diff --git a/src/frontends/xforms/FormTabular.C b/src/frontends/xforms/FormTabular.C index 21d1f4912c..2056abebac 100644 --- a/src/frontends/xforms/FormTabular.C +++ b/src/frontends/xforms/FormTabular.C @@ -222,7 +222,7 @@ void FormTabular::update() } pwidth = tabular->GetMColumnPWidth(cell); align = tabular->GetAlignment(cell); - if (!pwidth.zero() || (align == LYX_ALIGN_LEFT)) + if (align == LYX_ALIGN_LEFT) fl_set_button(cell_options_->radio_align_left, 1); else if (align == LYX_ALIGN_RIGHT) fl_set_button(cell_options_->radio_align_right, 1); @@ -258,9 +258,9 @@ void FormTabular::update() setEnabled(cell_options_->radio_valign_bottom, !pwidth.zero()); setEnabled(cell_options_->radio_valign_center, !pwidth.zero()); - setEnabled(cell_options_->radio_align_left, pwidth.zero()); - setEnabled(cell_options_->radio_align_right, pwidth.zero()); - setEnabled(cell_options_->radio_align_center, pwidth.zero()); + setEnabled(cell_options_->radio_align_left, true); + setEnabled(cell_options_->radio_align_right, true); + setEnabled(cell_options_->radio_align_center, true); } else { fl_set_button(cell_options_->check_multicolumn, 0); @@ -349,7 +349,7 @@ void FormTabular::update() fl_set_button(column_options_->radio_align_left, 0); fl_set_button(column_options_->radio_align_right, 0); fl_set_button(column_options_->radio_align_center, 0); - if (!pwidth.zero() || (align == LYX_ALIGN_LEFT)) + if (align == LYX_ALIGN_LEFT) fl_set_button(column_options_->radio_align_left, 1); else if (align == LYX_ALIGN_RIGHT) fl_set_button(column_options_->radio_align_right, 1); @@ -366,10 +366,9 @@ void FormTabular::update() else fl_set_button(column_options_->radio_valign_top, 1); - setEnabled(column_options_->radio_align_left, pwidth.zero()); - setEnabled(column_options_->radio_align_right, pwidth.zero()); - setEnabled(column_options_->radio_align_center, pwidth.zero()); - + setEnabled(column_options_->radio_align_left, true); + setEnabled(column_options_->radio_align_right, true); + setEnabled(column_options_->radio_align_center, true); setEnabled(column_options_->radio_valign_top, !pwidth.zero()); setEnabled(column_options_->radio_valign_bottom, !pwidth.zero()); setEnabled(column_options_->radio_valign_center, !pwidth.zero()); diff --git a/src/lyx_sty.C b/src/lyx_sty.C index 7450237ae2..94078b90ff 100644 --- a/src/lyx_sty.C +++ b/src/lyx_sty.C @@ -118,3 +118,7 @@ string const binom_def = string const mathcircumflex_def = "%% For printing a cirumflex inside a formula\n" "\\newcommand{\\mathcircumflex}[0]{\\mbox{\\^{}}}\n"; + +string const tabularnewline_def = + "%% Because html converters don't know tabularnewline\n" + "\\providecommand{\\tabularnewline}{\\\\}\n"; diff --git a/src/lyx_sty.h b/src/lyx_sty.h index 9ac39db2c5..b7461115be 100644 --- a/src/lyx_sty.h +++ b/src/lyx_sty.h @@ -49,5 +49,7 @@ extern string const boldsymbol_def; extern string const binom_def; /// extern string const mathcircumflex_def; +/// +extern string const tabularnewline_def; #endif // LYX_STY_H diff --git a/src/tabular.C b/src/tabular.C index 68696aadd9..74c9caa17e 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -751,8 +751,9 @@ bool LyXTabular::SetColumnPWidth(int cell, LyXLength const & width) int const j = column_of_cell(cell); column_info[j].p_width = width; - if (flag) // do this only if there is a width - SetAlignment(cell, LYX_ALIGN_LEFT); + // This should not ne necessary anymore + // if (flag) // do this only if there is a width + // SetAlignment(cell, LYX_ALIGN_LEFT); for (int i = 0; i < rows_; ++i) { int c = GetCellNumber(i, j); flag = !GetPWidth(c).zero(); // because of multicolumns! @@ -2212,7 +2213,7 @@ int LyXTabular::TeXRow(ostream & os, int const i, Buffer const * buf, } ++cell; } - os << "\\\\\n"; + os << "\\tabularnewline\n"; ++ret; ret += TeXBottomHLine(os, i); return ret; @@ -2243,6 +2244,20 @@ int LyXTabular::latex(Buffer const * buf, if (column_info[i].left_line) os << '|'; if (!column_info[i].p_width.zero()) { + os << ">{"; + switch (column_info[i].alignment) { + case LYX_ALIGN_LEFT: + os << "\\raggedright"; + break; + case LYX_ALIGN_RIGHT: + os << "\\raggedleft"; + break; + case LYX_ALIGN_CENTER: + os << "\\centering"; + break; + } + os << "}"; + switch (column_info[i].valignment) { case LYX_VALIGN_TOP: os << "p"; @@ -2722,12 +2737,15 @@ int LyXTabular::GetCellFromInset(Inset const * inset, int maybe_cell) const void LyXTabular::Validate(LaTeXFeatures & features) const { + features.require("NeedTabularnewline"); if (IsLongTabular()) features.require("longtable"); if (NeedRotating()) features.require("rotating"); for (int cell = 0; cell < numberofcells; ++cell) { - if (GetVAlignment(cell) != LYX_VALIGN_TOP) + if ( (GetVAlignment(cell) != LYX_VALIGN_TOP) || + ( !(GetPWidth(cell).zero())&&!(IsMultiColumn(cell)) ) + ) features.require("array"); GetCellInset(cell)->validate(features); } -- 2.39.5