Revert r32566 and r32568.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32569 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2009-12-17 17:42:21 +00:00
parent 46e1424678
commit 812616e100
2 changed files with 15 additions and 21 deletions

View File

@ -17,7 +17,7 @@
// or \sum, \prod... for interfacing external programs // or \sum, \prod... for interfacing external programs
#include "InsetMathNest.h" #include "InsetMathNest.h"
#include "support/strfwd.h"
namespace lyx { namespace lyx {
@ -57,13 +57,11 @@ public:
void write(WriteStream & os) const; void write(WriteStream & os) const;
/// ///
InsetCode lyxCode() const { return MATH_EXINT_CODE; } InsetCode lyxCode() const { return MATH_EXINT_CODE; }
/// is this a sum, product, or whatever that we can handle?
/// note that this does not include integrals.
static bool isExIntOperator(docstring const &);
private: private:
virtual Inset * clone() const; virtual Inset * clone() const;
/// ///
bool hasScripts() const; bool hasScripts() const;
/// ///
docstring symbol_; docstring symbol_;
}; };

View File

@ -80,6 +80,7 @@ typedef bool TestItemFunc(MathAtom const &);
typedef MathAtom ReplaceArgumentFunc(const MathData & ar); typedef MathAtom ReplaceArgumentFunc(const MathData & ar);
// try to extract a super/subscript // try to extract a super/subscript
// modify iterator position to point behind the thing // modify iterator position to point behind the thing
bool extractScript(MathData & ar, bool extractScript(MathData & ar,
@ -355,7 +356,7 @@ void splitScripts(MathData & ar)
// leave alone sums and integrals // leave alone sums and integrals
InsetMathSymbol const * sym = InsetMathSymbol const * sym =
script->nuc().front()->asSymbolInset(); script->nuc().front()->asSymbolInset();
if (sym && (InsetMathExInt::isExIntOperator(sym->name()) || sym->name() == "int")) if (sym && (sym->name() == "sum" || sym->name() == "int"))
continue; continue;
} }
@ -704,29 +705,25 @@ bool testEqualSign(MathAtom const & at)
} }
bool testSumLikeSymbol(MathAtom const & p) bool testSumSymbol(MathAtom const & p)
{ {
return InsetMathExInt::isExIntOperator(p->name()); return testSymbol(p, from_ascii("sum"));
} }
docstring testSumLike(MathAtom const & at) bool testSum(MathAtom const & at)
{ {
if (testSumLikeSymbol(at)) return
return at->name(); testSumSymbol(at) ||
if ( at->asScriptInset() ( at->asScriptInset()
&& at->asScriptInset()->nuc().size() && at->asScriptInset()->nuc().size()
&& testSumLikeSymbol(at->asScriptInset()->nuc().back()) ) && testSumSymbol(at->asScriptInset()->nuc().back()) );
return at->asScriptInset()->nuc().back()->name();
return docstring();
} }
// replace '\sum' ['_^'] f(x) sequences by a real InsetMathExInt // replace '\sum' ['_^'] f(x) sequences by a real InsetMathExInt
// and similar things, like \prod. The things we extract are
// determined by InsetMathExInt::isExIntOperator().
// assume 'extractDelims' ran before // assume 'extractDelims' ran before
void extractSumLike(MathData & ar) void extractSums(MathData & ar)
{ {
// we need at least two items... // we need at least two items...
if (ar.size() < 2) if (ar.size() < 2)
@ -739,12 +736,11 @@ void extractSumLike(MathData & ar)
MathData::iterator it = ar.begin() + i; MathData::iterator it = ar.begin() + i;
// is this a sum name? // is this a sum name?
docstring const opname = testSumLike(ar[i]); if (!testSum(ar[i]))
if (opname.empty())
continue; continue;
// create a proper inset as replacement // create a proper inset as replacement
auto_ptr<InsetMathExInt> p(new InsetMathExInt(buf, opname)); auto_ptr<InsetMathExInt> p(new InsetMathExInt(buf, from_ascii("sum")));
// collect lower bound and summation index // collect lower bound and summation index
InsetMathScript const * sub = ar[i]->asScriptInset(); InsetMathScript const * sub = ar[i]->asScriptInset();
@ -953,7 +949,7 @@ void extractStructure(MathData & ar, ExternalMath kind)
splitScripts(ar); splitScripts(ar);
extractDelims(ar); extractDelims(ar);
extractIntegrals(ar, kind); extractIntegrals(ar, kind);
extractSumLike(ar); extractSums(ar);
extractNumbers(ar); extractNumbers(ar);
extractMatrices(ar); extractMatrices(ar);
extractFunctions(ar, kind); extractFunctions(ar, kind);