Revision: 13328
http://sourceforge.net/p/skim-app/code/13328
Author: hofman
Date: 2023-03-01 23:32:48 +0000 (Wed, 01 Mar 2023)
Log Message:
-----------
move text to note translation to PDFAnnotation class
Modified Paths:
--------------
trunk/PDFAnnotation_SKExtensions.h
trunk/PDFAnnotation_SKExtensions.m
trunk/SKFDFParser.m
trunk/SKMainDocument.m
trunk/SKNPDFAnnotationNote_SKExtensions.h
trunk/SKNPDFAnnotationNote_SKExtensions.m
Modified: trunk/PDFAnnotation_SKExtensions.h
===================================================================
--- trunk/PDFAnnotation_SKExtensions.h 2023-03-01 22:15:12 UTC (rev 13327)
+++ trunk/PDFAnnotation_SKExtensions.h 2023-03-01 23:32:48 UTC (rev 13328)
@@ -66,6 +66,8 @@
+ (NSArray *)SkimNotesAndPagesWithSelection:(PDFSelection *)selection
forType:(NSString *)type;
++ (NSDictionary *)textToNoteSkimNoteProperties:(NSDictionary *)properties;
+
- (NSString *)fdfString;
- (NSUInteger)pageIndex;
Modified: trunk/PDFAnnotation_SKExtensions.m
===================================================================
--- trunk/PDFAnnotation_SKExtensions.m 2023-03-01 22:15:12 UTC (rev 13327)
+++ trunk/PDFAnnotation_SKExtensions.m 2023-03-01 23:32:48 UTC (rev 13328)
@@ -208,6 +208,33 @@
return annotation;
}
++ (NSDictionary *)textToNoteSkimNoteProperties:(NSDictionary *)properties {
+ if ([[properties objectForKey:SKNPDFAnnotationTypeKey]
isEqualToString:SKNTextString]) {
+ NSMutableDictionary *mutableProperties = [[properties mutableCopy]
autorelease];
+ NSRect bounds = NSRectFromString([properties
objectForKey:SKNPDFAnnotationBoundsKey]);
+ NSString *contents = [properties
objectForKey:SKNPDFAnnotationContentsKey];
+ [mutableProperties setObject:SKNNoteString
forKey:SKNPDFAnnotationTypeKey];
+ bounds.origin.y = NSMaxY(bounds) - SKNPDFAnnotationNoteSize.height;
+ bounds.size = SKNPDFAnnotationNoteSize;
+ [mutableProperties setObject:NSStringFromRect(bounds)
forKey:SKNPDFAnnotationBoundsKey];
+ if (contents) {
+ NSRange r = [contents rangeOfString:@" "];
+ NSRange r1 = [contents rangeOfString:@"\n"];
+ if (r1.location < r.location)
+ r = r1;
+ if (NSMaxRange(r) < [contents length]) {
+ NSFont *font = [[NSUserDefaults standardUserDefaults]
fontForNameKey:SKAnchoredNoteFontNameKey sizeKey:SKAnchoredNoteFontSizeKey];
+ NSAttributedString *attrString = [[[NSAttributedString alloc]
initWithString:[contents substringFromIndex:NSMaxRange(r)]
+ attributes:[NSDictionary
dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil]] autorelease];
+ [mutableProperties setObject:attrString
forKey:SKNPDFAnnotationTextKey];
+ [mutableProperties setObject:[contents
substringToIndex:r.location] forKey:SKNPDFAnnotationContentsKey];
+ }
+ }
+ return mutableProperties;
+ }
+ return properties;
+}
+
- (NSString *)fdfString {
NSMutableString *fdfString = [NSMutableString string];
NSRect bounds = [self bounds];
Modified: trunk/SKFDFParser.m
===================================================================
--- trunk/SKFDFParser.m 2023-03-01 22:15:12 UTC (rev 13327)
+++ trunk/SKFDFParser.m 2023-03-01 23:32:48 UTC (rev 13328)
@@ -41,7 +41,7 @@
#import "NSGeometry_SKExtensions.h"
#import "SKStringConstants.h"
#import <SkimNotes/SkimNotes.h>
-#import "SKNPDFAnnotationNote_SKExtensions.h"
+#import "PDFAnnotation_SKExtensions.h"
SKFDFString SKFDFFDFKey = "FDF";
SKFDFString SKFDFAnnotationsKey = "Annots";
@@ -256,7 +256,7 @@
NSSet *validTypes = [NSSet setWithObjects:SKNFreeTextString,
SKNNoteString, SKNCircleString, SKNSquareString, SKNHighlightString,
SKNUnderlineString, SKNStrikeOutString, SKNLineString, SKNInkString, nil];
NSString *type = [dictionary objectForKey:SKNPDFAnnotationTypeKey];
if ([type isEqualToString:SKNTextString]) {
- [dictionary setDictionary:[SKNPDFAnnotationNote
textToNoteSkimNoteProperties:dictionary]];
+ [dictionary setDictionary:[PDFAnnotation
textToNoteSkimNoteProperties:dictionary]];
} else if ([validTypes containsObject:type] == NO) {
success = NO;
}
Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m 2023-03-01 22:15:12 UTC (rev 13327)
+++ trunk/SKMainDocument.m 2023-03-01 23:32:48 UTC (rev 13328)
@@ -1137,7 +1137,7 @@
[annotations addObject:annotation];
NSDictionary *properties = [annotation SkimNoteProperties];
if ([[annotation type] isEqualToString:SKNTextString])
- properties = [SKNPDFAnnotationNote
textToNoteSkimNoteProperties:properties];
+ properties = [PDFAnnotation
textToNoteSkimNoteProperties:properties];
if (noteDicts == nil)
noteDicts = [[NSMutableArray alloc] init];
[noteDicts addObject:properties];
Modified: trunk/SKNPDFAnnotationNote_SKExtensions.h
===================================================================
--- trunk/SKNPDFAnnotationNote_SKExtensions.h 2023-03-01 22:15:12 UTC (rev
13327)
+++ trunk/SKNPDFAnnotationNote_SKExtensions.h 2023-03-01 23:32:48 UTC (rev
13328)
@@ -53,6 +53,5 @@
#pragma mark -
@interface SKNPDFAnnotationNote (SKExtensions) <NSTextStorageDelegate>
-+ (NSDictionary *)textToNoteSkimNoteProperties:(NSDictionary *)properties;
- (void)setRichText:(id)newText;
@end
Modified: trunk/SKNPDFAnnotationNote_SKExtensions.m
===================================================================
--- trunk/SKNPDFAnnotationNote_SKExtensions.m 2023-03-01 22:15:12 UTC (rev
13327)
+++ trunk/SKNPDFAnnotationNote_SKExtensions.m 2023-03-01 23:32:48 UTC (rev
13328)
@@ -55,33 +55,6 @@
@implementation SKNPDFAnnotationNote (SKExtensions)
-+ (NSDictionary *)textToNoteSkimNoteProperties:(NSDictionary *)properties {
- if ([[properties objectForKey:SKNPDFAnnotationTypeKey]
isEqualToString:SKNTextString]) {
- NSMutableDictionary *mutableProperties = [[properties mutableCopy]
autorelease];
- NSRect bounds = NSRectFromString([properties
objectForKey:SKNPDFAnnotationBoundsKey]);
- NSString *contents = [properties
objectForKey:SKNPDFAnnotationContentsKey];
- [mutableProperties setObject:SKNNoteString
forKey:SKNPDFAnnotationTypeKey];
- bounds.origin.y = NSMaxY(bounds) - SKNPDFAnnotationNoteSize.height;
- bounds.size = SKNPDFAnnotationNoteSize;
- [mutableProperties setObject:NSStringFromRect(bounds)
forKey:SKNPDFAnnotationBoundsKey];
- if (contents) {
- NSRange r = [contents rangeOfString:@" "];
- NSRange r1 = [contents rangeOfString:@"\n"];
- if (r1.location < r.location)
- r = r1;
- if (NSMaxRange(r) < [contents length]) {
- NSFont *font = [[NSUserDefaults standardUserDefaults]
fontForNameKey:SKAnchoredNoteFontNameKey sizeKey:SKAnchoredNoteFontSizeKey];
- NSAttributedString *attrString = [[[NSAttributedString alloc]
initWithString:[contents substringFromIndex:NSMaxRange(r)]
- attributes:[NSDictionary
dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil]] autorelease];
- [mutableProperties setObject:attrString
forKey:SKNPDFAnnotationTextKey];
- [mutableProperties setObject:[contents
substringToIndex:r.location] forKey:SKNPDFAnnotationContentsKey];
- }
- }
- return mutableProperties;
- }
- return properties;
-}
-
- (void)setDefaultSkimNoteProperties {
[self setColor:[[NSUserDefaults standardUserDefaults]
colorForKey:SKAnchoredNoteColorKey]];
[self setIconType:[[NSUserDefaults standardUserDefaults]
integerForKey:SKAnchoredNoteIconTypeKey]];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit