1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: GetMetadataForFile.m,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 *************************************************************************/
31 #include <CoreFoundation/CoreFoundation.h>
32 #include <CoreServices/CoreServices.h>
33 #include <Foundation/Foundation.h>
36 #import "OOoSpotlightImporter.h"
39 /* -----------------------------------------------------------------------------
40 Get metadata attributes from file
42 This function's job is to extract useful information your file format supports
43 and return it as a dictionary
44 ----------------------------------------------------------------------------- */
46 Boolean GetMetadataForFile(void* thisInterface,
47 CFMutableDictionaryRef attributes,
48 CFStringRef contentTypeUTI,
49 CFStringRef pathToFile)
51 /* Pull any available metadata from the file at the specified path */
52 /* Return the attribute keys and attribute values in the dict */
53 /* Return TRUE if successful, FALSE if there was no data provided */
54 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
56 OOoSpotlightImporter *importer = [OOoSpotlightImporter new];
58 Boolean importOK = NO;
60 importOK = [importer importDocument:(NSString*)pathToFile
61 contentType:(NSString*)contentTypeUTI
62 attributes:(NSMutableDictionary*)attributes];
64 @catch (NSException *exception) {
65 NSLog(@"main: Caught %@: %@", [exception name], [exception reason]);