Revision: 3808
http://skim-app.svn.sourceforge.net/skim-app/?rev=3808&view=rev
Author: hofman
Date: 2008-04-24 04:30:09 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
Check for valid types in FDF earlier, so we don't do unnecessary work.
Modified Paths:
--------------
trunk/SKFDFParser.m
Modified: trunk/SKFDFParser.m
===================================================================
--- trunk/SKFDFParser.m 2008-04-24 11:27:13 UTC (rev 3807)
+++ trunk/SKFDFParser.m 2008-04-24 11:30:09 UTC (rev 3808)
@@ -211,6 +211,35 @@
success = NO;
}
+ if (success && CGPDFDictionaryGetString(annot, SKFDFAnnotationContentsKey,
&string)) {
+ NSString *contents = (NSString *)CGPDFStringCopyTextString(string);
+ if (contents)
+ [dictionary setObject:contents forKey:SKPDFAnnotationContentsKey];
+ [contents release];
+ }
+
+ if (success) {
+ NSSet *validTypes = [NSSet setWithObjects:SKFreeTextString,
SKNoteString, SKCircleString, SKSquareString, SKHighlightString,
SKUnderlineString, SKStrikeOutString, SKLineString, nil];
+ NSString *type = [dictionary objectForKey:SKPDFAnnotationTypeKey];
+ NSString *contents;
+ if ([type isEqualToString:SKTextString]) {
+ [dictionary setObject:SKNoteString forKey:SKPDFAnnotationTypeKey];
+ if (contents = [dictionary
objectForKey:SKPDFAnnotationContentsKey]) {
+ NSRange r = [contents rangeOfString:@" "];
+ if (NSMaxRange(r) < [contents length]) {
+ NSFont *font = [NSFont fontWithName:[[NSUserDefaults
standardUserDefaults] stringForKey:SKAnchoredNoteFontNameKey]
+ size:[[NSUserDefaults
standardUserDefaults] floatForKey:SKAnchoredNoteFontSizeKey]];
+ NSAttributedString *attrString = [[[NSAttributedString
alloc] initWithString:[contents substringFromIndex:NSMaxRange(r)]
+
attributes:[NSDictionary dictionaryWithObjectsAndKeys:font,
NSFontAttributeName, nil]] autorelease];
+ [dictionary setObject:attrString
forKey:SKPDFAnnotationTextKey];
+ [dictionary setObject:[contents
substringToIndex:r.location] forKey:SKPDFAnnotationContentsKey];
+ }
+ }
+ } else if ([validTypes containsObject:type] == NO) {
+ success = NO;
+ }
+ }
+
if (success && CGPDFDictionaryGetArray(annot, SKFDFAnnotationBoundsKey,
&array)) {
CGPDFReal l, b, r, t;
if (CGPDFArrayGetCount(array) == 4 && CGPDFArrayGetNumber(array, 0,
&l) && CGPDFArrayGetNumber(array, 1, &b) && CGPDFArrayGetNumber(array, 2, &r)
&& CGPDFArrayGetNumber(array, 3, &t)) {
@@ -227,13 +256,6 @@
success = NO;
}
- if (success && CGPDFDictionaryGetString(annot, SKFDFAnnotationContentsKey,
&string)) {
- NSString *contents = (NSString *)CGPDFStringCopyTextString(string);
- if (contents)
- [dictionary setObject:contents forKey:SKPDFAnnotationContentsKey];
- [contents release];
- }
-
if (success) {
if (CGPDFDictionaryGetDictionary(annot,
SKFDFAnnotationBorderStylesKey, &dict)) {
if (CGPDFDictionaryGetNumber(dict, SKFDFAnnotationLineWidthKey,
&real)) {
@@ -360,28 +382,6 @@
}
}
- if (success) {
- NSSet *validTypes = [NSSet setWithObjects:SKFreeTextString,
SKNoteString, SKCircleString, SKSquareString, SKHighlightString,
SKUnderlineString, SKStrikeOutString, SKLineString, nil];
- NSString *type = [dictionary objectForKey:SKPDFAnnotationTypeKey];
- NSString *contents;
- if ([type isEqualToString:SKTextString]) {
- [dictionary setObject:SKNoteString forKey:SKPDFAnnotationTypeKey];
- if (contents = [dictionary
objectForKey:SKPDFAnnotationContentsKey]) {
- NSRange r = [contents rangeOfString:@" "];
- if (NSMaxRange(r) < [contents length]) {
- NSFont *font = [NSFont fontWithName:[[NSUserDefaults
standardUserDefaults] stringForKey:SKAnchoredNoteFontNameKey]
- size:[[NSUserDefaults
standardUserDefaults] floatForKey:SKAnchoredNoteFontSizeKey]];
- NSAttributedString *attrString = [[[NSAttributedString
alloc] initWithString:[contents substringFromIndex:NSMaxRange(r)]
-
attributes:[NSDictionary dictionaryWithObjectsAndKeys:font,
NSFontAttributeName, nil]] autorelease];
- [dictionary setObject:attrString
forKey:SKPDFAnnotationTextKey];
- [dictionary setObject:[contents
substringToIndex:r.location] forKey:SKPDFAnnotationContentsKey];
- }
- }
- } else if ([validTypes containsObject:type] == NO) {
- success = NO;
- }
- }
-
return success ? dictionary : 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 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