]> git.lyx.org Git - features.git/commitdiff
bugfix: in some cases the parser created unecessary extra braces
authorAndré Pönitz <poenitz@gmx.net>
Thu, 7 Feb 2002 09:47:21 +0000 (09:47 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 7 Feb 2002 09:47:21 +0000 (09:47 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3499 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_braceinset.h
src/mathed/math_inset.h
src/mathed/math_parser.C

index 6a9c08657568127e71639efd1bddc910c7fdfa75..88031d383fd8e966261338466f7b356165fa00db 100644 (file)
@@ -20,6 +20,8 @@ public:
        ///
        MathInset * clone() const;
        ///
+       MathBraceInset * asBraceInset() { return this; }
+       ///
        void draw(Painter &, int x, int y) const;
        ///
        void write(WriteStream & os) const;
index 015d15df7948c8ac658783224d1c5be1c81bef76..42957a9b6e3fd7d62a68c8ec9ae9e0bb2a8fe43c 100644 (file)
@@ -47,6 +47,7 @@ inclusion in the "real LyX insets" FormulaInset and FormulaMacroInset.
 
 
 class MathArrayInset;
+class MathBraceInset;
 class MathBoxInset;
 class MathCharInset;
 class MathDelimInset;
@@ -176,6 +177,7 @@ public:
 
        /// identifies certain types of insets
        virtual MathArrayInset         * asArrayInset()         { return 0; }
+       virtual MathBraceInset         * asBraceInset()         { return 0; }
        virtual MathBoxInset           * asBoxInset()           { return 0; }
        virtual MathBoxInset const     * asBoxInset() const     { return 0; }
        virtual MathCharInset const    * asCharInset() const    { return 0; }
index 4a94e204fad25cd3bf5fe22c5975e1534f766560..313d2354442632fdce3f7e002cf52bf10b15f78c 100644 (file)
@@ -256,6 +256,8 @@ public:
        void putback();
 
 private:
+       ///
+       void parse_into1(MathArray & array, unsigned flags, MathTextCodes);
        ///
        string getArg(char lf, char rf);
        ///
@@ -521,6 +523,7 @@ void Parser::error(string const & msg)
 }
 
 
+
 bool Parser::parse_lines(MathAtom & t, bool numbered, bool outmost)
 {      
        MathGridInset * p = t->asGridInset();
@@ -545,7 +548,11 @@ bool Parser::parse_lines(MathAtom & t, bool numbered, bool outmost)
                for (MathInset::col_type col = 0; col < p->ncols(); ++col) {
                        //lyxerr << "reading cell " << row << " " << col << "\n";
                
-                       parse_into(p->cell(col + row * p->ncols()), FLAG_BLOCK);
+                       MathArray & ar = p->cell(col + row * p->ncols());
+                       parse_into(ar, FLAG_BLOCK);
+                       // remove 'unnecessary' braces:
+                       if (ar.size() == 1 && ar.back()->asBraceInset())
+                               ar = ar.back()->asBraceInset()->cell(0);
 
                        // break if cell is not followed by an ampersand
                        if (nextToken().cat() != catAlign) {
@@ -824,6 +831,15 @@ bool Parser::parse_normal(MathAtom & matrix)
 
 
 void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
+{
+       parse_into1(array, flags, code);
+       // remove 'unnecessary' braces:
+       if (array.size() == 1 && array.back()->asBraceInset())
+               array = array.back()->asBraceInset()->cell(0);
+}
+
+
+void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
 {
        bool panic  = false;
        int  limits = 0;