20#include <objc/objc-runtime.h>
32 static BOOL isInitialized =
NO;
34 if (isInitialized ==
NO) {
36 NSMutableSet *temp = [NSMutableSet new];
38 [temp addObject:@"dc:title"];
39 [temp addObject:@"dc:description"];
40 [temp addObject:@"meta:user-defined"];
44 [temp removeAllObjects];
45 [temp addObject:@"dc:subject"];
46 [temp addObject:@"meta:keyword"];
47 [temp addObject:@"meta:initial-creator"];
48 [temp addObject:@"dc:creator"];
53 NSMutableDictionary *tempDict = [NSMutableDictionary new];
54 [tempDict setObject:(NSString*)kMDItemTitle forKey:@"dc:title"];
55 [tempDict setObject:(NSString*)kMDItemDescription forKey:@"dc:description"];
56 [tempDict setObject:(NSString*)kMDItemKeywords forKey:@"dc:subject"];
57 [tempDict setObject:(NSString*)kMDItemAuthors forKey:@"meta:initial-creator"];
58 [tempDict setObject:(NSString*)kMDItemAuthors forKey:@"dc:creator"];
59 [tempDict setObject:(NSString*)kMDItemKeywords forKey:@"meta:keyword"];
60 [tempDict setObject:@"org_openoffice_opendocument_custominfo1" forKey:@"Info 1"];
61 [tempDict setObject:@"org_openoffice_opendocument_custominfo2" forKey:@"Info 2"];
62 [tempDict setObject:@"org_openoffice_opendocument_custominfo3" forKey:@"Info 3"];
63 [tempDict setObject:@"org_openoffice_opendocument_custominfo4" forKey:@"Info 4"];
64 metaXML2MDIKeys = [[NSDictionary dictionaryWithDictionary:tempDict] retain];
73 if ((
self = [super init]) != nil) {
83- (void)parseXML:(NSData*)data intoDictionary:(NSMutableDictionary*)dict
92 NSXMLParser *
parser = [[NSXMLParser alloc] initWithData:data];
94 [parser setDelegate:self];
96 [parser setShouldResolveExternalEntities:NO];
104- (void)
parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict
109 (void) qualifiedName;
123 isCustom = [elementName isEqualToString:@"meta:user-defined"];
133- (void)
parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
140 NSString *mdiName = nil;
148 if (mdiName == nil) {
153 [metaValues setObject:textCurrentElement forKey:mdiName];
156 NSMutableArray *
arr = [metaValues objectForKey:mdiName];
159 arr = [[NSMutableArray new] autorelease];
161 [metaValues setObject:arr forKey:mdiName];
165 [arr addObject:textCurrentElement];
169 [textCurrentElement release];
171 [customAttribute release];
180- (void)
parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
190 [textCurrentElement appendString:string];
195- (void)
parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
198 NSLog(
@"Error %li, Description: %@, Line: %li, Column: %li", (
long) [parseError code],
199 [[parser parserError] localizedDescription], (
long) [parser lineNumber],
200 (
long) [parser columnNumber]);
FILE * init(int, char **)
const wchar_t *typedef BOOL