@@ -39,13 +39,13 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
39
39
NSString *fileString = [NSString stringWithContentsOfURL: myURL usedEncoding: &stringEncoding error: &theErr];
40
40
41
41
// We could not open the file, probably unknown encoding; try ISO-8859-1
42
- if (nil == fileString) {
42
+ if (nil == fileString) {
43
43
stringEncoding = NSISOLatin1StringEncoding;
44
44
fileString = [NSString stringWithContentsOfURL: myURL encoding: stringEncoding error: &theErr];
45
45
46
46
// Still no success, give up
47
- if (nil == fileString) {
48
- if (nil != theErr) {
47
+ if (nil == fileString) {
48
+ if (nil != theErr) {
49
49
NSLog (@" Error opening the file: %@ " , theErr);
50
50
}
51
51
@@ -56,14 +56,14 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
56
56
57
57
58
58
// Parse the data if still interested in the preview
59
- if (false == QLPreviewRequestIsCancelled (preview)) {
59
+ if (false == QLPreviewRequestIsCancelled (preview)) {
60
60
CSVDocument *csvDoc = [CSVDocument csvDoc ];
61
61
csvDoc.autoDetectSeparator = YES ;
62
62
NSUInteger numRowsParsed = [csvDoc numRowsFromCSVString: fileString maxRows: MAX_ROWS error: NULL ];
63
63
64
64
65
65
// Create HTML of the data if still interested in the preview
66
- if (false == QLPreviewRequestIsCancelled (preview)) {
66
+ if (false == QLPreviewRequestIsCancelled (preview)) {
67
67
NSBundle *myBundle = [NSBundle bundleForClass: [CSVDocument class ]];
68
68
69
69
NSString *cssPath = [myBundle pathForResource: @" Style" ofType: @" css" ];
@@ -77,7 +77,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
77
77
[html appendString: @" <html xmlns=\" http://www.w3.org/1999/xhtml\" lang=\" en\" ><head>\n " ];
78
78
[html appendFormat: @" <meta http-equiv=\" Content-Type\" content=\" text/html; charset=%s \" />\n " , htmlReadableFileEncoding (stringEncoding)];
79
79
[html appendString: @" <style>\n " ];
80
- if (nil != css) {
80
+ if (nil != css) {
81
81
[html appendString: css];
82
82
[css release ];
83
83
}
@@ -90,7 +90,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
90
90
91
91
// add the table rows
92
92
BOOL altRow = NO ;
93
- for (CSVRowObject *row in csvDoc.rows ) {
93
+ for (CSVRowObject *row in csvDoc.rows ) {
94
94
[html appendFormat: @" <tr%@ ><td>" , altRow ? @" class=\" alt_row\" " : @" " ];
95
95
[html appendString: [row columns: csvDoc.columnKeys combinedByString: @" </td><td>" ]];
96
96
[html appendString: @" </td></tr>\n " ];
@@ -101,7 +101,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
101
101
[html appendString: @" </table>\n " ];
102
102
103
103
// not all rows were parsed, show hint
104
- if (numRowsParsed > MAX_ROWS) {
104
+ if (numRowsParsed > MAX_ROWS) {
105
105
NSString *rowsHint = [NSString stringWithFormat: NSLocalizedString(@" Only the first %i rows are being displayed" , nil ), MAX_ROWS];
106
106
[html appendFormat: @" <div class=\" truncated_rows\" >%@ </div>" , rowsHint];
107
107
}
@@ -131,24 +131,24 @@ void CancelPreviewGeneration(void* thisInterface, QLPreviewRequestRef preview)
131
131
// to be used for the generated HTML
132
132
static char * htmlReadableFileEncoding (NSStringEncoding stringEncoding)
133
133
{
134
- if (NSUTF8StringEncoding == stringEncoding ||
134
+ if (NSUTF8StringEncoding == stringEncoding ||
135
135
NSUnicodeStringEncoding == stringEncoding) {
136
136
return " utf-8" ;
137
137
}
138
- if (NSASCIIStringEncoding == stringEncoding) {
138
+ if (NSASCIIStringEncoding == stringEncoding) {
139
139
return " ascii" ;
140
140
}
141
- if (NSISOLatin1StringEncoding == stringEncoding) {
141
+ if (NSISOLatin1StringEncoding == stringEncoding) {
142
142
return " iso-8859-1" ;
143
143
}
144
- if (NSMacOSRomanStringEncoding == stringEncoding) {
144
+ if (NSMacOSRomanStringEncoding == stringEncoding) {
145
145
return " x-mac-roman" ;
146
146
}
147
- if (NSUTF16BigEndianStringEncoding == stringEncoding ||
147
+ if (NSUTF16BigEndianStringEncoding == stringEncoding ||
148
148
NSUTF16LittleEndianStringEncoding == stringEncoding) {
149
149
return " utf-16" ;
150
150
}
151
- if (NSUTF32StringEncoding == stringEncoding ||
151
+ if (NSUTF32StringEncoding == stringEncoding ||
152
152
NSUTF32BigEndianStringEncoding == stringEncoding ||
153
153
NSUTF32LittleEndianStringEncoding == stringEncoding) {
154
154
return " utf-32" ;
@@ -160,24 +160,24 @@ void CancelPreviewGeneration(void* thisInterface, QLPreviewRequestRef preview)
160
160
161
161
static char * humanReadableFileEncoding (NSStringEncoding stringEncoding)
162
162
{
163
- if (NSUTF8StringEncoding == stringEncoding ||
163
+ if (NSUTF8StringEncoding == stringEncoding ||
164
164
NSUnicodeStringEncoding == stringEncoding) {
165
165
return " UTF-8" ;
166
166
}
167
- if (NSASCIIStringEncoding == stringEncoding) {
167
+ if (NSASCIIStringEncoding == stringEncoding) {
168
168
return " ASCII-text" ;
169
169
}
170
- if (NSISOLatin1StringEncoding == stringEncoding) {
170
+ if (NSISOLatin1StringEncoding == stringEncoding) {
171
171
return " ISO-8859-1" ;
172
172
}
173
- if (NSMacOSRomanStringEncoding == stringEncoding) {
173
+ if (NSMacOSRomanStringEncoding == stringEncoding) {
174
174
return " Mac-Roman" ;
175
175
}
176
- if (NSUTF16BigEndianStringEncoding == stringEncoding ||
176
+ if (NSUTF16BigEndianStringEncoding == stringEncoding ||
177
177
NSUTF16LittleEndianStringEncoding == stringEncoding) {
178
178
return " UTF-16" ;
179
179
}
180
- if (NSUTF32StringEncoding == stringEncoding ||
180
+ if (NSUTF32StringEncoding == stringEncoding ||
181
181
NSUTF32BigEndianStringEncoding == stringEncoding ||
182
182
NSUTF32LittleEndianStringEncoding == stringEncoding) {
183
183
return " UTF-32" ;
@@ -188,7 +188,7 @@ void CancelPreviewGeneration(void* thisInterface, QLPreviewRequestRef preview)
188
188
189
189
190
190
static char * formatFilesize (float bytes) {
191
- if (bytes < 1 ) {
191
+ if (bytes < 1 ) {
192
192
return " " ;
193
193
}
194
194
@@ -199,7 +199,7 @@ void CancelPreviewGeneration(void* thisInterface, QLPreviewRequestRef preview)
199
199
bytes /= 1024 ;
200
200
i++;
201
201
202
- if (i >= 5 ) { // we most likely won't end up here, but let's be sure
202
+ if (i >= 5 ) { // we most likely won't end up here, but let's be sure
203
203
break ;
204
204
}
205
205
}
0 commit comments