]> git.lyx.org Git - features.git/commitdiff
cosmetics
authorAndré Pönitz <poenitz@gmx.net>
Sat, 15 Mar 2008 08:43:16 +0000 (08:43 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sat, 15 Mar 2008 08:43:16 +0000 (08:43 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23759 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathArray.cpp
src/mathed/InsetMathArray.h
src/mathed/InsetMathGrid.cpp
src/mathed/InsetMathGrid.h
src/mathed/InsetMathSplit.cpp
src/mathed/InsetMathTabular.cpp
src/mathed/InsetMathTabular.h
src/mathed/MathParser.cpp

index 319e7ef55c6c85ac91dd37d6aad471f44c7b77a1..78e190e0539fda64cff1ba45ff694eb4a5fc9f4a 100644 (file)
@@ -39,12 +39,6 @@ InsetMathArray::InsetMathArray(docstring const & name, int m, int n,
 {}
 
 
-InsetMathArray::InsetMathArray(docstring const & name, char valign,
-               docstring const & halign)
-       : InsetMathGrid(valign, halign), name_(name)
-{}
-
-
 InsetMathArray::InsetMathArray(docstring const & name, docstring const & str)
        : InsetMathGrid(1, 1), name_(name)
 {
@@ -105,9 +99,10 @@ void InsetMathArray::write(WriteStream & os) const
                os << "\\protect";
        os << "\\begin{" << name_ << '}';
 
-       if (v_align_ == 't' || v_align_ == 'b')
-               os << '[' << char(v_align_) << ']';
-       os << '{' << halign() << "}\n";
+       char const v = verticalAlignment();
+       if (v == 't' || v == 'b')
+               os << '[' << v << ']';
+       os << '{' << horizontalAlignments() << "}\n";
 
        InsetMathGrid::write(os);
 
index f59d9e7304a9090cbad15a03722009359ed071d5..f6901bed161342e5eaff896c6b79696e933523c8 100644 (file)
@@ -26,8 +26,6 @@ public:
        ///
        InsetMathArray(docstring const &, int m, int n,
                char valign, docstring const & halign);
-       ///
-       InsetMathArray(docstring const &, char valign, docstring const & halign);
        /// convenience constructor from whitespace/newline separated data
        InsetMathArray(docstring const &, docstring const & str);
        ///
index ae009cff22ede84115c219f841cc81a7c131d2b6..308e059fd7c3c7ec68cb5d3820bc3368b8c3b0ab 100644 (file)
@@ -97,19 +97,6 @@ InsetMathGrid::ColInfo::ColInfo()
 //////////////////////////////////////////////////////////////
 
 
-InsetMathGrid::InsetMathGrid(char v, docstring const & h)
-       : InsetMathNest(guessColumns(h)),
-         rowinfo_(2),
-         colinfo_(guessColumns(h) + 1),
-         cellinfo_(1 * guessColumns(h))
-{
-       setDefaults();
-       valign(v);
-       halign(h);
-       //lyxerr << "created grid with " << ncols() << " columns" << endl;
-}
-
-
 InsetMathGrid::InsetMathGrid()
        : InsetMathNest(1),
          rowinfo_(1 + 1),
@@ -140,8 +127,8 @@ InsetMathGrid::InsetMathGrid(col_type m, row_type n, char v, docstring const & h
                v_align_(v)
 {
        setDefaults();
-       valign(v);
-       halign(h);
+       setVerticalAlignment(v);
+       setHorizontalAlignments(h);
 }
 
 
@@ -171,7 +158,7 @@ void InsetMathGrid::setDefaults()
 }
 
 
-void InsetMathGrid::halign(docstring const & hh)
+void InsetMathGrid::setHorizontalAlignments(docstring const & hh)
 {
        col_type col = 0;
        for (docstring::const_iterator it = hh.begin(); it != hh.end(); ++it) {
@@ -253,7 +240,7 @@ void InsetMathGrid::halign(docstring const & hh)
 }
 
 
-InsetMathGrid::col_type InsetMathGrid::guessColumns(docstring const & hh) const
+InsetMathGrid::col_type InsetMathGrid::guessColumns(docstring const & hh)
 {
        col_type col = 0;
        for (docstring::const_iterator it = hh.begin(); it != hh.end(); ++it)
@@ -268,7 +255,7 @@ InsetMathGrid::col_type InsetMathGrid::guessColumns(docstring const & hh) const
 }
 
 
-void InsetMathGrid::halign(char h, col_type col)
+void InsetMathGrid::setHorizontalAlignment(char h, col_type col)
 {
        colinfo_[col].align_ = h;
        if (!colinfo_[col].special_.empty()) {
@@ -280,13 +267,13 @@ void InsetMathGrid::halign(char h, col_type col)
 }
 
 
-char InsetMathGrid::halign(col_type col) const
+char InsetMathGrid::horizontalAlignment(col_type col) const
 {
        return colinfo_[col].align_;
 }
 
 
-docstring InsetMathGrid::halign() const
+docstring InsetMathGrid::horizontalAlignments() const
 {
        docstring res;
        for (col_type col = 0; col < ncols(); ++col) {
@@ -302,13 +289,13 @@ docstring InsetMathGrid::halign() const
 }
 
 
-void InsetMathGrid::valign(char c)
+void InsetMathGrid::setVerticalAlignment(char c)
 {
        v_align_ = c;
 }
 
 
-char InsetMathGrid::valign() const
+char InsetMathGrid::verticalAlignment() const
 {
        return v_align_;
 }
@@ -1133,17 +1120,17 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
                string s;
                is >> s;
                if (s == "valign-top")
-                       valign('t');
+                       setVerticalAlignment('t');
                else if (s == "valign-middle")
-                       valign('c');
+                       setVerticalAlignment('c');
                else if (s == "valign-bottom")
-                       valign('b');
+                       setVerticalAlignment('b');
                else if (s == "align-left")
-                       halign('l', cur.col());
+                       setHorizontalAlignment('l', cur.col());
                else if (s == "align-right")
-                       halign('r', cur.col());
+                       setHorizontalAlignment('r', cur.col());
                else if (s == "align-center")
-                       halign('c', cur.col());
+                       setHorizontalAlignment('c', cur.col());
                else if (s == "append-row")
                        for (int i = 0, n = extractInt(is); i < n; ++i)
                                addRow(cur.row());
@@ -1398,12 +1385,14 @@ bool InsetMathGrid::getStatus(Cursor & cur, FuncRequest const & cmd,
                                from_utf8(N_("Unknown tabular feature '%1$s'")), lyx::from_ascii(s)));
                }
 
-               status.setOnOff((s == "align-left" && halign(cur.col()) == 'l')
-                          || (s == "align-right"   && halign(cur.col()) == 'r')
-                          || (s == "align-center"  && halign(cur.col()) == 'c')
-                          || (s == "valign-top"    && valign() == 't')
-                          || (s == "valign-bottom" && valign() == 'b')
-                          || (s == "valign-middle" && valign() == 'm'));
+               char const ha = horizontalAlignment(cur.col());
+               char const va = verticalAlignment();
+               status.setOnOff((s == "align-left" && ha == 'l')
+                          || (s == "align-right"   && ha == 'r')
+                          || (s == "align-center"  && ha == 'c')
+                          || (s == "valign-top"    && va == 't')
+                          || (s == "valign-bottom" && va == 'b')
+                          || (s == "valign-middle" && va == 'm'));
 
 #if 0
                // FIXME: What did this code do?
index da309998d19142ba8128a23bac9f322257ce8dfc..15aa437d8a9fd409f5dd1f2a41efc52a0eb1c438 100644 (file)
@@ -91,10 +91,8 @@ public:
        };
 
 public:
-       /// sets nrows and ncols to 1
+       /// sets nrows and ncols to 1, vertical alingment to 'c'
        InsetMathGrid();
-       /// constructor from columns description, creates one row
-       InsetMathGrid(char valign, docstring const & halign);
        /// Note: columns first!
        InsetMathGrid(col_type m, row_type n);
        ///
@@ -113,18 +111,20 @@ public:
        void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
        ///
        void drawT(TextPainter & pi, int x, int y) const;
+       /// extract number of columns from alignment string
+       static col_type guessColumns(docstring const & halign);
+       /// accepts some LaTeX column codes: p,m,!,@,M,<,>
+       void setHorizontalAlignments(docstring const & align);
        ///
-       void halign(docstring const & align);
-       ///
-       void halign(char c, col_type col);
-       ///
-       char halign(col_type col) const;
+       void setHorizontalAlignment(char c, col_type col);
        ///
-       docstring halign() const;
+       char horizontalAlignment(col_type col) const;
        ///
-       void valign(char c);
+       docstring horizontalAlignments() const;
+       /// 't', 'b', or 'm'
+       void setVerticalAlignment(char c);
        ///
-       char valign() const;
+       char verticalAlignment() const;
        ///
        void vcrskip(Length const &, row_type row);
        ///
@@ -219,7 +219,8 @@ public:
        //void octave(OctaveStream &) const;
 
 protected:
-       virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
+       ///
+       void doDispatch(Cursor & cur, FuncRequest & cmd);
        ///
        bool getStatus(Cursor & cur, FuncRequest const & cmd,
                FuncStatus & flag) const;
@@ -232,8 +233,6 @@ protected:
                                      bool fragile) const;
        /// returns proper 'end of column' code for LaTeX
        virtual docstring eocString(col_type col, col_type lastcol) const;
-       /// extract number of columns from alignment string
-       col_type guessColumns(docstring const & halign) const;
        /// splits cells and shifts right part to the next cell
        void splitCell(Cursor & cur);
 
@@ -245,13 +244,14 @@ protected:
        std::vector<ColInfo> colinfo_;
        /// cell info
        std::vector<CellInfo> cellinfo_;
+private:
        ///
        char v_align_; // add approp. type
-private:
-       virtual Inset * clone() const;
+       ///
+       Inset * clone() const;
 };
 
 
-
 } // namespace lyx
+
 #endif
index 647f5cf7371eeed6b9354a4041cf2138bb05b532..01b5bcfe68c018764b7a1a6b64e598135c7253f3 100644 (file)
@@ -90,8 +90,8 @@ void InsetMathSplit::write(WriteStream & ws) const
        if (ws.fragile())
                ws << "\\protect";
        ws << "\\begin{" << name_ << '}';
-       if (name_ != "split" && valign() != 'c')
-               ws << '[' << valign() << ']';
+       if (name_ != "split" && verticalAlignment() != 'c')
+               ws << '[' << verticalAlignment() << ']';
        if (name_ == "alignedat")
                ws << '{' << static_cast<unsigned int>((ncols() + 1)/2) << '}';
        InsetMathGrid::write(ws);
index bb4e5c48381e21d6f152a6e0513bbdc03ce976e7..636c2c29f126885d76a706dedf98ae52c5bdea87 100644 (file)
@@ -34,11 +34,6 @@ InsetMathTabular::InsetMathTabular(docstring const & name, int m, int n,
 {}
 
 
-InsetMathTabular::InsetMathTabular(docstring const & name, char valign,
-               docstring const & halign)
-       : InsetMathGrid(valign, halign), name_(name)
-{}
-
 
 Inset * InsetMathTabular::clone() const
 {
@@ -75,9 +70,10 @@ void InsetMathTabular::write(WriteStream & os) const
                os << "\\protect";
        os << "\\begin{" << name_ << '}';
 
-       if (v_align_ == 't' || v_align_ == 'b')
-               os << '[' << char(v_align_) << ']';
-       os << '{' << halign() << "}\n";
+       char const v = verticalAlignment();
+       if (v == 't' || v == 'b')
+               os << '[' << v << ']';
+       os << '{' << horizontalAlignments() << "}\n";
 
        InsetMathGrid::write(os);
 
index d6c5bbac159f8b72dc239654de8518f0afb70d41..15a8809f92f82c35f6c64c089a52f50d697429a6 100644 (file)
@@ -27,8 +27,6 @@ public:
        InsetMathTabular(docstring const &, int m, int n,
                char valign, docstring const & halign);
        ///
-       InsetMathTabular(docstring const &, char valign, docstring const & halign);
-       ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
        Dimension const dimension(BufferView const &) const;
@@ -49,7 +47,7 @@ public:
        void maple(MapleStream &) const;
 
 private:
-       virtual Inset * clone() const;
+       Inset * clone() const;
        ///
        docstring name_;
 };
index d267021642c2e13e94ead6f49c3829b91ef727ac..266272e84eecd86a90f083a40fc2865b86bec626 100644 (file)
@@ -1299,14 +1299,16 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        if (name == "array" || name == "subarray") {
                                docstring const valign = parse_verbatim_option() + 'c';
                                docstring const halign = parse_verbatim_item();
-                               cell->push_back(MathAtom(new InsetMathArray(name, (char)valign[0], halign)));
+                               cell->push_back(MathAtom(new InsetMathArray(name,
+                                       InsetMathGrid::guessColumns(halign), 1, (char)valign[0], halign)));
                                parse2(cell->back(), FLAG_END, mode, false);
                        }
 
                        else if (name == "tabular") {
                                docstring const valign = parse_verbatim_option() + 'c';
                                docstring const halign = parse_verbatim_item();
-                               cell->push_back(MathAtom(new InsetMathTabular(name, (char)valign[0], halign)));
+                               cell->push_back(MathAtom(new InsetMathTabular(name,
+                                       InsetMathGrid::guessColumns(halign), 1, (char)valign[0], halign)));
                                parse2(cell->back(), FLAG_END, InsetMath::TEXT_MODE, false);
                        }