Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: samples/total/client/SYLKReader.dart

Issue 10635015: Delete proxy and total samples, which have bit-rotted. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/total/client/RowColStyle.dart ('k') | samples/total/client/Scanner.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 class SYLKReader extends Reader {
6
7 SYLKReader() : super() { }
8
9 void loadSpreadsheet(Spreadsheet spreadsheet, List<String> sylk) {
10 int row, col;
11 String contents;
12 CellLocation lastLocation;
13
14 for (int i = 0; i < sylk.length; i++) {
15 List<String> parts = StringUtils.split(sylk[i], StringUtils.SEMICOLON);
16 String cmd = parts[0];
17 switch (cmd) {
18 case "ID":
19 break;
20 case "B":
21 for (int j = 1; j < parts.length; j++) {
22 String part = parts[j];
23 if (part.startsWith("X")) {
24 col = Math.parseInt(part.substring(1, part.length));
25 spreadsheet.setColumnCount(col);
26 } else if (part.startsWith("Y")) {
27 row = Math.parseInt(part.substring(1, part.length));
28 spreadsheet.setRowCount(row);
29 }
30 }
31 break;
32 case "C":
33 row = -1;
34 col = -1;
35 contents = "";
36 for (int j = 1; j < parts.length; j++) {
37 String part = parts[j];
38 if (part.startsWith("Y")) {
39 row = Math.parseInt(part.substring(1, part.length));
40 } else if (part.startsWith("X")) {
41 col = Math.parseInt(part.substring(1, part.length));
42 } if (part.startsWith("K")) {
43 contents = StringUtils.stripQuotes(part.substring(1, part.length));
44 }
45 }
46 if (row == -1) {
47 throw new RuntimeException("${i}: No row (Y) specified in ${sylk[i]}") ;
48 }
49 if (col == -1) {
50 throw new RuntimeException("${i}: No col (X) specified in ${sylk[i]}") ;
51 }
52 lastLocation = new CellLocation(spreadsheet, new RowCol(row, col));
53 spreadsheet.execute(new SetCellContentsCommand(lastLocation, contents));
54 break;
55 case "F":
56 Cell lastCell = lastLocation.getCell();
57 if (lastCell == null) {
58 break;
59 }
60 Style style = lastCell.style;
61 for (int j = 1; j < parts.length; j++) {
62 String part = parts[j];
63 if (part.startsWith("P")) {
64 int formatIndex = Math.parseInt(part.substring(1, part.length));
65 style = style.setNumericFormatByIndex(formatIndex);
66 } else if (part.startsWith("S")) {
67 switch (part[1]) {
68 case "I"[0]:
69 style = style.setTextFormatByIndex(Style.ITALIC);
70 break;
71 case "D"[0]:
72 style = style.setTextFormatByIndex(Style.BOLD);
73 break;
74 }
75 } else if (part.startsWith("F")) {
76 // F;...;F<format><decimal_places><alignment>
77 // Only handle alignment for now
78 switch (part[3]) {
79 case "L"[0]:
80 style = style.setTextAlignment(Style.LEFT);
81 break;
82 case "C"[0]:
83 style = style.setTextAlignment(Style.CENTER);
84 break;
85 case "R"[0]:
86 style = style.setTextAlignment(Style.RIGHT);
87 break;
88 }
89 }
90 }
91 spreadsheet.setCellStyle(lastLocation.rowCol, style);
92 break;
93 }
94 }
95 }
96
97 void request(String name, void callback(String spreadsheet)) {
98 String url = '/spreadsheet/get?name=$name';
99 XMLHttpRequest req = new XMLHttpRequest();
100 req.on.readyStateChange.add((Event event) {
101 if (req.readyState != XMLHttpRequest.DONE) {
102 return;
103 }
104
105 String text;
106 if (req.status == 200 && req.responseText != null) {
107 text = req.responseText;
108 } else {
109 text = 'ID;P';
110 }
111
112 try {
113 callback(text);
114 } catch (var e, var s) {
115 print(e);
116 }
117 });
118
119 req.open('GET', url, true);
120 req.send();
121 }
122 }
OLDNEW
« no previous file with comments | « samples/total/client/RowColStyle.dart ('k') | samples/total/client/Scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698