summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-04-24 13:50:11 (UTC)
committer mickeyl <mickeyl>2004-04-24 13:50:11 (UTC)
commit0e24210ea7aa2deaf2facf29c366413aa93d0482 (patch) (unidiff)
tree1adae72f49c3f5005be836e6e7525dc79fb098cd
parent9ac401fbe5c80f710757926920d734e93a7e159b (diff)
downloadopie-0e24210ea7aa2deaf2facf29c366413aa93d0482.zip
opie-0e24210ea7aa2deaf2facf29c366413aa93d0482.tar.gz
opie-0e24210ea7aa2deaf2facf29c366413aa93d0482.tar.bz2
gcc 3.4 fixlet
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-sheet/sheet.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/noncore/apps/opie-sheet/sheet.cpp b/noncore/apps/opie-sheet/sheet.cpp
index d4419af..88847da 100644
--- a/noncore/apps/opie-sheet/sheet.cpp
+++ b/noncore/apps/opie-sheet/sheet.cpp
@@ -1708,773 +1708,773 @@ QString Sheet::calculateFunction(const QString &func, const QString &parameters,
1708 val3=calculateVariable(getParameter(parameters, 2, TRUE, function)).toDouble(&ok); 1708 val3=calculateVariable(getParameter(parameters, 2, TRUE, function)).toDouble(&ok);
1709 vali=calculateVariable(getParameter(parameters, 3, TRUE, function)).toInt(&ok); 1709 vali=calculateVariable(getParameter(parameters, 3, TRUE, function)).toInt(&ok);
1710 if(vali==1)//distribution 1710 if(vali==1)//distribution
1711 { 1711 {
1712 return QString::number( 1712 return QString::number(
1713 (ErrorFunction((val1-val2)/(sqrt(2)*val3))+1)/2.0 1713 (ErrorFunction((val1-val2)/(sqrt(2)*val3))+1)/2.0
1714 ); 1714 );
1715 }else //density 1715 }else //density
1716 { 1716 {
1717 return QString::number( 1717 return QString::number(
1718 exp(-pow(((val1-val2)/val3),2)/2)/(val3*sqrt(2*M_PI)) 1718 exp(-pow(((val1-val2)/val3),2)/2)/(val3*sqrt(2*M_PI))
1719 ); 1719 );
1720 }; 1720 };
1721 }; 1721 };
1722 if(function=="PHI") 1722 if(function=="PHI")
1723 { 1723 {
1724 // NORMALDIST (x,distribution?density1:0) with mean=0 s=1.0 1724 // NORMALDIST (x,distribution?density1:0) with mean=0 s=1.0
1725 val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok); 1725 val1=calculateVariable(getParameter(parameters, 0, TRUE, function)).toDouble(&ok);
1726 vali=calculateVariable(getParameter(parameters, 1, TRUE, function)).toInt(&ok); 1726 vali=calculateVariable(getParameter(parameters, 1, TRUE, function)).toInt(&ok);
1727 if(vali==1)//distribution 1727 if(vali==1)//distribution
1728 { 1728 {
1729 return QString::number( 1729 return QString::number(
1730 (ErrorFunction(val1/(sqrt(2)))+1)/2.0 1730 (ErrorFunction(val1/(sqrt(2)))+1)/2.0
1731 ); 1731 );
1732 }else //density 1732 }else //density
1733 { 1733 {
1734 return QString::number( 1734 return QString::number(
1735 exp(-pow(val1,2)/2)/(sqrt(2*M_PI)) 1735 exp(-pow(val1,2)/2)/(sqrt(2*M_PI))
1736 ); 1736 );
1737 }; 1737 };
1738 }; 1738 };
1739 /* 1739 /*
1740 StudentTDistribution/: PDF[StudentTDistribution[n_], x_] := 1740 StudentTDistribution/: PDF[StudentTDistribution[n_], x_] :=
1741 1/(Sqrt[n] Beta[n/2, 1/2]) Sqrt[n/(n+x^2)]^(n+1) /; 1741 1/(Sqrt[n] Beta[n/2, 1/2]) Sqrt[n/(n+x^2)]^(n+1) /;
1742 ParameterQ[StudentTDistribution[n]] 1742 ParameterQ[StudentTDistribution[n]]
1743 1743
1744 StudentTDistribution/: CDF[StudentTDistribution[n_], x_] := 1744 StudentTDistribution/: CDF[StudentTDistribution[n_], x_] :=
1745 (1 + Sign[x] BetaRegularized[n/(n+x^2), 1, n/2, 1/2])/2 /; 1745 (1 + Sign[x] BetaRegularized[n/(n+x^2), 1, n/2, 1/2])/2 /;
1746 ParameterQ[StudentTDistribution[n]] 1746 ParameterQ[StudentTDistribution[n]]
1747 */ 1747 */
1748 1748
1749 1749
1750 1750
1751 return 0; 1751 return 0;
1752}; 1752};
1753 1753
1754 1754
1755 1755
1756 1756
1757QString Sheet::dataParserHelper(const QString &data) 1757QString Sheet::dataParserHelper(const QString &data)
1758{ 1758{
1759 if(data.left(1)=="""" && data.right(1)=="""") return QString(data); 1759 if(data.left(1)=="""" && data.right(1)=="""") return QString(data);
1760 Expression exp1(data); 1760 Expression exp1(data);
1761 exp1.Parse(); 1761 exp1.Parse();
1762 QStack<QString> stack1; 1762 QStack<QString> stack1;
1763 stack1.setAutoDelete(TRUE); 1763 stack1.setAutoDelete(TRUE);
1764 int i=0; 1764 int i=0;
1765 QString* s1; 1765 QString* s1;
1766 QString* s2=NULL; 1766 QString* s2=NULL;
1767 int* i1; 1767 int* i1;
1768 int args,tokentype; 1768 int args,tokentype;
1769 QString tempval; 1769 QString tempval;
1770 s1=exp1.CompiledBody.first();i1=exp1.CompiledBodyType.first(); 1770 s1=exp1.CompiledBody.first();i1=exp1.CompiledBodyType.first();
1771 while(i<=(int)exp1.CompiledBody.count()-1) 1771 while(i<=(int)exp1.CompiledBody.count()-1)
1772 { 1772 {
1773 args= ((*i1) & 0xFF00)>>8; tokentype=(*i1) & 0x00FF; 1773 args= ((*i1) & 0xFF00)>>8; tokentype=(*i1) & 0x00FF;
1774 if(tokentype==NUMBER_TOKEN) 1774 if(tokentype==NUMBER_TOKEN)
1775 { 1775 {
1776 stack1.push(new QString(*s1)); 1776 stack1.push(new QString(*s1));
1777 //printf("Parse:Number=%s\r\n",s1->latin1()); 1777 //printf("Parse:Number=%s\r\n",s1->latin1());
1778 } 1778 }
1779 else if(tokentype==VARIABLE_TOKEN) 1779 else if(tokentype==VARIABLE_TOKEN)
1780 { 1780 {
1781 stack1.push(new QString(QString(*s1).upper())); 1781 stack1.push(new QString(QString(*s1).upper()));
1782 //printf("Parse:Var=%s\r\n",s1->latin1()); 1782 //printf("Parse:Var=%s\r\n",s1->latin1());
1783 //here to put implementation of other types of variables except cell. 1783 //here to put implementation of other types of variables except cell.
1784 //for example names 1784 //for example names
1785 } 1785 }
1786 else if(tokentype==STRING_TOKEN) 1786 else if(tokentype==STRING_TOKEN)
1787 { 1787 {
1788 stack1.push(new QString(*s1)); 1788 stack1.push(new QString(*s1));
1789 //printf("Parse:String=%s\r\n",s1->ascii()); 1789 //printf("Parse:String=%s\r\n",s1->ascii());
1790 } 1790 }
1791 else if(tokentype==FUNCTION_TOKEN) 1791 else if(tokentype==FUNCTION_TOKEN)
1792 { 1792 {
1793 QString params=""; 1793 QString params="";
1794 for(int w1=1;w1<=args;w1++) 1794 for(int w1=1;w1<=args;w1++)
1795 { 1795 {
1796 if((int)stack1.count()!=0) s2=stack1.pop(); 1796 if((int)stack1.count()!=0) s2=stack1.pop();
1797 params=*s2+params;//args in reverse order 1797 params=*s2+params;//args in reverse order
1798 params=","+params; 1798 params=","+params;
1799 }; 1799 };
1800 params=params.mid(1); 1800 params=params.mid(1);
1801 if(params==NULL) params="0"; 1801 if(params==NULL) params="0";
1802 //printf("Parse:Func=%s, params=%s, stackcount=%d,args=%d\r\n" 1802 //printf("Parse:Func=%s, params=%s, stackcount=%d,args=%d\r\n"
1803 //,s1->latin1(),params.latin1(),stack1.count(),args); 1803 //,s1->latin1(),params.latin1(),stack1.count(),args);
1804 tempval=calculateFunction(*s1,params,args); 1804 tempval=calculateFunction(*s1,params,args);
1805 tempval=tempval; 1805 tempval=tempval;
1806 stack1.push(new QString(tempval)); 1806 stack1.push(new QString(tempval));
1807 }; 1807 };
1808 1808
1809 //loops to next token 1809 //loops to next token
1810 if(exp1.CompiledBody.next()!=NULL) s1=exp1.CompiledBody.current(); else break; 1810 if(exp1.CompiledBody.next()!=NULL) s1=exp1.CompiledBody.current(); else break;
1811 if(exp1.CompiledBodyType.next()!=NULL) i1=exp1.CompiledBodyType.current(); else break; 1811 if(exp1.CompiledBodyType.next()!=NULL) i1=exp1.CompiledBodyType.current(); else break;
1812 i++; 1812 i++;
1813 }; 1813 };
1814 if((int)stack1.count()!=0)s2=stack1.pop(); else s2=new QString("!ERROR"); 1814 if((int)stack1.count()!=0)s2=stack1.pop(); else s2=new QString("!ERROR");
1815 tempval=*s2; 1815 tempval=*s2;
1816 return(tempval); 1816 return(tempval);
1817}; 1817};
1818 1818
1819 1819
1820 1820
1821QString Sheet::dataParser(const QString &cell, const QString &data) 1821QString Sheet::dataParser(const QString &cell, const QString &data)
1822{ 1822{
1823 QString strippedData(data); 1823 QString strippedData(data);
1824 strippedData.replace(QRegExp("\\s"), ""); 1824 strippedData.replace(QRegExp("\\s"), "");
1825 if (strippedData.isEmpty() || strippedData[0]!='=') return data; 1825 if (strippedData.isEmpty() || strippedData[0]!='=') return data;
1826 if (listDataParser.find(cell)!=listDataParser.end()) return "0"; 1826 if (listDataParser.find(cell)!=listDataParser.end()) return "0";
1827 listDataParser.append(cell); 1827 listDataParser.append(cell);
1828 // printf("DATAPARSER: data=%s, cell=%s\r\n",data.ascii(),cell.ascii()); 1828 // printf("DATAPARSER: data=%s, cell=%s\r\n",data.ascii(),cell.ascii());
1829 strippedData=dataParserHelper(strippedData.remove(0, 1).replace(QRegExp(":"), ",")); 1829 strippedData=dataParserHelper(strippedData.remove(0, 1).replace(QRegExp(":"), ","));
1830 1830
1831 int i=0; 1831 int i=0;
1832 QString tempParameter(getParameter(strippedData, i)), result=""; 1832 QString tempParameter(getParameter(strippedData, i)), result="";
1833 do 1833 do
1834 { 1834 {
1835 result+=","+calculateVariable(tempParameter); 1835 result+=","+calculateVariable(tempParameter);
1836 tempParameter=getParameter(strippedData, ++i); 1836 tempParameter=getParameter(strippedData, ++i);
1837 } 1837 }
1838 while (!tempParameter.isNull()); 1838 while (!tempParameter.isNull());
1839 listDataParser.remove(cell); 1839 listDataParser.remove(cell);
1840 return result.mid(1); 1840 return result.mid(1);
1841} 1841}
1842 1842
1843 1843
1844void Sheet::setData(const QString &data) 1844void Sheet::setData(const QString &data)
1845{ 1845{
1846 setText(currentRow(), currentColumn(), data); 1846 setText(currentRow(), currentColumn(), data);
1847 slotCellChanged(currentRow(), currentColumn()); 1847 slotCellChanged(currentRow(), currentColumn());
1848 activateNextCell(); 1848 activateNextCell();
1849} 1849}
1850 1850
1851QString Sheet::getData() 1851QString Sheet::getData()
1852{ 1852{
1853 typeCellData *cellData=findCellData(currentRow(), currentColumn()); 1853 typeCellData *cellData=findCellData(currentRow(), currentColumn());
1854 if (cellData) 1854 if (cellData)
1855 return cellData->data; 1855 return cellData->data;
1856 return ""; 1856 return "";
1857} 1857}
1858 1858
1859void Sheet::lockClicks(bool lock) 1859void Sheet::lockClicks(bool lock)
1860{ 1860{
1861 clicksLocked=lock; 1861 clicksLocked=lock;
1862} 1862}
1863 1863
1864void Sheet::paintCell(QPainter *p, int row, int col, const QRect & cr, bool selected) 1864void Sheet::paintCell(QPainter *p, int row, int col, const QRect & cr, bool selected)
1865{ 1865{
1866 if (selected && row==currentRow() && col==currentColumn()) selected=FALSE; 1866 if (selected && row==currentRow() && col==currentColumn()) selected=FALSE;
1867 1867
1868 int sheetDataCurrent=sheetData.at(); 1868 int sheetDataCurrent=sheetData.at();
1869 typeCellData *cellData=findCellData(row, col); 1869 typeCellData *cellData=findCellData(row, col);
1870 if (sheetDataCurrent>=0) sheetData.at(sheetDataCurrent); 1870 if (sheetDataCurrent>=0) sheetData.at(sheetDataCurrent);
1871 if (!cellData) cellData=&defaultCellData; 1871 if (!cellData) cellData=&defaultCellData;
1872 if (selected) 1872 if (selected)
1873 p->fillRect(0, 0, cr.width(), cr.height(), colorGroup().highlight()); 1873 p->fillRect(0, 0, cr.width(), cr.height(), colorGroup().highlight());
1874 else 1874 else
1875 { 1875 {
1876 p->fillRect(0, 0, cr.width(), cr.height(), colorGroup().base()); 1876 p->fillRect(0, 0, cr.width(), cr.height(), colorGroup().base());
1877 p->fillRect(0, 0, cr.width(), cr.height(), cellData->background); 1877 p->fillRect(0, 0, cr.width(), cr.height(), cellData->background);
1878 } 1878 }
1879 1879
1880 QTableItem *cellItem=item(row, col); 1880 QTableItem *cellItem=item(row, col);
1881 if (cellItem) 1881 if (cellItem)
1882 { 1882 {
1883 p->setPen(selected ? colorGroup().highlightedText() : cellData->fontColor); 1883 p->setPen(selected ? colorGroup().highlightedText() : cellData->fontColor);
1884 p->setFont(cellData->font); 1884 p->setFont(cellData->font);
1885 QString str=cellItem->text(); 1885 QString str=cellItem->text();
1886 p->drawText(2, 2, cr.width()-4, cr.height()-4, cellData->alignment, cellItem->text()); 1886 p->drawText(2, 2, cr.width()-4, cr.height()-4, cellData->alignment, cellItem->text());
1887 } 1887 }
1888 1888
1889 int rx=cr.width()-1, ry=cr.height()-1; 1889 int rx=cr.width()-1, ry=cr.height()-1;
1890 QPen pen(p->pen()); 1890 QPen pen(p->pen());
1891 p->setPen(cellData->borders.right); 1891 p->setPen(cellData->borders.right);
1892 p->drawLine(rx, 0, rx, ry); 1892 p->drawLine(rx, 0, rx, ry);
1893 p->setPen(cellData->borders.bottom); 1893 p->setPen(cellData->borders.bottom);
1894 p->drawLine(0, ry, rx, ry); 1894 p->drawLine(0, ry, rx, ry);
1895 p->setPen(pen); 1895 p->setPen(pen);
1896} 1896}
1897 1897
1898void Sheet::viewportMousePressEvent(QMouseEvent *e) 1898void Sheet::viewportMousePressEvent(QMouseEvent *e)
1899{ 1899{
1900 QMouseEvent ce(e->type(), viewportToContents(e->pos()), e->globalPos(), e->button(), e->state()); 1900 QMouseEvent ce(e->type(), viewportToContents(e->pos()), e->globalPos(), e->button(), e->state());
1901 if (clicksLocked) 1901 if (clicksLocked)
1902 { 1902 {
1903 if (selectionNo<0) 1903 if (selectionNo<0)
1904 { 1904 {
1905 clearSelection(); 1905 clearSelection();
1906 QTableSelection newSelection; 1906 QTableSelection newSelection;
1907 newSelection.init(rowAt(ce.pos().y()), columnAt(ce.pos().x())); 1907 newSelection.init(rowAt(ce.pos().y()), columnAt(ce.pos().x()));
1908 newSelection.expandTo(newSelection.anchorRow(), newSelection.anchorCol()); 1908 newSelection.expandTo(newSelection.anchorRow(), newSelection.anchorCol());
1909 selectionNo=addSelection(newSelection); 1909 selectionNo=addSelection(newSelection);
1910 } 1910 }
1911 } 1911 }
1912 else 1912 else
1913 QTable::contentsMousePressEvent(&ce); 1913 QTable::contentsMousePressEvent(&ce);
1914} 1914}
1915 1915
1916void Sheet::viewportMouseMoveEvent(QMouseEvent *e) 1916void Sheet::viewportMouseMoveEvent(QMouseEvent *e)
1917{ 1917{
1918 QMouseEvent ce(e->type(), viewportToContents(e->pos()), e->globalPos(), e->button(), e->state()); 1918 QMouseEvent ce(e->type(), viewportToContents(e->pos()), e->globalPos(), e->button(), e->state());
1919 if (clicksLocked) 1919 if (clicksLocked)
1920 { 1920 {
1921 if (selectionNo>=0) 1921 if (selectionNo>=0)
1922 { 1922 {
1923 QTableSelection oldSelection(selection(selectionNo)); 1923 QTableSelection oldSelection(selection(selectionNo));
1924 oldSelection.expandTo(rowAt(ce.pos().y()), columnAt(ce.pos().x())); 1924 oldSelection.expandTo(rowAt(ce.pos().y()), columnAt(ce.pos().x()));
1925 if (!(oldSelection==selection(selectionNo))) 1925 if (!(oldSelection==selection(selectionNo)))
1926 { 1926 {
1927 removeSelection(selectionNo); 1927 removeSelection(selectionNo);
1928 selectionNo=addSelection(oldSelection); 1928 selectionNo=addSelection(oldSelection);
1929 } 1929 }
1930 } 1930 }
1931 } 1931 }
1932 else 1932 else
1933 QTable::contentsMouseMoveEvent(&ce); 1933 QTable::contentsMouseMoveEvent(&ce);
1934} 1934}
1935 1935
1936void Sheet::viewportMouseReleaseEvent(QMouseEvent *e) 1936void Sheet::viewportMouseReleaseEvent(QMouseEvent *e)
1937{ 1937{
1938 QMouseEvent ce(e->type(), viewportToContents(e->pos()), e->globalPos(), e->button(), e->state()); 1938 QMouseEvent ce(e->type(), viewportToContents(e->pos()), e->globalPos(), e->button(), e->state());
1939 if (clicksLocked && selectionNo>=0) 1939 if (clicksLocked && selectionNo>=0)
1940 { 1940 {
1941 QTableSelection oldSelection(selection(selectionNo)); 1941 QTableSelection oldSelection(selection(selectionNo));
1942 oldSelection.expandTo(rowAt(ce.pos().y()), columnAt(ce.pos().x())); 1942 oldSelection.expandTo(rowAt(ce.pos().y()), columnAt(ce.pos().x()));
1943 removeSelection(selectionNo); 1943 removeSelection(selectionNo);
1944 selectionNo=-1; 1944 selectionNo=-1;
1945 if (oldSelection.topRow()==oldSelection.bottomRow() && oldSelection.leftCol()==oldSelection.rightCol()) 1945 if (oldSelection.topRow()==oldSelection.bottomRow() && oldSelection.leftCol()==oldSelection.rightCol())
1946 emit cellClicked(findCellName(oldSelection.topRow(), oldSelection.leftCol())); 1946 emit cellClicked(findCellName(oldSelection.topRow(), oldSelection.leftCol()));
1947 else 1947 else
1948 emit cellClicked(findCellName(oldSelection.topRow(), oldSelection.leftCol())+','+findCellName(oldSelection.bottomRow(), oldSelection.rightCol())); 1948 emit cellClicked(findCellName(oldSelection.topRow(), oldSelection.leftCol())+','+findCellName(oldSelection.bottomRow(), oldSelection.rightCol()));
1949 } 1949 }
1950 else 1950 else
1951 QTable::contentsMouseReleaseEvent(&ce); 1951 QTable::contentsMouseReleaseEvent(&ce);
1952} 1952}
1953 1953
1954QString Sheet::findCellName(int row, int col) 1954QString Sheet::findCellName(int row, int col)
1955{ 1955{
1956 return (getHeaderString(col+1)+QString::number(row+1)); 1956 return (getHeaderString(col+1)+QString::number(row+1));
1957} 1957}
1958 1958
1959void Sheet::copySheetData(QList<typeCellData> *destSheetData) 1959void Sheet::copySheetData(QList<typeCellData> *destSheetData)
1960{ 1960{
1961 typeCellData *tempCellData, *newCellData; 1961 typeCellData *tempCellData, *newCellData;
1962 destSheetData->clear(); 1962 destSheetData->clear();
1963 1963
1964 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) 1964 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next())
1965 { 1965 {
1966 newCellData=new typeCellData; 1966 newCellData=new typeCellData;
1967 *newCellData=*tempCellData; 1967 *newCellData=*tempCellData;
1968 destSheetData->append(newCellData); 1968 destSheetData->append(newCellData);
1969 } 1969 }
1970} 1970}
1971 1971
1972void Sheet::setSheetData(QList<typeCellData> *srcSheetData) 1972void Sheet::setSheetData(QList<typeCellData> *srcSheetData)
1973{ 1973{
1974 typeCellData *tempCellData, *newCellData; 1974 typeCellData *tempCellData, *newCellData;
1975 1975
1976 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) 1976 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next())
1977 { 1977 {
1978 clearCell(tempCellData->row, tempCellData->col); 1978 clearCell(tempCellData->row, tempCellData->col);
1979 updateCell(tempCellData->row, tempCellData->col); 1979 updateCell(tempCellData->row, tempCellData->col);
1980 } 1980 }
1981 sheetData.clear(); 1981 sheetData.clear();
1982 1982
1983 for (tempCellData=srcSheetData->first(); tempCellData; tempCellData=srcSheetData->next()) 1983 for (tempCellData=srcSheetData->first(); tempCellData; tempCellData=srcSheetData->next())
1984 { 1984 {
1985 newCellData=new typeCellData; 1985 newCellData=new typeCellData;
1986 *newCellData=*tempCellData; 1986 *newCellData=*tempCellData;
1987 sheetData.append(newCellData); 1987 sheetData.append(newCellData);
1988 setText(newCellData->row, newCellData->col, dataParser(findCellName(newCellData->row, newCellData->col), newCellData->data)); 1988 setText(newCellData->row, newCellData->col, dataParser(findCellName(newCellData->row, newCellData->col), newCellData->data));
1989 } 1989 }
1990 emit sheetModified(); 1990 emit sheetModified();
1991} 1991}
1992 1992
1993void Sheet::setName(const QString &name) 1993void Sheet::setName(const QString &name)
1994{ 1994{
1995 sheetName=name; 1995 sheetName=name;
1996 emit sheetModified(); 1996 emit sheetModified();
1997} 1997}
1998 1998
1999QString Sheet::getName() 1999QString Sheet::getName()
2000{ 2000{
2001 return sheetName; 2001 return sheetName;
2002} 2002}
2003 2003
2004void Sheet::setBrush(int row, int col, const QBrush &brush) 2004void Sheet::setBrush(int row, int col, const QBrush &brush)
2005{ 2005{
2006 typeCellData *cellData=findCellData(row, col); 2006 typeCellData *cellData=findCellData(row, col);
2007 if (!cellData) cellData=createCellData(row, col); 2007 if (!cellData) cellData=createCellData(row, col);
2008 if (cellData) 2008 if (cellData)
2009 { 2009 {
2010 cellData->background=brush; 2010 cellData->background=brush;
2011 emit sheetModified(); 2011 emit sheetModified();
2012 } 2012 }
2013} 2013}
2014 2014
2015QBrush Sheet::getBrush(int row, int col) 2015QBrush Sheet::getBrush(int row, int col)
2016{ 2016{
2017 typeCellData *cellData=findCellData(row, col); 2017 typeCellData *cellData=findCellData(row, col);
2018 if (!cellData) cellData=&defaultCellData; 2018 if (!cellData) cellData=&defaultCellData;
2019 return cellData->background; 2019 return cellData->background;
2020} 2020}
2021 2021
2022void Sheet::setTextAlign(int row, int col, Qt::AlignmentFlags flags) 2022void Sheet::setTextAlign(int row, int col, Qt::AlignmentFlags flags)
2023{ 2023{
2024 typeCellData *cellData=findCellData(row, col); 2024 typeCellData *cellData=findCellData(row, col);
2025 if (!cellData) cellData=createCellData(row, col); 2025 if (!cellData) cellData=createCellData(row, col);
2026 if (cellData) 2026 if (cellData)
2027 { 2027 {
2028 cellData->alignment=flags; 2028 cellData->alignment=flags;
2029 emit sheetModified(); 2029 emit sheetModified();
2030 } 2030 }
2031} 2031}
2032 2032
2033Qt::AlignmentFlags Sheet::getAlignment(int row, int col) 2033Qt::AlignmentFlags Sheet::getAlignment(int row, int col)
2034{ 2034{
2035 typeCellData *cellData=findCellData(row, col); 2035 typeCellData *cellData=findCellData(row, col);
2036 if (!cellData) cellData=&defaultCellData; 2036 if (!cellData) cellData=&defaultCellData;
2037 return cellData->alignment; 2037 return cellData->alignment;
2038} 2038}
2039 2039
2040void Sheet::setTextFont(int row, int col, const QFont &font, const QColor &color) 2040void Sheet::setTextFont(int row, int col, const QFont &font, const QColor &color)
2041{ 2041{
2042 typeCellData *cellData=findCellData(row, col); 2042 typeCellData *cellData=findCellData(row, col);
2043 if (!cellData) cellData=createCellData(row, col); 2043 if (!cellData) cellData=createCellData(row, col);
2044 if (cellData) 2044 if (cellData)
2045 { 2045 {
2046 cellData->font=font; 2046 cellData->font=font;
2047 cellData->fontColor=color; 2047 cellData->fontColor=color;
2048 emit sheetModified(); 2048 emit sheetModified();
2049 } 2049 }
2050} 2050}
2051 2051
2052QFont Sheet::getFont(int row, int col) 2052QFont Sheet::getFont(int row, int col)
2053{ 2053{
2054 typeCellData *cellData=findCellData(row, col); 2054 typeCellData *cellData=findCellData(row, col);
2055 if (!cellData) cellData=&defaultCellData; 2055 if (!cellData) cellData=&defaultCellData;
2056 return cellData->font; 2056 return cellData->font;
2057} 2057}
2058 2058
2059QColor Sheet::getFontColor(int row, int col) 2059QColor Sheet::getFontColor(int row, int col)
2060{ 2060{
2061 typeCellData *cellData=findCellData(row, col); 2061 typeCellData *cellData=findCellData(row, col);
2062 if (!cellData) cellData=&defaultCellData; 2062 if (!cellData) cellData=&defaultCellData;
2063 return cellData->fontColor; 2063 return cellData->fontColor;
2064} 2064}
2065 2065
2066void Sheet::setPen(int row, int col, int vertical, const QPen &pen) 2066void Sheet::setPen(int row, int col, int vertical, const QPen &pen)
2067{ 2067{
2068 typeCellData *cellData=findCellData(row, col); 2068 typeCellData *cellData=findCellData(row, col);
2069 if (!cellData) cellData=createCellData(row, col); 2069 if (!cellData) cellData=createCellData(row, col);
2070 if (cellData) 2070 if (cellData)
2071 { 2071 {
2072 if (vertical) 2072 if (vertical)
2073 cellData->borders.right=pen; 2073 cellData->borders.right=pen;
2074 else 2074 else
2075 cellData->borders.bottom=pen; 2075 cellData->borders.bottom=pen;
2076 emit sheetModified(); 2076 emit sheetModified();
2077 } 2077 }
2078} 2078}
2079 2079
2080QPen Sheet::getPen(int row, int col, int vertical) 2080QPen Sheet::getPen(int row, int col, int vertical)
2081{ 2081{
2082 typeCellData *cellData=findCellData(row, col); 2082 typeCellData *cellData=findCellData(row, col);
2083 if (!cellData) cellData=&defaultCellData; 2083 if (!cellData) cellData=&defaultCellData;
2084 return (vertical ? cellData->borders.right : cellData->borders.bottom); 2084 return (vertical ? cellData->borders.right : cellData->borders.bottom);
2085} 2085}
2086 2086
2087void Sheet::getSelection(int *row1, int *col1, int *row2, int *col2) 2087void Sheet::getSelection(int *row1, int *col1, int *row2, int *col2)
2088{ 2088{
2089 int selectionNo=currentSelection(); 2089 int selectionNo=currentSelection();
2090 if (selectionNo>=0) 2090 if (selectionNo>=0)
2091 { 2091 {
2092 QTableSelection selection(selection(selectionNo)); 2092 QTableSelection select(selection(selectionNo));
2093 *row1=selection.topRow(); 2093 *row1=select.topRow();
2094 *row2=selection.bottomRow(); 2094 *row2=select.bottomRow();
2095 *col1=selection.leftCol(); 2095 *col1=select.leftCol();
2096 *col2=selection.rightCol(); 2096 *col2=select.rightCol();
2097 } 2097 }
2098 else 2098 else
2099 { 2099 {
2100 *row1=*row2=currentRow(); 2100 *row1=*row2=currentRow();
2101 *col1=*col2=currentColumn(); 2101 *col1=*col2=currentColumn();
2102 } 2102 }
2103} 2103}
2104 2104
2105void Sheet::editClear() 2105void Sheet::editClear()
2106{ 2106{
2107 int row1, row2, col1, col2; 2107 int row1, row2, col1, col2;
2108 getSelection(&row1, &col1, &row2, &col2); 2108 getSelection(&row1, &col1, &row2, &col2);
2109 2109
2110 int row, col; 2110 int row, col;
2111 for (row=row1; row<=row2; ++row) 2111 for (row=row1; row<=row2; ++row)
2112 for (col=col1; col<=col2; ++col) 2112 for (col=col1; col<=col2; ++col)
2113 { 2113 {
2114 setText(row, col, ""); 2114 setText(row, col, "");
2115 slotCellChanged(row, col); 2115 slotCellChanged(row, col);
2116 } 2116 }
2117} 2117}
2118 2118
2119void Sheet::editCopy() 2119void Sheet::editCopy()
2120{ 2120{
2121 clipboardData.clear(); 2121 clipboardData.clear();
2122 2122
2123 int row1, row2, col1, col2; 2123 int row1, row2, col1, col2;
2124 getSelection(&row1, &col1, &row2, &col2); 2124 getSelection(&row1, &col1, &row2, &col2);
2125 2125
2126 typeCellData *cellData, *newCellData; 2126 typeCellData *cellData, *newCellData;
2127 int row, col; 2127 int row, col;
2128 for (row=row1; row<=row2; ++row) 2128 for (row=row1; row<=row2; ++row)
2129 for (col=col1; col<=col2; ++col) 2129 for (col=col1; col<=col2; ++col)
2130 { 2130 {
2131 cellData=findCellData(row, col); 2131 cellData=findCellData(row, col);
2132 if (cellData) 2132 if (cellData)
2133 { 2133 {
2134 newCellData=new typeCellData; 2134 newCellData=new typeCellData;
2135 *newCellData=*cellData; 2135 *newCellData=*cellData;
2136 newCellData->row-=row1; 2136 newCellData->row-=row1;
2137 newCellData->col-=col1; 2137 newCellData->col-=col1;
2138 clipboardData.append(newCellData); 2138 clipboardData.append(newCellData);
2139 } 2139 }
2140 } 2140 }
2141} 2141}
2142 2142
2143void Sheet::editCut() 2143void Sheet::editCut()
2144{ 2144{
2145 editCopy(); 2145 editCopy();
2146 editClear(); 2146 editClear();
2147} 2147}
2148 2148
2149void Sheet::editPaste(bool onlyContents) 2149void Sheet::editPaste(bool onlyContents)
2150{ 2150{
2151 int row1=currentRow(), col1=currentColumn(); 2151 int row1=currentRow(), col1=currentColumn();
2152 typeCellData *cellData, *tempCellData; 2152 typeCellData *cellData, *tempCellData;
2153 2153
2154 for (tempCellData=clipboardData.first(); tempCellData; tempCellData=clipboardData.next()) 2154 for (tempCellData=clipboardData.first(); tempCellData; tempCellData=clipboardData.next())
2155 { 2155 {
2156 cellData=findCellData(tempCellData->row+row1, tempCellData->col+col1); 2156 cellData=findCellData(tempCellData->row+row1, tempCellData->col+col1);
2157 if (!cellData) cellData=createCellData(tempCellData->row+row1, tempCellData->col+col1); 2157 if (!cellData) cellData=createCellData(tempCellData->row+row1, tempCellData->col+col1);
2158 if (cellData) 2158 if (cellData)
2159 { 2159 {
2160 if (onlyContents) 2160 if (onlyContents)
2161 cellData->data=tempCellData->data; 2161 cellData->data=tempCellData->data;
2162 else 2162 else
2163 { 2163 {
2164 *cellData=*tempCellData; 2164 *cellData=*tempCellData;
2165 cellData->row+=row1; 2165 cellData->row+=row1;
2166 cellData->col+=col1; 2166 cellData->col+=col1;
2167 } 2167 }
2168 setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); 2168 setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data));
2169 emit sheetModified(); 2169 emit sheetModified();
2170 } 2170 }
2171 } 2171 }
2172} 2172}
2173 2173
2174void Sheet::insertRows(int no, bool allColumns) 2174void Sheet::insertRows(int no, bool allColumns)
2175{ 2175{
2176 setNumRows(numRows()+no); 2176 setNumRows(numRows()+no);
2177 2177
2178 typeCellData *tempCellData; 2178 typeCellData *tempCellData;
2179 int row=currentRow(), col=currentColumn(); 2179 int row=currentRow(), col=currentColumn();
2180 2180
2181 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) 2181 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next())
2182 if (tempCellData->row>=row && (allColumns || tempCellData->col==col)) 2182 if (tempCellData->row>=row && (allColumns || tempCellData->col==col))
2183 { 2183 {
2184 clearCell(tempCellData->row, tempCellData->col); 2184 clearCell(tempCellData->row, tempCellData->col);
2185 tempCellData->row+=no; 2185 tempCellData->row+=no;
2186 } 2186 }
2187 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) 2187 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next())
2188 if (tempCellData->row>=row && (allColumns || tempCellData->col==col)) 2188 if (tempCellData->row>=row && (allColumns || tempCellData->col==col))
2189 { 2189 {
2190 updateCell(tempCellData->row-no, tempCellData->col); 2190 updateCell(tempCellData->row-no, tempCellData->col);
2191 setText(tempCellData->row, tempCellData->col, dataParser(findCellName(tempCellData->row, tempCellData->col), tempCellData->data)); 2191 setText(tempCellData->row, tempCellData->col, dataParser(findCellName(tempCellData->row, tempCellData->col), tempCellData->data));
2192 } 2192 }
2193 emit sheetModified(); 2193 emit sheetModified();
2194} 2194}
2195 2195
2196void Sheet::insertColumns(int no, bool allRows) 2196void Sheet::insertColumns(int no, bool allRows)
2197{ 2197{
2198 int noCols=numCols(); 2198 int noCols=numCols();
2199 int newCols=noCols+no; 2199 int newCols=noCols+no;
2200 setNumCols(newCols); 2200 setNumCols(newCols);
2201 for (int i=noCols; i<newCols; ++i) 2201 for (int i=noCols; i<newCols; ++i)
2202 horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); 2202 horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH);
2203 2203
2204 typeCellData *tempCellData; 2204 typeCellData *tempCellData;
2205 int col=currentColumn(), row=currentRow(); 2205 int col=currentColumn(), row=currentRow();
2206 2206
2207 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) 2207 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next())
2208 if (tempCellData->col>=col && (allRows || tempCellData->row==row)) 2208 if (tempCellData->col>=col && (allRows || tempCellData->row==row))
2209 { 2209 {
2210 clearCell(tempCellData->row, tempCellData->col); 2210 clearCell(tempCellData->row, tempCellData->col);
2211 tempCellData->col+=no; 2211 tempCellData->col+=no;
2212 } 2212 }
2213 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) 2213 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next())
2214 if (tempCellData->col>=col && (allRows || tempCellData->row==row)) 2214 if (tempCellData->col>=col && (allRows || tempCellData->row==row))
2215 { 2215 {
2216 updateCell(tempCellData->row, tempCellData->col-no); 2216 updateCell(tempCellData->row, tempCellData->col-no);
2217 setText(tempCellData->row, tempCellData->col, dataParser(findCellName(tempCellData->row, tempCellData->col), tempCellData->data)); 2217 setText(tempCellData->row, tempCellData->col, dataParser(findCellName(tempCellData->row, tempCellData->col), tempCellData->data));
2218 } 2218 }
2219 emit sheetModified(); 2219 emit sheetModified();
2220} 2220}
2221 2221
2222void Sheet::dataFindReplace(const QString &findStr, const QString &replaceStr, bool matchCase, bool allCells, bool entireCell, bool replace, bool replaceAll) 2222void Sheet::dataFindReplace(const QString &findStr, const QString &replaceStr, bool matchCase, bool allCells, bool entireCell, bool replace, bool replaceAll)
2223{ 2223{
2224 typeCellData *tempCellData; 2224 typeCellData *tempCellData;
2225 int row1, col1, row2, col2; 2225 int row1, col1, row2, col2;
2226 getSelection(&row1, &col1, &row2, &col2); 2226 getSelection(&row1, &col1, &row2, &col2);
2227 bool found=FALSE; 2227 bool found=FALSE;
2228 2228
2229 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) 2229 for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next())
2230 if (allCells || (tempCellData->row>=row1 && tempCellData->row<=row2 && tempCellData->col>=col1 && tempCellData->col<=col2)) 2230 if (allCells || (tempCellData->row>=row1 && tempCellData->row<=row2 && tempCellData->col>=col1 && tempCellData->col<=col2))
2231 { 2231 {
2232 QTableItem *cellItem=item(tempCellData->row, tempCellData->col); 2232 QTableItem *cellItem=item(tempCellData->row, tempCellData->col);
2233 if (cellItem && (entireCell ? (matchCase ? cellItem->text()==findStr : cellItem->text().upper()==findStr.upper()) : cellItem->text().find(findStr, 0, matchCase)>=0)) 2233 if (cellItem && (entireCell ? (matchCase ? cellItem->text()==findStr : cellItem->text().upper()==findStr.upper()) : cellItem->text().find(findStr, 0, matchCase)>=0))
2234 { 2234 {
2235 if (!found) 2235 if (!found)
2236 { 2236 {
2237 found=TRUE; 2237 found=TRUE;
2238 clearSelection(); 2238 clearSelection();
2239 } 2239 }
2240 setCurrentCell(tempCellData->row, tempCellData->col); 2240 setCurrentCell(tempCellData->row, tempCellData->col);
2241 if (replace) 2241 if (replace)
2242 { 2242 {
2243 tempCellData->data=cellItem->text().replace(QRegExp(findStr, matchCase), replaceStr); 2243 tempCellData->data=cellItem->text().replace(QRegExp(findStr, matchCase), replaceStr);
2244 setText(tempCellData->row, tempCellData->col, dataParser(findCellName(tempCellData->row, tempCellData->col), tempCellData->data)); 2244 setText(tempCellData->row, tempCellData->col, dataParser(findCellName(tempCellData->row, tempCellData->col), tempCellData->data));
2245 } 2245 }
2246 if (!replace || !replaceAll) break; 2246 if (!replace || !replaceAll) break;
2247 } 2247 }
2248 } 2248 }
2249 2249
2250 if (found) 2250 if (found)
2251 { 2251 {
2252 if (replace) 2252 if (replace)
2253 slotCellChanged(currentRow(), currentColumn()); 2253 slotCellChanged(currentRow(), currentColumn());
2254 } 2254 }
2255 else 2255 else
2256 QMessageBox::warning(this, tr("Error"), tr("Search key not found!")); 2256 QMessageBox::warning(this, tr("Error"), tr("Search key not found!"));
2257} 2257}
2258 2258
2259// 2259//
2260// Static functions 2260// Static functions
2261// 2261//
2262 2262
2263QString Sheet::getHeaderString(int section) 2263QString Sheet::getHeaderString(int section)
2264{ 2264{
2265 if (section<1) return ""; 2265 if (section<1) return "";
2266 return getHeaderString((section-1)/26)+QChar('A'+(section-1)%26); 2266 return getHeaderString((section-1)/26)+QChar('A'+(section-1)%26);
2267} 2267}
2268 2268
2269int Sheet::getHeaderColumn(const QString &section) 2269int Sheet::getHeaderColumn(const QString &section)
2270{ 2270{
2271 if (section.isEmpty()) return 0; 2271 if (section.isEmpty()) return 0;
2272 return (section[section.length()-1]-'A'+1)+getHeaderColumn(section.left(section.length()-1))*26; 2272 return (section[section.length()-1]-'A'+1)+getHeaderColumn(section.left(section.length()-1))*26;
2273} 2273}
2274 2274
2275 2275
2276//Expression Parser Class Definition 2276//Expression Parser Class Definition
2277 2277
2278 2278
2279QChar Expression::chunk0(void) 2279QChar Expression::chunk0(void)
2280{ 2280{
2281 if(chunk.length()>0) return(chunk[0]); else return('\0'); 2281 if(chunk.length()>0) return(chunk[0]); else return('\0');
2282}; 2282};
2283 2283
2284Expression::Expression(QString expr1)// constructor 2284Expression::Expression(QString expr1)// constructor
2285{ 2285{
2286 Body=expr1; 2286 Body=expr1;
2287 SYMBOL="+-*/%^=()<>&|!,"; 2287 SYMBOL="+-*/%^=()<>&|!,";
2288 MATHSYMBOL="+-*/%^=<>&|!,"; 2288 MATHSYMBOL="+-*/%^=<>&|!,";
2289 // lnlim=1.0e-36; // Smallest number allowed 2289 // lnlim=1.0e-36; // Smallest number allowed
2290 // loglim=1.0e-10 ; // Smallest number allowed in call to log10() * 2290 // loglim=1.0e-10 ; // Smallest number allowed in call to log10() *
2291 ErrorFound=TRUE; 2291 ErrorFound=TRUE;
2292 n=0;chunk="";SymbGroup=NONE_TOKEN;InExpr=Body; 2292 n=0;chunk="";SymbGroup=NONE_TOKEN;InExpr=Body;
2293 ArgsOfFunc=0; 2293 ArgsOfFunc=0;
2294 CompiledBody.setAutoDelete(TRUE); 2294 CompiledBody.setAutoDelete(TRUE);
2295 CompiledBodyType.setAutoDelete(TRUE); 2295 CompiledBodyType.setAutoDelete(TRUE);
2296 //CompiledBody=QStringList(0); 2296 //CompiledBody=QStringList(0);
2297}; 2297};
2298 2298
2299bool Expression::isSymbol(QChar ch) 2299bool Expression::isSymbol(QChar ch)
2300{ 2300{
2301 int j = 0; 2301 int j = 0;
2302 while (j<=((int)SYMBOL.length()-1) && ch!=SYMBOL[j]) j++; 2302 while (j<=((int)SYMBOL.length()-1) && ch!=SYMBOL[j]) j++;
2303 if(j<((int)SYMBOL.length())) return true; else return false; 2303 if(j<((int)SYMBOL.length())) return true; else return false;
2304}; 2304};
2305 2305
2306bool Expression::isMathSymbol(QChar ch) 2306bool Expression::isMathSymbol(QChar ch)
2307{ 2307{
2308 int j = 0; 2308 int j = 0;
2309 while (j<=((int)MATHSYMBOL.length()-1) && ch!=MATHSYMBOL[j]) j++; 2309 while (j<=((int)MATHSYMBOL.length()-1) && ch!=MATHSYMBOL[j]) j++;
2310 if(j<((int)MATHSYMBOL.length())) return true; else return false; 2310 if(j<((int)MATHSYMBOL.length())) return true; else return false;
2311}; 2311};
2312 2312
2313void Expression::GetNext() 2313void Expression::GetNext()
2314{ 2314{
2315 chunk=""; 2315 chunk="";
2316 if(n>=(int)InExpr.length()) return; 2316 if(n>=(int)InExpr.length()) return;
2317 while (InExpr[n]==' ') n++; 2317 while (InExpr[n]==' ') n++;
2318 if(InExpr[n]=='\"') 2318 if(InExpr[n]=='\"')
2319 { 2319 {
2320 while ( (n<(int)InExpr.length()) && (InExpr[n+1]!='\"') ) 2320 while ( (n<(int)InExpr.length()) && (InExpr[n+1]!='\"') )
2321 { 2321 {
2322 printf("chunk=%s\r\n",chunk.latin1()); 2322 printf("chunk=%s\r\n",chunk.latin1());
2323 chunk+=InExpr[n]; 2323 chunk+=InExpr[n];
2324 n++; 2324 n++;
2325 }; 2325 };
2326 chunk+=InExpr[n]; 2326 chunk+=InExpr[n];
2327 printf("2\r\n"); 2327 printf("2\r\n");
2328 SymbGroup=STRING_TOKEN; 2328 SymbGroup=STRING_TOKEN;
2329 } 2329 }
2330 else if (isSymbol(InExpr[n])) 2330 else if (isSymbol(InExpr[n]))
2331 { 2331 {
2332 SymbGroup=SYMBOL_TOKEN; 2332 SymbGroup=SYMBOL_TOKEN;
2333 chunk+=InExpr[n]; 2333 chunk+=InExpr[n];
2334 n++; 2334 n++;
2335 if( (n<(int)InExpr.length()) && 2335 if( (n<(int)InExpr.length()) &&
2336 isMathSymbol(InExpr[n-1]) && 2336 isMathSymbol(InExpr[n-1]) &&
2337 isMathSymbol(InExpr[n]) ) 2337 isMathSymbol(InExpr[n]) )
2338 { 2338 {
2339 SymbGroup=SYMBOL_TOKEN; 2339 SymbGroup=SYMBOL_TOKEN;
2340 chunk+=InExpr[n]; 2340 chunk+=InExpr[n];
2341 n++; 2341 n++;
2342 }; 2342 };
2343 } 2343 }
2344 else if ((InExpr[n].isLetter())||(InExpr[n]=='#')) 2344 else if ((InExpr[n].isLetter())||(InExpr[n]=='#'))
2345 { 2345 {
2346 while ( (n<(int)InExpr.length()) && !isSymbol(InExpr[n]) ) 2346 while ( (n<(int)InExpr.length()) && !isSymbol(InExpr[n]) )
2347 { 2347 {
2348 if (!(InExpr[n]==' ')) chunk+=InExpr[n]; 2348 if (!(InExpr[n]==' ')) chunk+=InExpr[n];
2349 n++; 2349 n++;
2350 }; 2350 };
2351 if (InExpr[n]=='(') SymbGroup=FUNCTION_TOKEN; // function TOKEN 2351 if (InExpr[n]=='(') SymbGroup=FUNCTION_TOKEN; // function TOKEN
2352 else SymbGroup=VARIABLE_TOKEN; 2352 else SymbGroup=VARIABLE_TOKEN;
2353 } 2353 }
2354 else if((n<(int)InExpr.length()) && 2354 else if((n<(int)InExpr.length()) &&
2355 ((InExpr[n].isDigit()) || (InExpr[n]=='.'))) 2355 ((InExpr[n].isDigit()) || (InExpr[n]=='.')))
2356 { 2356 {
2357 while( n<(int)InExpr.length() ) 2357 while( n<(int)InExpr.length() )
2358 { 2358 {
2359 if((InExpr[n].isDigit()) || InExpr[n]=='.') 2359 if((InExpr[n].isDigit()) || InExpr[n]=='.')
2360 { 2360 {
2361 chunk+=InExpr[n]; 2361 chunk+=InExpr[n];
2362 SymbGroup=NUMBER_TOKEN; 2362 SymbGroup=NUMBER_TOKEN;
2363 n++; 2363 n++;
2364 } 2364 }
2365 else if(InExpr[n]=='e') 2365 else if(InExpr[n]=='e')
2366 { 2366 {
2367 if((n+1)<(int)InExpr.length()) 2367 if((n+1)<(int)InExpr.length())
2368 { 2368 {
2369 if(InExpr[n+1]=='-' || InExpr[n+1]=='+' || InExpr[n+1].isDigit()) 2369 if(InExpr[n+1]=='-' || InExpr[n+1]=='+' || InExpr[n+1].isDigit())
2370 { 2370 {
2371 chunk+=InExpr[n]; 2371 chunk+=InExpr[n];
2372 chunk+=InExpr[n+1]; 2372 chunk+=InExpr[n+1];
2373 SymbGroup=NUMBER_TOKEN; 2373 SymbGroup=NUMBER_TOKEN;
2374 n+=2; 2374 n+=2;
2375 } 2375 }
2376 } 2376 }
2377 else 2377 else
2378 { 2378 {
2379 break; 2379 break;
2380 } 2380 }
2381 } 2381 }
2382 else 2382 else
2383 { 2383 {
2384 break; 2384 break;
2385 } 2385 }
2386 }//while 2386 }//while
2387 }//else if 2387 }//else if
2388};//end function 2388};//end function
2389 2389
2390 2390
2391void Expression::First() 2391void Expression::First()
2392{ 2392{
2393 GetNext(); 2393 GetNext();
2394 if (!(chunk=="") && !ErrorFound) Third(); 2394 if (!(chunk=="") && !ErrorFound) Third();
2395 else ErrorFound = true; 2395 else ErrorFound = true;
2396}; 2396};
2397 2397
2398void Expression::Third() 2398void Expression::Third()
2399{ 2399{
2400 QChar sign, secS='\0'; 2400 QChar sign, secS='\0';
2401 Fourth(); 2401 Fourth();
2402 sign = chunk0(); 2402 sign = chunk0();
2403 if((int)chunk.length()>1) secS=chunk[1]; 2403 if((int)chunk.length()>1) secS=chunk[1];
2404 while( sign == '+' || sign == '-'|| 2404 while( sign == '+' || sign == '-'||
2405 sign == '<' || sign == '>'|| sign == '%'|| 2405 sign == '<' || sign == '>'|| sign == '%'||
2406 sign == '&' || sign == '|' || sign == '!' || sign == '=' 2406 sign == '&' || sign == '|' || sign == '!' || sign == '='
2407 ) 2407 )
2408 { 2408 {
2409 GetNext(); 2409 GetNext();
2410 Fourth(); 2410 Fourth();
2411 QString name; 2411 QString name;
2412 if( sign == '+' ) name= "+" ; 2412 if( sign == '+' ) name= "+" ;
2413 else if(sign=='-') name= "-" ; 2413 else if(sign=='-') name= "-" ;
2414 else if(sign=='>' && secS=='\0') name= ">" ; 2414 else if(sign=='>' && secS=='\0') name= ">" ;
2415 else if(sign=='<' && secS=='\0') name= "<" ; 2415 else if(sign=='<' && secS=='\0') name= "<" ;
2416 else if(sign=='=' && secS=='=') name= "==" ; 2416 else if(sign=='=' && secS=='=') name= "==" ;
2417 else if(sign=='!' && secS=='=') name= "!=" ; 2417 else if(sign=='!' && secS=='=') name= "!=" ;
2418 else if(sign=='>' && secS=='=') name= ">=" ; 2418 else if(sign=='>' && secS=='=') name= ">=" ;
2419 else if(sign=='<' && secS=='=') name= "<=" ; 2419 else if(sign=='<' && secS=='=') name= "<=" ;
2420 else if(sign=='&' && secS=='&') name= "AND" ; 2420 else if(sign=='&' && secS=='&') name= "AND" ;
2421 else if(sign=='|' && secS=='|') name= "OR" ; 2421 else if(sign=='|' && secS=='|') name= "OR" ;
2422 else if(sign=='%') name= "MOD" ; 2422 else if(sign=='%') name= "MOD" ;
2423 CompiledBody.append(new QString(name)); // not sure if pushed in the back. 2423 CompiledBody.append(new QString(name)); // not sure if pushed in the back.
2424 CompiledBodyType.append(new int(FUNCTION_TOKEN | 2<<8)); //2 argument functions 2424 CompiledBodyType.append(new int(FUNCTION_TOKEN | 2<<8)); //2 argument functions
2425 sign = chunk0(); 2425 sign = chunk0();
2426 } 2426 }
2427}; 2427};
2428 2428
2429void Expression::Fourth() 2429void Expression::Fourth()
2430{ 2430{
2431 QChar sign; 2431 QChar sign;
2432 Fifth(); 2432 Fifth();
2433 sign = chunk0(); 2433 sign = chunk0();
2434 while( sign == '*' || sign == '/' ) 2434 while( sign == '*' || sign == '/' )
2435 { 2435 {
2436 GetNext(); 2436 GetNext();
2437 Fifth(); 2437 Fifth();
2438 QString name; 2438 QString name;
2439 if( sign == '*' ) name= "*" ; 2439 if( sign == '*' ) name= "*" ;
2440 else name= "/" ; 2440 else name= "/" ;
2441 CompiledBody.append(new QString(name)); 2441 CompiledBody.append(new QString(name));
2442 CompiledBodyType.append(new int(FUNCTION_TOKEN | 2<<8)); //2 arguments functions 2442 CompiledBodyType.append(new int(FUNCTION_TOKEN | 2<<8)); //2 arguments functions
2443 sign = chunk0(); 2443 sign = chunk0();
2444 } 2444 }
2445}; 2445};
2446 2446
2447void Expression::Fifth() 2447void Expression::Fifth()
2448{ 2448{
2449 Sixth(); 2449 Sixth();
2450 //if(chunk.Length==0) return; 2450 //if(chunk.Length==0) return;
2451 if( chunk0() == '^' ) 2451 if( chunk0() == '^' )
2452 { 2452 {
2453 GetNext(); 2453 GetNext();
2454 Fifth(); 2454 Fifth();
2455 CompiledBody.append(new QString("POWER")); 2455 CompiledBody.append(new QString("POWER"));
2456 CompiledBodyType.append(new int(FUNCTION_TOKEN | 2<<8)); // 2 argument functions 2456 CompiledBodyType.append(new int(FUNCTION_TOKEN | 2<<8)); // 2 argument functions
2457 } 2457 }
2458}; 2458};
2459 2459
2460void Expression::Sixth() 2460void Expression::Sixth()
2461{ 2461{
2462 char sign; 2462 char sign;
2463 sign = ' '; 2463 sign = ' ';
2464 if(SymbGroup== SYMBOL_TOKEN && 2464 if(SymbGroup== SYMBOL_TOKEN &&
2465 chunk0() == '+' || chunk0() == '-' | chunk0() == '!') 2465 chunk0() == '+' || chunk0() == '-' | chunk0() == '!')
2466 { 2466 {
2467 sign = chunk0(); 2467 sign = chunk0();
2468 GetNext(); 2468 GetNext();
2469 } 2469 }
2470 Seventh(); 2470 Seventh();
2471 if( sign == '-' ) 2471 if( sign == '-' )
2472 { 2472 {
2473 CompiledBody.append(new QString("CHGSGN")); // unary minus 2473 CompiledBody.append(new QString("CHGSGN")); // unary minus
2474 CompiledBodyType.append(new int(FUNCTION_TOKEN | 1<<8)); //1 argument 2474 CompiledBodyType.append(new int(FUNCTION_TOKEN | 1<<8)); //1 argument
2475 } 2475 }
2476 if( sign == '!' ) 2476 if( sign == '!' )
2477 { 2477 {
2478 CompiledBody.append(new QString("NOT")); // unary minus 2478 CompiledBody.append(new QString("NOT")); // unary minus
2479 CompiledBodyType.append(new int(FUNCTION_TOKEN | 1<<8)); //1 argument 2479 CompiledBodyType.append(new int(FUNCTION_TOKEN | 1<<8)); //1 argument
2480 } 2480 }