PageRenderTime 41ms CodeModel.GetById 23ms app.highlight 15ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Clients/Spreadsheets/GDataEntryWorksheet.m

http://macfuse.googlecode.com/
Objective C | 153 lines | 87 code | 41 blank | 25 comment | 3 complexity | 867b1daf8655030a520d8aba73add2a7 MD5 | raw file
  1/* Copyright (c) 2007 Google Inc.
  2 *
  3 * Licensed under the Apache License, Version 2.0 (the "License");
  4 * you may not use this file except in compliance with the License.
  5 * You may obtain a copy of the License at
  6 *
  7 *     http://www.apache.org/licenses/LICENSE-2.0
  8 *
  9 * Unless required by applicable law or agreed to in writing, software
 10 * distributed under the License is distributed on an "AS IS" BASIS,
 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12 * See the License for the specific language governing permissions and
 13 * limitations under the License.
 14 */
 15
 16//
 17//  GDataEntryWorksheet.m
 18//
 19
 20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_SPREADSHEET_SERVICE
 21
 22#define GDATAENTRYWORKSHEET_DEFINE_GLOBALS 1
 23
 24#import "GDataEntryWorksheet.h"
 25#import "GDataSpreadsheetConstants.h"
 26#import "GDataRowColumnCount.h"
 27
 28
 29@implementation GDataEntryWorksheet
 30
 31
 32+ (GDataEntryWorksheet *)worksheetEntry {
 33  GDataEntryWorksheet *entry = [self object];
 34
 35  [entry setNamespaces:[GDataSpreadsheetConstants spreadsheetNamespaces]];
 36  return entry;
 37}
 38
 39#pragma mark -
 40
 41+ (NSString *)coreProtocolVersionForServiceVersion:(NSString *)serviceVersion {
 42  return [GDataSpreadsheetConstants coreProtocolVersionForServiceVersion:serviceVersion];
 43}
 44
 45+ (NSString *)standardEntryKind {
 46  // spreadsheet categories do not use the standard Kind scheme
 47  // (kGDataCategoryScheme) so cannot be init'd by GDataEntryBase
 48  return nil;
 49}
 50
 51+ (void)load {
 52  // spreadsheet categories do not use the standard Kind scheme
 53  // (kGDataCategoryScheme) so cannot be registered with +registerEntryClass
 54  [GDataEntryBase registerEntryClass:[self class]
 55               forCategoryWithScheme:kGDataCategorySchemeSpreadsheet 
 56                                term:kGDataCategoryWorksheet];
 57}
 58
 59- (void)addExtensionDeclarations {
 60  
 61  [super addExtensionDeclarations];
 62  
 63  Class entryClass = [self class];
 64  
 65  // Worksheet extensions
 66  [self addExtensionDeclarationForParentClass:entryClass
 67                                   childClass:[GDataColumnCount class]];
 68  [self addExtensionDeclarationForParentClass:entryClass
 69                                   childClass:[GDataRowCount class]];  
 70}
 71
 72#if !GDATA_SIMPLE_DESCRIPTIONS
 73- (NSMutableArray *)itemsForDescription {
 74  
 75  NSMutableArray *items = [super itemsForDescription];
 76  
 77  NSString *colStr = [NSString stringWithFormat:@"%d", (int) [self columnCount]];
 78  NSString *rowStr = [NSString stringWithFormat:@"%d", (int) [self rowCount]];
 79  
 80  [self addToArray:items objectDescriptionIfNonNil:colStr withName:@"cols"];
 81  [self addToArray:items objectDescriptionIfNonNil:rowStr withName:@"rows"];
 82  
 83  return items;
 84}
 85#endif
 86
 87- (id)init {
 88  self = [super init];
 89  if (self) {
 90    [self addCategory:[GDataCategory categoryWithScheme:kGDataCategorySchemeSpreadsheet
 91                                                   term:kGDataCategoryWorksheet]];
 92
 93    // set a default row & column count, as in the Java
 94    [self setRowCount:100];
 95    [self setColumnCount:20];
 96  }
 97  return self;
 98}
 99
100+ (NSString *)defaultServiceVersion {
101  return kGDataSpreadsheetDefaultServiceVersion;
102}
103
104#pragma mark -
105
106- (NSInteger)rowCount {
107  GDataRowCount *rowCount = [self objectForExtensionClass:[GDataRowCount class]];
108  
109  return [rowCount count];
110}
111
112- (void)setRowCount:(NSInteger)val {
113  GDataRowCount *obj = [GDataRowCount rowCountWithInt:val];
114  [self setObject:obj forExtensionClass:[GDataRowCount class]];
115}
116
117- (NSInteger)columnCount {
118  GDataColumnCount *columnCount = [self objectForExtensionClass:[GDataColumnCount class]];
119  
120  return [columnCount count];
121}
122
123- (void)setColumnCount:(NSInteger)val {
124  GDataColumnCount *obj = [GDataColumnCount columnCountWithInt:val];
125  [self setObject:obj forExtensionClass:[GDataColumnCount class]];
126}
127
128#pragma mark -
129
130- (GDataLink *)spreadsheetLink {
131  return [self alternateLink]; 
132}
133
134- (GDataLink *)cellsLink {
135  return [self linkWithRelAttributeValue:kGDataLinkCellsFeed];
136}
137
138- (NSURL *)listFeedURL {
139
140  // the worksheets feed URL is the URI in the entry's content element
141  GDataEntryContent *content = [self content];
142
143  if ([[content type] hasPrefix:@"application/atom+xml"]) {
144    return [content sourceURL];
145  }
146
147  // prior to V2 feeds, the URL is in a link
148  return [[self linkWithRelAttributeValue:kGDataLinkListFeed] URL];
149}
150
151@end
152
153#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_SPREADSHEET_SERVICE