summaryrefslogtreecommitdiff
path: root/extensions/source/macosx
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/source/macosx')
-rw-r--r--extensions/source/macosx/spotlight/OOoContentDataParser.m32
-rw-r--r--extensions/source/macosx/spotlight/OOoMetaDataParser.m44
-rw-r--r--extensions/source/macosx/spotlight/OOoSpotlightImporter.m34
3 files changed, 55 insertions, 55 deletions
diff --git a/extensions/source/macosx/spotlight/OOoContentDataParser.m b/extensions/source/macosx/spotlight/OOoContentDataParser.m
index 07368aebc15e..d394115a3010 100644
--- a/extensions/source/macosx/spotlight/OOoContentDataParser.m
+++ b/extensions/source/macosx/spotlight/OOoContentDataParser.m
@@ -29,24 +29,24 @@
shouldReadCharacters = NO;
textContent = nil;
runningTextContent = nil;
-
+
return self;
}
-
+
return nil;
}
- (void)parseXML:(NSData*)data intoDictionary:(NSMutableDictionary*)dict
{
mdiValues = dict;
-
+
//NSLog(@"data: %@ %d", data, [data length]);
-
+
//init parser settings
shouldReadCharacters = NO;
-
+
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
-
+
// Once again...
// class 'OOoContentDataParser' does not implement the 'NSXMLParserDelegate' protocol
// So instead of this:
@@ -56,9 +56,9 @@
[parser setShouldResolveExternalEntities:NO];
[parser parse];
-
+
[parser release];
-
+
//NSLog(@"finished");
}
@@ -77,11 +77,11 @@
} else {
return;
}
-
+
//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) elementName; // unused
@@ -95,7 +95,7 @@
[textContent appendString:@" "];
}
//NSLog(@"end");
-
+
[textContent appendString:[NSString stringWithString:runningTextContent]];
[runningTextContent release];
}
@@ -109,20 +109,20 @@
return;
}
//NSLog(string);
-
+
[runningTextContent appendString:string];
-
+
//NSLog(@"read: %@", string);
-
+
}
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
{
//NSLog(@"parsing finished with error");
- NSLog(@"An error occurred parsing the document. (Error %li, Description: %@, Line: %li, Column: %li)", (long) [parseError code],
+ NSLog(@"An error occurred parsing the document. (Error %li, Description: %@, Line: %li, Column: %li)", (long) [parseError code],
[[parser parserError] localizedDescription], (long) [parser lineNumber],
(long) [parser columnNumber]);
-
+
if (runningTextContent != nil) {
[runningTextContent release];
}
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]);
}
diff --git a/extensions/source/macosx/spotlight/OOoSpotlightImporter.m b/extensions/source/macosx/spotlight/OOoSpotlightImporter.m
index dd599fbb6b01..dde2c473437b 100644
--- a/extensions/source/macosx/spotlight/OOoSpotlightImporter.m
+++ b/extensions/source/macosx/spotlight/OOoSpotlightImporter.m
@@ -366,10 +366,10 @@ NSData *getUncompressedData(NSFileHandle *file, NSString *name)
[temp setObject:@"OpenDocument Drawing Template" forKey:@"org.oasis.opendocument.graphics-template"];
[temp setObject:@"OpenOffice.org 1.0 Database" forKey:@"org.openoffice.database"];
[temp setObject:@"OpenDocument Chart" forKey:@"org.oasis.opendocument.chart"];
-
+
uti2kind = [[NSDictionary dictionaryWithDictionary:temp] retain];
[temp release];
-
+
isInitialized = YES;
}
}
@@ -379,21 +379,21 @@ NSData *getUncompressedData(NSFileHandle *file, NSString *name)
{
//NSLog(contentTypeUTI);
//NSLog(pathToFile);
-
+
NSString *itemKind = [uti2kind objectForKey:contentTypeUTI];
if (itemKind != nil) {
[attributes setObject:itemKind forKey:(NSString*)kMDItemKind];
}
-
+
//first check to see if this is a valid zipped file that contains a file "meta.xml"
NSFileHandle *unzipFile = [self openZipFileAtPath:pathToFile];
- //
+
if (unzipFile == nil) {
//NSLog(@"zip file not open");
return YES;
}
-
+
//first get the metadata
NSData *metaData = [self metaDataFileFromZip:unzipFile];
if (metaData == nil) {
@@ -402,7 +402,7 @@ NSData *getUncompressedData(NSFileHandle *file, NSString *name)
}
[metaData retain];
-
+
OOoMetaDataParser *parser = [OOoMetaDataParser new];
if (parser != nil) {
//parse and extract the data
@@ -411,16 +411,16 @@ NSData *getUncompressedData(NSFileHandle *file, NSString *name)
[metaData release];
[parser release];
-
+
//and now get the content
NSData *contentData = [self contentDataFileFromZip:unzipFile];
if (contentData == nil) {
[unzipFile closeFile];
return YES;
}
-
+
[contentData retain];
-
+
OOoContentDataParser *parser2 = [OOoContentDataParser new];
if (parser2 != nil) {
//parse and extract the data
@@ -431,7 +431,7 @@ NSData *getUncompressedData(NSFileHandle *file, NSString *name)
[parser2 release];
[unzipFile closeFile];
-
+
return YES;
}
@@ -439,12 +439,12 @@ NSData *getUncompressedData(NSFileHandle *file, NSString *name)
- (NSFileHandle*)openZipFileAtPath:(NSString*)pathToFile
{
NSFileHandle* unzipFile = nil;
-
+
if ([pathToFile length] != 0)
{
unzipFile = [NSFileHandle fileHandleForReadingAtPath: pathToFile];
}
-
+
if (unzipFile == nil)
{
//NSLog(@"Cannot open %s",zipfilename);
@@ -455,13 +455,13 @@ NSData *getUncompressedData(NSFileHandle *file, NSString *name)
{
[unzipFile closeFile];
return nil;
- }
+ }
//NSLog(@"%s opened",zipfilename);
-
+
return unzipFile;
}
-/* metaDataFileFromZip extracts the file meta.xml from the zip file and returns it as an NSData* structure
+/* metaDataFileFromZip extracts the file meta.xml from the zip file and returns it as an NSData* structure
or nil if the metadata is not present */
- (NSData*) metaDataFileFromZip:(NSFileHandle*)unzipFile
{
@@ -470,7 +470,7 @@ NSData *getUncompressedData(NSFileHandle *file, NSString *name)
return getUncompressedData(unzipFile, @"meta.xml");
}
-/* contentDataFileFromZip extracts the file content.xml from the zip file and returns it as an NSData* structure
+/* contentDataFileFromZip extracts the file content.xml from the zip file and returns it as an NSData* structure
or nil if the metadata is not present */
- (NSData*) contentDataFileFromZip:(NSFileHandle*)unzipFile
{