Revision: 3688
http://skim-app.svn.sourceforge.net/skim-app/?rev=3688&view=rev
Author: hofman
Date: 2008-04-09 09:27:51 -0700 (Wed, 09 Apr 2008)
Log Message:
-----------
Rename c-string constant. Avoid declaring a private method.
Modified Paths:
--------------
trunk/SKDocument.m
trunk/SKFDFParser.h
trunk/SKFDFParser.m
Modified: trunk/SKDocument.m
===================================================================
--- trunk/SKDocument.m 2008-04-09 15:36:59 UTC (rev 3687)
+++ trunk/SKDocument.m 2008-04-09 16:27:51 UTC (rev 3688)
@@ -1503,7 +1503,7 @@
[annots appendFormat:@"%i 0 R ", i + 1];
}
[string appendFormat:@"%i 0 obj<<", i + 1];
- [string appendFDFName:SKFDFCatalogKey];
+ [string appendFDFName:SKFDFFDFKey];
[string appendString:@"<<"];
[string appendFDFName:SKFDFAnnotationsKey];
[string appendFormat:@"[EMAIL PROTECTED]", annots];
Modified: trunk/SKFDFParser.h
===================================================================
--- trunk/SKFDFParser.h 2008-04-09 15:36:59 UTC (rev 3687)
+++ trunk/SKFDFParser.h 2008-04-09 16:27:51 UTC (rev 3688)
@@ -38,7 +38,7 @@
#import <Cocoa/Cocoa.h>
-extern const char *SKFDFCatalogKey;
+extern const char *SKFDFFDFKey;
extern const char *SKFDFAnnotationsKey;
extern const char *SKFDFFileKey;
extern const char *SKFDFFileIDKey;
Modified: trunk/SKFDFParser.m
===================================================================
--- trunk/SKFDFParser.m 2008-04-09 15:36:59 UTC (rev 3687)
+++ trunk/SKFDFParser.m 2008-04-09 16:27:51 UTC (rev 3688)
@@ -51,7 +51,7 @@
#import "SKPDFAnnotationFreeText.h"
#import "SKPDFAnnotationNote.h"
-const char *SKFDFCatalogKey = "FDF";
+const char *SKFDFFDFKey = "FDF";
const char *SKFDFAnnotationsKey = "Annots";
const char *SKFDFFileKey = "F";
const char *SKFDFFileIDKey = "ID";
@@ -185,58 +185,8 @@
}
[EMAIL PROTECTED] SKFDFParser (SKPrivate)
-+ (NSDictionary *)noteDictionaryFromPDFDictionary:(CGPDFDictionaryRef)annot;
[EMAIL PROTECTED]
-
-
@implementation SKFDFParser
-+ (NSArray *)noteDictionariesFromFDFData:(NSData *)data {
- const char *pdfHeader = "%PDF";
- unsigned pdfHeaderLength = strlen(pdfHeader);
-
- if ([data length] < pdfHeaderLength)
- return NO;
-
- NSMutableData *pdfData = [data mutableCopy];
-
- [pdfData replaceBytesInRange:NSMakeRange(0, pdfHeaderLength)
withBytes:pdfHeader length:pdfHeaderLength];
-
- CGDataProviderRef provider =
CGDataProviderCreateWithCFData((CFDataRef)pdfData);
- CGPDFDocumentRef document = CGPDFDocumentCreateWithProvider(provider);
- NSMutableArray *notes = nil;
-
- if (document) {
- CGPDFDictionaryRef catalog = CGPDFDocumentGetCatalog(document);
- CGPDFDictionaryRef fdfDict;
- CGPDFArrayRef annots;
-
- if (catalog &&
- CGPDFDictionaryGetDictionary(catalog, SKFDFCatalogKey, &fdfDict) &&
- CGPDFDictionaryGetArray(fdfDict, SKFDFAnnotationsKey, &annots)) {
-
- size_t i, count = CGPDFArrayGetCount(annots);
- notes = [NSMutableArray arrayWithCapacity:count];
- for (i = 0; i < count; i++) {
- CGPDFDictionaryRef annot;
- NSDictionary *note;
- if (CGPDFArrayGetDictionary(annots, i, &annot) &&
- (note = [self noteDictionaryFromPDFDictionary:annot])) {
- [notes addObject:note];
- }
- }
- }
-
- CGPDFDocumentRelease(document);
- }
-
- CGDataProviderRelease(provider);
- [pdfData release];
-
- return notes;
-}
-
+ (NSDictionary *)noteDictionaryFromPDFDictionary:(CGPDFDictionaryRef)annot {
if (annot == NULL)
return nil;
@@ -284,20 +234,6 @@
[contents release];
}
- if (CGPDFDictionaryGetArray(annot, SKFDFAnnotationColorKey, &array)) {
- CGPDFReal r, g, b;
- if (CGPDFArrayGetCount(array) == 3 && CGPDFArrayGetNumber(array, 0,
&r) && CGPDFArrayGetNumber(array, 1, &g) && CGPDFArrayGetNumber(array, 2, &b)) {
- [dictionary setObject:[NSColor colorWithCalibratedRed:r green:g
blue:b alpha:1.0] forKey:SKPDFAnnotationColorKey];
- }
- }
-
- if (CGPDFDictionaryGetArray(annot, SKFDFAnnotationInteriorColorKey,
&array)) {
- CGPDFReal r, g, b;
- if (CGPDFArrayGetCount(array) == 3 && CGPDFArrayGetNumber(array, 0,
&r) && CGPDFArrayGetNumber(array, 1, &g) && CGPDFArrayGetNumber(array, 2, &b)) {
- [dictionary setObject:[NSColor colorWithCalibratedRed:r green:g
blue:b alpha:1.0] forKey:SKPDFAnnotationInteriorColorKey];
- }
- }
-
if (CGPDFDictionaryGetDictionary(annot, SKFDFAnnotationBorderStylesKey,
&dict)) {
if (CGPDFDictionaryGetNumber(dict, SKFDFAnnotationLineWidthKey,
&real)) {
if (real > 0.0) {
@@ -339,6 +275,20 @@
[dictionary setObject:[NSNumber numberWithInt:kPDFBorderStyleSolid]
forKey:SKPDFAnnotationBorderStyleKey];
}
+ if (CGPDFDictionaryGetArray(annot, SKFDFAnnotationColorKey, &array)) {
+ CGPDFReal r, g, b;
+ if (CGPDFArrayGetCount(array) == 3 && CGPDFArrayGetNumber(array, 0,
&r) && CGPDFArrayGetNumber(array, 1, &g) && CGPDFArrayGetNumber(array, 2, &b)) {
+ [dictionary setObject:[NSColor colorWithCalibratedRed:r green:g
blue:b alpha:1.0] forKey:SKPDFAnnotationColorKey];
+ }
+ }
+
+ if (CGPDFDictionaryGetArray(annot, SKFDFAnnotationInteriorColorKey,
&array)) {
+ CGPDFReal r, g, b;
+ if (CGPDFArrayGetCount(array) == 3 && CGPDFArrayGetNumber(array, 0,
&r) && CGPDFArrayGetNumber(array, 1, &g) && CGPDFArrayGetNumber(array, 2, &b)) {
+ [dictionary setObject:[NSColor colorWithCalibratedRed:r green:g
blue:b alpha:1.0] forKey:SKPDFAnnotationInteriorColorKey];
+ }
+ }
+
if (CGPDFDictionaryGetName(annot, SKFDFAnnotationIconTypeKey, &name)) {
[dictionary setObject:[NSNumber
numberWithInt:SKPDFTextAnnotationIconTypeFromFDFTextAnnotationIconType(name)]
forKey:SKPDFAnnotationIconTypeKey];
}
@@ -431,6 +381,51 @@
return success ? dictionary : nil;
}
++ (NSArray *)noteDictionariesFromFDFData:(NSData *)data {
+ const char *pdfHeader = "%PDF";
+ unsigned pdfHeaderLength = strlen(pdfHeader);
+ NSMutableArray *notes = nil;
+
+ if ([data length] > pdfHeaderLength) {
+
+ NSMutableData *pdfData = [data mutableCopy];
+
+ [pdfData replaceBytesInRange:NSMakeRange(0, pdfHeaderLength)
withBytes:pdfHeader length:pdfHeaderLength];
+
+ CGDataProviderRef provider =
CGDataProviderCreateWithCFData((CFDataRef)pdfData);
+ CGPDFDocumentRef document = CGPDFDocumentCreateWithProvider(provider);
+
+ if (document) {
+ CGPDFDictionaryRef catalog = CGPDFDocumentGetCatalog(document);
+ CGPDFDictionaryRef fdfDict;
+ CGPDFArrayRef annots;
+
+ if (catalog &&
+ CGPDFDictionaryGetDictionary(catalog, SKFDFFDFKey, &fdfDict) &&
+ CGPDFDictionaryGetArray(fdfDict, SKFDFAnnotationsKey,
&annots)) {
+
+ size_t i, count = CGPDFArrayGetCount(annots);
+ notes = [NSMutableArray arrayWithCapacity:count];
+ for (i = 0; i < count; i++) {
+ CGPDFDictionaryRef annot;
+ NSDictionary *note;
+ if (CGPDFArrayGetDictionary(annots, i, &annot) &&
+ (note = [self noteDictionaryFromPDFDictionary:annot]))
{
+ [notes addObject:note];
+ }
+ }
+ }
+
+ CGPDFDocumentRelease(document);
+ }
+
+ CGDataProviderRelease(provider);
+ [pdfData release];
+ }
+
+ return notes;
+}
+
@end
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 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit