Revision: 4095
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4095&view=rev
Author:   hofman
Date:     2008-06-28 14:57:18 -0700 (Sat, 28 Jun 2008)

Log Message:
-----------
Type FDF related constants and functions.

Modified Paths:
--------------
    trunk/SKFDFParser.h
    trunk/SKFDFParser.m

Modified: trunk/SKFDFParser.h
===================================================================
--- trunk/SKFDFParser.h 2008-06-28 20:26:42 UTC (rev 4094)
+++ trunk/SKFDFParser.h 2008-06-28 21:57:18 UTC (rev 4095)
@@ -37,71 +37,74 @@
  */
 
 #import <Cocoa/Cocoa.h>
+#import <Quartz/Quartz.h>
 
-extern const char *SKFDFFDFKey;
-extern const char *SKFDFAnnotationsKey;
-extern const char *SKFDFFileKey;
-extern const char *SKFDFFileIDKey;
-extern const char *SKFDFRootKey;
+typedef const char *SKFDFString;
 
-extern const char *SKFDFTypeKey;
+extern SKFDFString SKFDFFDFKey;
+extern SKFDFString SKFDFAnnotationsKey;
+extern SKFDFString SKFDFFileKey;
+extern SKFDFString SKFDFFileIDKey;
+extern SKFDFString SKFDFRootKey;
 
-extern const char *SKFDFAnnotationFlagsKey;
-extern const char *SKFDFAnnotationTypeKey;
-extern const char *SKFDFAnnotationBoundsKey;
-extern const char *SKFDFAnnotationPageIndexKey;
-extern const char *SKFDFAnnotationContentsKey;
-extern const char *SKFDFAnnotationColorKey;
-extern const char *SKFDFAnnotationInteriorColorKey;
-extern const char *SKFDFAnnotationBorderStylesKey;
-extern const char *SKFDFAnnotationLineWidthKey;
-extern const char *SKFDFAnnotationDashPatternKey;
-extern const char *SKFDFAnnotationBorderStyleKey;
-extern const char *SKFDFAnnotationBorderKey;
-extern const char *SKFDFAnnotationIconTypeKey;
-extern const char *SKFDFAnnotationLineStylesKey;
-extern const char *SKFDFAnnotationLinePointsKey;
-extern const char *SKFDFAnnotationQuadrilateralPointsKey;
-extern const char *SKFDFDefaultAppearanceKey;
-extern const char *SKFDFDefaultStyleKey;
+extern SKFDFString SKFDFTypeKey;
 
-extern const char *SKFDFAnnotation;
+extern SKFDFString SKFDFAnnotationFlagsKey;
+extern SKFDFString SKFDFAnnotationTypeKey;
+extern SKFDFString SKFDFAnnotationBoundsKey;
+extern SKFDFString SKFDFAnnotationPageIndexKey;
+extern SKFDFString SKFDFAnnotationContentsKey;
+extern SKFDFString SKFDFAnnotationColorKey;
+extern SKFDFString SKFDFAnnotationInteriorColorKey;
+extern SKFDFString SKFDFAnnotationBorderStylesKey;
+extern SKFDFString SKFDFAnnotationLineWidthKey;
+extern SKFDFString SKFDFAnnotationDashPatternKey;
+extern SKFDFString SKFDFAnnotationBorderStyleKey;
+extern SKFDFString SKFDFAnnotationBorderKey;
+extern SKFDFString SKFDFAnnotationIconTypeKey;
+extern SKFDFString SKFDFAnnotationLineStylesKey;
+extern SKFDFString SKFDFAnnotationLinePointsKey;
+extern SKFDFString SKFDFAnnotationQuadrilateralPointsKey;
+extern SKFDFString SKFDFDefaultAppearanceKey;
+extern SKFDFString SKFDFDefaultStyleKey;
 
-extern const char *SKFDFBorderStyleSolid;
-extern const char *SKFDFBorderStyleDashed;
-extern const char *SKFDFBorderStyleBeveled;
-extern const char *SKFDFBorderStyleInset;
-extern const char *SKFDFBorderStyleUnderline;
+extern SKFDFString SKFDFAnnotation;
 
