Revision: 4781
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4781&view=rev
Author:   hofman
Date:     2008-10-12 22:13:04 +0000 (Sun, 12 Oct 2008)

Log Message:
-----------
Use a custom object class wrapping the dictionary for notes in notes document.

Modified Paths:
--------------
    trunk/SKMainWindowController.m
    trunk/SKMainWindowController_UI.m
    trunk/SKNPDFAnnotationNote_SKExtensions.h
    trunk/SKNPDFAnnotationNote_SKExtensions.m
    trunk/SKNotesDocument.h
    trunk/SKNotesDocument.m
    trunk/Skim.xcodeproj/project.pbxproj

Added Paths:
-----------
    trunk/SKNote.h
    trunk/SKNote.m
    trunk/SKNoteText.h
    trunk/SKNoteText.m

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2008-10-12 21:14:01 UTC (rev 4780)
+++ trunk/SKMainWindowController.m      2008-10-12 22:13:04 UTC (rev 4781)
@@ -60,6 +60,7 @@
 #import <SkimNotes/SkimNotes.h>
 #import "PDFAnnotation_SKExtensions.h"
 #import "SKNPDFAnnotationNote_SKExtensions.h"
+#import "SKNoteText.h"
 #import "SKPDFAnnotationTemporary.h"
 #import "SKSplitView.h"
 #import "NSScrollView_SKExtensions.h"
