]> git.lyx.org Git - features.git/commitdiff
step 1
authorUwe Stöhr <uwestoehr@lyx.org>
Mon, 19 Mar 2012 00:21:26 +0000 (01:21 +0100)
committerUwe Stöhr <uwestoehr@lyx.org>
Wed, 21 Mar 2012 21:54:03 +0000 (22:54 +0100)
src/insets/InsetTabular.cpp
src/insets/InsetTabular.h

index 79aaf4b7245cdb177c7d7d152117e3d4a3d94bce..113bd99028407e10fb517731772d6bf95b138a09 100644 (file)
@@ -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 << "<features"
-          << write_attribute("rotate", rotate)
+          << write_attribute("rotate", convert<string>(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<string>(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<int>(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:
index 047f39a83393608e6d06b108808963ced5f3cd35..90abb4840d27b4380e2d15af06ea98fe1edeb7b3 100644 (file)
@@ -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_;