From: Uwe Stöhr Date: Mon, 19 Mar 2012 00:21:26 +0000 (+0100) Subject: step 1 X-Git-Tag: 2.1.0beta1~1933^2~84 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=304655a759665b202be5f0e33407df261d92c8c3;p=features.git step 1 --- diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 79aaf4b724..113bd99028 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -149,9 +149,9 @@ TabularFeature tabularFeature[] = { Tabular::UNSET_LONGTABULAR, "unset-longtabular", false }, { Tabular::SET_PWIDTH, "set-pwidth", true }, { Tabular::SET_MPWIDTH, "set-mpwidth", true }, - { Tabular::SET_ROTATE_TABULAR, "set-rotate-tabular", false }, - { Tabular::UNSET_ROTATE_TABULAR, "unset-rotate-tabular", false }, - { Tabular::TOGGLE_ROTATE_TABULAR, "toggle-rotate-tabular", false }, + { Tabular::SET_ROTATE_TABULAR, "set-rotate-tabular", true }, + { Tabular::UNSET_ROTATE_TABULAR, "unset-rotate-tabular", true }, + { Tabular::TOGGLE_ROTATE_TABULAR, "toggle-rotate-tabular", true }, { Tabular::SET_ROTATE_CELL, "set-rotate-cell", true }, { Tabular::UNSET_ROTATE_CELL, "unset-rotate-cell", true }, { Tabular::TOGGLE_ROTATE_CELL, "toggle-rotate-cell", true }, @@ -686,7 +686,7 @@ void Tabular::init(Buffer * buf, row_type rows_arg, tabular_valignment = LYX_VALIGN_MIDDLE; tabular_width = Length(); longtabular_alignment = LYX_LONGTABULAR_ALIGN_CENTER; - rotate = false; + rotate = 0; use_booktabs = false; // set silly default lines for (row_type r = 0; r < nrows(); ++r) @@ -1388,7 +1388,7 @@ void Tabular::write(ostream & os) const << ">\n"; // global longtable options os << "(rotate)) << write_attribute("booktabs", use_booktabs) << write_attribute("islongtable", is_long_tabular) << write_attribute("firstHeadTopDL", endfirsthead.topDL) @@ -2599,8 +2599,8 @@ void Tabular::latex(otexstream & os, OutputParams const & runparams) const if (runparams.lastid != -1) os.texrow().start(runparams.lastid, runparams.lastpos); - if (rotate) - os << "\\begin{sideways}\n"; + if (rotate != 0) + os << "\\begin{turn}" << convert(rotate) << "\n"; if (is_long_tabular) { os << "\\begin{longtable}"; @@ -2724,8 +2724,8 @@ void Tabular::latex(otexstream & os, OutputParams const & runparams) const os << "\\end{tabular}"; } - if (rotate) - os << breakln << "\\end{sideways}"; + if (rotate != 0) + os << breakln << "\\end{turn}"; } @@ -4545,7 +4545,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(tabular.rotate); + status.setOnOff(tableIsRotated()); break; case Tabular::TABULAR_VALIGN_TOP: @@ -4578,7 +4578,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd, break; case Tabular::UNSET_ROTATE_TABULAR: - status.setOnOff(!tabular.rotate); + status.setOnOff(!tableIsRotated()); break; case Tabular::TOGGLE_ROTATE_CELL: @@ -5196,6 +5196,14 @@ 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) { @@ -5549,15 +5557,19 @@ void InsetTabular::tabularFeatures(Cursor & cur, break; case Tabular::SET_ROTATE_TABULAR: - tabular.rotate = true; + tabular.rotate = convert(value); break; case Tabular::UNSET_ROTATE_TABULAR: - tabular.rotate = false; + tabular.rotate = 0; break; case Tabular::TOGGLE_ROTATE_TABULAR: - tabular.rotate = !tabular.rotate; + // when pressing the rotate button we default to 90° rotation + if (tableIsRotated()) + tabular.rotate = 90; + else + tabular.rotate = 0; break; case Tabular::TABULAR_VALIGN_TOP: diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index 047f39a833..90abb4840d 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -702,7 +702,7 @@ public: /// bool use_booktabs; /// - bool rotate; + int rotate; /// VAlignment tabular_valignment; // @@ -979,6 +979,8 @@ private: row_type row_start, row_type row_end, col_type col_start, col_type col_end) const; /// + bool tableIsRotated() const; + /// mutable idx_type first_visible_cell; /// mutable int scx_;