From feab528fd1555065592284603d8443b71f534a7a Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Wed, 18 Apr 2018 13:22:29 +0200 Subject: [PATCH] Add support for rotated longtabulars (via [pdf]lscape) Fixes: #9194 See #9194 for why we use an earlier file format change here. --- lib/chkconfig.ltx | 2 + lib/doc/LaTeXConfig.lyx | 64 ++++++++++++++++++++++++++++++++ lib/lyx2lyx/lyx_2_3.py | 26 ++++++++++++- src/LaTeXFeatures.cpp | 9 +++++ src/frontends/qt4/GuiTabular.cpp | 22 ++++++----- src/insets/InsetTabular.cpp | 18 +++++++-- 6 files changed, 126 insertions(+), 15 deletions(-) diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx index a3e3518859..7dc6812030 100644 --- a/lib/chkconfig.ltx +++ b/lib/chkconfig.ltx @@ -338,6 +338,7 @@ \TestPackage{listings} \TestPackage[lithuanian.ldf]{lithuanian} \TestPackage{longtable} +\TestPackage{lscape} \TestPackage{luainputenc} \TestPackage{mathdots} \TestPackage{mathrsfs} @@ -352,6 +353,7 @@ \TestPackage{nomencl} \TestPackage{paralist} \TestPackage{pdfcolmk} +\TestPackage{pdflscape} \TestPackage{polyglossia} \TestPackage{pdfcomment} \TestPackage{pdfpages} diff --git a/lib/doc/LaTeXConfig.lyx b/lib/doc/LaTeXConfig.lyx index fc71a6c3bc..9b95b3b259 100644 --- a/lib/doc/LaTeXConfig.lyx +++ b/lib/doc/LaTeXConfig.lyx @@ -5918,6 +5918,38 @@ natbib You'll need to have jurabib version 0.6 at least. \end_layout +\begin_layout Subsection +lscape +\end_layout + +\begin_layout Description +Found: +\begin_inset Info +type "package" +arg "lscape" +\end_inset + + +\end_layout + +\begin_layout Description +CTAN: +\series medium + +\family typewriter +\series default +macros/latex/contrib/graphics/ +\end_layout + +\begin_layout Description +Notes: The package +\family sans +lscape +\family default + is used to turn specific contents (longtables particularly) to landscape + mode with DVI/PS output. +\end_layout + \begin_layout Subsection mslapa \end_layout @@ -6031,6 +6063,38 @@ jurabib instead). \end_layout +\begin_layout Subsection +pdflscape +\end_layout + +\begin_layout Description +Found: +\begin_inset Info +type "package" +arg "pdflscape" +\end_inset + + +\end_layout + +\begin_layout Description +CTAN: +\series medium + +\family typewriter +\series default +macros/latex/contrib/oberdiek/ +\end_layout + +\begin_layout Description +Notes: The package +\family sans +pdflscape +\family default + is used to turn specific contents (longtables particularly) to landscape + mode with PDF output. +\end_layout + \begin_layout Section Packages required by modules \end_layout diff --git a/lib/lyx2lyx/lyx_2_3.py b/lib/lyx2lyx/lyx_2_3.py index 815ac2b508..ff30dd06c5 100644 --- a/lib/lyx2lyx/lyx_2_3.py +++ b/lib/lyx2lyx/lyx_2_3.py @@ -2162,6 +2162,30 @@ def revert_minted(document): del_token(document.header, "\\use_minted") +def revert_longtable_lscape(document): + " revert the longtable landcape mode to ERT " + i = 0 + regexp = re.compile(r'^setEnabled(setwidth); tabularWidthUnitLC->setEnabled(setwidth); - rotateTabularAngleSB->setEnabled(rotateTabularCB->isChecked()); + rotateTabularAngleSB->setEnabled(rotateTabularCB->isChecked() + && !longTabularCB->isChecked()); rotateCellAngleSB->setEnabled(rotateCellCB->isChecked()); bool const enable_valign = @@ -258,11 +259,8 @@ void GuiTabular::enableWidgets() const // longtables and tabular* cannot have a vertical alignment TableAlignLA->setDisabled(is_tabular_star || longtabular); TableAlignCO->setDisabled(is_tabular_star || longtabular); - // longtable cannot be rotated (with rotating package) - // FIXME: Add support for [pdf]lscape - rotateTabularCB->setDisabled(longtabular); - rotateTabularLA->setDisabled(longtabular); - // this one would also be disabled with [pdf]lscape + // longtable cannot be rotated with rotating package, only + // with [pdf]lscape, which only supports 90 deg. rotateTabularAngleSB->setDisabled(longtabular); // FIXME: This Dialog is really horrible, disabling/enabling a checkbox @@ -743,12 +741,16 @@ void GuiTabular::paramsToDialog(Inset const * inset) 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); + rotateTabularCB->setChecked(tabular.rotate != 0); + if (rotateTabularCB->isChecked()) { + if (longTabularCB->isChecked()) + rotateTabularAngleSB->setValue(90); + else + rotateTabularAngleSB->setValue(tabular.rotate != 0 ? tabular.rotate : 90); + } + borders->setTop(tabular.topLine(cell)); borders->setBottom(tabular.bottomLine(cell)); borders->setLeft(tabular.leftLine(cell)); diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index ba8cfb9445..ee666869f1 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -2763,8 +2763,12 @@ void Tabular::latex(otexstream & os, OutputParams const & runparams) const if (!TexRow::isNone(pos)) os.texrow().start(pos); - if (rotate != 0 && !is_long_tabular) - os << "\\begin{turn}{" << convert(rotate) << "}\n"; + if (rotate != 0) { + if (is_long_tabular) + os << "\\begin{landscape}\n"; + else + os << "\\begin{turn}{" << convert(rotate) << "}\n"; + } if (is_long_tabular) { os << "\\begin{longtable}"; @@ -2931,8 +2935,12 @@ void Tabular::latex(otexstream & os, OutputParams const & runparams) const os << "\\end{tabular}"; } - if (rotate != 0 && !is_long_tabular) - os << breakln << "\\end{turn}"; + if (rotate != 0) { + if (is_long_tabular) + os << breakln << "\\end{landscape}"; + else + os << breakln << "\\end{turn}"; + } if (!TexRow::isNone(pos)) os.texrow().start(pos); @@ -3477,6 +3485,8 @@ void Tabular::validate(LaTeXFeatures & features) const features.require("booktabs"); if (is_long_tabular) features.require("longtable"); + if (rotate && is_long_tabular) + features.require("lscape"); if (needRotating()) features.require("rotating"); for (idx_type cell = 0; cell < numberofcells; ++cell) { -- 2.39.5