-extern const char *SKFDFTextAnnotationIconComment;
-extern const char *SKFDFTextAnnotationIconKey;
-extern const char *SKFDFTextAnnotationIconNote;
-extern const char *SKFDFTextAnnotationIconNewParagraph;
-extern const char *SKFDFTextAnnotationIconParagraph;
-extern const char *SKFDFTextAnnotationIconInsert;
+extern SKFDFString SKFDFBorderStyleSolid;
+extern SKFDFString SKFDFBorderStyleDashed;
+extern SKFDFString SKFDFBorderStyleBeveled;
+extern SKFDFString SKFDFBorderStyleInset;
+extern SKFDFString SKFDFBorderStyleUnderline;
 
-extern const char *SKFDFLineStyleNone;
-extern const char *SKFDFLineStyleSquare;
-extern const char *SKFDFLineStyleCircle;
-extern const char *SKFDFLineStyleDiamond;
-extern const char *SKFDFLineStyleOpenArrow;
-extern const char *SKFDFLineStyleClosedArrow;
+extern SKFDFString SKFDFTextAnnotationIconComment;
+extern SKFDFString SKFDFTextAnnotationIconKey;
+extern SKFDFString SKFDFTextAnnotationIconNote;
+extern SKFDFString SKFDFTextAnnotationIconNewParagraph;
+extern SKFDFString SKFDFTextAnnotationIconParagraph;
+extern SKFDFString SKFDFTextAnnotationIconInsert;
 
-extern int SKPDFBorderStyleFromFDFBorderStyle(const char *name);
-extern const char *SKFDFBorderStyleFromPDFBorderStyle(int borderStyle);
+extern SKFDFString SKFDFLineStyleNone;
+extern SKFDFString SKFDFLineStyleSquare;
+extern SKFDFString SKFDFLineStyleCircle;
+extern SKFDFString SKFDFLineStyleDiamond;
+extern SKFDFString SKFDFLineStyleOpenArrow;
+extern SKFDFString SKFDFLineStyleClosedArrow;
 
-extern int SKPDFTextAnnotationIconTypeFromFDFTextAnnotationIconType(const char 
*name);
-extern const char 
*SKFDFTextAnnotationIconTypeFromPDFTextAnnotationIconType(int iconType);
+extern PDFBorderStyle SKPDFBorderStyleFromFDFBorderStyle(SKFDFString name);
+extern SKFDFString SKFDFBorderStyleFromPDFBorderStyle(PDFBorderStyle 
borderStyle);
 
-extern int SKPDFLineStyleFromFDFLineStyle(const char *name);
-extern const char *SKFDFLineStyleFromPDFLineStyle(int lineStyle);
+extern PDFTextAnnotationIconType 
SKPDFTextAnnotationIconTypeFromFDFTextAnnotationIconType(SKFDFString name);
+extern SKFDFString 
SKFDFTextAnnotationIconTypeFromPDFTextAnnotationIconType(PDFTextAnnotationIconType
 iconType);
 
+extern PDFLineStyle SKPDFLineStyleFromFDFLineStyle(SKFDFString name);
+extern SKFDFString SKFDFLineStyleFromPDFLineStyle(PDFLineStyle lineStyle);
 
+
 @interface SKFDFParser : NSObject
 + (NSArray *)noteDictionariesFromFDFData:(NSData *)data;
 @end
 
 
 @interface NSMutableString (SKFDFExtensions)
-- (void)appendFDFName:(const char *)name;
+- (void)appendFDFName:(SKFDFString)name;
 @end

Modified: trunk/SKFDFParser.m
===================================================================
--- trunk/SKFDFParser.m 2008-06-28 20:26:42 UTC (rev 4094)
+++ trunk/SKFDFParser.m 2008-06-28 21:57:18 UTC (rev 4095)
@@ -37,7 +37,6 @@
  */
 
 #import "SKFDFParser.h"
-#import <Quartz/Quartz.h>
 #import <ApplicationServices/ApplicationServices.h>
 #import "NSScanner_SKExtensions.h"
 #import "NSCharacterSet_SKExtensions.h"
@@ -53,71 +52,75 @@
 #import <SkimNotes/PDFAnnotationText_SKNExtensions.h>
 #import <SkimNotes/SKNPDFAnnotationNote.h>
 
