mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
full support for table rotations; fileformat change
This commit is contained in:
parent
304655a759
commit
ea54461d85
@ -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, '<features ', i)
|
||||
if i == -1:
|
||||
return
|
||||
j = document.body[i].find('rotate="')
|
||||
if j != -1:
|
||||
k = document.body[i].find('"', j + 8)
|
||||
value = document.body[i][j + 8 : k]
|
||||
if value == "0":
|
||||
rgx = re.compile(r'rotate="[^"]+?"')
|
||||
# remove rotate option
|
||||
document.body[i] = rgx.sub('', document.body[i])
|
||||
elif value == "90":
|
||||
rgx = re.compile(r'rotate="[^"]+?"')
|
||||
document.body[i] = rgx.sub('rotate="true"', document.body[i])
|
||||
else:
|
||||
rgx = re.compile(r'rotate="[^"]+?"')
|
||||
load_rotating = True
|
||||
# remove rotate option
|
||||
document.body[i] = rgx.sub('', document.body[i])
|
||||
# write ERT
|
||||
document.body[i + 5 : i + 5] = \
|
||||
put_cmd_in_ert("\\end{turn}")
|
||||
document.body[i + 4 : i + 4] = \
|
||||
put_cmd_in_ert("\\begin{turn}{" + value + "}")
|
||||
|
||||
i += 1
|
||||
|
||||
finally:
|
||||
if load_rotating:
|
||||
add_to_preamble(document, ["\\@ifundefined{turnbox}{\usepackage{rotating}}{}"])
|
||||
|
||||
|
||||
def convert_table_rotation(document):
|
||||
'Convert table rotation statements from "true" to "90"'
|
||||
|
||||
i = 0
|
||||
while True:
|
||||
# first, let's find out if we need to do anything
|
||||
i = find_token(document.body, '<features ', i)
|
||||
if i == -1:
|
||||
return
|
||||
j = document.body[i].find('rotate="true"')
|
||||
if j != -1:
|
||||
rgx = re.compile(r'rotate="[^"]+?"')
|
||||
# convert "true" to "90"
|
||||
document.body[i] = rgx.sub('rotate="90"', document.body[i])
|
||||
|
||||
i += 1
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -651,10 +709,12 @@ convert = [
|
||||
[425, []],
|
||||
[426, []],
|
||||
[427, []],
|
||||
[428, [convert_cell_rotation]]
|
||||
[428, [convert_cell_rotation]],
|
||||
[429, [convert_table_rotation]]
|
||||
]
|
||||
|
||||
revert = [
|
||||
[428, [revert_table_rotation]],
|
||||
[427, [revert_cell_rotation]],
|
||||
[426, [revert_tipa]],
|
||||
[425, [revert_verbatim]],
|
||||
|
@ -143,6 +143,8 @@ GuiTabular::GuiTabular(QWidget * parent)
|
||||
this, SLOT(checkEnabled()));
|
||||
connect(rotateTabularCB, SIGNAL(clicked()),
|
||||
this, SLOT(checkEnabled()));
|
||||
connect(rotateTabularAngleSB, SIGNAL(valueChanged(int)),
|
||||
this, SLOT(checkEnabled()));
|
||||
connect(rotateCellCB, SIGNAL(clicked()),
|
||||
this, SLOT(checkEnabled()));
|
||||
connect(rotateCellAngleSB, SIGNAL(valueChanged(int)),
|
||||
@ -213,11 +215,12 @@ void GuiTabular::checkEnabled()
|
||||
decimalLA->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<string>(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<string>(rotateCellAngleSB->value());
|
||||
string const cell_angle = convert<string>(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);
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>497</width>
|
||||
<height>400</height>
|
||||
<height>402</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -107,7 +107,7 @@
|
||||
<string>&Table Settings</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="GroupBox12">
|
||||
<property name="title">
|
||||
<string>Column settings</string>
|
||||
@ -307,115 +307,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="specialAlignmentLA">
|
||||
<property name="text">
|
||||
<string>LaTe&X argument:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>specialAlignmentED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="specialAlignmentED">
|
||||
<property name="toolTip">
|
||||
<string>Custom column format (LaTeX)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="tabAlignmentGB">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Table-wide settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="tabularWidthLA">
|
||||
<property name="text">
|
||||
<string>Table w&idth:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>tabularWidthED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="LengthCombo" name="tabularWidthUnitLC"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="tabularWidthED"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="TableAlignLA">
|
||||
<property name="text">
|
||||
<string>Verti&cal alignment:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>vAlignCO</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="TableAlignCO">
|
||||
<property name="toolTip">
|
||||
<string>Vertical alignment of the table</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Middle</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bottom</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<spacer name="spacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>153</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QCheckBox" name="rotateTabularCB">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Rotate the table by 90 degrees</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Rotate table 90 degrees</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
@ -468,7 +359,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<item row="1" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Cell setting</string>
|
||||
@ -539,6 +430,154 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="tabAlignmentGB">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Table-wide settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="tabularWidthLA">
|
||||
<property name="text">
|
||||
<string>W&idth:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>tabularWidthED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="tabularWidthED"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="LengthCombo" name="tabularWidthUnitLC"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="TableAlignLA">
|
||||
<property name="text">
|
||||
<string>Verti&cal alignment:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>vAlignCO</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="TableAlignCO">
|
||||
<property name="toolTip">
|
||||
<string>Vertical alignment of the table</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Middle</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bottom</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="spacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>153</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="rotateTabularCB">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Rotate the table by 90 degrees</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Rotate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="rotateTabularAngleSB">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>rotation angle</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-180</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>180</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>90</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="rotateTabularLA">
|
||||
<property name="text">
|
||||
<string>degrees</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>tabularWidthED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="specialAlignmentLA">
|
||||
<property name="text">
|
||||
<string>LaTe&X argument:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>specialAlignmentED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="specialAlignmentED">
|
||||
<property name="toolTip">
|
||||
<string>Custom column format (LaTeX)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="Borders">
|
||||
|
@ -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<string>(rotate) << "\n";
|
||||
os << "\\begin{turn}{" << convert<string>(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:
|
||||
|
@ -1272,7 +1272,7 @@ void handle_tabular(Parser & p, ostream & os, string const & name,
|
||||
os << "\n<lyxtabular version=\"3\" rows=\"" << rowinfo.size()
|
||||
<< "\" columns=\"" << colinfo.size() << "\">\n";
|
||||
os << "<features"
|
||||
<< write_attribute("rotate", false)
|
||||
<< write_attribute("rotate", "0")
|
||||
<< write_attribute("booktabs", booktabs)
|
||||
<< write_attribute("islongtable", is_long_tabular);
|
||||
if (is_long_tabular) {
|
||||
|
@ -30,8 +30,8 @@ extern char const * const lyx_version_info;
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
#define LYX_FORMAT_LYX 428 // uwestoehr: rotated table cells
|
||||
#define LYX_FORMAT_TEX2LYX 428 // uwestoehr: rotated table cells
|
||||
#define LYX_FORMAT_LYX 429 // uwestoehr: rotated tables
|
||||
#define LYX_FORMAT_TEX2LYX 429 // uwestoehr: rotated tables
|
||||
|
||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||
#ifndef _MSC_VER
|
||||
|
Loading…
Reference in New Issue
Block a user