Revision: 2769
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2769&view=rev
Author:   hofman
Date:     2007-08-29 02:51:52 -0700 (Wed, 29 Aug 2007)

Log Message:
-----------
Add document attributes to spotlight values for PDFD bundle.

Modified Paths:
--------------
    trunk/SkimImporter/Dutch.lproj/schema.strings
    trunk/SkimImporter/English.lproj/schema.strings
    trunk/SkimImporter/French.lproj/schema.strings
    trunk/SkimImporter/GetMetadataForFile.m
    trunk/SkimImporter/Italian.lproj/schema.strings
    trunk/SkimImporter/schema.xml

Modified: trunk/SkimImporter/Dutch.lproj/schema.strings
===================================================================
(Binary files differ)

Modified: trunk/SkimImporter/English.lproj/schema.strings
===================================================================
(Binary files differ)

Modified: trunk/SkimImporter/French.lproj/schema.strings
===================================================================
(Binary files differ)

Modified: trunk/SkimImporter/GetMetadataForFile.m
===================================================================
--- trunk/SkimImporter/GetMetadataForFile.m     2007-08-29 09:49:32 UTC (rev 
2768)
+++ trunk/SkimImporter/GetMetadataForFile.m     2007-08-29 09:51:52 UTC (rev 
2769)
@@ -62,9 +62,10 @@
     }
     
     if (notePath && [[NSFileManager defaultManager] 
fileExistsAtPath:notePath]) {
+        NSMutableString *textContent = [[NSMutableString alloc] init];
+        
         NSData *data = [[NSData alloc] initWithContentsOfFile:notePath 
options:NSUncachedRead error:NULL];
         if (data) {
-            NSMutableString *textContent = [[NSMutableString alloc] init];
             NSArray *array = [NSKeyedUnarchiver unarchiveObjectWithData:data];
             [data release];
             
@@ -88,22 +89,50 @@
                     }
                 }
                 [(NSMutableDictionary *)attributes setObject:notes 
forKey:@"net_sourceforge_skim_app_notes"];
-                [textContent release];
                 [notes release];
             }
-            
-            if (UTTypeEqual(contentTypeUTI, 
CFSTR("net.sourceforge.skim-app.pdfd"))) {
-                NSString *textPath = [(NSString *)pathToFile 
stringByAppendingPathComponent:@"data.txt"];
-                NSString *string = [NSString 
stringWithContentsOfFile:textPath];
-                if ([string length]) {
-                    if ([textContent length])
-                        [textContent appendString:@"\n\n"];
-                    [textContent appendString:string];
+        }
+        
+        if (UTTypeEqual(contentTypeUTI, 
CFSTR("net.sourceforge.skim-app.pdfd"))) {
+            NSString *textPath = [(NSString *)pathToFile 
stringByAppendingPathComponent:@"data.txt"];
+            NSString *string = [NSString stringWithContentsOfFile:textPath];
+            if ([string length]) {
+                if ([textContent length])
+                    [textContent appendString:@"\n\n"];
+                [textContent appendString:string];
+            }
+        
+            NSString *plistPath = [(NSString *)pathToFile 
stringByAppendingPathComponent:@"data.plist"];
+            NSData *plistData = [NSData dataWithContentsOfFile:plistPath];
+            NSDictionary *info = plistData ? [NSPropertyListSerialization 
propertyListFromData:plistData mutabilityOption:NSPropertyListImmutable 
format:NULL errorDescription:NULL] : nil;
+            if (info) {
+                id value;
+                id pageWidth = [info objectForKey:@"PageWidth"], pageHeight = 
[info objectForKey:@"PageHeight"];
+                if (value = [info objectForKey:@"Title"])
+                    [(NSMutableDictionary *)attributes setObject:value 
forKey:(NSString *)kMDItemTitle];
+                if (value = [info objectForKey:@"Author"])
+                    [(NSMutableDictionary *)attributes setObject:value 
forKey:(NSString *)kMDItemAuthors];
+                if (value = [info objectForKey:@"Keywords"])
+                    [(NSMutableDictionary *)attributes setObject:value 
forKey:(NSString *)kMDItemKeywords];
+                if (value = [info objectForKey:@"Producer"])
+                    [(NSMutableDictionary *)attributes setObject:value 
forKey:(NSString *)kMDItemEncodingApplications];
+                if (value = [info objectForKey:@"Version"])
+                    [(NSMutableDictionary *)attributes setObject:value 
forKey:(NSString *)kMDItemVersion];
+                if (value = [info objectForKey:@"Encrypted"])
+                    [(NSMutableDictionary *)attributes setObject:[value 
boolValue] ? @"Password Encrypted" : @"None" forKey:(NSString 
*)kMDItemSecurityMethod];
+                if (value = [info objectForKey:@"PageCount"])
+                    [(NSMutableDictionary *)attributes setObject:value 
forKey:(NSString *)kMDItemNumberOfPages];
+                if (pageWidth && pageHeight) {
+                    [(NSMutableDictionary *)attributes setObject:pageWidth 
forKey:(NSString *)kMDItemPageWidth];
+                    [(NSMutableDictionary *)attributes setObject:pageHeight 
forKey:(NSString *)kMDItemPageHeight];
+                    [(NSMutableDictionary *)attributes setObject:[NSString 
stringWithFormat:@"%@ x %@ points", pageWidth, pageHeight] 
forKey:@"net_sourceforge_skim_app_dimensions"];
                 }
             }
-            [(NSMutableDictionary *)attributes setObject:textContent 
forKey:(NSString *)kMDItemTextContent];
         }
         
+        [(NSMutableDictionary *)attributes setObject:textContent 
forKey:(NSString *)kMDItemTextContent];
+        [textContent release];
+        
         [(NSMutableDictionary *)attributes setObject:@"Skim" forKey:(NSString 
*)kMDItemCreator];
         
         if (sourcePath && [[NSFileManager defaultManager] 
fileExistsAtPath:sourcePath])

Modified: trunk/SkimImporter/Italian.lproj/schema.strings
===================================================================
(Binary files differ)

Modified: trunk/SkimImporter/schema.xml
===================================================================
--- trunk/SkimImporter/schema.xml       2007-08-29 09:49:32 UTC (rev 2768)
+++ trunk/SkimImporter/schema.xml       2007-08-29 09:51:52 UTC (rev 2769)
@@ -10,6 +10,7 @@
     </note>
     <attributes>
         <attribute name="net_sourceforge_skim_app_notes" multivalued="true" 
type="CFString"/>
+        <attribute name="net_sourceforge_skim_app_dimensions" 
multivalued="false" type="CFString"/>
     </attributes>
 
     <types>
@@ -22,8 +23,6 @@
             </allattrs>
             <displayattrs>
                 kMDItemWhereFroms
-                kMDItemContentModificationDate
-                kMDItemContentCreationDate
                 net_sourceforge_skim_app_notes
             </displayattrs>
         </type>
@@ -33,10 +32,18 @@
             </note>
             <allattrs>
                 net_sourceforge_skim_app_notes
+                net_sourceforge_skim_app_dimensions
             </allattrs>
             <displayattrs>
-                kMDItemContentModificationDate
-                kMDItemContentCreationDate
+                kMDItemTitle
+                kMDItemAuthors
+                kMDItemCreator
+                kMDItemNumberOfPages
+                net_sourceforge_skim_app_dimensions
+                kMDItemVersion
+                kMDItemEncodingApplications
+                kMDItemSecurityMethod
+                kMDItemKeywords
                 net_sourceforge_skim_app_notes
             </displayattrs>
         </type>


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to