Revision: 4622
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4622&view=rev
Author:   hofman
Date:     2008-09-14 12:33:11 +0000 (Sun, 14 Sep 2008)

Log Message:
-----------
Add support for Ink annotation as Skim notes. Save points for the paths as an 
array of a string array.

Modified Paths:
--------------
    trunk/SkimNotes/PDFAnnotation_SKNExtensions.h
    trunk/SkimNotes/PDFAnnotation_SKNExtensions.m

Modified: trunk/SkimNotes/PDFAnnotation_SKNExtensions.h
===================================================================
--- trunk/SkimNotes/PDFAnnotation_SKNExtensions.h       2008-09-14 12:07:50 UTC 
(rev 4621)
+++ trunk/SkimNotes/PDFAnnotation_SKNExtensions.h       2008-09-14 12:33:11 UTC 
(rev 4622)
@@ -84,6 +84,10 @@
     @discussion  Global string for Line note type.
 */
 extern NSString *SKNLineString;
+/*!
+    @discussion  Global string for Ink note type.
+*/
+extern NSString *SKNInkString;
 
 /*!
     @discussion  Global string for annotation type key.
@@ -183,6 +187,10 @@
 */
 extern NSString *SKNPDFAnnotationIconTypeKey;
 
+/*!
+    @discussion  Global string for annotation point lists key.
+*/
+extern NSString *SKNPDFAnnotationPointListsKey;
 
 /*!
     @abstract    Provides methods to translate between dictionary 
representations of Skim notes and <code>PDFAnnotation</code> objects.
@@ -310,3 +318,12 @@
 */
 @interface PDFAnnotationText (SKNExtensions)
 @end
+
+#pragma mark -
+
+/*!
+    @abstract    Provides methods to translate between dictionary 
representations of Skim notes and <code>PDFAnnotation</code> objects.
+    @discussion  Implements <code>initSkimNotesWithProperties:</code> and 
properties to take care of the extra properties of a text annotation.
+*/
[EMAIL PROTECTED] PDFAnnotationInk (SKNExtensions)
[EMAIL PROTECTED]

Modified: trunk/SkimNotes/PDFAnnotation_SKNExtensions.m
===================================================================
--- trunk/SkimNotes/PDFAnnotation_SKNExtensions.m       2008-09-14 12:07:50 UTC 
(rev 4621)
+++ trunk/SkimNotes/PDFAnnotation_SKNExtensions.m       2008-09-14 12:33:11 UTC 
(rev 4622)
@@ -52,6 +52,7 @@
 NSString *SKNUnderlineString = @"Underline";
 NSString *SKNStrikeOutString = @"StrikeOut";
 NSString *SKNLineString = @"Line";
+NSString *SKNInkString = @"Ink";
 
 NSString *SKNPDFAnnotationTypeKey = @"type";
 NSString *SKNPDFAnnotationBoundsKey = @"bounds";
@@ -82,6 +83,8 @@
 
 NSString *SKNPDFAnnotationIconTypeKey = @"iconType";
 
+NSString *SKNPDFAnnotationPointListsKey = @"pointLists";
+
 @implementation PDFAnnotation (SKNExtensions)
 
 static id SkimNotes = nil;
@@ -156,6 +159,8 @@
             annotationClass = [PDFAnnotationMarkup class];
         else if ([type isEqualToString:SKNLineString])
             annotationClass = [PDFAnnotationLine class];
+        else if ([type isEqualToString:SKNInkString])
+            annotationClass = [PDFAnnotationInk class];
         
         [[self initWithBounds:NSZeroRect] release];
         self = [[annotationClass allocWithZone:zone] 
initSkimNoteWithProperties:dict];
@@ -430,3 +435,60 @@
 }
 
 @end
+
+#pragma mark -
+
[EMAIL PROTECTED] PDFAnnotationInk (SKNExtensions)
+
+- (id)initSkimNoteWithProperties:(NSDictionary *)dict{
+    if (self = [super initSkimNoteWithProperties:dict]) {
+        Class arrayClass = [NSArray class];
+        NSArray *pointLists = [dict 
objectForKey:SKNPDFAnnotationPointListsKey];
+        if ([pointLists isKindOfClass:arrayClass]) {
+            NSUInteger i, iMax = [pointLists count];
+            for (i = 0; i < iMax; i++) {
+                NSArray *pointStrings = [pointLists objectAtIndex:i];
+                if ([pointStrings isKindOfClass:arrayClass]) {
+                    NSUInteger j, jMax = [pointStrings count];
+                    NSBezierPath *path = [NSBezierPath bezierPath];
+                    for (j = 0; j < jMax; j++) {
+                        NSPoint p = NSPointFromString([pointStrings 
objectAtIndex:j]);
+                        if (j == 0)
+                            [path moveToPoint:p];
+                        else
+                            [path lineToPoint:p];
+                    }
+                    [self addBezierPath:path];
+                }
+            }
+        }
+    }
+    return self;
+}
+
+- (NSDictionary *)SkimNoteProperties{
+    NSMutableDictionary *dict = [[[super SkimNoteProperties] mutableCopy] 
autorelease];
+    NSArray *paths = [self paths];
+    if (paths) {
+        NSUInteger i, iMax = [paths count];
+        NSMutableArray *pointLists = [[NSMutableArray alloc] 
initWithCapacity:iMax];
+        for (i = 0; i < iMax; i++) {
+            NSBezierPath *path = [paths objectAtIndex:i];
+            NSUInteger j, jMax = [path elementCount];
+            NSMutableArray *pointStrings = [[NSMutableArray alloc] 
initWithCapacity:jMax];
+            for (j = 0; j < jMax; j++) {
+                NSPoint points[3];
+                NSBezierPathElement element = [path elementAtIndex:j 
associatedPoints:points];
+                NSPoint point = element == NSCurveToBezierPathElement ? 
points[2] : points[0];
+                [pointStrings addObject:NSStringFromPoint(point)];
+            }
+            [pointLists addObject:pointStrings];
+            [pointStrings release];
+        }
+        [dict setValue:pointLists forKey:SKNPDFAnnotationPointListsKey];
+        [pointLists release];
+    }
+    return dict;
+}
+
[EMAIL PROTECTED]


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 the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to