-const char *SKFDFFDFKey = "FDF";
-const char *SKFDFAnnotationsKey = "Annots";
-const char *SKFDFFileKey = "F";
-const char *SKFDFFileIDKey = "ID";
-const char *SKFDFRootKey = "Root";
+SKFDFString SKFDFFDFKey = "FDF";
+SKFDFString SKFDFAnnotationsKey = "Annots";
+SKFDFString SKFDFFileKey = "F";
+SKFDFString SKFDFFileIDKey = "ID";
+SKFDFString SKFDFRootKey = "Root";
 
-const char *SKFDFTypeKey = "Type";
+SKFDFString SKFDFTypeKey = "Type";
 
-const char *SKFDFAnnotationFlagsKey = "F";
-const char *SKFDFAnnotationTypeKey = "Subtype";
-const char *SKFDFAnnotationBoundsKey = "Rect";
-const char *SKFDFAnnotationPageIndexKey = "Page";
-const char *SKFDFAnnotationContentsKey = "Contents";
-const char *SKFDFAnnotationColorKey = "C";
-const char *SKFDFAnnotationInteriorColorKey = "IC";
-const char *SKFDFAnnotationBorderStylesKey = "BS";
-const char *SKFDFAnnotationLineWidthKey = "W";
-const char *SKFDFAnnotationDashPatternKey = "D";
-const char *SKFDFAnnotationBorderStyleKey = "S";
-const char *SKFDFAnnotationBorderKey = "Border";
-const char *SKFDFAnnotationIconTypeKey = "Name";
-const char *SKFDFAnnotationLineStylesKey = "LE";
-const char *SKFDFAnnotationLinePointsKey = "L";
-const char *SKFDFAnnotationQuadrilateralPointsKey = "QuadPoints";
-const char *SKFDFDefaultAppearanceKey = "DA";
-const char *SKFDFDefaultStyleKey = "DS";
+SKFDFString SKFDFAnnotationFlagsKey = "F";
+SKFDFString SKFDFAnnotationTypeKey = "Subtype";
+SKFDFString SKFDFAnnotationBoundsKey = "Rect";
+SKFDFString SKFDFAnnotationPageIndexKey = "Page";
+SKFDFString SKFDFAnnotationContentsKey = "Contents";
+SKFDFString SKFDFAnnotationColorKey = "C";
+SKFDFString SKFDFAnnotationInteriorColorKey = "IC";
+SKFDFString SKFDFAnnotationBorderStylesKey = "BS";
+SKFDFString SKFDFAnnotationLineWidthKey = "W";
+SKFDFString SKFDFAnnotationDashPatternKey = "D";
+SKFDFString SKFDFAnnotationBorderStyleKey = "S";
+SKFDFString SKFDFAnnotationBorderKey = "Border";
+SKFDFString SKFDFAnnotationIconTypeKey = "Name";
+SKFDFString SKFDFAnnotationLineStylesKey = "LE";
+SKFDFString SKFDFAnnotationLinePointsKey = "L";
+SKFDFString SKFDFAnnotationQuadrilateralPointsKey = "QuadPoints";
+SKFDFString SKFDFDefaultAppearanceKey = "DA";
+SKFDFString SKFDFDefaultStyleKey = "DS";
 
-const char *SKFDFAnnotation = "Annot";
+SKFDFString SKFDFAnnotation = "Annot";
 
-const char *SKFDFBorderStyleSolid = "S";
-const char *SKFDFBorderStyleDashed = "D";
-const char *SKFDFBorderStyleBeveled = "B";
-const char *SKFDFBorderStyleInset = "I";
-const char *SKFDFBorderStyleUnderline = "U";
+SKFDFString SKFDFBorderStyleSolid = "S";
+SKFDFString SKFDFBorderStyleDashed = "D";
+SKFDFString SKFDFBorderStyleBeveled = "B";
+SKFDFString SKFDFBorderStyleInset = "I";
+SKFDFString SKFDFBorderStyleUnderline = "U";
 
