diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /extensions/source/macosx/spotlight | |
parent | Initial commit. (diff) | |
download | libreoffice-upstream/4%7.4.7.tar.xz libreoffice-upstream/4%7.4.7.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
17 files changed, 2232 insertions, 0 deletions
diff --git a/extensions/source/macosx/spotlight/GetMetadataForFile.h b/extensions/source/macosx/spotlight/GetMetadataForFile.h new file mode 100644 index 000000000..51086827e --- /dev/null +++ b/extensions/source/macosx/spotlight/GetMetadataForFile.h @@ -0,0 +1,26 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +Boolean GetMetadataForFile( + void * thisInterface, CFMutableDictionaryRef attributes, + CFStringRef contentTypeUTI, CFStringRef pathToFile); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/macosx/spotlight/GetMetadataForFile.m b/extensions/source/macosx/spotlight/GetMetadataForFile.m new file mode 100644 index 000000000..a1dcdbe61 --- /dev/null +++ b/extensions/source/macosx/spotlight/GetMetadataForFile.m @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <CoreFoundation/CoreFoundation.h> +#include <CoreServices/CoreServices.h> +#include <Foundation/Foundation.h> + +#include "GetMetadataForFile.h" +#import "OOoSpotlightImporter.h" + +/* ----------------------------------------------------------------------------- + Get metadata attributes from file + + This function's job is to extract useful information your file format supports + and return it as a dictionary + ----------------------------------------------------------------------------- */ + +Boolean GetMetadataForFile(void* thisInterface, + CFMutableDictionaryRef attributes, + CFStringRef contentTypeUTI, + CFStringRef pathToFile) +{ + (void) thisInterface; /* unused */ + /* Pull any available metadata from the file at the specified path */ + /* Return the attribute keys and attribute values in the dict */ + /* Return TRUE if successful, FALSE if there was no data provided */ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + OOoSpotlightImporter *importer = [OOoSpotlightImporter new]; + + Boolean importOK = NO; + @try { + importOK = [importer importDocument:(NSString*)pathToFile + contentType:(NSString*)contentTypeUTI + attributes:(NSMutableDictionary*)attributes]; + } + @catch (NSException *exception) { + NSLog(@"main: Caught %@: %@", [exception name], [exception reason]); + } + + [importer release]; + + [pool release]; + + return importOK; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/macosx/spotlight/OOoContentDataParser.h b/extensions/source/macosx/spotlight/OOoContentDataParser.h new file mode 100644 index 000000000..dc07a3166 --- /dev/null +++ b/extensions/source/macosx/spotlight/OOoContentDataParser.h @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#import <Cocoa/Cocoa.h> + +@interface OOoContentDataParser : NSObject <NSXMLParserDelegate> { + // indicates if we are interested in an element's content + BOOL shouldReadCharacters; + + // the MD importer's values + NSMutableDictionary *mdiValues; + + // all of the text inside a document + NSMutableString *textContent; + + // the current element's content + NSMutableString *runningTextContent; +} + +- (void)parseXML:(NSData*)data intoDictionary:(NSMutableDictionary*)dict; + +// delegates +- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict; + +- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName; + +- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string; + +- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError; + +- (void)parserDidEndDocument:(NSXMLParser *)parser; + +@end + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/macosx/spotlight/OOoContentDataParser.m b/extensions/source/macosx/spotlight/OOoContentDataParser.m new file mode 100644 index 000000000..e1f51e5b9 --- /dev/null +++ b/extensions/source/macosx/spotlight/OOoContentDataParser.m @@ -0,0 +1,144 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <objc/objc-runtime.h> + +#import "OOoContentDataParser.h" + +@implementation OOoContentDataParser + +- (id)init +{ + if ((self = [super init]) != nil) { + 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]; + + [parser setDelegate:self]; + + [parser setShouldResolveExternalEntities:NO]; + [parser parse]; + + [parser release]; + + //NSLog(@"finished"); +} + +- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict +{ + (void) parser; // unused + (void) namespaceURI; // FIXME this should not be ignored but should be used + // instead of text: prefix in the comparison below! + (void) qualifiedName; // unused + (void) attributeDict; // unused + // all text content is stored inside <text:p> elements + if ([elementName isEqualToString:@"text:p"] == YES) { + runningTextContent = [NSMutableString new]; + shouldReadCharacters = YES; + //NSLog(@"start"); + } else { + return; + } + + //NSLog(@"start element %@", elementName); +} + +- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName +{ + (void) parser; // unused + (void) elementName; // unused + (void) namespaceURI; // unused + (void) qName; // unused + if (shouldReadCharacters == TRUE) { + if (textContent == nil) { + textContent = [NSMutableString new]; + } else if ([runningTextContent isEqualToString:@""] == NO) { + // separate by whitespace + [textContent appendString:@" "]; + } + //NSLog(@"end"); + + [textContent appendString:[NSString stringWithString:runningTextContent]]; + [runningTextContent release]; + runningTextContent = nil; + } + shouldReadCharacters = NO; +} + +- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string +{ + (void) parser; // unused + if (shouldReadCharacters == NO) { + 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], + [[parser parserError] localizedDescription], (long) [parser lineNumber], + (long) [parser columnNumber]); + + if (runningTextContent != nil) { + [runningTextContent release]; + runningTextContent = nil; + } + if (textContent != nil) { + [textContent release]; + textContent = nil; + } +} + +- (void)parserDidEndDocument:(NSXMLParser *)parser +{ + (void) parser; // unused + if (textContent != nil && [textContent length] > 0) { + [mdiValues setObject:[NSString stringWithString:textContent] forKey:(NSString*)kMDItemTextContent]; + [textContent release]; + textContent = nil; + } +} + +@end + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/macosx/spotlight/OOoMetaDataParser.h b/extensions/source/macosx/spotlight/OOoMetaDataParser.h new file mode 100644 index 000000000..85d48b173 --- /dev/null +++ b/extensions/source/macosx/spotlight/OOoMetaDataParser.h @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#import <Cocoa/Cocoa.h> + + +@interface OOoMetaDataParser : NSObject <NSXMLParserDelegate> { + //indicates if content should be read + BOOL shouldReadCharacters; + //indicates if the current element is a custom metadata tag + BOOL isCustom; + + NSMutableDictionary *metaValues; + NSMutableString *textCurrentElement; + NSString *customAttribute; +} + +- (void)parseXML:(NSData*)data intoDictionary:(NSMutableDictionary*)dict; + +//delegates +- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict; + +- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName; + +- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string; + +- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError; +@end + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/macosx/spotlight/OOoMetaDataParser.m b/extensions/source/macosx/spotlight/OOoMetaDataParser.m new file mode 100644 index 000000000..1e7cac685 --- /dev/null +++ b/extensions/source/macosx/spotlight/OOoMetaDataParser.m @@ -0,0 +1,205 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <objc/objc-runtime.h> + +#import "OOoMetaDataParser.h" + +static NSSet *singleValueXMLElements; +static NSSet *multiValueXMLElements; +static NSDictionary *metaXML2MDIKeys; + +@implementation OOoMetaDataParser + ++ (void)initialize +{ + static BOOL isInitialized = NO; + + if (isInitialized == NO) { + //set up the meta elements with only one value + NSMutableSet *temp = [NSMutableSet new]; +//FIXME these should use namespace URIs and not prefixes + [temp addObject:@"dc:title"]; + [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"]; + [temp addObject:@"meta:keyword"]; + [temp addObject:@"meta:initial-creator"]; + [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"]; + [tempDict setObject:(NSString*)kMDItemDescription forKey:@"dc:description"]; + [tempDict setObject:(NSString*)kMDItemKeywords forKey:@"dc:subject"]; + [tempDict setObject:(NSString*)kMDItemAuthors forKey:@"meta:initial-creator"]; + [tempDict setObject:(NSString*)kMDItemAuthors forKey:@"dc:creator"]; + [tempDict setObject:(NSString*)kMDItemKeywords forKey:@"meta:keyword"]; + [tempDict setObject:@"org_openoffice_opendocument_custominfo1" forKey:@"Info 1"]; + [tempDict setObject:@"org_openoffice_opendocument_custominfo2" forKey:@"Info 2"]; + [tempDict setObject:@"org_openoffice_opendocument_custominfo3" forKey:@"Info 3"]; + [tempDict setObject:@"org_openoffice_opendocument_custominfo4" forKey:@"Info 4"]; + metaXML2MDIKeys = [[NSDictionary dictionaryWithDictionary:tempDict] retain]; + [tempDict release]; + + isInitialized = YES; + } +} + +- (id)init +{ + 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]; + + [parser setDelegate:self]; + + [parser setShouldResolveExternalEntities:NO]; + [parser parse]; + + [parser release]; + + //NSLog(@"finished parsing meta"); +} + +- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict +{ + (void) parser; // unused + (void) namespaceURI; // FIXME this should not be ignored but should be used + // instead of meta: prefix in the comparison below! + (void) qualifiedName; // unused +// NSLog(@"<%@>", elementName); + if ([singleValueXMLElements containsObject:elementName] == YES) { + shouldReadCharacters = YES; + } else if ([multiValueXMLElements containsObject:elementName] == YES) { + shouldReadCharacters = YES; + } else { + //we are not interested in this element + shouldReadCharacters = NO; + return; + } + + if (shouldReadCharacters == YES) { + textCurrentElement = [NSMutableString new]; + isCustom = [elementName isEqualToString:@"meta:user-defined"]; + if (isCustom == YES) { + customAttribute = [[attributeDict objectForKey:@"meta:name"] retain]; + //NSLog(customAttribute); + } + } + + //NSLog(@"start element %@", elementName); +} + +- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName +{ + (void) parser; // unused + (void) namespaceURI; // unused + (void) qName; // unused +// NSLog(@"</%@>", elementName); + if (shouldReadCharacters == YES) { + NSString *mdiName = nil; + if (isCustom == YES) { + mdiName = (NSString*)[metaXML2MDIKeys objectForKey:customAttribute]; + } else { + mdiName = (NSString*)[metaXML2MDIKeys objectForKey:elementName]; + } + //NSLog(@"mdiName: %@", mdiName); + + if (mdiName == nil) { + return; + } + + if ([singleValueXMLElements containsObject:elementName] == YES) { + [metaValues setObject:textCurrentElement forKey:mdiName]; + } else { + // must be multi-value + NSMutableArray *arr = [metaValues objectForKey:mdiName]; + if (arr == nil) { + // we have no array yet, create it + arr = [[NSMutableArray new] autorelease]; + // and store it + [metaValues setObject:arr forKey:mdiName]; + } + // only store an element once, no need for duplicates + if ([arr containsObject:textCurrentElement] == NO) { + [arr addObject:textCurrentElement]; + } + } + // cleanup part 1 + [textCurrentElement release]; + if (isCustom == YES) { + [customAttribute release]; + } + } + + //cleanup part 2 + shouldReadCharacters = NO; + isCustom = NO; +} + +- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string +{ + (void) parser; // unused +// NSLog(@"%@", string); + if (shouldReadCharacters == NO) { + return; + } + + // 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], + [[parser parserError] localizedDescription], (long) [parser lineNumber], + (long) [parser columnNumber]); +} + +@end + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/macosx/spotlight/OOoSpotlightImporter.h b/extensions/source/macosx/spotlight/OOoSpotlightImporter.h new file mode 100644 index 000000000..947f8dbf1 --- /dev/null +++ b/extensions/source/macosx/spotlight/OOoSpotlightImporter.h @@ -0,0 +1,37 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#import <Cocoa/Cocoa.h> + +@interface OOoSpotlightImporter : NSObject +{ +} + +- (BOOL)importDocument:(NSString*)pathToFile + contentType:(NSString*)contentTypeUTI + attributes:(NSMutableDictionary*)attributes; + +- (NSFileHandle*)openZipFileAtPath:(NSString*)pathToFile; + +- (NSData*)metaDataFileFromZip:(NSFileHandle*)unzipFile; + +- (NSData*)contentDataFileFromZip:(NSFileHandle*)unzipFile; +@end + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/macosx/spotlight/OOoSpotlightImporter.m b/extensions/source/macosx/spotlight/OOoSpotlightImporter.m new file mode 100644 index 000000000..a144fe259 --- /dev/null +++ b/extensions/source/macosx/spotlight/OOoSpotlightImporter.m @@ -0,0 +1,487 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#import <zlib.h> + +#import "OOoSpotlightImporter.h" +#import "OOoMetaDataParser.h" +#import "OOoContentDataParser.h" + +/* a dictionary to hold the UTIs */ +static NSDictionary *uti2kind; + +typedef struct { + unsigned short min_version; + unsigned short general_flag; + unsigned short compression; + unsigned short lastmod_time; + unsigned short lastmod_date; + unsigned crc32; + unsigned compressed_size; + unsigned uncompressed_size; + unsigned short filename_size; + unsigned short extra_field_size; + NSString *filename; + NSString *extra_field; +} LocalFileHeader; + +typedef struct { + unsigned short creator_version; + unsigned short min_version; + unsigned short general_flag; + unsigned short compression; + unsigned short lastmod_time; + unsigned short lastmod_date; + unsigned crc32; + unsigned compressed_size; + unsigned uncompressed_size; + unsigned short filename_size; + unsigned short extra_field_size; + unsigned short file_comment_size; + unsigned short disk_num; + unsigned short internal_attr; + unsigned external_attr; + unsigned offset; + NSString *filename; + NSString *extra_field; + NSString *file_comment; +} CentralDirectoryEntry; + +typedef struct { + unsigned short disk_num; + unsigned short cdir_disk; + unsigned short disk_entries; + unsigned short cdir_entries; + unsigned cdir_size; + unsigned cdir_offset; + unsigned short comment_size; + NSString *comment; +} CentralDirectoryEnd; + +#define CDIR_ENTRY_SIG (0x02014b50) +#define LOC_FILE_HEADER_SIG (0x04034b50) +#define CDIR_END_SIG (0x06054b50) + +static unsigned char readByte(NSFileHandle *file) +{ + if (file == nil) + return 0; + NSData* tmpBuf = [file readDataOfLength: 1]; + if (tmpBuf == nil) + return 0; + unsigned char *d = (unsigned char*)[tmpBuf bytes]; + if (d == nil) + return 0; + return *d; +} + +static unsigned short readShort(NSFileHandle *file) +{ + unsigned short p0 = (unsigned short)readByte(file); + unsigned short p1 = (unsigned short)readByte(file); + return (unsigned short)(p0|(p1<<8)); +} + +static unsigned readInt(NSFileHandle *file) +{ + unsigned p0 = (unsigned)readByte(file); + unsigned p1 = (unsigned)readByte(file); + unsigned p2 = (unsigned)readByte(file); + unsigned p3 = (unsigned)readByte(file); + return (unsigned)(p0|(p1<<8)|(p2<<16)|(p3<<24)); +} + +static bool readCentralDirectoryEnd(NSFileHandle *file, CentralDirectoryEnd *end) +{ + unsigned signature = readInt(file); + if (signature != CDIR_END_SIG) + return false; + + end->disk_num = readShort(file); + end->cdir_disk = readShort(file); + end->disk_entries = readShort(file); + end->cdir_entries = readShort(file); + end->cdir_size = readInt(file); + end->cdir_offset = readInt(file); + end->comment_size = readShort(file); + NSData *data = [file readDataOfLength: end->comment_size]; + end->comment = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + return true; +} + +static bool readCentralDirectoryEntry(NSFileHandle *file, CentralDirectoryEntry *entry) +{ + unsigned signature = readInt(file); + if (signature != CDIR_ENTRY_SIG) + return false; + + entry->creator_version = readShort(file); + entry->min_version = readShort(file); + entry->general_flag = readShort(file); + entry->compression = readShort(file); + entry->lastmod_time = readShort(file); + entry->lastmod_date = readShort(file); + entry->crc32 = readInt(file); + entry->compressed_size = readInt(file); + entry->uncompressed_size = readInt(file); + entry->filename_size = readShort(file); + entry->extra_field_size = readShort(file); + entry->file_comment_size = readShort(file); + entry->disk_num = readShort(file); + entry->internal_attr = readShort(file); + entry->external_attr = readInt(file); + entry->offset = readInt(file); + NSData *data = [file readDataOfLength: entry->filename_size]; + entry->filename = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + data = [file readDataOfLength: entry->extra_field_size]; + entry->extra_field = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + data = [file readDataOfLength: entry->file_comment_size]; + entry->file_comment = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + return true; +} + +static bool readLocalFileHeader(NSFileHandle *file, LocalFileHeader *header) +{ + unsigned signature = readInt(file); + if (signature != LOC_FILE_HEADER_SIG) + return false; + + header->min_version = readShort(file); + header->general_flag = readShort(file); + header->compression = readShort(file); + header->lastmod_time = readShort(file); + header->lastmod_date = readShort(file); + header->crc32 = readInt(file); + header->compressed_size = readInt(file); + header->uncompressed_size = readInt(file); + header->filename_size = readShort(file); + header->extra_field_size = readShort(file); + NSData *data = [file readDataOfLength: header->filename_size]; + header->filename = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + data = [file readDataOfLength: header->extra_field_size]; + header->extra_field = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + return true; +} + +static bool areHeadersConsistent(const LocalFileHeader *header, const CentralDirectoryEntry *entry) +{ + if (header->min_version != entry->min_version) + return false; + if (header->general_flag != entry->general_flag) + return false; + if (header->compression != entry->compression) + return false; + if (!(header->general_flag & 0x08)) + { + if (header->crc32 != entry->crc32) + return false; + if (header->compressed_size != entry->compressed_size) + return false; + if (header->uncompressed_size != entry->uncompressed_size) + return false; + } + return true; +} + +static bool findCentralDirectoryEnd(NSFileHandle *file) +{ + // Assume the cdir end is in the last 1024 bytes + // Scan backward from end of file for the end signature + + [file seekToEndOfFile]; + unsigned long long fileLength = [file offsetInFile]; + + if (fileLength < 10) + return false; + + [file seekToFileOffset: (fileLength - 4)]; + + unsigned long long limit; + if (fileLength > 1024) + limit = fileLength - 1024; + else + limit = 0; + + unsigned long long offset; + while ((offset = [file offsetInFile]) > limit) + { + unsigned signature = readInt(file); + if (signature == CDIR_END_SIG) + { + // Seek back over the CDIR_END_SIG + [file seekToFileOffset: offset]; + return true; + } + else + { + // Seek one byte back + [file seekToFileOffset: (offset - 1)]; + } + } + return false; +} + +static bool isZipFile(NSFileHandle *file) +{ + if (!findCentralDirectoryEnd(file)) + return false; + CentralDirectoryEnd end; + if (!readCentralDirectoryEnd(file, &end)) + return false; + [file seekToFileOffset: end.cdir_offset]; + CentralDirectoryEntry entry; + if (!readCentralDirectoryEntry(file, &entry)) + return false; + [file seekToFileOffset: entry.offset]; + LocalFileHeader header; + if (!readLocalFileHeader(file, &header)) + return false; + if (!areHeadersConsistent(&header, &entry)) + return false; + return true; +} + +static bool findDataStream(NSFileHandle *file, CentralDirectoryEntry *entry, NSString *name) +{ + [file seekToEndOfFile]; + unsigned long long fileLength = [file offsetInFile]; + if (!findCentralDirectoryEnd(file)) + return false; + CentralDirectoryEnd end; + if (!readCentralDirectoryEnd(file, &end)) + return false; + [file seekToFileOffset: end.cdir_offset]; + do + { + if (!readCentralDirectoryEntry(file, entry)) + return false; + if ([entry->filename compare: name] == NSOrderedSame) + break; + } + while ( [file offsetInFile] < fileLength && [file offsetInFile] < end.cdir_offset + end.cdir_size); + if ([entry->filename compare: name] != NSOrderedSame) + return false; + [file seekToFileOffset: entry->offset]; + LocalFileHeader header; + if (!readLocalFileHeader(file, &header)) + return false; + if (!areHeadersConsistent(&header, entry)) + return false; + return true; +} + +static NSData *getUncompressedData(NSFileHandle *file, NSString *name) +{ + CentralDirectoryEntry entry; + if (!findDataStream(file, &entry, name)) + return nil; + if (!entry.compression) + return [file readDataOfLength: entry.compressed_size]; + else + { + int ret; + z_stream strm; + + /* allocate inflate state */ + strm.zalloc = Z_NULL; + strm.zfree = Z_NULL; + strm.opaque = Z_NULL; + strm.avail_in = 0; + strm.next_in = Z_NULL; + ret = inflateInit2(&strm,-MAX_WBITS); + if (ret != Z_OK) + return nil; + + NSData *compressedData = [file readDataOfLength: entry.compressed_size]; + + strm.avail_in = [compressedData length]; + strm.next_in = (Bytef *)[compressedData bytes]; + + Bytef *uncompressedData = (Bytef *)malloc(entry.uncompressed_size); + if (!uncompressedData) + { + (void)inflateEnd(&strm); + return nil; + } + strm.avail_out = entry.uncompressed_size; + strm.next_out = uncompressedData; + ret = inflate(&strm, Z_FINISH); + switch (ret) + { + case Z_NEED_DICT: + case Z_DATA_ERROR: + case Z_MEM_ERROR: + (void)inflateEnd(&strm); + free(uncompressedData); + return nil; + } + (void)inflateEnd(&strm); + NSData *returnBuffer = [NSData dataWithBytes:(const void *)uncompressedData length:entry.uncompressed_size]; + free(uncompressedData); + return returnBuffer; + } +} + +@implementation OOoSpotlightImporter + +/* initialize is only called once the first time this class is loaded */ ++ (void)initialize +{ + static BOOL isInitialized = NO; + if (isInitialized == NO) { + NSMutableDictionary *temp = [NSMutableDictionary new]; + [temp setObject:@"OpenOffice.org 1.0 Text" forKey:@"org.openoffice.text"]; + [temp setObject:@"OpenDocument Text" forKey:@"org.oasis.opendocument.text"]; + [temp setObject:@"OpenOffice.org 1.0 Spreadsheet" forKey:@"org.openoffice.spreadsheet"]; + [temp setObject:@"OpenDocument Spreadsheet" forKey:@"org.oasis.opendocument.spreadsheet"]; + [temp setObject:@"OpenOffice.org 1.0 Presentation" forKey:@"org.openoffice.presentation"]; + [temp setObject:@"OpenDocument Presentation" forKey:@"org.oasis.opendocument.presentation"]; + [temp setObject:@"OpenOffice.org 1.0 Drawing" forKey:@"org.openoffice.graphics"]; + [temp setObject:@"OpenDocument Drawing" forKey:@"org.oasis.opendocument.graphics"]; + [temp setObject:@"OpenOffice.org 1.0 Master" forKey:@"org.openoffice.text-master"]; + [temp setObject:@"OpenDocument Master" forKey:@"org.oasis.opendocument.text-master"]; + [temp setObject:@"OpenOffice.org 1.0 Formula" forKey:@"org.openoffice.formula"]; + [temp setObject:@"OpenDocument Formula" forKey:@"org.oasis.opendocument.formula"]; + [temp setObject:@"OpenOffice.org 1.0 Text Template" forKey:@"org.openoffice.text-template"]; + [temp setObject:@"OpenDocument Text Template" forKey:@"org.oasis.opendocument.text-template"]; + [temp setObject:@"OpenOffice.org 1.0 Spreadsheet Template" forKey:@"org.openoffice.spreadsheet-template"]; + [temp setObject:@"OpenDocument Spreadsheet Template" forKey:@"org.oasis.opendocument.spreadsheet-template"]; + [temp setObject:@"OpenOffice.org 1.0 Presentation Template" forKey:@"org.openoffice.presentation-template"]; + [temp setObject:@"OpenDocument Presentation Template" forKey:@"org.oasis.opendocument.presentation-template"]; + [temp setObject:@"OpenOffice.org 1.0 Drawing Template" forKey:@"org.openoffice.graphics-template"]; + [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; + } +} + +/* importDocument is the real starting point for our plugin */ +- (BOOL)importDocument:(NSString*)pathToFile contentType:(NSString*)contentTypeUTI attributes:(NSMutableDictionary*)attributes +{ + //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 NO; + } + + //first get the metadata + NSData *metaData = [self metaDataFileFromZip:unzipFile]; + if (metaData == nil) { + [unzipFile closeFile]; + return YES; + } + + [metaData retain]; + + OOoMetaDataParser *parser = [OOoMetaDataParser new]; + if (parser != nil) { + //parse and extract the data + [parser parseXML:metaData intoDictionary:attributes]; + } + + [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 + [parser2 parseXML:contentData intoDictionary:attributes]; + } + + [contentData release]; + [parser2 release]; + + [unzipFile closeFile]; + + return YES; +} + +/* openZipFileAtPath returns the file as a valid data structure or nil otherwise*/ +- (NSFileHandle*)openZipFileAtPath:(NSString*)pathToFile +{ + NSFileHandle* unzipFile = nil; + + if ([pathToFile length] != 0) + { + unzipFile = [NSFileHandle fileHandleForReadingAtPath: pathToFile]; + } + + if (unzipFile == nil) + { + //NSLog(@"Cannot open %s",zipfilename); + return nil; + } + + if (!isZipFile(unzipFile)) + { + [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 + or nil if the metadata is not present */ +- (NSData*) metaDataFileFromZip:(NSFileHandle*)unzipFile +{ + if (unzipFile == nil) + return nil; + return getUncompressedData(unzipFile, @"meta.xml"); +} + +/* 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 +{ + if (unzipFile == nil) + return nil; + return getUncompressedData(unzipFile, @"content.xml"); +} + + +@end + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/macosx/spotlight/SpotlightImporterTester/SpotlightImporterTester.xcodeproj/.gitignore b/extensions/source/macosx/spotlight/SpotlightImporterTester/SpotlightImporterTester.xcodeproj/.gitignore new file mode 100644 index 000000000..96c4e5542 --- /dev/null +++ b/extensions/source/macosx/spotlight/SpotlightImporterTester/SpotlightImporterTester.xcodeproj/.gitignore @@ -0,0 +1 @@ +project.xcworkspace diff --git a/extensions/source/macosx/spotlight/SpotlightImporterTester/SpotlightImporterTester.xcodeproj/project.pbxproj b/extensions/source/macosx/spotlight/SpotlightImporterTester/SpotlightImporterTester.xcodeproj/project.pbxproj new file mode 100644 index 000000000..a577eeb1d --- /dev/null +++ b/extensions/source/macosx/spotlight/SpotlightImporterTester/SpotlightImporterTester.xcodeproj/project.pbxproj @@ -0,0 +1,308 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + BE9A7AC823590D9500931013 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BE9A7AC723590D9500931013 /* main.m */; }; + BE9A7AD723590E5D00931013 /* OOoSpotlightImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = BE9A7ACE23590E5D00931013 /* OOoSpotlightImporter.m */; }; + BE9A7AD823590E5D00931013 /* OOoMetaDataParser.m in Sources */ = {isa = PBXBuildFile; fileRef = BE9A7AD223590E5D00931013 /* OOoMetaDataParser.m */; }; + BE9A7AD923590E5D00931013 /* OOoContentDataParser.m in Sources */ = {isa = PBXBuildFile; fileRef = BE9A7AD323590E5D00931013 /* OOoContentDataParser.m */; }; + BE9A7ADA23590E5D00931013 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BE9A7AD423590E5D00931013 /* main.m */; }; + BE9A7ADB23590E5D00931013 /* GetMetadataForFile.m in Sources */ = {isa = PBXBuildFile; fileRef = BE9A7AD623590E5D00931013 /* GetMetadataForFile.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + BE9A7AC223590D9400931013 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + BE9A7AC423590D9500931013 /* SpotlightImporterTester */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = SpotlightImporterTester; sourceTree = BUILT_PRODUCTS_DIR; }; + BE9A7AC723590D9500931013 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; + BE9A7ACE23590E5D00931013 /* OOoSpotlightImporter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OOoSpotlightImporter.m; path = ../../OOoSpotlightImporter.m; sourceTree = "<group>"; }; + BE9A7ACF23590E5D00931013 /* OOoSpotlightImporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OOoSpotlightImporter.h; path = ../../OOoSpotlightImporter.h; sourceTree = "<group>"; }; + BE9A7AD023590E5D00931013 /* GetMetadataForFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GetMetadataForFile.h; path = ../../GetMetadataForFile.h; sourceTree = "<group>"; }; + BE9A7AD123590E5D00931013 /* OOoMetaDataParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OOoMetaDataParser.h; path = ../../OOoMetaDataParser.h; sourceTree = "<group>"; }; + BE9A7AD223590E5D00931013 /* OOoMetaDataParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OOoMetaDataParser.m; path = ../../OOoMetaDataParser.m; sourceTree = "<group>"; }; + BE9A7AD323590E5D00931013 /* OOoContentDataParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OOoContentDataParser.m; path = ../../OOoContentDataParser.m; sourceTree = "<group>"; }; + BE9A7AD423590E5D00931013 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = ../../main.m; sourceTree = "<group>"; }; + BE9A7AD523590E5D00931013 /* OOoContentDataParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OOoContentDataParser.h; path = ../../OOoContentDataParser.h; sourceTree = "<group>"; }; + BE9A7AD623590E5D00931013 /* GetMetadataForFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GetMetadataForFile.m; path = ../../GetMetadataForFile.m; sourceTree = "<group>"; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + BE9A7AC123590D9400931013 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + BE9A7ABB23590D9400931013 = { + isa = PBXGroup; + children = ( + BE9A7AC623590D9500931013 /* SpotlightImporterTester */, + BE9A7AC523590D9500931013 /* Products */, + ); + sourceTree = "<group>"; + }; + BE9A7AC523590D9500931013 /* Products */ = { + isa = PBXGroup; + children = ( + BE9A7AC423590D9500931013 /* SpotlightImporterTester */, + ); + name = Products; + sourceTree = "<group>"; + }; + BE9A7AC623590D9500931013 /* SpotlightImporterTester */ = { + isa = PBXGroup; + children = ( + BE9A7AD023590E5D00931013 /* GetMetadataForFile.h */, + BE9A7AD623590E5D00931013 /* GetMetadataForFile.m */, + BE9A7AD423590E5D00931013 /* main.m */, + BE9A7AD523590E5D00931013 /* OOoContentDataParser.h */, + BE9A7AD323590E5D00931013 /* OOoContentDataParser.m */, + BE9A7AD123590E5D00931013 /* OOoMetaDataParser.h */, + BE9A7AD223590E5D00931013 /* OOoMetaDataParser.m */, + BE9A7ACF23590E5D00931013 /* OOoSpotlightImporter.h */, + BE9A7ACE23590E5D00931013 /* OOoSpotlightImporter.m */, + BE9A7AC723590D9500931013 /* main.m */, + ); + path = SpotlightImporterTester; + sourceTree = "<group>"; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + BE9A7AC323590D9400931013 /* SpotlightImporterTester */ = { + isa = PBXNativeTarget; + buildConfigurationList = BE9A7ACB23590D9500931013 /* Build configuration list for PBXNativeTarget "SpotlightImporterTester" */; + buildPhases = ( + BE9A7AC023590D9400931013 /* Sources */, + BE9A7AC123590D9400931013 /* Frameworks */, + BE9A7AC223590D9400931013 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SpotlightImporterTester; + productName = SpotlightImporterTester; + productReference = BE9A7AC423590D9500931013 /* SpotlightImporterTester */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + BE9A7ABC23590D9400931013 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1110; + ORGANIZATIONNAME = Collabora; + TargetAttributes = { + BE9A7AC323590D9400931013 = { + CreatedOnToolsVersion = 11.1; + }; + }; + }; + buildConfigurationList = BE9A7ABF23590D9400931013 /* Build configuration list for PBXProject "SpotlightImporterTester" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = BE9A7ABB23590D9400931013; + productRefGroup = BE9A7AC523590D9500931013 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + BE9A7AC323590D9400931013 /* SpotlightImporterTester */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + BE9A7AC023590D9400931013 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BE9A7ADA23590E5D00931013 /* main.m in Sources */, + BE9A7AD923590E5D00931013 /* OOoContentDataParser.m in Sources */, + BE9A7AD823590E5D00931013 /* OOoMetaDataParser.m in Sources */, + BE9A7ADB23590E5D00931013 /* GetMetadataForFile.m in Sources */, + BE9A7AD723590E5D00931013 /* OOoSpotlightImporter.m in Sources */, + BE9A7AC823590D9500931013 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + BE9A7AC923590D9500931013 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + LO_CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + LO_CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + BE9A7ACA23590D9500931013 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + LO_CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + LO_CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + }; + name = Release; + }; + BE9A7ACC23590D9500931013 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_ARC = NO; + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + BE9A7ACD23590D9500931013 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_OBJC_ARC = NO; + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + BE9A7ABF23590D9400931013 /* Build configuration list for PBXProject "SpotlightImporterTester" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BE9A7AC923590D9500931013 /* Debug */, + BE9A7ACA23590D9500931013 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + BE9A7ACB23590D9500931013 /* Build configuration list for PBXNativeTarget "SpotlightImporterTester" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BE9A7ACC23590D9500931013 /* Debug */, + BE9A7ACD23590D9500931013 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = BE9A7ABC23590D9400931013 /* Project object */; +} diff --git a/extensions/source/macosx/spotlight/SpotlightImporterTester/SpotlightImporterTester.xcodeproj/xcshareddata/xcschemes/SpotlightImporterTester.xcscheme b/extensions/source/macosx/spotlight/SpotlightImporterTester/SpotlightImporterTester.xcodeproj/xcshareddata/xcschemes/SpotlightImporterTester.xcscheme new file mode 100644 index 000000000..d2aab1a01 --- /dev/null +++ b/extensions/source/macosx/spotlight/SpotlightImporterTester/SpotlightImporterTester.xcodeproj/xcshareddata/xcschemes/SpotlightImporterTester.xcscheme @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "1110" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + <BuildActionEntries> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "BE9A7AC323590D9400931013" + BuildableName = "SpotlightImporterTester" + BlueprintName = "SpotlightImporterTester" + ReferencedContainer = "container:SpotlightImporterTester.xcodeproj"> + </BuildableReference> + </BuildActionEntry> + </BuildActionEntries> + </BuildAction> + <TestAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + shouldUseLaunchSchemeArgsEnv = "YES"> + <Testables> + </Testables> + </TestAction> + <LaunchAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + debugServiceExtension = "internal" + allowLocationSimulation = "YES"> + <BuildableProductRunnable + runnableDebuggingMode = "0"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "BE9A7AC323590D9400931013" + BuildableName = "SpotlightImporterTester" + BlueprintName = "SpotlightImporterTester" + ReferencedContainer = "container:SpotlightImporterTester.xcodeproj"> + </BuildableReference> + </BuildableProductRunnable> + <CommandLineArguments> + <CommandLineArgument + argument = "org.openoffice.database" + isEnabled = "YES"> + </CommandLineArgument> + <CommandLineArgument + argument = "/tmp/sample.odb" + isEnabled = "YES"> + </CommandLineArgument> + </CommandLineArguments> + </LaunchAction> + <ProfileAction + buildConfiguration = "Release" + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + debugDocumentVersioning = "YES"> + <BuildableProductRunnable + runnableDebuggingMode = "0"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "BE9A7AC323590D9400931013" + BuildableName = "SpotlightImporterTester" + BlueprintName = "SpotlightImporterTester" + ReferencedContainer = "container:SpotlightImporterTester.xcodeproj"> + </BuildableReference> + </BuildableProductRunnable> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/extensions/source/macosx/spotlight/SpotlightImporterTester/SpotlightImporterTester/main.m b/extensions/source/macosx/spotlight/SpotlightImporterTester/SpotlightImporterTester/main.m new file mode 100644 index 000000000..f9b6bbb5f --- /dev/null +++ b/extensions/source/macosx/spotlight/SpotlightImporterTester/SpotlightImporterTester/main.m @@ -0,0 +1,30 @@ +/* -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +#import <stdio.h> + +#import <CoreFoundation/CoreFoundation.h> +#import <CoreServices/CoreServices.h> +#import <Foundation/Foundation.h> + +#import "GetMetadataForFile.h" + +int main(int argc, const char* argv[]) +{ + @autoreleasepool + { + if (argc != 3) + { + fprintf(stderr, "Usage: %s UTI path\n", argv[0]); + return 1; + } + NSMutableDictionary* attributes = [NSMutableDictionary dictionaryWithCapacity:10]; + NSString* contentTypeUTI = [NSString stringWithUTF8String:argv[1]]; + NSString* pathToFile = [NSString stringWithUTF8String:argv[2]]; + + GetMetadataForFile(NULL, (__bridge CFMutableDictionaryRef)attributes, + (__bridge CFStringRef)contentTypeUTI, (__bridge CFStringRef)pathToFile); + } + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/macosx/spotlight/main.m b/extensions/source/macosx/spotlight/main.m new file mode 100644 index 000000000..b1a6381a7 --- /dev/null +++ b/extensions/source/macosx/spotlight/main.m @@ -0,0 +1,211 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +// +// main.m +// SpotlightTester +// +// Created by Florian Heckl on 10.07.07. +// +//============================================================================== +// +// DO NOT MODIFY THE CONTENTS OF THIS FILE +// +// This file contains the generic CFPlug-in code necessary for your importer +// To complete your importer implement the function in GetMetadataForFile.c +// +//============================================================================== + +#include <CoreFoundation/CoreFoundation.h> +#include <CoreFoundation/CFPlugInCOM.h> +#include <CoreServices/CoreServices.h> + +#include "GetMetadataForFile.h" + +// constants + + +#define PLUGIN_ID "A3FCC88D-B9A6-4364-8B93-92123C8A2D18" + +// +// Below is the generic glue code for all plug-ins. +// +// You should not have to modify this code aside from changing +// names if you decide to change the names defined in the Info.plist +// + + +// typedefs + +// The layout for an instance of MetaDataImporterPlugIn +typedef struct +{ + MDImporterInterfaceStruct *conduitInterface; + CFUUIDRef factoryID; + UInt32 refCount; +} MetadataImporterPluginType; + +// prototypes +// Forward declaration for the IUnknown implementation. +// + +static MetadataImporterPluginType *AllocMetadataImporterPluginType(CFUUIDRef inFactoryID); +static void DeallocMetadataImporterPluginType(MetadataImporterPluginType *thisInstance); +static HRESULT MetadataImporterQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv); +static ULONG MetadataImporterPluginAddRef(void *thisInstance); +static ULONG MetadataImporterPluginRelease(void *thisInstance); +// testInterfaceFtbl definition +// The TestInterface function table. +// + +static MDImporterInterfaceStruct testInterfaceFtbl = { + NULL, + MetadataImporterQueryInterface, + MetadataImporterPluginAddRef, + MetadataImporterPluginRelease, + GetMetadataForFile +}; + + +// AllocMetadataImporterPluginType +// Utility function that allocates a new instance. +// You can do some initial setup for the importer here if you wish +// like allocating globals etc... +// +MetadataImporterPluginType *AllocMetadataImporterPluginType(CFUUIDRef inFactoryID) +{ + MetadataImporterPluginType *theNewInstance; + + theNewInstance = (MetadataImporterPluginType *)malloc(sizeof(MetadataImporterPluginType)); + memset(theNewInstance,0,sizeof(MetadataImporterPluginType)); + + /* Point to the function table */ + theNewInstance->conduitInterface = &testInterfaceFtbl; + + /* Retain and keep an open instance refcount for each factory. */ + theNewInstance->factoryID = CFRetain(inFactoryID); + CFPlugInAddInstanceForFactory(inFactoryID); + + /* This function returns the IUnknown interface so set the refCount to one. */ + theNewInstance->refCount = 1; + return theNewInstance; +} + +// DeallocSpotlightTesterMDImporterPluginType +// Utility function that deallocates the instance when +// the refCount goes to zero. +// In the current implementation importer interfaces are never deallocated +// but implement this as this might change in the future +// +void DeallocMetadataImporterPluginType(MetadataImporterPluginType *thisInstance) +{ + CFUUIDRef theFactoryID; + + theFactoryID = thisInstance->factoryID; + free(thisInstance); + if (theFactoryID){ + CFPlugInRemoveInstanceForFactory(theFactoryID); + CFRelease(theFactoryID); + } +} + +// MetadataImporterQueryInterface +// Implementation of the IUnknown QueryInterface function. +// +HRESULT MetadataImporterQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv) +{ + CFUUIDRef interfaceID; + + interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault,iid); + + if (CFEqual(interfaceID,kMDImporterInterfaceID)){ + /* If the Right interface was requested, bump the ref count, + * set the ppv parameter equal to the instance, and + * return good status. + */ + ((MetadataImporterPluginType*)thisInstance)->conduitInterface->AddRef(thisInstance); + *ppv = thisInstance; + CFRelease(interfaceID); + return S_OK; + }else{ + if (CFEqual(interfaceID,IUnknownUUID)){ + /* If the IUnknown interface was requested, same as above. */ + ((MetadataImporterPluginType*)thisInstance )->conduitInterface->AddRef(thisInstance); + *ppv = thisInstance; + CFRelease(interfaceID); + return S_OK; + }else{ + /* Requested interface unknown, bail with error. */ + *ppv = NULL; + CFRelease(interfaceID); + return E_NOINTERFACE; + } + } +} + +// MetadataImporterPluginAddRef +// Implementation of reference counting for this type. Whenever an interface +// is requested, bump the refCount for the instance. NOTE: returning the +// refcount is a convention but is not required so don't rely on it. +// +ULONG MetadataImporterPluginAddRef(void *thisInstance) +{ + ((MetadataImporterPluginType *)thisInstance )->refCount += 1; + return ((MetadataImporterPluginType*) thisInstance)->refCount; +} + +// SampleCMPluginRelease +// When an interface is released, decrement the refCount. +// If the refCount goes to zero, deallocate the instance. +// +ULONG MetadataImporterPluginRelease(void *thisInstance) +{ + ((MetadataImporterPluginType*)thisInstance)->refCount -= 1; + if (((MetadataImporterPluginType*)thisInstance)->refCount == 0){ + DeallocMetadataImporterPluginType((MetadataImporterPluginType*)thisInstance ); + return 0; + }else{ + return ((MetadataImporterPluginType*) thisInstance )->refCount; + } +} + +// SpotlightTesterMDImporterPluginFactory +// Implementation of the factory function for this type. +// +__attribute__ ((visibility("default"))) +void * +MetadataImporterPluginFactory(CFAllocatorRef allocator, CFUUIDRef typeID) +{ + (void) allocator; /* unused */ + MetadataImporterPluginType *result; + CFUUIDRef uuid; + + /* If correct type is being requested, allocate an + * instance of TestType and return the IUnknown interface. + */ + if (CFEqual(typeID,kMDImporterTypeID)){ + uuid = CFUUIDCreateFromString(kCFAllocatorDefault,CFSTR(PLUGIN_ID)); + result = AllocMetadataImporterPluginType(uuid); + CFRelease(uuid); + return result; + } + /* If the requested type is incorrect, return NULL. */ + return NULL; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/macosx/spotlight/mdimporter/Info.plist b/extensions/source/macosx/spotlight/mdimporter/Info.plist new file mode 100644 index 000000000..5a60493cb --- /dev/null +++ b/extensions/source/macosx/spotlight/mdimporter/Info.plist @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleDocumentTypes</key> + <array> + <dict> + <key>CFBundleTypeRole</key> + <string>MDImporter</string> + <key>LSItemContentTypes</key> + <array> + <string>org.openoffice.text</string> + <string>org.oasis-open.opendocument.text</string> + <string>org.openoffice.spreadsheet</string> + <string>org.oasis-open.opendocument.spreadsheet</string> + <string>org.openoffice.presentation</string> + <string>org.oasis-open.opendocument.presentation</string> + <string>org.openoffice.graphics</string> + <string>org.oasis-open.opendocument.graphics</string> + <string>org.openoffice.text-master</string> + <string>org.oasis-open.opendocument.text-master</string> + <string>org.openoffice.formula</string> + <string>org.oasis-open.opendocument.formula</string> + <string>org.openoffice.text-template</string> + <string>org.oasis-open.opendocument.text-template</string> + <string>org.openoffice.spreadsheet-template</string> + <string>org.oasis-open.opendocument.spreadsheet-template</string> + <string>org.openoffice.presentation-template</string> + <string>org.oasis-open.opendocument.presentation-template</string> + <string>org.openoffice.graphics-template</string> + <string>org.oasis-open.opendocument.graphics-template</string> + <string>org.oasis-open.opendocument.database</string> + </array> + </dict> + </array> + <key>CFBundleExecutable</key> + <string>OOoSpotlightImporter</string> + <key>CFBundleName</key> + <string>OOoSpotlightImporter</string> + <key>CFBundleIconFile</key> + <string></string> + <key>CFBundleIdentifier</key> + <string>org.libreoffice.mdimporter</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleVersion</key> + <string>1.0</string> + <key>CFPlugInDynamicRegisterFunction</key> + <string></string> + <key>CFPlugInDynamicRegistration</key> + <string>NO</string> + <key>CFPlugInFactories</key> + <dict> + <key>A3FCC88D-B9A6-4364-8B93-92123C8A2D18</key> + <string>MetadataImporterPluginFactory</string> + </dict> + <key>CFPlugInTypes</key> + <dict> + <key>8B08C4BF-415B-11D8-B3F9-0003936726FC</key> + <array> + <string>A3FCC88D-B9A6-4364-8B93-92123C8A2D18</string> + </array> + </dict> + <key>CFPlugInUnloadFunction</key> + <string></string> + +</dict> +</plist> diff --git a/extensions/source/macosx/spotlight/mdimporter/en.lproj/schema.strings b/extensions/source/macosx/spotlight/mdimporter/en.lproj/schema.strings new file mode 100644 index 000000000..355998783 --- /dev/null +++ b/extensions/source/macosx/spotlight/mdimporter/en.lproj/schema.strings @@ -0,0 +1 @@ +ÿþ
\ No newline at end of file diff --git a/extensions/source/macosx/spotlight/mdimporter/schema.xml b/extensions/source/macosx/spotlight/mdimporter/schema.xml new file mode 100644 index 000000000..f17aa8c6c --- /dev/null +++ b/extensions/source/macosx/spotlight/mdimporter/schema.xml @@ -0,0 +1,413 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> +<schema version="1.0" xmlns="http://www.apple.com/metadata" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.apple.com/metadata file:///System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Resources/MetadataSchema.xsd"> + <note> + OpenOffice.org allows the user to enter 4 pieces of custom information in the document's metadata. + These metadata fields are described here for Spotlight's use. + </note> + <attributes> + <attribute name="org_openoffice_opendocument_custominfo1" type="CFString"/> + <attribute name="org_openoffice_opendocument_custominfo2" type="CFString"/> + <attribute name="org_openoffice_opendocument_custominfo3" type="CFString"/> + <attribute name="org_openoffice_opendocument_custominfo4" type="CFString"/> + </attributes> + + <types> + <type name="org.openoffice.text"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.oasis.opendocument.text"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.openoffice.spreadsheet"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.oasis.opendocument.spreadsheet"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.openoffice.presentation"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.oasis.opendocument.presentation"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.openoffice.graphics"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.oasis.opendocument.graphics"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.openoffice.text-master"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.oasis.opendocument.text-master"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.openoffice.formula"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.oasis.opendocument.formula"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.openoffice.text-template"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.oasis.opendocument.text-template"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.openoffice.spreadsheet-template"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.oasis.opendocument.spreadsheet-template"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.openoffice.presentation-template"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.oasis.opendocument.presentation-template"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.openoffice.graphics-template"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.oasis.opendocument.graphics-template"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + + <type name="org.oasis.opendocument.chart"> + <note> + The custom metadata info. + </note> + <allattrs id="attrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </allattrs> + <displayattrs id="dattrs"> + org_openoffice_opendocument_custominfo1 + org_openoffice_opendocument_custominfo2 + org_openoffice_opendocument_custominfo3 + org_openoffice_opendocument_custominfo4 + </displayattrs> + </type> + </types> +</schema> + diff --git a/extensions/source/macosx/spotlight/version.plist b/extensions/source/macosx/spotlight/version.plist new file mode 100644 index 000000000..d91342841 --- /dev/null +++ b/extensions/source/macosx/spotlight/version.plist @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> +<plist version="1.0"> +<dict> + <key>BuildVersion</key> + <string>266</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleVersion</key> + <string>1.0</string> + <key>ProjectName</key> + <string>DevToolsWizardTemplates</string> + <key>SourceVersion</key> + <string>3070000</string> +</dict> +</plist> |