diff options
Diffstat (limited to 'extensions/source/macosx/spotlight/OOoMetaDataParser.m')
-rw-r--r-- | extensions/source/macosx/spotlight/OOoMetaDataParser.m | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/extensions/source/macosx/spotlight/OOoMetaDataParser.m b/extensions/source/macosx/spotlight/OOoMetaDataParser.m index 34e3652b34f6..4d2b95d72fff 100644 --- a/extensions/source/macosx/spotlight/OOoMetaDataParser.m +++ b/extensions/source/macosx/spotlight/OOoMetaDataParser.m @@ -30,7 +30,7 @@ static NSDictionary *metaXML2MDIKeys; + (void)initialize { static BOOL isInitialized = NO; - + if (isInitialized == NO) { //set up the meta elements with only one value NSMutableSet *temp = [NSMutableSet new]; @@ -39,7 +39,7 @@ static NSDictionary *metaXML2MDIKeys; [temp addObject:@"dc:description"]; [temp addObject:@"meta:user-defined"]; singleValueXMLElements = [[NSSet setWithSet:temp] retain]; - + //set up the meta elements that can have more than one value [temp removeAllObjects]; [temp addObject:@"dc:subject"]; @@ -48,7 +48,7 @@ static NSDictionary *metaXML2MDIKeys; [temp addObject:@"dc:creator"]; multiValueXMLElements = [[NSSet setWithSet:temp] retain]; [temp release]; - + //set up the map to store the values with the correct MDI keys NSMutableDictionary *tempDict = [NSMutableDictionary new]; [tempDict setObject:(NSString*)kMDItemTitle forKey:@"dc:title"]; @@ -63,7 +63,7 @@ static NSDictionary *metaXML2MDIKeys; [tempDict setObject:@"org_openoffice_opendocument_custominfo4" forKey:@"Info 4"]; metaXML2MDIKeys = [[NSDictionary dictionaryWithDictionary:tempDict] retain]; [tempDict release]; - + isInitialized = YES; } } @@ -73,35 +73,35 @@ static NSDictionary *metaXML2MDIKeys; if ((self = [super init]) != nil) { shouldReadCharacters = NO; textCurrentElement = nil; - + return self; } - + return nil; } - (void)parseXML:(NSData*)data intoDictionary:(NSMutableDictionary*)dict { metaValues = dict; - + //NSLog(@"data: %@ %d", data, [data length]); - + //init parser settings shouldReadCharacters = NO; - + NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data]; - + // class 'OOoMetaDataParser' does not implement the 'NSXMLParserDelegate' protocol // So instead of this: // [parser setDelegate:self]; // do this: objc_msgSend(parser, @selector(setDelegate:), self); - + [parser setShouldResolveExternalEntities:NO]; [parser parse]; - + [parser release]; - + //NSLog(@"finished parsing meta"); } @@ -121,7 +121,7 @@ static NSDictionary *metaXML2MDIKeys; shouldReadCharacters = NO; return; } - + if (shouldReadCharacters == YES) { textCurrentElement = [NSMutableString new]; isCustom = [elementName isEqualToString:@"meta:user-defined"]; @@ -134,7 +134,7 @@ static NSDictionary *metaXML2MDIKeys; //NSLog(@"start element %@", elementName); } -- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName +- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { (void) parser; // unused (void) namespaceURI; // unused @@ -148,11 +148,11 @@ static NSDictionary *metaXML2MDIKeys; mdiName = (NSString*)[metaXML2MDIKeys objectForKey:elementName]; } //NSLog(@"mdiName: %@", mdiName); - + if (mdiName == nil) { return; } - + if ([singleValueXMLElements containsObject:elementName] == YES) { [metaValues setObject:textCurrentElement forKey:mdiName]; } else { @@ -175,7 +175,7 @@ static NSDictionary *metaXML2MDIKeys; [customAttribute release]; } } - + //cleanup part 2 shouldReadCharacters = NO; isCustom = NO; @@ -188,18 +188,18 @@ static NSDictionary *metaXML2MDIKeys; if (shouldReadCharacters == NO) { return; } - - // this delegate method might be called several times for a single element, + + // this delegate method might be called several times for a single element, // so we have to collect the received data [textCurrentElement appendString:string]; - + //NSLog(@"chars read: %@", string); } - (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError { //NSLog(@"parsing finished with error"); - NSLog(@"Error %li, Description: %@, Line: %li, Column: %li", (long) [parseError code], + NSLog(@"Error %li, Description: %@, Line: %li, Column: %li", (long) [parseError code], [[parser parserError] localizedDescription], (long) [parser lineNumber], (long) [parser columnNumber]); } |