-const char *SKFDFTextAnnotationIconComment = "Comment";
-const char *SKFDFTextAnnotationIconKey = "Key";
-const char *SKFDFTextAnnotationIconNote = "Note";
-const char *SKFDFTextAnnotationIconNewParagraph = "NewParagraph";
-const char *SKFDFTextAnnotationIconParagraph = "Paragraph";
-const char *SKFDFTextAnnotationIconInsert = "Insert";
+SKFDFString SKFDFTextAnnotationIconComment = "Comment";
+SKFDFString SKFDFTextAnnotationIconKey = "Key";
+SKFDFString SKFDFTextAnnotationIconNote = "Note";
+SKFDFString SKFDFTextAnnotationIconNewParagraph = "NewParagraph";
+SKFDFString SKFDFTextAnnotationIconParagraph = "Paragraph";
+SKFDFString SKFDFTextAnnotationIconInsert = "Insert";
 
-const char *SKFDFLineStyleNone = "None";
-const char *SKFDFLineStyleSquare = "Square";
-const char *SKFDFLineStyleCircle = "Circle";
-const char *SKFDFLineStyleDiamond = "Diamond";
-const char *SKFDFLineStyleOpenArrow = "OpenArrow";
-const char *SKFDFLineStyleClosedArrow = "ClosedArrow";
+SKFDFString SKFDFLineStyleNone = "None";
+SKFDFString SKFDFLineStyleSquare = "Square";
+SKFDFString SKFDFLineStyleCircle = "Circle";
+SKFDFString SKFDFLineStyleDiamond = "Diamond";
+SKFDFString SKFDFLineStyleOpenArrow = "OpenArrow";
+SKFDFString SKFDFLineStyleClosedArrow = "ClosedArrow";
 
