Skip to content

Commit

Permalink
Spreadsheet: Removed own expression parser and instead use the one in…
Browse files Browse the repository at this point in the history
… App.
  • Loading branch information
eivindkv authored and wwmayer committed Apr 2, 2016
1 parent c506881 commit a21571a
Show file tree
Hide file tree
Showing 33 changed files with 121 additions and 3,666 deletions.
12 changes: 6 additions & 6 deletions src/Mod/Drawing/App/FeatureViewSpreadsheet.cpp
Expand Up @@ -151,17 +151,17 @@ App::DocumentObjectExecReturn *FeatureViewSpreadsheet::execute(void)
float coloffset = 0.0;
float cellheight = 100;
float cellwidth = 100;
std::string celltext;
std::string celltext;
Spreadsheet::Sheet* sheet = static_cast<Spreadsheet::Sheet*>(link);
std::vector<std::string> skiplist;
for (std::vector<std::string>::const_iterator col = columns.begin(); col != columns.end(); ++col) {
for (std::vector<std::string>::const_iterator col = columns.begin(); col != columns.end(); ++col) {
// create a group for each column
result << " <g id=\"" << ViewName << "_col" << (*col) << "\">" << endl;
for (std::vector<int>::const_iterator row = rows.begin(); row != rows.end(); ++row) {
// get cell size
std::stringstream srow;
srow << (*row);
Spreadsheet::CellAddress address((*col) + srow.str());
App::CellAddress address((*col) + srow.str());
cellwidth = sheet->getColumnWidth(address.col());
cellheight = sheet->getRowHeight(address.row());
celltext = "";
Expand Down Expand Up @@ -216,7 +216,7 @@ App::DocumentObjectExecReturn *FeatureViewSpreadsheet::execute(void)
if (cell->getSpans(rowspan,colspan)) {
for (int i=0; i<colspan; ++i) {
for (int j=0; j<rowspan; ++j) {
Spreadsheet::CellAddress nextcell(address.row()+j,address.col()+i);
App::CellAddress nextcell(address.row()+j,address.col()+i);
if (i > 0)
cellwidth = cellwidth + sheet->getColumnWidth(nextcell.col());
if (j > 0)
Expand All @@ -227,7 +227,7 @@ App::DocumentObjectExecReturn *FeatureViewSpreadsheet::execute(void)
}
}
cell->getAlignment(alignment);
}
}
// skip cell if found in skiplist
if (std::find(skiplist.begin(), skiplist.end(), address.toString()) == skiplist.end()) {
result << " <rect x=\"" << coloffset << "\" y=\"" << rowoffset << "\" width=\"" << cellwidth
Expand All @@ -241,7 +241,7 @@ App::DocumentObjectExecReturn *FeatureViewSpreadsheet::execute(void)
result << " <text text-anchor=\"end\" style=\"" << textstyle << "\" x=\"" << coloffset + (cellwidth - FontSize.getValue()/2) << "\" y=\"" << rowoffset + 0.75 * cellheight << "\" font-family=\"" ;
result << Font.getValue() << "\"" << " font-size=\"" << FontSize.getValue() << "\""
<< " fill=\"" << fcolor << "\">" << celltext << "</text>" << endl;
}
}
rowoffset = rowoffset + cellheight;
}
result << " </g>" << endl;
Expand Down
4 changes: 0 additions & 4 deletions src/Mod/Spreadsheet/App/AppSpreadsheet.cpp
Expand Up @@ -20,8 +20,6 @@

#include <Base/Console.h>
#include "Sheet.h"
#include "SpreadsheetExpression.h"


namespace Spreadsheet {
class Module : public Py::ExtensionModule<Module>
Expand All @@ -46,8 +44,6 @@ PyMODINIT_FUNC initSpreadsheet() {
Spreadsheet::PropertySheet::init();

Spreadsheet::Sheet::init();
Spreadsheet::AggregateFunctionExpression::init();
Spreadsheet::RangeExpression::init();

new Spreadsheet::Module();
Base::Console().Log("Loading Spreadsheet module... done\n");
Expand Down
4 changes: 0 additions & 4 deletions src/Mod/Spreadsheet/App/CMakeLists.txt
Expand Up @@ -17,8 +17,6 @@ set(Spreadsheet_LIBS
)

set(Spreadsheet_SRCS
SpreadsheetExpression.cpp
SpreadsheetExpression.h
Cell.cpp
Cell.h
DisplayUnit.h
Expand All @@ -44,8 +42,6 @@ set(Spreadsheet_SRCS
SheetObserver.h
Utils.cpp
Utils.h
Range.h
Range.cpp
AppSpreadsheet.cpp
)

Expand Down
5 changes: 3 additions & 2 deletions src/Mod/Spreadsheet/App/Cell.cpp
Expand Up @@ -30,14 +30,15 @@
#include <boost/tokenizer.hpp>
#include <Base/Reader.h>
#include <Base/Writer.h>
#include "SpreadsheetExpression.h"
#include <App/Expression.h>
#include "Sheet.h"
#include <iomanip>

#ifdef _MSC_VER
#define __func__ __FUNCTION__
#endif

using namespace App;
using namespace Base;
using namespace Spreadsheet;

Expand Down Expand Up @@ -216,7 +217,7 @@ void Cell::setContent(const char * value)
if (value != 0) {
if (*value == '=') {
try {
expr = Spreadsheet::ExpressionParser::parse(owner->sheet(), value + 1);
expr = App::ExpressionParser::parse(owner->sheet(), value + 1);
}
catch (Base::Exception & e) {
expr = new App::StringExpression(owner->sheet(), value);
Expand Down
11 changes: 6 additions & 5 deletions src/Mod/Spreadsheet/App/Cell.h
Expand Up @@ -26,6 +26,7 @@
#include <string>
#include <set>
#include <App/Material.h>
#include <App/Range.h>
#include "DisplayUnit.h"
#include "Utils.h"

Expand All @@ -49,7 +50,7 @@ class SpreadsheetExport Cell {

public:

Cell(const CellAddress & _address, PropertySheet * _owner);
Cell(const App::CellAddress & _address, PropertySheet * _owner);

Cell(const Cell & other);

Expand Down Expand Up @@ -101,7 +102,7 @@ class SpreadsheetExport Cell {

bool hasException() const { return isUsed(EXCEPTION_SET) || isUsed(PARSE_EXCEPTION_SET) || isUsed(RESOLVE_EXCEPTION_SET); }

void moveAbsolute(CellAddress newAddress);
void moveAbsolute(App::CellAddress newAddress);

void restore(Base::XMLReader &reader);

Expand All @@ -117,7 +118,7 @@ class SpreadsheetExport Cell {

void visit(App::ExpressionVisitor & v);

CellAddress getAddress() const { return address; }
App::CellAddress getAddress() const { return address; }

/* Alignment */
static const int ALIGNMENT_LEFT;
Expand Down Expand Up @@ -172,7 +173,7 @@ class SpreadsheetExport Cell {
static const int PARSE_EXCEPTION_SET;
static const int RESOLVE_EXCEPTION_SET;

CellAddress address;
App::CellAddress address;
PropertySheet * owner;

int used;
Expand All @@ -187,7 +188,7 @@ class SpreadsheetExport Cell {
int rowSpan;
int colSpan;
std::string exceptionStr;
CellAddress anchor;
App::CellAddress anchor;
};

}
Expand Down

0 comments on commit a21571a

Please sign in to comment.