Revision: 3096 http://skim-app.svn.sourceforge.net/skim-app/?rev=3096&view=rev Author: hofman Date: 2007-10-30 04:54:58 -0700 (Tue, 30 Oct 2007)
Log Message: ----------- Use "string" wrapper around "contents", and set the contents to the full string contents in anchored notes. This allows exporting embedded Text notes with the full string contents on Leopard. Modified Paths: -------------- trunk/Dutch.lproj/NoteWindow.nib/keyedobjects.nib trunk/English.lproj/NoteWindow.nib/info.nib trunk/English.lproj/NoteWindow.nib/keyedobjects.nib trunk/French.lproj/NoteWindow.nib/info.nib trunk/French.lproj/NoteWindow.nib/keyedobjects.nib trunk/Italian.lproj/NoteWindow.nib/keyedobjects.nib trunk/NSArray_SKExtensions.m trunk/SKMainWindowController.m trunk/SKNoteWindowController.m trunk/SKNotesDocument.m trunk/SKPDFAnnotationNote.h trunk/SKPDFAnnotationNote.m trunk/SKPDFHoverWindow.m trunk/SKPDFView.m trunk/Spanish.lproj/NoteWindow.nib/info.nib trunk/Spanish.lproj/NoteWindow.nib/keyedobjects.nib trunk/notesTemplate.rtf trunk/notesTemplate.rtfd/TXT.rtf trunk/notesTemplate.txt Modified: trunk/Dutch.lproj/NoteWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/English.lproj/NoteWindow.nib/info.nib =================================================================== --- trunk/English.lproj/NoteWindow.nib/info.nib 2007-10-30 10:49:51 UTC (rev 3095) +++ trunk/English.lproj/NoteWindow.nib/info.nib 2007-10-30 11:54:58 UTC (rev 3096) @@ -13,8 +13,8 @@ <string>446.1</string> <key>IBOpenObjects</key> <array> + <integer>7</integer> <integer>114</integer> - <integer>7</integer> </array> <key>IBSystem Version</key> <string>8R218</string> Modified: trunk/English.lproj/NoteWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/French.lproj/NoteWindow.nib/info.nib =================================================================== --- trunk/French.lproj/NoteWindow.nib/info.nib 2007-10-30 10:49:51 UTC (rev 3095) +++ trunk/French.lproj/NoteWindow.nib/info.nib 2007-10-30 11:54:58 UTC (rev 3096) @@ -3,7 +3,7 @@ <plist version="1.0"> <dict> <key>IBDocumentLocation</key> - <string>79 78 356 240 0 0 1600 1178 </string> + <string>69 58 356 240 0 0 1440 938 </string> <key>IBEditorPositions</key> <dict> <key>114</key> @@ -11,7 +11,11 @@ </dict> <key>IBFramework Version</key> <string>446.1</string> + <key>IBOpenObjects</key> + <array> + <integer>7</integer> + </array> <key>IBSystem Version</key> - <string>8R2218</string> + <string>8R218</string> </dict> </plist> Modified: trunk/French.lproj/NoteWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/Italian.lproj/NoteWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/NSArray_SKExtensions.m =================================================================== --- trunk/NSArray_SKExtensions.m 2007-10-30 10:49:51 UTC (rev 3095) +++ trunk/NSArray_SKExtensions.m 2007-10-30 11:54:58 UTC (rev 3096) @@ -59,11 +59,11 @@ } - (NSArray *)arraySortedByContents { - return [self sortedArrayUsingDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"contents" ascending:YES selector:@selector(localizedCaseInsensitiveNumericCompare:)] autorelease]]]; + return [self sortedArrayUsingDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"string" ascending:YES selector:@selector(localizedCaseInsensitiveNumericCompare:)] autorelease]]]; } - (NSArray *)arraySortedByTypeAndContents { - return [self sortedArrayUsingDescriptors:[NSArray arrayWithObjects:[[[NSSortDescriptor alloc] initWithKey:@"type" ascending:YES selector:@selector(noteTypeCompare:)] autorelease], [[[NSSortDescriptor alloc] initWithKey:@"contents" ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease], nil]]; + return [self sortedArrayUsingDescriptors:[NSArray arrayWithObjects:[[[NSSortDescriptor alloc] initWithKey:@"type" ascending:YES selector:@selector(noteTypeCompare:)] autorelease], [[[NSSortDescriptor alloc] initWithKey:@"string" ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease], nil]]; } - (NSArray *)arraySortedByTypeAndPageIndex { Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2007-10-30 10:49:51 UTC (rev 3095) +++ trunk/SKMainWindowController.m 2007-10-30 11:54:58 UTC (rev 3096) @@ -3335,7 +3335,7 @@ } else if ([ov isEqual:noteOutlineView]) { NSString *tcID = [tableColumn identifier]; if ([tcID isEqualToString:@"note"]) { - return [item contents]; + return [item string]; } else if([tcID isEqualToString:@"type"]) { return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:item == [pdfView activeAnnotation]], @"active", [item type], @"type", nil]; } else if([tcID isEqualToString:@"page"]) { @@ -3348,8 +3348,8 @@ - (void)outlineView:(NSOutlineView *)ov setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item{ if ([ov isEqual:noteOutlineView]) { if ([[tableColumn identifier] isEqualToString:@"note"]) { - if ([object isEqualToString:[item contents]] == NO) - [item setContents:object]; + if ([object isEqualToString:[item string]] == NO) + [item setString:object]; } } } @@ -3389,7 +3389,7 @@ if ([tcID isEqualToString:@"type"]) { [sds insertObject:[[[NSSortDescriptor alloc] initWithKey:@"type" ascending:YES selector:@selector(noteTypeCompare:)] autorelease] atIndex:0]; } else if ([tcID isEqualToString:@"note"]) { - [sds insertObject:[[[NSSortDescriptor alloc] initWithKey:@"contents" ascending:YES selector:@selector(localizedCaseInsensitiveNumericCompare:)] autorelease] atIndex:0]; + [sds insertObject:[[[NSSortDescriptor alloc] initWithKey:@"string" ascending:YES selector:@selector(localizedCaseInsensitiveNumericCompare:)] autorelease] atIndex:0]; } else if ([tcID isEqualToString:@"page"]) { if (oldTableColumn == nil) ascending = NO; @@ -3419,7 +3419,7 @@ - (NSString *)outlineView:(NSOutlineView *)ov toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tableColumn item:(id)item mouseLocation:(NSPoint)mouseLocation { if ([ov isEqual:noteOutlineView] && [[tableColumn identifier] isEqualToString:@"note"]) { - return [item type] ? [(PDFAnnotation *)item contents] : [[(SKNoteText *)item contents] string]; + return [item type] ? [(PDFAnnotation *)item string] : [[(SKNoteText *)item string] string]; } return nil; } @@ -3512,8 +3512,8 @@ NSPasteboard *pboard = [NSPasteboard generalPasteboard]; NSMutableArray *types = [NSMutableArray array]; NSData *noteData = item ? [NSKeyedArchiver archivedDataWithRootObject:[item dictionaryValue]] : nil; - NSAttributedString *attrString = [firstItem type] ? nil : [(SKNoteText *)firstItem contents]; - NSString *string = [firstItem type] ? [firstItem contents] : [attrString string]; + NSAttributedString *attrString = [firstItem type] ? nil : [(SKNoteText *)firstItem string]; + NSString *string = [firstItem type] ? [firstItem string] : [attrString string]; if (noteData) [types addObject:SKSkimNotePboardType]; if (string) @@ -3612,7 +3612,7 @@ for (i = 0; i < count; i++) { item = [items objectAtIndex:i]; - [cell setObjectValue:[item contents]]; + [cell setObjectValue:[item string]]; NSAttributedString *attrString = [cell attributedStringValue]; NSRect rect = [attrString boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin]; [item setRowHeight:fmaxf(NSHeight(rect) + 3.0, 19.0)]; @@ -3867,8 +3867,8 @@ NSMutableArray *texts = [NSMutableArray arrayWithCapacity:count]; for (i = 0; i < count; i++) { id item = [noteOutlineView itemAtRow:i]; - NSString *contents = [item type] ? [(PDFAnnotation *)item contents] : [[(SKNoteText *)item contents] string]; - [texts addObject:contents ? contents : @""]; + NSString *string = [item type] ? [(PDFAnnotation *)item string] : [[(SKNoteText *)item string] string]; + [texts addObject:string ? string : @""]; } return texts; } else if ([typeSelectHelper isEqual:[outlineView typeSelectHelper]]) { @@ -4102,11 +4102,11 @@ } if (searchString && [searchString isEqualToString:@""] == NO) { NSExpression *lhs = [NSExpression expressionForConstantValue:searchString]; - NSExpression *rhs = [NSExpression expressionForKeyPath:@"contents"]; - NSPredicate *contentsPredicate = [NSComparisonPredicate predicateWithLeftExpression:lhs rightExpression:rhs modifier:NSDirectPredicateModifier type:NSInPredicateOperatorType options:NSCaseInsensitivePredicateOption | NSDiacriticInsensitivePredicateOption]; + NSExpression *rhs = [NSExpression expressionForKeyPath:@"string"]; + NSPredicate *stringPredicate = [NSComparisonPredicate predicateWithLeftExpression:lhs rightExpression:rhs modifier:NSDirectPredicateModifier type:NSInPredicateOperatorType options:NSCaseInsensitivePredicateOption | NSDiacriticInsensitivePredicateOption]; rhs = [NSExpression expressionForKeyPath:@"text.string"]; NSPredicate *textPredicate = [NSComparisonPredicate predicateWithLeftExpression:lhs rightExpression:rhs modifier:NSDirectPredicateModifier type:NSInPredicateOperatorType options:NSCaseInsensitivePredicateOption | NSDiacriticInsensitivePredicateOption]; - searchPredicate = [NSCompoundPredicate orPredicateWithSubpredicates:[NSArray arrayWithObjects:contentsPredicate, textPredicate, nil]]; + searchPredicate = [NSCompoundPredicate orPredicateWithSubpredicates:[NSArray arrayWithObjects:stringPredicate, textPredicate, nil]]; } if (typePredicate) { if (searchPredicate) Modified: trunk/SKNoteWindowController.m =================================================================== --- trunk/SKNoteWindowController.m 2007-10-30 10:49:51 UTC (rev 3095) +++ trunk/SKNoteWindowController.m 2007-10-30 11:54:58 UTC (rev 3096) @@ -119,7 +119,7 @@ } - (NSString *)windowTitleForDocumentDisplayName:(NSString *)displayName { - return [[self note] contents]; + return [[self note] string]; } - (PDFAnnotation *)note { @@ -212,7 +212,7 @@ - (BOOL)dragImageView:(BDSKDragImageView *)view writeDataToPasteboard:(NSPasteboard *)pasteboard { NSImage *image = [self isNoteType] ? [(SKPDFAnnotationNote *)note image] : nil; if (image) { - NSString *name = [note contents]; + NSString *name = [note string]; if ([name length] == 0) name = @"NoteImage"; [pasteboard declareTypes:[NSArray arrayWithObjects:NSFilesPromisePboardType, NSTIFFPboardType, nil] owner:nil]; @@ -225,10 +225,10 @@ - (NSArray *)dragImageView:(BDSKDragImageView *)view namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination { NSImage *image = [self isNoteType] ? [(SKPDFAnnotationNote *)note image] : nil; if (image) { - NSString *name = [note contents]; + NSString *name = [note string]; if ([name length] == 0) name = @"NoteImage"; - NSString *basePath = [[dropDestination path] stringByAppendingPathComponent:[note contents]]; + NSString *basePath = [[dropDestination path] stringByAppendingPathComponent:[note string]]; NSString *path = [basePath stringByAppendingPathExtension:@"tiff"]; int i = 0; NSFileManager *fm = [NSFileManager defaultManager]; Modified: trunk/SKNotesDocument.m =================================================================== --- trunk/SKNotesDocument.m 2007-10-30 10:49:51 UTC (rev 3095) +++ trunk/SKNotesDocument.m 2007-10-30 11:54:58 UTC (rev 3096) @@ -78,8 +78,8 @@ [aController setWindowFrameAutosaveNameOrCascade:SKNotesDocumentWindowFrameAutosaveName]; NSSortDescriptor *indexSortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"pageIndex" ascending:YES] autorelease]; - NSSortDescriptor *contentsSortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"contents" ascending:YES selector:@selector(localizedCaseInsensitiveNumericCompare:)] autorelease]; - [arrayController setSortDescriptors:[NSArray arrayWithObjects:indexSortDescriptor, contentsSortDescriptor, nil]]; + NSSortDescriptor *stringSortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"string" ascending:YES selector:@selector(localizedCaseInsensitiveNumericCompare:)] autorelease]; + [arrayController setSortDescriptors:[NSArray arrayWithObjects:indexSortDescriptor, stringSortDescriptor, nil]]; [outlineView reloadData]; SKTypeSelectHelper *typeSelectHelper = [[[SKTypeSelectHelper alloc] init] autorelease]; @@ -132,8 +132,19 @@ while (dict = [dictEnum nextObject]) { NSMutableDictionary *note = [dict mutableCopy]; - if ([[dict valueForKey:@"type"] isEqualToString:SKNoteString]) - [note setObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:85.0], @"rowHeight", [dict valueForKey:@"text"], @"contents", nil] forKey:@"child"]; + [note setValue:[dict valueForKey:@"contents"] forKey:@"string"]; + if ([[dict valueForKey:@"type"] isEqualToString:SKNoteString]) { + [note setObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:85.0], @"rowHeight", [dict valueForKey:@"text"], @"string", nil] forKey:@"child"]; + NSMutableString *contents = [[NSMutableString alloc] init]; + if ([[dict valueForKey:@"contents"] length]) + [contents appendString:[dict valueForKey:@"contents"]]; + if ([[dict valueForKey:@"text"] length]) { + [contents appendString:@" "]; + [contents appendString:[[dict valueForKey:@"text"] string]]; + } + [note setValue:contents forKey:@"contents"]; + [contents release]; + } [note setObject:[NSNumber numberWithFloat:19.0] forKey:@"rowHeight"]; [newNotes addObject:note]; @@ -238,7 +249,7 @@ for (i = 0; i < count; i++) { item = [items objectAtIndex:i]; - [cell setObjectValue:[item valueForKey:@"contents"]]; + [cell setObjectValue:[item valueForKey:@"string"]]; NSAttributedString *attrString = [cell attributedStringValue]; NSRect rect = [attrString boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin]; [item setValue:[NSNumber numberWithFloat:fmaxf(NSHeight(rect) + 3.0, 19.0)] forKey:@"rowHeight"]; @@ -300,7 +311,7 @@ - (id)outlineView:(NSOutlineView *)ov objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item { NSString *tcID = [tableColumn identifier]; if ([tcID isEqualToString:@"note"]) { - return [item valueForKey:@"contents"]; + return [item valueForKey:@"string"]; } else if([tcID isEqualToString:@"type"]) { return [NSDictionary dictionaryWithObjectsAndKeys:[item valueForKey:@"type"], @"type", nil]; } else if ([tcID isEqualToString:@"page"]) { @@ -325,7 +336,7 @@ if ([tcID isEqualToString:@"type"]) { [sds insertObject:[[[NSSortDescriptor alloc] initWithKey:@"type" ascending:YES selector:@selector(noteTypeCompare:)] autorelease] atIndex:0]; } else if ([tcID isEqualToString:@"note"]) { - [sds insertObject:[[[NSSortDescriptor alloc] initWithKey:@"contents" ascending:YES selector:@selector(localizedCaseInsensitiveNumericCompare:)] autorelease] atIndex:0]; + [sds insertObject:[[[NSSortDescriptor alloc] initWithKey:@"string" ascending:YES selector:@selector(localizedCaseInsensitiveNumericCompare:)] autorelease] atIndex:0]; } else if ([tcID isEqualToString:@"page"]) { if (oldTableColumn == nil) ascending = NO; @@ -365,8 +376,8 @@ NSDictionary *firstItem = [items objectAtIndex:0]; NSPasteboard *pboard = [NSPasteboard generalPasteboard]; NSMutableArray *types = [NSMutableArray array]; - NSAttributedString *attrString = [firstItem valueForKey:@"type"] ? nil : [firstItem valueForKey:@"contents"]; - NSString *string = [firstItem valueForKey:@"type"] ? [firstItem valueForKey:@"contents"] : [attrString string]; + NSAttributedString *attrString = [firstItem valueForKey:@"type"] ? nil : [firstItem valueForKey:@"string"]; + NSString *string = [firstItem valueForKey:@"type"] ? [firstItem valueForKey:@"string"] : [attrString string]; if (string) [types addObject:NSStringPboardType]; if (attrString) @@ -397,7 +408,7 @@ } - (NSString *)outlineView:(NSOutlineView *)ov toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tableColumn item:(id)item mouseLocation:(NSPoint)mouseLocation { - return [item valueForKey:@"type"] ? [item valueForKey:@"contents"] : [[item valueForKey:@"contents"] string]; + return [item valueForKey:@"type"] ? [item valueForKey:@"string"] : [[item valueForKey:@"string"] string]; } - (NSMenu *)outlineView:(NSOutlineView *)ov menuForTableColumn:(NSTableColumn *)tableColumn item:(id)item { @@ -429,8 +440,8 @@ NSMutableArray *texts = [NSMutableArray arrayWithCapacity:count]; for (i = 0; i < count; i++) { id item = [outlineView itemAtRow:i]; - NSString *contents = [item valueForKey:@"type"] ? [item valueForKey:@"contents"] : [[item valueForKey:@"contents"] string]; - [texts addObject:contents ? contents : @""]; + NSString *string = [item valueForKey:@"type"] ? [item valueForKey:@"string"] : [[item valueForKey:@"string"] string]; + [texts addObject:string ? string : @""]; } return texts; } Modified: trunk/SKPDFAnnotationNote.h =================================================================== --- trunk/SKPDFAnnotationNote.h 2007-10-30 10:49:51 UTC (rev 3095) +++ trunk/SKPDFAnnotationNote.h 2007-10-30 11:54:58 UTC (rev 3096) @@ -62,6 +62,9 @@ - (NSArray *)dashPattern; - (void)setDashPattern:(NSArray *)pattern; +- (NSString *)string; +- (void)setString:(NSString *)newString; + - (NSImage *)image; - (NSAttributedString *)text; @@ -140,6 +143,7 @@ #pragma mark - @interface SKPDFAnnotationNote : PDFAnnotationText { + NSString *string; NSImage *image; NSTextStorage *textStorage; NSAttributedString *text; @@ -188,7 +192,7 @@ - (NSString *)type; - (PDFPage *)page; - (unsigned int)pageIndex; -- (NSAttributedString *)contents; +- (NSAttributedString *)string; - (float)rowHeight; - (void)setRowHeight:(float)newRowHeight; Modified: trunk/SKPDFAnnotationNote.m =================================================================== --- trunk/SKPDFAnnotationNote.m 2007-10-30 10:49:51 UTC (rev 3095) +++ trunk/SKPDFAnnotationNote.m 2007-10-30 11:54:58 UTC (rev 3096) @@ -154,14 +154,12 @@ @interface PDFAnnotation (SKPDFAnnotationPrivate) - (id)initWithBounds:(NSRect)bounds dictionary:(NSDictionary *)dict; - (void)replacementSetBounds:(NSRect)bounds; -- (void)replacementSetContents:(NSString *)contents; - (void)replacementSetColor:(NSColor *)color; - (void)replacementSetBorder:(PDFBorder *)border; @end static IMP originalSetBounds = NULL; -static IMP originalSetContents = NULL; static IMP originalSetColor = NULL; static IMP originalSetBorder = NULL; @@ -169,11 +167,12 @@ + (void)load { originalSetBounds = OBReplaceMethodImplementationWithSelector(self, @selector(setBounds:), @selector(replacementSetBounds:)); - originalSetContents = OBReplaceMethodImplementationWithSelector(self, @selector(setContents:), @selector(replacementSetContents:)); originalSetColor = OBReplaceMethodImplementationWithSelector(self, @selector(setColor:), @selector(replacementSetColor:)); originalSetBorder = OBReplaceMethodImplementationWithSelector(self, @selector(setBorder:), @selector(replacementSetBorder:)); } +- (void)updateContents{} + - (id)initWithBounds:(NSRect)bounds dictionary:(NSDictionary *)dict{ [[self initWithBounds:NSZeroRect] release]; return nil; @@ -207,7 +206,7 @@ NSArray *dashPattern = [dict objectForKey:DASH_PATTERN_KEY]; if (contents) - originalSetContents(self, @selector(setContents:), contents); + [self setString:contents]; if (color) originalSetColor(self, @selector(setColor:), color); if (lineWidth == nil && borderStyle == nil && dashPattern == nil) { @@ -223,6 +222,7 @@ if (dashPattern) [[self border] setDashPattern:dashPattern]; } + [self updateContents]; } return self; } @@ -230,7 +230,7 @@ - (NSDictionary *)dictionaryValue{ NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:5]; [dict setValue:[self type] forKey:TYPE_KEY]; - [dict setValue:[self contents] forKey:CONTENTS_KEY]; + [dict setValue:[self string] forKey:CONTENTS_KEY]; [dict setValue:[self color] forKey:COLOR_KEY]; [dict setValue:NSStringFromRect([self bounds]) forKey:BOUNDS_KEY]; [dict setValue:[NSNumber numberWithUnsignedInt:[self pageIndex]] forKey:PAGE_INDEX_KEY]; @@ -243,51 +243,47 @@ } - (NSString *)fdfString { - NSMutableString *string = [NSMutableString string]; + NSMutableString *fdfString = [NSMutableString string]; NSRect bounds = [self bounds]; float r, g, b, a = 0.0; PDFBorder *border = [self border]; NSString *contents = [self contents]; [[self color] getRed:&r green:&g blue:&b alpha:&a]; - [string appendString:@"/Type/Annot/Subtype/"]; - [string appendString:[[self type] isEqualToString:SKNoteString] ? SKTextString : [self type]]; - [string appendFormat:@"/Rect[%f %f %f %f]", NSMinX(bounds), NSMinY(bounds), NSMaxX(bounds), NSMaxY(bounds)]; - [string appendFormat:@"/Page %i", [self pageIndex]]; - [string appendString:@"/F 4"]; + [fdfString appendString:@"/Type/Annot/Subtype/"]; + [fdfString appendString:[[self type] isEqualToString:SKNoteString] ? SKTextString : [self type]]; + [fdfString appendFormat:@"/Rect[%f %f %f %f]", NSMinX(bounds), NSMinY(bounds), NSMaxX(bounds), NSMaxY(bounds)]; + [fdfString appendFormat:@"/Page %i", [self pageIndex]]; + [fdfString appendString:@"/F 4"]; if (a > 0.0) - [string appendFormat:@"/C[%f %f %f]", r, g, b]; + [fdfString appendFormat:@"/C[%f %f %f]", r, g, b]; if (border) { - [string appendFormat:@"/BS<</W %f/S", [border lineWidth]]; + [fdfString appendFormat:@"/BS<</W %f/S", [border lineWidth]]; switch ([border style]) { case kPDFBorderStyleSolid: - [string appendString:@"/S"]; + [fdfString appendString:@"/S"]; break; case kPDFBorderStyleDashed: - [string appendString:@"/D"]; + [fdfString appendString:@"/D"]; break; case kPDFBorderStyleBeveled: - [string appendString:@"/B"]; + [fdfString appendString:@"/B"]; break; case kPDFBorderStyleInset: - [string appendString:@"/I"]; + [fdfString appendString:@"/I"]; break; case kPDFBorderStyleUnderline: - [string appendString:@"/U"]; + [fdfString appendString:@"/U"]; break; } - [string appendFormat:@"/[EMAIL PROTECTED]", [[[border dashPattern] valueForKey:@"stringValue"] componentsJoinedByString:@" "]]; - [string appendString:@">>"]; + [fdfString appendFormat:@"/[EMAIL PROTECTED]", [[[border dashPattern] valueForKey:@"fdfStringValue"] componentsJoinedByString:@" "]]; + [fdfString appendString:@">>"]; } else { - [string appendString:@"/BS<</W 0.0>>"]; + [fdfString appendString:@"/BS<</W 0.0>>"]; } - [string appendString:@"/Contents("]; - [string appendString:contents ? [contents stringByEscapingParenthesis] : @""]; - if ([[self text] length]) { - [string appendString:@" "]; - [string appendString:[[[self text] string] stringByEscapingParenthesis]]; - } - [string appendString:@")"]; - return string; + [fdfString appendString:@"/Contents("]; + [fdfString appendString:contents ? [contents stringByEscapingParenthesis] : @""]; + [fdfString appendString:@")"]; + return fdfString; } - (PDFDestination *)destination{ @@ -343,28 +339,32 @@ [border release]; } -- (void)replacementSetBounds:(NSRect)bounds { +- (NSString *)string { + return [self contents]; +} + +- (void)setString:(NSString *)newString { if ([self isNoteAnnotation]) { - [[[self undoManager] prepareWithInvocationTarget:self] setBounds:[self bounds]]; + [[[self undoManager] prepareWithInvocationTarget:self] setString:[self string]]; [[self undoManager] setActionName:NSLocalizedString(@"Edit Note", @"Undo action name")]; - [[NSNotificationCenter defaultCenter] postNotificationName:SKAnnotationWillChangeNotification - object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"bounds", @"key", nil]]; } - originalSetBounds(self, _cmd, bounds); + [self setContents:newString]; if ([self isNoteAnnotation]) [[NSNotificationCenter defaultCenter] postNotificationName:SKAnnotationDidChangeNotification - object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"bounds", @"key", nil]]; + object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"string", @"key", nil]]; } -- (void)replacementSetContents:(NSString *)contents { +- (void)replacementSetBounds:(NSRect)bounds { if ([self isNoteAnnotation]) { - [[[self undoManager] prepareWithInvocationTarget:self] setContents:[self contents]]; + [[[self undoManager] prepareWithInvocationTarget:self] setBounds:[self bounds]]; [[self undoManager] setActionName:NSLocalizedString(@"Edit Note", @"Undo action name")]; + [[NSNotificationCenter defaultCenter] postNotificationName:SKAnnotationWillChangeNotification + object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"bounds", @"key", nil]]; } - originalSetContents(self, _cmd, contents); + originalSetBounds(self, _cmd, bounds); if ([self isNoteAnnotation]) [[NSNotificationCenter defaultCenter] postNotificationName:SKAnnotationDidChangeNotification - object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"contents", @"key", nil]]; + object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"bounds", @"key", nil]]; } - (void)replacementSetColor:(NSColor *)color { @@ -520,12 +520,12 @@ - (id)textContents; { - return [self contents] ? [[[NSTextStorage alloc] initWithString:[self contents]] autorelease] : [NSNull null]; + return [self string] ? [[[NSTextStorage alloc] initWithString:[self string]] autorelease] : [NSNull null]; } - (void)setTextContents:(id)text; { - [self setContents:[text string]]; + [self setString:[text string]]; } - (id)coerceValueForTextContents:(id)value { @@ -648,12 +648,12 @@ } - (NSString *)fdfString { - NSMutableString *string = [[[super fdfString] mutableCopy] autorelease]; + NSMutableString *fdfString = [[[super fdfString] mutableCopy] autorelease]; float r, g, b, a = 0.0; [[self interiorColor] getRed:&r green:&g blue:&b alpha:&a]; if (a > 0.0) - [string appendFormat:@"/IC[%f %f %f]", r, g, b]; - return string; + [fdfString appendFormat:@"/IC[%f %f %f]", r, g, b]; + return fdfString; } - (BOOL)isNoteAnnotation { return YES; } @@ -723,12 +723,12 @@ } - (NSString *)fdfString { - NSMutableString *string = [[[super fdfString] mutableCopy] autorelease]; + NSMutableString *fdfString = [[[super fdfString] mutableCopy] autorelease]; float r, g, b, a = 0.0; [[self interiorColor] getRed:&r green:&g blue:&b alpha:&a]; if (a > 0.0) - [string appendFormat:@"/IC[%f %f %f]", r, g, b]; - return string; + [fdfString appendFormat:@"/IC[%f %f %f]", r, g, b]; + return fdfString; } - (BOOL)isNoteAnnotation { return YES; } @@ -961,18 +961,18 @@ } - (NSString *)fdfString { - NSMutableString *string = [[[super fdfString] mutableCopy] autorelease]; + NSMutableString *fdfString = [[[super fdfString] mutableCopy] autorelease]; NSEnumerator *pointEnum = [[self quadrilateralPoints] objectEnumerator]; NSValue *value; NSPoint point; NSRect bounds = [self bounds]; - [string appendString:@"/QuadPoints["]; + [fdfString appendString:@"/QuadPoints["]; while (value = [pointEnum nextObject]) { point = [value pointValue]; - [string appendFormat:@"%f %f ", point.x + NSMinX(bounds), point.y + NSMinY(bounds)]; + [fdfString appendFormat:@"%f %f ", point.x + NSMinX(bounds), point.y + NSMinY(bounds)]; } - [string appendString:@"]"]; - return string; + [fdfString appendString:@"]"]; + return fdfString; } - (void)regenerateLineRects { @@ -1121,9 +1121,9 @@ } - (NSString *)fdfString { - NSMutableString *string = [[[super fdfString] mutableCopy] autorelease]; - [string appendFormat:@"/DA(/%@ %f Tf)/DS(font: %@ %fpt)", [[self font] fontName], [[self font] pointSize], [[self font] fontName], [[self font] pointSize]]; - return string; + NSMutableString *fdfString = [[[super fdfString] mutableCopy] autorelease]; + [fdfString appendFormat:@"/DA(/%@ %f Tf)/DS(font: %@ %fpt)", [[self font] fontName], [[self font] pointSize], [[self font] fontName], [[self font] pointSize]]; + return fdfString; } - (BOOL)isNoteAnnotation { return YES; } @@ -1159,10 +1159,10 @@ } - (id)textContents { - NSTextStorage *textContents = [[[NSTextStorage alloc] initWithString:[self contents]] autorelease]; + NSTextStorage *textContents = [[[NSTextStorage alloc] initWithString:[self string]] autorelease]; if ([self font]) [textContents addAttribute:NSFontAttributeName value:[self font] range:NSMakeRange(0, [textContents length])]; - return [self contents] ? textContents : (id)[NSNull null]; + return [self string] ? textContents : (id)[NSNull null]; } - (NSString *)fontName { @@ -1237,29 +1237,29 @@ } - (NSString *)fdfString { - NSMutableString *string = [[[super fdfString] mutableCopy] autorelease]; - [string appendString:@"/Name"]; + NSMutableString *fdfString = [[[super fdfString] mutableCopy] autorelease]; + [fdfString appendString:@"/Name"]; switch ([self iconType]) { case kPDFTextAnnotationIconComment: - [string appendString:@"/Comment"]; + [fdfString appendString:@"/Comment"]; break; case kPDFTextAnnotationIconKey: - [string appendString:@"/Key"]; + [fdfString appendString:@"/Key"]; break; case kPDFTextAnnotationIconNote: - [string appendString:@"/Note"]; + [fdfString appendString:@"/Note"]; break; case kPDFTextAnnotationIconNewParagraph: - [string appendString:@"/NewParagraph"]; + [fdfString appendString:@"/NewParagraph"]; break; case kPDFTextAnnotationIconParagraph: - [string appendString:@"/Paragraph"]; + [fdfString appendString:@"/Paragraph"]; break; case kPDFTextAnnotationIconInsert: - [string appendString:@"/Insert"]; + [fdfString appendString:@"/Insert"]; break; } - return string; + return fdfString; } - (BOOL)isNoteAnnotation { return YES; } @@ -1272,6 +1272,36 @@ return SKNoteString; } +- (void)updateContents { + NSMutableString *contents = [NSMutableString string]; + if ([string length]) + [contents appendString:string]; + if ([text length]) { + [contents appendString:@" "]; + [contents appendString:[text string]]; + } + [self setContents:contents]; +} + +- (NSString *)string { + return string; +} + +- (void)setString:(NSString *)newString { + if (string != newString) { + if ([self isNoteAnnotation]) { + [[[self undoManager] prepareWithInvocationTarget:self] setString:[self string]]; + [[self undoManager] setActionName:NSLocalizedString(@"Edit Note", @"Undo action name")]; + } + [string release]; + string = [newString retain]; + [self updateContents]; + if ([self isNoteAnnotation]) + [[NSNotificationCenter defaultCenter] postNotificationName:SKAnnotationDidChangeNotification + object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"string", @"key", nil]]; + } +} + - (void)setIconType:(PDFTextAnnotationIconType)type; { [[[self undoManager] prepareWithInvocationTarget:self] setIconType:[self iconType]]; @@ -1326,6 +1356,7 @@ [self didChangeValueForKey:@"text"]; [text release]; text = [[NSAttributedString allocWithZone:[self zone]] initWithAttributedString:textStorage]; + [self updateContents]; [[NSNotificationCenter defaultCenter] postNotificationName:SKAnnotationDidChangeNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"text", @"key", nil]]; } @@ -1449,56 +1480,56 @@ } - (NSString *)fdfString { - NSMutableString *string = [[[super fdfString] mutableCopy] autorelease]; - [string appendString:@"/LE["]; + NSMutableString *fdfString = [[[super fdfString] mutableCopy] autorelease]; + [fdfString appendString:@"/LE["]; switch ([self startLineStyle]) { case kPDFLineStyleNone: - [string appendString:@"/None"]; + [fdfString appendString:@"/None"]; break; case kPDFLineStyleSquare: - [string appendString:@"/Square"]; + [fdfString appendString:@"/Square"]; break; case kPDFLineStyleCircle: - [string appendString:@"/Circle"]; + [fdfString appendString:@"/Circle"]; break; case kPDFLineStyleDiamond: - [string appendString:@"/Diamond"]; + [fdfString appendString:@"/Diamond"]; break; case kPDFLineStyleOpenArrow: - [string appendString:@"/OpenArrow"]; + [fdfString appendString:@"/OpenArrow"]; break; case kPDFLineStyleClosedArrow: - [string appendString:@"/ClosedArrow"]; + [fdfString appendString:@"/ClosedArrow"]; break; default: - [string appendString:@"/None"]; + [fdfString appendString:@"/None"]; break; } switch ([self endLineStyle]) { case kPDFLineStyleNone: - [string appendString:@"/None"]; + [fdfString appendString:@"/None"]; break; case kPDFLineStyleSquare: - [string appendString:@"/Square"]; + [fdfString appendString:@"/Square"]; break; case kPDFLineStyleCircle: - [string appendString:@"/Circle"]; + [fdfString appendString:@"/Circle"]; break; case kPDFLineStyleDiamond: - [string appendString:@"/Diamond"]; + [fdfString appendString:@"/Diamond"]; break; case kPDFLineStyleOpenArrow: - [string appendString:@"/OpenArrow"]; + [fdfString appendString:@"/OpenArrow"]; break; case kPDFLineStyleClosedArrow: - [string appendString:@"/ClosedArrow"]; + [fdfString appendString:@"/ClosedArrow"]; break; default: - [string appendString:@"/None"]; + [fdfString appendString:@"/None"]; break; } - [string appendString:@"]"]; - return string; + [fdfString appendString:@"]"]; + return fdfString; } - (BOOL)isNoteAnnotation { return YES; } @@ -1748,7 +1779,7 @@ - (unsigned int)pageIndex { return [annotation pageIndex]; } -- (NSAttributedString *)contents { return [annotation text]; } +- (NSAttributedString *)string { return [annotation text]; } - (float)rowHeight { return rowHeight; @@ -1760,8 +1791,8 @@ - (void)handleAnnotationDidChangeNotification:(NSNotification *)notification { if ([[[notification userInfo] objectForKey:@"key"] isEqualToString:@"text"]) { - [self willChangeValueForKey:@"contents"]; - [self didChangeValueForKey:@"contents"]; + [self willChangeValueForKey:@"string"]; + [self didChangeValueForKey:@"string"]; } } Modified: trunk/SKPDFHoverWindow.m =================================================================== --- trunk/SKPDFHoverWindow.m 2007-10-30 10:49:51 UTC (rev 3095) +++ trunk/SKPDFHoverWindow.m 2007-10-30 11:54:58 UTC (rev 3096) @@ -285,8 +285,8 @@ if ([text length] == 0) { [text release]; text = nil; - if ([[annotation contents] length]) - string = [annotation contents]; + if ([[annotation string] length]) + string = [annotation string]; } } Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-10-30 10:49:51 UTC (rev 3095) +++ trunk/SKPDFView.m 2007-10-30 11:54:58 UTC (rev 3096) @@ -834,7 +834,7 @@ newAnnotation = [[SKPDFAnnotationNote alloc] initWithBounds:bounds]; else newAnnotation = [[SKPDFAnnotationFreeText alloc] initWithBounds:bounds]; - [newAnnotation setContents:[pboard stringForType:NSStringPboardType]]; + [newAnnotation setString:[pboard stringForType:NSStringPboardType]]; } [self addAnnotation:newAnnotation toPage:page]; @@ -1066,7 +1066,7 @@ if (draggingAnnotation && didDrag) { if ([[activeAnnotation type] isEqualToString:SKCircleString] || [[activeAnnotation type] isEqualToString:SKSquareString]) { NSString *selString = [[[[activeAnnotation page] selectionForRect:[activeAnnotation bounds]] string] stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines]; - [activeAnnotation setContents:selString]; + [activeAnnotation setString:selString]; } } else if (toolMode == SKNoteToolMode && hideNotes == NO && [self currentSelection] && (annotationMode == SKHighlightNote || annotationMode == SKUnderlineNote || annotationMode == SKStrikeOutNote)) { [self addAnnotationFromSelectionWithType:annotationMode]; @@ -1797,7 +1797,7 @@ text = [[[page selectionForRect:bounds] string] stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines]; if ([[activeAnnotation type] isEqualToString:SKLineString] == NO) - [newAnnotation setContents:text]; + [newAnnotation setString:text]; [self addAnnotation:newAnnotation toPage:page]; [[self undoManager] setActionName:NSLocalizedString(@"Add Note", @"Undo action name")]; @@ -1921,7 +1921,7 @@ editField = [[NSTextField alloc] initWithFrame:editBounds]; [editField setBackgroundColor:color]; [editField setFont:[[NSFontManager sharedFontManager] convertFont:font toSize:[font pointSize] * [self scaleFactor]]]; - [editField setStringValue:[activeAnnotation contents]]; + [editField setStringValue:[activeAnnotation string]]; [editField setDelegate:self]; [[self documentView] addSubview:editField]; [editField selectText:self]; @@ -1934,8 +1934,8 @@ if (editField) { if ([[self window] firstResponder] == [editField currentEditor] && [[self window] makeFirstResponder:self] == NO) [[self window] endEditingFor:nil]; - if ([[editField stringValue] isEqualToString:[activeAnnotation contents]] == NO) - [activeAnnotation setContents:[editField stringValue]]; + if ([[editField stringValue] isEqualToString:[activeAnnotation string]] == NO) + [activeAnnotation setString:[editField stringValue]]; [editField removeFromSuperview]; [editField release]; editField = nil; @@ -2439,7 +2439,7 @@ [activeAnnotation setBounds:newBounds]; if ([[activeAnnotation type] isEqualToString:SKSquareString] || [[activeAnnotation type] isEqualToString:SKSquareString]) { NSString *selString = [[[[activeAnnotation page] selectionForRect:newBounds] string] stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines]; - [activeAnnotation setContents:selString]; + [activeAnnotation setString:selString]; } } } @@ -2685,7 +2685,7 @@ [activeAnnotation setBounds:newBounds]; if ([[activeAnnotation type] isEqualToString:SKSquareString] || [[activeAnnotation type] isEqualToString:SKSquareString]) { NSString *selString = [[[[activeAnnotation page] selectionForRect:newBounds] string] stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines]; - [activeAnnotation setContents:selString]; + [activeAnnotation setString:selString]; } } } @@ -2810,7 +2810,7 @@ [self removeAnnotation:newActiveAnnotation]; newActiveAnnotation = [[[SKPDFAnnotationMarkup alloc] initWithSelection:sel markupType:markupType] autorelease]; - [newActiveAnnotation setContents:[[sel string] stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines]]; + [newActiveAnnotation setString:[[sel string] stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines]]; [self addAnnotation:newActiveAnnotation toPage:page]; [[self undoManager] setActionName:NSLocalizedString(@"Join Notes", @"Undo action name")]; } Modified: trunk/Spanish.lproj/NoteWindow.nib/info.nib =================================================================== --- trunk/Spanish.lproj/NoteWindow.nib/info.nib 2007-10-30 10:49:51 UTC (rev 3095) +++ trunk/Spanish.lproj/NoteWindow.nib/info.nib 2007-10-30 11:54:58 UTC (rev 3096) @@ -11,6 +11,10 @@ </dict> <key>IBFramework Version</key> <string>446.1</string> + <key>IBOpenObjects</key> + <array> + <integer>7</integer> + </array> <key>IBSystem Version</key> <string>8R218</string> </dict> Modified: trunk/Spanish.lproj/NoteWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/notesTemplate.rtf =================================================================== --- trunk/notesTemplate.rtf 2007-10-30 10:49:51 UTC (rev 3095) +++ trunk/notesTemplate.rtf 2007-10-30 11:54:58 UTC (rev 3096) @@ -6,10 +6,10 @@ \f0\fs24 \cf0 <[EMAIL PROTECTED]>\ \'a5 <$type.typeName/>, page <$pageIndex.numberByAddingOne/>\ \ -<$contents?>\ -<$contents/>\ +<$string?>\ +<$string/>\ \ -</$contents?>\ +</$string?>\ <$text?>\ <$text/>\ \ Modified: trunk/notesTemplate.rtfd/TXT.rtf =================================================================== --- trunk/notesTemplate.rtfd/TXT.rtf 2007-10-30 10:49:51 UTC (rev 3095) +++ trunk/notesTemplate.rtfd/TXT.rtf 2007-10-30 11:54:58 UTC (rev 3096) @@ -13,10 +13,10 @@ \f2\i \'a5 <$type.typeName/>, page <$pageIndex.numberByAddingOne/>\ \f1\i0 \ -<$contents?>\ -<$contents/>\ +<$string?>\ +<$string/>\ \ -</$contents?>\ +</$string?>\ <$text?>\ <$text/>\ \ Modified: trunk/notesTemplate.txt =================================================================== --- trunk/notesTemplate.txt 2007-10-30 10:49:51 UTC (rev 3095) +++ trunk/notesTemplate.txt 2007-10-30 11:54:58 UTC (rev 3096) @@ -1,10 +1,10 @@ <[EMAIL PROTECTED]> * <$type.typeName/>, page <$pageIndex.numberByAddingOne/> -<$contents?> -<$contents/> +<string?> +<string/> -</$contents?> +</string?> <$text?> <$text/> 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: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit