tex2lyx: support rotated longtable

This commit is contained in:
Juergen Spitzmueller 2018-08-24 08:50:32 +02:00
parent 2877032791
commit 766eb3f02c
5 changed files with 55 additions and 3 deletions

View File

@ -85,7 +85,7 @@ Context::Context(bool need_layout_,
new_layout_allowed(true), merging_hyphens_allowed(true),
textclass(textclass_),
layout(layout_), parent_layout(parent_layout_),
font(font_)
font(font_), rotlongtable(false)
{
if (!layout)
layout = &textclass.defaultLayout();

View File

@ -165,6 +165,8 @@ public:
TeXFont font;
/// font attributes of normal text
static TeXFont normalfont;
/// A rotated longtable
bool rotlongtable;
private:
void begin_layout(std::ostream & os, Layout const * const & l);

View File

@ -39,7 +39,6 @@ Format LaTeX feature LyX feature
526 Plural and capitalized refstyles InsetRef
546 Landscape support
\begin{landscape}...\end{landscape} \begin_inset Flex Landscape (see #11259)
with longtable content: <features rotate ="90"...>
555 V column type (varwidth package) Automatically detected with newlines, paragraph breaks and environment content in cells of rows
563 InsetArgument listpreamble:<nr> All content between \begin{env} and first \item of a list

View File

@ -16,6 +16,7 @@
#include "tex2lyx.h"
#include "Context.h"
#include "Preamble.h"
#include "support/lassert.h"
@ -1415,7 +1416,9 @@ void handle_tabular(Parser & p, ostream & os, string const & name,
//cerr << "// output what we have\n";
// output what we have
string const rotate = "0";
string rotate = "0";
if (is_long_tabular && context.rotlongtable)
rotate = "90";
os << "\n<lyxtabular version=\"3\" rows=\"" << rowinfo.size()
<< "\" columns=\"" << colinfo.size() << "\">\n";
os << "<features"

View File

@ -1955,6 +1955,54 @@ void parse_environment(Parser & p, ostream & os, bool outer,
break;
}
// This is only attempted at landscape environments that consists only
// of a longtable (this is how longtables in LyX are rotated by 90 degs).
// Other landscape environment is handled via the landscape module, thus
// we will fall through in that case.
if (name == "landscape") {
// We check if the next thing is a longtable
p.pushPosition();
bool found_end = false;
bool only_longtable = false;
bool end_longtable = false;
p.get_token();
p.get_token();
string envname = p.getArg('{', '}');
if (envname == "longtable") {
// Now we check if the longtable is the only content
// of the landscape environment
while (!found_end && !end_longtable && p.good()) {
envname = p.next_token().cat() == catBegin
? p.getArg('{', '}') : string();
Token const & t = p.get_token();
p.skip_spaces();
end_longtable = t.asInput() != "\\end"
&& envname == "longtable";
found_end = t.asInput() == "\\end"
&& envname == "landscape";
}
if (end_longtable) {
p.get_token();
envname = p.getArg('{', '}');
only_longtable = p.next_next_token().asInput() == "\\end"
&& envname == "landscape";
}
if (only_longtable) {
p.popPosition();
p.skip_spaces();
bool const save_rotlongtable = parent_context.rotlongtable;
parent_context.rotlongtable = true;
parse_text(p, os, FLAG_END, outer, parent_context);
parent_context.rotlongtable = save_rotlongtable;
p.skip_spaces();
break;
}
// fall through
}
// fall through
p.popPosition();
}
if (name == "framed" || name == "shaded") {
eat_whitespace(p, os, parent_context, false);
parse_outer_box(p, os, FLAG_END, outer, parent_context, name, "");