/Source/externals/GData/Source/Clients/Spreadsheets/GDataFeedSpreadsheetCell.m

http://google-email-uploader-mac.googlecode.com/ · Objective C · 125 lines · 73 code · 30 blank · 22 comment · 2 complexity · 9656fd5a5726a0b739e6020cee1fc0fa 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. // GDataFeedSpreadsheetCell.m
  17. //
  18. #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_SPREADSHEET_SERVICE
  19. #import "GDataEntrySpreadsheetCell.h"
  20. #import "GDataSpreadsheetConstants.h"
  21. #import "GDataFeedSpreadsheetCell.h"
  22. #import "GDataCategory.h"
  23. #import "GDataRowColumnCount.h"
  24. @implementation GDataFeedSpreadsheetCell
  25. + (NSString *)coreProtocolVersionForServiceVersion:(NSString *)serviceVersion {
  26. return [GDataSpreadsheetConstants coreProtocolVersionForServiceVersion:serviceVersion];
  27. }
  28. + (GDataFeedSpreadsheetCell *)spreadsheetCellFeedWithXMLData:(NSData *)data {
  29. return [self feedWithXMLData:data];
  30. }
  31. + (GDataFeedSpreadsheetCell *)spreadsheetCellFeed {
  32. GDataFeedSpreadsheetCell *feed = [self object];
  33. [feed setNamespaces:[GDataSpreadsheetConstants spreadsheetNamespaces]];
  34. return feed;
  35. }
  36. #pragma mark -
  37. + (NSString *)standardEntryKind {
  38. // spreadsheet categories do not use the standard Kind scheme
  39. // (kGDataCategoryScheme) so cannot be init'd by GDataEntryBase
  40. return nil;
  41. }
  42. + (void)load {
  43. // spreadsheet categories do not use the standard Kind scheme
  44. // (kGDataCategoryScheme) so cannot be registered with +registerEntryClass
  45. [GDataFeedBase registerFeedClass:[self class]
  46. forCategoryWithScheme:nil
  47. term:kGDataCategorySpreadsheetCell];
  48. }
  49. - (void)addExtensionDeclarations {
  50. [super addExtensionDeclarations];
  51. Class entryClass = [self class];
  52. // Worksheet extensions
  53. [self addExtensionDeclarationForParentClass:entryClass
  54. childClasses:
  55. [GDataColumnCount class],
  56. [GDataRowCount class],
  57. nil];
  58. }
  59. - (id)init {
  60. self = [super init];
  61. if (self) {
  62. [self addCategory:[GDataCategory categoryWithScheme:kGDataCategorySchemeSpreadsheet
  63. term:kGDataCategorySpreadsheetCell]];
  64. }
  65. return self;
  66. }
  67. #if !GDATA_SIMPLE_DESCRIPTIONS
  68. - (NSMutableArray *)itemsForDescription {
  69. NSMutableArray *items = [super itemsForDescription];
  70. NSString *colStr = [NSString stringWithFormat:@"%d", [self columnCount]];
  71. NSString *rowStr = [NSString stringWithFormat:@"%d", [self rowCount]];
  72. [self addToArray:items objectDescriptionIfNonNil:colStr withName:@"cols"];
  73. [self addToArray:items objectDescriptionIfNonNil:rowStr withName:@"rows"];
  74. return items;
  75. }
  76. #endif
  77. - (Class)classForEntries {
  78. return [GDataEntrySpreadsheetCell class];
  79. }
  80. + (NSString *)defaultServiceVersion {
  81. return kGDataSpreadsheetDefaultServiceVersion;
  82. }
  83. #pragma mark -
  84. - (NSInteger)rowCount {
  85. GDataRowCount *rowCount =
  86. (GDataRowCount *) [self objectForExtensionClass:[GDataRowCount class]];
  87. return [rowCount count];
  88. }
  89. - (NSInteger)columnCount {
  90. GDataColumnCount *columnCount =
  91. (GDataColumnCount *) [self objectForExtensionClass:[GDataColumnCount class]];
  92. return [columnCount count];
  93. }
  94. @end
  95. #endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_SPREADSHEET_SERVICE