Revision: 5166
          http://skim-app.svn.sourceforge.net/skim-app/?rev=5166&view=rev
Author:   hofman
Date:     2009-01-27 15:52:29 +0000 (Tue, 27 Jan 2009)

Log Message:
-----------
Add the openmeta tags and rating in the info dictionary. make this accessible 
in AppleScript. This will also save it in PDF bundles. Read openmeta tag from 
any opened file type.

Modified Paths:
--------------
    trunk/SKInfoWindowController.m
    trunk/SKPDFDocument.m

Modified: trunk/SKInfoWindowController.m
===================================================================
--- trunk/SKInfoWindowController.m      2009-01-27 12:48:17 UTC (rev 5165)
+++ trunk/SKInfoWindowController.m      2009-01-27 15:52:29 UTC (rev 5166)
@@ -56,6 +56,8 @@
 static NSString *SKInfoFileSizeKey = @"FileSize";
 static NSString *SKInfoPhysicalSizeKey = @"PhysicalSize";
 static NSString *SKInfoLogicalSizeKey = @"LogicalSize";
+static NSString *SKInfoTagsKey = @"Tags";
+static NSString *SKInfoRatingKey = @"Rating";
 
 @implementation SKInfoWindowController
 
@@ -230,6 +232,10 @@
     [dictionary setValue:SKFileSizeStringForFileURL([doc fileURL], 
&physicalSize, &logicalSize) forKey:SKInfoFileSizeKey];
     [dictionary setValue:[NSNumber numberWithUnsignedLongLong:physicalSize] 
forKey:SKInfoPhysicalSizeKey];
     [dictionary setValue:[NSNumber numberWithUnsignedLongLong:logicalSize] 
forKey:SKInfoLogicalSizeKey];
+    if ([doc respondsToSelector:@selector(tags)] && [[(SKPDFDocument *)doc 
tags] count] > 0)
+        [dictionary setValue:[(SKPDFDocument *)doc tags] forKey:SKInfoTagsKey];
+    if ([doc respondsToSelector:@selector(rating)] && [(SKPDFDocument *)doc 
rating] > 0.0)
+        [dictionary setValue:[NSNumber numberWithDouble:[(SKPDFDocument *)doc 
rating]] forKey:SKInfoRatingKey];
     
     return dictionary;
 }

Modified: trunk/SKPDFDocument.m
===================================================================
--- trunk/SKPDFDocument.m       2009-01-27 12:48:17 UTC (rev 5165)
+++ trunk/SKPDFDocument.m       2009-01-27 15:52:29 UTC (rev 5166)
@@ -728,14 +728,6 @@
                     }
                 }
             }
-            if (pdfDoc) {
-                array = [[SKNExtendedAttributeManager sharedNoSplitManager] 
propertyListFromExtendedAttributeNamed:OPEN_META_TAGS_KEY atPath:[absoluteURL 
path] traverseLink:YES error:NULL];
-                if ([array count])
-                    [self setOpenMetaTags:array];
-                NSNumber *number = [[SKNExtendedAttributeManager 
sharedNoSplitManager] 
propertyListFromExtendedAttributeNamed:OPEN_META_RATING_KEY atPath:[absoluteURL 
path] traverseLink:YES error:NULL];
-                if (number && [number doubleValue] > 0.0)
-                    [self setOpenMetaRating:[number doubleValue]];
-            }
         }
     } else if (SKIsPDFBundleDocumentType(docType)) {
         NSString *path = [absoluteURL path];
@@ -783,6 +775,30 @@
             fileChangedOnDisk = NO;
             [lastModifiedDate release];
             lastModifiedDate = [[[[NSFileManager defaultManager] 
fileAttributesAtPath:[absoluteURL path] traverseLink:YES] fileModificationDate] 
retain];
+            
+            NSArray *array = nil;
+            NSNumber *number = nil;
+            if (SKIsPDFBundleDocumentType(docType)) {
+                NSString *infoPath = [[[absoluteURL path] 
stringByAppendingPathComponent:BUNDLE_DATA_FILENAME] 
stringByAppendingPathExtension:@"plist"];
+                NSData *infoData = [NSData dataWithContentsOfFile:infoPath 
options:0 error:NULL];
+                if (infoData) {
+                    NSString *errorString = nil;
+                    NSDictionary *info = [NSPropertyListSerialization 
propertyListFromData:infoData mutabilityOption:NSPropertyListImmutable 
format:NULL errorDescription:&errorString];
+                    if (info == nil) {
+                        [errorString release];
+                    } else if ([info isKindOfClass:[NSDictionary class]]) {
+                        array =[info objectForKey:@"Tags"];
+                        number = [info objectForKey:@"Rating"];
+                    }
+                }
+            } else {
+                array = [[SKNExtendedAttributeManager sharedNoSplitManager] 
propertyListFromExtendedAttributeNamed:OPEN_META_TAGS_KEY atPath:[absoluteURL 
path] traverseLink:YES error:NULL];
+                number = [[SKNExtendedAttributeManager sharedNoSplitManager] 
propertyListFromExtendedAttributeNamed:OPEN_META_RATING_KEY atPath:[absoluteURL 
path] traverseLink:YES error:NULL];
+            }
+            if ([array isKindOfClass:[NSArray class]] && [array count])
+                [self setOpenMetaTags:array];
+            if ([number respondsToSelector:@selector(doubleValue)] && [number 
doubleValue] > 0.0)
+                [self setOpenMetaRating:[number doubleValue]];
         } else {
             [self setPDFData:nil];
         }


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:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to