-int SKPDFBorderStyleFromFDFBorderStyle(const char *name) {
-    if (strcmp(name, SKFDFBorderStyleSolid) == 0)
+static BOOL SKFDFEqualStrings(SKFDFString string1, SKFDFString string2) {
+    return strcmp(string1, string2) == 0;
+}
+
+PDFBorderStyle SKPDFBorderStyleFromFDFBorderStyle(SKFDFString name) {
+    if (SKFDFEqualStrings(name, SKFDFBorderStyleSolid))
         return kPDFBorderStyleSolid;
-    else if (strcmp(name, SKFDFBorderStyleDashed) == 0)
+    else if (SKFDFEqualStrings(name, SKFDFBorderStyleDashed))
         return kPDFBorderStyleDashed;
-    else if (strcmp(name, SKFDFBorderStyleBeveled) == 0)
+    else if (SKFDFEqualStrings(name, SKFDFBorderStyleBeveled))
         return kPDFBorderStyleBeveled;
-    else if (strcmp(name, SKFDFBorderStyleInset) == 0)
+    else if (SKFDFEqualStrings(name, SKFDFBorderStyleInset))
         return kPDFBorderStyleInset;
-    else if (strcmp(name, SKFDFBorderStyleUnderline) == 0)
+    else if (SKFDFEqualStrings(name, SKFDFBorderStyleUnderline))
         return kPDFBorderStyleUnderline;
     else
         return kPDFBorderStyleSolid;
 }
 
-const char *SKFDFBorderStyleFromPDFBorderStyle(int borderStyle) {
+SKFDFString SKFDFBorderStyleFromPDFBorderStyle(PDFBorderStyle borderStyle) {
     switch (borderStyle) {
         case kPDFBorderStyleSolid: return SKFDFBorderStyleSolid;
         case kPDFBorderStyleDashed: return SKFDFBorderStyleDashed;
@@ -128,24 +131,24 @@
     }
 }
 
-int SKPDFTextAnnotationIconTypeFromFDFTextAnnotationIconType(const char *name) 
{
-    if (strcmp(name, SKFDFTextAnnotationIconComment) == 0)
+PDFTextAnnotationIconType 
SKPDFTextAnnotationIconTypeFromFDFTextAnnotationIconType(SKFDFString name) {
+    if (SKFDFEqualStrings(name, SKFDFTextAnnotationIconComment))
         return kPDFTextAnnotationIconComment;
-    else if (strcmp(name, SKFDFTextAnnotationIconKey) == 0)
+    else if (SKFDFEqualStrings(name, SKFDFTextAnnotationIconKey))
         return kPDFTextAnnotationIconKey;
-    else if (strcmp(name, SKFDFTextAnnotationIconNote) == 0)
+    else if (SKFDFEqualStrings(name, SKFDFTextAnnotationIconNote))
         return kPDFTextAnnotationIconNote;
-    else if (strcmp(name, SKFDFTextAnnotationIconNewParagraph) == 0)
+    else if (SKFDFEqualStrings(name, SKFDFTextAnnotationIconNewParagraph))
         return kPDFTextAnnotationIconNewParagraph;
-    else if (strcmp(name, SKFDFTextAnnotationIconParagraph) == 0)
+    else if (SKFDFEqualStrings(name, SKFDFTextAnnotationIconParagraph))
         return kPDFTextAnnotationIconParagraph;
-    else if (strcmp(name, SKFDFTextAnnotationIconInsert) == 0)
+    else if (SKFDFEqualStrings(name, SKFDFTextAnnotationIconInsert))
         return kPDFTextAnnotationIconInsert;
     else
         return kPDFTextAnnotationIconNote;
 }
 
-const char *SKFDFTextAnnotationIconTypeFromPDFTextAnnotationIconType(int 
iconType) {
+SKFDFString 
SKFDFTextAnnotationIconTypeFromPDFTextAnnotationIconType(PDFTextAnnotationIconType
 iconType) {
     switch (iconType) {
         case kPDFTextAnnotationIconComment: return 
SKFDFTextAnnotationIconComment;
         case kPDFTextAnnotationIconKey: return SKFDFTextAnnotationIconKey;
@@ -157,24 +160,24 @@
     }
 }
 
-int SKPDFLineStyleFromFDFLineStyle(const char *name) {
-    if (strcmp(name, SKFDFLineStyleNone) == 0)
+PDFLineStyle SKPDFLineStyleFromFDFLineStyle(SKFDFString name) {
+    if (SKFDFEqualStrings(name, SKFDFLineStyleNone))
         return kPDFLineStyleNone;
-    else if (strcmp(name, SKFDFLineStyleSquare) == 0)
+    else if (SKFDFEqualStrings(name, SKFDFLineStyleSquare))
         return kPDFLineStyleSquare;
-    else if (strcmp(name, SKFDFLineStyleCircle) == 0)
+    else if (SKFDFEqualStrings(name, SKFDFLineStyleCircle))
         return kPDFLineStyleCircle;
-    else if (strcmp(name, SKFDFLineStyleDiamond) == 0)
+    else if (SKFDFEqualStrings(name, SKFDFLineStyleDiamond))
         return kPDFLineStyleDiamond;
-    else if (strcmp(name, SKFDFLineStyleOpenArrow) == 0)
+    else if (SKFDFEqualStrings(name, SKFDFLineStyleOpenArrow))
         return kPDFLineStyleOpenArrow;
-    else if (strcmp(name, SKFDFLineStyleClosedArrow) == 0)
+    else if (SKFDFEqualStrings(name, SKFDFLineStyleClosedArrow))
         return kPDFLineStyleClosedArrow;
     else
         return kPDFLineStyleNone;
 }
 
-const char *SKFDFLineStyleFromPDFLineStyle(int lineStyle) {
+SKFDFString SKFDFLineStyleFromPDFLineStyle(PDFLineStyle lineStyle) {
     switch (lineStyle) {
         case kPDFLineStyleNone: return SKFDFLineStyleNone;
         case kPDFLineStyleSquare: return SKFDFLineStyleSquare;
@@ -197,13 +200,13 @@
     CGPDFDictionaryRef dict;
     CGPDFArrayRef array;
     CGPDFStringRef string;
-    const char *name;
+    SKFDFString name;
     CGPDFReal real;
     CGPDFInteger integer;
     BOOL success = YES;
     NSRect bounds = NSZeroRect;
     
-    if (CGPDFDictionaryGetName(annot, SKFDFTypeKey, &name) == NO || 
strcmp(name, SKFDFAnnotation) != 0) {
+    if (CGPDFDictionaryGetName(annot, SKFDFTypeKey, &name) == NO || 
SKFDFEqualStrings(name, SKFDFAnnotation) == NO) {
         success = NO;
     }
     
@@ -436,7 +439,7 @@
 
 
 @implementation NSMutableString (SKFDFExtensions)
-- (void)appendFDFName:(const char *)name {
+- (void)appendFDFName:(SKFDFString)name {
     [self appendFormat:@"/%s", name];
 }
 @end


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

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to