From: Uwe Stöhr Date: Wed, 21 Mar 2012 22:04:45 +0000 (+0100) Subject: full support for table rotations; fileformat change X-Git-Tag: 2.1.0beta1~1933^2~83 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ea54461d8507c31ad2245a7df0b6c18c11544eed;p=features.git full support for table rotations; fileformat change --- diff --git a/lib/lyx2lyx/lyx_2_1.py b/lib/lyx2lyx/lyx_2_1.py index 1c7f781250..1c0ebf00c1 100644 --- a/lib/lyx2lyx/lyx_2_1.py +++ b/lib/lyx2lyx/lyx_2_1.py @@ -631,6 +631,64 @@ def convert_cell_rotation(document): i += 1 +def revert_table_rotation(document): + "Revert table rotations to TeX-code" + + load_rotating = False + i = 0 + try: + while True: + # first, let's find out if we need to do anything + i = find_token(document.body, 'setEnabled(dalign); bool const setwidth = TableAlignCO->currentText() == qt_("Middle") - && !longTabularCB->isChecked() && !rotateTabularCB->isChecked(); + && !longTabularCB->isChecked(); tabularWidthLA->setEnabled(setwidth); tabularWidthED->setEnabled(setwidth); tabularWidthUnitLC->setEnabled(setwidth); + rotateTabularAngleSB->setEnabled(rotateTabularCB->isChecked()); rotateCellAngleSB->setEnabled(rotateCellCB->isChecked()); bool const enable_valign = @@ -557,17 +560,18 @@ docstring GuiTabular::dialogToParams() const setParam(param_str, Tabular::SET_MULTIROW); else setParam(param_str, Tabular::UNSET_MULTIROW); - // + // store the table rotation angle + string const tabular_angle = convert(rotateTabularAngleSB->value()); if (rotateTabularCB->isChecked()) - setParam(param_str, Tabular::SET_ROTATE_TABULAR); + setParam(param_str, Tabular::SET_ROTATE_TABULAR, tabular_angle); else - setParam(param_str, Tabular::UNSET_ROTATE_TABULAR); + setParam(param_str, Tabular::UNSET_ROTATE_TABULAR, tabular_angle); // store the cell rotation angle - string angle = convert(rotateCellAngleSB->value()); + string const cell_angle = convert(rotateCellAngleSB->value()); if (rotateCellCB->isChecked()) - setParam(param_str, Tabular::SET_ROTATE_CELL, angle); + setParam(param_str, Tabular::SET_ROTATE_CELL, cell_angle); else - setParam(param_str, Tabular::UNSET_ROTATE_CELL, angle); + setParam(param_str, Tabular::UNSET_ROTATE_CELL, cell_angle); // if (longTabularCB->isChecked()) setParam(param_str, Tabular::SET_LONGTABULAR); @@ -704,11 +708,16 @@ void GuiTabular::paramsToDialog(Inset const * inset) multirowCB->setChecked(multirow); rotateCellCB->setChecked(tabular.getRotateCell(cell) != 0); - if (tabular.getRotateCell(cell) != 0) - rotateCellAngleSB->setValue(tabular.getRotateCell(cell)); - else - rotateCellAngleSB->setValue(90); - rotateTabularCB->setChecked(tabular.rotate); + if (rotateCellCB->isChecked()) { + if (tabular.getRotateCell(cell) != 0) + rotateCellAngleSB->setValue(tabular.getRotateCell(cell)); + else + rotateCellAngleSB->setValue(90); + } + + rotateTabularCB->setChecked(tabular.rotate != 0); + if (rotateTabularCB->isChecked()) + rotateTabularAngleSB->setValue(tabular.rotate != 0 ? tabular.rotate : 90); longTabularCB->setChecked(tabular.is_long_tabular); diff --git a/src/frontends/qt4/ui/TabularUi.ui b/src/frontends/qt4/ui/TabularUi.ui index 733bbfca6f..39c09228f3 100644 --- a/src/frontends/qt4/ui/TabularUi.ui +++ b/src/frontends/qt4/ui/TabularUi.ui @@ -7,7 +7,7 @@ 0 0 497 - 400 + 402 @@ -107,7 +107,7 @@ &Table Settings - + Column settings @@ -307,115 +307,6 @@ - - - - LaTe&X argument: - - - specialAlignmentED - - - - - - - Custom column format (LaTeX) - - - - - - - true - - - Table-wide settings - - - - - - Table w&idth: - - - tabularWidthED - - - - - - - - - - - - - Verti&cal alignment: - - - vAlignCO - - - - - - - Vertical alignment of the table - - - 1 - - - - Top - - - - - Middle - - - - - Bottom - - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 153 - 20 - - - - - - - - true - - - Rotate the table by 90 degrees - - - &Rotate table 90 degrees - - - - - - @@ -468,7 +359,7 @@ - + Cell setting @@ -539,6 +430,154 @@ + + + + true + + + Table-wide settings + + + + + + W&idth: + + + tabularWidthED + + + + + + + + + + + + + Verti&cal alignment: + + + vAlignCO + + + + + + + Vertical alignment of the table + + + 1 + + + + Top + + + + + Middle + + + + + Bottom + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 153 + 20 + + + + + + + + + + true + + + Rotate the table by 90 degrees + + + &Rotate + + + + + + + + 51 + 20 + + + + rotation angle + + + -180 + + + 180 + + + 5 + + + 90 + + + + + + + degrees + + + tabularWidthED + + + + + + + + + + + + LaTe&X argument: + + + specialAlignmentED + + + + + + + Custom column format (LaTeX) + + + diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 113bd99028..00ee719d81 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -2600,7 +2600,7 @@ void Tabular::latex(otexstream & os, OutputParams const & runparams) const os.texrow().start(runparams.lastid, runparams.lastpos); if (rotate != 0) - os << "\\begin{turn}" << convert(rotate) << "\n"; + os << "\\begin{turn}{" << convert(rotate) << "}\n"; if (is_long_tabular) { os << "\\begin{longtable}"; @@ -4544,8 +4544,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd, case Tabular::TOGGLE_ROTATE_TABULAR: case Tabular::SET_ROTATE_TABULAR: - status.setEnabled(tabular.tabular_width.zero()); - status.setOnOff(tableIsRotated()); + status.setOnOff(tabular.rotate != 0); break; case Tabular::TABULAR_VALIGN_TOP: @@ -4578,7 +4577,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd, break; case Tabular::UNSET_ROTATE_TABULAR: - status.setOnOff(!tableIsRotated()); + status.setOnOff(tabular.rotate == 0); break; case Tabular::TOGGLE_ROTATE_CELL: @@ -5196,13 +5195,6 @@ bool InsetTabular::oneCellHasRotationState(bool rotated, return false; } -bool InsetTabular::tableIsRotated() const -{ - if (tabular.rotate != 0) - return true; - else - return false; -} void InsetTabular::tabularFeatures(Cursor & cur, Tabular::Feature feature, string const & value) @@ -5566,10 +5558,7 @@ void InsetTabular::tabularFeatures(Cursor & cur, case Tabular::TOGGLE_ROTATE_TABULAR: // when pressing the rotate button we default to 90° rotation - if (tableIsRotated()) - tabular.rotate = 90; - else - tabular.rotate = 0; + tabular.rotate != 0 ? tabular.rotate = 0 : tabular.rotate = 90; break; case Tabular::TABULAR_VALIGN_TOP: diff --git a/src/tex2lyx/table.cpp b/src/tex2lyx/table.cpp index 7ba5344d13..ca3a84cdae 100644 --- a/src/tex2lyx/table.cpp +++ b/src/tex2lyx/table.cpp @@ -1272,7 +1272,7 @@ void handle_tabular(Parser & p, ostream & os, string const & name, os << "\n\n"; os << "