@@ -1136,7 +1137,7 @@
     while (row != NSNotFound) {
         item = [noteOutlineView itemAtRow:row];
         if ([item type] == nil)
-            item = [(SKNoteText *)item annotation];
+            item = [(SKNoteText *)item note];
         if ([selectedNotes containsObject:item] == NO)
             [selectedNotes addObject:item];
         row = [rowIndexes indexGreaterThanIndex:row];

Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m   2008-10-12 21:14:01 UTC (rev 4780)
+++ trunk/SKMainWindowController_UI.m   2008-10-12 22:13:04 UTC (rev 4781)
@@ -54,6 +54,7 @@
 #import <SkimNotes/SkimNotes.h>
 #import "PDFAnnotation_SKExtensions.h"
 #import "SKNPDFAnnotationNote_SKExtensions.h"
+#import "SKNoteText.h"
 #import "SKPDFToolTipWindow.h"
 #import "SKPDFDocument.h"
 #import "PDFPage_SKExtensions.h"
@@ -583,7 +584,7 @@
         if ([[tableColumn identifier] 
isEqualToString:SKMainWindowNoteColumnIdentifer]) {
             if ([item type] == nil) {
                 if ([pdfView hideNotes] == NO) {
-                    PDFAnnotation *annotation = [(SKNoteText *)item 
annotation];
+                    PDFAnnotation *annotation = [(SKNoteText *)item note];
                     [pdfView scrollAnnotationToVisible:annotation];
                     [pdfView setActiveAnnotation:annotation];
                     [self showNote:annotation];
@@ -697,7 +698,7 @@
     
     while (item = [itemEnum nextObject]) {
         if ([item type] == nil) {
-            item = [(SKNoteText *)item annotation];
+            item = [(SKNoteText *)item note];
         }
         if ([noteItems containsObject:item] == NO)
             [noteItems addObject:item];

Modified: trunk/SKNPDFAnnotationNote_SKExtensions.h
===================================================================
--- trunk/SKNPDFAnnotationNote_SKExtensions.h   2008-10-12 21:14:01 UTC (rev 
4780)
+++ trunk/SKNPDFAnnotationNote_SKExtensions.h   2008-10-12 22:13:04 UTC (rev 
4781)
@@ -55,23 +55,3 @@
 @interface SKNPDFAnnotationNote (SKExtensions)
 - (void)setRichText:(id)newText;
 @end
-
-#pragma mark -
-
[EMAIL PROTECTED] SKNoteText : NSObject {
-    PDFAnnotation *annotation;
-}
-
-- (id)initWithAnnotation:(PDFAnnotation *)anAnnotation;
-
-- (PDFAnnotation *)annotation;
-
-- (NSArray *)texts;
-
-- (NSString *)type;
-- (PDFPage *)page;
-- (unsigned int)pageIndex;
-- (NSString *)string;
-- (NSAttributedString *)text;
-
[EMAIL PROTECTED]

Modified: trunk/SKNPDFAnnotationNote_SKExtensions.m
===================================================================
--- trunk/SKNPDFAnnotationNote_SKExtensions.m   2008-10-12 21:14:01 UTC (rev 
4780)
+++ trunk/SKNPDFAnnotationNote_SKExtensions.m   2008-10-12 22:13:04 UTC (rev 
4781)
@@ -45,6 +45,7 @@
 #import "NSUserDefaults_SKExtensions.h"
 #import "NSGeometry_SKExtensions.h"
 #import "NSString_SKExtensions.h"
+#import "SKNoteText.h"
 
 
 NSString *SKPDFAnnotationRichTextKey = @"richText";
@@ -59,7 +60,7 @@
         textStorage = [[NSTextStorage allocWithZone:[self zone]] init];
         [textStorage setDelegate:self];
         text = [[NSAttributedString alloc] init];
-        texts = [[NSArray alloc] initWithObjects:[[[SKNoteText alloc] 
initWithAnnotation:self] autorelease], nil];
+        texts = [[NSArray alloc] initWithObjects:[[[SKNoteText alloc] 
initWithNote:self] autorelease], nil];
     }
     return self;
 }
@@ -158,32 +159,3 @@
 }
 
 @end
-
-#pragma mark -
-
[EMAIL PROTECTED] SKNoteText
-
-- (id)initWithAnnotation:(PDFAnnotation *)anAnnotation {
-    if (self = [super init]) {
-        annotation = anAnnotation;
-    }
-    return self;
-}
-
-- (PDFAnnotation *)annotation {
-    return annotation;
-}
-
-- (NSArray *)texts { return nil; }
-
-- (NSString *)type { return nil; }
-
-- (PDFPage *)page { return nil; }
-
-- (NSString *)string { return [[self text] string]; }
-
-- (unsigned int)pageIndex { return [annotation pageIndex]; }
-
-- (NSAttributedString *)text { return [annotation text]; }
-
[EMAIL PROTECTED]

Added: trunk/SKNote.h
===================================================================
--- trunk/SKNote.h                              (rev 0)
+++ trunk/SKNote.h      2008-10-12 22:13:04 UTC (rev 4781)
@@ -0,0 +1,34 @@
+//
+//  SKNote.h
+//  Skim
+//
+//  Created by Christiaan Hofman on 12/10/08.
+//  Copyright 2008 Christiaan Hofman. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+
[EMAIL PROTECTED] SKNote : NSObject {
+    NSDictionary *properties;
+    NSString *type;
+    NSString *contents;
+    NSArray *texts;
+}
+
+- (id)initWithSkimNoteProperties:(NSDictionary *)aProperties;
+
+- (NSDictionary *)SkimNoteProperties;
+
+- (NSString *)type;
+- (NSRect)bounds;
+- (NSString *)contents;
+- (unsigned int)pageIndex;
+- (NSString *)string;
+- (NSAttributedString *)text;
+
+- (id)page;
+
+- (NSArray *)texts;
+
[EMAIL PROTECTED]

Added: trunk/SKNote.m
===================================================================
--- trunk/SKNote.m                              (rev 0)
+++ trunk/SKNote.m      2008-10-12 22:13:04 UTC (rev 4781)
@@ -0,0 +1,86 @@
+//
+//  SKNote.m
+//  Skim
+//
+//  Created by Christiaan Hofman on 12/10/08.
+//  Copyright 2008 Christiaan Hofman. All rights reserved.
+//
+
+#import "SKNote.h"
+#import <SkimNotes/SkimNotes.h>
+#import "SKNoteText.h"
+
[EMAIL PROTECTED] SKNote
+
+
+- (id)initWithSkimNoteProperties:(NSDictionary *)aProperties {
+    if (self = [super init]) {
+        properties = [aProperties copy];
+        type = [properties valueForKey:SKNPDFAnnotationTypeKey];
+        if ([type isEqualToString:SKNTextString])
+            type = SKNNoteString;
+        if ([type isEqualToString:SKNNoteString])
+            texts = [[NSArray alloc] initWithObjects:[[[SKNoteText alloc] 
initWithNote:self] autorelease], nil];
+        NSMutableString *mutableContents = [[NSMutableString alloc] init];
+        if ([[aProperties valueForKey:SKNPDFAnnotationContentsKey] length])
+            [mutableContents appendString:[aProperties 
valueForKey:SKNPDFAnnotationContentsKey]];
+        if ([[aProperties valueForKey:SKNPDFAnnotationTextKey] length]) {
+            [mutableContents appendString:@"  "];
+            [mutableContents appendString:[[aProperties 
valueForKey:SKNPDFAnnotationTextKey] string]];
+        }
+        contents = [mutableContents copy];
+        [mutableContents release];
+    }
+    return self;
+}
+
+- (void)dealloc {
+    [properties release];
+    [type release];
+    [contents release];
+    [texts release];
+    [super dealloc];
+}
+
+- (NSDictionary *)SkimNoteProperties {
+    return properties;
+}
+
+- (NSString *)type {
+    return type;
+}
+
+- (NSRect)bounds {
+    return NSRectFromString([properties 
valueForKey:SKNPDFAnnotationBoundsKey]);
+}
+
+- (unsigned int)pageIndex {
+    return [[properties valueForKey:SKNPDFAnnotationPageIndexKey] 
unsignedIntValue];
+}
+
+- (NSString *)contents {
+    return contents;
+}
+
+- (NSString *)string {
+    return [properties valueForKey:SKNPDFAnnotationContentsKey];
+}
+
+- (NSAttributedString *)text {
+    return [properties valueForKey:SKNPDFAnnotationTextKey];
+}
+
+- (id)page {
+    unsigned int pageIndex = [self pageIndex];
+    return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber 
numberWithUnsignedInt:pageIndex], @"pageIndex", [NSString 
stringWithFormat:@"%u", pageIndex + 1], @"label", nil];
+}
+
+- (NSArray *)texts {
+    return texts;
+}
+
+- (id)valueForUndefinedKey:(NSString *)key {
+    return [properties valueForKey:key];
+}
+
[EMAIL PROTECTED]

Added: trunk/SKNoteText.h
===================================================================
--- trunk/SKNoteText.h                          (rev 0)
+++ trunk/SKNoteText.h  2008-10-12 22:13:04 UTC (rev 4781)
@@ -0,0 +1,58 @@
+//
+//  SKNoteText.h
+//  Skim
+//
+//  Created by Christiaan Hofman on 10/12/08.
+/*
+ This software is Copyright (c) 2007-2008
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+
[EMAIL PROTECTED] SKNoteText : NSObject {
+    id note;
+}
+
+- (id)initWithNote:(id)aNote;
+
+- (id)note;
+
+- (NSArray *)texts;
+
+- (NSString *)type;
+- (id)page;
+- (unsigned int)pageIndex;
+- (NSString *)string;
+- (NSAttributedString *)text;
+
[EMAIL PROTECTED]

Added: trunk/SKNoteText.m
===================================================================
--- trunk/SKNoteText.m                          (rev 0)
+++ trunk/SKNoteText.m  2008-10-12 22:13:04 UTC (rev 4781)
@@ -0,0 +1,67 @@
+//
+//  SKNoteText.m
+//  Skim
+//
+//  Created by Christiaan Hofman on 10/12/08.
+/*
+ This software is Copyright (c) 2007-2008
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "SKNoteText.h"
+
+
[EMAIL PROTECTED] SKNoteText
+
+- (id)initWithNote:(id)aNote {
+    if (self = [super init]) {
+        note = aNote;
+    }
+    return self;
+}
+
+- (id)note {
+    return note;
+}
+
+- (NSArray *)texts { return nil; }
+
+- (NSString *)type { return nil; }
+
+- (id)page { return nil; }
+
+- (NSString *)string { return [[self text] string]; }
+
+- (unsigned int)pageIndex { return [note pageIndex]; }
+
+- (NSAttributedString *)text { return [note text]; }
+
[EMAIL PROTECTED]

Modified: trunk/SKNotesDocument.h
===================================================================
--- trunk/SKNotesDocument.h     2008-10-12 21:14:01 UTC (rev 4780)
+++ trunk/SKNotesDocument.h     2008-10-12 22:13:04 UTC (rev 4781)
@@ -47,6 +47,7 @@
     IBOutlet NSSearchField *searchField;
     NSMutableDictionary *toolbarItems;
     NSMutableArray *notes;
+    CFMutableDictionaryRef rowHeights;
     BOOL exportUsingPanel;
 }
 

Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m     2008-10-12 21:14:01 UTC (rev 4780)
+++ trunk/SKNotesDocument.m     2008-10-12 22:13:04 UTC (rev 4781)
@@ -46,7 +46,8 @@
 #import "NSString_SKExtensions.h"
 #import "SKTypeSelectHelper.h"
 #import <SkimNotes/SkimNotes.h>
-#import "SKNPDFAnnotationNote_SKExtensions.h"
+#import "SKNote.h"
+#import "SKNoteText.h"
 #import "SKStringConstants.h"
 #import "SKFDFParser.h"
 #import "SKStatusBar.h"
@@ -57,6 +58,8 @@
 #import "Files_SKExtensions.h"
 #import "BDSKPrintableView.h"
 #import "SKToolbarItem.h"
+#import "SKCFCallbacks.h"
+#import "SKAnnotationTypeImageCell.h"
 
 static NSString *SKNotesDocumentWindowFrameAutosaveName = 
@"SKNotesDocumentWindow";
 
@@ -66,9 +69,6 @@
 
 static NSString *SKLastExportedNotesTypeKey = @"SKLastExportedNotesType";
 
-static NSString *SKNotesDocumentRowHeightKey = @"rowHeight";
-static NSString *SKNotesDocumentChildKey = @"child";
-
 static NSString *SKNotesDocumentNotesKey = @"notes";
 
 static NSString *SKNotesDocumentNoteColumnIdentifier = @"note";
@@ -80,12 +80,14 @@
 - (id)init {
     if (self = [super init]) {
         notes = [[NSMutableArray alloc] initWithCapacity:10];
+        rowHeights = CFDictionaryCreateMutable(NULL, 0, 
&kSKPointerEqualObjectDictionaryKeyCallBacks, 
&kSKFloatDictionaryValueCallBacks);
     }
     return self;
 }
 
 - (void)dealloc {
     [notes release];
+       CFRelease(rowHeights);
     [toolbarItems release];
     [statusBar release];
     [super dealloc];
@@ -196,20 +198,7 @@
     NSData *data = nil;
     
     if (SKIsNotesDocumentType(typeName)) {
-        NSMutableArray *array = [NSMutableArray arrayWithCapacity:[notes 
count]];
-        NSEnumerator *noteEnum = [notes objectEnumerator];
-        NSMutableDictionary *note;
-        while (note = [noteEnum nextObject]) {
-            note = [note mutableCopy];
-            [note setValue:[note valueForKey:SKNPDFAnnotationStringKey] 
forKey:SKNPDFAnnotationContentsKey];
-            [note removeObjectForKey:SKNPDFAnnotationStringKey];
-            [note removeObjectForKey:SKNPDFAnnotationPageKey];
-            [note removeObjectForKey:SKNotesDocumentRowHeightKey];
-            [note removeObjectForKey:SKNotesDocumentChildKey];
-            [array addObject:note];
-            [note release];
-        }
-        data = [NSKeyedArchiver archivedDataWithRootObject:array];
+        data = [NSKeyedArchiver archivedDataWithRootObject:[notes 
valueForKey:@"SkimNoteProperties"]];
     } else if (SKIsNotesRTFDocumentType(typeName)) {
         data = [self notesRTFData];
     } else if (SKIsNotesTextDocumentType(typeName)) {
@@ -239,27 +228,7 @@
         NSMutableArray *newNotes = [NSMutableArray arrayWithCapacity:[array 
count]];
         
         while (dict = [dictEnum nextObject]) {
-            NSMutableDictionary *note = [dict mutableCopy];
-            unsigned int pageIndex = [[dict valueForKey:@"pageIndex"] 
unsignedIntValue];
-            NSDictionary *pageDict = [NSDictionary 
dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:pageIndex], 
@"pageIndex", [NSString stringWithFormat:@"%u", pageIndex + 1], @"label", nil];
-            
-            [note setValue:[dict valueForKey:SKNPDFAnnotationContentsKey] 
forKey:SKNPDFAnnotationStringKey];
-            [note setValue:pageDict forKey:SKNPDFAnnotationPageKey];
-            if ([[note valueForKey:SKNPDFAnnotationTypeKey] 
isEqualToString:SKNTextString])
-                [note setValue:SKNNoteString forKey:SKNPDFAnnotationTypeKey];
-            if ([[note valueForKey:SKNPDFAnnotationTypeKey] 
isEqualToString:SKNNoteString]) {
-                [note setObject:[NSMutableDictionary 
dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:85.0], 
SKNotesDocumentRowHeightKey, [dict valueForKey:SKNPDFAnnotationTextKey], 
SKNPDFAnnotationTextKey, [[dict valueForKey:SKNPDFAnnotationTextKey] string], 
SKNPDFAnnotationStringKey, nil] forKey:SKNotesDocumentChildKey];
-                NSMutableString *contents = [[NSMutableString alloc] init];
-                if ([[dict valueForKey:SKNPDFAnnotationContentsKey] length])
-                    [contents appendString:[dict 
valueForKey:SKNPDFAnnotationContentsKey]];
-                if ([[dict valueForKey:SKNPDFAnnotationTextKey] length]) {
-                    [contents appendString:@"  "];
-                    [contents appendString:[[dict 
valueForKey:SKNPDFAnnotationTextKey] string]];
-                }
-                [note setValue:contents forKey:SKNPDFAnnotationContentsKey];
-                [contents release];
-            }
-            
+            SKNote *note = [[SKNote alloc] initWithSkimNoteProperties:dict];
             [newNotes addObject:note];
             [note release];
         }
@@ -376,7 +345,7 @@
     if (items == nil) {
         items = [NSMutableArray array];
         [(NSMutableArray *)items addObjectsFromArray:[self notes]];
-        [(NSMutableArray *)items addObjectsFromArray:[[self notes] 
valueForKey:SKNotesDocumentChildKey]];
+        [(NSMutableArray *)items addObjectsFromArray:[[self notes] 
valueForKeyPath:@"@unionOfArrays.texts"]];
         [(NSMutableArray *)items removeObject:[NSNull null]];
     }
     
@@ -384,10 +353,11 @@
     
     for (i = 0; i < count; i++) {
         id item = [items objectAtIndex:i];
-        [cell setObjectValue:[item valueForKey:([item 
valueForKey:SKNPDFAnnotationTypeKey] ? SKNPDFAnnotationStringKey : 
SKNPDFAnnotationTextKey)]];
+        [cell setObjectValue:[item type] ? (id)[item string] : (id)[item 
text]];
         NSAttributedString *attrString = [cell attributedStringValue];
-        NSRect rect = [attrString boundingRectWithSize:[item 
valueForKey:SKNPDFAnnotationTypeKey] ? size : smallSize 
options:NSStringDrawingUsesLineFragmentOrigin];
-        [item setValue:[NSNumber numberWithFloat:fmaxf(NSHeight(rect) + 3.0, 
rowHeight + 2.0)] forKey:SKNotesDocumentRowHeightKey];
+        NSRect rect = [attrString boundingRectWithSize:[item type] ? size : 
smallSize options:NSStringDrawingUsesLineFragmentOrigin];
+        float height = fmaxf(NSHeight(rect) + 3.0, rowHeight + 2.0);
+        CFDictionarySetValue(rowHeights, (const void *)item, &height);
     }
     // don't use noteHeightOfRowsWithIndexesChanged: as this only updates the 
visible rows and the scrollers
     [outlineView reloadData];
@@ -432,32 +402,30 @@
 - (int)outlineView:(NSOutlineView *)ov numberOfChildrenOfItem:(id)item {
     if (item == nil)
         return [[arrayController arrangedObjects] count];
-    else if ([[item valueForKey:SKNPDFAnnotationTypeKey] 
isEqualToString:SKNNoteString])
-        return 1;
-    return 0;
+    else
+        return [[item texts] count];
 }
 
 - (BOOL)outlineView:(NSOutlineView *)ov isItemExpandable:(id)item {
-    return [[item valueForKey:SKNPDFAnnotationTypeKey] 
isEqualToString:SKNNoteString];
+    return [[item texts] count] > 0;
 }
 
 - (id)outlineView:(NSOutlineView *)ov child:(int)anIndex ofItem:(id)item {
     if (item == nil) {
         return [[arrayController arrangedObjects] objectAtIndex:anIndex];
     } else {
-        return [item valueForKey:SKNotesDocumentChildKey];
+        return [[item texts] lastObject];
     }
 }
 
 - (id)outlineView:(NSOutlineView *)ov objectValueForTableColumn:(NSTableColumn 
*)tableColumn byItem:(id)item {
     NSString *tcID = [tableColumn identifier];
     if ([tcID isEqualToString:SKNotesDocumentNoteColumnIdentifier]) {
-        return [item valueForKey:([item valueForKey:SKNPDFAnnotationTypeKey] ? 
SKNPDFAnnotationStringKey : SKNPDFAnnotationTextKey)];
+        return [item type] ? (id)[item string] : (id)[item text];
     } else if([tcID isEqualToString:SKNotesDocumentTypeColumnIdentifier]) {
-        return [NSDictionary dictionaryWithObjectsAndKeys:[item 
valueForKey:SKNPDFAnnotationTypeKey], SKNPDFAnnotationTypeKey, nil];
+        return [NSDictionary dictionaryWithObjectsAndKeys:[item type], 
SKAnnotationTypeImageCellTypeKey, nil];
     } else if ([tcID isEqualToString:SKNotesDocumentPageColumnIdentifier]) {
-        NSNumber *pageNumber = [item valueForKey:SKNPDFAnnotationPageIndexKey];
-        return pageNumber ? [NSString stringWithFormat:@"%i", [pageNumber 
intValue] + 1] : nil;
+        return [item type] ? [NSString stringWithFormat:@"%u", [item 
pageIndex] + 1] : nil;
     }
     return nil;
 }
@@ -503,18 +471,18 @@
     NSMutableAttributedString *attrString = [[items 
valueForKey:SKNPDFAnnotationTypeKey] containsObject:[NSNull null]] ? 
[[[NSMutableAttributedString alloc] init] autorelease] : nil;
     NSMutableString *string = [NSMutableString string];
     NSEnumerator *itemEnum = [items objectEnumerator];
-    NSDictionary *item;
+    id item;
     
     while (item = [itemEnum nextObject]) {
         if ([string length])
             [string appendString:@"\n\n"];
         if ([attrString length])
             [attrString replaceCharactersInRange:NSMakeRange([attrString 
length], 0) withString:@"\n\n"];
-        [string appendString:[item valueForKey:SKNPDFAnnotationStringKey]];
-        if ([item valueForKey:SKNPDFAnnotationTypeKey])
-            [attrString replaceCharactersInRange:NSMakeRange([attrString 
length], 0) withString:[item valueForKey:SKNPDFAnnotationStringKey]];
+        [string appendString:[item string]];
+        if ([item type])
+            [attrString replaceCharactersInRange:NSMakeRange([attrString 
length], 0) withString:[item string]];
         else
-            [attrString appendAttributedString:[item 
valueForKey:SKNPDFAnnotationTextKey]];
+            [attrString appendAttributedString:[(SKNoteText *)item text]];
     }
     
     if ([string length])
@@ -534,20 +502,24 @@
 }
 
 - (float)outlineView:(NSOutlineView *)ov heightOfRowByItem:(id)item {
-    NSNumber *heightNumber = [item valueForKey:SKNotesDocumentRowHeightKey];
-    return heightNumber ? [heightNumber floatValue] : [item 
valueForKey:SKNPDFAnnotationTypeKey] ? [ov rowHeight] + 2.0 : 85.0;
+    float rowHeight = 0.0;
+    if (CFDictionaryContainsKey(rowHeights, (const void *)item))
+        rowHeight = *(float *)CFDictionaryGetValue(rowHeights, (const void 
*)item);
+    else if ([item type] == nil)
+        rowHeight = 85.0;
+    return rowHeight > 0.0 ? rowHeight : [ov rowHeight] + 2.0;
 }
 
-- (void)outlineView:(NSOutlineView *)ov setHeightOfRow:(float)newHeight 
byItem:(id)item {
-    [item setObject:[NSNumber numberWithFloat:newHeight] 
forKey:SKNotesDocumentRowHeightKey];
-}
-
 - (BOOL)outlineView:(NSOutlineView *)ov canResizeRowByItem:(id)item {
     return YES;
 }
 
+- (void)outlineView:(NSOutlineView *)ov setHeightOfRow:(float)newHeight 
byItem:(id)item {
+    CFDictionarySetValue(rowHeights, (const void *)item, &newHeight);
+}
+
 - (NSString *)outlineView:(NSOutlineView *)ov toolTipForCell:(NSCell *)cell 
rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tableColumn item:(id)item 
mouseLocation:(NSPoint)mouseLocation {
-    return [item valueForKey:SKNPDFAnnotationStringKey];
+    return [item string];
 }
 
 - (NSMenu *)outlineView:(NSOutlineView *)ov menuForTableColumn:(NSTableColumn 
*)tableColumn item:(id)item {
@@ -586,7 +558,7 @@
     NSMutableArray *texts = [NSMutableArray arrayWithCapacity:count];
     for (i = 0; i < count; i++) {
         id item = [outlineView itemAtRow:i];
-        NSString *string = [item valueForKey:SKNPDFAnnotationStringKey];
+        NSString *string = [item string];
         [texts addObject:string ?: @""];
     }
     return texts;

Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj        2008-10-12 21:14:01 UTC (rev 
4780)
+++ trunk/Skim.xcodeproj/project.pbxproj        2008-10-12 22:13:04 UTC (rev 
4781)
@@ -326,6 +326,10 @@
                CEAA56D50C6DEE83006BD633 /* Delete.tiff in Resources */ = {isa 
= PBXBuildFile; fileRef = CEAA56D30C6DEE83006BD633 /* Delete.tiff */; };
                CEAA67260C70A882006BD633 /* NSURL_SKExtensions.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CEAA67240C70A882006BD633 /* 
NSURL_SKExtensions.m */; };
                CEAA68EB0C71242F006BD633 /* Resume.tiff in Resources */ = {isa 
= PBXBuildFile; fileRef = CEAA68EA0C71242F006BD633 /* Resume.tiff */; };
+               CEAA8EF70EA2A14700C16FE4 /* SKNote.h in Headers */ = {isa = 
PBXBuildFile; fileRef = CEAA8EF50EA2A14700C16FE4 /* SKNote.h */; };
+               CEAA8EF80EA2A14700C16FE4 /* SKNote.m in Sources */ = {isa = 
PBXBuildFile; fileRef = CEAA8EF60EA2A14700C16FE4 /* SKNote.m */; };
+               CEAA8F2E0EA2A86200C16FE4 /* SKNoteText.h in Headers */ = {isa = 
PBXBuildFile; fileRef = CEAA8F2C0EA2A86200C16FE4 /* SKNoteText.h */; };
+               CEAA8F2F0EA2A86200C16FE4 /* SKNoteText.m in Sources */ = {isa = 
PBXBuildFile; fileRef = CEAA8F2D0EA2A86200C16FE4 /* SKNoteText.m */; };
                CEAE1C480CA1877F00849B0F /* SKSecondaryPDFView.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CEAE1C460CA1877F00849B0F /* 
SKSecondaryPDFView.m */; };
                CEAE38C40CA4399B00849B0F /* TransitionSheet.nib in Resources */ 
= {isa = PBXBuildFile; fileRef = CEAE38C20CA4399B00849B0F /* 
TransitionSheet.nib */; };
                CEAE39070CA43E7300849B0F /* SKSheetController.m in Sources */ = 
{isa = PBXBuildFile; fileRef = CEAE39050CA43E7300849B0F /* SKSheetController.m 
*/; };
@@ -915,6 +919,10 @@
                CEAA67230C70A882006BD633 /* NSURL_SKExtensions.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
NSURL_SKExtensions.h; sourceTree = "<group>"; };
                CEAA67240C70A882006BD633 /* NSURL_SKExtensions.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= NSURL_SKExtensions.m; sourceTree = "<group>"; };
                CEAA68EA0C71242F006BD633 /* Resume.tiff */ = {isa = 
PBXFileReference; lastKnownFileType = image.tiff; path = Resume.tiff; 
sourceTree = "<group>"; };
+               CEAA8EF50EA2A14700C16FE4 /* SKNote.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
SKNote.h; sourceTree = "<group>"; };
+               CEAA8EF60EA2A14700C16FE4 /* SKNote.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= SKNote.m; sourceTree = "<group>"; };
+               CEAA8F2C0EA2A86200C16FE4 /* SKNoteText.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
SKNoteText.h; sourceTree = "<group>"; };
+               CEAA8F2D0EA2A86200C16FE4 /* SKNoteText.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= SKNoteText.m; sourceTree = "<group>"; };
                CEAE1C450CA1877F00849B0F /* SKSecondaryPDFView.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
SKSecondaryPDFView.h; sourceTree = "<group>"; };
                CEAE1C460CA1877F00849B0F /* SKSecondaryPDFView.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= SKSecondaryPDFView.m; sourceTree = "<group>"; };
                CEAE38C30CA4399B00849B0F /* English */ = {isa = 
PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = 
English.lproj/TransitionSheet.nib; sourceTree = "<group>"; };
@@ -1470,6 +1478,10 @@
                                CECB03D20DC7503A0000B16B /* 
SKGroupedSearchResult.m */,
                                CEAF2E570C45414100C3ECBB /* SKLine.h */,
                                CEAF2E580C45414100C3ECBB /* SKLine.m */,
+                               CEAA8EF50EA2A14700C16FE4 /* SKNote.h */,
+                               CEAA8EF60EA2A14700C16FE4 /* SKNote.m */,
+                               CEAA8F2C0EA2A86200C16FE4 /* SKNoteText.h */,
+                               CEAA8F2D0EA2A86200C16FE4 /* SKNoteText.m */,
                                CE4294A10BBD29120016FDC2 /* SKReadingBar.h */,
                                CE4294A20BBD29120016FDC2 /* SKReadingBar.m */,
                                CE2DE4900B85D48F00D0DA12 /* SKThumbnail.h */,
@@ -1925,6 +1937,8 @@
                                CE05A86E0E90ED950060BB07 /* 
SKTextFieldSheetController.h in Headers */,
                                CE9AFFF40E991AEC00FE1497 /* BDSKPrintableView.h 
in Headers */,
                                CE9AFFF60E991B0E00FE1497 /* MultiplePageView.h 
in Headers */,
+                               CEAA8EF70EA2A14700C16FE4 /* SKNote.h in Headers 
*/,
+                               CEAA8F2E0EA2A86200C16FE4 /* SKNoteText.h in 
Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
@@ -2430,6 +2444,8 @@
                                CE05A86F0E90ED950060BB07 /* 
SKTextFieldSheetController.m in Sources */,
                                CE9AFFF00E991ACD00FE1497 /* MultiplePageView.m 
in Sources */,
                                CE9AFFF20E991AD500FE1497 /* BDSKPrintableView.m 
in Sources */,
+                               CEAA8EF80EA2A14700C16FE4 /* SKNote.m in Sources 
*/,
+                               CEAA8F2F0EA2A86200C16FE4 /* SKNoteText.m in 
Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };


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 Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to