Revision: 2273
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2273&view=rev
Author:   hofman
Date:     2007-06-11 13:30:01 -0700 (Mon, 11 Jun 2007)

Log Message:
-----------
Evaluate specifier for selection properties. Hack to be able to add new markups 
from selection to a document. 

Modified Paths:
--------------
    trunk/PDFPage_SKExtensions.m
    trunk/PDFSelection_SKExtensions.m
    trunk/SKDocument.m
    trunk/SKPDFAnnotationNote.m

Modified: trunk/PDFPage_SKExtensions.m
===================================================================
--- trunk/PDFPage_SKExtensions.m        2007-06-11 19:39:03 UTC (rev 2272)
+++ trunk/PDFPage_SKExtensions.m        2007-06-11 20:30:01 UTC (rev 2273)
@@ -302,9 +302,6 @@
     
     [pdfView addAnnotation:newNote toPage:self];
     [[pdfView undoManager] setActionName:NSLocalizedString(@"Add Note", @"Undo 
action name")];
-    
-    [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewDidAddAnnotationNotification object:pdfView 
-        userInfo:[NSDictionary dictionaryWithObjectsAndKeys:newNote, 
@"annotation", self, @"page", nil]];
 }
 
 - (void)insertInNotes:(id)newNote atIndex:(unsigned int)index {

Modified: trunk/PDFSelection_SKExtensions.m
===================================================================
--- trunk/PDFSelection_SKExtensions.m   2007-06-11 19:39:03 UTC (rev 2272)
+++ trunk/PDFSelection_SKExtensions.m   2007-06-11 20:30:01 UTC (rev 2273)
@@ -119,6 +119,8 @@
         return nil;
     if ([specifier isKindOfClass:[NSArray class]] == NO)
         specifier = [NSArray arrayWithObject:specifier];
+    else if ([specifier count] == 1 && [[specifier objectAtIndex:0] 
isKindOfClass:[NSPropertySpecifier class]])
+        specifier = [[specifier objectAtIndex:0] objectsByEvaluatingSpecifier];
     
     PDFSelection *selection = nil;
     NSEnumerator *specEnum = [specifier objectEnumerator];

Modified: trunk/SKDocument.m
===================================================================
--- trunk/SKDocument.m  2007-06-11 19:39:03 UTC (rev 2272)
+++ trunk/SKDocument.m  2007-06-11 20:30:01 UTC (rev 2273)
@@ -906,6 +906,20 @@
     return [[self mainWindowController] notes];
 }
 
+- (void)insertInNotes:(id)newNote {
+    PDFPage *page = [newNote page];
+    if (page && [[page annotations] containsObject:newNote] == NO) {
+        SKPDFView *pdfView = [self pdfView];
+        
+        [pdfView addAnnotation:newNote toPage:page];
+        [[self undoManager] setActionName:NSLocalizedString(@"Add Note", 
@"Undo action name")];
+    }
+}
+
+- (void)insertInNotes:(id)newNote atIndex:(unsigned int)index {
+    [self insertInNotes:newNote];
+}
+
 - (void)removeFromNotesAtIndex:(unsigned int)index {
     PDFAnnotation *note = [[self notes] objectAtIndex:index];
     

Modified: trunk/SKPDFAnnotationNote.m
===================================================================
--- trunk/SKPDFAnnotationNote.m 2007-06-11 19:39:03 UTC (rev 2272)
+++ trunk/SKPDFAnnotationNote.m 2007-06-11 20:30:01 UTC (rev 2273)
@@ -249,7 +249,7 @@
 #pragma mark Scripting support
 
 - (id)init {
-    //[[super init] release];
+    [[self initWithBounds:NSZeroRect] release];
     self = nil;
     NSScriptCommand *currentCommand = [NSScriptCommand currentCommand];
     if ([currentCommand isKindOfClass:[NSCreateCommand class]]) {
@@ -278,7 +278,11 @@
                         markupType = kPDFMarkupTypeStrikeOut;
                     else if (type == SKASStrikeOutNote)
                         markupType = kPDFMarkupTypeUnderline;
-                    self = [[SKPDFAnnotationMarkup alloc] 
initWithSelection:selection markupType:markupType];
+                    if (self = [[SKPDFAnnotationMarkup alloc] 
initWithSelection:selection markupType:markupType]) {
+                        PDFPage *page = [[selection pages] objectAtIndex:0];
+                        if (page && [self 
respondsToSelector:@selector(setPage:)])
+                            [self performSelector:@selector(setPage:) 
withObject:page];
+                    }
                 }
             } else {
                 if (type == SKASTextNote)
@@ -525,7 +529,7 @@
 }
 
 - (id)initWithSelection:(PDFSelection *)selection markupType:(int)type {
-    NSRect bounds = selection ? [selection boundsForPage:[[selection pages] 
objectAtIndex:0]] : NSZeroRect;
+    NSRect bounds = [[selection pages] count] ? [selection 
boundsForPage:[[selection pages] objectAtIndex:0]] : NSZeroRect;
     if (selection == nil || NSIsEmptyRect(bounds)) {
         [[self initWithBounds:NSZeroRect] release];
         self = 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 DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to