/** * This Handles the Drawing of the Board Layer */ void boxDraw (Layer *layer, GContext *ctx) { graphics_context_set_fill_color (ctx, GColorBlack); int i; for (i=0;i<status.size;i++) { GRect bounds = parseCell (status.boxes[i].x, status.boxes[i].y); graphics_fill_rect(ctx, bounds, 0, GCornerNone); } if (status.level < ROWS) { int r, c; for (r=(ROWS-1);r>(status.level-1);r--) { if (status.storage[r] != NULL) { for (c=0;c<status.sizes[r];c++) { GRect bounds = parseCell (status.storage[r][c].x, status.storage[r][c].y); graphics_fill_rect(ctx, bounds, 0, GCornerNone); } } // DEBUG: // mini_snprintf(debug.text, 60, "Debug Mode\nLevel: %d\nSize: %d\n", status.level, status.sizes[r]); // text_layer_set_text(ui.debugLayer, debug.text); } } }
bool MorkParser::parseDict() { char cur = nextChar(); bool Result = true; nowParsing_ = NPValues; while (Result && cur != '>' && cur) { if (!isWhiteSpace(cur)) { switch (cur) { case '<': if (mMorkData.mid(mMorkPos - 1, strlen(MorkDictColumnMeta)) == MorkDictColumnMeta) { nowParsing_ = NPColumns; mMorkPos += strlen(MorkDictColumnMeta) - 1; } break; case '(': Result = parseCell(); break; case '/': Result = parseComment(); break; } } cur = nextChar(); } return Result; }
void ExcelFile::parseRange(const std::string& value, Range& range) { size_t index = value.find_first_of(':'); if (index != std::string::npos) { parseCell(value.substr(0, index), range.firstRow, range.firstCol); parseCell(value.substr(index + 1), range.lastRow, range.lastCol); } else { parseCell(value, range.firstRow, range.firstCol); range.lastCol = range.firstCol; range.lastRow = range.firstRow; } }
bool MorkParser::parseRow( int TableId, int TableScope ) { bool Result = true; std::string TextId; int Id = 0, Scope = 0; nowParsing_ = NPRows; char cur = nextChar(); // Get id while ( cur != '(' && cur != ']' && cur != '[' && cur ) { if ( !isWhiteSpace( cur ) ) { TextId += cur; } cur = nextChar(); } parseScopeId( TextId, &Id, &Scope ); setCurrentRow( TableScope, TableId, Scope, Id ); // Parse the row while ( Result && cur != ']' && cur ) { if ( !isWhiteSpace( cur ) ) { switch ( cur ) { case '(': Result = parseCell(); break; case '[': Result = parseMeta( ']' ); break; default: Result = false; break; } } cur = nextChar(); } return Result; }
void ExcelFile::readSheet(Sheet& sh) { rapidxml::xml_document<> doc; rapidxml::xml_node<> *root, *row, *c, *v, *d; _zip->openXML(sh._path.c_str(), doc); root = doc.first_node("worksheet"); d = root->first_node("dimension"); if (d) parseRange(d->first_attribute("ref")->value(), sh._dimension); row = root->first_node("sheetData"); row = row->first_node("row"); int vecsize = (sh._dimension.lastCol - sh._dimension.firstCol + 1) * (sh._dimension.lastRow - sh._dimension.firstRow + 1); sh._cells.resize(vecsize); while (row) { int rowIdx = lexical_cast<int>(row->first_attribute("r")->value()); c = row->first_node("c"); while (c) { int colIdx = 0; parseCell(c->first_attribute("r")->value(), rowIdx, colIdx); int index = sh.toIndex(rowIdx, colIdx); const char *s, *t; v = c->first_node("v"); Cell* cell = new Cell; if (v) { s = v->value(); if (c->first_attribute("t")) { t = c->first_attribute("t")->value(); if (!strcmp(t, "s")) { cell->value = (char*)_sharedString[atoi(s)].c_str(); cell->type = "string"; } else if (!strcmp(t, "b")) { if (!strcmp(s, "0")) { cell->value = "FALSE"; } else { cell->value = "TRUE"; } cell->type = "bool"; } } else { cell->type = "unknow"; cell->value = (char*)s; } } sh._cells[index] = cell; c = c->next_sibling("c"); } row = row->next_sibling("row"); } }