Revision: 2892
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2892&view=rev
Author:   hofman
Date:     2007-09-11 04:43:44 -0700 (Tue, 11 Sep 2007)

Log Message:
-----------
View FDF files using SKNotesDocument

Modified Paths:
--------------
    trunk/Info.plist
    trunk/SKNotesDocument.m

Modified: trunk/Info.plist
===================================================================
--- trunk/Info.plist    2007-09-11 11:36:24 UTC (rev 2891)
+++ trunk/Info.plist    2007-09-11 11:43:44 UTC (rev 2892)
@@ -357,11 +357,11 @@
                                <string>FDF </string>
                        </array>
                        <key>CFBundleTypeRole</key>
-                       <string>None</string>
+                       <string>Viewer</string>
                        <key>LSTypeIsPackage</key>
                        <false/>
                        <key>NSDocumentClass</key>
-                       <string>SKDocument</string>
+                       <string>SKNotesDocument</string>
                        <key>NSPersistentStoreTypeKey</key>
                        <string>Binary</string>
                </dict>

Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m     2007-09-11 11:36:24 UTC (rev 2891)
+++ trunk/SKNotesDocument.m     2007-09-11 11:43:44 UTC (rev 2892)
@@ -48,6 +48,7 @@
 #import "SKTypeSelectHelper.h"
 #import "SKPDFAnnotationNote.h"
 #import "SKStringConstants.h"
+#import "SKFDFParser.h"
 
 @implementation SKNotesDocument
 
@@ -110,29 +111,31 @@
 
 - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError 
**)outError {
     BOOL didRead = NO;
+    NSArray *array = nil;
     
     if ([typeName isEqualToString:SKNotesDocumentType]) {
-        NSArray *array = [NSKeyedUnarchiver unarchiveObjectWithData:data];
+        array = [NSKeyedUnarchiver unarchiveObjectWithData:data];
+    } else if ([typeName isEqualToString:SKNotesFDFDocumentType]) {
+        array = [SKFDFParser noteDictionariesFromFDFData:data];
+    }
+    if (array) {
+        NSEnumerator *dictEnum = [array objectEnumerator];
+        NSDictionary *dict;
+        NSMutableArray *newNotes = [NSMutableArray arrayWithCapacity:[array 
count]];
         
-        if (array) {
-            NSEnumerator *dictEnum = [array objectEnumerator];
-            NSDictionary *dict;
-            NSMutableArray *newNotes = [NSMutableArray 
arrayWithCapacity:[array count]];
+        while (dict = [dictEnum nextObject]) {
+            NSMutableDictionary *note = [dict mutableCopy];
             
-            while (dict = [dictEnum nextObject]) {
-                NSMutableDictionary *note = [dict mutableCopy];
-                
-                if ([[dict valueForKey:@"type"] isEqualToString:@"Note"])
-                    [note setObject:[NSMutableDictionary 
dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:85.0], @"rowHeight", 
[dict valueForKey:@"text"], @"contents", nil] forKey:@"child"];
-                [note setObject:[NSNumber numberWithFloat:19.0] 
forKey:@"rowHeight"];
-                
-                [newNotes addObject:note];
-                [note release];
-            }
-            [[self mutableArrayValueForKey:@"notes"] setArray:newNotes];
-            [outlineView reloadData];
-            didRead = YES;
+            if ([[dict valueForKey:@"type"] isEqualToString:@"Note"])
+                [note setObject:[NSMutableDictionary 
dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:85.0], @"rowHeight", 
[dict valueForKey:@"text"], @"contents", nil] forKey:@"child"];
+            [note setObject:[NSNumber numberWithFloat:19.0] 
forKey:@"rowHeight"];
+            
+            [newNotes addObject:note];
+            [note release];
         }
+        [[self mutableArrayValueForKey:@"notes"] setArray:newNotes];
+        [outlineView reloadData];
+        didRead = YES;
     }
     
     if (didRead == NO && outError != NULL)


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: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to